Repository navigation
Conversation
This PR lets `#print T.rec` show more information about a recursor, in particular it's reduction rules.
This PR experiments with a slightly different representation of a
recursor's rules. Instead of having a rules
```
fun α motive rec cons {n} x xs => cons x xs (Vec.rec α motive rec cons n xs)
```
we leave a hole for `Vec.rec α motive rec` and abstract over this
```
fun α motive rec nil cons {n} x xs => cons x xs (rec n xs)
```
This could be beneficial if the recursor has many arguments (e.g. many
minor premises from an inductive with many constructors). Note that the
subexpression `Vec.rec α motive rec` is exactly a subterm of the
expression we are reducing. So instead of substituting every single
argument, we can substitute this subexpression as a whole, increasing
sharing and reducing the cost.
It also simplifies the kernel code for nested inductives a bit, as
recursor names don't have to be changed in the rules `rhs`, only in the
list of mutual recursors.
This refactoring is also in anticipation of maybe treating more
functions as primitively recursive, instead of always going all the way
to `.rec`.
|
!bench |
|
!bench |
|
Here are the benchmark results for commit 39bdfc6. Benchmark Metric Change
===========================================================
+ big_beq_rec branch-misses -3.4% (-57.5 σ)
+ big_beq_rec branches -3.1% (-205.4 σ)
+ big_beq_rec instructions -3.3% (-235.0 σ)
+ bv_decide_rewriter.lean branch-misses -1.9% (-23.0 σ)
+ channel.lean unbounded_seq -1.4%
+ grind_ring_5.lean branches -10.6% (-824.8 σ)
+ grind_ring_5.lean instructions -11.2% (-831.8 σ)
+ grind_ring_5.lean maxrss -4.7% (-64.0 σ)
+ mut_rec_wf branches -2.8% (-283.8 σ)
+ mut_rec_wf instructions -2.9% (-287.2 σ)
+ stdlib grind ac -18.6% (-26.8 σ)
+ stdlib grind dsimp -20.3% (-20.6 σ)
- stdlib grind ematch 2.3% (40.3 σ) |
|
Here are the benchmark results for commit a99a153. Benchmark Metric Change
=======================================================================
+ Std.Data.Internal.List.Associative branch-misses -2.5% (-32.4 σ)
+ big_beq_rec branch-misses -4.0% (-38.9 σ)
+ big_beq_rec branches -3.2% (-306.1 σ)
+ big_beq_rec instructions -3.4% (-327.5 σ)
- big_do task-clock 1.6% (66.2 σ)
- big_do wall-clock 1.7% (20.1 σ)
+ grind_ring_5.lean branch-misses -5.7% (-23.1 σ)
+ grind_ring_5.lean branches -10.6% (-1279.4 σ)
+ grind_ring_5.lean instructions -11.2% (-1424.2 σ)
+ mut_rec_wf branches -2.8% (-185.0 σ)
+ mut_rec_wf instructions -2.9% (-199.4 σ)
+ reduceMatch instructions -1.1% (-30.9 σ) |
This PR is an experiment: What if the kernel would recognize primitiely recursive functions and treat them as recursors themselves. In paticular reduce them only when applied to a construtor, and then to the RHS directly. Builds on top of #10548
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
|
!radar |
|
Benchmark results for 58dcd82 against 1403994 are in! @nomeata Large changes (3✅)
Medium changes (4✅, 1🟥)
Small changes (19✅, 8🟥)Too many entries to display here. View the full report on radar instead. |
|
!bench mathlib |
|
Benchmark results for leanprover-community/mathlib4-nightly-testing@03e5dd3 against leanprover-community/mathlib4-nightly-testing@25ef31e are in! @nomeata Warnings (2)These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.
No significant changes detected. |
|
!bench mathlib |
|
Benchmark results for leanprover-community/mathlib4-nightly-testing@2ca8b22 against leanprover-community/mathlib4-nightly-testing@b4b270b are in! @nomeata
No significant changes detected. |
This PR experiments with a slightly different representation of a
recursor's rules. Instead of having a rules
we leave a hole for
Vec.rec α motive recand abstract over thisThis could be beneficial if the recursor has many arguments (e.g. many
minor premises from an inductive with many constructors). Note that the
subexpression
Vec.rec α motive recis exactly a subterm of theexpression we are reducing. So instead of substituting every single
argument, we can substitute this subexpression as a whole, increasing
sharing and reducing the cost.
It also simplifies the kernel code for nested inductives a bit, as
recursor names don't have to be changed in the rules
rhs, only in thelist of mutual recursors.
This refactoring is also in anticipation of maybe treating more
functions as primitively recursive, instead of always going all the way
to
.rec.