2014-01-05 20:05:08 +00:00
|
|
|
scope
|
|
|
|
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)
|
2014-01-05 20:05:08 +00:00
|
|
|
pop::scope
|
2013-12-19 01:40:21 +00:00
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
scope
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Same example but using ∀ instead of Π and ⇒ instead of →
|
2014-01-05 20:05:08 +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
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
infixl 50 ! : ForallElim
|
|
|
|
infixl 30 << : MP
|
2013-12-19 02:00:37 +00:00
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
theorem ReflIf2 (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)
|
|
|
|
:
|
|
|
|
∀ 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 20:05:08 +00:00
|
|
|
print environment 1
|
|
|
|
pop::scope
|
2013-12-19 01:40:21 +00:00
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
scope
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Same example again.
|
2014-01-05 20:05:08 +00:00
|
|
|
variable A : Type
|
|
|
|
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
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
theorem ReflIf (x : A) : R x x :=
|
2013-12-19 01:40:21 +00:00
|
|
|
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
|
2014-01-05 20:05:08 +00:00
|
|
|
theorem ReflIf2 (x : A) : R x x :=
|
2013-12-19 01:40:21 +00:00
|
|
|
ExistsElim (Linked x) (fun w H, Transitivity H (Symmetry H))
|
|
|
|
|
2014-01-05 20:05:08 +00:00
|
|
|
-- The command Endscope exports both theorem to the main scope
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The variables and axioms in the scope become parameters to both theorems.
|
2014-01-05 20:05:08 +00:00
|
|
|
end
|
2013-12-19 01:40:21 +00:00
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- Display the last two theorems
|
2014-01-05 20:05:08 +00:00
|
|
|
print environment 2
|