Wheeler

WIP-0011: Integrated proofs and certificates

FieldValue
StatusDraft
OwnersWheeler language, type-system, proof, compiler, bytecode, and tooling maintainers
Created2026-07-17
Updated2026-07-28
AreaLanguage, proofs, contracts, certificates, trusted kernel
Depends onWIP-0001, WIP-0002, WIP-0005, WIP-0007
SupersedesNone
Superseded byNone

Summary

Proofs are part of the Wheeler language. Contracts attach to ordinary, reversible, coherent, unitary, and hybrid declarations. Theorem declarations use the same modules and types as executable code. Structured proof blocks carry source locations. A small deterministic kernel checks them. Tree-sitter, package metadata, bytecode, diagnostics, docs, and editor tools expose the same proof structure.

Proof text is not a comment, a free-form because string, a provider claim, or a host-language annotation. Propositions refer to Wheeler's typed IR relations: forward transition, exact inverse, logged rewind boundary, coherent permutation, unitary adjoint, and measurement or workflow transition. They do not refer to an optimizing host IR or provider circuit.

A successful theorem creates a bounded canonical certificate. The certificate binds exact declarations, semantic region identities, type and effect assumptions, and compiler profile. A consumer can verify it without rerunning a solver or trusting the compiler that found the proof.

Wheeler keeps formal claims separate from measurements. Theorems about unitarity, inverse behavior, ownership, totality, or resources are checked against formal rules. A sampled hardware claim is an experiment with target, calibration, estimator, shots, uncertainty, and confidence data. It cannot satisfy a theorem that requires exact or universal evidence.

Motivation

Reversible and quantum programs carry proof duties during normal development:

Prose alone cannot let the compiler or package system check these claims. A separate proof language would duplicate names, types, modules, source maps, effects, and quantum rules. Integrated proof syntax lets executable code and its claims evolve under one resolver and one compatibility model.

The trusted base must stay small. Elaborators, automation, SMT tools, and circuit simplifiers may search for a proof. Only the bounded kernel decides whether the canonical proof term is valid.

Goals

Non-goals

Source model

Proof syntax is part of the ordinary grammar. The exact spelling remains subject to parser implementation, but the language model has four integrated forms.

Contracts

A declaration may state preconditions, postconditions, frame conditions, effects, resource bounds, and loop invariants:

rev long increment(long value)
  requires value < Long.MAX_VALUE
  ensures result == old(value) + 1
  ensures inverse(result) == old(value)
  modifies nothing
{
  return value + 1;
}

old(expression) names the value at the declaration boundary selected by the contract. It isn't VM history access. result has the declaration's return type. modifies names owned mutable locations or nothing. Effects and quantum resource transitions are also available as typed contract terms.

A rev contract is checked in both directions. Forward preconditions become obligations for callers. The generated inverse receives the mechanically derived inverse relation plus any explicit inverse-side conditions.

Theorems

A theorem is a declaration with typed parameters, proposition result, visibility, and optional generic or finite-domain bounds:

theorem qftRoundTrip(qreg_shape shape)
  requires shape.qubits > 0
  shows adjoint(qft(shape)) >> qft(shape) == identity(shape)
{
  proof {
    ...
  }
}

The theorem body cannot perform ordinary I/O, target submission, measurement, mutable allocation outside proof arenas, clock access, randomness, or undeclared effects. It elaborates to a proof term checked by the kernel.

WIP-0028 exposes ownership, lifetime, and frame propositions without allowing proofs to bypass verifier safety. WIP-0029 generic theorems quantify over kinded parameters. WIP-0030 class laws and associated reductions name exact coherent evidence. WIP-0031 certificates bind effect rows, inverse/adjoint characteristics, and specialization-commutation claims. Safety-critical classes such as coherent basis, permutation, and unitary evidence require compiler- or kernel-admitted certificates. An ordinary instance declaration cannot notarize itself.

Proof blocks

Proof blocks contain a small structured statement set:

Every construct has a concrete syntax node and elaboration rule. The because form cannot accept a free-form explanation string.

Proof values

Proofs may be passed, returned, stored in immutable package metadata, or erased after certificate emission according to type and visibility. A proposition P has proof type Proof<P>. Runtime code cannot forge that value from bytes. Certificate decoding invokes the kernel.

Proof irrelevance applies to semantic equality unless a declaration explicitly processes certificate metadata. Two valid proofs of the same proposition don't make executable values unequal.

Proposition language

The first proposition profile includes:

Unbounded integer, rational, algebraic, complex, or real reasoning is added only with canonical term encodings and kernel rules. Floating-point values obey their executable finite semantics. A proof cannot silently reinterpret them as mathematical reals.

Effects and totality

A proof declaration is deterministic and total under declared bounds. The checker verifies termination through one of:

Proof elaboration may allocate in a bounded private arena and emit diagnostics. Those implementation effects do not enter theorem terms. Kernel checking has explicit term-node, recursion-depth, rewrite-step, memory-byte, and elapsed-policy ceilings.

An exhausted automation budget leaves the proof unresolved. It does not make the proposition false. An existing certificate is checked under kernel limits independent of the search process that found it.

Reversibility claims

The compiler generates a proof obligation for each rev declaration:

forall owned input satisfying precondition:
  inverse(forward(input)) == input
  and forward(inverse(output)) == output

The exact relation includes modified state, returned values, traps excluded by preconditions, and frame conditions. Logged or barrier effects prevent an intrinsic inverse theorem unless the proposition explicitly models retained history or effect contracts.

Generated-inverse bytecode can discharge local opcode laws compositionally. Loops, allocation, aliasing, and calls require corresponding invariants and callee certificates. Testing an inverse over sample values remains a test, not this theorem.

VM rewind has a separate transition theorem over StepRecord. It is not used to prove a language-level inverse. WIP-0041 result proofs include caller-owned slot state, source ownership, exact held values, coherent valid-subspace preservation, padding identity, and a no-history law. A valid certificate still passes when the VM commits all prior rewind history before the generated inverse runs.

Quantum claims

Quantum proof terms refer to canonical semantic region IR, not OpenQASM text, Qiskit objects, native gate schedules, or provider display circuits.

The initial exact quantum rules cover:

A theorem about ideal region unitarity survives target lowering only as an ideal semantic claim. A theorem about a physical implementation also needs a verified lowering certificate and a formal target model. Calibration samples cannot turn an ideal theorem into a physical guarantee.

Measurement changes the proposition domain. Post-measurement claims describe distributions, typed outcomes, ownership transitions, and classical continuation state. They do not assert an inverse collapse.

Experiments and empirical claims

Empirical evidence uses an integrated but distinct declaration:

experiment bellCorrelation(Target target)
  requires target supports STATIC_CIRCUIT
  estimates correlation(q[0], q[1])
  confidence 0.99
  shots 4096
{
  ...
}

An experiment result records semantic region, target descriptor, lowering policy, calibration identity when supplied, job lineage, estimator, shots, uncertainty, confidence method, and bounded diagnostics. Replay can reproduce downstream classical decisions from recorded evidence. Fresh execution creates new evidence.

An experiment may discharge a proposition explicitly typed as empirical, such as a confidence interval under named assumptions. It cannot inhabit Proof<Unitary<R>>, exact equality, or a universal theorem.

Contracts on hybrid code

Hybrid declarations may state event and continuation properties:

These theorems range over the deterministic event reducer and abstract target lifecycle. Provider cancellation success is not assumed unless the target model supplies that premise.

Transaction contracts identify reversible, prepared-external, observed, and committed phases. A post-observation abort theorem may prove classical checkpoint restoration and branch discard. It cannot claim physical quantum-state restoration.

Proof elaboration and kernel

Proof processing has two trust layers.

The elaborator resolves names, infers omitted arguments, expands notation, runs bounded tactics, invokes optional external search tools, and emits a fully explicit canonical proof term. Elaborator defects may reject valid programs or produce bad terms, but cannot make a bad term pass the kernel.

The kernel checks:

The kernel does not search. It is deterministic, bounded, and implemented in Wheeler under the self-hosting plan. A minimal independent checker remains part of certificate conformance and diverse bootstrap work.

Axioms and assumptions

Wheeler has no implicit user-defined axiom syntax. Trusted axioms are versioned kernel primitives or packages explicitly marked as assumption providers by host policy. A theorem certificate records the transitive set of axioms and assumptions it uses.

Package policy may reject certificates using unsafe assumptions, classical choice, unverified arithmetic oracles, external solver attestations, target noise models, or experimental premises.

assume is permitted only inside an experiment, a theorem parameter, or a declaration explicitly producing a conditional theorem. It creates a visible premise. It never closes a goal silently.

Modules and APIs

Theorems, propositions, proof-producing functions, and contracts use normal package/module visibility. Public declaration identity includes observable contracts and theorem signatures. Strengthening a postcondition may be compatible. Strengthening a required precondition is not silently compatible.

Imports can select executable and proof namespaces without duplicating declaration identity. Cyclic theorem dependencies are rejected unless accepted mutual induction rules apply.

Documentation renders contracts next to declarations, theorem statements with assumption sets, and certificate status. Source navigation moves between an executable declaration, generated obligations, proofs, and uses.

Bytecode and certificates

.wbc gains versioned proof metadata sections only through an accepted bytecode extension. Canonical records include:

Executable loading may omit proof payloads when policy does not require them. It cannot claim that a proof was checked without a verified certificate identity. Optimizers using proof-directed transformations must retain the exact input theorem and transformation certificate identities.

Unknown required proof records fail closed. Certificate compression is bounded and does not alter canonical uncompressed identity.

Diagnostics and tooling

Proof diagnostics report source goal, local hypotheses, expected proposition, actual proof type, failed kernel rule, and bounded context. They do not dump unbounded terms or solver logs.

Tree-sitter supplies nodes and queries for contracts, theorem headers, proposition expressions, proof blocks, proof statements, and experiment declarations. Editors can fold proof bodies, highlight goals and declarations, navigate theorem references, and show checked, stale, missing, or assumption-bearing status.

Formatting is deterministic and preserves structured proof layout. Renaming uses semantic identities and updates proof references with ordinary code.

Concurrency and determinism

Independent proof elaboration may run concurrently, but certificate bytes and diagnostics are reduced in canonical declaration order. Solver response order, hash iteration, task scheduling, wall-clock timing, and cache location cannot affect theorem identity.

Proof caches key exact source declaration, imported API, semantic IR, elaborator profile, kernel profile, and options. Every cache hit is kernel-checked or covered by a verified content identity under package policy.

Safety and limits

Source and certificate limits cover proposition depth, quantified-domain size, proof nodes, local hypotheses, rewrite steps, normalization fuel, and recursion depth. They also bound arithmetic width, matrix size, qubits, resource-polynomial size, diagnostics, attachment bytes, and total kernel memory.

Decoders reject cycles where acyclic terms are required, invalid de Bruijn or symbol references, duplicate records, noncanonical terms, forged identities, unknown rules, profile mismatch, excessive expansion, and trailing payload.

Kernel failure cannot produce an executable artifact marked as proved. Policy decides whether an unproved optional theorem blocks ordinary compilation. Required contracts and transformation certificates always block their dependent operation.

I/O receipts and conditional proofs

WIP-0032 receipt-chain, range-disjointness, graph-ordering, idempotency-key, operation-lifecycle, and backend-profile obligations may be WIP-0011 proof subjects. The kernel can prove that accepted evidence satisfies a declared rule. It cannot prove that an unmodeled device persisted bytes, that a network peer acted, or that a replica survived an unmodeled failure.

Durability theorems therefore bind the exact protected subject, failure model, operation, backend/profile evidence, assumptions, and receipt chain. A proof cannot cast WriteCompleted into DataStable or empirical provider output into theorem authority.

Application fixtures

The integrated proof profile is driven by executable applications:

Each fixture first lands as an executable law if necessary, then gains a formal theorem without changing the executable semantics it claims.

Migration and deletion

  1. Specify proposition AST, proof term, kernel rules, identities, and limits independently of surface tactics.
  2. Add contracts and theorem headers to the parser, resolver, type checker, Tree-sitter grammar, and documentation renderer.
  3. Implement a small kernel for equality, finite logic, bit vectors, records, variants, and bounded induction.
  4. Generate and check inverse obligations for straight-line rev functions.
  5. Add semantic quantum gate, composition, adjoint, global-phase, and ancilla rules.
  6. Add structured proof blocks and deterministic elaboration.
  7. Add canonical .wbc certificate sections and independent decoding tests.
  8. Upgrade QFT, circuit normalization, resource, and package fixtures.
  9. Implement the kernel and elaborator in Wheeler and include them in self-host and package recovery checks.
  10. Delete any ad hoc proof parser, free-form justification field, unchecked optimization assertion, or duplicate external claim schema.

Progress

Testing and acceptance

Alternatives

Keep proofs in comments or documentation

Rejected. They cannot participate in type checking, optimization, package APIs, independent verification, or stale-identity detection.

Use free-form tactic scripts as certificates

Rejected. Search scripts are not stable evidence and require trusting tactic implementations. Wheeler stores explicit kernel-checkable terms.

Delegate theorem validity to an SMT solver

Rejected as the trust boundary. Solvers may search or emit certificates, but deterministic kernel checking establishes validity.

Use a separate proof language

Rejected. It duplicates Wheeler names, modules, types, effects, ownership, regions, source maps, packages, and tooling, and permits the two semantic models to drift.

Treat simulation as proof

Rejected. Simulation can establish exact finite cases under its model or provide empirical evidence. It does not imply a universal theorem or physical hardware guarantee.

Open questions

Integration with reversible concurrency

Structured-task proof subjects

Task concurrency adds TaskTreeWellFormed, ScheduleEnabled, SequentiallyConsistent, ReadFrom, EventIndependent, MutualExclusion, DeadlockFreeWithinBound, TaskScopeInverse, and TaskWitnessClean subjects.

A future causal-rollback certificate checks accepted independence plus causal safety and liveness. Recording edges alone proves neither.

Bakery claims separate mutual exclusion, termination under one schedule, progress under named fairness, and universal bounded safety. Sampled schedules do not prove the stronger forms.

References