lean4-htt/src
Leonardo de Moura 3bd39ed8b6
perf: a isDefEq friendly Fin.sub (#4421)
The performance issue at #4413 is due to our `Fin.sub` definition.
```
def sub : Fin n → Fin n → Fin n
  | ⟨a, h⟩, ⟨b, _⟩ => ⟨(a + (n - b)) % n, mlt h⟩
```
Thus, the following runs out of stack space
```
example (a : UInt64) : a - 1 = a :=
  rfl
```
at the `isDefEq` test
```
(a.val.val + 18446744073709551615) % 18446744073709551616 =?= a.val.val
```

From the user's perspective, this timeout is unexpected since they are
using small numerals, and none of the other `Fin` basic operations (such
as `Fin.add` and `Fin.mul`) suffer from this problem.

This PR implements an inelegant solution for the performance issue. It
redefines `Fin.sub` as
```
def sub : Fin n → Fin n → Fin n
  | ⟨a, h⟩, ⟨b, _⟩ => ⟨((n - b) + a) % n, mlt h⟩
```
This approach is unattractive because it relies on the fact that
`Nat.add` is defined using recursion on the second argument.

The impact on this repo was small, but we want to evaluate the impact on
Mathlib.

closes #4413
2024-06-11 17:18:11 +00:00
..
bin
cmake
include/lean feat: IO.TaskState (#4097) 2024-05-10 23:04:54 +00:00
Init perf: a isDefEq friendly Fin.sub (#4421) 2024-06-11 17:18:11 +00:00
initialize
kernel feat: propagate maxHeartbeats to kernel (#4113) 2024-05-09 17:44:19 +00:00
lake refactor: lake: inputBinFile / inputTextFile (#4384) 2024-06-08 01:20:46 +00:00
Lean chore: slightly more informative trace.Elab.snapshotTree 2024-06-11 10:44:04 +02:00
library fix: segfault in old compiler due to noConfusion assumptions (#2903) 2024-05-10 01:38:38 +00:00
runtime feat: incremental elaboration of definition headers, bodies, and tactics (#3940) 2024-05-22 13:23:30 +00:00
shell fix: do not dllexport symbols in core static libraries (#3601) 2024-03-15 11:58:34 +00:00
util chore: move trace.cpp to kernel (#4014) 2024-04-28 17:24:48 +00:00
CMakeLists.txt chore: build Lake again 2024-06-07 13:59:22 +02:00
config.h.in
githash.h.in
Init.lean feat: grind normalization theorems (#4164) 2024-05-14 19:19:38 +00:00
lean-toolchain
Lean.lean feat: propagate maxHeartbeats to kernel (#4113) 2024-05-09 17:44:19 +00:00
lean.mk.in fix: do not dllexport symbols in core static libraries (#3601) 2024-03-15 11:58:34 +00:00
Leanc.lean fix: do not dllexport symbols in core static libraries (#3601) 2024-03-15 11:58:34 +00:00
stdlib.make.in fix: do not dllexport symbols in core static libraries (#3601) 2024-03-15 11:58:34 +00:00
stdlib_flags.h
version.h.in