fix: propagateCtor (#8341)

This PR fixes the `propagateCtor` constraint propagator used in `grind`.
This commit is contained in:
Leonardo de Moura 2025-05-14 20:32:25 -04:00 committed by GitHub
parent e982bf9472
commit fad3e0ef5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,9 +41,15 @@ def propagateCtor (a b : Expr) : GoalM Unit := do
let info ← getConstInfo injDeclName
let n := info.type.getForallArity
let mask : Array (Option Expr) := .replicate n none
let mask := mask.set! (n-1) (some (← mkEqProof a b))
/-
We use `mkExpectedTypeHint` here to ensure that `mkAppOptM` will "fill" the implicit
arguments of `injDeclName` using exactly the fields of `a` and `b`.
There is no guarantee that `inferType (← mkEqProof a b)` is structurally equal to `a = b`.
-/
let mask := mask.set! (n-1) (some (← mkExpectedTypeHint (← mkEqProof a b) (← mkEq a b)))
let injLemma ← mkAppOptM injDeclName mask
propagateInjEqs (← inferType injLemma) injLemma
let injLemmaType ← inferType injLemma
propagateInjEqs injLemmaType injLemma
else
let .const declName _ := aType.getAppFn | return ()
let noConfusionDeclName := Name.mkStr declName "noConfusion"