Repository navigation
audit: 2 Idris2 postulates in src/abi/Layout.idr — alignment + alignedSize correctness #27
Description
Context
A 2026-05-20 cross-estate trust-escape sweep surfaced 2 Idris2 postulates in `src/abi/Layout.idr` that aren't tracked under the standards#133 POST-T0 axiom audit (that audit covered `proofs/lean4/` + `proofs/coq/` model-layer axioms — 117 declarations triaged to 73 Axioms + 42 Parameters, all owner-classified as legitimate model-layer assumptions about abstract Parameters).
The two Layout.idr postulates are a different kind: they're concrete number-theoretic lemmas about `mod` arithmetic, deferred awaiting a div/mod lemma library.
The two postulates
1. `alignmentMatchesPlatformWord` (line 251)
```idris
export
postulate alignmentMatchesPlatformWord :
(p : Platform) -> {0 t : Type} -> {n : Nat} ->
HasAlignment t n -> So (n `mod` (ptrSize p `div` 8) == 0)
```
Comment cites "the same deferral pattern as civic-connect/src/Abi/Layout.idr (alignUpDivides, mkFieldsAligned, offsetInBoundsPrf)" — so this is a known cross-repo pattern.
The obligation moves to the producer: `AlignProof` must only be constructed for types whose alignment genuinely matches platform word size. But the postulate itself sits in the trusted base.
2. `alignedSizeCorrect` (line 297)
```idris
export
postulate alignedSizeCorrect : (size : Nat) -> (align : Nat) -> {auto 0 nonZero : So (align /= 0)} ->
So (alignedSize size align `mod` align == 0)
```
Comment: "showing `(size + align - remainder) mod align = 0` needs the div/mod identity `size = (size `div` align) * align + remainder` plus congruence lemmas, i.e. the same `div_mod_lemma` infrastructure civic-connect's `alignUpDivides` defers."
Why this is worth filing
- These are provable (standard Nat-mod algebra), unlike the model-layer Parameters tracked under standards#133 (which are abstract physics/quantum/POSIX assumptions).
- They are concentrated in one ABI module + replicated across the estate per the comment trail (civic-connect, presumably others).
- A div/mod lemma library — once written — would discharge both at once, plus civic-connect's three deferrals, plus any future ABI alignment work.
Suggested labels
`audit` / `technical-debt` / `idris2` / `abi` — leave priority/timing to owner.
Audit scope context
Trust-escape sweep audit: 2026-05-20 evening, by Claude session bee4abf8-11ea-4236-bada-c4173ba54b3b. Other absolute-zero trust-escapes (52 Lean axioms + 114 Coq axioms/parameters) are all owner-authorised under standards#133.
Activity
hyperpolymath commentedon May 24, 2026
Worked through this — pushed
claude/upbeat-mendel-lBO9G(commit aac48b7). One important audit finding before the mechanical part:Finding: the two postulates are not symmetric
alignmentMatchesPlatformWordis unsound, not merely unprovenHasAlignment t nis defined with a single information-free constructor:so the postulate's
HasAlignment t n -> So (nmod(ptrSize pdiv8) == 0)quantifies over annit has no evidence about. Concrete counterexample from the same file:Feed that to the postulate and you derive
So (1mod8 == 0)≡So False. The unsoundness was hidden because the only consumer (programStateAlignmentValid) instantiatednat 8 — where the claim happens to hold on every supported platform.This is not in the same category as civic-connect's
alignUpDivides(a genuine Nat-mod lemma). It's a load-bearing axiom that should never have shipped, and "moving the obligation to the producer" doesn't rescue it — the producer ofAlignProofis anyone, including the lib itself for n=1.alignedSizeCorrectis a genuine deferred Nat lemma, but currently has zero consumers in-treeIt's a forward-looking placeholder for the cross-estate div/mod work the issue describes. Worth keeping the signature, but it doesn't need to sit in
Layout.idr.Fix applied
alignmentMatchesPlatformWord(unsound, see above).programStateAlignmentValiddirectly by Platform case-split — every case reduces toSo TruesoOhdischarges it. No axiom required.verifyAlignment— orphan helper whose only purpose was calling the postulate.alignedSize+alignedSizeCorrectinto a new shared moduleAbsoluteZero.ABI.Proofs.DivMod, structured as the estate-wide trusted div/mod surface:alignUpDivides,mkFieldsAligned,offsetInBoundsPrfcan migrate onto the same module rather than re-postulating per-repo.divModIdentity,multModZero,addModDistrib) are stated explicitly so the proof reduction path is documented in the trusted base itself.Layout.idrre-exportsalignedSizeto preserve the public API.META.scmmatching the project's audit-trail pattern (ADR-007/ADR-008).Net effect on the trusted base
src/abi/alignmentMatchesPlatformWord)alignedSizeCorrect, in Layout)Proofs/DivMod.idr, but each individually trackable and shared with civic-connect)src/abi/Layout.idr(mixed with concrete layout decls)src/abi/Proofs/DivMod.idrThe increase from 1→4 trusted lemmas is intentional:
alignedSizeCorrectwas previously a single postulate that hid three sub-obligations. Naming them surfaces the actual reduction path and lets civic-connect / other repos depend on the named lemmas rather than the composite.Upstream coordination
The
Proofs/DivMod.idrmodule documents (in its header +alignedSizeCorrectcomment) that civic-connect's three deferrals should migrate to import from here rather than restating in each repo. That's a separate PR over there — happy to follow up if you want it raised.Caveat
No Idris2 compiler is present in this environment / not wired into CI (
Justfilehas nobuild-idris2target), so the changes are validated by inspection only. The pattern (Oh : So Trueafter concrete Platform case-split, qualified re-export viaDivMod.alignedSize) is standard and should typecheck, but worth a localidris2 --checkbefore merge. Adding an Idris2 target to theJustfilewould be a sensible follow-up so this whole module stops being a CI blind spot.Branch:
claude/upbeat-mendel-lBO9G— no PR opened (per instructions, awaiting your call).Generated by Claude Code
proof(idris2/abi): delete unsound alignmentMatchesPlatformWord, isola… (
hyperpolymath commentedon May 25, 2026
Followup with idris2 0.8.0 now bootstrapped locally (Chez Scheme + libgmp from apt, then
make bootstrap && make installto~/.idris2). Two findings beyond the original audit:Finding 1:
postulatedoesn't parse in Idris2 0.8.0The
postulatekeyword has been removed; it now only survives as an IDE-protocol decoration tag (/tmp/Idris2/src/Protocol/IDE/Decoration.idr). So the originalLayout.idrpostulate syntax was never valid in the current compiler. The whole Idris2 surface insrc/abi/had been silently non-buildable — nobuild-idris2target inJustfileto surface it.Canonical idiom for an axiom in Idris2 0.8.0:
Same semantic content as
postulate, but each axiom is now grep-able as abelieve_meoccurrence in the trusted base.Finding 2:
programStateAlignmentValiddoesn't reduce viaOheven with concrete PlatformThe earlier comment claimed the discharge would be
Oh : So Trueafter Platform case-split. With the actual compiler in hand: it doesn't. Idris2 0.8.0 refuses to reduce throughdivNat's non-covering case (divNat _ Zhas no clause) at type-level, even when both args are concrete literals after substitution. Minimal repro:So the new
programStateAlignmentValidis now also abelieve_me ()— but explicitly distinguished from the deleted unsound postulate:Proofs.DivModexports the explicitptrSize p → concrete valuerewrite equations to drive the proof.Other pre-existing breakage in src/abi/Types.idr (out of scope for #27)
Surfacing for a separate audit issue:
import Decidable.Equalityis missing (DecEq instances fail).thisPlatformuses%runElabwithout%language ElabReflection.createStateHandle ptr = Just (MkStateHandle ptr)and the program-handle equivalent: the catch-all branch doesn't supply the constructor's autoSo (ptr /= 0)proof. Needs achoose-based case-split.decEq _ _ = No absurdlacks anUninhabited (Ctor1 = Ctor2)instance; needs explicit\Refl impossiblelambdas per constructor pair (or abelieve_meif hand-enumeration is too much).What's pushed (commit f0f9b8f, on top of aac48b7)
src/abi/Proofs/DivMod.idrrewritten to compile under Idris2 0.8.0 (believe_meaxiom pattern;align minus remainderinstead ofalign - remainder). Verified:idris2 --checkclean.src/abi/Layout.idrprogramStateAlignmentValidrouted throughbelieve_mewith the distinguishing rationale above.absolute-zero-abi.ipkgsoidris2 --build absolute-zero-abibecomes a real CI target. Would recommend wiring this intoJustfileasbuild-idris2to prevent silent breakage from happening again — that's likely the highest-leverage followup.Net effect
src/abi/alignmentMatchesPlatformWord)believe_meaxioms (issue #27 surface)postulatesyntax errors; whole module non-buildable)Proofs/DivMod.idr+ 1 inLayout.idr, each individually named/audit-trackableProofs/DivMod.idrstandalone;Layout.idrblocked only by pre-existingTypes.idrerrorsBranch
claude/upbeat-mendel-lBO9G— still no PR opened per instructions.Generated by Claude Code
proof(idris2/abi): port to Idris2 0.8.0 syntax; add ipkg for verifiab…
docs: Phase 1 per-axiom triage of 72 Coq Axioms (#58)
refactor(proofs/coq): consolidate trusted-base dups (Follow-ups 1+2+3) (
hyperpolymath commentedon May 30, 2026
Status (2026-05-31): still OPEN — no work landed this session
Tracked under the new
tech-debtlabel.The two postulates in
src/abi/Layout.idrhave since morphed into 5believe_mes insrc/abi/Proofs/DivMod.idr:alignmentMatchesPlatformWord— DELETED (was unsound:AlignProofcarried no evidence aboutn); replaced with the per-instanceprogramStateAlignmentValidusingbelieve_me.alignedSizeCorrect— moved toProofs/DivMod.idr:86-90; stillbelieve_me (). Joined bydivModIdentity,multModZero,addModDistrib— allbelieve_me.The bodies are computationally true (
(size + align - r) mod align == 0) but per[[reference_idris2_0_8_0_reduction_map]]Idris2 0.8.0'sdivNatdoesn't reduce through its non-covering case at type-level, soReflwon't close them. Discharge requires inductive proofs on Nat-mod algebra — multi-day work, gated on either an Idris2 reduction-strategy fix or hand-rollingdiv_mod_lemmainfrastructure (same gap civic-connect'salignUpDividesdefers).hyperpolymath commentedon Sep 19, 2026
Re-measured today (2026-09-19) — the concern moved, it did not go away. Keeping it open with the current facts.
The file moved:
src/abi/Layout.idrno longer exists; the module is nowsrc/abi/AbsoluteZero/ABI/Layout.idr(303 lines).The two postulates are gone — as postulates. Repo-wide there are now 0
postulatedeclarations. Consistent with the 2026-05-25 finding recorded here:postulatedoes not parse in Idris2 0.8.0 (removed; survives only as an IDE decoration tag).What replaced them:
src/abi/AbsoluteZero/ABI/Proofs/DivMod.idrcarries 7believe_me ()axioms, and its own header documents the pattern as "eachbelieve_me-based axiom below is an individually-audit-trackable" and "so every axiom is grep-able as abelieve_meoccurrence". The obligations named in this issue survive there:So the acceptance criteria should be restated, because the original ones cannot be met as written: the work is no longer "remove two postulates" (done — they cannot exist in current Idris2) but "discharge the seven
believe_meaxioms inProofs/DivMod.idr", of whichalignedSizeCorrectand the mod-arithmetic lemmas this issue is about are still believed rather than proved. Flagging for the owner rather than silently closing: the trust-escape this issue was filed to remove is still present, in a new form.