Zulip Chat Archive

Stream: lean4

Topic: Termination-checking of one-field structures


Eric Wieser (Sep 11 2025 at 23:12):

Is this something that could be supported by the equation compiler?

structure WrappedFunc where
  func : Nat  Nat

def factorial : WrappedFunc where
  func
  | 0 => 1
  | n + 1 => n * factorial.func n

Eric Wieser (Sep 11 2025 at 23:12):

I can cheat with

def factorial : WrappedFunc where func where
  func
  | 0 => 1
  | n + 1 => n * factorial.func n

but then the equation lemma is WrappedFunc.func factorial (n + 1) = n * factorial.func n, where the RHS is not dot notation

Eric Wieser (Sep 11 2025 at 23:13):

(probably a question for @Joachim Breitner)

Eric Wieser (Sep 11 2025 at 23:16):

The context is #mathlib4 > Changing `Stream.Seq` to use `GetElem` @ 💬

Joachim Breitner (Sep 12 2025 at 07:50):

Hmm, that reminds me of an issue I looked at recently. I think it was related to type classes… ah, no, that was about nested induction.

I’m not sure how to support it easily. There must be some kind of etwa-expansion happening, to expose the function parameter for the function inside factorial : WrappedFunc. So not completely impossible, but not a quick feature to add.


Last updated: Dec 20 2025 at 21:32 UTC