2014-07-05 05:22:26 +00:00
|
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
-- Author: Leonardo de Moura
|
2014-07-12 06:08:12 +00:00
|
|
|
|
import logic cast
|
2014-07-25 05:49:12 +00:00
|
|
|
|
using eq_proofs
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:49:54 +00:00
|
|
|
|
axiom prop_complete (a : Prop) : a = true ∨ a = false
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem case (P : Prop → Prop) (H1 : P true) (H2 : P false) (a : Prop) : P a
|
2014-07-22 16:49:54 +00:00
|
|
|
|
:= or_elim (prop_complete a)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(assume Ht : a = true, Ht⁻¹ ▸ H1)
|
|
|
|
|
(assume Hf : a = false, Hf⁻¹ ▸ H2)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem em (a : Prop) : a ∨ ¬a
|
2014-07-22 16:49:54 +00:00
|
|
|
|
:= or_elim (prop_complete a)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume Ht : a = true, or_intro_left (¬ a) (eqt_elim Ht))
|
|
|
|
|
(assume Hf : a = false, or_intro_right a (eqf_elim Hf))
|
|
|
|
|
|
2014-07-22 16:49:54 +00:00
|
|
|
|
theorem prop_complete_swapped (a : Prop) : a = false ∨ a = true
|
2014-07-05 05:22:26 +00:00
|
|
|
|
:= case (λ x, x = false ∨ x = true)
|
|
|
|
|
(or_intro_right (true = false) (refl true))
|
|
|
|
|
(or_intro_left (false = true) (refl false))
|
|
|
|
|
a
|
|
|
|
|
|
2014-07-19 08:29:04 +00:00
|
|
|
|
theorem not_true : (¬true) = false
|
|
|
|
|
:= have aux : ¬ (¬true) = true, from
|
2014-07-25 05:14:15 +00:00
|
|
|
|
assume H : (¬true) = true,
|
2014-07-25 05:49:12 +00:00
|
|
|
|
absurd_not_true (H⁻¹ ▸ trivial),
|
2014-07-22 16:49:54 +00:00
|
|
|
|
resolve_right (prop_complete (¬true)) aux
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-19 08:29:04 +00:00
|
|
|
|
theorem not_false : (¬false) = true
|
|
|
|
|
:= have aux : ¬ (¬false) = false, from
|
2014-07-25 05:14:15 +00:00
|
|
|
|
assume H : (¬false) = false,
|
2014-07-25 05:49:12 +00:00
|
|
|
|
H ▸ not_false_trivial,
|
2014-07-22 16:49:54 +00:00
|
|
|
|
resolve_right (prop_complete_swapped (¬ false)) aux
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_not_eq (a : Prop) : (¬¬a) = a
|
2014-07-19 08:29:04 +00:00
|
|
|
|
:= case (λ x, (¬¬x) = x)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(calc (¬¬true) = (¬false) : {not_true}
|
2014-07-19 08:29:04 +00:00
|
|
|
|
... = true : not_false)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(calc (¬¬false) = (¬true) : {not_false}
|
2014-07-19 08:29:04 +00:00
|
|
|
|
... = false : not_true)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
a
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_not_elim {a : Prop} (H : ¬¬a) : a
|
2014-07-05 05:22:26 +00:00
|
|
|
|
:= (not_not_eq a) ◂ H
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem propext {a b : Prop} (Hab : a → b) (Hba : b → a) : a = b
|
2014-07-22 16:49:54 +00:00
|
|
|
|
:= or_elim (prop_complete a)
|
|
|
|
|
(assume Hat, or_elim (prop_complete b)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(assume Hbt, Hat ⬝ Hbt⁻¹)
|
|
|
|
|
(assume Hbf, false_elim (a = b) (Hbf ▸ (Hab (eqt_elim Hat)))))
|
2014-07-22 16:49:54 +00:00
|
|
|
|
(assume Haf, or_elim (prop_complete b)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(assume Hbt, false_elim (a = b) (Haf ▸ (Hba (eqt_elim Hbt))))
|
|
|
|
|
(assume Hbf, Haf ⬝ Hbf⁻¹))
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem iff_to_eq {a b : Prop} (H : a ↔ b) : a = b
|
|
|
|
|
:= iff_elim (assume H1 H2, propext H1 H2) H
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem iff_eq_eq {a b : Prop} : (a ↔ b) = (a = b)
|
|
|
|
|
:= propext
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, iff_to_eq H)
|
|
|
|
|
(assume H, eq_to_iff H)
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem eqt_intro {a : Prop} (H : a) : a = true
|
|
|
|
|
:= propext (assume H1 : a, trivial)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H2 : true, H)
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem eqf_intro {a : Prop} (H : ¬a) : a = false
|
|
|
|
|
:= propext (assume H1 : a, absurd H1 H)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H2 : false, false_elim a H2)
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem by_contradiction {a : Prop} (H : ¬a → false) : a
|
2014-07-19 08:29:04 +00:00
|
|
|
|
:= or_elim (em a) (assume H1 : a, H1) (assume H1 : ¬a, false_elim a (H H1))
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
|
|
|
|
theorem a_neq_a {A : Type} (a : A) : (a ≠ a) = false
|
2014-07-22 16:43:18 +00:00
|
|
|
|
:= propext (assume H, a_neq_a_elim H)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, false_elim (a ≠ a) H)
|
|
|
|
|
|
|
|
|
|
theorem eq_id {A : Type} (a : A) : (a = a) = true
|
|
|
|
|
:= eqt_intro (refl a)
|
|
|
|
|
|
|
|
|
|
theorem heq_id {A : Type} (a : A) : (a == a) = true
|
2014-07-12 05:21:00 +00:00
|
|
|
|
:= eqt_intro (hrefl a)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_or (a b : Prop) : (¬ (a ∨ b)) = (¬ a ∧ ¬ b)
|
|
|
|
|
:= propext
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, or_elim (em a)
|
|
|
|
|
(assume Ha, absurd_elim (¬ a ∧ ¬ b) (or_intro_left b Ha) H)
|
|
|
|
|
(assume Hna, or_elim (em b)
|
|
|
|
|
(assume Hb, absurd_elim (¬ a ∧ ¬ b) (or_intro_right a Hb) H)
|
|
|
|
|
(assume Hnb, and_intro Hna Hnb)))
|
2014-07-25 05:14:15 +00:00
|
|
|
|
(assume (H : ¬ a ∧ ¬ b) (N : a ∨ b),
|
2014-07-05 05:22:26 +00:00
|
|
|
|
or_elim N
|
|
|
|
|
(assume Ha, absurd Ha (and_elim_left H))
|
2014-07-25 05:14:15 +00:00
|
|
|
|
(assume Hb, absurd Hb (and_elim_right H)))
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_and (a b : Prop) : (¬ (a ∧ b)) = (¬ a ∨ ¬ b)
|
|
|
|
|
:= propext
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, or_elim (em a)
|
|
|
|
|
(assume Ha, or_elim (em b)
|
|
|
|
|
(assume Hb, absurd_elim (¬ a ∨ ¬ b) (and_intro Ha Hb) H)
|
|
|
|
|
(assume Hnb, or_intro_right (¬ a) Hnb))
|
|
|
|
|
(assume Hna, or_intro_left (¬ b) Hna))
|
2014-07-25 05:14:15 +00:00
|
|
|
|
(assume (H : ¬ a ∨ ¬ b) (N : a ∧ b),
|
2014-07-05 05:22:26 +00:00
|
|
|
|
or_elim H
|
|
|
|
|
(assume Hna, absurd (and_elim_left N) Hna)
|
2014-07-25 05:14:15 +00:00
|
|
|
|
(assume Hnb, absurd (and_elim_right N) Hnb))
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem imp_or (a b : Prop) : (a → b) = (¬ a ∨ b)
|
|
|
|
|
:= propext
|
2014-07-19 08:29:04 +00:00
|
|
|
|
(assume H : a → b, (or_elim (em a)
|
|
|
|
|
(assume Ha : a, or_intro_right (¬ a) (H Ha))
|
|
|
|
|
(assume Hna : ¬ a, or_intro_left b Hna)))
|
|
|
|
|
(assume (H : ¬ a ∨ b) (Ha : a),
|
2014-07-25 05:49:12 +00:00
|
|
|
|
resolve_right H ((not_not_eq a)⁻¹ ◂ Ha))
|
2014-07-19 08:29:04 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_implies (a b : Prop) : (¬ (a → b)) = (a ∧ ¬b)
|
2014-07-19 08:29:04 +00:00
|
|
|
|
:= calc (¬ (a → b)) = (¬(¬a ∨ b)) : {imp_or a b}
|
|
|
|
|
... = (¬¬a ∧ ¬b) : not_or (¬ a) b
|
|
|
|
|
... = (a ∧ ¬b) : {not_not_eq a}
|
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem a_eq_not_a (a : Prop) : (a = ¬a) = false
|
|
|
|
|
:= propext
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, or_elim (em a)
|
2014-07-25 05:49:12 +00:00
|
|
|
|
(assume Ha, absurd Ha (H ▸ Ha))
|
|
|
|
|
(assume Hna, absurd (H⁻¹ ▸ Hna) Hna))
|
2014-07-05 05:22:26 +00:00
|
|
|
|
(assume H, false_elim (a = ¬ a) H)
|
|
|
|
|
|
|
|
|
|
theorem true_eq_false : (true = false) = false
|
2014-07-25 05:49:12 +00:00
|
|
|
|
:= not_true ▸ (a_eq_not_a true)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
|
|
|
|
theorem false_eq_true : (false = true) = false
|
2014-07-25 05:49:12 +00:00
|
|
|
|
:= not_false ▸ (a_eq_not_a false)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem a_eq_true (a : Prop) : (a = true) = a
|
|
|
|
|
:= propext (assume H, eqt_elim H) (assume H, eqt_intro H)
|
2014-07-05 05:22:26 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem a_eq_false (a : Prop) : (a = false) = ¬a
|
|
|
|
|
:= propext (assume H, eqf_elim H) (assume H, eqf_intro H)
|
2014-07-13 01:48:00 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_exists_forall {A : Type} {P : A → Prop} (H : ¬∃x, P x) : ∀x, ¬P x
|
2014-07-13 01:48:00 +00:00
|
|
|
|
:= take x, or_elim (em (P x))
|
2014-07-19 08:29:04 +00:00
|
|
|
|
(assume Hp : P x, absurd_elim (¬P x) (exists_intro x Hp) H)
|
|
|
|
|
(assume Hn : ¬P x, Hn)
|
2014-07-13 01:48:00 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem not_forall_exists {A : Type} {P : A → Prop} (H : ¬∀x, P x) : ∃x, ¬P x
|
2014-07-19 08:29:04 +00:00
|
|
|
|
:= by_contradiction (assume H1 : ¬∃ x, ¬P x,
|
|
|
|
|
have H2 : ∀x, ¬¬P x, from not_exists_forall H1,
|
|
|
|
|
have H3 : ∀x, P x, from take x, not_not_elim (H2 x),
|
2014-07-13 01:48:00 +00:00
|
|
|
|
absurd H3 H)
|
2014-07-13 02:05:17 +00:00
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
|
theorem peirce (a b : Prop) : ((a → b) → a) → a
|
2014-07-19 08:29:04 +00:00
|
|
|
|
:= assume H, by_contradiction (assume Hna : ¬a,
|
|
|
|
|
have Hnna : ¬¬a, from not_implies_left (mt H Hna),
|
2014-07-13 02:05:17 +00:00
|
|
|
|
absurd (not_not_elim Hnna) Hna)
|