lean2/tests/lean/tst1.lean
Leonardo de Moura 9f08156a73 feat(frontends/lean/parser): combine Echo and Show commands into the 'print' command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-05 11:03:35 -08:00

26 lines
1.1 KiB
Text

-- Define a "fake" type to simulate the natural numbers. This is just a test.
Variable N : Type
Variable lt : N -> N -> Bool
Variable zero : N
Variable one : N
Variable two : N
Variable three : N
Infix 50 < : lt
Axiom two_lt_three : two < three
Definition vector (A : Type) (n : N) : Type := Pi (i : N) (H : i < n), A
Definition const {A : Type} (n : N) (d : A) : vector A n := fun (i : N) (H : i < n), d
Definition update {A : Type} {n : N} (v : vector A n) (i : N) (d : A) : vector A n := fun (j : N) (H : j < n), if (j = i) d (v j H)
Definition select {A : Type} {n : N} (v : vector A n) (i : N) (H : i < n) : A := v i H
Definition map {A B C : Type} {n : N} (f : A -> B -> C) (v1 : vector A n) (v2 : vector B n) : vector C n := fun (i : N) (H : i < n), f (v1 i H) (v2 i H)
print Environment 10
Check select (update (const three false) two true) two two_lt_three
Eval select (update (const three false) two true) two two_lt_three
Check update (const three false) two true
print "\n--------"
Check @select
print "\nmap type ---> "
Check @map
print "\nmap normal form --> "
Eval @map
print "\nupdate normal form --> "
Eval @update