Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use more reduction when computing parent types #7764

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Lean/Elab/StructInst.lean
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,11 @@ where
let cinfo ← try getConstInfo flatCtorName catch _ => getConstInfo (ctor.induct ++ `_flat_ctor) -- TODO(kmill): remove catch
let ctorVal ← instantiateValueLevelParams cinfo us
let fieldArgs := parentFields.map fieldMap.find!
-- Normalize the expressions since there might be some projections.
let params ← params.mapM normalizeExpr
let e' := (ctorVal.beta params).beta fieldArgs
return .done e'
-- Continue, since we need to reduce the parameters.
return .continue e'

private def getParentStructType? (parentStructName : Name) : StructInstM (Option (Expr × Option Name)) := do
let env ← getEnv
Expand All @@ -953,6 +956,7 @@ private def getParentStructType? (parentStructName : Name) : StructInstM (Option
let params := ty.getAppArgs
pure <| mkApp (mkAppN (.const projFn us) params) e
let projTy ← whnf <| ← inferType proj
let projTy ← normalizeExpr projTy
let projTy ← reduceSelfProjs self projTy
let projTy ← normalizeExpr projTy
if projTy.containsFVar self.fvarId! then
Expand Down
Loading