ABI Layer 2: prove generated max is correct-by-construction (flagship Idris2 proof)#39
Merged
Merged
Conversation
…ition
Add Dafniser.ABI.Semantics raising the Idris2 ABI to Layer 2 with a genuine,
machine-checked semantic proof of the repo's headline ("correct-by-construction
code generation").
Model: a Dafny spec as the postcondition MaxPost a b r — a real proposition
inhabited only when r dominates both inputs and equals one of them. The
generated body genMax returns its result paired with a MaxPost proof
(correct-by-construction). genMaxCorrect derives all three ensures conjuncts
(result>=a, result>=b, result==a||result==b) for all inputs; noUndershootLeft
refutes the bad case. A sound certifier (certifyMax/certifyMaxSound) emits the
ABI's VerificationResult. Positive control maxPositive : MaxPost 7 3 7 and
negative control maxNegative : Not (MaxPost 7 3 2) are machine-checked; an
adversarial false proof (MaxPost 7 3 2) is rejected by idris2, confirming
non-vacuity.
Builds clean (idris2 0.7.0, exit 0, zero warnings).
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
Raises dafniser's Idris2 ABI to Layer 2 with its first flagship semantic proof. Dafniser's headline is "generate correct-by-construction code"; this models a Dafny spec (precondition + postcondition + generated body) for a representative generated function — integer
max— and proves in the type system that the generated body meets its postcondition (result ≥ a ∧ result ≥ b ∧ (result = a ∨ result = b)) for all inputs. Incorrect results are unprovable.Mirrors the estate's flagship-proof pattern (InjectionFree / Partition / Octad): faithful model, a proposition with no inhabitant for the bad case, a sound+complete
Dec, a certifier proven sound, and positive + negative controls.Changes
src/interface/abi/Dafniser/ABI/Semantics.idr—MaxPostpostcondition (LTE-backed),genMaxreturning result-with-proof,genMaxCorrect(all three conjuncts),decMaxPost,certifyMaxSound, a no-undershoot soundness lemma, positive control (MaxPost 7 3 7) and negative control (Not (MaxPost 7 3 2)).dafniser-abi.ipkg.RSR Quality Checklist
Required
idris2 --buildemits zero warningsbelieve_me/postulate/sorry/assert_total) — proof is genuineAs Applicable
Testing
Verified with Idris2 0.7.0:
cd src/interface/abi && idris2 --build dafniser-abi.ipkg→ exit 0, zero warnings (all modules). Adversarial check: a deliberately-false proof was rejected by the type checker (non-vacuity).build/removed (not committed).🤖 Generated with Claude Code
https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Generated by Claude Code