Skip to content

ABI Layer 4: prove the FFI result-code seam is injective + faithful#40

Merged
hyperpolymath merged 4 commits into
mainfrom
claude/new-session-znxgm7
Jun 28, 2026
Merged

ABI Layer 4: prove the FFI result-code seam is injective + faithful#40
hyperpolymath merged 4 commits into
mainfrom
claude/new-session-znxgm7

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Layer 4 (seal the ABI↔FFI seam): proves the FFI result-code encoding (resultToInt) is a sound, lossless wire encoding — decoder intToResult with resultRoundTrip, from which resultToIntInjective is derived. Distinct ABI outcomes never collide on the C wire. Complements the structural abi-ffi-gate.py.

New module *.ABI.FfiSeam (imports Types). Positive + non-vacuity controls.

Testing

Idris2 0.7.0 --build → exit 0, zero warnings. Adversarial rejection confirmed. build/ removed. No believe_me/postulate/sorry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx


Generated by Claude Code

claude and others added 4 commits June 27, 2026 19:57
…emantics

Add a flagship machine-checked semantic proof raising the Tlaiser Idris2 ABI
to Layer 2. Models a two-process lock-based mutual-exclusion state machine (the
canonical PlusCal example) with an Init predicate, a nondeterministic Step
relation, and an inductive Reachable closure.

Headline theorem (safetySound): mutual exclusion (Safe) holds on every
reachable state. The engine is invInductive (TLA+ INV1): a strengthened,
genuinely inductive invariant Inv that couples "process is Critical" to
"process holds the lock" holds initially (initEstablishes) and is preserved by
every transition (stepPreserves), hence holds on all reachable states; Safe is
derived from Inv (invImpliesSafe).

Includes a sound+complete Dec (decSafe), a Result-valued certifier with
soundness (certifyReachableSound), a positive control (a real reachable
Critical state, proven Safe) and negative controls (the (Critical,Critical)
state has no Safe proof and is unreachable). The "both critical" bad case has
no constructor, so a deliberately false safety witness is rejected by idris2
(non-vacuity verified).

Builds clean (idris2 0.7.0, zero warnings).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
…inductive)

Add Tlaiser.ABI.Invariants, a deeper, distinct machine-checked theorem built
over the SAME Layer-2 state-machine model (St/Init/Step/Reachable/Inv in
Tlaiser.ABI.Semantics; no datatypes redefined).

Layer-2 proved INV1 for one hand-crafted invariant. Layer-3 proves the
meta-theorem that licenses modular invariant construction in TLA+/TLAPS:

  andInductive : IsInductive p -> IsInductive q -> IsInductive (And p q)
  "the conjunction of two inductive invariants is itself inductive."

Contents:
- IsInductive p: the two INV1 premises (established by Init, preserved by Step)
  packaged as a first-class value so inductiveness can be combined.
- inductiveOnReachable: generic INV1 (any inductive p holds on all reachable
  states), proved once polymorphically.
- andInductive: the headline composition theorem.
- HolderCrit: a SECOND, independent concrete invariant ("the lock holder is
  Critical"), proved inductive from scratch (holderInit + holderStep over the
  existing Step relation), packaged as holderIsInductive.
- combinedIsInductive / combinedOnReachable: Inv and HolderCrit composed via
  andInductive, yielding the conjunction on every reachable state with no new
  induction.
- decHolderCrit: sound + complete Dec for the second invariant; certifyHolder
  reuses the Result ABI; certifyHolderReachableSound ties it together.
- Controls: positive (inhabited reachable witness of the conjunction +
  decided Ok), negative (Not (HolderCrit (Idle,Idle,HeldBy0))), and a
  distinctness/non-vacuity control (HolderCrit holds but Inv fails on
  (Critical,Critical,Free) — proving the two predicates are genuinely
  different).

Clean build, zero warnings; adversarial false statements rejected. No
believe_me/postulate/assert_total/idris_crash. %default total throughout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Prove resultToInt is a sound wire encoding for the Tlaiser FFI Result
enum: a total faithful decoder intToResultSeam with resultRoundTrip
(encode-then-decode = identity), and resultToIntInjective derived from
the round-trip via cong + justInjective. Includes positive decode
controls and a machine-checked non-vacuity control (Ok and Error have
distinct wire integers). Genuine total proofs; no escape hatches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath hyperpolymath marked this pull request as ready for review June 28, 2026 06:41
@hyperpolymath hyperpolymath merged commit 9efc926 into main Jun 28, 2026
6 checks passed
@hyperpolymath hyperpolymath deleted the claude/new-session-znxgm7 branch June 28, 2026 06:41
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