Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last problem on morecoq.v #3

Open
sven-- opened this issue Jul 5, 2014 · 1 comment
Open

Last problem on morecoq.v #3

sven-- opened this issue Jul 5, 2014 · 1 comment
Labels

Comments

@sven--
Copy link
Owner

sven-- commented Jul 5, 2014

This looks quite simple logically but I cannot reduce it. Help!

@jeehoonkang
Copy link
Collaborator

Not sure where you have troubles with. So I paste my solution here:

Fixpoint forallb (A:Type) (P: forall (a:A), bool) (l: list A): bool :=
match l with
| nil => true
| a::l => andb (P a) (forallb _ P l)
end.

Fixpoint existsb (A:Type) (P: forall (a:A), bool) (l: list A): bool :=
match l with
| nil => false
| a::l => orb (P a) (existsb _ P l)
end.

Definition existsb' (A:Type) (P:forall (a:A), bool) (l: list A) :=
negb (forallb _ (fun a => negb (P a)) l).

Lemma negb_andb a b:
negb (andb a b) = orb (negb a) (negb b).
Proof.
destruct a, b; auto.
Qed.

Lemma existsb_existsb' (A:Type) (P: forall (a:A), bool) (l: list A):
existsb _ P l = existsb' _ P l.
Proof.
induction l; simpl in *; auto.
unfold existsb'. simpl.
rewrite negb_andb. rewrite negb_involutive.
unfold existsb' in IHl. rewrite <- IHl.
auto.
Qed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants