2013-12-19 01:40:21 +00:00
|
|
|
Push
|
|
|
|
Theorem ReflIf (A : Type)
|
2013-12-19 02:00:37 +00:00
|
|
|
(R : A → A → Bool)
|
|
|
|
(Symmetry : Π x y, R x y → R y x)
|
|
|
|
(Transitivity : Π x y z, R x y → R y z → R x z)
|
|
|
|
(Linked : Π x, ∃ y, R x y)
|
2013-12-19 01:40:21 +00:00
|
|
|
:
|
2013-12-19 02:00:37 +00:00
|
|
|
Π x, R x x :=
|
2013-12-19 01:40:21 +00:00
|
|
|
fun x, ExistsElim (Linked x)
|
|
|
|
(fun (w : A) (H : R x w),
|
|
|
|
let L1 : R w x := Symmetry x w H
|
|
|
|
in Transitivity x w x H L1)
|
|
|
|
Pop
|
|
|
|
|
|
|
|
Push
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Same example but using ∀ instead of Π and ⇒ instead of →
|
2013-12-19 01:40:21 +00:00
|
|
|
Theorem ReflIf (A : Type)
|
2013-12-19 02:00:37 +00:00
|
|
|
(R : A → A → Bool)
|
|
|
|
(Symmetry : ∀ x y, R x y ⇒ R y x)
|
|
|
|
(Transitivity : ∀ x y z, R x y ⇒ R y z ⇒ R x z)
|
|
|
|
(Linked : ∀ x, ∃ y, R x y)
|
2013-12-19 01:40:21 +00:00
|
|
|
:
|
2013-12-19 02:00:37 +00:00
|
|
|
∀ x, R x x :=
|
2013-12-19 01:40:21 +00:00
|
|
|
ForallIntro (fun x,
|
|
|
|
ExistsElim (ForallElim Linked x)
|
|
|
|
(fun (w : A) (H : R x w),
|
|
|
|
let L1 : R w x := (MP (ForallElim (ForallElim Symmetry x) w) H)
|
|
|
|
in (MP (MP (ForallElim (ForallElim (ForallElim Transitivity x) w) x) H) L1)))
|
2013-12-19 02:00:37 +00:00
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- We can make the previous example less verbose by using custom notation
|
2013-12-19 02:00:37 +00:00
|
|
|
|
|
|
|
Infixl 50 ! : ForallElim
|
|
|
|
Infixl 30 << : MP
|
|
|
|
|
|
|
|
Theorem ReflIf2 (A : Type)
|
|
|
|
(R : A → A → Bool)
|
|
|
|
(Symmetry : ∀ x y, R x y ⇒ R y x)
|
|
|
|
(Transitivity : ∀ x y z, R x y ⇒ R y z ⇒ R x z)
|
|
|
|
(Linked : ∀ x, ∃ y, R x y)
|
|
|
|
:
|
|
|
|
∀ x, R x x :=
|
|
|
|
ForallIntro (fun x,
|
|
|
|
ExistsElim (Linked ! x)
|
|
|
|
(fun (w : A) (H : R x w),
|
|
|
|
let L1 : R w x := Symmetry ! x ! w << H
|
|
|
|
in Transitivity ! x ! w ! x << H << L1))
|
|
|
|
|
2014-01-05 19:03:35 +00:00
|
|
|
print Environment 1
|
2013-12-19 01:40:21 +00:00
|
|
|
Pop
|
|
|
|
|
|
|
|
Scope
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Same example again.
|
2013-12-19 01:40:21 +00:00
|
|
|
Variable A : Type
|
2013-12-19 02:00:37 +00:00
|
|
|
Variable R : A → A → Bool
|
|
|
|
Axiom Symmetry {x y : A} : R x y → R y x
|
|
|
|
Axiom Transitivity {x y z : A} : R x y → R y z → R x z
|
|
|
|
Axiom Linked (x : A) : ∃ y, R x y
|
2013-12-19 01:40:21 +00:00
|
|
|
|
|
|
|
Theorem ReflIf (x : A) : R x x :=
|
|
|
|
ExistsElim (Linked x) (fun (w : A) (H : R x w),
|
|
|
|
let L1 : R w x := Symmetry H
|
|
|
|
in Transitivity H L1)
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Even more compact proof of the same theorem
|
2013-12-19 01:40:21 +00:00
|
|
|
Theorem ReflIf2 (x : A) : R x x :=
|
|
|
|
ExistsElim (Linked x) (fun w H, Transitivity H (Symmetry H))
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The command EndScope exports both theorem to the main scope
|
|
|
|
-- The variables and axioms in the scope become parameters to both theorems.
|
2013-12-19 01:40:21 +00:00
|
|
|
EndScope
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Display the last two theorems
|
2014-01-05 19:03:35 +00:00
|
|
|
print Environment 2
|