|
| 1 | +<!-- SPDX-License-Identifier: MPL-2.0 --> |
| 2 | +<!-- Owner: Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> --> |
| 3 | + |
| 4 | +# The eliminator fork — and whether choreographic typing across time segments closes it |
| 5 | + |
| 6 | +The two admits the tropical re-foundation does **not** dissolve |
| 7 | +(`step_pop_disjoint_from_type_l1`, ADMIT 3; `preservation_l1`, ADMIT 4 gated on |
| 8 | +it). This note states the challenge precisely, explains why both prior fixes |
| 9 | +failed, and assesses the proposal: **type region-liveness choreographically, |
| 10 | +across time segments.** Verdict up front: it is the right *shape* — more so than |
| 11 | +the grade-in-context patch — but it is unproven and can *relocate* rather than |
| 12 | +*close*, so it needs the minimal-counterexample experiment in §5. |
| 13 | + |
| 14 | +## 1. The challenge, precisely |
| 15 | + |
| 16 | +Preservation needs: if `R ; G ⊢ e : T -| R' ; G'` and `(μ,R,e) → (μ',R₂,e')`, |
| 17 | +then `R₂ ; G ⊢ e' : T -| … `. It fails on a single shape: |
| 18 | + |
| 19 | +> A **subterm `e_sub` depends on a region `rv`** (its type mentions `rv`, e.g. |
| 20 | +> `e_sub : TString rv`), but an **eliminator/context erases `rv` from the |
| 21 | +> result type** (`EDrop(·):TUnit`, `Fst`, application, `Let`-body, `Case`-arm), |
| 22 | +> and a step **exits `rv`** (`R → R₂`, `rv` gone). Now `e'` still contains |
| 23 | +> `e_sub`, which needs `rv` live, but `R₂` no longer has it and `T` never |
| 24 | +> showed it. |
| 25 | +
|
| 26 | +Minimal Coq-checked witness: `EDrop (EVar j : TString rv)` at `R = [rv]`. It |
| 27 | +types; `expr_strictly_free_of_region rv` holds (no syntactic `rv`); the result |
| 28 | +type `Unit` satisfies the Tofte–Talpin premise — yet shrinking `rv` leaves the |
| 29 | +inner `EVar j` untypable. |
| 30 | + |
| 31 | +**The root is a representational mismatch in *time*.** The judgment expresses |
| 32 | +region liveness with: |
| 33 | +- a **snapshot** `R` (the live set *at one point*), and |
| 34 | +- a **result-type-local** view (`free_regions(T)`), |
| 35 | + |
| 36 | +but the actual obligation is **temporally extended and non-local**: "`rv` must |
| 37 | +be live *throughout the evaluation of `e_sub`*". A snapshot cannot say |
| 38 | +"throughout"; a result type cannot say "of a subterm whose contribution I |
| 39 | +erased". The information needed is *when*, and neither carrier carries time. |
| 40 | + |
| 41 | +## 2. Why both prior fixes failed (the same wall) |
| 42 | + |
| 43 | +- **Leaf-rule strengthening (path 3):** put `free_regions(T) ⊆ R` on `T_Var`. |
| 44 | + This forces liveness *at the variable use site*. But region-shrink/exit |
| 45 | + *wants to remove* `rv` while that very variable is in scope, so the premise |
| 46 | + and `region_shrink` **contradict** — the `EDrop` witness is exactly the |
| 47 | + contradiction. It moves the snapshot demand to the leaf; it does not add time. |
| 48 | +- **Effect-typed lambdas (A′):** makes a *lambda's* footprint type-visible. |
| 49 | + Helps only `S_App_Step2`; the witness is a *free variable under an |
| 50 | + eliminator*, no lambda involved. It adds type-visibility for one binder |
| 51 | + shape; it does not add time. |
| 52 | + |
| 53 | +Both stay inside the snapshot+result-type ontology. The wall is that ontology. |
| 54 | + |
| 55 | +## 3. The proposal: liveness as a choreography over time segments |
| 56 | + |
| 57 | +Replace "liveness = membership in a snapshot" with "liveness = a position in a |
| 58 | +**global protocol over time segments**", and recover the per-subterm rule by |
| 59 | +**projection**. Concretely: |
| 60 | + |
| 61 | +- **Time segments.** A region scope `enter rv … exit rv` *is* a segment: the |
| 62 | + interval during which `rv` is live. Nesting/re-entry gives nested segments |
| 63 | + (depth = the tropical `cnt rv` grade — the two views meet here). |
| 64 | +- **Regions as session-typed resources.** Each region is a participant whose |
| 65 | + lifecycle is a session `open → use* → close` (exactly a file-handle/typestate |
| 66 | + protocol). The whole program is the **choreography**: the interleaving of all |
| 67 | + regions' sessions across segments. |
| 68 | +- **Local typing = endpoint projection.** A subterm `e_sub` is typed by |
| 69 | + *projecting* the choreography onto `e_sub`'s segment. Its dependency on `rv` |
| 70 | + is satisfied because the projection places `e_sub` *inside* `rv`'s `open…close` |
| 71 | + segment — **not** because `rv` appears in the result type. |
| 72 | +- **Preservation = subject reduction for the choreography.** A step advances |
| 73 | + the global type to a coherent global type; the snapshot problem dissolves |
| 74 | + because the global type carries the *temporal* structure the snapshot lacked. |
| 75 | + |
| 76 | +The eliminator's "hidden" dependency is then **not hidden**: the global type |
| 77 | +records that `e_sub` runs in `rv`'s segment, even though the local/erased result |
| 78 | +type does not. That is precisely the missing *when*. |
| 79 | + |
| 80 | +## 4. Why this is the right shape — and the estate already has both halves |
| 81 | + |
| 82 | +The dependency is temporal-and-global; choreographies are *the* device for |
| 83 | +temporal-global protocols projected to local views. This is a structural match, |
| 84 | +not an analogy. And it composes with the tropical re-foundation rather than |
| 85 | +competing with it: |
| 86 | + |
| 87 | +- `tropical-resource-typing` already ships **`TropicalSessionTypes.lean`**. |
| 88 | + Session types are the *local projections* of a choreography. So region |
| 89 | + liveness becomes a **tropical-graded choreography across time segments**: the |
| 90 | + grade (MinPlus `cnt`) carries the *resource quantity* (re-entry depth), the |
| 91 | + session/choreographic structure carries the *temporal protocol*. One object, |
| 92 | + two readings — the same `echo ≡ tropical ≡ epistemic` unification, now |
| 93 | + extended to include the *order of events*, not just their magnitude. |
| 94 | +- Division of labour becomes clean: **tropical grade** closes the structural |
| 95 | + admits (1, 2 — quantity/carrier); **choreography over segments** is aimed at |
| 96 | + the eliminator admit (3 — time). `EchoBridge` already measures L3 residues |
| 97 | + into the grade; a choreography adds the missing temporal axis to the same |
| 98 | + grade. |
| 99 | + |
| 100 | +## 5. The honest risks (why "right shape" ≠ "resolved") |
| 101 | + |
| 102 | +1. **Sequential, not distributed.** Choreographies/session types were built for |
| 103 | + *concurrent* systems with communicating participants. The reinterpretation |
| 104 | + here — *regions* as participants, *scopes* as segments, region |
| 105 | + alloc/use/free as the "communication" — is principled (resource-usage |
| 106 | + protocols / typestate are exactly session-shaped) but **non-standard**; it |
| 107 | + needs a clean foundation, not an off-the-shelf import. |
| 108 | +2. **Projection coherence is where the problem could re-appear.** The whole |
| 109 | + method rests on endpoint projection being *coherent* (locals recompose to the |
| 110 | + global). The eliminator case might project to a local type that is itself |
| 111 | + inconsistent — in which case the difficulty is **relocated** to a coherence |
| 112 | + side-condition, not closed. This is the single thing to check first. |
| 113 | +3. **Close vs relocate.** Subject reduction for the choreography must genuinely |
| 114 | + *carry* "`rv` live throughout `e_sub`'s segment" through the exit step. If it |
| 115 | + does, ADMIT 3 closes; if the segment boundary and the exit step don't line up |
| 116 | + definitionally, you get a new obligation, not a discharge. |
| 117 | +4. **Apparatus cost.** This is a research program (global types, projection, |
| 118 | + coherence, subject reduction for the region choreography), not a refactor — |
| 119 | + high-reward, high-cost. It should not gate the §`L1-REGION-REFOUNDATION-PLAN` |
| 120 | + clean win, which proceeds independently. |
| 121 | + |
| 122 | +## 6. The deciding experiment (cheap, do this before committing) |
| 123 | + |
| 124 | +Do **not** build the general theory first. Formulate the *minimal* choreography |
| 125 | +that types just `EDrop (EVar j : TString rv)` over two segments — |
| 126 | +`S₁ = [enter rv … (EVar j read) …]`, `S₂ = [exit rv …]` — and ask one question: |
| 127 | + |
| 128 | +> Does the choreography's subject-reduction step for `S_Region_Exit rv` |
| 129 | +> transform the global type into a **coherent** global type in which the |
| 130 | +> (now-residual) `EVar j` no longer claims `rv`-liveness — *without* a snapshot |
| 131 | +> premise? |
| 132 | +
|
| 133 | +- **If yes**, the segment carried the *when*, the projection stayed coherent, |
| 134 | + and ADMIT 3 closes choreographically → re-grade `region_liveness` *and* |
| 135 | + `step_pop` against the global type; the capstone follows. (This is the path |
| 136 | + to **0** admits.) |
| 137 | +- **If no — i.e. coherence needs an extra side-condition** — the problem has |
| 138 | + *relocated* to that condition. Report it; it is likely the *same* eliminator |
| 139 | + obligation in choreographic clothing, and the honest count stays **2** until a |
| 140 | + different idea (or a restricted language fragment) lands. |
| 141 | + |
| 142 | +Either outcome is decisive and cheap, and tells us whether choreographic typing |
| 143 | +*resolves* the eliminator fork or merely *renames* it. |
| 144 | + |
| 145 | +## 7. Verdict |
| 146 | + |
| 147 | +Choreographic typing across time segments is the **best-shaped** candidate for |
| 148 | +ADMIT 3 because it is the only proposal that adds the missing axis — *time* — |
| 149 | +rather than re-arranging the snapshot. It also unifies cleanly with the tropical |
| 150 | +re-foundation via `TropicalSessionTypes` (a tropically-graded choreography: |
| 151 | +quantity × order in one structure). It is **not yet a resolution**: it can |
| 152 | +relocate the difficulty into projection coherence, and the sequential-language |
| 153 | +foundation is non-standard. The §5/§6 experiment is the inexpensive way to |
| 154 | +learn which — and it is the recommended next step on the eliminator fork, run in |
| 155 | +parallel with (not blocking) the clean-win carrier refactor. |
0 commit comments