2014-01-05 20:05:08 +00:00
|
|
|
|
import macros
|
2013-12-29 21:03:32 +00:00
|
|
|
|
|
2014-01-08 20:34:55 +00:00
|
|
|
|
universe U ≥ 1
|
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)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
|
definition not (a : Bool) : Bool
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= a → false
|
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
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= ¬ 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
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= ¬ (a → ¬ b)
|
|
|
|
|
|
|
|
|
|
definition implies (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 20:05:08 +00:00
|
|
|
|
definition Exists (A : TypeU) (P : A → Bool) : Bool
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= ¬ (∀ 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-06 03:10:21 +00:00
|
|
|
|
axiom refl {A : TypeU} (a : A) : a == a
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
axiom subst {A : TypeU} {a b : A} {P : A → Bool} (H1 : P a) (H2 : a == b) : P b
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
axiom iff::intro {a b : Bool} (H1 : a → b) (H2 : b → a) : a == b
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
axiom abst {A : TypeU} {B : A → TypeU} {f g : ∀ x : A, B x} (H : ∀ x : A, f x == g x) : f == g
|
|
|
|
|
|
|
|
|
|
axiom abstpi {A : TypeU} {B C : A → TypeU} (H : ∀ x : A, B x == C x) : (∀ x : A, B x) == (∀ x : A, C x)
|
2013-12-29 22:01:30 +00:00
|
|
|
|
|
2014-01-09 00:19:11 +00:00
|
|
|
|
axiom eta {A : TypeU} {B : A → TypeU} (f : ∀ x : A, B x) : (λ x : A, f x) == f
|
|
|
|
|
|
|
|
|
|
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-09 00:19:11 +00:00
|
|
|
|
-- Alias for subst where we can provide P explicitly, but keep A,a,b implicit
|
|
|
|
|
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-06 03:10:21 +00:00
|
|
|
|
theorem trivial : true
|
|
|
|
|
:= refl true
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +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-06 03:10:21 +00:00
|
|
|
|
theorem false::elim (a : Bool) (H : false) : a
|
|
|
|
|
:= case (λ x, x) trivial H a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem absurd {a : Bool} (H1 : a) (H2 : ¬ a) : false
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= H2 H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem eqmp {a b : Bool} (H1 : a == b) (H2 : a) : b
|
2014-01-06 03:10:21 +00:00
|
|
|
|
:= subst H2 H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
infixl 100 <| : eqmp
|
|
|
|
|
infixl 100 ◂ : eqmp
|
2014-01-03 18:33:57 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
-- assume is a 'macro' that expands into a discharge
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem imp::trans {a b c : Bool} (H1 : a → b) (H2 : b → c) : a → c
|
|
|
|
|
:= λ Ha, H2 (H1 Ha)
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem imp::eq::trans {a b c : Bool} (H1 : a → b) (H2 : b == c) : a → c
|
|
|
|
|
:= λ Ha, H2 ◂ (H1 Ha)
|
2014-01-02 18:53:14 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem eq::imp::trans {a b c : Bool} (H1 : a == b) (H2 : b → c) : a → c
|
|
|
|
|
:= λ Ha, H2 (H1 ◂ Ha)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::not::eq (a : Bool) : (¬ ¬ a) == a
|
|
|
|
|
:= case (λ x, (¬ ¬ x) == x) trivial trivial a
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::not::elim {a : Bool} (H : ¬ ¬ a) : a
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::not::eq a) ◂ H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem mt {a b : Bool} (H1 : a → b) (H2 : ¬ b) : ¬ a
|
|
|
|
|
:= λ Ha, absurd (H1 Ha) H2
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem contrapos {a b : Bool} (H : a → b) : ¬ b → ¬ a
|
|
|
|
|
:= λ Hnb : ¬ b, mt H Hnb
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem absurd::elim {a : Bool} (b : Bool) (H1 : a) (H2 : ¬ a) : b
|
|
|
|
|
:= false::elim b (absurd H1 H2)
|
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem not::imp::eliml {a b : Bool} (Hnab : ¬ (a → b)) : a
|
2014-01-06 03:10:21 +00:00
|
|
|
|
:= not::not::elim
|
2014-01-05 19:25:58 +00:00
|
|
|
|
(have ¬ ¬ a :
|
2014-01-08 08:38:39 +00:00
|
|
|
|
λ Hna : ¬ a, absurd (have a → b : λ Ha : a, absurd::elim b Ha Hna)
|
|
|
|
|
Hnab)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem not::imp::elimr {a b : Bool} (H : ¬ (a → b)) : ¬ b
|
|
|
|
|
:= λ Hb : b, absurd (have a → b : λ Ha : a, Hb)
|
|
|
|
|
(have ¬ (a → b) : H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem resolve1 {a b : Bool} (H1 : a ∨ b) (H2 : ¬ a) : b
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= H1 H2
|
2014-01-06 03:10:21 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
-- Remark: conjunction is defined as ¬ (a → ¬ b) in Lean
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::intro {a b : Bool} (H1 : a) (H2 : b) : a ∧ b
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= λ H : a → ¬ b, absurd H2 (H H1)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::eliml {a b : Bool} (H : a ∧ b) : a
|
|
|
|
|
:= not::imp::eliml H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::elimr {a b : Bool} (H : a ∧ b) : b
|
|
|
|
|
:= not::not::elim (not::imp::elimr H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
-- Remark: disjunction is defined as ¬ a → b in Lean
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::introl {a : Bool} (H : a) (b : Bool) : a ∨ b
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= λ H1 : ¬ a, absurd::elim b H H1
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::intror {b : Bool} (a : Bool) (H : b) : a ∨ b
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= λ H1 : ¬ a, H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::elim {a b c : Bool} (H1 : a ∨ b) (H2 : a → c) (H3 : b → c) : c
|
|
|
|
|
:= not::not::elim
|
2014-01-08 08:38:39 +00:00
|
|
|
|
(λ H : ¬ c,
|
|
|
|
|
absurd (have c : H3 (have b : resolve1 H1 (have ¬ a : (mt (λ Ha : a, H2 Ha) H))))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
H)
|
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem refute {a : Bool} (H : ¬ a → false) : a
|
|
|
|
|
:= or::elim (em a) (λ H1 : a, H1) (λ H1 : ¬ a, false::elim a (H H1))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +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-06 03:10:21 +00:00
|
|
|
|
theorem trans {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-06 03:10:21 +00:00
|
|
|
|
infixl 100 ⋈ : trans
|
2014-01-03 06:47:45 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem ne::symm {A : TypeU} {a b : A} (H : a ≠ b) : b ≠ a
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= λ H1 : b = a, H (symm H1)
|
2014-01-03 06:47:45 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem eq::ne::trans {A : TypeU} {a b c : A} (H1 : a = b) (H2 : b ≠ c) : a ≠ c
|
|
|
|
|
:= subst H2 (symm H1)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem ne::eq::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-06 03:10:21 +00:00
|
|
|
|
theorem eqt::elim {a : Bool} (H : a == true) : a
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (symm H) ◂ trivial
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem eqt::intro {a : Bool} (H : a) : a == true
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H1 : a, trivial)
|
|
|
|
|
(λ H2 : true, H)
|
2014-01-06 03:10:21 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +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-08 08:38:39 +00:00
|
|
|
|
theorem congr2 {A : TypeU} {B : A → TypeU} {a b : A} (f : ∀ x : A, B x) (H : a == b) : f a == f b
|
2014-01-06 03:10:21 +00:00
|
|
|
|
:= 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-08 08:38:39 +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
|
2014-01-09 00:19:11 +00:00
|
|
|
|
:= subst (congr2 f H2) (congr1 b H1)
|
2014-01-06 03:10:21 +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-08 08:38:39 +00:00
|
|
|
|
theorem exists::elim {A : TypeU} {P : A → Bool} {B : Bool} (H1 : Exists A P) (H2 : ∀ (a : A) (H : P a), B) : B
|
2014-01-06 03:10:21 +00:00
|
|
|
|
:= refute (λ R : ¬ B,
|
2014-01-08 08:38:39 +00:00
|
|
|
|
absurd (λ a : A, mt (λ 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-06 03:10:21 +00:00
|
|
|
|
theorem exists::intro {A : TypeU} {P : A → Bool} (a : A) (H : P a) : Exists A P
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= λ H1 : (∀ x : A, ¬ P x),
|
|
|
|
|
absurd H (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-06 03:10:21 +00:00
|
|
|
|
theorem or::comm (a b : Bool) : (a ∨ b) == (b ∨ a)
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, or::elim H (λ H1, or::intror b H1) (λ H2, or::introl H2 a))
|
|
|
|
|
(λ H, or::elim H (λ H1, or::intror a H1) (λ H2, or::introl H2 b))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::assoc (a b c : Bool) : ((a ∨ b) ∨ c) == (a ∨ (b ∨ c))
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H : (a ∨ b) ∨ c,
|
2014-01-06 03:10:21 +00:00
|
|
|
|
or::elim H (λ H1 : a ∨ b, or::elim H1 (λ Ha : a, or::introl Ha (b ∨ c)) (λ Hb : b, or::intror a (or::introl Hb c)))
|
|
|
|
|
(λ Hc : c, or::intror a (or::intror b Hc)))
|
2014-01-08 08:38:39 +00:00
|
|
|
|
(λ H : a ∨ (b ∨ c),
|
2014-01-06 03:10:21 +00:00
|
|
|
|
or::elim H (λ Ha : a, (or::introl (or::introl Ha b) c))
|
|
|
|
|
(λ H1 : b ∨ c, or::elim H1 (λ Hb : b, or::introl (or::intror a Hb) c)
|
|
|
|
|
(λ Hc : c, or::intror (a ∨ b) Hc)))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::id (a : Bool) : (a ∨ a) == a
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, or::elim H (λ H1, H1) (λ H2, H2))
|
|
|
|
|
(λ H, or::introl H a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::falsel (a : Bool) : (a ∨ false) == a
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, or::elim H (λ H1, H1) (λ H2, false::elim a H2))
|
|
|
|
|
(λ H, or::introl H false)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::falser (a : Bool) : (false ∨ a) == a
|
|
|
|
|
:= (or::comm false a) ⋈ (or::falsel a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::truel (a : Bool) : (true ∨ a) == true
|
|
|
|
|
:= eqt::intro (case (λ x : Bool, true ∨ x) trivial trivial a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::truer (a : Bool) : (a ∨ true) == true
|
|
|
|
|
:= (or::comm a true) ⋈ (or::truel a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem or::tauto (a : Bool) : (a ∨ ¬ a) == true
|
|
|
|
|
:= eqt::intro (em a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::comm (a b : Bool) : (a ∧ b) == (b ∧ a)
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, and::intro (and::elimr H) (and::eliml H))
|
|
|
|
|
(λ H, and::intro (and::elimr H) (and::eliml H))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::id (a : Bool) : (a ∧ a) == a
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, and::eliml H)
|
|
|
|
|
(λ H, and::intro H H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::assoc (a b c : Bool) : ((a ∧ b) ∧ c) == (a ∧ (b ∧ c))
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, and::intro (and::eliml (and::eliml H)) (and::intro (and::elimr (and::eliml H)) (and::elimr H)))
|
|
|
|
|
(λ H, and::intro (and::intro (and::eliml H) (and::eliml (and::elimr H))) (and::elimr (and::elimr H)))
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::truer (a : Bool) : (a ∧ true) == a
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H : a ∧ true, and::eliml H)
|
|
|
|
|
(λ H : a, and::intro H trivial)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::truel (a : Bool) : (true ∧ a) == a
|
|
|
|
|
:= trans (and::comm true a) (and::truer a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::falsel (a : Bool) : (a ∧ false) == false
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, and::elimr H)
|
|
|
|
|
(λ H, false::elim (a ∧ false) H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::falser (a : Bool) : (false ∧ a) == false
|
|
|
|
|
:= (and::comm false a) ⋈ (and::falsel a)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem and::absurd (a : Bool) : (a ∧ ¬ a) == false
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H, absurd (and::eliml H) (and::elimr H))
|
|
|
|
|
(λ H, false::elim (a ∧ ¬ a) H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::true : (¬ true) == false
|
|
|
|
|
:= trivial
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::false : (¬ false) == true
|
|
|
|
|
:= trivial
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::and (a b : Bool) : (¬ (a ∧ b)) == (¬ a ∨ ¬ b)
|
|
|
|
|
:= case (λ x, (¬ (x ∧ b)) == (¬ x ∨ ¬ b))
|
|
|
|
|
(case (λ y, (¬ (true ∧ y)) == (¬ true ∨ ¬ y)) trivial trivial b)
|
|
|
|
|
(case (λ y, (¬ (false ∧ y)) == (¬ false ∨ ¬ y)) trivial trivial b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
a
|
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::and::elim {a b : Bool} (H : ¬ (a ∧ b)) : ¬ a ∨ ¬ b
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::and a b) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::or (a b : Bool) : (¬ (a ∨ b)) == (¬ a ∧ ¬ b)
|
|
|
|
|
:= case (λ x, (¬ (x ∨ b)) == (¬ x ∧ ¬ b))
|
|
|
|
|
(case (λ y, (¬ (true ∨ y)) == (¬ true ∧ ¬ y)) trivial trivial b)
|
|
|
|
|
(case (λ y, (¬ (false ∨ y)) == (¬ false ∧ ¬ y)) trivial trivial b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
a
|
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::or::elim {a b : Bool} (H : ¬ (a ∨ b)) : ¬ a ∧ ¬ b
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::or a b) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::iff (a b : Bool) : (¬ (a == b)) == ((¬ a) == b)
|
|
|
|
|
:= case (λ x, (¬ (x == b)) == ((¬ x) == b))
|
|
|
|
|
(case (λ y, (¬ (true == y)) == ((¬ true) == y)) trivial trivial b)
|
|
|
|
|
(case (λ y, (¬ (false == y)) == ((¬ false) == y)) trivial trivial b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
a
|
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::iff::elim {a b : Bool} (H : ¬ (a == b)) : (¬ a) == b
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::iff a b) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem not::implies (a b : Bool) : (¬ (a → b)) == (a ∧ ¬ b)
|
|
|
|
|
:= case (λ x, (¬ (x → b)) == (x ∧ ¬ b))
|
|
|
|
|
(case (λ y, (¬ (true → y)) == (true ∧ ¬ y)) trivial trivial b)
|
|
|
|
|
(case (λ y, (¬ (false → y)) == (false ∧ ¬ y)) trivial trivial b)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
a
|
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem not::implies::elim {a b : Bool} (H : ¬ (a → b)) : a ∧ ¬ b
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::implies a b) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::congr {a b : Bool} (H : a == b) : (¬ a) == (¬ b)
|
|
|
|
|
:= congr2 not H
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
theorem eq::exists::intro {A : (Type U)} {P Q : A → Bool} (H : ∀ x : A, P x == Q x) : (∃ x : A, P x) == (∃ x : A, Q x)
|
2014-01-06 03:10:21 +00:00
|
|
|
|
:= congr2 (Exists A) (abst H)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::forall (A : (Type U)) (P : A → Bool) : (¬ (∀ x : A, P x)) == (∃ x : A, ¬ P x)
|
2014-01-08 20:10:46 +00:00
|
|
|
|
:= calc (¬ ∀ x : A, P x) = (¬ ∀ x : A, ¬ ¬ P x) : not::congr (abstpi (λ x : A, symm (not::not::eq (P x))))
|
|
|
|
|
... = (∃ x : A, ¬ P x) : refl (∃ x : A, ¬ P x)
|
2013-12-29 10:44:49 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::forall::elim {A : (Type U)} {P : A → Bool} (H : ¬ (∀ x : A, P x)) : ∃ x : A, ¬ P x
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::forall A P) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::exists (A : (Type U)) (P : A → Bool) : (¬ ∃ x : A, P x) == (∀ x : A, ¬ P x)
|
|
|
|
|
:= calc (¬ ∃ x : A, P x) = (¬ ¬ ∀ x : A, ¬ P x) : refl (¬ ∃ x : A, P x)
|
|
|
|
|
... = (∀ x : A, ¬ P x) : not::not::eq (∀ x : A, ¬ P x)
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem not::exists::elim {A : (Type U)} {P : A → Bool} (H : ¬ ∃ x : A, P x) : ∀ x : A, ¬ P x
|
2014-01-06 05:39:31 +00:00
|
|
|
|
:= (not::exists A P) ◂ H
|
2014-01-01 19:35:21 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem exists::unfold1 {A : TypeU} {P : A → Bool} (a : A) (H : ∃ x : A, P x) : P a ∨ (∃ x : A, x ≠ a ∧ P x)
|
|
|
|
|
:= exists::elim H
|
2013-12-30 02:30:41 +00:00
|
|
|
|
(λ (w : A) (H1 : P w),
|
2014-01-06 03:10:21 +00:00
|
|
|
|
or::elim (em (w = a))
|
|
|
|
|
(λ Heq : w = a, or::introl (subst H1 Heq) (∃ x : A, x ≠ a ∧ P x))
|
|
|
|
|
(λ Hne : w ≠ a, or::intror (P a) (exists::intro w (and::intro Hne H1))))
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem exists::unfold2 {A : TypeU} {P : A → Bool} (a : A) (H : P a ∨ (∃ x : A, x ≠ a ∧ P x)) : ∃ x : A, P x
|
|
|
|
|
:= or::elim H
|
|
|
|
|
(λ H1 : P a, exists::intro a H1)
|
2013-12-30 04:33:31 +00:00
|
|
|
|
(λ H2 : (∃ x : A, x ≠ a ∧ P x),
|
2014-01-06 03:10:21 +00:00
|
|
|
|
exists::elim H2
|
2013-12-30 02:30:41 +00:00
|
|
|
|
(λ (w : A) (Hw : w ≠ a ∧ P w),
|
2014-01-06 03:10:21 +00:00
|
|
|
|
exists::intro w (and::elimr Hw)))
|
2013-12-30 02:30:41 +00:00
|
|
|
|
|
2014-01-06 03:10:21 +00:00
|
|
|
|
theorem exists::unfold {A : TypeU} (P : A → Bool) (a : A) : (∃ x : A, P x) = (P a ∨ (∃ x : A, x ≠ a ∧ P x))
|
2014-01-08 08:38:39 +00:00
|
|
|
|
:= iff::intro (λ H : (∃ x : A, P x), exists::unfold1 a H)
|
|
|
|
|
(λ H : (P a ∨ (∃ x : A, x ≠ a ∧ P x)), exists::unfold2 a H)
|
2014-01-01 19:00:32 +00:00
|
|
|
|
|
2014-01-08 08:38:39 +00:00
|
|
|
|
set::opaque exists true
|
|
|
|
|
set::opaque not true
|
|
|
|
|
set::opaque or true
|
|
|
|
|
set::opaque and true
|