-
Notifications
You must be signed in to change notification settings - Fork 433
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
refactor: getUnfoldableConst*?
#5997
base: master
Are you sure you want to change the base?
Conversation
@@ -1263,10 +1263,7 @@ private def processAssignment' (mvarApp : Expr) (v : Expr) : MetaM Bool := do | |||
|
|||
private def isDeltaCandidate? (t : Expr) : MetaM (Option ConstantInfo) := do | |||
match t.getAppFn with | |||
| Expr.const c _ => | |||
match (← getUnfoldableConst? c) with | |||
| r@(some info) => if info.hasValue then return r else return none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasValue
checks unnecessary now that getUnfoldableConst*?
is documented to return defs/thms.
@[inline] private def matchConstAux {α} (e : Expr) (failK : Unit → MetaM α) (k : ConstantInfo → List Level → MetaM α) : MetaM α := do | ||
let .const name lvls := e | ||
| failK () | ||
let (some cinfo) ← getUnfoldableConst? name | ||
| failK () | ||
k cinfo lvls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the code clearer after inlining this helper, its name is too mysterious otherwise
matchConstAux f.getAppFn (fun _ => unfoldProjInstWhenInstances? e) fun fInfo fLvls => do | ||
| .app f _ => do | ||
let .const fName fLvls := f.getAppFn | unfoldProjInstWhenInstances? e | ||
match (← getUnfoldableConst? fName) with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only former matchConstAux
caller that cares about unfolding
27c91a5
to
a719d61
Compare
!bench |
Here are the benchmark results for commit a719d61. Benchmark Metric Change
=====================================================
+ big_do branch-misses -7.7% (-18.1 σ)
+ big_omega.lean MT branch-misses -4.5% (-22.1 σ)
- lake env task-clock 6.8% (12.2 σ)
- lake env wall-clock 6.8% (12.8 σ)
+ reduceMatch instructions -1.2% (-367.6 σ) |
Mathlib CI status (docs):
|
Continuation from #5429: eliminates uses of these two functions that care about something other than reducible defs/theorems, then restricts the function definition to these cases to be more true to its name.