ABI Layer 4: prove the FFI result-code seam is injective + faithful#35
Merged
Conversation
Raises the Phronesiser Idris2 ABI to Layer 2 with a flagship, machine-checked
semantic proof of the repo's headline property ("provably safe ethical
constraints for AI agents").
Model: a deontic policy partitions agent actions into Allow/Deny. The
`ActionPermitted` proposition has NO constructor admitting a `Deny` verdict, so
a forbidden action is structurally uncertifiable.
Proven:
- decActionPermitted: sound + complete `Dec (ActionPermitted a)`.
- certifyPermittedSound: certifier soundness (Ok => ActionPermitted).
- safeInformPermitted: positive control (inhabited permission witness).
- forbiddenNeverPermitted: negative control / core safety theorem
`Not (ActionPermitted forbiddenDeploy)`.
- forbiddenNeverCertifiedOk: corollary that the forbidden action is never Ok.
Non-vacuity confirmed: a deliberately false witness
`PermitAllow Refl : ActionPermitted forbiddenDeploy` is rejected by idris2
(Allow vs Deny mismatch). Build is clean (exit 0, zero warnings).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
New module Phronesiser.ABI.Invariants, built over the existing Layer-2
Semantics model (Action / Verdict / verdictOf — nothing redefined). It
proves two properties strictly deeper than the Layer-2 single-action
safety theorem, both quantified over all actions and over policies:
1. Monotone safety (downward-closure of permission): if policy p2
tightens p1, every action p1 forbids stays forbidden under p2 —
tightening never re-permits a previously-forbidden action; the
permitted set only shrinks. Tightening is a proven preorder
(reflexive + transitive).
2. Conjunction composition: an action permitted under andPolicy p1 p2
is permitted under each conjunct (iff via bothPermitsAnd), and the
conjunction provably tightens each conjunct.
Includes a sound+complete Dec (Permits p a), sample policies over the
shared model, positive controls (witnesses + a live application of the
monotone-safety theorem) and negative/non-vacuity controls in Not(...)
form. %default total; no believe_me / postulate / assert_total / sorry /
asserted equalities. Builds with zero warnings; an adversarial false
proof (tightened policy permits the forbidden action) is rejected by the
type checker.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Prove the FFI result-code encoding is SOUND, not just structurally agreed (the abi-ffi-gate.py check): distinct ABI outcomes never collide on the wire, and the C integer faithfully round-trips back. New module Phronesiser.ABI.FfiSeam (imports Phronesiser.ABI.Types): - intToResult decoder + resultRoundTrip (left inverse of resultToInt) - resultToIntInjective derived from the round-trip via justInj + cong - same round-trip + injectivity for modalityToInt (DeonticModality) and severityToInt (HarmSeverity); no ProofStatus/statusToInt exists - positive controls (concrete decode = Refl) and non-vacuity controls (distinct codes have distinct ints, machine-checked) Genuine proof only: no believe_me/idris_crash/assert_total/postulate. %default total, SPDX header, zero warnings. abi package builds clean; an adversarial false claim (resultToInt Ok = resultToInt Error) is rejected by the type checker. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
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 4 (seal the ABI↔FFI seam): proves the FFI result-code encoding (
resultToInt) is a sound, lossless wire encoding — decoderintToResultwithresultRoundTrip, from whichresultToIntInjectiveis derived. Distinct ABI outcomes never collide on the C wire. Complements the structuralabi-ffi-gate.py.New module
*.ABI.FfiSeam(importsTypes). 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