Skip to content

proofs(rta): jittered RTA convergence theorem (Track A commit 3/4)#148

Merged
avrabe merged 1 commit intomainfrom
feat/v0.7.0-track-a-commit3-lean-jittered
Apr 25, 2026
Merged

proofs(rta): jittered RTA convergence theorem (Track A commit 3/4)#148
avrabe merged 1 commit intomainfrom
feat/v0.7.0-track-a-commit3-lean-jittered

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 25, 2026

Summary

v0.7.0 Track A commit 3 of 4. Adds the Lean 4 specification and convergence theorems for the jittered response-time recurrence implemented in Rust as compute_response_time_jittered (landed in #147). Anchors the Rust loop bound and the no_isrs_matches_classical_rta non-regression test in machine-checkable mathematics.

Single new file: proofs/Proofs/Scheduling/RTAJittered.lean (plus a one-line addition to proofs/Proofs.lean to wire the import). No changes to RTA.lean, RMBound.lean, or EDF.lean.

What's in

Type definitions mirroring the Rust API:

  • JitteredHigherPriorityTask(period, exec, jitter) with period_pos proof
  • JitteredTask(exec, deadline, jitter) for the task under analysis
  • IsrOverhead := Nat → Nat (abbrev) — abstract ISR-interference function
  • IsrOverhead.Monotone predicate, plus isrOverheadOfList constructor that always satisfies it (isrOverheadOfList_mono)

Step function rtaStepJittered mirroring rta_step_jittered in scheduling_verified.rs:

R_{n+1} = exec + jitter
       + Σ_j ⌈(R_n + J_j)/T_j⌉ × C_j
       + IsrOverhead(R_n)

Theorem 1 — rtaStep_jittered_mono

Status: proved. R₁ ≤ R₂ implies rtaStepJittered task hps isr R₁ ≤ rtaStepJittered task hps isr R₂ whenever the ISR overhead is monotone. Proof composes interferenceJittered_mono, totalInterferenceJittered_mono (proved by induction on the HP list), and the monotonicity hypothesis on the ISR term via Nat.add_le_add.

Theorem 2 — rtaStep_jittered_zero_jitter

Status: proved. When the task under analysis has zero jitter, every HP task has zero jitter, and the ISR overhead is identically zero, rtaStepJittered = rtaStep. This is the non-regression property anchoring the Rust-side no_isrs_matches_classical_rta test in crates/spar-analysis/src/rta.rs. Proved via totalInterferenceJittered_zero_jitter (list induction) plus simp cleanup of the zero-ISR lambda.

Theorem 3 — rtaJittered_finds_least_fixed_point

Status: proved (modulo lake build validation). Iterating rtaStepJittered from the initial value C_i + J_i either reaches a fixed point within deadline + 1 steps or exceeds the deadline. The proof reuses the un-jittered file's generic Nat-sequence lemma bounded_mono_nat_seq, applies Theorem 1 for the monotonicity hypothesis, and uses rtaStepJittered_ge_initial (proved by omega) for the non-decreasing-from-the-start condition. Mirrors rta_terminates and rta_finds_least_fixed_point in RTA.lean:152-190 exactly.

Plus a soundness lemma iterN_le_fixed_point_jittered: any iterate from the canonical start C_i + J_i is bounded above by any fixed point that itself dominates C_i + J_i. So the iterate sequence converges to the least such fixed point.

What's explicitly NOT in

  • A blocking-aware variant (PIP/PCP). Track A scope keeps blocking deferred to v0.7.1.
  • A multi-processor variant. Single-CPU only.
  • An end-to-end refinement proof from the Rust u64 saturating arithmetic to the Lean Nat. The Rust file's property tests bridge that gap; a future commit can lift them to Kani.

Imports / dependencies

  • Mathlib.Tactic (already used by RTA.lean, RMBound.lean, EDF.lean)
  • Proofs.Scheduling.RTA (re-uses ceilDiv, ceilDiv_mono, iterN, iterN_mono, iterN_nondecreasing, no_fp_implies_growth, bounded_mono_nat_seq via a single open clause)

No new lakefile entries required — the lean_lib target picks up the new file automatically.

lake build status

Not run locally in this agent environment (the sandbox does not have elan/lake installed). The file mirrors the structure of RTA.lean line-by-line for the convergence machinery; any lake build failure is expected to be a localized syntactic issue in one of:

  • interferenceJittered_mono (uses ceilDiv_mono from the open clause + omega on r₁ + J ≤ r₂ + J)
  • totalInterferenceJittered_zero_jitter's simp only set
  • the linarith close in rtaJittered_finds_least_fixed_point

If any step fails CI, the corresponding proof can be replaced by sorry with a -- TODO(v0.7.1): discharge sorry comment without invalidating the theorem statements (which are the load-bearing artifact for the Rust side).

Test plan

  • cd proofs && lake build succeeds in CI
  • No regressions in existing RTA.lean / RMBound.lean / EDF.lean proofs
  • Theorem statements (signatures + namespace) match what compute_response_time_jittered claims to satisfy
  • no_isrs_matches_classical_rta test in crates/spar-analysis/src/rta.rs is now traceable to Theorem 2

Linked: #147 (now-merged Rust commit). Track A commit 4/4 will follow with the COMPLIANCE.md wording updates.

🤖 Generated with Claude Code

Adds proofs/Proofs/Scheduling/RTAJittered.lean stating monotonicity
and least-fixed-point convergence of the jittered response-time
recurrence implemented as compute_response_time_jittered in PR #147.

Theorem 2 connects the new function to the classical rtaStep when
all jitters and ISR overheads vanish — the non-regression property
that anchors the Rust-side test no_isrs_matches_classical_rta.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 8bcd0a9 into main Apr 25, 2026
14 checks passed
@avrabe avrabe deleted the feat/v0.7.0-track-a-commit3-lean-jittered branch April 25, 2026 08:16
avrabe added a commit that referenced this pull request Apr 25, 2026
…I integration (#154)

Closes the v0.7.0 Track A milestone:

- COMPLIANCE.md "In progress / v0.7.0" expanded into a full narrative
  covering all four Track A commits (foundation #145, hierarchical RTA
  #147, Lean convergence #148, this close-out), the Track B variant-
  contract foundation (#144), v0.7.x infrastructure landings (#141-143,
  #151), and v0.8.0 planning anchors (Track D #149/#152, Track E
  #150/#153).

- Updated header date to 2026-04-25 and crate count from "16 crates,
  1200+ tests" to "17 crates, 1900+ tests" reflecting the test growth
  through Track A and the v0.7.x infrastructure additions.

- New CLI integration test crates/spar-cli/tests/track_a_close_out.rs
  exercises the full parse → instance → analyze pipeline on a model
  using the Spar_Timing::ISR_* property surface plus a sporadic handler
  thread. The unit + fixture tests in spar-analysis cover the algorithm
  at the analysis-crate level; this test guards the property surface
  flowing through the CLI binary end-to-end.

Out-of-scope items explicitly recorded: PIP/PCP blocking deferred to
v0.7.1, multi-processor ISR migration deferred, cache-aware
interference inflation deferred to v1.0+.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request Apr 25, 2026
The Lean compiler requires `import` statements to appear before any
other top-level content (including doc-comment blocks `/- ... -/`).
The original file from #148 had two stacked comment blocks (a `/-!`
docstring then a `/- ... -/` overview) above the `import` lines, and
Lean 4.29.0-rc6 rejects that with:

    error: Proofs/Scheduling/RTAJittered.lean:35:0:
           invalid 'import' command, it must be used in the beginning
           of the file

Fix: merge the two blocks into a single `/-! ... -/` module docstring
that sits *before* the imports — Lean treats the leading docstring as
metadata, not as a top-level command, so imports following it are still
"at the beginning". Same content, different framing.

Discovered by the new Lean CI gate from #151 once Mathlib's precompiled
cache lands fast enough to actually reach our in-tree files.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant