@@ -641,6 +641,9 @@ def rwLetWith (h : Expr) (e : Expr) : MetaM Simp.Result := do
641641 return { expr := e.letBody!.instantiate1 h }
642642 return { expr := e }
643643
644+ def rwMData (e : Expr) : MetaM Simp.Result := do
645+ return { expr := e.consumeMData }
646+
644647def rwHaveWith (h : Expr) (e : Expr) : MetaM Simp.Result := do
645648 if let some (_n, t, _v, b) := e.letFun? then
646649 if (← isDefEq t (← inferType h)) then
@@ -674,11 +677,12 @@ def rwMatcher (altIdx : Nat) (e : Expr) : MetaM Simp.Result := do
674677 return { expr := e }
675678 else
676679 unless (← isMatcherApp e) do
680+ trace[Meta.FunInd] "Not a matcher application:{indentExpr e}"
677681 return { expr := e }
678682 let matcherDeclName := e.getAppFn.constName!
679683 let eqns ← Match.genMatchCongrEqns matcherDeclName
680684 unless altIdx < eqns.size do
681- trace[Tactic .FunInd] "When trying to reduce arm {altIdx}, only {eqns.size} equations for {.ofConstName matcherDeclName}"
685+ trace[Meta .FunInd] "When trying to reduce arm {altIdx}, only {eqns.size} equations for {.ofConstName matcherDeclName}"
682686 return { expr := e }
683687 let eqnThm := eqns[altIdx]!
684688 try
@@ -865,7 +869,8 @@ partial def buildInductionBody (toErase toClear : Array FVarId) (goal : Expr)
865869
866870 -- we look through mdata
867871 if e.isMData then
868- let b ← buildInductionBody toErase toClear goal oldIH newIH isRecCall e.mdataExpr!
872+ let b ← withRewrittenMotiveArg goal (rwMData) fun goal' =>
873+ buildInductionBody toErase toClear goal' oldIH newIH isRecCall e.mdataExpr!
869874 return e.updateMData! b
870875
871876 if let .letE n t v b _ := e then
0 commit comments