Skip to content

feat: in app elaborator, beta reduce when substituting arguments #7991

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion src/Lean/Elab/App.lean
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,16 @@ def eraseNamedArg (binderName : Name) : M Unit :=
Add a new argument to the result. That is, `f := f arg`, update `fType`.
This method assumes `fType` is a function type. -/
private def addNewArg (argName : Name) (arg : Expr) : M Unit := do
modify fun s => { s with f := mkApp s.f arg, fType := s.fType.bindingBody!.instantiate1 arg }
modify fun s => { s with
f := mkApp s.f arg,
fType :=
-- If this is a higher-order argument, then apply beta reduction when instantiating,
-- which is useful for eliminator-like applications.
-- This mirrors `inferType` (see `Lean.Meta.inferAppType`).
if arg.isLambda then
s.fType.bindingBody!.instantiateBetaRevRange 0 1 #[arg]
else
s.fType.bindingBody!.instantiate1 arg }
if arg.isMVar then
registerMVarArgName arg.mvarId! argName

Expand Down
2 changes: 1 addition & 1 deletion tests/lean/run/4144.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ case refine'_4
⊢ ?refine'_1

case refine'_5
⊢ ¬(fun x => ?m.16) ?refine'_3 = (fun x => ?m.16) ?refine'_4
⊢ ¬?m.17 ?refine'_3 = ?m.17 ?refine'_4
-/
#guard_msgs in
example : False := by
Expand Down
Loading