Single coherent story: PROOF-NARRATIVE.md. Assumption registry: ASSUMPTIONS.md. This file is the per-obligation checklist.
Tier: T1 — Critical. Tangle owns the type system. KRL and QuandleDB rest on Tangle’s metatheory. The core (including let-binding) has been mechanised; the remaining gap is implementation-refinement and WASM/dialect proofs.
-
LOC: ~18,000 (OCaml + Rust + Tangle DSL + Lean proofs)
-
Languages: OCaml (compiler), Rust (tangle-wasm), Lean 4 (proofs), Tangle DSL (lib/stdlib + examples)
-
Existing mechanised proofs:
proofs/Tangle.lean(~1604 LoC, 22+ results, allQed) -
Dangerous patterns: None detected
Tracked in PROOF-NARRATIVE.md §2
and proofs/Tangle.lean:
| ID | Result | LoC |
|---|---|---|
T-Progress |
Every well-typed closed term is a value or steps |
~80 |
T-Preservation |
Stepping preserves types |
~180 |
T-Determinism |
Step relation is deterministic |
~250 |
T-TypeSafety |
Corollary: well-typed terms never get stuck |
~3 |
T-Weakening |
Context insertion preserves typing (TG-1) |
~70 |
T-SubstPreserves |
Substitution preserves typing (TG-1) |
~100 |
|
Algorithmic type inference ≡ HasType (TG-2) |
~120 |
|
Type uniqueness + Decidable instance (TG-2) |
~15 |
+ canonical lemmas |
canonical-num/str/word/echo/prod, value-no-step, width-append/shift, echo capstones, echoAdd/echoEq capstones |
~250 |
Coverage: the full core fragment of Tangle — Num, Str,
Bool, Identity, BraidLit, Compose, Tensor,
Pipeline, Close, Add, Eq, Var, Let, plus the
echo-types fragment (EchoClose, Lower, Residue,
EchoAdd, EchoEq) and the product type (Pair, Fst,
Snd). 26 typing rules, 55 step rules. All four theorems cover the
full fragment including let-binding (TG-1) and the echo/product fragment
(TG-10). Type checking is decidable (TG-2).
Cross-referenced to PROOF-NARRATIVE.md §3.
| # | Statement | Category | Prover | Priority | Effort | Status |
|---|---|---|---|---|---|---|
TG-1 |
Extend Progress/Preservation/Determinism/TypeSafety to
|
TP |
Lean 4 |
P1 |
— |
LANDED ( |
TG-2 |
Type checking is decidable: define |
ALG |
Lean 4 |
P1 |
— |
LANDED
( |
TG-3 |
OCaml |
TP |
Lean 4 + translation validation |
P1 |
— |
LANDED
(translation-validation level —
|
TG-4 |
Pretty-print/parse round-trip on closed values |
INV |
OCaml property test (cheap) |
P2 |
4h |
LANDED (PR #46 — OCaml property test in
|
TG-5 |
|
TP |
OCaml property test |
P2 |
— |
LANDED
( |
TG-6 |
WASM compilation preserves semantics (source eval ≡ wasm exec) |
TP / ALG |
differential + Lean bisimulation |
P1 |
— |
RUNG LANDED
(differential): |
TG-7 |
|
ALG / DOM |
OCaml + Lean 4 |
P2 |
— |
SEMANTICS LANDED
2026-07-29 (owner ruling #50 → (a) true braid-group equivalence).
|
TG-11 |
Epistemic types: |
TP / DOM |
Lean 4 |
P1 |
- |
LANDED: |
TG-8 |
Each dialect (braid-calculus, quantum-circuit, skein-algebra, string-diagram, virtual-knot) is a conservative extension of core |
TP |
OCaml model + Lean per-dialect |
P3 |
— |
TEMPLATE LANDED
(virtual-knot): |
TG-9 |
LSP diagnostics are a subset of |
INV |
Audit + refactor |
P2 |
— |
LANDED ( |
TG-10 |
Echo-types integrated into the type system: |
TP / DOM |
Lean 4 |
P1 |
— |
LANDED ( |
For full per-obligation statements, why valuable, and the assumptions each rests on, see PROOF-NARRATIVE.md.
Concrete approach, effort, risk, and dependencies for what is left after
TG-0/1/2/3/4/5/9/10 landed. Landable rungs of TG-6, TG-7, and TG-8 also
landed (2026-06-14): TG-6 a wasmi differential test; TG-7 an
out-of-band braid_equiv checker; TG-8 a virtual-knot
conservative-extension template. What genuinely remains is
research-grade: TG-8’s surface-syntax integration + other 4 dialects
+ Lean conservativity proof; TG-6’s full source↔wasm bisimulation;
and TG-7’s Lean correctness proof. (TG-7’s semantics change is no
longer owner-gated — it was ruled and landed 2026-07-29, see #50 and
the TG-7 row above.)
-
Key lever (used): TG-2 proves Lean
infer ≡ HasType, so refinement reduced to OCamlinfer_expr≡ Leaninferon the shared core fragment. -
Delivered: (1) closure proof — the core fragment never yields
TTangleunderinfer_expr(strengthened entire-type-tree IH;closeis the sole boundary gateway, excluded); (2) machine-checked half —proofs/TG3Differential.lean, 496 obligationsinfer [] e = <infer_expr result> := by decide, generated from the OCaml checker bycompiler/test/tg3/tg3_emit.ml, kernel-verified byproofs/check-tg3-differential.sh(wired intolean-proofs.yml); (3) OCaml side — 1008dune runtestassertions (closure invariant, curated pins, de Bruijn translation, divergence behaviours). Full write-up + extra-core list + divergence catalogue:proofs/TG3-REFINEMENT.md. -
Divergences (complete): D1
close(Tangle[I,I] vs word 0)
family D1b/c/d; D2bool==bool(OCaml accepts / Lean rejects). Both pinned both sides. -
Honest boundary: translation validation over a broad corpus + a structural argument — NOT a universal Lean theorem over all OCaml runs (needs reflecting
typecheck.ml). Extra-core features excluded, not modelled. OCaml→Lean only.
-
Delivered:
compiler/test/tg5/tg5_invariants.ml(189 assertions, indune runtest). compositional has noTy; “preserves types” is realised as preserving the PD-lowering structural invariants + the echo residue-recovery property. Per-variant pins:OpenWordunit-expanded;ClosedDiagramclosed/components=[]/source unit-expanded/|crossings|=|source|=unit-count;EchoClosedresidue verbatim (exponents preserved, e.g.echoClose(s1^3)keeps[s1^3]while the diagram is the 3-crossing unit closure),expand(residue)=diagram word, and echo-diagram pdv1-identical to plainclose. Plus error-path message pins and concrete crossing-count pins. -
Honest boundary: asserts ONLY invariants the lowering guarantees — NOT arc balance, planarity, or crossing-index validity (the code makes no such claim). A Lean model of the PD IR + a mechanised preservation theorem is an optional later rung (Lean currently has no planar-diagram type).
-
✅ Non-semantic rung landed 2026-06-14:
compiler/lib/braid_equiv.ml(equiv/is_trivial) decides braid-group equivalence via Dehornoy handle reduction, out-of-band —==/Step.eqBraidsare untouched. Validated bycompiler/test/tg7/tg7_braid_equiv.ml(2220 assertions): the defining relations, 400 constructed-equivalent pairs (writhe/permutation invariants guard the generator), and invariant-distinguished negatives. Correctness is by-testing; a Lean Garside/Dehornoy proof is the research-grade rung. -
The only
eqBraidsis the LeanStepruleeq (braidLit gs₁) (braidLit gs₂) → boolLit (gs₁ == gs₂)= list equality; OCamleval.mlmatches it. -
Moving to Dehornoy handle reduction would change the observable semantics of
==on braids (terms group-equal but not list-equal would newly compare true) on BOTH the OCaml evaluator AND the LeanSteprelation, rippling into the Determinism/Preservation proofs. This is a language-design decision, not just a proof — it must not be auto-landed. -
Owner decision needed: (a) change
==semantics to braid-group equivalence, or (b) keep==as-is and add an out-of-bandbraid_equivchecker (Dehornoy/BKL normal form) that does NOT touch==. The smallest non-semantic step is (b): an OCamlbraid_equiv : gen list -> gen list -> boolwith tests, no semantic change. Lean correctness (Garside/Dehornoy) remains research-grade either way.
-
✅ Conservativity template landed 2026-06-14:
compiler/lib/dialect_vk.mlmodels the virtual-knot dialect (VBₙ ⊃ Bₙ — braids plus involutive virtual crossings) as core + a virtual layer that delegates toBraid_equiv(TG-7) on the real fragment, so conservativity holds by construction (the dialect cannot change core typing/semantics).compiler/test/tg8/tg8_conservativity.ml(2311 assertions) verifies: faithful embedding (project∘embed=id); the dialect decides core terms exactly as the core procedure; invariant agreement (permutation/writhe); proper extension (a virtual crossing is a genuinely-new non-real element; vᵢvᵢ=ε); and an honest undecided-frontier (irreducible mixed virtual content is reportedNone, never guessed). -
Honest scope: this is the dialect’s semantic core + conservativity bridge, built as a separate module (no core-AST/Lean-oracle edits, avoiding the
Warning 8cascade). It is NOT yet a surface-syntax parser integration, and VBₙ equivalence is a sound partial decider (full VBₙ word problem is research-grade). -
Remaining: surface syntax (
lexer/parser/ast/eval); replicate the template to the other four dialects; a mechanised Lean conservativity proof.
-
✅ Differential rung landed 2026-06-14:
compiler/tangle-wasm/tests/differential.rsaddswasmi(pure-Rust interpreter) as a dev-dependency, EXECUTES the generated wasm modules with reference host primitives (alloc_strands= identity init,swap_strands= cell swap), and checks the resulting strand permutation equals an independent in-Rust reference model — over trefoil, non-commuting pairs (s1s2≠s2s1), braid-relation pairs (s1s2s1=s2s1s2), and a 5-strand weave. Runs viacargo test. -
Honest scope: validates the codegen against the permutation semantics (catches wrong crossing indices / call order / strand count / non-instantiable modules); it is NOT a cross-binary diff against
compiler/lib/eval.ml, and the Markov-move helpers are not yet exercised. -
Remaining (research-grade): a full source↔wasm bisimulation proof (WasmCert / Wasm-spec); and, if desired, a true cross-binary differential that drives
eval.mland the wasm over a shared corpus.
| Code | Meaning | Applies? |
|---|---|---|
TP |
Typing proofs |
Yes |
INV |
Invariant proofs (round-trip, LSP discipline) |
Yes |
SEC |
Security proofs |
No |
CONC |
Concurrency proofs |
No |
ALG |
Algorithm proofs (decidability, eqBraids, WASM compile) |
Yes |
ABI |
ABI/FFI proofs |
Out of scope (compiler-internal) |
DOM |
Domain proofs (braid-group, isotopy) |
Yes |
CI rejects any PR introducing these:
| Pattern | Language | Meaning |
|---|---|---|
|
Idris2 |
Unsafe cast |
|
Idris2 |
Skip totality check |
|
Idris2 / Agda |
Unproven axiom |
|
Lean 4 |
Incomplete proof |
|
Lean 4 |
Unproven postulate |
|
Coq |
Incomplete proof |
|
Haskell |
Unsafe cast |
|
OCaml |
Unsafe cast |
|
Rust |
Unsafe block without safety comment |
Enforced by panic-attack assail --proofs-only.
-
Lean 4 for the core metatheory (already chosen;
proofs/Tangle.lean). -
Lean 4 for
infer-decidability andcompositional-preservation. -
Lean 4 + Wasm-spec / WasmCert for WASM compilation correctness.
Template ABI files (Idris2 Types.idr, Layout.idr,
Foreign.idr) were removed in March 2026 — they contained only RSR
template scaffolding with unresolved placeholders and no domain-specific
proofs. This decision still stands; ABI proofs are out of scope here
(Tangle is compiler-internal; the FFI boundary is in KRL’s repo).
-
Implementation:
compiler/lib/,compiler/tangle-wasm/,compiler/tangle-lsp/. -
Formal core:
proofs/Tangle.lean. -
Companion narratives:
hyperpolymath/krl/PROOF-NARRATIVE.md,hyperpolymath/quandledb/PROOF-NARRATIVE.md.