Skip to content

Commit e65ee21

Browse files
ABI Layer 5: end-to-end soundness capstone certificate (#47)
## Summary Layer 5 (the capstone, completing the 5-layer proof track): a new `*.ABI.Capstone` module importing every prior layer and assembling a single inhabited **`ABISound` certificate** (`abiContractDischarged`) from the real exported witnesses of the flagship property (L2 linear-pointer safety), the deeper invariant (L3 free transition-soundness), and the FFI-seam injectivity (L4). One end-to-end soundness statement. Genuine composition only — reuses real exported names. ## Testing Idris2 0.7.0 `--build` → exit 0, zero warnings. Adversarial: a bogus-field certificate was rejected. `build/` removed. No `believe_me`/`postulate`/`sorry`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx --- _Generated by [Claude Code](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 87aad80 commit e65ee21

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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: the end-to-end ABI SOUNDNESS CERTIFICATE for atsiser.
5+
|||
6+
||| Every prior layer proved one facet of the linear-pointer ABI contract in
7+
||| isolation:
8+
|||
9+
||| * Layer 2 (`Atsiser.ABI.Semantics`) — the FLAGSHIP property: a live
10+
||| pointer is accessible, while a freed one has no accessibility witness
11+
||| (use-after-free / double-free unrepresentable). Its canonical positive
12+
||| control is `liveAccessible : Accessible (MkPtr 4096 Live)`.
13+
||| * Layer 3 (`Atsiser.ABI.Invariants`) — the DEEPER transition invariant:
14+
||| the result of `free` is never accessible again, witnessed concretely by
15+
||| `freeConcreteUnusable` (no reuse / no double-free, dynamic soundness).
16+
||| * Layer 4 (`Atsiser.ABI.FfiSeam`) — the SEAM guarantee: the C integer
17+
||| encoding of `Result` is injective (`resultToIntInjective`), so distinct
18+
||| ABI outcomes never collide on the wire.
19+
|||
20+
||| This module assembles those three already-proven facts into a single record
21+
||| `ABISound` and inhabits it once as `abiContractDischarged`. The value ties
22+
||| the manifest's intent ("wrap C in ATS linear types for zero-cost memory
23+
||| safety") through the ABI proofs (flagship + invariant) and out across the
24+
||| FFI seam into ONE end-to-end soundness statement: if ANY prior layer were
25+
||| unsound — if the flagship control, the no-reuse invariant, or the seam
26+
||| injectivity failed to typecheck — this capstone value would not exist.
27+
|||
28+
||| No new domain theorem is proved here; the certificate is genuine composition
29+
||| of exported witnesses. The non-vacuity control lives in `/tmp/Advatsiser.idr`
30+
||| (an adversarial false certificate that is REJECTED), mirrored conceptually by
31+
||| the negative controls already in each imported layer.
32+
33+
module Atsiser.ABI.Capstone
34+
35+
import Atsiser.ABI.Types
36+
import Atsiser.ABI.Semantics
37+
import Atsiser.ABI.Invariants
38+
import Atsiser.ABI.FfiSeam
39+
40+
%default total
41+
42+
--------------------------------------------------------------------------------
43+
-- The capstone certificate
44+
--------------------------------------------------------------------------------
45+
46+
||| One record gathering the KEY proven facts of the atsiser ABI contract.
47+
|||
48+
||| * `flagship` — Layer 2 flagship property on the canonical positive
49+
||| control: the live pointer at address 4096 is accessible.
50+
||| * `noReuse` — Layer 3 deeper invariant on the SAME concrete instance:
51+
||| once freed, that pointer admits no accessibility witness, so it can
52+
||| never be passed to `free` again.
53+
||| * `seamInjective` — Layer 4 FFI-seam soundness: the `Result` integer
54+
||| encoding is injective, carried here as the full theorem (a function
55+
||| value), not a single instance.
56+
public export
57+
record ABISound where
58+
constructor MkABISound
59+
flagship : Accessible (MkPtr 4096 Live)
60+
noReuse : Not (Accessible (free (MkPtr 4096 Live) Acc))
61+
seamInjective : (a, b : Result) -> resultToInt a = resultToInt b -> a = b
62+
63+
--------------------------------------------------------------------------------
64+
-- The single inhabited capstone value
65+
--------------------------------------------------------------------------------
66+
67+
||| THE capstone: the full ABI contract discharged, built entirely from existing
68+
||| exported witnesses/theorems of Layers 2-4. Its mere existence is the
69+
||| end-to-end soundness proof.
70+
export
71+
abiContractDischarged : ABISound
72+
abiContractDischarged = MkABISound
73+
liveAccessible -- Layer 2 flagship positive control
74+
freeConcreteUnusable -- Layer 3 no-reuse invariant (concrete instance)
75+
resultToIntInjective -- Layer 4 FFI-seam injectivity theorem

src/interface/abi/atsiser-abi.ipkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ modules = Atsiser.ABI.Types
1010
, Atsiser.ABI.Semantics
1111
, Atsiser.ABI.Invariants
1212
, Atsiser.ABI.FfiSeam
13+
, Atsiser.ABI.Capstone

0 commit comments

Comments
 (0)