Commit 69ebb74
committed
perf(Algebra/IsPrimePow): speed up decidability for Nat IsPrimePow (#30093)
Previously, this decidability instance was defined using `isPrimePow_nat_iff_bounded`, which (as I understand it) means that it undertook a search over all pairs `p, k` of numbers below `n` until it finds one where `p` is prime, and `p^k = n`, or else loops through all possibilities.
This PR creates a new theorem which instead searches over possible values of the exponent first, bounding the search at the binary logarithm of `n`, and then a further theorem which uses `n.minFac` for `p`. This massively reduces the time for large `n`.
In principle this could be made polynomial time, if we were to compute the putative prime factor for each `k` by taking the `k`th root and checking primality with AKS. But until that is implemented, this seems like a fine improvement.1 parent 12fc3da commit 69ebb74
1 file changed
+32
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
79 | 110 | | |
80 | | - | |
| 111 | + | |
81 | 112 | | |
82 | 113 | | |
83 | 114 | | |
| |||
0 commit comments