chore: reset local context at correct place

This commit is contained in:
Leonardo de Moura 2022-04-29 09:07:56 -07:00
parent 10d43492ba
commit c959c80310
3 changed files with 14 additions and 15 deletions

View file

@ -80,7 +80,7 @@ private def mkSimpleEqThm (declName : Name) : MetaM (Option Name) := do
By default, we not create equation theorems for nonrecursive definitions.
You can use `nonRec := true` to override this behavior, a dummy `rfl` proof is created on the fly.
-/
def getEqnsFor? (declName : Name) (nonRec := false) : MetaM (Option (Array Name)) := do
def getEqnsFor? (declName : Name) (nonRec := false) : MetaM (Option (Array Name)) := withLCtx {} {} do
if let some eqs := eqnsExt.getState (← getEnv) |>.map.find? declName then
return some eqs
else if (← shouldGenerateEqnThms declName) then
@ -134,7 +134,7 @@ def registerGetUnfoldEqnFn (f : GetUnfoldEqnFn) : IO Unit := do
By default, we not create unfold theorems for nonrecursive definitions.
You can use `nonRec := true` to override this behavior.
-/
def getUnfoldEqnFor? (declName : Name) (nonRec := false) : MetaM (Option Name) := do
def getUnfoldEqnFor? (declName : Name) (nonRec := false) : MetaM (Option Name) := withLCtx {} {} do
if (← shouldGenerateEqnThms declName) then
for f in (← getUnfoldEqnFnsRef.get) do
if let some r ← f declName then

View file

@ -260,7 +260,7 @@ private def substSomeVar (mvarId : MVarId) : MetaM (Array MVarId) := withMVarCon
the `match`-eliminator `matchDeclName`. `type` contains the type of the theorem. -/
partial def proveCondEqThm (matchDeclName : Name) (type : Expr) : MetaM Expr := do
let type ← instantiateMVars type
withLCtx {} {} <| forallTelescope type fun ys target => do
forallTelescope type fun ys target => do
let mvar0 ← mkFreshExprSyntheticOpaqueMVar target
let mvarId ← deltaTarget mvar0.mvarId! (· == matchDeclName)
trace[Meta.Match.matchEqs] "{MessageData.ofGoal mvarId}"
@ -397,7 +397,7 @@ where
/--
Create conditional equations and splitter for the given match auxiliary declaration. -/
private partial def mkEquationsFor (matchDeclName : Name) : MetaM MatchEqns := do
private partial def mkEquationsFor (matchDeclName : Name) : MetaM MatchEqns := withLCtx {} {} do
trace[Meta.Match.matchEqs] "mkEquationsFor '{matchDeclName}'"
withConfig (fun c => { c with etaStruct := .none }) do
let baseName := mkPrivateName (← getEnv) matchDeclName

View file

@ -383,17 +383,16 @@ where
else
return none
def SimpTheorems.addDeclToUnfold (d : SimpTheorems) (declName : Name) : MetaM SimpTheorems :=
withLCtx {} {} do
if let some eqns ← getEqnsFor? declName then
let mut d := d
for eqn in eqns do
d ← SimpTheorems.addConst d eqn
if hasSmartUnfoldingDecl (← getEnv) declName then
d := d.addDeclToUnfoldCore declName
return d
else
return d.addDeclToUnfoldCore declName
def SimpTheorems.addDeclToUnfold (d : SimpTheorems) (declName : Name) : MetaM SimpTheorems := do
if let some eqns ← getEqnsFor? declName then
let mut d := d
for eqn in eqns do
d ← SimpTheorems.addConst d eqn
if hasSmartUnfoldingDecl (← getEnv) declName then
d := d.addDeclToUnfoldCore declName
return d
else
return d.addDeclToUnfoldCore declName
abbrev SimpTheoremsArray := Array SimpTheorems