Skip to content

Add Lean4 proof kernel, scheduling analysis, and conformance tests#38

Open
avrabe wants to merge 6 commits intomainfrom
feat/stpa-safety-batch3
Open

Add Lean4 proof kernel, scheduling analysis, and conformance tests#38
avrabe wants to merge 6 commits intomainfrom
feat/stpa-safety-batch3

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Mar 15, 2026

Summary

  • Lean4 proof kernel for scheduling theory (RTA convergence, monotonicity, least fixed point — 0 sorry in RTA.lean)
  • RTA + EDF scheduling analysis rewrite with margin reporting, tight-margin warnings, modal awareness
  • Lean-to-Rust codegen (lake exe codegen) generates verified Rust from proven definitions
  • 9 conformance tests verify actual scheduling.rs math matches Lean-proven reference (systematic sweep of 180 parameter combinations)
  • STPA batch 3 — tool landscape survey, analysis scope hazards, wave 2 requirements

Lean proofs (12 theorems proven)

  • ceilDiv_mono, interference_mono, totalInterference_mono, rtaStep_mono
  • bounded_mono_nat_seq — core pigeon-hole termination argument
  • rta_terminates — bounded by deadline + 1 iterations
  • rta_finds_least_fixed_point — converged result is minimal

Test plan

  • 327 spar-analysis tests pass (including 9 new conformance tests)
  • 4 scheduling_verified unit tests pass
  • lake exe codegen generates valid Rust
  • Lean4 proofs type-check (lake build)

🤖 Generated with Claude Code

avrabe and others added 6 commits March 14, 2026 23:36
17 tools catalogued with capabilities, differentiators, and adoption
potential. Overview doc references artifacts via [[TOOL-*]] links.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 AADL tools now catalogued. Key additions: Sireum HAMR (only tool
generating Rust from AADL), Sireum Awas (security flow analysis),
EMFTA (open-source FTA), COMPASS (ESA formal verification suite),
MASIW (AFDX network analysis).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tool comparison revealed a blind spot: original STPA only covered
"spar does X wrong" not "spar lacks critical X, creating false
confidence." New findings:

- H-7: Analysis scope creates false confidence (RM-only scheduling)
- H-8: Missing standard safety outputs (FTA/FMEA from EMV2)
- UCA-17..20: Misleading verdict, no margin, no FTA, no cross-check
- LS-9..12: Concrete scenarios (blocking masks deadline miss, etc.)
- CC-15..18: Algorithm assumption checks, margin reporting
- STPA-REQ-024..031: 8 new safety requirements (all not-implemented)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement STPA-REQ-024 through STPA-REQ-026 and STPA-REQ-031:
- Response Time Analysis (RTA) with fixed-point iteration for exact
  worst-case response times including higher-priority interference
- EDF feasibility check (U ≤ 1.0 for implicit-deadline tasks)
- Margin reporting with warnings at <5% and critical at <1%
- Analysis limitation documentation info diagnostic

Scheduling analysis now produces RMA utilization bound, RTA per-task
response times, and EDF feasibility — matching capabilities of
Cheddar/MAST for the common fixed-priority preemptive case.

15 tests (was 9): rta convergence/divergence, EDF feasibility,
margin warnings, explicit deadlines, limitation docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Machine-checked proofs of the mathematical theorems underlying
spar's scheduling analysis (RTA, EDF, RM bound):

RTA.lean (fully proven, 0 sorry):
- ceilDiv/interference/totalInterference monotonicity
- rtaStep monotonicity and fixed-point iteration convergence
- bounded_mono_nat_seq: pigeon-hole termination argument
- rta_terminates: RTA either finds fixed point or exceeds deadline
- iterN_le_fixed_point: iterate ≤ any fixed point (least FP)

EDF.lean (1 sorry):
- demand_le_interval: single-task demand ≤ interval when U≤1
- totalDemand_le_nL: total demand bound
- demandBound_at_period: exact demand at period boundaries
- edf_two_tasks_demand: sorry (needs rational arithmetic)

RMBound.lean (1 sorry):
- rmBound_one: RM bound for n=1 is exactly 1.0
- rm_single_task: U≤1 for C≤T
- rmBound_ge_ln2: sorry (needs calculus)

Uses Mathlib for push_neg, linarith, positivity, norm_num.
Zero runtime cost — proofs are build-time only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codegen.lean generates verified Rust from proven Lean4 definitions.
Nine conformance tests verify the actual scheduling.rs math matches
the Lean-proven reference at every decomposition level (ceil_div,
interference, total_interference, rta_step, full RTA iteration).

Co-Authored-By: Claude Opus 4.6 <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