lean4-htt/tests/lean/run/cdotTests.lean
Leonardo de Moura b71e5b4648 test: cdot tests
2020-09-25 18:48:23 -07:00

33 lines
591 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

new_frontend
class Inc (α : Type) :=
(inc : αα)
export Inc (inc)
instance {α} [Inc α] : Inc (List α) :=
{ inc := (·.map inc) }
instance : Inc Nat :=
{ inc := Nat.succ }
#eval inc 10
#eval inc [1, 2, 3]
theorem ex1 : [(1, "hello"), (2, "world")].map (·.1) = [1, 2] :=
rfl
theorem ex2 : [(1, "hello"), (2, "world")].map (·.snd) = ["hello", "world"] :=
rfl
def sum (xs : List Nat) : Nat :=
(·.2) $ Id.run $ StateT.run (s:=0) do
xs.forM fun x => modify (· + x)
#eval sum [1, 2, 3, 4]
theorem ex3 : sum [1, 2, 3] = 6 :=
rfl
theorem ex4 : sum [1, 2, 3, 4] = 10 :=
rfl