You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(tg-7): == on braids decides braid-group equivalence (#50 ruling)
Implements the owner ruling on #50: option (a), true braid-group
equivalence. Syntactic equality contradicted the language's own thesis —
programs are topological objects and equivalence is isotopy — so `==` was
the one place that quietly reverted to comparing representations.
`σ₁σ₂σ₁ == σ₂σ₁σ₂` is now true.
Landed on BOTH engines in one change, because the TG-3 differential and the
Lean proof oracle straddle them:
* OCaml — `eval.ml` `Eq` on VBraid routes through `braid_equiv.ml`
(Dehornoy handle reduction, already present and tested). `Identity` is
`VBraid []`, so identity comparisons flow through the same case.
Added `ast_of_gen(s)`, the missing inverse of the existing `gen_of_ast`
(the runtime and AST generator records are structurally identical but
nominally distinct).
* Lean — new §BRAID-GROUP EQUIVALENCE in `Tangle.lean` ports the same
procedure (`unitsOf`, `inverseWord`, `freeReduce`, `scanHandle`,
`rewriteInterior`, `reduceOne`, `reduceFuel`, `braidEquiv`). Six Step
rules now use it: `eqBraids`, `eqIdBraid`, `eqBraidId` and the three
`echoEq` counterparts — echoEq must follow because eval.ml's EchoEq
explicitly reuses the Eq logic.
`~` (isotopy) routes there too. It used `simplify_gens`, which only cancels
adjacent inverses and does NOT implement the braid relation. Leaving that
while `==` became complete would have allowed `a == b` true with `a ~ b`
false, which is incoherent — for braids, isotopy IS braid-group equality.
This is a completeness fix, not a change of intended meaning. Closed
tangles are documented as a sound-but-incomplete under-approximation:
link isotopy is Markov equivalence, which is NOT implemented.
Progress / Preservation / Determinism re-verified UNCHANGED — all three need
only that the RHS is a total function into Bool. TG-3's 496 kernel-checked
obligations still pass (typing is untouched; only the runtime value changes).
TRUSTED, NOT PROVEN. These are definitions, not axioms, so the sorry/axiom
gate passes legitimately — but that does not make the claim proven. The
metatheory holds *relative to* `braidEquiv`; that `braidEquiv` correctly
DECIDES braid-group equality is the mechanised Garside/Dehornoy proof, which
remains research-grade (#51). Recorded as new assumption A-TG-7.2, and
stated plainly in PROOF-NARRATIVE.md so the green gate cannot be mistaken
for a proof. The Lean port is fuel-bounded rather than well-founded, since
proving termination IS that research obligation.
Tests: 8 new cases in test_eval.ml that DISTINGUISH the two semantics (the
pre-existing braid-equality tests pass either way, so they could not). They
cover the braid relation, far commutation, free cancellation, symmetry, and
two negatives guarding against a procedure that just says true. eval suite
104 -> 112, whole suite 0 failures.
Also in this change, both found while doing the above:
* `.github/workflows/ocaml-ci.yml` (NEW) — the OCaml compiler and its 4,000+
assertions were NOT built or run by CI at all; only the Lean proofs were
gated. A semantics change to eval.ml could have landed fully green with
nothing having compiled it. Uses apt rather than a setup action so no new
third-party pin enters the estate.
* `lean-proofs.yml` — the sorry/axiom gate's comment filter never worked:
it anchored on `^\s*--` AFTER `grep -n` had prepended `<line>:`, so the
documented "outside comments" exemption could never match. It went
unnoticed only because no comment had yet contained one of these words;
the TG-7 trusted-base note does. Anchored after the prefix — strictly
tighter than the old unanchored `/-` catch-all, and verified to still
catch a real `sorry`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: ASSUMPTIONS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ Cross-references use `[[A-TG-N.M]]` syntax, resolved here.
32
32
| A-TG-6.1 | MATH | WASM small-step semantics is well-defined; assume the official Wasm spec / WasmCert-Isabelle definition | TG-6 | wasm-spec, WasmCert-Isabelle |
33
33
| A-TG-6.2 | DESIGN | Source semantics has no floating-point non-determinism (Tangle has only `Int` currently) | TG-6 |`Tangle.lean::Ty` lacks `.float`|
34
34
| A-TG-7.1 | MATH | Word problem in the braid group `B_n` is solvable in polynomial time (Birman–Ko–Lee / Garside normal form) | TG-7 | Birman–Ko–Lee 1998; _A New Approach to the Word and Conjugacy Problems in the Braid Groups_|
35
+
| A-TG-7.2 | IMPL |`braidEquiv` (`proofs/Tangle.lean`) and `braid_equiv.ml` implement Dehornoy handle reduction **correctly**, and agree with each other. Since the 2026-07-29 ruling (#50) routed `==` through them, this is **load-bearing for the semantics of `==`**: the Step relation's metatheory is proven only *relative to*`braidEquiv`, never that it decides braid-group equality. Evidenced by testing (2220 + 8 assertions), not proof. Retired by the mechanised Garside/Dehornoy proof (#51, research-grade). The Lean port is additionally **fuel-bounded**, so termination is assumed rather than proven. | TG-7 |`compiler/lib/braid_equiv.ml`; `proofs/Tangle.lean` §BRAID-GROUP EQUIVALENCE; `compiler/test/tg7`|
35
36
| A-TG-8.1 | DESIGN | Each dialect's grammar is a strict superset of core's EBNF (`tangle.ebnf`) | TG-8 |`dialects/*/grammar.ebnf`|
36
37
| A-TG-8.2 | DESIGN | Each dialect's typing rules are additive (new constructors + their typing rules only; no modification of existing rules) | TG-8 | Per-dialect spec |
37
38
| A-TG-9.1 | DESIGN |`tangle-lsp` emits diagnostics in four documented categories (`PARSE_ERROR`, `MISSPELLING_HINT`, `STRUCTURAL_HINT`, `NAME_HINT`); only `PARSE_ERROR` corresponds to a grammar-level rejection. The other three are LSP-only by design (Option B from TG-9 audit; Option A — full refinement via FFI to `typecheck.ml` — remains queued at #28). Each emission site is tagged in the `Diagnostic.source` field as `tangle-lsp[CATEGORY]`. | TG-9 |`compiler/tangle-lsp/src/backend.rs`; `compiler/tangle-lsp/docs/lsp-diagnostic-categories.md`|
Copy file name to clipboardExpand all lines: PROOF-NEEDS.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ Cross-referenced to [PROOF-NARRATIVE.md §3](PROOF-NARRATIVE.md#3-remaining-obli
59
59
| TG-4 | Pretty-print/parse round-trip on closed values | INV | OCaml property test (cheap) | P2 | 4h |**LANDED** (PR #46 — OCaml property test in `compiler/test/test_roundtrip.ml`, 26-entry corpus including 8 echo/product constructors; 52 round-trip runs) |
60
60
| TG-5 |`compositional.ml` (418 LoC) rewriter preserves types | TP | OCaml property test | P2 | — |**LANDED** (`compiler/test/tg5/tg5_invariants.ml`, 189 assertions in `dune runtest`). compositional is below the Ty layer, so "preserves types" = preserves the PD-lowering structural invariants + echo residue-recovery: `OpenWord`/`ClosedDiagram`/`EchoClosed` each pinned (closedness, `\|crossings\|`=unit-length, source unit-expanded, **verbatim residue** for `EchoClose` with `expand(residue)=diagram word` and echo-diagram pdv1-identical to plain `close`), error paths, count pins. Lean IR model = optional later rung |
61
61
| TG-6 | WASM compilation preserves semantics (source eval ≡ wasm exec) | TP / ALG | differential + Lean bisimulation | P1 | — |**RUNG LANDED (differential)**: `compiler/tangle-wasm/tests/differential.rs` EXECUTES the generated wasm with the `wasmi` interpreter (dev-dep) and checks the braid strand-permutation equals an independent reference model (trefoil, non-commuting pairs, braid-relation pairs, 5-strand weave). Validates codegen vs the permutation semantics; not a cross-binary diff against `eval.ml`, and Markov helpers untested. Full source↔wasm bisimulation (WasmCert) remains research-grade |
62
-
| TG-7 |`Step.eqBraids` decides braid-group equivalence (not list equality) | ALG / DOM | OCaml + Lean 4 | P2 | — |**RUNG LANDED (non-semantic)**: `compiler/lib/braid_equiv.ml` decides braid-group equivalence via Dehornoy handle reduction, out-of-band (leaves `==`/`Step.eqBraids` as list equality). Tested (`compiler/test/tg7`, 2220 assertions: defining relations + 400 constructed-equivalent pairs + invariant-distinguished negatives).**Still OWNER-GATED**: whether to route `==` through it (a semantics change to eval.ml + Lean Step + proofs) is a language-design decision; Lean correctness (Garside/Dehornoy) remains research-grade|
62
+
| TG-7 |`Step.eqBraids` decides braid-group equivalence (not list equality) | ALG / DOM | OCaml + Lean 4 | P2 | — |**SEMANTICS LANDED 2026-07-29** (owner ruling #50 → (a) true braid-group equivalence). `==` on braids now decides braid-group equality in BOTH engines: OCaml `eval.ml``Eq`/`Isotopy` route through `compiler/lib/braid_equiv.ml`; Lean `Step.eqBraids`/`eqIdBraid`/`eqBraidId` (and the three `echoEq` counterparts) use `braidEquiv`, a faithful in-Lean port of the same Dehornoy procedure. Progress/Preservation/Determinism re-verified unchanged (they need only a total function into `Bool`). Tested: `compiler/test/tg7` 2220 assertions + 8 new semantics-distinguishing cases in `test_eval.ml`.**Remaining (research-grade): the mechanised Garside/Dehornoy correctness proof — `braidEquiv` is TRUSTED, NOT PROVEN; the Step relation is proven only RELATIVE to it**|
63
63
| 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)**: `compiler/lib/dialect_vk.ml` models VBₙ ⊃ Bₙ as core + a virtual layer that DELEGATES to `Braid_equiv` on the real fragment, so conservativity holds by construction; `compiler/test/tg8` (2311 assertions) verifies faithful embedding, core-delegation, invariant agreement, proper extension, virtual involution, honest undecided-frontier. Remaining: surface-syntax parser integration, the other 4 dialects (replicate the template), and a Lean conservativity proof |
64
64
| TG-9 | LSP diagnostics are a subset of `HasType` failures (no LSP-only diagnostics) | INV | Audit + refactor | P2 | — |**LANDED** (`tangle-lsp` delegates all diagnostics to `tanglec --check` ⇒ `compiler/lib/check.ml`; hand-rolled LSP-only false positives removed. Subset holds by construction. Tests: `test_check.ml` + tangle-lsp unit/delegation tests) |
65
65
| TG-10 | Echo-types integrated into the type system: `Echo[ρ,τ]` former + `echoClose`/`lower`/`residue`/`echoAdd`/`echoEq` + product type (`pair`/`fst`/`snd`), with Progress/Preservation/Determinism/TypeSafety extended to cover them and the non-injectivity / residue-recovery capstones proven | TP / DOM | Lean 4 | P1 | — |**LANDED** (`proofs/Tangle.lean` §ECHO-TYPES) |
@@ -73,10 +73,11 @@ Concrete approach, effort, risk, and dependencies for what is left after
73
73
TG-0/1/2/3/4/5/9/10 landed. **Landable rungs of TG-6, TG-7, and TG-8 also
74
74
landed** (2026-06-14): TG-6 a `wasmi` differential test; TG-7 an out-of-band
75
75
`braid_equiv` checker; TG-8 a virtual-knot conservative-extension template. What
76
-
genuinely remains is **owner-gated or research-grade**: TG-7's *semantics
77
-
change* (decision); TG-8's *surface-syntax integration + other 4 dialects +
78
-
Lean conservativity proof*; TG-6's *full source↔wasm bisimulation* and TG-7's
79
-
*Lean correctness proof*.
76
+
genuinely remains is **research-grade**: TG-8's *surface-syntax integration +
77
+
other 4 dialects + Lean conservativity proof*; TG-6's *full source↔wasm
78
+
bisimulation*; and TG-7's *Lean correctness proof*. (TG-7's **semantics
79
+
change is no longer owner-gated — it was ruled and landed 2026-07-29**, see
0 commit comments