Ixon v3: usage, ownership, and relative locality in the Ix frontend - #636
Open
johnchandlerburnham wants to merge 4 commits into
Open
johnchandlerburnham wants to merge 4 commits into
johnchandlerburnham wants to merge 4 commits into
Conversation
johnchandlerburnham
enabled auto-merge
September 16, 2026 16:50
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
The Ix frontend needs to preserve resource contracts through Lean elaboration,
compilation, content addressing, and downstream validation. This PR implements
Ixon v3 with independent usage, ownership, and relative-locality annotations,
transports them through the Lean and Rust compilers, and adds native resource
validation for the supported annotated fragment.
Ordinary Lean code keeps its existing typing and computational interpretation.
Its binders receive unrestricted usage, shared ownership, and unrestricted
locality. IxVM continues to prove ordinary Lean typing with contracts erased.
Explicit resource annotations are checked by the native admission layer; IxVM
resource proofs and backend ownership/locality optimizations remain future work.
The serialized format changes. V3 changes canonical bytes, content addresses,
primitive pins, and claim/proof envelopes. Existing artifacts require regeneration.
Ordinary Lean defaults and the IxVM boundary
many, shared ownership, unrestricted localitymany, shared ownership, unrestricted locality; preserves the dependency flagBoth compilers use these defaults for unannotated source, including implicit and
instance binders. Lean's native
@&metadata retains its existing role and grantsno additional resource permissions. Ordinary components keep the existing
compilation path without new resource obligations.
IxVM preserves the contract fields when decoding, serializing, hashing, and
revealing Ixon. Conversion into its typing representation erases those fields;
a shared-borrow let has the ordinary let's erased interpretation. Its
Checkand
CheckEnvproofs therefore retain their ordinary-typing meaning.Check/CheckEnverased-lean-v1Reveal/ContainsResourceFormat and validator identities are committed in the envelopes. A native
resource claim additionally binds the complete constant-set root and the
canonical resource profile. Consumers that rely on ownership or locality must
require resource admission separately from an IxVM typing proof.
Annotation model and source syntax
The three axes are independent:
0,1,&, unmarked!, unmarked~, unmarked~!combines local scope and unique ownership. For example:The second definition consumes its local input once and returns it under a local
result contract. Input and result contracts belong to individual arrows, including
intermediate arrows in curried functions.
Annotations are supported in definition headers, lambda and forall binders,
dependent arrows, arrow results, and lets. An explicit
let borrowcreates ashared view whose loan lasts for the let body. Its initializer identifies an
owner binding or supported projection path.
Locality is relative to the caller and lexical scopes. Contracts carry no named
lifetimes, region parameter lists, or region arguments.
App,Ref, andRecurkeep their ordinary roles. See the
source syntax and API specification.
Source transport and native validation
occurrences. Imports preserve registrations, including opaque bodies.
Stale snapshots, missing registrations, and conflicting annotations reject.
distinguish otherwise equal terms with different contracts in semantic
equality, ordering, caches, sharing, bytes, and addresses.
presentation metadata.
annotated output. Invalid or unsupported annotated inputs produce no artifact,
including with partial compilation enabled.
alias cannot discard an imported resource obligation.
The Lean and Rust resource checkers enforce quantitative use, unique moves,
permanent sharing, active shared loans, reborrowing, local escape, and closure
captures. They account for calls, partial applications, recursive interfaces,
and profile-admitted alternative-path behavior. Analysis is bounded and rejects
unsupported cases or exhausted limits.
Ix.Resource.validateandix_kernel::resource::validateconsume the canonicaladdressed environment and a profile. Profiles bind external assumptions,
shareable representations, selection primitives, literal identities, and
analysis limits. Optional metadata or cached materializations confer no
permissions. Native
makeClaimandcheckClaimbind and validate the completesubject and profile.
Supported fragment and deferred infrastructure
explicitly admitted external interfaces.
transformations reject before emission.
unrestricted field usage; availability is tracked for the whole owner.
normalization. Unsupported higher-order or representation assumptions reject.
and broader generated resource-program testing remain follow-up work.
and backend allocation/reuse strategies remain follow-up work.
consumer handoff
supplies complete accepted/rejected environments, a profile, a resource claim,
and exact identities for downstream integration.
The detailed admitted fragment is documented in
resource checking.
Format and consumer migration
six bits. Lets carry a binder byte and dependency/shared-borrow flags.
claims, catalogs, and decompilation use the same v3 fields.
counts, noncanonical telescopes, truncation, and whole-object trailing bytes.
IxVM uses strict incremental reads for counted sequences.
The generated Rust kernel and recursive consumers match their current Aiur
sources. The historical Mathlib proof fixture retains its pinned identity and
rejects at the incompatible envelope header.
See the v3 specification
and wire format.
Verification
The compiler audit covers 143 roots. The ordinary typechecker audits cover
2,034 completed roots, one conditional root, and seven statement roots, with
existing assumptions recorded in their manifests. The resource audit covers
15 roots tied to executable quantitative, scope, ownership, loan-ending, and
join invariants. Local sorry-frontier audits pass; no new axioms or local
sorryplaceholders were added.The resource theorems establish the stated checks and transition invariants.
A theorem connecting the entire resource checker to machine operational
semantics remains future work.
Executed checks
lake lint -- --wfailix codegen --checkpasses for all three generated consumersThe new counted-decoding regressions cover all 11 affected paths with complete
single-element inputs and truncated inputs declaring two or
UInt64.maxelements. Rejection is checked during decoding, before reserialization.
Specialized CUDA, SP1, and Zisk toolchain jobs were not run locally. Commands,
counts, trust boundaries, and migration evidence are recorded in the
verification record.
FFT cost
The final deterministic estimates increase by 0.008%–1.278% across the
83 existing kernel cases compared with the pre-v3 baseline. Exact equality
assertions are retained.
Nat.add_commThese are estimates of FFT work. They are derived from the actual circuit
shapes and execution query counts.
Review map
Ix/IxonContract.lean,Ix/Ixon.lean,crates/ixon/src/contract.rs, codecs and sharingIx/Compile/SourceContract/,Ix/SemanticContract.lean,crates/compile/src/semantic_contract.rsIx/CompileDriver.lean,Ix/CompileM.lean,crates/compile/src/compile/, FFI adaptersIx/Resource/,crates/ixon/src/resource/,crates/ixon/src/resource.rs,crates/kernel/src/resource.rsIx/IxVM/Ixon*.lean,Ix/IxVM/Convert.lean,Ix/IxVM/Kernel/Claim.lean, claim/catalog/aggregate consumersIx/Compile/Verify/, affectedIx/Tc/Verify/modules,Ix/Resource/Audit.leanTests/Ix/,Tests/Fixtures/ixon-v3/, CLI tests, v3 test executables,docs/Most of the line churn is regenerated Rust in
crates/ixvm-codegen/src/.Its consistency is checked by regeneration and execution/query-count parity.