mathlib4
mathlib4 copied to clipboard
feat: use @[csimp] to use exponentiation by repeated squaring at runtime
Using a @[csimp] attribute we can replace npowRec at runtime with an algorithm that uses repeated squaring,
without affecting the definitional properties of npowRec.
The prototypical application is that
#eval (3 : ZMod 49999)^49998
used to stack overflow, but now runs fine.
(This is an output of the "Formalization and Computer Algebra Systems" group at https://aimath.org/workshops/upcoming/cyberinfrastructure/.)
- [x] depends on: #8884
This PR/issue depends on:
- ~~leanprover-community/mathlib4#8884~~ By Dependent Issues (🤖). Happy coding!
I believe everyone's concerns have been addressed. There other PR (https://github.com/leanprover-community/mathlib4/pull/9154) is a few dependent PRs deep. I don't think it makes sense to wait.
Please address the merge conflicts created by #6262 removing the default values for npow and zpow and then send it off.
Thanks. I think this is really great for connections to computation.
bors delegate+
:v: semorrison can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.
If anyone would like to take over this PR, I'd be happy!
PR summary ba89098f97
Import changes for modified files
No significant changes to the import graph
Import changes for all files
| Files | Import difference |
|---|
Declarations diff
+ k
+ npowBinRec
+ npowBinRec.go_spec
+ npowBinRecAuto
+ npowRec'
+ npowRec'_mul_comm
+ npowRec'_succ
+ npowRec'_two_mul
+ npowRecAuto
+ npowRec_eq
+ npowRec_eq_npowBinRec
+ nsmulBinRec
+ nsmulRec'
+ nsmulRec_eq_nsmulBinRec
+ p
You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>
The doc-module for script/declarations_diff.sh contains some details about this script.
bors d+
:v: kim-em can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.
bors d=mattrobball
:v: mattrobball can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.
bors merge