feat(builtin/macros): rename 'For' macro to 'take'

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-01-05 11:08:55 -08:00
parent 9f08156a73
commit 0b4bdceb10
3 changed files with 9 additions and 9 deletions

View file

@ -9,30 +9,30 @@ Definition subset {A : Type} (s1 : Set A) (s2 : Set A) := ∀ x, x ∈ s1 ⇒ x
Infix 50 ⊆ : subset
Theorem SubsetTrans (A : Type) : ∀ s1 s2 s3 : Set A, s1 ⊆ s2 ⇒ s2 ⊆ s3 ⇒ s1 ⊆ s3 :=
For s1 s2 s3, Assume (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s3),
take s1 s2 s3, Assume (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s3),
show s1 ⊆ s3,
For x, Assume Hin : x ∈ s1,
take x, Assume Hin : x ∈ s1,
show x ∈ s3,
let L1 : x ∈ s2 := MP (Instantiate H1 x) Hin
in MP (Instantiate H2 x) L1
Theorem SubsetExt (A : Type) : ∀ s1 s2 : Set A, (∀ x, x ∈ s1 = x ∈ s2) ⇒ s1 = s2 :=
For s1 s2, Assume (H : ∀ x, x ∈ s1 = x ∈ s2),
take s1 s2, Assume (H : ∀ x, x ∈ s1 = x ∈ s2),
Abst (fun x, Instantiate H x)
Theorem SubsetAntiSymm (A : Type) : ∀ s1 s2 : Set A, s1 ⊆ s2 ⇒ s2 ⊆ s1 ⇒ s1 = s2 :=
For s1 s2, Assume (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s1),
take s1 s2, Assume (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s1),
show s1 = s2,
MP (show (∀ x, x ∈ s1 = x ∈ s2) ⇒ s1 = s2,
Instantiate (SubsetExt A) s1 s2)
(show (∀ x, x ∈ s1 = x ∈ s2),
For x, show x ∈ s1 = x ∈ s2,
take x, show x ∈ s1 = x ∈ s2,
let L1 : x ∈ s1 ⇒ x ∈ s2 := Instantiate H1 x,
L2 : x ∈ s2 ⇒ x ∈ s1 := Instantiate H2 x
in ImpAntisym L1 L2)
-- Compact (but less readable) version of the previous theorem
Theorem SubsetAntiSymm2 (A : Type) : ∀ s1 s2 : Set A, s1 ⊆ s2 ⇒ s2 ⊆ s1 ⇒ s1 = s2 :=
For s1 s2, Assume H1 H2,
take s1 s2, Assume H1 H2,
MP (Instantiate (SubsetExt A) s1 s2)
(For x, ImpAntisym (Instantiate H1 x) (Instantiate H2 x))
(take x, ImpAntisym (Instantiate H1 x) (Instantiate H2 x))

View file

@ -83,7 +83,7 @@ function nary_macro(name, f, farity)
end)
end
binder_macro("For", Const("ForallIntro"), 3, 1, 3)
binder_macro("take", Const("ForallIntro"), 3, 1, 3)
binder_macro("Assume", Const("Discharge"), 3, 1, 3)
nary_macro("Instantiate", Const("ForallElim"), 4)
nary_macro("MP'", Const("MP"), 4)

View file

@ -1,7 +1,7 @@
(* import("macros.lua") *)
Theorem T (A : Type) (p : A -> Bool) (f : A -> A -> A) : forall x y z, p (f x x) => x = y => x = z => p (f y z) :=
For x y z, Assume (H1 : p (f x x)) (H2 : x = y) (H3 : x = z),
take x y z, Assume (H1 : p (f x x)) (H2 : x = y) (H3 : x = z),
Subst' H1 H2 H3.
print Environment 1.