In Lean, we can define a function like this
def f (n : ℕ) : ℕ := n + 1
However, inside a proof this is no longer possible. The following code is invalid:
theorem exmpl (x : ℕ) : false :=
begin
def f (n : ℕ) : ℕ := n + 1,
end
I would assume that it is possible with have
instead, but attempts like
theorem exmpl (x : ℕ) : false :=
begin
have f (n : ℕ) : n := n + 1,
have f : ℕ → ℕ := --some definition,
end
did not work for me. Is it possible to define a function inside of a proof in lean and how would you achive that?
(In the example above, it would be possible to define it before the proof, but you could also imagine a function like f (n : ℕ) : ℕ := n + x
, which can only be defined after x
is introduced)