2014-12-15 21:13:04 +00:00
|
|
|
|
/-
|
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
Authors: Jeremy Avigad, Leonardo de Moura
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
Useful logical identities. Since we are not using propositional extensionality, some of the
|
|
|
|
|
calculations use the type class support provided by logic.instances.
|
|
|
|
|
-/
|
2014-12-12 21:20:27 +00:00
|
|
|
|
import logic.connectives logic.instances logic.quantifiers logic.cast
|
2014-09-03 23:00:38 +00:00
|
|
|
|
open relation decidable relation.iff_ops
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem or.right_comm (a b c : Prop) : (a ∨ b) ∨ c ↔ (a ∨ c) ∨ b :=
|
2014-08-22 23:36:47 +00:00
|
|
|
|
calc
|
2014-09-05 04:25:21 +00:00
|
|
|
|
(a ∨ b) ∨ c ↔ a ∨ (b ∨ c) : or.assoc
|
|
|
|
|
... ↔ a ∨ (c ∨ b) : {or.comm}
|
|
|
|
|
... ↔ (a ∨ c) ∨ b : iff.symm or.assoc
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2015-02-01 16:16:30 +00:00
|
|
|
|
theorem or.left_comm (a b c : Prop) : a ∨ (b ∨ c) ↔ b ∨ (a ∨ c) :=
|
2014-08-22 23:36:47 +00:00
|
|
|
|
calc
|
2014-09-05 04:25:21 +00:00
|
|
|
|
a ∨ (b ∨ c) ↔ (a ∨ b) ∨ c : iff.symm or.assoc
|
|
|
|
|
... ↔ (b ∨ a) ∨ c : {or.comm}
|
|
|
|
|
... ↔ b ∨ (a ∨ c) : or.assoc
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem and.right_comm (a b c : Prop) : (a ∧ b) ∧ c ↔ (a ∧ c) ∧ b :=
|
2014-08-22 23:36:47 +00:00
|
|
|
|
calc
|
2014-09-05 04:25:21 +00:00
|
|
|
|
(a ∧ b) ∧ c ↔ a ∧ (b ∧ c) : and.assoc
|
|
|
|
|
... ↔ a ∧ (c ∧ b) : {and.comm}
|
|
|
|
|
... ↔ (a ∧ c) ∧ b : iff.symm and.assoc
|
2014-08-22 23:36:47 +00:00
|
|
|
|
|
2015-02-01 16:16:30 +00:00
|
|
|
|
theorem and.left_comm (a b c : Prop) : a ∧ (b ∧ c) ↔ b ∧ (a ∧ c) :=
|
2014-08-22 23:36:47 +00:00
|
|
|
|
calc
|
2014-09-05 04:25:21 +00:00
|
|
|
|
a ∧ (b ∧ c) ↔ (a ∧ b) ∧ c : iff.symm and.assoc
|
|
|
|
|
... ↔ (b ∧ a) ∧ c : {and.comm}
|
|
|
|
|
... ↔ b ∧ (a ∧ c) : and.assoc
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-10-12 20:06:00 +00:00
|
|
|
|
theorem not_not_iff {a : Prop} [D : decidable a] : (¬¬a) ↔ a :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume H : ¬¬a,
|
|
|
|
|
by_cases (assume H' : a, H') (assume H' : ¬a, absurd H' H))
|
|
|
|
|
(assume H : a, assume H', H' H)
|
|
|
|
|
|
2014-10-12 20:06:00 +00:00
|
|
|
|
theorem not_not_elim {a : Prop} [D : decidable a] (H : ¬¬a) : a :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.mp not_not_iff H
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem not_true_iff_false : ¬true ↔ false :=
|
2014-12-15 20:05:44 +00:00
|
|
|
|
iff.intro (assume H, H trivial) false.elim
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem not_false_iff_true : ¬false ↔ true :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro (assume H, trivial) (assume H H', H')
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 20:05:44 +00:00
|
|
|
|
theorem not_or_iff_not_and_not {a b : Prop} [Da : decidable a] [Db : decidable b] :
|
2014-12-15 21:13:04 +00:00
|
|
|
|
¬(a ∨ b) ↔ ¬a ∧ ¬b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
|
|
|
|
(assume H, or.elim (em a)
|
|
|
|
|
(assume Ha, absurd (or.inl Ha) H)
|
|
|
|
|
(assume Hna, or.elim (em b)
|
|
|
|
|
(assume Hb, absurd (or.inr Hb) H)
|
2014-09-04 23:36:06 +00:00
|
|
|
|
(assume Hnb, and.intro Hna Hnb)))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume (H : ¬a ∧ ¬b) (N : a ∨ b),
|
2014-09-05 04:25:21 +00:00
|
|
|
|
or.elim N
|
2014-09-05 00:44:53 +00:00
|
|
|
|
(assume Ha, absurd Ha (and.elim_left H))
|
|
|
|
|
(assume Hb, absurd Hb (and.elim_right H)))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem not_and_iff_not_or_not {a b : Prop} [Da : decidable a] [Db : decidable b] :
|
|
|
|
|
¬(a ∧ b) ↔ ¬a ∨ ¬b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
|
|
|
|
(assume H, or.elim (em a)
|
|
|
|
|
(assume Ha, or.elim (em b)
|
2014-09-04 23:36:06 +00:00
|
|
|
|
(assume Hb, absurd (and.intro Ha Hb) H)
|
2014-09-05 04:25:21 +00:00
|
|
|
|
(assume Hnb, or.inr Hnb))
|
|
|
|
|
(assume Hna, or.inl Hna))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume (H : ¬a ∨ ¬b) (N : a ∧ b),
|
2014-09-05 04:25:21 +00:00
|
|
|
|
or.elim H
|
2014-09-05 00:44:53 +00:00
|
|
|
|
(assume Hna, absurd (and.elim_left N) Hna)
|
|
|
|
|
(assume Hnb, absurd (and.elim_right N) Hnb))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem imp_iff_not_or {a b : Prop} [Da : decidable a] : (a → b) ↔ ¬a ∨ b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
|
|
|
|
(assume H : a → b, (or.elim (em a)
|
|
|
|
|
(assume Ha : a, or.inr (H Ha))
|
|
|
|
|
(assume Hna : ¬a, or.inl Hna)))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume (H : ¬a ∨ b) (Ha : a),
|
2014-12-15 20:05:44 +00:00
|
|
|
|
or_resolve_right H (not_not_iff⁻¹ ▸ Ha))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem not_implies_iff_and_not {a b : Prop} [Da : decidable a] [Db : decidable b] :
|
|
|
|
|
¬(a → b) ↔ a ∧ ¬b :=
|
|
|
|
|
calc
|
|
|
|
|
¬(a → b) ↔ ¬(¬a ∨ b) : {imp_iff_not_or}
|
|
|
|
|
... ↔ ¬¬a ∧ ¬b : not_or_iff_not_and_not
|
|
|
|
|
... ↔ a ∧ ¬b : {not_not_iff}
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-10-12 20:06:00 +00:00
|
|
|
|
theorem peirce {a b : Prop} [D : decidable a] : ((a → b) → a) → a :=
|
2014-08-30 03:45:57 +00:00
|
|
|
|
assume H, by_contradiction (assume Hna : ¬a,
|
2014-12-15 20:05:44 +00:00
|
|
|
|
have Hnna : ¬¬a, from not_not_of_not_implies (mt H Hna),
|
2014-08-30 03:45:57 +00:00
|
|
|
|
absurd (not_not_elim Hnna) Hna)
|
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem forall_not_of_not_exists {A : Type} {P : A → Prop} [D : ∀x, decidable (P x)]
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(H : ¬∃x, P x) : ∀x, ¬P x :=
|
2014-09-08 01:14:58 +00:00
|
|
|
|
take x, or.elim (em (P x))
|
2014-12-16 03:05:03 +00:00
|
|
|
|
(assume Hp : P x, absurd (exists.intro x Hp) H)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume Hn : ¬P x, Hn)
|
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem exists_not_of_not_forall {A : Type} {P : A → Prop} [D : ∀x, decidable (P x)]
|
2014-10-12 20:06:00 +00:00
|
|
|
|
[D' : decidable (∃x, ¬P x)] (H : ¬∀x, P x) :
|
2014-08-30 03:45:57 +00:00
|
|
|
|
∃x, ¬P x :=
|
|
|
|
|
@by_contradiction _ D' (assume H1 : ¬∃x, ¬P x,
|
2015-02-25 20:34:49 +00:00
|
|
|
|
have H2 : ∀x, ¬¬P x, from @forall_not_of_not_exists _ _ (take x, decidable_not) H1,
|
2014-08-30 03:45:57 +00:00
|
|
|
|
have H3 : ∀x, P x, from take x, @not_not_elim _ (D x) (H2 x),
|
|
|
|
|
absurd H3 H)
|
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem ne_self_iff_false {A : Type} (a : A) : (a ≠ a) ↔ false :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
2014-12-01 04:34:12 +00:00
|
|
|
|
(assume H, false.of_ne H)
|
2014-12-15 20:05:44 +00:00
|
|
|
|
(assume H, false.elim H)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem eq_self_iff_true {A : Type} (a : A) : (a = a) ↔ true :=
|
2014-09-04 23:36:06 +00:00
|
|
|
|
iff_true_intro rfl
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem heq_self_iff_true {A : Type} (a : A) : (a == a) ↔ true :=
|
2014-10-04 04:40:51 +00:00
|
|
|
|
iff_true_intro (heq.refl a)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem iff_not_self (a : Prop) : (a ↔ ¬a) ↔ false :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
2014-08-30 03:45:57 +00:00
|
|
|
|
(assume H,
|
|
|
|
|
have H' : ¬a, from assume Ha, (H ▸ Ha) Ha,
|
|
|
|
|
H' (H⁻¹ ▸ H'))
|
2014-12-15 20:05:44 +00:00
|
|
|
|
(assume H, false.elim H)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem true_iff_false : (true ↔ false) ↔ false :=
|
|
|
|
|
not_true_iff_false ▸ (iff_not_self true)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem false_iff_true : (false ↔ true) ↔ false :=
|
|
|
|
|
not_false_iff_true ▸ (iff_not_self false)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem iff_true_iff (a : Prop) : (a ↔ true) ↔ a :=
|
2014-12-12 21:50:53 +00:00
|
|
|
|
iff.intro (assume H, of_iff_true H) (assume H, iff_true_intro H)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem iff_false_iff_not (a : Prop) : (a ↔ false) ↔ ¬a :=
|
2014-12-12 21:50:53 +00:00
|
|
|
|
iff.intro (assume H, not_of_iff_false H) (assume H, iff_false_intro H)
|