Zulip Chat Archive
Stream: lean4
Topic: let rec puzzle
Eric Rodriguez (Apr 17 2024 at 15:39):
theorem test :
let rec f : Nat → Nat :=
fun n => match n with | n => n
f 0 = 0 := by
done
What's the goal state?
Mario Carneiro (Apr 17 2024 at 15:42):
Ah, you can't recurse with the main definition inside the type of the definition itself
Mario Carneiro (Apr 17 2024 at 15:42):
although I'm not sure the elaborator knows this
Mario Carneiro (Apr 17 2024 at 15:44):
i.e. this doesn't work
partial def foo : foo := foo
Joachim Breitner (Apr 17 2024 at 15:54):
Also this doesn’t work
foo := bar
where
myType := Nat
bar : myType := 42
which is unfortunate, at least once I wanted to put a large monad stack into a where M :=.
Kyle Miller (Apr 17 2024 at 15:58):
There are some complexities here, but it would be interesting if where blocks required explicit lets and let recs before each definition. Or at least required an explicit rec in front of a where definition if it was meant to be a let rec.
Kyle Miller (Apr 17 2024 at 15:59):
Like
def f := bar
where
myType := Nat
rec bar (n : myType) : myType := match n with | 0 => 0 | n + 1 => bar n
Last updated: May 02 2025 at 03:31 UTC