chore: update stage0

This commit is contained in:
Leonardo de Moura 2022-04-19 05:11:19 -07:00
parent 556ace5cc1
commit d0ccb73fc9
4 changed files with 2065 additions and 739 deletions

View file

@ -141,7 +141,10 @@ private def elabSimpArgs (stx : Syntax) (ctx : Simp.Context) (eraseLocal : Bool)
thms := thms.eraseCore arg[1].getId
else
let declName ← resolveGlobalConstNoOverloadWithInfo arg[1]
thms ← thms.erase declName
if ctx.config.autoUnfold then
thms := thms.eraseCore declName
else
thms ← thms.erase declName
else if arg.getKind == ``Lean.Parser.Tactic.simpLemma then
let post :=
if arg[0].isNone then

View file

@ -94,6 +94,25 @@ private def reduceFVar (cfg : Config) (e : Expr) : MetaM Expr := do
else
return e
/--
Return true if `declName` is the name of a definition of the form
```
def declName ... :=
match ... with
| ...
```
-/
private partial def isMatchDef (declName : Name) : CoreM Bool := do
let .defnInfo info ← getConstInfo declName | return false
return go (← getEnv) info.value
where
go (env : Environment) (e : Expr) : Bool :=
if e.isLambda then
go env e.bindingBody!
else
let f := e.getAppFn
f.isConst && isMatcherCore env f.constName!
private def unfold? (e : Expr) : SimpM (Option Expr) := do
let f := e.getAppFn
if !f.isConst then
@ -101,7 +120,19 @@ private def unfold? (e : Expr) : SimpM (Option Expr) := do
let fName := f.constName!
if (← isProjectionFn fName) then
return none -- should be reduced by `reduceProjFn?`
if (← read).isDeclToUnfold e.getAppFn.constName! then
let ctx ← read
if ctx.config.autoUnfold then
if ctx.simpTheorems.isErased fName then
return none
else if hasSmartUnfoldingDecl (← getEnv) fName then
withDefault <| unfoldDefinition? e
else if (← isMatchDef fName) then
let some value ← withDefault <| unfoldDefinition? e | return none
let .reduced value ← reduceMatcher? value | return none
return some value
else
return none
else if ctx.isDeclToUnfold fName then
withDefault <| unfoldDefinition? e
else
return none

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff