Open tobiasgrosser opened 5 months ago
There is a corresponding zulip thread where we investigate this further: https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/conv.20tactic.20sometimes.20solves.20goal/near/432918099
I meanwhile use the following tactic:
elab "contains? " ts:term : tactic => withMainContext do
let tgt ← getMainTarget
if (← kabstract tgt (← elabTerm ts none)) == tgt then throwError "pattern not found"
which does what I need. Thanks goes to Kyle Miller.
I am happy for this to be closed, but also wanted to record this in case someone feels these issues should be addressed within lean core.
I agree generalize
should fail if the pattern doesn't match. If someone would like to PR a fix, that would be welcome.
Prerequisites
Description
I am trying to write a tactic that generalizes patterns in a program. My tactic calls
generalize_or_fail
inrepeat
until all occurrences of the pattern are generalized. I cannot just usegeneralize
as it does not fail, but just keeps creating meta-variables in case the match pattern cannot be found. I managed to create a workaround, as shown below. However, this workaround is also not working for us asconv
seems to solve goals by reflection, as visible intest_solved_but_should_not
. In this specific case, this leads togeneralize
failing, which I can work around withtry
. While this resolves the error it leads to a solved goal state while I just wanted to generalize. In our framework, I would much prefer if our tactic does not start solving the goal.Steps to Reproduce
Run the code above.
Expected behavior:
Actual behavior:
Versions
"4.7.0"