Goal ∀ (X : Type) (x y : X), x=y → y=x.
Proof. intros X x y A. rewrite A. reflexivity. Qed.
(* Exercise 2.2.1 *)
Goal ∀ x y, andb x y = true → x = true.
Abort.
Goal ∀ X Y : Prop, X → (X → Y) → Y.
Proof. intros X Y x A. exact (A x). Qed.
Goal ∀ X Y Z : Prop, (X → Y) → (Y → Z) → X → Z.
Proof. intros X Y Z A B x. exact (B (A x)). Qed.
(* Exercise 2.2.2 *)
Goal ∀ (X: Prop) (x y z: X),
x = y → y = z → x = z.
Abort.
Goal ∀ X Y Z : Prop, (X → Y) → (Y → Z) → X → Z.
Proof. intros X Y Z A B x. apply B. apply A. exact x. Qed.
Goal ∀ p q : nat → Prop, p 7 → (∀ x, p x → q x) → q 7.
Proof. intros p q A B. apply B. exact A. Qed.
(* Exercise 2.4.1 *)
Goal ∀ X Y, (∀ Z, (X → Y → Z) → Z) → X.
Abort.
Goal ∀ X Y, (∀ Z, (X → Y → Z) → Z) → Y.
Abort.
(* Exercise 2.4.2 *)
Goal ∀ (p : bool → Prop) (x : bool),
p true → p false → p x.
Abort.
Goal ∀ (p : nat → Prop) (x : nat),
p O → (∀ n, p n → p (S n)) → p x.
Abort.
Goal ∀ (X : Type) (p : list X → Prop) (xs : list X),
p nil → (∀ x xs, p xs → p (cons x xs)) → p xs.
Abort.
Goal ∀ (X : Type) (x y : X),
(∀ p : X → Prop, p x → p y) → x=y.
Proof. intros X x y A. apply (A (fun z ⇒ x=z)). reflexivity. Qed.
(* Exercise 2.5.1 *)
Goal ∀ (X : Type) (x y : X),
x=y → ∀ p : X → Prop, p x → p y.
Abort.
Goal ∀ (X : Type) (x y : X),
(∀ p : X → Prop, p x → p y) →
∀ p : X → Prop, p y → p x.
Abort.
(* Exercise 2.6.1 *)
Goal ∀ X : Type,
(fun x : X ⇒ x) = (fun y : X ⇒ y).
Abort.
Goal ∀ X Y : Prop,
(X → Y) → ∀ x : X, Y.
Abort.
Goal ∀ X Y : Prop,
(∀ x : X, Y) → X → Y.
Abort.
Goal ∀ X Y : Prop,
(X → Y) = (∀ x : X, Y).
Abort.
Goal False → 2=3.
Proof. intros A. contradiction A. Qed.
Goal ∀ X : Prop, X → ~~ X.
Proof. intros X x A. exact (A x). Qed.
Goal ∀ X : Prop,
(X → ¬ X) → (¬ X → X) → False.
Proof.
intros X A B. apply A.
- apply B. intros x. exact (A x x).
- apply B. intros x. exact (A x x).
Qed.
Goal ∀ X : Prop,
~~ X → (X → ¬ X) → X.
Proof. intros X A B. exfalso. apply A. intros x. exact (B x x). Qed.
(* Exercise 2.7.1 *)
Goal ∀ X : Prop, ~~~ X → ¬ X.
Abort.
Goal ∀ X Y : Prop, (X → Y) → ¬ Y → ¬ X.
Abort.
(* Exercise 2.7.2 *)
Goal ∀ X : Prop, ~~ (~~ X → X).
Abort.
Goal ∀ X Y : Prop, ~~ (((X → Y) → X) → X).
Abort.
(* Exercise 2.7.3 *)
Goal ∀ X:Prop,
(X → False) → (¬ X → False) → False.
Abort.
Goal ∀ X Y : Prop, X ∧ Y → Y ∧ X.
Proof.
intros X Y A. destruct A as [x y]. split.
- exact y.
- exact x.
Qed.
Goal ∀ X Y : Prop, X ∨ Y → Y ∨ X.
Proof.
intros X Y A. destruct A as [x|y].
- right. exact x.
- left. exact y.
Qed.
Goal ∀ X Y : Prop, X ∧ Y → Y ∧ X.
Proof.
intros X Y [x y]. split.
- exact y.
- exact x.
Qed.
Goal ∀ X Y : Prop, X ∨ Y → Y ∨ X.
Proof.
intros X Y [x|y].
- right. exact x.
- left. exact y.
Qed.
Goal ∀ X Y Z : Prop,
X ∨ (Y ∧ Z) → (X ∨ Y) ∧ (X ∨ Z).
Proof.
intros X Y Z [x|[y z]].
- split; left; exact x.
- split; right.
+ exact y.
+ exact z.
Qed.
(* Exercise 2.8.1 *)
Goal ∀ X : Prop,
¬ (X ∨ ¬ X) → X ∨ ¬ X.
Abort.
Goal ∀ X : Prop,
(X ∨ ¬ X → ¬ (X ∨ ¬ X)) → X ∨ ¬ X.
Abort.
Goal ∀ X Y Z W : Prop,
(X → Y) ∨ (X → Z) → (Y → W) ∧ (Z → W) → X → W.
Abort.
(* Exercise 2.8.2 *)
Goal ∀ X : Prop, ~~ (X ∨ ¬ X).
Abort.
Goal ∀ X Y : Prop, ~~ ((X → Y) → ¬ X ∨ Y).
Abort.
Lemma and_com : ∀ X Y : Prop, X ∧ Y ↔ Y ∧ X.
Proof.
intros X Y. split.
- intros [x y]. split.
+ exact y.
+ exact x.
- intros [y x]. split.
+ exact x.
+ exact y.
Qed.
Lemma deMorgan : ∀ X Y : Prop, ¬ (X ∨ Y) ↔ ¬ X ∧ ¬ Y.
Proof.
intros X Y. split.
- intros A. split.
+ intros x. apply A. left. exact x.
+ intros y. apply A. right. exact y.
- intros [A B] [x|y].
+ exact (A x).
+ exact (B y).
Qed.
Goal ∀ X Y Z W : Prop, (X ↔ Y) → (Z ↔ W) → (X ∧ Z ↔ Y ∧ W).
Abort.
(* Allows us to use setoid-rewriting *)
Require Import Setoid.
Goal ∀ X Y Z : Prop, ¬ (X ∨ Y) ∧ Z ↔ Z ∧ ¬ X ∧ ¬ Y.
Proof.
intros X Y Z.
setoid_rewrite deMorgan.
apply and_com.
Qed.
Goal ∀ X : Type, ∀ p q : X → Prop, (∀ x, ¬ (p x ∨ q x)) → ∀ x, ¬ p x ∧ ¬ q x.
Proof.
intros X p q A.
setoid_rewrite <- deMorgan.
exact A.
Qed.
Goal ∀ X : Prop, X ↔ X.
Proof. reflexivity. Qed.
Goal ∀ X Y : Prop, (X ↔ Y) → (Y ↔ X).
Proof. intros X Y A. symmetry. exact A. Qed.
Goal ∀ X Y Z : Prop, (X ↔ Y) → (Y ↔ Z) → (X ↔ Z).
Proof.
intros X Y Z A B. transitivity Y.
- exact A.
- exact B.
Qed.
(* Exercise 2.9.1 *)
Goal ∀ X : Prop, X ↔ X.
Abort.
Goal ∀ X Y : Prop, (X ↔ Y) → (Y ↔ X).
Abort.
Goal ∀ X Y Z : Prop, (X ↔ Y) → (Y ↔ Z) → (X ↔ Z).
Abort.
(* Exercise 2.9.2 *)
Goal ∀ (X Y Z W : Prop), (X ↔ Y) → (Z ↔ W) → (X ∧ Z ↔ Y ∧ W).
Abort.
Goal ∀ (X:Type) (p q:X → Prop), (∀ x:X, p x ↔ q x) → ((∀ x:X, p x) ↔ ∀ x:X, q x).
Abort.
(* Exercise 2.9.3 *)
Goal ∀ X Y Z : Prop, X ∧ ¬ (Y ∨ Z) ↔ (¬ Y ∧ ¬ Z) ∧ X.
Abort.
Goal ∀ X : Type, ∀ p q : X → Prop, (∀ x, ¬ (p x ∨ q x)) ↔ ∀ x, ¬ p x ∧ ¬ q x.
Abort.
(* Exercise 2.9.4 *)
Goal ∀ X Y : Prop, X ∧ (X ∨ Y) ↔ X.
Abort.
Goal ∀ X Y : Prop, X ∨ (X ∧ Y) ↔ X.
Abort.
Goal ∀ X:Prop, (X → ¬ X) → X ↔ ~~ X.
Abort.
(* Exercise 2.9.5 *)
Goal False ↔ ∀ Z : Prop, Z.
Abort.
Goal ∀ X : Prop,
¬ X ↔ ∀ Z : Prop, X → Z.
Abort.
Goal ∀ X Y : Prop, X ∧ Y ↔ ∀ Z : Prop, (X → Y → Z) → Z.
Abort.
Goal ∀ X Y : Prop, X ∨ Y ↔ ∀ Z : Prop, (X → Z) → (Y → Z) → Z.
Abort.
Goal ∀ (X : Type) (x y : X), x=y ↔ ∀ p : X → Prop, p x → p y.
Abort.
Goal ∀ X Y : Prop, X ∧ Y → Y ∧ X.
Proof. intros X Y [x y]. split ; assumption. Qed.
Goal ∀ (X : Type) (p : list X → Prop) (xs : list X),
p nil → (∀ x xs, p xs → p (cons x xs)) → p xs.
Proof. induction xs ; auto. Qed.
Goal ∀ X : Prop, ¬ (X ↔ ¬ X).
Proof. tauto. Qed.
Goal ∀ (X : Type) (p q : X → Prop),
(∃ x, p x ∧ q x) → ∃ x, p x.
Proof.
intros X p q A. destruct A as [x B]. destruct B as [C _].
∃ x. exact C.
Qed.
Definition diagonal : Prop := ∀ (X : Type) (p : X → X → Prop),
¬ ∃ x, ∀ y, p x y ↔ ¬ p y y.
Lemma circuit (X : Prop) : ¬ (X ↔ ¬ X).
Proof. tauto. Qed.
Goal diagonal.
Proof. intros X p [x A]. apply (@circuit (p x x)). exact (A x). Qed.
Goal diagonal.
Proof. intros X p [x A]. specialize (A x). tauto. Qed.
Goal ∀ (X : Type) (x y : X),
x ≠ y ↔ ∃ p : X → Prop, p x ∧ ¬ p y.
Proof.
split.
- intros A. ∃ (fun z ⇒ x = z). auto.
- intros [p [A B]] C. apply B. rewrite <- C. apply A.
Qed.
(* Exercise 2.11.1 *)
Goal ∀ (X : Type) (p : X → Prop),
¬ (∃ x, p x) ↔ ∀ x, ¬ p x.
Abort.
(* Exercise 2.11.2 *)
Goal ∀ (X Y : Type) (p : X → Y → Prop),
(∃ x, ∃ y, p x y) ↔ ∃ y, ∃ x, p x y.
Abort.
(* Exercise 2.11.3 *)
Goal ∀ (X : Type) (p : X → Prop),
(∃ x, p x) ↔ ∀ Z : Prop, (∀ x, p x → Z) → Z.
Abort.
(* Exercise 2.11.4 *)
Goal ∀ (X : Type) (x y : X),
x = y ↔ ∀ r : X → X → Prop, (∀ z : X, r z z) → r x y.
Abort.
Goal ∀ (X : Type) (x y : X),
x ≠ y ↔ ∃ r : X → X → Prop, (∀ z : X, r z z) ∧ ¬ r x y.
Abort.
(* Exercise 2.11.5 *)
Goal ∀ (X: Type) (x : X) (p : X → Prop), ∃ q : X → Prop,
q x ∧ (∀ y, p y → q y) ∧ ∀ y, q y → p y ∨ x = y.
Abort.
(* Exercise 2.11.6 *)
Goal ∀ (X : Type) (Y : Prop) ,
X → Y ↔ (∃ x : X, True) → Y.
Abort.
Lemma AndI (X Y : Prop) :
X → Y → X ∧ Y.
Proof. tauto. Qed.
Lemma AndE (X Y U : Prop) :
X ∧ Y → (X → Y → U) → U.
Proof. tauto. Qed.
Goal ∀ X Y : Prop, X ∧ Y → Y ∧ X.
Proof.
intros X Y A. apply (AndE A).
intros x y. apply AndI.
- exact y.
- exact x.
Qed.
Lemma ExI (X : Type) (p : X → Prop) :
∀ x : X, p x → ∃ x, p x.
Proof. intros x A. ∃ x. exact A. Qed.
Lemma ExE (X : Type) (p : X → Prop) (U : Prop) :
(∃ x, p x) → (∀ x, p x → U) → U.
Proof. intros [x A] B. exact (B x A). Qed.
Goal ∀ (X : Type) (p q : X → Prop),
(∃ x, p x ∧ q x) → ∃ x, p x.
Proof.
intros X p q A. apply (ExE A).
intros x B. apply (AndE B). intros C _.
exact (ExI C).
Qed.
(* Exercise 2.13.1 *)
(* Lemma OrI_L (* ... *)
Lemma OrI_R (* ... *)
Lemma OrE (* ... *) *)
Goal ∀ X Y: Prop, X ∨ Y ↔ Y ∨ X.
Abort.
Inductive True : Prop :=
| I : True.
Inductive False : Prop := .
Goal ∀ x y : True, x=y.
Proof. intros x y. destruct x. destruct y. reflexivity. Qed.
Goal ∀ X : Prop, False → X.
Proof. intros X A. destruct A. Qed.
Inductive and (X Y : Prop) : Prop :=
| conj : X → Y → and X Y.
Inductive or (X Y : Prop) : Prop :=
| or_introl : X → or X Y
| or_intror : Y → or X Y.
Inductive ex (X : Type) (p : X → Prop) : Prop :=
| ex_intro : ∀ x : X, p x → ex p.
Definition not (X : Prop) : Prop := X → False.
Definition iff (X Y : Prop) : Prop := (X → Y) ∧ (Y → X).
(* Exercise 2.14.1 *)
Goal ∀ X Y: Prop, X ∨ Y ↔ Y ∨ X.
Abort.
Definition AND (X Y : Prop) : Prop :=
∀ Z : Prop, (X → Y → Z) → Z.
Lemma ANDI (X Y : Prop) :
X → Y → AND X Y.
Proof. intros x y Z. auto. Qed.
Lemma ANDE (X Y Z: Prop) :
AND X Y → (X → Y → Z) → Z.
Proof. intros A. exact (A Z). Qed.
Lemma AND_agree (X Y : Prop) :
AND X Y ↔ X ∧ Y.
Proof.
split.
- intros A. apply A. auto.
- intros [x y] Z A. apply A ; assumption.
Qed.
Definition XM : Prop := ∀ X : Prop, X ∨ ¬ X.
(* Exercise 2.16.1 *)
Goal ∀ X Y : Prop,
XM → ¬ (X ∧ Y) → ¬ X ∨ ¬ Y.
Abort.
Goal ∀ (X : Type) (p : X → Prop),
XM → ¬ (∀ x, p x) → ∃ x, ¬ p x.
Abort.
(* Exercise 2.16.2 *)
Definition DN : Prop := ∀ X : Prop, ~~ X → X. (* double negation *)
Definition CP : Prop := ∀ X Y : Prop, (¬ Y → ¬ X) → X → Y. (* contraposition *)
Definition Peirce : Prop := ∀ X Y : Prop, ((X → Y) → X) → X. (* Peirce's Law *)
Goal XM → DN.
Abort.
Goal DN → CP.
Abort.
Goal CP → Peirce.
Abort.
(* Exercise 2.16.3 *)
Lemma drinker (X : Type) (d : X → Prop) :
XM → (∃ x : X, True) → ∃ x, d x → ∀ x, d x.
Abort.
(* Exercise 2.16.4 *)
Goal ∀ X : Prop,
~~ (X ∨ ¬ X).
Abort.
Goal ∀ X Y : Prop,
~~ (((X → Y) → X) → X).
Abort.
Goal ∀ X Y : Prop,
~~ (~ (X ∧ Y) ↔ ¬ X ∨ ¬ Y).
Abort.
Goal ∀ X Y : Prop,
~~ ((X → Y) ↔ (¬ Y → ¬ X)).
Abort.
(* Exercise 2.16.5 *)
Definition pdec (s: Prop) := s ∨ ¬ s.
Goal pdec (∀ X: Prop, ¬ (X ∨ ¬ X)).
Abort.
Goal pdec (∃ X: Prop, ¬ (X ∨ ¬X)).
Abort.
Goal pdec (∀ P: Prop, ∃ f: Prop → Prop, ∀ X Y: Prop,
(X ∧ P → Y) ↔ (X → f Y)).
Abort.
Goal pdec (∀ P:Prop, ∃ f: Prop → Prop, ∀ X Y: Prop,
(X → Y ∧ P) ↔ (f X → Y)).
Abort.