Skip to content

Commit fad3e0e

Browse files
authored
fix: propagateCtor (#8341)
This PR fixes the `propagateCtor` constraint propagator used in `grind`.
1 parent e982bf9 commit fad3e0e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Lean/Meta/Tactic/Grind/Ctor.lean

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ def propagateCtor (a b : Expr) : GoalM Unit := do
4141
let info ← getConstInfo injDeclName
4242
let n := info.type.getForallArity
4343
let mask : Array (Option Expr) := .replicate n none
44-
let mask := mask.set! (n-1) (some (← mkEqProof a b))
44+
/-
45+
We use `mkExpectedTypeHint` here to ensure that `mkAppOptM` will "fill" the implicit
46+
arguments of `injDeclName` using exactly the fields of `a` and `b`.
47+
There is no guarantee that `inferType (← mkEqProof a b)` is structurally equal to `a = b`.
48+
-/
49+
let mask := mask.set! (n-1) (some (← mkExpectedTypeHint (← mkEqProof a b) (← mkEq a b)))
4550
let injLemma ← mkAppOptM injDeclName mask
46-
propagateInjEqs (← inferType injLemma) injLemma
51+
let injLemmaType ← inferType injLemma
52+
propagateInjEqs injLemmaType injLemma
4753
else
4854
let .const declName _ := aType.getAppFn | return ()
4955
let noConfusionDeclName := Name.mkStr declName "noConfusion"

0 commit comments

Comments
 (0)