-
Notifications
You must be signed in to change notification settings - Fork 717
refactor: structural recursion: prove .eq_def directly
#10606
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
Conversation
|
Still getting two failures with functions that have Possible fix: Undo the changes in #10415, unfold both sides (now that we know how to keep |
Got confused juggling stages, seems to help with one but not the other failing test. I still wonder if we need a way to relate two instances of the same dumping some partial thought experiments here, gotta go now |
|
Actually, the remaining test that fails seems to be related to module system issues: so maybe this is a good direction here. ah, yes, “forgetting |
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
66cc02d to
947152f
Compare
|
How could switching to the default equation generation break splitting this |
…achim/issue5667-2
|
Benchmark results for 81874c9 against fbfb075 are in! @nomeata |
|
!bench |
|
Benchmark results for 7785875 against fbfb075 are in! @nomeata |
|
Here are the benchmark results for commit 81874c9. Benchmark Metric Change
=====================================================================
- Init size bytes .olean 5.6%
- big_beq_rec branches 4.5% (304.9 σ)
- big_beq_rec instructions 4.9% (335.2 σ)
- big_deceq_rec branches 1.2% (155.2 σ)
- big_deceq_rec instructions 1.3% (142.3 σ)
- iterators (interpreted) maxrss 1.0% (35.3 σ)
- lake config elab maxrss 1.3% (54.7 σ)
- lake config import maxrss 1.2% (30.8 σ)
- lake config tree maxrss 1.3% (87.5 σ)
- lake env maxrss 1.2% (40.0 σ)
- mut_rec_wf branches 4.0% (731.1 σ)
- mut_rec_wf instructions 4.3% (558.0 σ)
+ reduceMatch instructions -1.8% (-80.7 σ)
+ stdlib grind ring -19.6% (-28.6 σ)
- stdlib number of imported bytes 4.9%
- stdlib size bytes .olean 4.1% |
|
Here are the benchmark results for commit 7785875. Benchmark Metric Change
================================================================
- Init size bytes .olean 5.6%
- big_beq_rec branches 2.4% (74.5 σ)
- big_beq_rec instructions 2.6% (77.4 σ)
+ grind_ring_5.lean task-clock -2.5% (-22.1 σ)
+ grind_ring_5.lean wall-clock -2.4% (-32.4 σ)
- lake config elab maxrss 1.2% (28.6 σ)
- lake config import maxrss 1.1% (22.8 σ)
- lake config tree maxrss 1.1% (44.7 σ)
- lake env maxrss 1.1% (31.2 σ)
- mut_rec_wf branches 2.2% (84.7 σ)
- mut_rec_wf instructions 2.3% (80.8 σ)
+ reduceMatch instructions -1.8% (-35.1 σ)
- riscv-ast.lean wall-clock 1.2% (92.3 σ)
- stdlib blocked (unaccounted) 4.7% (25.0 σ)
+ stdlib grind ac -10.5% (-23.8 σ)
+ stdlib grind ring -23.6% (-28.6 σ)
- stdlib number of imported bytes 4.9%
- stdlib size bytes .olean 4.1% |
This PR follows upon #10606 and creates equational theorems uniformly from the unfold theorem, removing the `registerGetEqnsFn` hook.
This PR follows upon #10606 and creates equational theorems uniformly from the unfold theorem, there is only one handler registered in `registerGetEqnsFn`. For now we keep `registerGetEqnsFn`, because it’s used by mathlib’s `irreducible_def`, but I’d like to get rid of it in the long term, relying only on `registerGetUnfoldEqnFn` for constructions that should unfold differently.
This PR changes how Lean proves the equational theorems for structural recursion. The core idea is to let-bind the
fargument tobrecOnand rewriting.brecOnwith an unfolding theorem. This means no extra case split for the.recin.brecOnis needed, andsimpdoesn't change thefargument which can break the definitional equality with the defined function. With this, we can prove the unfolding theorem first, and derive the equational theorems from that, like for all other ways of defining recursive functions.Backs out the changes from #10415, the old strategy works well with the new goals.
Fixes #5667
Fixes #10431
Fixes #10195
Fixes #2962