Skip to content

[Lean Squad] feat(fv): SlewRate convergence proofs + crc32_signature informal spec (run 74)#71

Open
github-actions[bot] wants to merge 1 commit intomainfrom
lean-squad/slewrate-convergence-crc32-informal-run74-24971784654-c17ebe28a77d60ff
Open

[Lean Squad] feat(fv): SlewRate convergence proofs + crc32_signature informal spec (run 74)#71
github-actions[bot] wants to merge 1 commit intomainfrom
lean-squad/slewrate-convergence-crc32-informal-run74-24971784654-c17ebe28a77d60ff

Conversation

@github-actions
Copy link
Copy Markdown

🔬 Lean Squad automated formal verification — run 74

Task 5: SlewRate Multi-Step Convergence Proofs

Adds the key liveness property of the rate limiter to formal-verification/lean/FVSquad/SlewRate.lean: iterating slewUpdate always terminates at target within a bounded number of steps.

New definitions and theorems

Name Kind Status
slewIterate def N-step iterate of slewUpdate
slewIterate_zero @[simp] theorem Base case
slewIterate_succ theorem Unfolding lemma
slewIterate_steady theorem Steady state preserved under iteration
slewUpdate_far_up private theorem One step = current + max_step when far below target
slewUpdate_far_down private theorem One step = current − max_step when far above target
slewIterate_converges_up theorem ✅ Proved 0-sorry: starting ≤ target, N steps suffice when target − current ≤ max_step × N
slewIterate_converges_down theorem ✅ Proved 0-sorry: starting ≥ target, N steps suffice when current − target ≤ max_step × N

Plus 4 native_decide spot-checks: 0→10 in 4 steps at rate 3, 10→0 in 2 steps at rate 5, stability past convergence.

Proof technique: induction on N, by_cases on whether current is within one step of target. The "too far" case uses slewUpdate_far_up/down helpers and a calc chain. Key fix: replaced Mathlib-only ring with omega (for linear steps) and simp [Int.mul_add] (for the max_step * ↑(n+1) − max_step = max_step * ↑n algebra), keeping this a stdlib-only proof.


Task 2: crc32_signature Informal Specification

New file formal-verification/specs/crc32_informal.md for crc32_signature in src/lib/crc/crc.c.

Algorithm: CRC-32/ISO-HDLC (reflected polynomial 0xEDB88320), same family as used in Ethernet/gzip/PNG. Processed as List.foldl crc32Step acc bytes.

Key properties specified:

  • Empty identity: crc32_signature(acc, 0, []) = acc
  • Fold/append: crc32_signature(acc, a++b) = crc32_signature(crc32_signature(acc,a), b) — justifies UAVCAN bootloader's two-call chaining pattern
  • Determinism, 32-bit output range

Concrete check value: crc32_signature(0, 9, "123456789") = 0xCBF43926 (REVENG check value for CRC-32/ISO-HDLC).

Next step (Task 3): translate to Lean using same pattern as Crc16Fold.lean.


Verification Status

✅ Proofs verified: lake build passed with Lean 4.29.0 (31 jobs). 0 sorry remain in new theorems.


Files Changed

Generated by 📐 Lean Squad, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/lean-squad.md@13377ddf7e35c2b6e47aa58f45acb228fba902c8

Task 5 (Proof Assistance): Add multi-step convergence theorems to SlewRate.lean.
- slewIterate: N-step iterate of slewUpdate
- slewIterate_steady: steady state is preserved under iteration
- slewIterate_converges_up: starting ≤ target, N steps suffice when
  target - current ≤ max_step * N (proved 0-sorry)
- slewIterate_converges_down: starting ≥ target, N steps suffice when
  current - target ≤ max_step * N (proved 0-sorry)
- 4 native_decide spot-checks (0→10 in 4 steps, 10→0 in 2 steps, etc.)

Key fix: replaced ring (Mathlib-only) with omega and simp [Int.mul_add]
for the calc steps in the induction cases.

Task 2 (Informal Spec Extraction): Write informal spec for crc32_signature.
- specs/crc32_informal.md: purpose, preconditions, postconditions, edge cases,
  concrete examples (check value 0xCBF43926 for "123456789"), and formal
  properties suitable for Lean (fold/append, empty identity, determinism)
- Identifies crc32_fold as highest-value target (justifies UAVCAN bootloader
  two-call chaining pattern)

lake build: passed (31 jobs, Lean 4.29.0, 0 sorry)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants