fix: tail-recursive `BitVec.ofBoolListLE`/`ofBoolListBE` to avoid stack overflow
This PR adds tail-recursive replacements for BitVec.ofBoolListLE and BitVec.ofBoolListBE, registered via @[csimp], to avoid stack overflow on lists with ~1M elements.
The reference definitions in Init.Data.BitVec.Basic recurse via concat, which is clean for proofs but allocates O(n) stack frames. The new implementations in Init.Data.BitVec.Impl pack bits in 64-bit chunks (packChunk, collectChunks) and combine them via a balanced tree merge (mergePass, treeMerge), giving O(n log n) work and O(1) stack usage.
Correctness is established via a list-level spec function flattenList giving the intended Nat semantics of (value, width) pairs, with flattenList_append, flattenList_mergePassList (key bit-packing identity), and a chunk-local testBit_flattenList_collectChunks_aux. The two @[csimp] theorems chain through BitVec.eq_of_getLsbD_eq and the existing getLsbD_ofBoolListLE/getLsbD_ofBoolListBE characterizations.
🤖 Prepared with Claude Code
Mathlib CI status (docs):
- ❗ Mathlib CI can not be attempted yet, as the
nightly-testing-2026-04-29tag does not exist there yet. We will retry when you push more commits. If you rebase your branch ontonightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-04-29 14:47:34) - 💥 Mathlib branch lean-pr-testing-13576 build failed against this PR. (2026-05-16 07:55:26) View Log
Forcing Mathlib CI because the
force-mathlib-cilabel is present, despite problem: - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off thenightly-with-mathlibbranch. Trygit rebase 1fb7efad0255f2f227a68e7023c4c5a6a8e42265 --onto 4792cd22887c8b529a351f6563b693426ff2a8f8. (2026-06-18 04:46:49) - ✅ Mathlib branch lean-pr-testing-13576 has successfully built against this PR. (2026-06-18 05:42:22) View Log
Reference manual CI status:
- ❗ Reference manual CI can not be attempted yet, as the
nightly-testing-2026-04-29tag does not exist there yet. We will retry when you push more commits. If you rebase your branch ontonightly-with-manual, reference manual CI should run now. You can force reference manual CI using theforce-manual-cilabel. (2026-04-29 14:47:35) - ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase 1fb7efad0255f2f227a68e7023c4c5a6a8e42265 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using theforce-manual-cilabel. (2026-06-18 04:46:50)