ABI Layer 3: McCarthy store/select array-update laws (write-then-read, read-other)#43
Merged
Merged
Conversation
Raise the Idrisiser Idris2 ABI to Layer 2 with a genuine, machine-checked semantic proof of the repo's headline domain property (proven-correct wrappers via dependent types). Module Idrisiser.ABI.Semantics models a length-indexed SafeArray (Vect n a) with a total accessor safeIndex : SafeArray n a -> Fin n -> a, and proves: - InBounds i n is inhabited exactly when i < n (carries an LT i n proof); the out-of-range case has no constructor. - Uninhabited (InBounds i 0): no index exists into an empty array, so out-of-range access is unrepresentable. - decInBounds : sound + complete Dec (InBounds i n), backed by isLT. - finToNatNatToFinLT / safeIndexUsesExactSlot: the proven index round-trips exactly to the requested raw position (no off-by-one, no runtime failure). - certifyBounded + certifyBoundedSound: certifier into the ABI Totality witness, returning Total only when genuinely in bounds. - Positive control (idx2InBounds reads "gamma") and negative controls (Not (InBounds 5 3), Not (InBounds i 0)), all machine-checked. No believe_me / postulate / assert; the headline property is non-vacuous (a deliberately-false InBounds 5 3 witness is rejected by idris2 0.7.0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Add a second, deeper machine-checked theorem over the SAME Layer-2 model
(SafeArray/Vect/Fin), raising the Idris2 ABI to Layer 3.
New module Idrisiser.ABI.Invariants proves McCarthy's store/select array
axioms — distinct from Layer-2 in-bounds totality:
- safeReadAfterWriteSame: read i after write v@i = v (write-then-read)
- safeReadAfterWriteOther: write@j leaves slot i/=j unchanged (read-other)
- predictReadOverWrite + safeReadOverWriteCorrect: sound decEq-driven
decision procedure with correctness proof in both branches
Vect-level lemmas (indexReplaceAtSame, indexReplaceAtOther) proved by hand
via induction, not delegated to a library lemma. Defines safeWrite as the
formal dual of safeIndex. Positive controls (write-then-read, other-slot
preserved, prediction agrees) plus a negative/non-vacuity control
(writeReallyChangedSlot: the write genuinely changed the slot). %default
total, no believe_me/postulate/assert. Clean build, zero warnings;
adversarial false-equality check rejected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Layer 3 (second, deeper invariant): proves the McCarthy store/select array laws over the Layer-2 SafeArray/Vect/Fin model — write-then-read (
read i (write i v a) = v) and read-other (a write atileaves indexj≠iunchanged). Distinct from and deeper than the Layer-2 in-bounds totality property.New module
Idrisiser.ABI.Invariants(imports the Layer-2Semanticsmodel). Positive + non-vacuity controls.Testing
Idris2 0.7.0
--build→ exit 0, zero warnings. Adversarial rejection confirmed.build/removed. Nobelieve_me/postulate/sorry.🤖 Generated with Claude Code
https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Generated by Claude Code