Skip to content

ABI Layer 3: type-lowering injectivity + composition (two deeper codegen theorems)#37

Merged
hyperpolymath merged 3 commits into
mainfrom
claude/new-session-znxgm7
Jun 28, 2026
Merged

ABI Layer 3: type-lowering injectivity + composition (two deeper codegen theorems)#37
hyperpolymath merged 3 commits into
mainfrom
claude/new-session-znxgm7

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Layer 3 (second, deeper invariant): two deeper codegen theorems over the Layer-2 model — type-lowering injectivity (distinct Nim type lists lower to distinct C type lists) and composition/arity-preservation under extension. Distinct from and deeper than the Layer-2 signature-preservation theorem.

New module Nimiser.ABI.Invariants (imports the Layer-2 Semantics model). Positive + non-vacuity controls.

Testing

Idris2 0.7.0 --build → exit 0, zero warnings. Adversarial rejection confirmed. build/ removed. No believe_me/postulate/sorry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx


Generated by Claude Code

claude and others added 3 commits June 27, 2026 19:44
Add Nimiser.ABI.Semantics, a machine-checked semantic proof that the
Nim->C code generator preserves source signatures: same name, same
arity, and every argument/return type lowered by the canonical injective
nimToC mapping. An arity or type mismatch is unrepresentable as a
SigPreserved witness.

Contents:
- Faithful model: NimT / CT type universes, NimSig / CSig signatures,
  total nimToC lowering, genBinding code generator.
- Headline property SigPreserved with no constructor for any mismatch.
- genBindingPreserves: the generator ALWAYS preserves (soundness).
- nimToCInjective: the lowering is injective (non-vacuity engine).
- decSigPreserved: sound + complete Dec decision procedure.
- certifyBinding + certifyBindingSound tied to the project Result type;
  generatedAlwaysCertifies corollary.
- Positive control samplePreserved (explicit witness) and three
  negative controls (wrong return type, wrong arity, wrong arg type),
  all machine-checked.

Build: idris2 --build nimiser-abi.ipkg exits 0, zero warnings.
Adversarial false proof (claiming a type-mismatched binding is
preserved) is rejected by the type-checker, confirming non-vacuity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Adds Nimiser.ABI.Invariants over the existing Semantics codegen model
(NimT/CT/nimToC/NimSig/CSig/genBinding/ArgsLower), proving two facts
deeper than and distinct from the Layer-2 signature-preservation theorem:

1. Composition/distributivity: lowering is a homomorphism over argument-
   list concatenation (lowerAppendDistrib), lifted relationally
   (argsLowerAppend) and to signature extension (genBindingExtendComposes,
   extendedArgsLower) — codegen of a grown proc is the grown codegen.
2. Whole-signature injectivity: genBindingInjective shows distinct Nim
   signatures lower to distinct C bindings (no symbol/ABI aliasing),
   strictly stronger than the Layer-2 per-type nimToCInjective lemma.

Includes a sound+complete DecEq NimSig, a positive control (composed
ArgsLower witness on concrete data) and negative/non-vacuity controls
(distinctSigsDistinctBindings, extensionChangesBinding, decEqDistinctIsNo).
Builds clean (exit 0, zero warnings); adversarial false-equality proof via
genBindingInjective is rejected. No believe_me/postulate/assert_total/etc.

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 28, 2026 05:41
@hyperpolymath hyperpolymath merged commit d6ec80c into main Jun 28, 2026
22 of 25 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