doc(examples/lean): new example
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
42cb5d1d3c
commit
d7886c4f5f
2 changed files with 38 additions and 2 deletions
30
examples/lean/set.lean
Normal file
30
examples/lean/set.lean
Normal file
|
@ -0,0 +1,30 @@
|
|||
Definition set (A : Type) : Type := A -> Bool
|
||||
|
||||
Definition element {A : Type} (x : A) (s : set A) := s x
|
||||
Infix 60 ∈ : element
|
||||
|
||||
Definition subset {A : Type} (s1 : set A) (s2 : set A) := ∀ x, x ∈ s1 ⇒ x ∈ s2
|
||||
Infix 50 ⊆ : subset
|
||||
|
||||
Theorem SubsetProp {A : Type} {s1 s2 : set A} {x : A} (H1 : s1 ⊆ s2) (H2 : x ∈ s1) : x ∈ s2 :=
|
||||
MP (ForallElim H1 x) H2
|
||||
|
||||
Theorem SubsetTrans {A : Type} {s1 s2 s3 : set A} (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s3) : s1 ⊆ s3 :=
|
||||
ForallIntro (λ x,
|
||||
Discharge (λ Hin : x ∈ s1,
|
||||
let L1 : x ∈ s2 := SubsetProp H1 Hin,
|
||||
L2 : x ∈ s3 := SubsetProp H2 L1
|
||||
in L2)).
|
||||
|
||||
Definition transitive {A : Type} (R : A → A → Bool) := ∀ x y z, R x y ⇒ R y z ⇒ R x z
|
||||
|
||||
Theorem SubsetTrans2 {A : Type} : transitive (subset::explicit A) :=
|
||||
ForallIntro (λ s1, ForallIntro (λ s2, ForallIntro (λ s3,
|
||||
Discharge (λ H1, (Discharge (λ H2,
|
||||
SubsetTrans H1 H2)))))).
|
||||
|
||||
Theorem SubsetRefl {A : Type} (s : set A) : s ⊆ s :=
|
||||
ForallIntro (λ x, Discharge (λ H : x ∈ s, H))
|
||||
|
||||
Definition union {A : Type} (s1 : set A) (s2 : set A) := λ x, x ∈ s1 ∨ x ∈ s2
|
||||
Infix 55 ∪ : union
|
|
@ -1654,8 +1654,14 @@ class parser::imp {
|
|||
} else {
|
||||
mk_scope scope(*this);
|
||||
parse_object_bindings(bindings);
|
||||
check_colon_next("invalid definition, ':' expected");
|
||||
expr type_body = parse_expr();
|
||||
expr type_body;
|
||||
if (curr_is_colon()) {
|
||||
next();
|
||||
type_body = parse_expr();
|
||||
} else {
|
||||
auto p = pos();
|
||||
type_body = save(mk_placeholder(), p);
|
||||
}
|
||||
pre_type = mk_abstraction(false, bindings, type_body);
|
||||
if (!is_definition && curr_is_period()) {
|
||||
pre_val = mk_abstraction(true, bindings, mk_placeholder());
|
||||
|
|
Loading…
Reference in a new issue