2014-07-28 08:13:21 +00:00
|
|
|
|
-- Theorems/Exercises from "Logical Investigations, with the Nuprl Proof Assistant"
|
|
|
|
|
-- by Robert L. Constable and Anne Trostle
|
|
|
|
|
-- http://www.nuprl.org/MathLibrary/LogicalInvestigations/
|
2014-07-28 08:17:31 +00:00
|
|
|
|
import logic
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-28 08:17:31 +00:00
|
|
|
|
-- 2. The Minimal Implicational Calculus
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm1 {A B : Prop} : A → B → A :=
|
|
|
|
|
assume Ha Hb, Ha
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm2 {A B C : Prop} : (A → B) → (A → B → C) → (A → C) :=
|
|
|
|
|
assume Hab Habc Ha,
|
|
|
|
|
Habc Ha (Hab Ha)
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm3 {A B C : Prop} : (A → B) → (B → C) → (A → C) :=
|
|
|
|
|
assume Hab Hbc Ha,
|
|
|
|
|
Hbc (Hab Ha)
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-28 08:17:31 +00:00
|
|
|
|
-- 3. False Propositions and Negation
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm4 {P Q : Prop} : ¬P → P → Q :=
|
|
|
|
|
assume Hnp Hp,
|
2014-08-28 01:34:09 +00:00
|
|
|
|
absurd Hp Hnp
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm5 {P : Prop} : P → ¬¬P :=
|
|
|
|
|
assume (Hp : P) (HnP : ¬P),
|
|
|
|
|
absurd Hp HnP
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm6 {P Q : Prop} : (P → Q) → (¬Q → ¬P) :=
|
|
|
|
|
assume (Hpq : P → Q) (Hnq : ¬Q) (Hp : P),
|
|
|
|
|
have Hq : Q, from Hpq Hp,
|
|
|
|
|
show false, from absurd Hq Hnq
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm7 {P Q : Prop} : (P → ¬P) → (P → Q) :=
|
|
|
|
|
assume Hpnp Hp,
|
2014-08-28 01:34:09 +00:00
|
|
|
|
absurd Hp (Hpnp Hp)
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm8 {P Q : Prop} : ¬(P → Q) → (P → ¬Q) :=
|
|
|
|
|
assume (Hn : ¬(P → Q)) (Hp : P) (Hq : Q),
|
|
|
|
|
-- Rermak we don't even need the hypothesis Hp
|
|
|
|
|
have H : P → Q, from assume H', Hq,
|
|
|
|
|
absurd H Hn
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-28 08:17:31 +00:00
|
|
|
|
-- 4. Conjunction and Disjunction
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm9 {P : Prop} : (P ∨ ¬P) → (¬¬P → P) :=
|
|
|
|
|
assume (em : P ∨ ¬P) (Hnn : ¬¬P),
|
|
|
|
|
or_elim em
|
|
|
|
|
(assume Hp, Hp)
|
2014-08-28 01:34:09 +00:00
|
|
|
|
(assume Hn, absurd Hn Hnn)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm10 {P : Prop} : ¬¬(P ∨ ¬P) :=
|
|
|
|
|
assume Hnem : ¬(P ∨ ¬P),
|
|
|
|
|
have Hnp : ¬P, from
|
|
|
|
|
assume Hp : P,
|
|
|
|
|
have Hem : P ∨ ¬P, from or_inl Hp,
|
|
|
|
|
absurd Hem Hnem,
|
|
|
|
|
have Hem : P ∨ ¬P, from or_inr Hnp,
|
|
|
|
|
absurd Hem Hnem
|
|
|
|
|
|
|
|
|
|
theorem thm11 {P Q : Prop} : ¬P ∨ ¬Q → ¬(P ∧ Q) :=
|
|
|
|
|
assume (H : ¬P ∨ ¬Q) (Hn : P ∧ Q),
|
|
|
|
|
or_elim H
|
2014-09-05 00:44:53 +00:00
|
|
|
|
(assume Hnp : ¬P, absurd (and.elim_left Hn) Hnp)
|
|
|
|
|
(assume Hnq : ¬Q, absurd (and.elim_right Hn) Hnq)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm12 {P Q : Prop} : ¬(P ∨ Q) → ¬P ∧ ¬Q :=
|
|
|
|
|
assume H : ¬(P ∨ Q),
|
|
|
|
|
have Hnp : ¬P, from assume Hp : P, absurd (or_inl Hp) H,
|
|
|
|
|
have Hnq : ¬Q, from assume Hq : Q, absurd (or_inr Hq) H,
|
2014-09-04 23:36:06 +00:00
|
|
|
|
and.intro Hnp Hnq
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm13 {P Q : Prop} : ¬P ∧ ¬Q → ¬(P ∨ Q) :=
|
|
|
|
|
assume (H : ¬P ∧ ¬Q) (Hn : P ∨ Q),
|
|
|
|
|
or_elim Hn
|
2014-09-05 00:44:53 +00:00
|
|
|
|
(assume Hp : P, absurd Hp (and.elim_left H))
|
|
|
|
|
(assume Hq : Q, absurd Hq (and.elim_right H))
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm14 {P Q : Prop} : ¬P ∨ Q → P → Q :=
|
|
|
|
|
assume (Hor : ¬P ∨ Q) (Hp : P),
|
|
|
|
|
or_elim Hor
|
2014-08-28 01:34:09 +00:00
|
|
|
|
(assume Hnp : ¬P, absurd Hp Hnp)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
(assume Hq : Q, Hq)
|
|
|
|
|
|
|
|
|
|
theorem thm15 {P Q : Prop} : (P → Q) → ¬¬(¬P ∨ Q) :=
|
|
|
|
|
assume (Hpq : P → Q) (Hn : ¬(¬P ∨ Q)),
|
|
|
|
|
have H1 : ¬¬P ∧ ¬Q, from thm12 Hn,
|
2014-09-05 00:44:53 +00:00
|
|
|
|
have Hnp : ¬P, from mt Hpq (and.elim_right H1),
|
|
|
|
|
absurd Hnp (and.elim_left H1)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm16 {P Q : Prop} : (P → Q) ∧ ((P ∨ ¬P) ∨ (Q ∨ ¬Q)) → ¬P ∨ Q :=
|
|
|
|
|
assume H : (P → Q) ∧ ((P ∨ ¬P) ∨ (Q ∨ ¬Q)),
|
2014-09-05 00:44:53 +00:00
|
|
|
|
have Hpq : P → Q, from and.elim_left H,
|
|
|
|
|
or_elim (and.elim_right H)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
(assume Hem1 : P ∨ ¬P, or_elim Hem1
|
|
|
|
|
(assume Hp : P, or_inr (Hpq Hp))
|
|
|
|
|
(assume Hnp : ¬P, or_inl Hnp))
|
|
|
|
|
(assume Hem2 : Q ∨ ¬Q, or_elim Hem2
|
|
|
|
|
(assume Hq : Q, or_inr Hq)
|
|
|
|
|
(assume Hnq : ¬Q, or_inl (mt Hpq Hnq)))
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-28 08:17:31 +00:00
|
|
|
|
-- 5. First-Order Logic: All and Exists
|
2014-07-28 08:13:21 +00:00
|
|
|
|
section
|
|
|
|
|
parameters {T : Type} {C : Prop} {P : T → Prop}
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm17a : (C → ∀x, P x) → (∀x, C → P x) :=
|
|
|
|
|
assume H : C → ∀x, P x,
|
|
|
|
|
take x : T, assume Hc : C,
|
|
|
|
|
H Hc x
|
|
|
|
|
|
|
|
|
|
theorem thm17b : (∀x, C → P x) → (C → ∀x, P x) :=
|
|
|
|
|
assume (H : ∀x, C → P x) (Hc : C),
|
|
|
|
|
take x : T,
|
|
|
|
|
H x Hc
|
|
|
|
|
|
|
|
|
|
theorem thm18a : ((∃x, P x) → C) → (∀x, P x → C) :=
|
|
|
|
|
assume H : (∃x, P x) → C,
|
|
|
|
|
take x, assume Hp : P x,
|
|
|
|
|
have Hex : ∃x, P x, from exists_intro x Hp,
|
|
|
|
|
H Hex
|
|
|
|
|
|
|
|
|
|
theorem thm18b : (∀x, P x → C) → (∃x, P x) → C :=
|
|
|
|
|
assume (H1 : ∀x, P x → C) (H2 : ∃x, P x),
|
|
|
|
|
obtain (w : T) (Hw : P w), from H2,
|
|
|
|
|
H1 w Hw
|
|
|
|
|
|
|
|
|
|
theorem thm19a : (C ∨ ¬C) → (∃x : T, true) → (C → (∃x, P x)) → (∃x, C → P x) :=
|
|
|
|
|
assume (Hem : C ∨ ¬C) (Hin : ∃x : T, true) (H1 : C → ∃x, P x),
|
|
|
|
|
or_elim Hem
|
|
|
|
|
(assume Hc : C,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
obtain (w : T) (Hw : P w), from H1 Hc,
|
|
|
|
|
have Hr : C → P w, from assume Hc, Hw,
|
|
|
|
|
exists_intro w Hr)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
(assume Hnc : ¬C,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
obtain (w : T) (Hw : true), from Hin,
|
2014-08-28 01:34:09 +00:00
|
|
|
|
have Hr : C → P w, from assume Hc, absurd Hc Hnc,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
exists_intro w Hr)
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm19b : (∃x, C → P x) → C → (∃x, P x) :=
|
|
|
|
|
assume (H : ∃x, C → P x) (Hc : C),
|
|
|
|
|
obtain (w : T) (Hw : C → P w), from H,
|
|
|
|
|
exists_intro w (Hw Hc)
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm20a : (C ∨ ¬C) → (∃x : T, true) → ((¬∀x, P x) → ∃x, ¬P x) → ((∀x, P x) → C) → (∃x, P x → C) :=
|
|
|
|
|
assume Hem Hin Hnf H,
|
|
|
|
|
or_elim Hem
|
|
|
|
|
(assume Hc : C,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
obtain (w : T) (Hw : true), from Hin,
|
|
|
|
|
exists_intro w (assume H : P w, Hc))
|
2014-07-29 02:58:57 +00:00
|
|
|
|
(assume Hnc : ¬C,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
have H1 : ¬(∀x, P x), from mt H Hnc,
|
|
|
|
|
have H2 : ∃x, ¬P x, from Hnf H1,
|
|
|
|
|
obtain (w : T) (Hw : ¬P w), from H2,
|
2014-08-28 01:34:09 +00:00
|
|
|
|
exists_intro w (assume H : P w, absurd H Hw))
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm20b : (∃x, P x → C) → (∀ x, P x) → C :=
|
|
|
|
|
assume Hex Hall,
|
|
|
|
|
obtain (w : T) (Hw : P w → C), from Hex,
|
|
|
|
|
Hw (Hall w)
|
|
|
|
|
|
|
|
|
|
theorem thm21a : (∃x : T, true) → ((∃x, P x) ∨ C) → (∃x, P x ∨ C) :=
|
|
|
|
|
assume Hin H,
|
|
|
|
|
or_elim H
|
|
|
|
|
(assume Hex : ∃x, P x,
|
|
|
|
|
obtain (w : T) (Hw : P w), from Hex,
|
|
|
|
|
exists_intro w (or_inl Hw))
|
|
|
|
|
(assume Hc : C,
|
|
|
|
|
obtain (w : T) (Hw : true), from Hin,
|
|
|
|
|
exists_intro w (or_inr Hc))
|
|
|
|
|
|
|
|
|
|
theorem thm21b : (∃x, P x ∨ C) → ((∃x, P x) ∨ C) :=
|
|
|
|
|
assume H,
|
|
|
|
|
obtain (w : T) (Hw : P w ∨ C), from H,
|
|
|
|
|
or_elim Hw
|
|
|
|
|
(assume H : P w, or_inl (exists_intro w H))
|
|
|
|
|
(assume Hc : C, or_inr Hc)
|
|
|
|
|
|
|
|
|
|
theorem thm22a : (∀x, P x) ∨ C → ∀x, P x ∨ C :=
|
|
|
|
|
assume H, take x,
|
|
|
|
|
or_elim H
|
|
|
|
|
(assume Hl, or_inl (Hl x))
|
|
|
|
|
(assume Hr, or_inr Hr)
|
|
|
|
|
|
|
|
|
|
theorem thm22b : (C ∨ ¬C) → (∀x, P x ∨ C) → ((∀x, P x) ∨ C) :=
|
|
|
|
|
assume Hem H1,
|
|
|
|
|
or_elim Hem
|
|
|
|
|
(assume Hc : C, or_inr Hc)
|
|
|
|
|
(assume Hnc : ¬C,
|
2014-07-28 08:13:21 +00:00
|
|
|
|
have Hx : ∀x, P x, from
|
|
|
|
|
take x,
|
|
|
|
|
have H1 : P x ∨ C, from H1 x,
|
|
|
|
|
resolve_left H1 Hnc,
|
|
|
|
|
or_inl Hx)
|
|
|
|
|
|
2014-07-29 02:58:57 +00:00
|
|
|
|
theorem thm23a : (∃x, P x) ∧ C → (∃x, P x ∧ C) :=
|
|
|
|
|
assume H,
|
2014-09-05 00:44:53 +00:00
|
|
|
|
have Hex : ∃x, P x, from and.elim_left H,
|
|
|
|
|
have Hc : C, from and.elim_right H,
|
2014-07-29 02:58:57 +00:00
|
|
|
|
obtain (w : T) (Hw : P w), from Hex,
|
2014-09-04 23:36:06 +00:00
|
|
|
|
exists_intro w (and.intro Hw Hc)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm23b : (∃x, P x ∧ C) → (∃x, P x) ∧ C :=
|
|
|
|
|
assume H,
|
|
|
|
|
obtain (w : T) (Hw : P w ∧ C), from H,
|
2014-09-05 00:44:53 +00:00
|
|
|
|
have Hex : ∃x, P x, from exists_intro w (and.elim_left Hw),
|
|
|
|
|
and.intro Hex (and.elim_right Hw)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm24a : (∀x, P x) ∧ C → (∀x, P x ∧ C) :=
|
|
|
|
|
assume H, take x,
|
2014-09-05 00:44:53 +00:00
|
|
|
|
and.intro (and.elim_left H x) (and.elim_right H)
|
2014-07-29 02:58:57 +00:00
|
|
|
|
|
|
|
|
|
theorem thm24b : (∃x : T, true) → (∀x, P x ∧ C) → (∀x, P x) ∧ C :=
|
|
|
|
|
assume Hin H,
|
|
|
|
|
obtain (w : T) (Hw : true), from Hin,
|
2014-09-05 00:44:53 +00:00
|
|
|
|
have Hc : C, from and.elim_right (H w),
|
|
|
|
|
have Hx : ∀x, P x, from take x, and.elim_left (H x),
|
2014-09-04 23:36:06 +00:00
|
|
|
|
and.intro Hx Hc
|
2014-07-28 08:13:21 +00:00
|
|
|
|
|
2014-07-28 08:17:31 +00:00
|
|
|
|
end -- of section
|