feat: trace non-easy whnf invocations (#3774)
This commit is contained in:
parent
63290babde
commit
2405fd605e
1 changed files with 10 additions and 9 deletions
|
|
@ -936,21 +936,22 @@ private def cache (useCache : Bool) (e r : Expr) : MetaM Expr := do
|
|||
@[export lean_whnf]
|
||||
partial def whnfImp (e : Expr) : MetaM Expr :=
|
||||
withIncRecDepth <| whnfEasyCases e fun e => do
|
||||
checkSystem "whnf"
|
||||
let useCache ← useWHNFCache e
|
||||
match (← cached? useCache e) with
|
||||
| some e' => pure e'
|
||||
| none =>
|
||||
let e' ← whnfCore e
|
||||
match (← reduceNat? e') with
|
||||
| some v => cache useCache e v
|
||||
| none =>
|
||||
match (← reduceNative? e') with
|
||||
withTraceNode `Meta.whnf (fun _ => return m!"Non-easy whnf: {e}") do
|
||||
checkSystem "whnf"
|
||||
let e' ← whnfCore e
|
||||
match (← reduceNat? e') with
|
||||
| some v => cache useCache e v
|
||||
| none =>
|
||||
match (← unfoldDefinition? e') with
|
||||
| some e'' => cache useCache e (← whnfImp e'')
|
||||
| none => cache useCache e e'
|
||||
match (← reduceNative? e') with
|
||||
| some v => cache useCache e v
|
||||
| none =>
|
||||
match (← unfoldDefinition? e') with
|
||||
| some e'' => cache useCache e (← whnfImp e'')
|
||||
| none => cache useCache e e'
|
||||
|
||||
/-- If `e` is a projection function that satisfies `p`, then reduce it -/
|
||||
def reduceProjOf? (e : Expr) (p : Name → Bool) : MetaM (Option Expr) := do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue