fix: decreasing_by: remove mdata (#10931)

This PR strips the `Expr.mdata` that `WF.Fix` uses to associate goal
with recursive calls from the goal presented to the tactics.
Fixes #10895.
This commit is contained in:
Joachim Breitner 2025-10-23 22:54:32 +02:00 committed by GitHub
parent 59573646c2
commit 54175f3b99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View file

@ -221,8 +221,10 @@ def solveDecreasingGoals (funNames : Array Name) (argsPacker : ArgsPacker) (decr
let type ← goal.getType
let some ref := getRecAppSyntax? (← goal.getType)
| throwError "MVar not annotated as a recursive call:{indentExpr type}"
goal.setType type.mdataExpr!
withRef ref <| applyDefaultDecrTactic goal
| some decrTactic => withRef decrTactic.ref do
goals.forM fun goal => do goal.setType (← goal.getType).mdataExpr!
unless goals.isEmpty do -- unlikely to be empty
-- make info from `runTactic` available
goals.forM fun goal => pushInfoTree (.hole goal)

View file

@ -0,0 +1,16 @@
axiom T : Type
axiom T.lt : T → T → Prop
axiom T.wf_lt : WellFounded T.lt
axiom T.f : T → T
instance : WellFoundedRelation T := ⟨_, T.wf_lt⟩
axiom T.lt_f x : (T.f x).lt x
set_option pp.raw true
#guard_msgs in
noncomputable def foo (t : T) : Unit :=
foo (T.f t)
termination_by t
decreasing_by
have := T.lt_f t
grind

View file

@ -4,5 +4,4 @@ def f (n : Nat) : Nat :=
else
2 * f (n-1)
decreasing_by
simp [measure, id, invImage, InvImage, Nat.lt_wfRel]
apply Nat.pred_lt h