Skip to content

Commit e369b3c

Browse files
ABI Layer 5: end-to-end soundness capstone certificate (#76)
* feat(abi): prove Conformant scaffold property (Layer 2 Semantics) Add Iseriser.ABI.Semantics proving the headline domain property: a generated -iser scaffold is Conformant exactly when all five required components (Manifest, Idris2 ABI, Zig FFI, Codegen, Rust CLI) are present. Conformant is built from genuine Data.List.Elem membership obligations with no catch-all constructor, so a scaffold missing any component has no witness. Includes a sound+complete decConformant : (s) -> Dec (Conformant s), a soundness fact certifyConformantSound, a positive control (completeIsConformant via explicit Elem positions), and a negative control (ffiMissingNotConformant : Not (Conformant ffiMissing)). Non-vacuity confirmed: a deliberately-false Has Ffi witness for the FFI-missing scaffold is rejected by idris2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx * abi: add Layer-3 Invariants (generation soundness + conformance closure) Add Iseriser.ABI.Invariants over the existing Layer-2 Semantics model (Component/Scaffold/Has/Conformant). Two new, deeper, distinct theorems: 1. Generation soundness (correct-by-construction): genScaffold provably emits (s ** Conformant s) for any LanguageModel, with a corollary tying it back to the Layer-2 certifier (conformantCertifies). 2. Upward-closure / monotonicity: conformantStable proves Conformance is preserved under extension, via a genuine Elem-weakening lemma (elemAppendRight) — an algebraic closure law, not the Layer-2 decision. Includes a sound+complete Dec (decExtendConformant), a positive control (extendedGeneratedConformant) and a non-vacuity negative control (extendedBrokenNotConformant : Not ...). Builds clean with zero warnings; adversarial false proof rejected. No believe_me/postulate/assert_total. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx * abi: seal ABI<->FFI seam with Layer-4 soundness proof (FfiSeam) Add Iseriser.ABI.FfiSeam proving the resultToInt encoding is sound: - intToResult decoder + resultRoundTrip (lossless/faithful encoding) - resultToIntInjective derived from round-trip (distinct outcomes never collide on the wire) - positive controls (concrete decodes by Refl) and a machine-checked non-vacuity control (resultToInt Ok /= resultToInt Error) Genuine total proof: no believe_me/postulate/assert_total/etc. Registered in iseriser-abi.ipkg; package builds clean with zero warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx * abi(iseriser): add Layer-5 capstone ABI soundness certificate Assemble the existing Layer-2/3/4 ABI proofs into one inhabited value, Iseriser.ABI.Capstone.abiContractDischarged : ABISound, with fields: - flagship : Conformant Semantics.completeScaffold (reuses Semantics.completeIsConformant) - invariant : Conformant (extend [Manifest] generatedScaffold) (reuses Invariants.extendedGeneratedConformant) - ffiInjective : resultToInt injectivity (reuses FfiSeam.resultToIntInjective) Pure composition of already-exported witnesses: if any prior layer were unsound the capstone would not typecheck. Adversarial check confirms a wrong-type witness in the flagship slot is rejected. %default total, SPDX, zero warnings. ipkg updated (Capstone listed last). 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> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2e9d19f commit e369b3c

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
-- SPDX-License-Identifier: MPL-2.0
2+
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
--
4+
||| Layer-5 CAPSTONE: the end-to-end ABI SOUNDNESS CERTIFICATE for iseriser.
5+
|||
6+
||| This module proves NO new domain theorem. Its sole job is to ASSEMBLE the
7+
||| already-discharged proof layers into ONE inhabited value, so that the full
8+
||| ABI contract is shown to hold *together*. The certificate ties the chain:
9+
|||
10+
||| manifest/doctrine model (Types: Component, Scaffold, Result)
11+
||| -> Layer-2 flagship (Semantics.completeIsConformant — the canonical
12+
||| positive control: the complete five-component
13+
||| scaffold IS Conformant)
14+
||| -> Layer-3 invariant (Invariants.extendedGeneratedConformant — the
15+
||| upward-closure / monotonicity witness: a
16+
||| generated-then-extended scaffold stays Conformant)
17+
||| -> Layer-4 FFI seam (FfiSeam.resultToIntInjective — distinct ABI
18+
||| outcomes never collide on the C wire)
19+
|||
20+
||| into a single end-to-end soundness statement. `abiContractDischarged` is the
21+
||| capstone value: it is constructed ENTIRELY from the existing exported
22+
||| witnesses/theorems of the prior layers. If ANY prior layer were unsound,
23+
||| this value would not typecheck. There is no fresh proof obligation here —
24+
||| only genuine composition.
25+
26+
module Iseriser.ABI.Capstone
27+
28+
import Iseriser.ABI.Types
29+
import Iseriser.ABI.Semantics
30+
import Iseriser.ABI.Invariants
31+
import Iseriser.ABI.FfiSeam
32+
33+
%default total
34+
35+
--------------------------------------------------------------------------------
36+
-- The capstone certificate
37+
--------------------------------------------------------------------------------
38+
39+
||| `ABISound` bundles the KEY proven facts of the iseriser ABI into one record.
40+
||| Each field is the TYPE of an already-proven theorem from a prior layer; the
41+
||| only way to inhabit the record is to supply those real witnesses.
42+
|||
43+
||| * `flagship` : the Layer-2 flagship property holds on the canonical
44+
||| positive-control instance (`Semantics.completeScaffold` is
45+
||| `Conformant`).
46+
||| * `invariant` : the Layer-3 deeper invariant holds — conformance is
47+
||| upward-closed under extension, witnessed on the generated
48+
||| scaffold extended by one component.
49+
||| * `ffiInjective` : the Layer-4 FFI-seam guarantee — `resultToInt` is
50+
||| injective, so distinct ABI outcomes never collide on the
51+
||| wire. Stored as the full injectivity statement.
52+
public export
53+
record ABISound where
54+
constructor MkABISound
55+
flagship : Conformant Semantics.completeScaffold
56+
invariant : Conformant (extend [Manifest] Invariants.generatedScaffold)
57+
ffiInjective : (a, b : Result) -> resultToInt a = resultToInt b -> a = b
58+
59+
||| THE CAPSTONE. A single inhabited value assembled purely from the existing
60+
||| exported witnesses of Layers 2-4. Its mere existence certifies that the
61+
||| flagship property, the deeper invariant, and the FFI-seam injectivity are
62+
||| ALL simultaneously discharged for this ABI — manifest model -> ABI proofs
63+
||| -> FFI seam, sealed end to end.
64+
public export
65+
abiContractDischarged : ABISound
66+
abiContractDischarged =
67+
MkABISound
68+
completeIsConformant -- Layer-2 flagship positive control
69+
extendedGeneratedConformant -- Layer-3 upward-closure invariant witness
70+
resultToIntInjective -- Layer-4 FFI-seam injectivity

src/interface/abi/iseriser-abi.ipkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ modules = Iseriser.ABI.Types
1212
, Iseriser.ABI.Semantics
1313
, Iseriser.ABI.Invariants
1414
, Iseriser.ABI.FfiSeam
15+
, Iseriser.ABI.Capstone

0 commit comments

Comments
 (0)