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-07-23 00:21:47 +00:00
|
|
|
|
theorem or.left_comm [simp] (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-09-25 03:38:52 +00:00
|
|
|
|
theorem or_not_self_iff {a : Prop} [D : decidable a] : a ∨ ¬ a ↔ true :=
|
|
|
|
|
iff.intro (assume H, trivial) (assume H, em a)
|
|
|
|
|
|
|
|
|
|
theorem not_or_self_iff {a : Prop} [D : decidable a] : ¬ a ∨ a ↔ true :=
|
|
|
|
|
!or.comm ▸ !or_not_self_iff
|
|
|
|
|
|
|
|
|
|
theorem and_not_self_iff {a : Prop} : a ∧ ¬ a ↔ false :=
|
|
|
|
|
iff.intro (assume H, (and.right H) (and.left H)) (assume H, false.elim H)
|
|
|
|
|
|
|
|
|
|
theorem not_and_self_iff {a : Prop} : ¬ a ∧ a ↔ false :=
|
|
|
|
|
!and.comm ▸ !and_not_self_iff
|
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem and.left_comm [simp] (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 :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
iff.intro by_contradiction not_not_intro
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-24 15:56:18 +00:00
|
|
|
|
theorem not_not_elim {a : Prop} [D : decidable a] : ¬¬a → a :=
|
|
|
|
|
by_contradiction
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-24 15:56:18 +00:00
|
|
|
|
theorem not_or_iff_not_and_not {a b : Prop} : ¬(a ∨ b) ↔ ¬a ∧ ¬b :=
|
|
|
|
|
or.imp_distrib
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-24 15:56:18 +00:00
|
|
|
|
theorem not_and_iff_not_or_not {a b : Prop} [Da : decidable a] :
|
2014-12-15 21:13:04 +00:00
|
|
|
|
¬(a ∧ b) ↔ ¬a ∨ ¬b :=
|
2014-09-05 04:25:21 +00:00
|
|
|
|
iff.intro
|
2015-07-24 15:56:18 +00:00
|
|
|
|
(λH, by_cases (λa, or.inr (not.mto (and.intro a) H)) or.inl)
|
|
|
|
|
(or.rec (not.mto and.left) (not.mto and.right))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-08-27 18:26:21 +00:00
|
|
|
|
theorem or_iff_not_and_not {a b : Prop} [Da : decidable a] [Db : decidable b] :
|
|
|
|
|
a ∨ b ↔ ¬ (¬a ∧ ¬b) :=
|
|
|
|
|
by rewrite [-not_or_iff_not_and_not, not_not_iff]
|
|
|
|
|
|
|
|
|
|
theorem and_iff_not_or_not {a b : Prop} [Da : decidable a] [Db : decidable b] :
|
|
|
|
|
a ∧ b ↔ ¬ (¬ a ∨ ¬ b) :=
|
|
|
|
|
by rewrite [-not_and_iff_not_or_not, not_not_iff]
|
|
|
|
|
|
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
|
2015-07-24 15:56:18 +00:00
|
|
|
|
(by_cases (λHa H, or.inr (H Ha)) (λHa H, or.inl Ha))
|
|
|
|
|
(or.rec not.elim imp.intro)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-24 15:56:18 +00:00
|
|
|
|
theorem not_implies_iff_and_not {a b : Prop} [Da : decidable a] :
|
2014-12-15 21:13:04 +00:00
|
|
|
|
¬(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 :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
by_cases imp.intro (imp.syl imp.mp not.elim)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-06-04 03:41:52 +00:00
|
|
|
|
theorem forall_not_of_not_exists {A : Type} {p : A → Prop} [D : ∀x, decidable (p x)]
|
|
|
|
|
(H : ¬∃x, p x) : ∀x, ¬p x :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
take x, by_cases
|
|
|
|
|
(assume Hp : p x, absurd (exists.intro x Hp) H)
|
|
|
|
|
imp.id
|
2015-06-04 03:41:52 +00:00
|
|
|
|
|
|
|
|
|
theorem forall_of_not_exists_not {A : Type} {p : A → Prop} [D : decidable_pred p] :
|
|
|
|
|
¬(∃ x, ¬p x) → ∀ x, p x :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
imp.syl (forall_imp_forall (λa, not_not_elim)) forall_not_of_not_exists
|
2015-06-04 03:41:52 +00:00
|
|
|
|
|
|
|
|
|
theorem exists_not_of_not_forall {A : Type} {p : A → Prop} [D : ∀x, decidable (p x)]
|
|
|
|
|
[D' : decidable (∃x, ¬p x)] (H : ¬∀x, p x) :
|
|
|
|
|
∃x, ¬p x :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
by_contradiction (λH1, absurd (λx, not_not_elim (forall_not_of_not_exists H1 x)) H)
|
2015-06-04 03:41:52 +00:00
|
|
|
|
|
|
|
|
|
theorem exists_of_not_forall_not {A : Type} {p : A → Prop} [D : ∀x, decidable (p x)]
|
2015-07-24 15:56:18 +00:00
|
|
|
|
[D' : decidable (∃x, p x)] (H : ¬∀x, ¬ p x) :
|
2015-06-04 03:41:52 +00:00
|
|
|
|
∃x, p x :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
by_contradiction (imp.syl H forall_not_of_not_exists)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2014-12-15 21:13:04 +00:00
|
|
|
|
theorem ne_self_iff_false {A : Type} (a : A) : (a ≠ a) ↔ false :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
iff.intro false.of_ne false.elim
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem eq_self_iff_true [simp] {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
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem heq_self_iff_true [simp] {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
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem iff_not_self [simp] (a : Prop) : (a ↔ ¬a) ↔ false :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
iff_false_intro (λH,
|
|
|
|
|
have H' : ¬a, from (λHa, (mp H Ha) Ha),
|
|
|
|
|
H' (iff.mpr H H'))
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem true_iff_false [simp] : (true ↔ false) ↔ false :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
not_true ▸ (iff_not_self true)
|
2014-08-30 03:45:57 +00:00
|
|
|
|
|
2015-07-23 00:21:47 +00:00
|
|
|
|
theorem false_iff_true [simp] : (false ↔ true) ↔ false :=
|
2015-07-24 15:56:18 +00:00
|
|
|
|
not_false_iff ▸ (iff_not_self false)
|