Skip to content

proofs(network): NC primitives min-plus theorems (Track D commit 5/6)#169

Merged
avrabe merged 3 commits intomainfrom
feat/v0.8.0-track-d-commit5-lean-nc
Apr 27, 2026
Merged

proofs(network): NC primitives min-plus theorems (Track D commit 5/6)#169
avrabe merged 3 commits intomainfrom
feat/v0.8.0-track-d-commit5-lean-nc

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 26, 2026

Summary

Adds proofs/Proofs/Network/MinPlus.lean — Lean 4 / Mathlib statements of the classical Network Calculus closed-forms that anchor crates/spar-network/src/curves.rs (Track D commit 3, PR #161). The Lean module is wired into proofs/Proofs.lean alongside the existing Proofs.Scheduling.* modules.

What is delivered

Theorems in Spar.Network.MinPlus (mirroring Le Boudec & Thiran, Network Calculus, ch. 1, theorems 1.4.1-1.4.3):

Theorem Status
arrival_at_mono — α(t) monotone non-decreasing proved
service_at_mono — β(t) monotone non-decreasing proved
service_at_zero_below_latency — β(t) = 0 for t ≤ T proved
service_at_zero_strictly_below_latency — strict variant proved
service_at_zero_at_zero — β(0) = 0 proved
backlog_bound_classical — B = σ + ρ·T statement only (sorry + TODO v1.0.0)
delay_bound_classical — D = T + σ/R statement only (sorry + TODO v1.0.0)
output_bound_rate_preserved — rate / peak preserved, burst inflated by ρ·T proved (constructive)
output_dominates_input — α'(t) ≥ α(t) statement only (sorry + TODO v1.0.0)
compose_delays — naive serial-chain sum proved (existence of witness)
compose_delays_dominates — chained-delay domination statement only (sorry + TODO v1.0.0)
arrival_at_zero_is_burst — α(0) = σ partial (sorry for peak case; flags spec/impl mismatch)

Plus structural lemmas (output_preserves_*, output_stable_for_chain, backlogChained_eq_sum, etc.) and the compose_delays_zero_latency arithmetic identity (one residual sorry for div_ceil normalisation).

Per project policy, sorry is acceptable here — the statements are the load-bearing artifact (they pin the math the Rust min-plus kernel commits to). Full proof discharge is scheduled for v1.0.0.

Files changed

  • proofs/Proofs/Network/MinPlus.lean (new, 417 LOC)
  • proofs/Proofs.lean (add import Proofs.Network.MinPlus)
  • artifacts/requirements.yaml (REQ-NETWORK-007)
  • artifacts/verification.yaml (TEST-LEAN-MINPLUS → REQ-NETWORK-007)

lake build status

Not run locallylake / elan are not available in the local sandbox. The proofs CI gate from PR #151 is the verifier here. If a build break shows up there, the offending theorem will be the only one needing adjustment (the type definitions are direct mirrors of the Rust struct fields and the proofs are either trivial rfl or sorry-discharged).

Test plan

  • CI proofs gate (feat(ci): Lean proof + Bazel + proptest CI gates (#135) #151) reports green for Proofs/Network/MinPlus.lean
  • cargo build --workspace clean (verified locally — Lean changes don't touch Rust)
  • rivet validate clean (verified locally — same 91 pre-existing warnings, no new ones)
  • Confirm Proofs.Network.MinPlus namespace is reachable from downstream Lean modules (none yet — Track D commit 6 will consume)

Follow-ups (post-MVP)

  • v1.0.0: discharge the four sorry theorems via real-number reasoning (Mathlib rpow, div_ceil lemmas).
  • v1.0.0: reconcile arrival_at_zero_is_burst with the Rust short-circuit if t_ps == 0 branch — either fold into the spec or split into a separate "Rust-impl-aligned" lemma.

🤖 Generated with Claude Code

Adds proofs/Proofs/Network/MinPlus.lean stating classical Network
Calculus closed-forms mirroring crates/spar-network/src/curves.rs:

  - arrival_at_mono / service_at_mono: monotonicity of α(t), β(t)
  - service_at_zero_below_latency: β(t) = 0 for t < latency
  - backlog_bound_classical: σ + ρ·latency for stable affine flow
  - delay_bound_classical: latency + σ/rate (horizontal distance)
  - output_bound_rate_preserved: burst grows by ρ·latency through server
  - compose_delays: serial chain delay sums per-hop terms

Some proofs use `sorry` and a TODO(v1.0.0) comment; statements are the
load-bearing artifact, full discharge is post-MVP.

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

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

avrabe and others added 2 commits April 26, 2026 21:26
Lean CI surfaced "Unknown constant Nat.min_le_min" at MinPlus.lean:110.
The `Nat.min_le_min` qualified path doesn't exist in Mathlib v4.29.x;
the unqualified `min_le_min` (defined for any LinearOrder, including
Nat) discharges the same goal.

Format-only edit — same proof, correct lemma name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI surfaced "No goals to be solved" at MinPlus.lean:416. The
`simp [hne1, hne2, h1, h2]` on line 412 fully discharges the
compose_delays_zero_latency residual; the trailing `sorry` (left as
a TODO during initial drafting because simp's behaviour wasn't
verified locally) is therefore unreachable and Lean rejects it.

Removing the sorry + its TODO comment. The proof is now complete
without sorry — one fewer TODO(v1.0.0) item to chase down.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit a619fc1 into main Apr 27, 2026
17 checks passed
@avrabe avrabe deleted the feat/v0.8.0-track-d-commit5-lean-nc branch April 27, 2026 04:02
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