Merge pull request 'fix: Instantiation causes infinite loop' (#54) from output/expr into dev
Reviewed-on: #54
This commit is contained in:
commit
9c8cc33e07
|
@ -64,7 +64,7 @@ def inspect (args: Protocol.EnvInspect) (options: @&Protocol.Options): CoreM (Pr
|
||||||
else .none,
|
else .none,
|
||||||
valueDependency? := ← if args.dependency?.getD false
|
valueDependency? := ← if args.dependency?.getD false
|
||||||
then info.value?.mapM (λ e => do
|
then info.value?.mapM (λ e => do
|
||||||
let e ← (unfoldAuxLemmas e).run'
|
let e ← unfoldAuxLemmas e
|
||||||
pure $ e.getUsedConstants.filter (!isNameInternal ·) |>.map (λ n => name_to_ast n) )
|
pure $ e.getUsedConstants.filter (!isNameInternal ·) |>.map (λ n => name_to_ast n) )
|
||||||
else pure (.none),
|
else pure (.none),
|
||||||
module? := module?
|
module? := module?
|
||||||
|
|
|
@ -127,7 +127,7 @@ def exprEcho (expr: String) (options: @&Protocol.Options):
|
||||||
| .error e => return .error e
|
| .error e => return .error e
|
||||||
| .ok expr => pure expr
|
| .ok expr => pure expr
|
||||||
try
|
try
|
||||||
let type ← instantiateAll (← Lean.Meta.inferType expr)
|
let type ← unfoldAuxLemmas (← Lean.Meta.inferType expr)
|
||||||
return .ok {
|
return .ok {
|
||||||
type := (← serialize_expression options type),
|
type := (← serialize_expression options type),
|
||||||
expr := (← serialize_expression options expr)
|
expr := (← serialize_expression options expr)
|
||||||
|
@ -171,9 +171,9 @@ def goalPrint (state: GoalState) (options: @&Protocol.Options): Lean.CoreM Proto
|
||||||
state.restoreMetaM
|
state.restoreMetaM
|
||||||
return {
|
return {
|
||||||
root? := ← state.rootExpr?.mapM (λ expr => do
|
root? := ← state.rootExpr?.mapM (λ expr => do
|
||||||
serialize_expression options (← instantiateAll expr)),
|
serialize_expression options (← unfoldAuxLemmas expr)),
|
||||||
parent? := ← state.parentExpr?.mapM (λ expr => do
|
parent? := ← state.parentExpr?.mapM (λ expr => do
|
||||||
serialize_expression options (← instantiateAll expr)),
|
serialize_expression options (← unfoldAuxLemmas expr)),
|
||||||
}
|
}
|
||||||
runMetaM metaM
|
runMetaM metaM
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,9 @@ def Lean.Name.isAuxLemma (n : Lean.Name) : Bool := n matches .num (.str _ "_auxL
|
||||||
namespace Pantograph
|
namespace Pantograph
|
||||||
|
|
||||||
/-- Unfold all lemmas created by `Lean.Meta.mkAuxLemma`. These end in `_auxLemma.nn` where `nn` is a number. -/
|
/-- Unfold all lemmas created by `Lean.Meta.mkAuxLemma`. These end in `_auxLemma.nn` where `nn` is a number. -/
|
||||||
def unfoldAuxLemmas (e : Lean.Expr) : Lean.MetaM Lean.Expr := do
|
def unfoldAuxLemmas (e : Lean.Expr) : Lean.CoreM Lean.Expr := do
|
||||||
Lean.Meta.deltaExpand e Lean.Name.isAuxLemma
|
Lean.Meta.deltaExpand e Lean.Name.isAuxLemma
|
||||||
|
|
||||||
def instantiateAll (e: Lean.Expr) : Lean.MetaM Lean.Expr := do
|
|
||||||
let e ← unfoldAuxLemmas e
|
|
||||||
instantiateMVars (← Lean.Meta.whnf e)
|
|
||||||
|
|
||||||
--- Input Functions ---
|
--- Input Functions ---
|
||||||
|
|
||||||
/-- Read syntax object from string -/
|
/-- Read syntax object from string -/
|
||||||
|
|
Loading…
Reference in New Issue