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-11): epistemic types — Epi[k, ρ, τ], non-factive by construction (#98)
Wires `hyperpolymath/epistemic-types` into the mechanised core,
following the route TG-10 took for echo. **Lean 0 errors, sorry/axiom
gate clean.**
## The commitment: a warrant is not knowledge
`Epi[κ, ρ, τ]` — at standpoint κ, evidence of type ρ purporting to
support a claim of type τ. The claim type appears in the type and **no
elimination rule delivers it**. `evidence` is the sole projection, and
it yields ρ.
That mirrors upstream precisely:
- `Warrant.agda` gives the record only an `Evidence` field —
deliberately *not* `Evidence → A`, because that "would make every
warrant factive" — and puts extraction in a separate `SoundWarrant`.
- `Base.agda` splits `FactiveModality` (with `reflect : E κ A → A`) from
`BeliefModality` (without), rather than treating belief as knowledge
with a missing proof.
The absence here is that same design choice, mechanised.
## Six capstones
| Theorem | What it establishes |
|---|---|
| `epi_evidence_recovers` | `evidence ∘ warrant` returns the token |
| **`epi_claim_is_opaque`** | two warrants, same evidence, **different
claims**, observationally identical |
| `epi_only_yields_evidence` | from `Epi[κ,ρ,τ]` the only elimination is
at ρ |
| `epi_distinguishes_standpoints` | κ₁ ≠ κ₂ gives genuinely different
types |
| `epi_roundtrip_typed` | type safety of intro + projection |
| `epi_over_echo_typed` | `Epi[κ, Echo[ρ,τ], σ]` — the modalities
**nest** |
`epi_claim_is_opaque` is the exact dual of
`echo_distinguishes_collapsed`: **echo *reveals* what `close` forgot; a
warrant *withholds* what it purports.** Holding evidence is not holding
the fact.
`epi_over_echo_typed` mirrors `EpistemicEcho` in `EchoBridge.agda`,
which is explicit that these are different modalities — echo grades
irrecoverability, epi indexes standpoints — and that they compose
without collapsing.
## Metatheory extended, not weakened
Progress, Preservation, Determinism, TypeSafety, `infer_sound`,
`infer_complete` all cover the new fragment, plus a new `canonical_epi`
lemma.
Worth noting where non-factivity actually lands: in preservation, the
`evidenceVal` case inverts `tEvidence` then `tEpiVal` and returns the
**token's** typing (`he`), never the claim's (`hc`). Non-factivity is
discharged by the type system rather than asserted in a comment.
## Both engines
OCaml mirrors it — `TEpi` former, `Warrant`/`EpiVal`/`Evidence`, `VEpi`
runtime value, typing and evaluation. TG-3 extended with 4 pins
(including that `evidence` yields the *evidence* type, never the claim);
differential regenerated and **kernel-checked: 496 obligations, 0
errors**. TG-3 self-check 1008 → 1012.
## ⚠ Registered honestly — A-TG-11.1
What the simply-typed shadow does **not** model:
- standpoints are `Nat`, not an arbitrary index set `K`;
- upstream's `LawfulModality` functor laws, `FactiveModality.reflect`
and `ReturnModality.return` are omitted (all opt-in there);
- **the real gap** — the claim is *carried* in the value rather than
*erased*, because erasing it would break uniqueness of typing in a
system without quantities.
A **QTT** treatment (quantity `0` on the claim) would be the faithful
version — which is the same conclusion the linear/affine discussion
reached independently.
## Tests
6 typecheck cases, including two negatives: that `evidence` never
returns the claim type when the two differ, and that `evidence` of a
non-warrant is rejected. Typecheck suite 129 → 135; all suites green;
corpus and RSR gates pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
@@ -34,6 +34,7 @@ Cross-references use `[[A-TG-N.M]]` syntax, resolved here.
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
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`|
36
36
| A-TG-92.1 | MATH | Comparing braid words of different widths is decided in B_max(n,m) via the standard embedding Bn -> Bn+1 (adjoin a strand no generator touches). Used to justify widening `T-Eq-Word` (#92) and the match-arm width join. The embedding is standard mathematics but is **asserted in prose, not mechanised** — no Lean lemma states it. What IS machine-checked is that the metatheory (Progress/Preservation/Determinism/TypeSafety, infer_sound/complete) holds under the widened rule, and that OCaml `infer_expr` still agrees with Lean `infer` on the corpus (TG-3, 496 obligations). | TG-7 / #92|`proofs/Tangle.lean` (`tEqWord`, `infer`); `compiler/lib/typecheck.ml`|
37
+
| A-TG-11.1 | DESIGN | The simply-typed shadow is FAITHFUL to `epistemic-types`: `Epi[k,rho,tau]` models `Epi K k A` (Warrant.agda) with standpoints as Nat indices rather than an arbitrary index set K, and it omits the upstream `LawfulModality` functor laws, `FactiveModality.reflect` and `ReturnModality.return` (all deliberately opt-in upstream). What IS mechanised here is non-factivity: no elimination yields the claim. Erasure and quantity are NOT modelled - the claim is carried in the value rather than erased, because erasing it would break uniqueness of typing in a system without quantities. A QTT treatment (quantity 0 for the claim) would be the faithful version. | TG-11 |`proofs/Tangle.lean` section EPISTEMIC; `epistemic-types/src/EpistemicTypes/{Base,Warrant,EchoBridge}.agda`|
37
38
| A-TG-8.1 | DESIGN | Each dialect's grammar is a strict superset of core's EBNF (`tangle.ebnf`) | TG-8 |`dialects/*/grammar.ebnf`|
38
39
| 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 |
39
40
| 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
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,7 @@ Cross-referenced to [PROOF-NARRATIVE.md §3](PROOF-NARRATIVE.md#3-remaining-obli
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
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
+
| TG-11 | Epistemic types: `Epi[k, rho, tau]` former + `warrant`/`epiVal`/`evidence`, with Progress/Preservation/Determinism/TypeSafety extended to cover them, and NON-FACTIVITY established (no elimination delivers the claim) | TP / DOM | Lean 4 | P1 | - |**LANDED**: `proofs/Tangle.lean` §EPISTEMIC. Six capstones: `epi_evidence_recovers`, `epi_claim_is_opaque`, `epi_only_yields_evidence`, `epi_distinguishes_standpoints`, `epi_roundtrip_typed`, `epi_over_echo_typed`. Mirrors `hyperpolymath/epistemic-types` (Warrant.agda / Base.agda / EchoBridge.agda). TG-3 extended: 4 new pins, differential regenerated and kernel-checked (496 obligations, 0 errors) |
63
64
| 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
65
| 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
66
| 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) |
0 commit comments