Skip to content

ABI Layer 2: prove bounded array access (Fin-indexed, total) — flagship Idris2 proof#42

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/new-session-znxgm7
Jun 27, 2026
Merged

ABI Layer 2: prove bounded array access (Fin-indexed, total) — flagship Idris2 proof#42
hyperpolymath merged 1 commit into
mainfrom
claude/new-session-znxgm7

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Raises idrisiser's Idris2 ABI to Layer 2 with its first flagship semantic proof. Idrisiser's headline is generating proven-correct wrappers with dependent types; this proves bounded array access: indexing a length-n array with a Fin n is always in-bounds and total (no runtime failure), and an out-of-range index is unrepresentable.

Mirrors the estate flagship-proof pattern: Fin/InBounds model, decInBounds : Dec, certifier proven sound, positive + negative controls.

Changes

  • Adds src/interface/abi/Idrisiser/ABI/Semantics.idrSafeArray/safeIndex (total Fin index), InBounds, decInBounds : Dec, certifyBoundedSound, and negative controls idx5OutOfBounds : Not (InBounds 5 3), noIndexIntoEmpty : Not (InBounds i 0).
  • Registers the module in the ABI .ipkg.

RSR Quality Checklist

Required

  • Tests pass — ABI builds clean (see Testing)
  • Linter clean — zero warnings
  • No banned language patterns
  • No banned functions — genuine proof
  • SPDX headers present
  • No secrets

As Applicable

  • ABI/FFI changes validated — additive proof; FFI untouched

Testing

Verified with Idris2 0.7.0: idris2 --build idrisiser-abi.ipkg → exit 0, zero warnings. Adversarial check: a deliberately-false proof was rejected. build/ removed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx


Generated by Claude Code

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
@hyperpolymath hyperpolymath marked this pull request as ready for review June 27, 2026 19:46
@hyperpolymath hyperpolymath merged commit 29e9bec into main Jun 27, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants