Skip to content

proofs: add standalone x86_64 Fl4Spec ↔ l4v ASpec equivalence suite - #159

Merged
losfair merged 1 commit into
losfair:mainfrom
CommaBot:spec-equiv-x64
Dec 6, 2026
Merged

losfair merged 1 commit into
losfair:mainfrom
CommaBot:spec-equiv-x64

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a standalone, machine-checked Lean 4 equivalence suite (proofs/Fl4SpecEquivX64/) relating FL4's frozen x86_64 base abstract specification (proofs/Fl4Spec/, 23 base modules) to upstream seL4/l4v (rt branch, L4V_ARCH=X64 with a provenance-tracked X64-MCS Isabelle overlay through Syscall_A.call_kernel).

The suite is completely standalone — it is not imported from Fl4Proofs.lean or Fl4ProofsA64.lean and has zero impact on existing P0–P3 builds or CI.

Scope & Contents (113 files, +39,521 / -0)

  • proofs/Fl4SpecEquivX64/L4vRefX64/ (100 Lean 4 files, 34,646 LoC, 947 public theorems):
    • Spec/ (59 generated X64 ASpec theories + Spec.lean) emitted deterministically from Isabelle2025-2 typed HOL AST export (aspec-x64-full.jsonl).
    • Prim.lean (507-line HOL primitive layer shared with Fl4SpecEquivA64) & PrimX64.lean.
    • Rel/ (Config, Embed, Extension, Invocation, Lift, Monad, State): StateRel, ConfigRel, OpaqueRel RestRel, BaseCarriers (including NoVirtObjects and base-carrier restrictions).
    • Patched.lean: explicit, kernel-checked point-delta theorems documenting every deliberate divergence between upstream l4v X64 and FL4 (newContext_selectors_delta, decodeObjectType_codes7to11_delta, notificationBits_delta, asidWidths_delta, asidFreeIndex_delta, tcbEptSlot_delta, finaliseTcbZombieSlots_delta, lookupIpcBuffer_slot_delta, makeArchFaultMsg_delta, ioPortOwner_delta, invocationLabel_numbering_delta, hugePages_delta, endTimeslice_runningVM_delta, compiledNumDomains_delta, maxPeriodUs_delta).
    • Equiv/ (28 proof modules): end-to-end single-step kernel equivalence patched_callKernel_equiv (L4vRefX64/Equiv/Syscall.lean) covering all 11 syscall routes and all 5 non-syscall event constructors, guarded by run-indexed CallKernelSafe (0 unconstrained ∀ s : Structures_A.state in public *Safe or theorem signatures).
    • Equiv/Witness.lean: 26 public non-vacuity witness theorems, including the 16-domain PC99 configuration model witness (pc99Config_exists), direct instantiations of patched_callKernel_equiv (liveOneTickInterruptWitness charging 1 tick & advancing both oracles, liveNbWaitWitness delivering badge 0x62 & clearing notification), and sub-entry witnesses (liveScheduleWitness, native unmaps, IRQ issue/binding, TCB install, liveMakeAsidPoolWitness, liveLinkedFaultReplyWitness).
    • Manifest.lean: #print axioms audit over all 1,043 public theorems (including patched_callKernel_equiv and all witnesses).
  • proofs/Fl4SpecEquivX64/overlay/: minimal 25-hunk X64-only MCS Isabelle overlay (x64-mcs-overlay.patch, SHA-256 a4d0d1fe...) with per-hunk upstream donor citations (overlay-provenance.md; zero edits to generic MCS theories).
  • proofs/Fl4SpecEquivX64/tools/: ExportASpec.ML, Run_X64_Export.ML, phase1-theories.txt, phase1-symbols.txt, emit_l4v_ref.py, fail-closed build.py (enforcing zero warnings, 1,043 theorem floor, required headline/witness theorems, and standard-only axioms), and test_build.py negative self-tests.
  • proofs/Fl4SpecEquivX64/{README.md,PHASE2_REPORT.md,PATCHED_INVENTORY.md}: reproduction steps, explicit TCB disclosure (noting that call_kernel_p is a hand-patched call tree of 129 *_p definitions whose correspondence to Spec/* outside Patched.lean is established by inspection and indexed with exact file:line links in PATCHED_INVENTORY.md), and scope boundaries (ConfigRel, OpaqueRel RestRel, single-step CallKernelSafe, per-core base spec).
  • proofs/Fl4Spec/PORTING.md (+6 lines): documents the two intentional FL4 x86_64 deviations confirmed in Phase 1 (initial user selectors CS=0x33 / SS=0x2B vs 0x2B / 0x33, and arch-relative object codes 7..11 decoding to VCPU/EPT types vs None).

(Root README.md, DESIGN.md §9, and TRUSTED pointers are intentionally deferred to a small follow-up once #157 and #158 land, keeping this PR conflict-free.)

Verification

  • Pinned inputs: FL4@ed6b927999d462bc217cfcd44a5b02b8bab7c4ff, l4v@f44de69e426184f5edff14aeb8d8e03385f33c01, seL4@c98d70adf15e8be7d3b99085c28d057069ba7155 (all clean).
  • Lean 4 gate (fresh build directory): BUILD OK: 100 rebuilt, 100 total, 0 warnings, 0 errors, 0 forbidden tokens (sorry/admit/axiom/unsafe/implemented_by/extern/native_decide/partial), AXIOM_AUDIT PASS: 1043/1043 theorems strictly standard (⊆ {propext, Classical.choice, Quot.sound}).
  • Negative gate self-tests (tools/test_build.py): 5/5 PASS (rejects sorryAx, module warnings, manifest warnings, and missing required theorems at the 1,043 floor).
  • Regeneration check: Re-running Run_X64_Export.ML + emit_l4v_ref.py from the committed entry points matched the audited export digest (6a7c95f9...) and all 59 generated Lean theories + Spec.lean byte-for-byte.
  • Reviews: Independent static review (0 P0, 0 P1 after resolving documentation/inventory/reproducibility/gate findings, 129/129 PATCHED_INVENTORY.md rows script-verified) → APPROVE.

Check the guarded kernel step against the pinned l4v X64 MCS reference and include the reference overlay, regeneration tools, and axiom audit. Record the intentional x86-64 selector and object-type differences in the porting notes.
@losfair
losfair merged commit 34fca7a into losfair:main Dec 6, 2026
1 check was pending
CommaBot added a commit to CommaBot/FL4 that referenced this pull request Dec 6, 2026
…into par/a64-p6-int

Merged against the base 6c92d26 (main's Stage-5 squash has the same tree), so only the
Fl4SpecEquiv additions and the two PORTING.md edits come in.

Co-Authored-By: Claude Sonnet 5.5 <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.

2 participants