Closed kmill closed 10 months ago
I ran into this issues a few weeks ago as well, while helping some user.
Mostly a guess at this point, so jumping in here just for learning, but probably at this line:
the withApp
may need to be a variant looks through the recApp
metadata?
I think that would work to recognize this application, but this is in the context of something that is transforming the expression, so you shouldn't throw away any mdata except the _recApp
node; see the .mdata
case of the same function. I think this will need another recursive function doing the equivalent of withApp
.
Yes, I’d expect a annoyingly special withAppIgnoringRecApp
.
Let me give this a shot. I am supposed to work on that code soon anyways, so it’s a good learning experience.
Prerequisites
Description
When additional parentheses are inserted around a function, this can prevent structural recursion from succeeding.
Simple example:
With the parentheses, "structural recursion cannot be used." Replacing
(f) n
withf n
makes it succeed. Looking at the terms(f) n
andf n
, the difference is whethern
is included within the recApp metadata expression.This behavior indirectly appeared in a Zulip question when trying to make use of structural recursion within a theorem. This is a minified example:
Replacing
rw [thm]
withrw [thm n]
makes structural recursion succeed -- the terms are identical except for whethern
is included within a recApp metadata expression. Replacingrw [thm]
bysimp only [thm]
also makes it succeed -- in this casesimp
does not create an appRec metadata expression.Context
Zulip discussion
Versions
leanprover/lean4:v4.3.0-rc1
Impact
Add :+1: to issues you consider important. If others are impacted by this issue, please ask them to add :+1: to it.