2014-01-05 20:05:08 +00:00
|
|
|
|
import macros
|
2013-12-29 21:03:32 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
universe M : 512
|
|
|
|
|
universe U : M+512
|
2013-12-30 05:59:57 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
variable Bool : Type
|
|
|
|
|
-- The following builtin declarations can be removed as soon as Lean supports inductive datatypes and match expressions
|
|
|
|
|
builtin true : Bool
|
|
|
|
|
builtin false : Bool
|
|
|
|
|
builtin if {A : (Type U)} : Bool → A → A → A
|
2013-12-30 05:59:57 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition TypeU := (Type U)
|
|
|
|
|
definition TypeM := (Type M)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition implies (a b : Bool) : Bool
|
|
|
|
|
:= if a b true
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infixr 25 => : implies
|
|
|
|
|
infixr 25 ⇒ : implies
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition iff (a b : Bool) : Bool
|
|
|
|
|
:= a == b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infixr 25 <=> : iff
|
|
|
|
|
infixr 25 ⇔ : iff
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition not (a : Bool) : Bool
|
|
|
|
|
:= if a false true
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
notation 40 ¬ _ : not
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition or (a b : Bool) : Bool
|
|
|
|
|
:= ¬ a ⇒ b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infixr 30 || : or
|
|
|
|
|
infixr 30 \/ : or
|
|
|
|
|
infixr 30 ∨ : or
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition and (a b : Bool) : Bool
|
|
|
|
|
:= ¬ (a ⇒ ¬ b)
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infixr 35 && : and
|
|
|
|
|
infixr 35 /\ : and
|
|
|
|
|
infixr 35 ∧ : and
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Forall is a macro for the identifier forall, we use that
|
|
|
|
|
-- because the Lean parser has the builtin syntax sugar:
|
|
|
|
|
-- forall x : T, P x
|
|
|
|
|
-- for
|
|
|
|
|
-- (forall T (fun x : T, P x))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition Forall (A : TypeU) (P : A → Bool) : Bool
|
|
|
|
|
:= P == (λ x : A, true)
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition Exists (A : TypeU) (P : A → Bool) : Bool
|
|
|
|
|
:= ¬ (Forall A (λ x : A, ¬ (P x)))
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition eq {A : TypeU} (a b : A) : Bool
|
|
|
|
|
:= a == b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infix 50 = : eq
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition neq {A : TypeU} (a b : A) : Bool
|
|
|
|
|
:= ¬ (a == b)
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
infix 50 ≠ : neq
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom MP {a b : Bool} (H1 : a ⇒ b) (H2 : a) : b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Discharge {a b : Bool} (H : a → b) : a ⇒ b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Case (P : Bool → Bool) (H1 : P true) (H2 : P false) (a : Bool) : P a
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Refl {A : TypeU} (a : A) : a == a
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Subst {A : TypeU} {a b : A} {P : A → Bool} (H1 : P a) (H2 : a == b) : P b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition SubstP {A : TypeU} {a b : A} (P : A → Bool) (H1 : P a) (H2 : a == b) : P b
|
|
|
|
|
:= Subst H1 H2
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Eta {A : TypeU} {B : A → TypeU} (f : Π x : A, B x) : (λ x : A, f x) == f
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom ImpAntisym {a b : Bool} (H1 : a ⇒ b) (H2 : b ⇒ a) : a == b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom Abst {A : TypeU} {B : A → TypeU} {f g : Π x : A, B x} (H : Π x : A, f x == g x) : f == g
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom HSymm {A B : TypeU} {a : A} {b : B} (H : a == b) : b == a
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
axiom HTrans {A B C : TypeU} {a : A} {b : B} {c : C} (H1 : a == b) (H2 : b == c) : a == c
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Trivial : true
|
|
|
|
|
:= Refl true
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem TrueNeFalse : not (true == false)
|
|
|
|
|
:= Trivial
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EM (a : Bool) : a ∨ ¬ a
|
|
|
|
|
:= Case (λ x, x ∨ ¬ x) Trivial Trivial a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem FalseElim (a : Bool) (H : false) : a
|
|
|
|
|
:= Case (λ x, x) Trivial H a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Absurd {a : Bool} (H1 : a) (H2 : ¬ a) : false
|
|
|
|
|
:= MP H2 H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EqMP {a b : Bool} (H1 : a == b) (H2 : a) : b
|
|
|
|
|
:= Subst H2 H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Assume is a 'macro' that expands into a Discharge
|
2014-01-03 18:33:57 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ImpTrans {a b c : Bool} (H1 : a ⇒ b) (H2 : b ⇒ c) : a ⇒ c
|
|
|
|
|
:= Assume Ha, MP H2 (MP H1 Ha)
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ImpEqTrans {a b c : Bool} (H1 : a ⇒ b) (H2 : b == c) : a ⇒ c
|
|
|
|
|
:= Assume Ha, EqMP H2 (MP H1 Ha)
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EqImpTrans {a b c : Bool} (H1 : a == b) (H2 : b ⇒ c) : a ⇒ c
|
|
|
|
|
:= Assume Ha, MP H2 (EqMP H1 Ha)
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem DoubleNeg (a : Bool) : (¬ ¬ a) == a
|
|
|
|
|
:= Case (λ x, (¬ ¬ x) == x) Trivial Trivial a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem DoubleNegElim {a : Bool} (H : ¬ ¬ a) : a
|
|
|
|
|
:= EqMP (DoubleNeg a) H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem MT {a b : Bool} (H1 : a ⇒ b) (H2 : ¬ b) : ¬ a
|
|
|
|
|
:= Assume H : a, Absurd (MP H1 H) H2
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Contrapos {a b : Bool} (H : a ⇒ b) : ¬ b ⇒ ¬ a
|
|
|
|
|
:= Assume H1 : ¬ b, MT H H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AbsurdElim {a : Bool} (b : Bool) (H1 : a) (H2 : ¬ a) : b
|
|
|
|
|
:= FalseElim b (Absurd H1 H2)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotImp1 {a b : Bool} (H : ¬ (a ⇒ b)) : a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= DoubleNegElim
|
2014-01-05 19:25:58 +00:00
|
|
|
|
(have ¬ ¬ a :
|
|
|
|
|
Assume H1 : ¬ a, Absurd (have a ⇒ b : Assume H2 : a, AbsurdElim b H2 H1)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(have ¬ (a ⇒ b) : H))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotImp2 {a b : Bool} (H : ¬ (a ⇒ b)) : ¬ b
|
2014-01-05 19:25:58 +00:00
|
|
|
|
:= Assume H1 : b, Absurd (have a ⇒ b : Assume H2 : a, H1)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(have ¬ (a ⇒ b) : H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Remark: conjunction is defined as ¬ (a ⇒ ¬ b) in Lean
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Conj {a b : Bool} (H1 : a) (H2 : b) : a ∧ b
|
|
|
|
|
:= Assume H : a ⇒ ¬ b, Absurd H2 (MP H H1)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Conjunct1 {a b : Bool} (H : a ∧ b) : a
|
|
|
|
|
:= NotImp1 H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Conjunct2 {a b : Bool} (H : a ∧ b) : b
|
|
|
|
|
:= DoubleNegElim (NotImp2 H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Remark: disjunction is defined as ¬ a ⇒ b in Lean
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Disj1 {a : Bool} (H : a) (b : Bool) : a ∨ b
|
|
|
|
|
:= Assume H1 : ¬ a, AbsurdElim b H H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Disj2 {b : Bool} (a : Bool) (H : b) : a ∨ b
|
|
|
|
|
:= Assume H1 : ¬ a, H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ArrowToImplies {a b : Bool} (H : a → b) : a ⇒ b
|
|
|
|
|
:= Assume H1 : a, H H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Resolve1 {a b : Bool} (H1 : a ∨ b) (H2 : ¬ a) : b
|
|
|
|
|
:= MP H1 H2
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem DisjCases {a b c : Bool} (H1 : a ∨ b) (H2 : a → c) (H3 : b → c) : c
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= DoubleNegElim
|
2014-01-04 02:11:01 +00:00
|
|
|
|
(Assume H : ¬ c,
|
2014-01-05 19:25:58 +00:00
|
|
|
|
Absurd (have c : H3 (have b : Resolve1 H1 (have ¬ a : (MT (ArrowToImplies H2) H))))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
H)
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Refute {a : Bool} (H : ¬ a → false) : a
|
|
|
|
|
:= DisjCases (EM a) (λ H1 : a, H1) (λ H1 : ¬ a, FalseElim a (H H1))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Symm {A : TypeU} {a b : A} (H : a == b) : b == a
|
|
|
|
|
:= Subst (Refl a) H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NeSymm {A : TypeU} {a b : A} (H : a ≠ b) : b ≠ a
|
|
|
|
|
:= Assume H1 : b = a, MP H (Symm H1)
|
2014-01-03 06:47:45 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EqNeTrans {A : TypeU} {a b c : A} (H1 : a = b) (H2 : b ≠ c) : a ≠ c
|
|
|
|
|
:= Subst H2 (Symm H1)
|
2014-01-03 06:47:45 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NeEqTrans {A : TypeU} {a b c : A} (H1 : a ≠ b) (H2 : b = c) : a ≠ c
|
|
|
|
|
:= Subst H1 H2
|
2014-01-03 06:47:45 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Trans {A : TypeU} {a b c : A} (H1 : a == b) (H2 : b == c) : a == c
|
|
|
|
|
:= Subst H1 H2
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EqTElim {a : Bool} (H : a == true) : a
|
|
|
|
|
:= EqMP (Symm H) Trivial
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem EqTIntro {a : Bool} (H : a) : a == true
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H1 : a, Trivial)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H2 : true, H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Congr1 {A : TypeU} {B : A → TypeU} {f g : Π x : A, B x} (a : A) (H : f == g) : f a == g a
|
|
|
|
|
:= SubstP (fun h : (Π x : A, B x), f a == h a) (Refl (f a)) H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Remark: we must use heterogeneous equality in the following theorem because the types of (f a) and (f b)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
-- are not "definitionally equal" They are (B a) and (B b)
|
|
|
|
|
-- They are provably equal, we just have to apply Congr1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Congr2 {A : TypeU} {B : A → TypeU} {a b : A} (f : Π x : A, B x) (H : a == b) : f a == f b
|
|
|
|
|
:= SubstP (fun x : A, f a == f x) (Refl (f a)) H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
-- Remark: like the previous theorem we use heterogeneous equality We cannot use Trans theorem
|
|
|
|
|
-- because the types are not definitionally equal
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem Congr {A : TypeU} {B : A → TypeU} {f g : Π x : A, B x} {a b : A} (H1 : f == g) (H2 : a == b) : f a == g b
|
|
|
|
|
:= HTrans (Congr2 f H2) (Congr1 b H1)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ForallElim {A : TypeU} {P : A → Bool} (H : Forall A P) (a : A) : P a
|
|
|
|
|
:= EqTElim (Congr1 a H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ForallIntro {A : TypeU} {P : A → Bool} (H : Π x : A, P x) : Forall A P
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Trans (Symm (Eta P))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Abst (λ x, EqTIntro (H x)))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- Remark: the existential is defined as (¬ (forall x : A, ¬ P x))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ExistsElim {A : TypeU} {P : A → Bool} {B : Bool} (H1 : Exists A P) (H2 : Π (a : A) (H : P a), B) : B
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Refute (λ R : ¬ B,
|
2014-01-04 02:11:01 +00:00
|
|
|
|
Absurd (ForallIntro (λ a : A, MT (Assume H : P a, H2 a H) R))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
H1)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ExistsIntro {A : TypeU} {P : A → Bool} (a : A) (H : P a) : Exists A P
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= Assume H1 : (∀ x : A, ¬ P x),
|
2014-01-05 20:05:08 +00:00
|
|
|
|
Absurd H (ForallElim H1 a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
|
-- At this point, we have proved the theorems we need using the
|
2014-01-05 20:05:08 +00:00
|
|
|
|
-- definitions of forall, exists, and, or, =>, not We mark (some of)
|
|
|
|
|
-- them as opaque Opaque definitions improve performance, and
|
|
|
|
|
-- effectiveness of Lean's elaborator
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
setopaque implies true
|
|
|
|
|
setopaque not true
|
|
|
|
|
setopaque or true
|
|
|
|
|
setopaque and true
|
|
|
|
|
setopaque forall true
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrComm (a b : Bool) : (a ∨ b) == (b ∨ a)
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, DisjCases H (λ H1, Disj2 b H1) (λ H2, Disj1 H2 a))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, DisjCases H (λ H1, Disj2 a H1) (λ H2, Disj1 H2 b))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrAssoc (a b c : Bool) : ((a ∨ b) ∨ c) == (a ∨ (b ∨ c))
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H : (a ∨ b) ∨ c,
|
2013-12-29 10:44:49 +00:00
|
|
|
|
DisjCases H (λ H1 : a ∨ b, DisjCases H1 (λ Ha : a, Disj1 Ha (b ∨ c)) (λ Hb : b, Disj2 a (Disj1 Hb c)))
|
|
|
|
|
(λ Hc : c, Disj2 a (Disj2 b Hc)))
|
2014-01-04 02:11:01 +00:00
|
|
|
|
(Assume H : a ∨ (b ∨ c),
|
2013-12-29 10:44:49 +00:00
|
|
|
|
DisjCases H (λ Ha : a, (Disj1 (Disj1 Ha b) c))
|
|
|
|
|
(λ H1 : b ∨ c, DisjCases H1 (λ Hb : b, Disj1 (Disj2 a Hb) c)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(λ Hc : c, Disj2 (a ∨ b) Hc)))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrId (a : Bool) : (a ∨ a) == a
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, DisjCases H (λ H1, H1) (λ H2, H2))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, Disj1 H a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrRhsFalse (a : Bool) : (a ∨ false) == a
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, DisjCases H (λ H1, H1) (λ H2, FalseElim a H2))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, Disj1 H false)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrLhsFalse (a : Bool) : (false ∨ a) == a
|
|
|
|
|
:= Trans (OrComm false a) (OrRhsFalse a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrLhsTrue (a : Bool) : (true ∨ a) == true
|
|
|
|
|
:= EqTIntro (Case (λ x : Bool, true ∨ x) Trivial Trivial a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrRhsTrue (a : Bool) : (a ∨ true) == true
|
|
|
|
|
:= Trans (OrComm a true) (OrLhsTrue a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem OrAnotA (a : Bool) : (a ∨ ¬ a) == true
|
|
|
|
|
:= EqTIntro (EM a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndComm (a b : Bool) : (a ∧ b) == (b ∧ a)
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, Conj (Conjunct2 H) (Conjunct1 H))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, Conj (Conjunct2 H) (Conjunct1 H))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndId (a : Bool) : (a ∧ a) == a
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, Conjunct1 H)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, Conj H H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndAssoc (a b c : Bool) : ((a ∧ b) ∧ c) == (a ∧ (b ∧ c))
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, Conj (Conjunct1 (Conjunct1 H)) (Conj (Conjunct2 (Conjunct1 H)) (Conjunct2 H)))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, Conj (Conj (Conjunct1 H) (Conjunct1 (Conjunct2 H))) (Conjunct2 (Conjunct2 H)))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndRhsTrue (a : Bool) : (a ∧ true) == a
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H : a ∧ true, Conjunct1 H)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H : a, Conj H Trivial)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndLhsTrue (a : Bool) : (true ∧ a) == a
|
|
|
|
|
:= Trans (AndComm true a) (AndRhsTrue a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndRhsFalse (a : Bool) : (a ∧ false) == false
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, Conjunct2 H)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, FalseElim (a ∧ false) H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndLhsFalse (a : Bool) : (false ∧ a) == false
|
|
|
|
|
:= Trans (AndComm false a) (AndRhsFalse a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem AndAnotA (a : Bool) : (a ∧ ¬ a) == false
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H, Absurd (Conjunct1 H) (Conjunct2 H))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H, FalseElim (a ∧ ¬ a) H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotTrue : (¬ true) == false
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Trivial
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotFalse : (¬ false) == true
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Trivial
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotAnd (a b : Bool) : (¬ (a ∧ b)) == (¬ a ∨ ¬ b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Case (λ x, (¬ (x ∧ b)) == (¬ x ∨ ¬ b))
|
|
|
|
|
(Case (λ y, (¬ (true ∧ y)) == (¬ true ∨ ¬ y)) Trivial Trivial b)
|
|
|
|
|
(Case (λ y, (¬ (false ∧ y)) == (¬ false ∨ ¬ y)) Trivial Trivial b)
|
|
|
|
|
a
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotAndElim {a b : Bool} (H : ¬ (a ∧ b)) : ¬ a ∨ ¬ b
|
|
|
|
|
:= EqMP (NotAnd a b) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotOr (a b : Bool) : (¬ (a ∨ b)) == (¬ a ∧ ¬ b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Case (λ x, (¬ (x ∨ b)) == (¬ x ∧ ¬ b))
|
|
|
|
|
(Case (λ y, (¬ (true ∨ y)) == (¬ true ∧ ¬ y)) Trivial Trivial b)
|
|
|
|
|
(Case (λ y, (¬ (false ∨ y)) == (¬ false ∧ ¬ y)) Trivial Trivial b)
|
|
|
|
|
a
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotOrElim {a b : Bool} (H : ¬ (a ∨ b)) : ¬ a ∧ ¬ b
|
|
|
|
|
:= EqMP (NotOr a b) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotEq (a b : Bool) : (¬ (a == b)) == ((¬ a) == b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Case (λ x, (¬ (x == b)) == ((¬ x) == b))
|
|
|
|
|
(Case (λ y, (¬ (true == y)) == ((¬ true) == y)) Trivial Trivial b)
|
|
|
|
|
(Case (λ y, (¬ (false == y)) == ((¬ false) == y)) Trivial Trivial b)
|
|
|
|
|
a
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotEqElim {a b : Bool} (H : ¬ (a == b)) : (¬ a) == b
|
|
|
|
|
:= EqMP (NotEq a b) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotImp (a b : Bool) : (¬ (a ⇒ b)) == (a ∧ ¬ b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
:= Case (λ x, (¬ (x ⇒ b)) == (x ∧ ¬ b))
|
|
|
|
|
(Case (λ y, (¬ (true ⇒ y)) == (true ∧ ¬ y)) Trivial Trivial b)
|
|
|
|
|
(Case (λ y, (¬ (false ⇒ y)) == (false ∧ ¬ y)) Trivial Trivial b)
|
|
|
|
|
a
|
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotImpElim {a b : Bool} (H : ¬ (a ⇒ b)) : a ∧ ¬ b
|
|
|
|
|
:= EqMP (NotImp a b) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotCongr {a b : Bool} (H : a == b) : (¬ a) == (¬ b)
|
|
|
|
|
:= Congr2 not H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ForallEqIntro {A : (Type U)} {P Q : A → Bool} (H : Pi x : A, P x == Q x) : (∀ x : A, P x) == (∀ x : A, Q x)
|
|
|
|
|
:= Congr2 (Forall A) (Abst H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem ExistsEqIntro {A : (Type U)} {P Q : A → Bool} (H : Pi x : A, P x == Q x) : (∃ x : A, P x) == (∃ x : A, Q x)
|
|
|
|
|
:= Congr2 (Exists A) (Abst H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotForall (A : (Type U)) (P : A → Bool) : (¬ (∀ x : A, P x)) == (∃ x : A, ¬ P x)
|
2013-12-30 04:16:01 +00:00
|
|
|
|
:= let L1 : (¬ ∀ x : A, ¬ ¬ P x) == (∃ x : A, ¬ P x) := Refl (∃ x : A, ¬ P x),
|
|
|
|
|
L2 : (¬ ∀ x : A, P x) == (¬ ∀ x : A, ¬ ¬ P x) :=
|
2013-12-29 10:44:49 +00:00
|
|
|
|
NotCongr (ForallEqIntro (λ x : A, (Symm (DoubleNeg (P x)))))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
in Trans L2 L1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotForallElim {A : (Type U)} {P : A → Bool} (H : ¬ (∀ x : A, P x)) : ∃ x : A, ¬ P x
|
|
|
|
|
:= EqMP (NotForall A P) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotExists (A : (Type U)) (P : A → Bool) : (¬ ∃ x : A, P x) == (∀ x : A, ¬ P x)
|
2013-12-30 04:16:01 +00:00
|
|
|
|
:= let L1 : (¬ ∃ x : A, P x) == (¬ ¬ ∀ x : A, ¬ P x) := Refl (¬ ∃ x : A, P x),
|
|
|
|
|
L2 : (¬ ¬ ∀ x : A, ¬ P x) == (∀ x : A, ¬ P x) := DoubleNeg (∀ x : A, ¬ P x)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
in Trans L1 L2
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem NotExistsElim {A : (Type U)} {P : A → Bool} (H : ¬ ∃ x : A, P x) : ∀ x : A, ¬ P x
|
|
|
|
|
:= EqMP (NotExists A P) H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem UnfoldExists1 {A : TypeU} {P : A → Bool} (a : A) (H : ∃ x : A, P x) : P a ∨ (∃ x : A, x ≠ a ∧ P x)
|
2013-12-30 02:30:41 +00:00
|
|
|
|
:= ExistsElim H
|
|
|
|
|
(λ (w : A) (H1 : P w),
|
|
|
|
|
DisjCases (EM (w = a))
|
|
|
|
|
(λ Heq : w = a, Disj1 (Subst H1 Heq) (∃ x : A, x ≠ a ∧ P x))
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(λ Hne : w ≠ a, Disj2 (P a) (ExistsIntro w (Conj Hne H1))))
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem UnfoldExists2 {A : TypeU} {P : A → Bool} (a : A) (H : P a ∨ (∃ x : A, x ≠ a ∧ P x)) : ∃ x : A, P x
|
2013-12-30 04:33:31 +00:00
|
|
|
|
:= DisjCases H
|
|
|
|
|
(λ H1 : P a, ExistsIntro a H1)
|
|
|
|
|
(λ H2 : (∃ x : A, x ≠ a ∧ P x),
|
|
|
|
|
ExistsElim H2
|
2013-12-30 02:30:41 +00:00
|
|
|
|
(λ (w : A) (Hw : w ≠ a ∧ P w),
|
2014-01-05 20:05:08 +00:00
|
|
|
|
ExistsIntro w (Conjunct2 Hw)))
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
theorem UnfoldExists {A : TypeU} (P : A → Bool) (a : A) : (∃ x : A, P x) = (P a ∨ (∃ x : A, x ≠ a ∧ P x))
|
2014-01-04 02:11:01 +00:00
|
|
|
|
:= ImpAntisym (Assume H : (∃ x : A, P x), UnfoldExists1 a H)
|
2014-01-05 20:05:08 +00:00
|
|
|
|
(Assume H : (P a ∨ (∃ x : A, x ≠ a ∧ P x)), UnfoldExists2 a H)
|
2014-01-01 19:00:32 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
setopaque exists true
|