2014-01-06 03:10:21 +00:00
|
|
|
import macros
|
|
|
|
|
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)
|
2014-01-06 03:10:21 +00:00
|
|
|
(Symm : Π x y, R x y → R y x)
|
|
|
|
(Trans : Π x y z, R x y → R y z → R x z)
|
2013-12-19 02:00:37 +00:00
|
|
|
(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 :=
|
2014-01-06 03:10:21 +00:00
|
|
|
λ x, obtain (w : A) (H : R x w), from (Linked x),
|
|
|
|
let L1 : R w x := Symm x w H
|
|
|
|
in Trans 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-06 03:10:21 +00:00
|
|
|
-- Same example but using ∀ instead of Π and ⇒ instead of →.
|
2014-01-06 05:39:31 +00:00
|
|
|
-- Remark: H ◂ x is syntax sugar for forall::elim H x,
|
|
|
|
-- and H1 ◂ H2 is syntax sugar for mp H1 H2
|
2014-01-05 20:05:08 +00:00
|
|
|
theorem ReflIf (A : Type)
|
2013-12-19 02:00:37 +00:00
|
|
|
(R : A → A → Bool)
|
2014-01-06 03:10:21 +00:00
|
|
|
(Symm : ∀ x y, R x y ⇒ R y x)
|
|
|
|
(Trans : ∀ x y z, R x y ⇒ R y z ⇒ R x z)
|
2013-12-19 02:00:37 +00:00
|
|
|
(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 :=
|
2014-01-06 05:39:31 +00:00
|
|
|
take x, obtain (w : A) (H : R x w), from (Linked ◂ x),
|
|
|
|
let L1 : R w x := Symm ◂ x ◂ w ◂ H
|
|
|
|
in Trans ◂ x ◂ w ◂ x ◂ H ◂ L1
|
2013-12-19 02:00:37 +00:00
|
|
|
|
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 again.
|
2014-01-05 20:05:08 +00:00
|
|
|
variable A : Type
|
|
|
|
variable R : A → A → Bool
|
2014-01-06 03:10:21 +00:00
|
|
|
axiom Symm {x y : A} : R x y → R y x
|
|
|
|
axiom Trans {x y z : A} : R x y → R y z → R x z
|
2014-01-05 20:05:08 +00:00
|
|
|
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 :=
|
2014-01-06 03:10:21 +00:00
|
|
|
obtain (w : A) (H : R x w), from (Linked x),
|
|
|
|
let L1 : R w x := Symm H
|
|
|
|
in Trans H L1
|
2013-12-19 01:40:21 +00:00
|
|
|
|
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
|