Skip to content

[Lean Squad] feat(fv): interpolateNXY 3-pt spec (Task 4) + deadzone/expodz odd symmetry (Task 5) — run36#35

Merged
dsyme merged 3 commits intomainfrom
lean-squad/new-targets-run36-1744623000-d511158492ead7e9
Apr 15, 2026
Merged

[Lean Squad] feat(fv): interpolateNXY 3-pt spec (Task 4) + deadzone/expodz odd symmetry (Task 5) — run36#35
dsyme merged 3 commits intomainfrom
lean-squad/new-targets-run36-1744623000-d511158492ead7e9

Conversation

@github-actions
Copy link
Copy Markdown

🔬 Lean Squad — automated formal verification run 36.

Summary

Two tasks completed this run:

Task 4 — Implementation Extraction: interpolateNXY (new target)

New file: formal-verification/lean/FVSquad/InterpolateNXY.lean

Formal specification and proofs for math::interpolateNXY from
src/lib/mathlib/math/Functions.hpp. Models the 3-point case (N=3) as interp3:

// C++ original (N=3 case):
// - v > x[1]: use interpolate(v, x[1], x[2], y[1], y[2])
// - v ≤ x[1]: use interpolate(v, x[0], x[1], y[0], y[1])

9 theorems proved, 0 sorry:

Theorem Property
interp3_low_clamp v ≤ x0 → output = y0 (clamped at low end)
interp3_high_clamp v > x2 → output = y2 (clamped at high end)
interp3_at_x0 At first breakpoint: output = y0
interp3_at_x1 At interior breakpoint: output = y1 (from segment 0)
interp3_seg1_at_x1 Continuity: segment 1 also gives y1 at x1
interp3_at_x2 At last breakpoint: output = y2
interp3_le_y2 Upper range bound: output ≤ y2 when y-values ordered
interp3_ge_y0 Lower range bound: output ≥ y0 when y-values ordered
interp3_mono_seg0 Monotone within segment 0: larger v → larger output

The continuity proof (interp3_at_x1 + interp3_seg1_at_x1) is particularly
important: it confirms the two piecewise segments join smoothly at y[1], ruling out
discontinuous "jumps" at the interior breakpoint that could cause actuator transients.

New file: formal-verification/specs/interpolatenxy_informal.md — informal spec
with purpose, preconditions, postconditions, edge cases and worked examples.

Task 5 — Proof Assistance: Odd Symmetry for deadzone and expo-deadzone

deadzone_odd (Deadzone.lean)

New theorem: deadzone_odd — the deadzone is an odd function:

theorem deadzone_odd (x dz : Rat) (hdz : 0 ≤ dz) :
    deadzone (-x) dz = -(deadzone x dz)

Three-case proof: positive branch (x > dz), negative branch (x < -dz),
in-deadzone (|x| ≤ dz). Each case uses the existing deadzone_pos_eq/deadzone_neg_eq
lemmas and rational arithmetic (Rat.neg_sub, Rat.neg_add, Rat.div_def).

This is a key structural property: the RC stick deadzone preserves sign symmetry.

expodz_odd (ExpoDeadzone.lean)

New theorem: expodz_odd — the expo-deadzone pipeline is an odd function:

theorem expodz_odd (v e dz : Rat) (hdz : 0 ≤ dz) :
    expodz (-v) e dz = -(expodz v e dz)

Proof by composition: deadzone_odd + expo_odd (expo already had this theorem).
This was the gap flagged in the previous run's CRITIQUE.md.


Verification Status

✅ Proofs verified: lake build passed with Lean 4.29.0. 0 sorry in new/modified files.

All 19 modules built successfully. Only pre-existing 6 sorry warnings in WrapAngle.lean
(wrapRat theorems requiring Mathlib floor arithmetic — unchanged).


Files Changed

  • formal-verification/lean/FVSquad/InterpolateNXY.lean — new (9 theorems, 0 sorry)
  • formal-verification/specs/interpolatenxy_informal.md — new (informal spec)
  • formal-verification/lean/FVSquad/Deadzone.lean — add deadzone_odd theorem
  • formal-verification/lean/FVSquad/ExpoDeadzone.lean — add expodz_odd theorem
  • formal-verification/lean/FVSquad.lean — add InterpolateNXY import
  • formal-verification/TARGETS.md — add targets 16 and 17

Generated by 🔬 Lean Squad, see workflow run.

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

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/lean-squad.md@97143ac59cb3a13ef2a77581f929f06719c7402a

github-actions Bot and others added 2 commits April 14, 2026 10:11
…ility critique update (run35)

Task 5 (Proof Assistance): Add ExpoDeadzone.lean — formal specification and proofs
for the combined expo(deadzone(v, dz), e) RC input pipeline.

8 theorems proved (0 sorry, lake build passes):
- expodz_in_dz: inside-deadzone input → exactly 0
- expodz_in_range: output always ∈ [-1, 1] (unconditional)
- expodz_zero: zero input → zero output for dz ≥ 0
- expodz_at_one / expodz_at_neg_one: ±1 are fixed points for dz ∈ [0, 1)
- expodz_e0: e=0 (linear expo) reduces to pure deadzone
- expodz_cubic: e=1 (full cubic expo) gives (deadzone v dz)³
- expodz_no_dz: dz=0 recovers exactly expoRat (no-deadzone degeneration)

Proofs compose expo_* and deadzone_* theorems from prior Lean files,
demonstrating compositional verification of the two-stage RC pipeline.
Also registers ExpoDeadzone + MedianFilter + SuperExpo in FVSquad.lean.

Task 7 (Proof Utility Critique): Update CRITIQUE.md to reflect current state:
- 15 targets, 172 theorems, 166 proved, 6 sorry (WrapAngle wrapRat only)
- Add SuperExpo, MedianFilter, ExpoDeadzone rows to proved-theorems table
- Update gaps: add expodz_odd as next high-priority target
- Add positive findings #10-12 (MedianFilter spike rejection, superexpo
  denom-positive safety, expo+deadzone composition correctness)
- Update Known Sorry-Guarded section (14 files, 0 sorry except WrapAngle)

> ✅ Proofs verified: lake build passed with Lean 4.29.0. 0 sorry in new file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… (run36)

Task 4 (Implementation Extraction — new target):
- New file: formal-verification/lean/FVSquad/InterpolateNXY.lean
  Models math::interpolateNXY for N=3 as interp3
  9 theorems, 0 sorry (lake build passed)
- New file: formal-verification/specs/interpolatenxy_informal.md
  Informal spec: purpose, pre/postconditions, edge cases, examples

Task 5 (Proof Assistance — odd symmetry):
- Deadzone.lean: add deadzone_odd theorem
  deadzone(-x, dz) = -(deadzone x dz) for dz >= 0
  Three-case proof: pos branch, neg branch, in-deadzone
- ExpoDeadzone.lean: add expodz_odd theorem
  expodz(-v, e, dz) = -(expodz v e dz) for dz >= 0
  Proof by composition: deadzone_odd + expo_odd

Total theorems: 172 -> 183 (11 new), sorry unchanged at 6 (WrapAngle only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme merged commit 733ac19 into main Apr 15, 2026
1 check passed
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.

1 participant