lean4-htt/doc/examples/Certora2022/ex2.lean
2022-11-21 17:02:28 -08:00

14 lines
312 B
Text

/- First-class functions -/
def twice (f : Nat → Nat) (a : Nat) :=
f (f a)
#check twice
-- (Nat → Nat) → Nat → Nat
#eval twice (fun x => x + 2) 10
theorem twice_add_2 (a : Nat) : twice (fun x => x + 2) a = a + 4 := rfl
-- `(· + 2)` is syntax sugar for `(fun x => x + 2)`.
#eval twice (· + 2) 10