Skip to content

Commit 9988d8b

Browse files
hyperpolymathclaude
andcommitted
feat(abi): T5-proper kernel — decidable access-typing spec (extractable checker)
`SiteWellTyped` is decidable (a Bool equality + a Nat equality + an LTE), so `AccessTypingClean` is too: `decAccessTypingClean` is a correct-by-construction access-typing checker derivable from the spec itself — its `Yes` carries the acceptance proof, its `No` a refutation of one conjunct. This is the verified KERNEL of T5: the typing decision is now COMPUTABLE inside the spec ("the checker moved inside the spec's sight"), collapsing all typing-LOGIC trust. The residual trust reduces to decode-faithfulness ALONE (producing the SpecSite data from wasm bytes) — the WasmCert-scale tail. Full extraction-to-Rust and the wasm operational-semantics tie-back remain the open, multi-week T5 frontier; this is its verified core. idris2 --build: exit 0, 24 modules; no believe_me/postulate/sorry/assert_total; %default total; no new warnings. Stacked on #173 (T5a access-typing spec); to be rebased onto main and PR'd once #173 lands. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6249995 commit 9988d8b

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/abi/TypedWasm/ABI/AccessTypingSpec.idr

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import TypedWasm.ABI.PackedLayout
4141
import Data.Nat
4242
import Data.List
4343
import Data.List.Quantifiers
44+
import Decidable.Equality
4445

4546
%default total
4647

@@ -241,3 +242,43 @@ typedVerifierIsComplete _ (MkTypedSpecAccepts w) = TVAStructural w
241242
export
242243
specAcceptsWitness : TypedSpecAccepts sites -> AccessTypingClean sites
243244
specAcceptsWitness (MkTypedSpecAccepts w) = w
245+
246+
-- ============================================================================
247+
-- T5-proper kernel: the spec acceptance criterion is an EXECUTABLE checker
248+
-- ============================================================================
249+
--
250+
-- `SiteWellTyped` is decidable (each of its three conjuncts is: a Bool
251+
-- equality, a Nat equality, and an LTE), so `AccessTypingClean` is too.
252+
-- The spec's acceptance predicate is therefore not merely "holds by
253+
-- construction" — it is COMPUTABLE: `decAccessTypingClean` is a
254+
-- correct-by-construction checker derivable from the spec itself, whose
255+
-- `Yes` carries the full acceptance proof and whose `No` carries a refutation.
256+
--
257+
-- This is the concrete sense in which the typing checker can be "moved
258+
-- inside the spec's sight" (collapsing the determine-vs-bound BOUND on the
259+
-- typing LOGIC): the decision procedure IS a verifier, verified. After this,
260+
-- the residual trust is decode-faithfulness ALONE — producing the `SpecSite`
261+
-- data from wasm bytes — with no trust remaining in the typing decision. Full
262+
-- extraction-to-Rust and the wasm operational-semantics (WasmCert) tie-back
263+
-- remain the open, multi-week T5 tail; this is its verified kernel.
264+
265+
||| The spec's per-site acceptance is decidable: a `Yes` builds the
266+
||| `SiteWellTyped` witness, a `No` refutes one of its three conjuncts.
267+
export
268+
decSiteWellTyped : (s : SpecSite) -> Dec (SiteWellTyped s)
269+
decSiteWellTyped s =
270+
case decEq (opMatchesField (siteOp s) (siteField s)) True of
271+
No nm => No (\(MkSiteWellTyped m _ _) => nm m)
272+
Yes m => case decEq (siteOffset s) (siteFieldOff s) of
273+
No no => No (\(MkSiteWellTyped _ o _) => no o)
274+
Yes o =>
275+
case isLTE (siteFieldOff s + packedScalarSize (siteField s)) (siteRegionSz s) of
276+
No nl => No (\(MkSiteWellTyped _ _ l) => nl l)
277+
Yes l => Yes (MkSiteWellTyped m o l)
278+
279+
||| The whole-list acceptance criterion is decidable — the verified,
280+
||| extractable access-typing checker. Running it on the sites the Rust
281+
||| pass decodes is the data-level cross-check the bound reduces to.
282+
export
283+
decAccessTypingClean : (sites : List SpecSite) -> Dec (AccessTypingClean sites)
284+
decAccessTypingClean = all decSiteWellTyped

0 commit comments

Comments
 (0)