Library firstorder
Quantifiers
Variable T : Type.
Variable P : T -> Prop.
Variable Q : Prop.
Variable R : T -> T -> Prop.
Goal (exists x:T, forall y:T, R x y)
-> (forall y:T, exists x:T, R x y).
Proof.
intros H y.
destruct H.
exists x.
apply H.
Qed.
Goal (exists x:T, P x \/ Q) -> ((exists x:T, P x) \/ Q).
Proof.
intros. destruct H. destruct H.
+ left. exists x. exact H.
+ right. exact H.
Qed.
For the next result, we need to be able to introduce an
existential with an arbitrary term. This is not allowed in Coq,
where types may be empty. We thus postulate the existence of
at least one element in T.
Variable f : T -> T.
Goal forall x y : T, x = y -> f x = f y.
Proof.
intros x y Heq.
rewrite Heq.
reflexivity.
Qed.
Goal forall x y : T, x = y -> P y -> P x.
Proof.
intros x y Heq H.
rewrite Heq.
exact H.
Qed.
Goal forall x y : T, forall z:T,
x = y -> f y = z -> P (f x) -> P z.
Proof.
intros x y z Hxy Hfyz H.
rewrite<- Hxy in Hfyz.
rewrite Hfyz in H.
exact H.
Qed.
Symmetry and transitivity are consequences of the substitution
principle embodied by the rewrite tactic: prove it!
Lemma symmetry : forall x y : T, x = y -> y = x.
Proof.
admit.
Qed.
Lemma transitivity : forall x y z : T, x = y -> y = z -> x = z.
Proof.
admit.
Qed.
Functions
Module Functions.
Variable A : Type.
Definition injective (f:A->A) :=
forall x:A, forall y:A, f x = f y -> x = y.
Definition surjective (f:A->A) :=
forall x:A, exists y:A, x = f y.
Definition bijective (f:A->A) := injective f /\ surjective f.
Definition involutive (f:A->A) := forall x:A, f (f x) = x.
Theorem inv_bij : forall (f:A->A), involutive f -> bijective f.
Proof.
admit.
Qed.
End Functions.
Drinker's paradox
Assume a non-empty bar, and a predicate indicating
which persons in the bar drink.
You can use any of the two equivalent axioms.
You probably want to use LEM first, then try using only RAA
for added difficulty.