hclang 0.42.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -700,8 +700,8 @@ export const HC_SOURCES = new Map([
700
700
  "values have Size 1. `.###` alternates child Sizes on non-schema lists, or returns",
701
701
  "Count parity (`.# mod 2`) on every other value with a Count; schemas have nil",
702
702
  "residual, and `<>` observes as `[]`. `.####` derives a Demi, an instance of",
703
- "the class in `hc/demi.hc`, returning nil at zero Count or nil residual and",
704
- "propagating failed observations.",
703
+ "the class in `hc/demi.hc`, which keeps the source's whole Count, returning nil at",
704
+ "zero Count or nil residual and propagating failed observations.",
705
705
  "```",
706
706
  "; [.meta 1; 2, 3] .#",
707
707
  "# 2",
@@ -1202,10 +1202,11 @@ export const HC_SOURCES = new Map([
1202
1202
  "A = X.###. An empty terminal has Size 1. A nonempty host has Size equal to",
1203
1203
  "the sum of its immediate child Sizes, and A alternates + and - across those",
1204
1204
  "children, starting +. Properties do not enter these sums. D(X) = X.#### is",
1205
- "nil for the empty host; otherwise it has loads L = (S+A)/2, R = (S-A)/2 and",
1206
- "phase p = 2 for even n (left next), 1 for odd n (right next). Read these with",
1207
- "`.left`, `.right`, `.phase`. n is forgotten except for parity. Nesting,",
1208
- "identities, properties and the distribution within each load are forgotten.",
1205
+ "nil for the empty host; otherwise it has Count n, loads L = (S+A)/2, R = (S-A)/2",
1206
+ "and phase p = 2 for even n (left next), 1 for odd n (right next). Read these",
1207
+ "with `.count` (or `.#`), `.left`, `.right`, `.phase`. n is kept whole (007.25c);",
1208
+ "the phase is its parity. Nesting, identities, properties and the distribution",
1209
+ "within each load are forgotten.",
1209
1210
  "```",
1210
1211
  "; .E []; .X [[], [[], []], []];",
1211
1212
  "; [E.#, E.##, E.###, E.####]",
@@ -1224,36 +1225,39 @@ export const HC_SOURCES = new Map([
1224
1225
  "Generation and selective compression",
1225
1226
  "",
1226
1227
  "No Demi is initialized when building X. The native reading derives from the",
1227
- "constructed host. Equal readings can hide different nesting and even different",
1228
- "Counts, while another construction gives a different reading.",
1228
+ "constructed host. Equal readings can hide different nesting, while another",
1229
+ "construction gives a different reading. The reading keeps the Count, so two",
1230
+ "hosts with the same loads and phase but different Counts have different",
1231
+ "readings.",
1229
1232
  "```",
1230
1233
  "; .A [[]]; .B [[[]]];",
1231
1234
  "; [A = B, A.#### = B.####, A.#### === B.####]",
1232
1235
  "# [(), <>, ()]",
1233
1236
  "; .C [[[], []], [[], []]]; .F [[], [], [], []];",
1234
- "; [C.#, F.#, C = F, C.#### = F.####, A.#### = C.####]",
1235
- "# [2, 4, (), <>, ()]",
1236
- "; [“” A.####, “” C.####, “” [[], [[], []]].####]",
1237
- "# [“Demi((),1,0)”, “Demi(<>,2,2)”, “Demi(<>,1,2)”]",
1237
+ "; [C.#, F.#, C = F, C.#### = F.####, C.####.left = F.####.left, C.####.right = F.####.right, C.####.phase = F.####.phase, A.#### = C.####]",
1238
+ "# [2, 4, (), (), <>, <>, <>, ()]",
1239
+ "; [“” A.####, “” C.####, “” F.####, “” [[], [[], []]].####]",
1240
+ "# [“Demi(1,1,0)”, “Demi(2,2,2)”, “Demi(4,2,2)”, “Demi(2,1,2)”]",
1238
1241
  "```",
1239
1242
  "Uniform append and Inlay, including successive compositions",
1240
1243
  "",
1241
1244
  "For any nonempty X in the contract, appending Y deposits Y.## into the active",
1242
1245
  "load and flips phase. This is precisely how native append adds one term to",
1243
- "the Size sum and the alternating sum: (X Y).#### = (X.#### Y).",
1246
+ "the Size sum and the alternating sum, and adds one to the Count: (X Y).#### =",
1247
+ "(X.#### Y).",
1244
1248
  "It works for either parity, independent of the shape or size of Y.",
1245
1249
  "```",
1246
1250
  "; .Y [[], [], []];",
1247
1251
  "; [(A Y).#### = (A.#### Y), (C Y).#### = (C.#### Y), (X Y).#### = (X.#### Y)]",
1248
1252
  "# [<>, <>, <>]",
1249
1253
  "; [“” (A Y).####, “” (C Y).####, “” ((C Y) []).####]",
1250
- "# [“Demi(<>,1,3)”, “Demi((),5,2)”, “Demi(<>,5,3)”]",
1254
+ "# [“Demi(2,1,3)”, “Demi(3,5,2)”, “Demi(4,5,3)”]",
1251
1255
  "; ([5, “ab”] []).#### = ([5, “ab”].#### [])",
1252
1256
  "# <>",
1253
1257
  "```",
1254
1258
  "Inlay replaces every terminal with Y. Each immediate child's Size is multiplied",
1255
1259
  "by Y.##, so both alternating loads scale by that same quantity. A nonempty",
1256
- "host retains its immediate Count and phase. Thus for every such X and Y,",
1260
+ "host retains its immediate Count, so its phase. Thus for every such X and Y,",
1257
1261
  "(X * Y).#### = X.####.scale_ (Y.##). For empty X, [] * Y is Y itself:",
1258
1262
  "the empty case is substitution, not scaling a missing state.",
1259
1263
  "These are uniform recipes for every finite input in the contract. Enumerating",
@@ -1271,37 +1275,45 @@ export const HC_SOURCES = new Map([
1271
1275
  "",
1272
1276
  "The empty host has no Demi, despite Size 1. Its first append generates a",
1273
1277
  "present reading. Applying nil is not the append update; a zero-load phase-2",
1274
- "Demi is an explicit initialized-router convention, not a preconstruction state",
1275
- "secretly stored in []. A zero Size deposit still changes routing phase.",
1278
+ "Demi of Count zero is an explicit initialized-router convention, not a",
1279
+ "preconstruction state secretly stored in []. A zero Size deposit still adds one",
1280
+ "to the Count and so changes routing phase.",
1276
1281
  "```",
1277
1282
  "; [([] []).####.phase, ([] []).####.left, ([] []).####.right]",
1278
1283
  "# [1, 1, 0]",
1279
1284
  "; [([] Y).#### = ([].#### Y), ([] * Y).#### = Y.####]",
1280
1285
  "# [(), <>]",
1281
1286
  "; Demis <- './hc/demi.hc';",
1282
- "; ([] Y).#### = ((Demis.Demi [2, 0, 0]) Y)",
1287
+ "; ([] Y).#### = ((Demis.Demi [0, 0, 0]) Y)",
1283
1288
  "# <>",
1284
- "; [“” [0].####, “” ([0].#### 0), [].#### = [0].####]",
1285
- "# [“Demi((),0,0)”, “Demi(<>,0,0)”, ()]",
1289
+ "; [“” [0].####, “” ([0].#### 0), [].#### = [0].####, [].#### = (Demis.Demi [0, 0, 0]), (Demis.Demi [0, 0, 0]).#### = (Demis.Demi [0, 0, 0])]",
1290
+ "# [“Demi(1,0,0)”, “Demi(2,0,0)”, (), (), <>]",
1286
1291
  "```",
1287
1292
  "For a proposed relabeling, exchange the loads AND toggle which named channel",
1288
- "is next: J(p,L,R) = (3-p,R,L). Total load stays fixed and residual changes",
1289
- "sign. J commutes with deposit and scale; this is equivariance of a named",
1290
- "router representation, not invariance of its signed readout, not reversal of",
1291
- "the host, and not a new native constructor. The following closure only checks",
1292
- "that explicit relabeling using the existing Demi class.",
1293
- "```",
1294
- "; .swap {.d _; Demis.Demi [(d.phase = 2) ? {1} : {2}, d.right, d.left]};",
1293
+ "is next: J(n,L,R) = (n+1,R,L). Toggling the phase changes the parity of the",
1294
+ "Count, and a Demi derives its phase from its Count, so the relabeling moves the",
1295
+ "Count by one rather than leaving it fixed; the Count has no mirror image of its",
1296
+ "own. Total load stays fixed and residual changes sign. J commutes with deposit",
1297
+ "and scale; this is equivariance of a named router representation, not",
1298
+ "invariance of its signed readout, not reversal of the host, and not a new native",
1299
+ "constructor. Applying J twice returns the loads and the phase, with the Count",
1300
+ "two higher, so it is an involution on phase and loads and not on Count. The",
1301
+ "following closure only checks that explicit relabeling using the existing Demi",
1302
+ "class.",
1303
+ "```",
1304
+ "; .swap {.d _; Demis.Demi [(d.count + 1), d.right, d.left]};",
1295
1305
  "; .q [[], [[], []]].####;",
1296
1306
  "; [“” q, “” (swap q), (swap q).## = q.##, (swap q).### = (0 - q.###)]",
1297
- "# [“Demi(<>,1,2)”, “Demi((),2,1)”, <>, <>]",
1298
- "; [(swap (q Y)) = ((swap q) Y), (swap ((q Y) [])) = (((swap q) Y) []), (swap (q.scale_ 3)) = ((swap q).scale_ 3), (swap (swap q)) = q]",
1299
- "# [<>, <>, <>, <>]",
1307
+ "# [“Demi(2,1,2)”, “Demi(3,2,1)”, <>, <>]",
1308
+ "; [(swap (q Y)) = ((swap q) Y), (swap ((q Y) [])) = (((swap q) Y) []), (swap (q.scale_ 3)) = ((swap q).scale_ 3)]",
1309
+ "# [<>, <>, <>]",
1310
+ "; [(swap (swap q)).phase = q.phase, (swap (swap q)).left = q.left, (swap (swap q)).right = q.right, (swap (swap q)).count = (q.count + 2), (swap (swap q)) = q]",
1311
+ "# [<>, <>, <>, <>, ()]",
1300
1312
  "```",
1301
1313
  "Future sufficiency, at its earned scope",
1302
1314
  "",
1303
- "For equal nonempty D readings, equal loads imply equal total Size and equal",
1304
- "phase. The append recipe uses only those fields and the appended Size; the",
1315
+ "For equal nonempty D readings, equal Count and loads imply equal total Size",
1316
+ "and equal phase. The append recipe uses only those fields and the appended Size; the",
1305
1317
  "Inlay recipe uses only those fields and the replacement Size. Consequently",
1306
1318
  "any finite sequence of the SAME right-append and right-Inlay constructions",
1307
1319
  "preserves D equality. If both starting hosts are empty, they are the same",
@@ -1311,12 +1323,15 @@ export const HC_SOURCES = new Map([
1311
1323
  "the empty case must be treated separately (its Size is 1, not zero).",
1312
1324
  "This is a uniform construction/observer relationship, not a claim that every",
1313
1325
  "HC observer or arbitrary operation factors through D. Count already separates",
1314
- "C and F; inspecting stored metadata can separate decorated and undecorated X.",
1326
+ "C and F, and the fourth hash keeps it, so their readings differ; inspecting",
1327
+ "stored metadata can separate decorated and undecorated X, which the reading does",
1328
+ "not.",
1315
1329
  "```",
1316
- "; [((A Y) * Y).#### = ((B Y) * Y).####, (((C []) * Y) A).#### = (((F []) * Y) A).####]",
1317
- "# [<>, <>]",
1330
+ "; .P [[], [[], []]]; .Q [[[]], [[], []]];",
1331
+ "; [((A Y) * Y).#### = ((B Y) * Y).####, (((P []) * Y) A).#### = (((Q []) * Y) A).####, P = Q, P.#### = Q.####]",
1332
+ "# [<>, <>, (), <>]",
1318
1333
  "; [C.#### = F.####, C.# = F.#, decorated.#### = X.####, decorated = X]",
1319
- "# [<>, (), <>, ()]",
1334
+ "# [(), (), <>, ()]",
1320
1335
  "```",
1321
1336
  "Physically realizable readout (proposed material apparatus)",
1322
1337
  "",
@@ -1324,7 +1339,8 @@ export const HC_SOURCES = new Map([
1324
1339
  "nonempty host, count the sticks in each immediate child tray, deposit that many",
1325
1340
  "unit marks in alternating left and right bins, and toggle a two-position pointer",
1326
1341
  "after EACH child. Start left. Read bin populations as L,R and the next-bin",
1327
- "pointer as phase 2 or 1. Read n by counting immediate trays, S by counting all",
1342
+ "pointer as phase 2 or 1. Read n by counting immediate trays, which the pointer's",
1343
+ "position repeats only in parity, S by counting all",
1328
1344
  "terminal sticks, and A by subtracting the bin populations. No separately",
1329
1345
  "supplied state vector or stochastic routing law is needed. The empty host's",
1330
1346
  "one terminal stick is not an immediate child deposit: report no Demi until",
@@ -1353,7 +1369,8 @@ export const HC_SOURCES = new Map([
1353
1369
  "1. Derived: VACTED by execution for the examples; uniformly vacted under the",
1354
1370
  " construction/observer contract. Hosts are built before their Demi is read.",
1355
1371
  "2. Compressive: VACTED by distinct equal-reading constructions. Representation",
1356
- " has two unbounded Counts plus parity; fixed dimension is not bounded bits.",
1372
+ " has three unbounded Counts, n, L and R, with the phase derived from n; fixed",
1373
+ " dimension is not bounded bits.",
1357
1374
  "3. Forced update: VACTED by execution for the displayed compositions; uniformly",
1358
1375
  " vacted by the append and substitution recipes on the declared domain.",
1359
1376
  "4. Origin: VACTED for no supplied host Demi and the first-construction boundary.",
@@ -1361,7 +1378,8 @@ export const HC_SOURCES = new Map([
1361
1378
  " equivariance above. Full origin/gauge invariance is NOT YET VACTED.",
1362
1379
  "5. Earned forgetting: uniformly vacted for the specified future constructor",
1363
1380
  " language and D observations, with executable witnesses. Sufficiency for all",
1364
- " other HC observations is false, as the Count counterexample demonstrates.",
1381
+ " other HC observations is false, as the nesting and metadata counterexamples",
1382
+ " above demonstrate.",
1365
1383
  "",
1366
1384
  "Actual apparatus executed here: the HC interpreter and testdoc harness, using",
1367
1385
  "native Frame construction and .####. The command's per-claim output and final",
@@ -1446,13 +1464,14 @@ export const HC_SOURCES = new Map([
1446
1464
  [
1447
1465
  "#!/usr/bin/env hc",
1448
1466
  "```",
1449
- "Demi (occurrence/figure 011.20)",
1467
+ "Demi (occurrence/figure 011.20, 007.25c)",
1450
1468
  "",
1451
- "A Demi is a closed two-channel state: a phase and two loads, left and right.",
1452
- "Applying a Demi to a Frame deposits that Frame's Size into the active load and",
1453
- "flips the phase, so a Demi follows alternating construction one observation at",
1454
- "a time. It is what the fourth hash answers: `x.####` is the Demi of x's Count,",
1455
- "Size and residual, with left load (Size + residual)/2 and right load",
1469
+ "A Demi is a closed two-channel state: a Count and two loads, left and right.",
1470
+ "Applying a Demi to a Frame deposits that Frame's Size into the channel the",
1471
+ "Count's parity selects and adds one to the Count, so a Demi follows alternating",
1472
+ "construction one observation at a time and remembers how many it has seen. It",
1473
+ "is what the fourth hash answers: `x.####` is the Demi of x's Count, Size and",
1474
+ "residual, with Count x.#, left load (Size + residual)/2 and right load",
1456
1475
  "(Size − residual)/2.",
1457
1476
  "",
1458
1477
  "`Demi` is an ordinary HC class: a constructor closure answering a fresh",
@@ -1462,34 +1481,57 @@ export const HC_SOURCES = new Map([
1462
1481
  "in, the first time `.####` needs one. So this file is both the definition every",
1463
1482
  "evaluator uses and its specification, and it works without a resource root.",
1464
1483
  "Import it to construct Demis directly: `Demis <- './hc/demi.hc'`, then",
1465
- "`Demis.Demi [2, 0, 0]`.",
1466
- "",
1467
- "**State.** `Demi [phase, left, right]` takes three Counts. The phase is the",
1468
- "least positive Count of its parity (011.18g): 2 when even, left next, and 1",
1469
- "when odd, right next. It is a Count rather than all or nil because a field",
1470
- "cannot hold nil, and a Count keeps the odd phase present: a Demi in phase 1 is",
1471
- "a value, unlike the nil `.####` answers for a Frame with no Demi. Anything else",
1472
- "is refused with `$!!.invalid-demi`, a named error, as Figures refuses an",
1473
- "unsupported host. The fields are the whole state, so two Demis are `=` exactly",
1474
- "when their fields are.",
1484
+ "`Demis.Demi [0, 0, 0]`.",
1485
+ "",
1486
+ "**State (007.25c).** `Demi [C, L, R]` takes three Counts, any of them zero",
1487
+ '(`Demi [C, loads]` takes a Count and a list of loads; see "Channels and',
1488
+ 'division" below). `C`',
1489
+ "is the full application Count the state has recorded, not its parity, so",
1490
+ "`Demi [2, 5, 1]` and `Demi [4, 5, 1]` are different states that agree in phase",
1491
+ "and in both loads. Anything else is refused with `$!!.invalid-demi`, a named",
1492
+ "error, as Figures refuses an unsupported host. This replaces the phase-only",
1493
+ "`Demi [phase, L, R]` of earlier versions, where `phase` was 1 or 2 and the",
1494
+ 'number of applications was forgotten: `Demi [2, 5, 3]` used to mean "an even',
1495
+ 'number of applications, left next", and it now means exactly two. Nothing converts an old state to a new one, because the old one never recorded',
1496
+ "its Count. `Demi [0, 0, 0]` is the neutral start.",
1497
+ "",
1498
+ "**Count and phase.** `d.count` and `d.#` are the stored `C`. The phase is a",
1499
+ "derived field, `d.phase`, a two-state reading of the Count's parity and never",
1500
+ "the integer `C %% 2`: 2 when `C` is even, `C = 0` included, left next, and 1",
1501
+ "when it is odd, right next. It is a Count rather than all or nil because a",
1502
+ "field cannot hold nil, and a Count keeps the odd phase present. It is derived,",
1503
+ "not independent state: it is written only together with `C`, so the fields are",
1504
+ "the whole state and two Demis are `=` exactly when their Count and loads are.",
1505
+ "States with the same phase and loads but different Counts stay distinguishable.",
1475
1506
  "",
1476
1507
  "**Observers.** A Demi declares its own Count, Size and residual (011.20): its",
1477
- "phase, its total load L+R, and the signed difference L−R. An aggregate",
1508
+ "Count `C`, its total load `L+R` and the signed difference `L−R`. An aggregate",
1478
1509
  "otherwise observes its elements, and a Demi has none, so without these it",
1479
- "would observe as 0, 1, 0. Its fourth hash derives from them like any Frame's,",
1480
- "so `d.####` rebuilds the same Demi.",
1481
- "",
1482
- "**Application**, `d x`: observe x's Size once, deposit it into the active load,",
1483
- "flip the phase. A Size of zero still flips. If x has no Size, its failure is",
1484
- "the answer rather than a deposit. It is a mutating method, `apply_`, so",
1485
- "through a name, `d x` is a functional update: it answers a new Demi and leaves",
1486
- "d unchanged, holding exactly the same three fields.",
1510
+ "would observe as 0, 1, 0. Its fourth hash is not declared: no class can",
1511
+ "declare `.####`. The derivation from the three observers cannot tell an empty",
1512
+ "host from a Demi of Count zero, because both read 0, 0, 0, and it answers nil",
1513
+ "for either. A Demi of Count zero is a present state, so the fourth hash",
1514
+ "recognizes an instance of this class intrinsically (007.25e,",
1515
+ "`lib/frames/fourth-hash.ts`): a Frame whose stored `count`, `left` and `right`",
1516
+ "are Counts and which is `==` to the Demi this constructor builds from them",
1517
+ "answers that fresh reconstruction, an equal instance for every `C`. Nothing of",
1518
+ "the source runs, so a foreign aggregate that forges `#`, `##`, `###` or a",
1519
+ "`.####` method gets only the ordinary derived fourth hash. `[].####` and",
1520
+ "`0.####` stay nil: those are hosts with no children, and a host with no",
1521
+ "children has no Demi.",
1522
+ "",
1523
+ "**Application**, `d x`: observe x's Size once, deposit it into the channel the",
1524
+ "phase selects (left in phase 2, right in phase 1) and add one to the Count,",
1525
+ "which flips the phase. A Size of zero still counts. If x has no Size, its",
1526
+ "failure is the answer rather than a deposit. It is a mutating method, `apply_`,",
1527
+ "so through a name, `d x` is a functional update: it answers a new Demi and",
1528
+ "leaves d unchanged.",
1487
1529
  "",
1488
1530
  "**Scaling**, `d.scale_ k`: multiply both loads by a Count k, keeping the",
1489
- "phase. It is the numerical shadow of Star: `(x * y).####` is",
1490
- "`x.####.scale_ (y.##)` for a nonempty host x. `scale_` stays, as the name the",
1491
- "fourth hash and Star correspondence use; `d * k` now answers the same Demi",
1492
- "through the operator below.",
1531
+ "Count. It is the numerical shadow of Star: `(x * y).####` is",
1532
+ "`x.####.scale_ (y.##)` for a nonempty host x, Count included. `scale_` stays,",
1533
+ "as the name the fourth hash and Star correspondence use; `d * k` answers the",
1534
+ "same Demi through the operator below.",
1493
1535
  "",
1494
1536
  "**Arithmetic**, `d + x`, `d - x` and `d * x` (015.11). A class answers an",
1495
1537
  "operator by declaring a method under its name, found on the operand and its",
@@ -1498,197 +1540,300 @@ export const HC_SOURCES = new Map([
1498
1540
  "is running. All three **construct a fresh Demi state** from the one Size",
1499
1541
  "observation `x.##` of their operand, keeping Figure 008's distinction between",
1500
1542
  "construction and observation. They are **fixed-channel load transformations**",
1501
- "on the two-load shadow, consistent with what a `RotorRouter`",
1502
- "(`hc/rotor-router.hc`) does to its channel loads: `+` and `-` add `x.##` to one",
1503
- "fixed channel's load the way a route adds a Frame's Size to the channel it lands",
1504
- "in, and `*` is the Star shadow `scale_`. These are correspondences, not a claim",
1505
- "that the Router declares named `+`, `-` or `*` methods: the Router declares only",
1506
- "`apply_` (alternating route-and-flip), `.#`, `.##` and `.###` (its phase, total",
1507
- "load and signed residual). None of the three Demi operators is application: none",
1508
- "flips the phase, and each answers a fresh value and leaves `d` as it was.",
1543
+ "on the two-load shadow, consistent with the channel loads of a `RotorRouter`",
1544
+ "(`hc/rotor-router.hc`): `+` and `-` add `x.##` to one fixed channel's load the",
1545
+ "way a route adds a Frame's Size to the channel it lands in, and `*` is the Star",
1546
+ "shadow `scale_`. These are correspondences, not a claim that the Router",
1547
+ "declares named `+`, `-` or `*` methods. None of the three is application: **all",
1548
+ "keep `C`** and so the phase, and each answers a fresh value and leaves `d` as it",
1549
+ "was. Because they change loads without an application, they can reach a state",
1550
+ "no run of applications reaches, such as `C = 0` with a nonzero load.",
1509
1551
  "",
1510
1552
  "- `d + x` is the **tally** operator: it deposits `x.##` on the **right**,",
1511
- " `Demi [p, L, R + x.##]`. This is the transformation a route into the router's",
1512
- " right channel induces on the loads — that channel's load grows by the routed",
1513
- " Frame's Size — but it targets a fixed channel without flipping the phase,",
1514
- " rather than invoking the Router's alternating `apply_`. A sizeless host's",
1515
- " failure is the answer, as it is for application.",
1553
+ " `Demi [C, L, R + x.##]`. A sizeless host's failure is the answer, as it is for",
1554
+ " application. It is `d.deposit-right_ (x.##)`, a load-only functional update.",
1516
1555
  "- `d - x` is the **alternator** operator: it deposits on the **left**,",
1517
- " `Demi [p, L + x.##, R]`, the load transformation a route into the left channel",
1518
- " induces. It is not subtraction: a deposit only ever adds, so a load never goes",
1519
- " negative and stays a whole Count. Right deposition lowers the signed residual",
1520
- " `L − R` and left deposition raises it, the reverse of ordinary signed-scalar",
1521
- " `+` and `-`.",
1556
+ " `Demi [C, L + x.##, R]`, as `d.deposit-left_ (x.##)`. It is not subtraction: a deposit only ever adds, so",
1557
+ " a load never goes negative and stays a whole Count. Right deposition lowers",
1558
+ " the signed residual `L − R` and left deposition raises it, the reverse of",
1559
+ " ordinary signed-scalar `+` and `-`.",
1522
1560
  "- `d * x` is the **inlay** operator: it scales both loads by the operand's Size",
1523
- " `x.##`, `Demi [p, sL, sR]` for `s = x.##`, keeping the phase. It reads the",
1524
- " operand through the one Size observer, as `+` and `-` do, so any sized Frame",
1525
- " scales a Demi, not only a bare Count. A sizeless host's failure is the answer,",
1526
- " as it is for application. Because `x.##` is always a nonnegative whole Count",
1527
- " when present, the loads stay whole Counts and the result is a valid Demi. It",
1528
- " is literally `d.scale_ (x.##)`: `*` reads the Size, then hands it to `scale_`,",
1529
- " which is the Star shadow (`(x * y).####` is `x.####.scale_ (y.##)` for a",
1530
- " nonempty host x) and already takes a Size. Delegating to `scale_` builds the",
1531
- " fresh Demi by a load-only functional update, never naming the `Demi`",
1532
- " constructor inside the method, so a unit-taggable operand such as a decimal",
1533
- " cannot shadow the constructor through the argument scope; `D * 2.5` scales by",
1534
- " `(2.5).## = 2`.",
1535
- "",
1536
- "None of these is sequential application: `d x` deposits in the active channel",
1537
- "and flips the phase, while `+`, `-` and `*` choose a channel explicitly and",
1538
- "keep it. So `+` and `-` reach states a run cannot, a phase-2 Demi with a load",
1539
- "on the odd side, and `*` is the Star shadow, not a repeated deposit.",
1540
- "",
1541
- "**No division (015.11).** A Demi declares **no** `/` operator. Division is not a",
1542
- "Router construction: the router constructs tally, alternator and inlay — Count,",
1543
- "residual and Size — and nothing in that native structure earns a quotient. The",
1544
- "earlier signed-ratio `d / x` (015.02) and the Size-uniform `d / x` (015.09a)",
1545
- "are both removed. There is no modular Spin, renamed quotient, `phase`, or other",
1546
- "division surrogate in their place. A `D / x` now falls back to the global `/`",
1547
- "operator (`lib/ops/math.ts`), which has no numeric meaning for a non-numeric",
1548
- "Demi left operand and **answers nil**; it does **not** silently preserve a Demi",
1549
- "signed quotient through another path. An operand that is already an error still",
1550
- "propagates, left operand first, as it does for `+`, `-` and `*`. This removes",
1551
- "only the Demi-specific operator: the global language `/` and `hc/figures.hc`'s",
1552
- "`spin` observation (signed residual over a positive Count, on any host) are",
1553
- "untouched.",
1554
- "",
1555
- "**Compatibility (015.11).** The three constructive operators `+`, `-` and `*`",
1556
- "read their operand through the one Size observer `x.##`; `+` and `-` are",
1557
- "unchanged from 015.02, and `*` keeps its 015.09a Size-uniform domain. `D * 3` is",
1558
- "unchanged, because `3.## = 3`; a non-Count sized operand such as another Demi,",
1559
- "an aggregate, or a decimal scales by its Size (`D * 2.5` scales by `2`, since",
1560
- "`(2.5).## = 2`); and a sizeless operand propagates its own failure. `scale_` is",
1561
- "unchanged and still takes a Count directly; `*` equals `d.scale_ (x.##)` for",
1562
- "every sized `x`. The only removal is the Demi `/` operator: a call that",
1563
- "previously answered a signed Spin, such as `D / 2`, is no longer a Demi",
1564
- "operation.",
1565
- "",
1566
- "**Text.** A Demi prints as what it is, an aggregate of fields and methods, and",
1567
- "that reads back as the same Demi. As text it reads `Demi(<>,12,3)`, with the",
1568
- "phase spelled as the orientation it stands for.",
1561
+ " `x.##`, `Demi [C, sL, sR]` for `s = x.##`, keeping `C`. It reads the operand",
1562
+ " through the one Size observer, as `+` and `-` do, so any sized Frame scales a",
1563
+ " Demi, not only a bare Count. It is literally `d.scale_ (x.##)`.",
1564
+ "",
1565
+ "None of the three names the `Demi` constructor inside its method. A bare name",
1566
+ "in a method is looked up on the argument first (spec 7), and a decimal is",
1567
+ "unit-taggable, so inside `d + 2.5` the name `Demi` read `2.5.Demi`, a tagged",
1568
+ "number, and applying that to `[C, L, R]` was `$!.repetition-domain` (007.25e,",
1569
+ "PR #480 review). Each operator now hands the one Size it observed to a",
1570
+ "load-only functional update on the receiver, `deposit-right_`, `deposit-left_`",
1571
+ "or `scale_`, so `D + 2.5`, `D - 2.5` and `D * 2.5` all read `(2.5).## = 2`.",
1572
+ "`deposit-right_ k` and `deposit-left_ k` take a Count and refuse anything else",
1573
+ "with `$!!.invalid-demi`, since a negative deposit is no Demi.",
1574
+ "",
1575
+ "**Rational readings (007.25).** Because `C` is kept, two exact ratios are read",
1576
+ "from the state. They are unary observations of the stored state, not `/` and",
1577
+ "not `%%`, and they take no divisor. HC runs a method only when it is applied to",
1578
+ "something, so they are applied to nil, `d.size-ratio ()`; any other operand is",
1579
+ "`$!!.unary-observation`, so `d.size-ratio 4` is refused rather than read as a",
1580
+ "division by 4.",
1581
+ "",
1582
+ "- `d.size-ratio ()` is `S / C` for `S = L + R`, exact and nonnegative.",
1583
+ "- `d.residual-ratio ()` is `Δ / C` for `Δ = L − R`, exact and signed.",
1584
+ "",
1585
+ "Both are **nil when `C = 0`**, whatever the loads: the state exists and its Size",
1586
+ "and residual still read, but the ratio is absent, so there is no `0/0`, infinity",
1587
+ "or invented zero. They are different observables and neither replaces Size or",
1588
+ "residual; `C`, `S / C` and `Δ / C` together give back `S` and `Δ`. The answer is",
1589
+ "the language's exact `/`: a FrameRational when not whole, such as `5/2`, which",
1590
+ "the runtime keeps in lowest terms (the improper `6/4` reads `3/2`), and a",
1591
+ "FrameInt when whole, since the runtime collapses a whole rational. It is never a",
1592
+ "float or an integer quotient and remainder. The Count is a number the state",
1593
+ "stores or an application adds to; it is not a Frame-native witness of history,",
1594
+ "and `S / C` and `Δ / C` are arithmetic readings of it, not a construction of",
1595
+ "rational geometry.",
1596
+ "",
1597
+ "**Text.** A Demi prints as what it is, an aggregate of fields and methods. As",
1598
+ "text it reads `Demi(C,L,R)`, with the Count and both loads.",
1599
+ "",
1600
+ "**Channels and division (007.27).** The two loads are the arity-two case of an",
1601
+ "ordered list of channel loads. `Demi [C, loads]` takes a Count and a nonempty",
1602
+ "list of Counts: two loads are this binary Demi, the same instance",
1603
+ "`Demi [C, L, R]` builds, and any other number is a channel Demi. Every Demi",
1604
+ "stores `count` and `loads`; only the binary one also has `left`, `right` and",
1605
+ "`phase`, which it writes together with `loads`. A channel Demi of arity k",
1606
+ "deposits into channel `C mod k`, which for k = 2 is the phase's channel. Its",
1607
+ "Size is the sum of its loads and its residual their alternating sum",
1608
+ "`e0 − e1 + e2 − …`, the list residual, which for two loads is `L − R`. Its",
1609
+ "fourth hash is intrinsic too: a fresh equal Demi of the same arity. Its `*`,",
1610
+ "`scale_` and ratios are as here. Its `+` and `-` follow the residual's signs:",
1611
+ "`-` deposits on the first even load, load 0, raising the residual, and `+` on",
1612
+ "the first odd load, load 1, lowering it, which for two loads are left and",
1613
+ "right; with one load `+` is `$!!.invalid-arity`. Text reads `Demi(C,[e0, e1,",
1614
+ "…])`.",
1615
+ "",
1616
+ "`d ./ n`, also spelled `d / n`, redistributes the Size: it keeps C and the",
1617
+ "total S and deals S Size units round-robin into n channels, so the first",
1618
+ "S mod n hold ⌈S/n⌉ and the rest ⌊S/n⌋. It is idempotent, `(d ./ n) ./ m` is",
1619
+ "`d ./ m`, and equal Count and Size give equal results, so `Demi(3,[5,2])` and",
1620
+ "`Demi(3,[4,3])` divide into the same `Demi(3,[3,2,2])`. It is not scalar",
1621
+ "division and not the ratios: no number is answered. The divisor is a positive",
1622
+ "Count, refused as a list refuses it (`$!.division-by-zero /`,",
1623
+ "`$!.division-domain /`), never read as a Size. `hc/division.hc` is its",
1624
+ "specification, with the list and RotorRouter divisions beside it.",
1569
1625
  "",
1570
1626
  "**Methods read their own state through `_^`.** A bare name inside a method is",
1571
1627
  "looked up on the argument first (spec 7), and a Demi is applied to arbitrary",
1572
1628
  "Frames, so a bare `left` could read the argument's field. `_^` is the receiver",
1573
1629
  "from a method's body, and `_^^` from a block one level in, because carets",
1574
1630
  "count lexically (spec a06). What a branch needs is bound as a local at method",
1575
- "level, where nested blocks read it.",
1576
- "```",
1577
- ".Demi {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.p (__ .0); .l (__ .1); .r (__ .2);",
1578
- " ((((p = 2) : {p = 1}) ? {p ~ (0.<>)}) ? {(l ~ (0.<>)) ? {r ~ (0.<>)}}) ? {[",
1631
+ "level, where nested blocks read it. The file's own names, the constructor",
1632
+ "`Demi` and the helpers `deposit-at` (a cursor that adds a Size at one channel",
1633
+ "index, applied by reduce) and `redistribution` (the round-robin loads of S",
1634
+ "units in n channels), are read the same way, through the scope a caret ladder",
1635
+ "reaches, `(_^^^ .Demi)` from a branch, so an argument's fields never stand in",
1636
+ "for them.",
1637
+ "```",
1638
+ ".deposit-at {.at (_ .0); .by (_ .1); [.index 0; .target at; .amount by; .out [];",
1639
+ " .apply_ {.v _; .i (_^ .index); .t (_^ .target); .a (_^ .amount); .o (_^ .out);",
1640
+ " @out (o ((i = t) ? {v + a} : {v})); @index (i + 1);}]};",
1641
+ ".redistribution {.s (_ .0); .ways (_ .1); .r (s %% ways); .q (((s - r) / ways).##);",
1642
+ " ((ways - r) [q]) | (r [(q + 1)])};",
1643
+ ".binary-demi {.c (_ .0); .l (_ .1); .r (_ .2); .p (((c %% 2) = 0) ? {2} : {1}); [",
1644
+ " .count c;",
1579
1645
  " .phase p;",
1580
1646
  " .left l;",
1581
1647
  " .right r;",
1582
- " .# {_^.phase};",
1648
+ " .loads [l, r];",
1649
+ " .# {_^.count};",
1583
1650
  " .## {_^.left + _^.right};",
1584
1651
  " .### {_^.left - _^.right};",
1585
- " .apply_ {.s (_ .##); .l (_^ .left); .r (_^ .right);",
1586
- " (s ~ (0.<>)) ? {((_^^ .phase) = 2) ? {@left (l + s); @phase 1;} : {@right (r + s); @phase 2;}; _^^} : {s}};",
1652
+ " .apply_ {.s (_ .##); .c (_^ .count); .l (_^ .left); .r (_^ .right); .p (_^ .phase);",
1653
+ " (s ~ (0.<>)) ? {(p = 2) ? {@left (l + s); @loads [(l + s), r]; @phase 1;} : {@right (r + s); @loads [l, (r + s)]; @phase 2;}; @count (c + 1); _^^} : {s}};",
1587
1654
  " .scale_ {.k _; .l (_^ .left); .r (_^ .right);",
1588
- " (k ~ (0.<>)) ? {@left (l * k); @right (r * k); _^^} : {$!!.invalid-scale}};",
1589
- " .+ {.s (_ .##); .p (_^ .phase); .l (_^ .left); .r (_^ .right);",
1590
- " (s ~ (0.<>)) ? {Demi [p, l, (r + s)]} : {s}};",
1591
- " .- {.s (_ .##); .p (_^ .phase); .l (_^ .left); .r (_^ .right);",
1592
- " (s ~ (0.<>)) ? {Demi [p, (l + s), r]} : {s}};",
1655
+ " (k ~ (0.<>)) ? {@left (l * k); @right (r * k); @loads [(l * k), (r * k)]; _^^} : {$!!.invalid-scale}};",
1656
+ " .deposit-right_ {.k _; .l (_^ .left); .r (_^ .right);",
1657
+ " (k ~ (0.<>)) ? {@right (r + k); @loads [l, (r + k)]; _^^} : {$!!.invalid-demi}};",
1658
+ " .deposit-left_ {.k _; .l (_^ .left); .r (_^ .right);",
1659
+ " (k ~ (0.<>)) ? {@left (l + k); @loads [(l + k), r]; _^^} : {$!!.invalid-demi}};",
1660
+ " .+ {.s (_ .##);",
1661
+ " (s ~ (0.<>)) ? {(_^^ .deposit-right_ s)} : {s}};",
1662
+ " .- {.s (_ .##);",
1663
+ " (s ~ (0.<>)) ? {(_^^ .deposit-left_ s)} : {s}};",
1593
1664
  " .* {.s (_ .##);",
1594
1665
  " (s ~ (0.<>)) ? {(_^^ .scale_ s)} : {s}};",
1595
- " .toText {“Demi(” (((_^ .phase) = 2) ? {“<>”} : {“()”}) “,” (_^ .left) “,” (_^ .right) “)”}",
1596
- " ]} : {$!!.invalid-demi}} : {$!!.invalid-demi}};",
1666
+ " ./ {.ways _; .c (_^ .count); .s (_^ .##); .v ([] / ways);",
1667
+ " (v ~ ([].<>)) ? {(_^^^ .Demi) [c, ((_^^^ .redistribution) [s, ways])]} : {v}};",
1668
+ " .size-ratio {.c (_^ .count); .s (_^ .##); .u ((_ = ()) ? {1} : {0});",
1669
+ " (c .> 0) ? {(u = 1) ? {s / c} : {$!!.unary-observation}}};",
1670
+ " .residual-ratio {.c (_^ .count); .d (_^ .###); .u ((_ = ()) ? {1} : {0});",
1671
+ " (c .> 0) ? {(u = 1) ? {d / c} : {$!!.unary-observation}}};",
1672
+ " .toText {“Demi(” (_^ .count) “,” (_^ .left) “,” (_^ .right) “)”}",
1673
+ " ]};",
1674
+ ".channel-demi {.c (_ .0); .e (_ .1); [",
1675
+ " .count c;",
1676
+ " .loads e;",
1677
+ " .# {_^.count};",
1678
+ " .## {(_^ .loads).##};",
1679
+ " .### {(_^ .loads).###};",
1680
+ " .apply_ {.s (_ .##); .c (_^ .count); .e (_^ .loads);",
1681
+ " (s ~ (0.<>)) ? {@loads ((e | ((_^^^ .deposit-at) [(c %% (e.#)), s])) .out); @count (c + 1); _^^} : {s}};",
1682
+ " .scale_ {.k _; .e (_^ .loads);",
1683
+ " (k ~ (0.<>)) ? {@loads (e & {_ * k}); _^^} : {$!!.invalid-scale}};",
1684
+ " .deposit-right_ {.k _; .e (_^ .loads);",
1685
+ " ((k ~ (0.<>)) ? {(e.#) .> 1}) ? {@loads ((e | ((_^^^ .deposit-at) [1, k])) .out); _^^} : {(k ~ (0.<>)) ? {$!!.invalid-arity} : {$!!.invalid-demi}}};",
1686
+ " .deposit-left_ {.k _; .e (_^ .loads);",
1687
+ " (k ~ (0.<>)) ? {@loads ((e | ((_^^^ .deposit-at) [0, k])) .out); _^^} : {$!!.invalid-demi}};",
1688
+ " .+ {.s (_ .##);",
1689
+ " (s ~ (0.<>)) ? {(_^^ .deposit-right_ s)} : {s}};",
1690
+ " .- {.s (_ .##);",
1691
+ " (s ~ (0.<>)) ? {(_^^ .deposit-left_ s)} : {s}};",
1692
+ " .* {.s (_ .##);",
1693
+ " (s ~ (0.<>)) ? {(_^^ .scale_ s)} : {s}};",
1694
+ " ./ {.ways _; .c (_^ .count); .s (_^ .##); .v ([] / ways);",
1695
+ " (v ~ ([].<>)) ? {(_^^^ .Demi) [c, ((_^^^ .redistribution) [s, ways])]} : {v}};",
1696
+ " .size-ratio {.c (_^ .count); .s (_^ .##); .u ((_ = ()) ? {1} : {0});",
1697
+ " (c .> 0) ? {(u = 1) ? {s / c} : {$!!.unary-observation}}};",
1698
+ " .residual-ratio {.c (_^ .count); .d (_^ .###); .u ((_ = ()) ? {1} : {0});",
1699
+ " (c .> 0) ? {(u = 1) ? {d / c} : {$!!.unary-observation}}};",
1700
+ " .toText {“Demi(” (_^ .count) “,” (_^ .loads) “)”}",
1701
+ " ]};",
1702
+ ".Demi {((_ ~ ([].<>)) ? {(__ .#) ~ <2, 3>}) ? {.a __; .c (a .0);",
1703
+ " .boxed (((a.#) = 3) ? {[[a .1, a .2]]} : {[a .1]});",
1704
+ " ((c ~ (0.<>)) ? {(boxed .0) ~ ([].<>)}) ? {.e (boxed .0); .k (e.#);",
1705
+ " ((k .> 0) ? {(e &| {.x _; (x ~ (0.<>)) ? {[]} : {[x]}}).# = 0}) ? {",
1706
+ " (k = 2) ? {binary-demi [c, (e .0), (e .1)]} : {channel-demi [c, (e | [])]}",
1707
+ " } : {$!!.invalid-demi}} : {$!!.invalid-demi}} : {$!!.invalid-demi}};",
1597
1708
  "```",
1598
1709
  "## Construction",
1599
1710
  "",
1600
- "A Demi holds exactly its three fields. Each instance is its own: two built",
1601
- "from the same constructor share nothing",
1711
+ "A Demi holds its Count and its two loads, and the phase that Count fixes. Each",
1712
+ "instance is its own: two built from the same constructor share nothing. The",
1713
+ "neutral start `Demi [0, 0, 0]` is present, in phase 2",
1602
1714
  "```",
1603
- "; .d (Demi [2, 0, 0]);",
1604
- "; [d.phase, d.left, d.right]",
1605
- "# [2, 0, 0]",
1715
+ "; .d (Demi [0, 0, 0]);",
1716
+ "; [d.count, d.phase, d.left, d.right, d.#, d.##, d.###, “” d]",
1717
+ "# [0, 2, 0, 0, 0, 0, 0, “Demi(0,0,0)”]",
1606
1718
  "; .a (Demi [2, 5, 3]); .b (Demi [1, 7, 0]);",
1607
- "; [“” a, “” b, a.left, b.left]",
1608
- "# [“Demi(<>,5,3)”, “Demi((),7,0)”, 5, 7]",
1719
+ "; [“” a, “” b, a.left, b.left, a.phase, b.phase]",
1720
+ "# [“Demi(2,5,3)”, “Demi(1,7,0)”, 5, 7, 2, 1]",
1721
+ "```",
1722
+ "Any Counts are a state. The phase is read from the parity of the Count, never",
1723
+ "from the Count itself: even is phase 2, zero included, and odd is phase 1",
1609
1724
  "```",
1610
- "Anything but three Counts with phase 1 or 2 is refused",
1725
+ "; [0, 1, 2, 3, 4, 5, 100, 101] & {(Demi [_, 5, 3]).phase}",
1726
+ "# [2, 1, 2, 1, 2, 1, 2, 1]",
1727
+ "; [(Demi [2, 5, 3]).#, (Demi [4, 5, 3]).#, (Demi [100, 5, 3]).count, (Demi [100, 5, 3]).phase, (Demi [3, 5, 3]).phase]",
1728
+ "# [2, 4, 100, 2, 1]",
1611
1729
  "```",
1612
- "; Demi [3, 0, 0]",
1613
- "# $!!.invalid-demi",
1614
- "; [Demi [2, (0 - 1), 0], Demi [2, (5 - 3), 0], Demi [2, 0], Demi 5, Demi [(5 - 3), 0, 0]]",
1615
- "# [$!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi]",
1730
+ "A positive Count over empty loads and nonzero loads over a zero Count are both",
1731
+ "states. Anything that is not three Counts is refused",
1732
+ "```",
1733
+ "; [“” (Demi [3, 0, 0]), “” (Demi [0, 3, 0]), “” (Demi [0, 0, 4])]",
1734
+ "# [“Demi(3,0,0)”, “Demi(0,3,0)”, “Demi(0,0,4)”]",
1735
+ "; [Demi [2, (0 - 1), 0], Demi [(0 - 1), 1, 1], Demi [(5 - 3), (5 - 7), 0], Demi [2, 1], Demi 5, Demi [2, 1.5, 0], Demi [2, 1, 0, 0]]",
1736
+ "# [$!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi]",
1616
1737
  "```",
1617
1738
  "## Application",
1618
1739
  "",
1619
- "Each application deposits the argument's Size into the active load and flips",
1620
- "the phase. The receiver is left as it was",
1740
+ "Each application deposits the argument's Size into the channel the phase",
1741
+ "selects and adds one to the Count, which flips the phase. The receiver is left",
1742
+ "as it was",
1621
1743
  "```",
1622
1744
  "; “” (d [5, 3])",
1623
- "# “Demi((),8,0)”",
1745
+ "# “Demi(1,8,0)”",
1624
1746
  "; “” d",
1625
- "# “Demi(<>,0,0)”",
1747
+ "# “Demi(0,0,0)”",
1626
1748
  "; “” (((d 5) 3) 7)",
1627
- "# “Demi((),12,3)”",
1749
+ "# “Demi(3,12,3)”",
1628
1750
  "```",
1629
- "A Size of zero deposits nothing and still flips, in both phases",
1751
+ "A Size of zero deposits nothing and still counts, in both phases",
1630
1752
  "```",
1631
- "; [(d 0).phase, ((d 0) 0).phase, (d 0).left, ((d 0) 0).right]",
1632
- "# [1, 2, 0, 0]",
1753
+ "; [(d 0).count, ((d 0) 0).count, (d 0).phase, ((d 0) 0).phase, (d 0).left, ((d 0) 0).right]",
1754
+ "# [1, 2, 1, 2, 0, 0]",
1633
1755
  "```",
1634
1756
  "Any Frame is applied by its Size, measured without running it: text, the",
1635
1757
  "empty aggregate and all (Size 1 each), nested aggregates, a closure (one per",
1636
1758
  "word, so `{5 + 3}` is 9), empty text, and loads too large for a machine integer",
1637
1759
  "```",
1638
1760
  "; “” ((((((d “hello”) []) <>) [[1, 2], [3]]) {5 + 3}) “”)",
1639
- "# “Demi(<>,15,7)”",
1761
+ "# “Demi(6,15,7)”",
1640
1762
  "; “” ((d 123456789012345678901234567890) 987654321098765432109876543210)",
1641
- "# “Demi(<>,123456789012345678901234567890,987654321098765432109876543210)”",
1763
+ "# “Demi(2,123456789012345678901234567890,987654321098765432109876543210)”",
1642
1764
  "```",
1643
1765
  "A Frame without a Size is not deposited: its failure is the answer",
1644
1766
  "```",
1645
1767
  "; d ([].nope)",
1646
1768
  "# $!.name-missing “...",
1647
1769
  "; “” d",
1648
- "# “Demi(<>,0,0)”",
1770
+ "# “Demi(0,0,0)”",
1649
1771
  "```",
1650
1772
  "Deposit reads the receiver through `_^`, so an argument that holds fields of",
1651
1773
  "the same names deposits by its Size and nothing else",
1652
1774
  "```",
1653
- "; “” (d [.left 50; .phase 1; .s 100; 4])",
1654
- "# “Demi((),4,0)”",
1775
+ "; “” (d [.count 50; .left 99; .phase 1; .s 100; 4])",
1776
+ "# “Demi(1,4,0)”",
1777
+ "; “” ((Demi [2, 5, 3]) [.count 50; .left 99; .right 7; 4])",
1778
+ "# “Demi(3,9,3)”",
1655
1779
  "```",
1656
1780
  "A Demi captured by a closure, mapped, or reduced is applied the same way, and",
1657
1781
  "the captured one stays as it was",
1658
1782
  "```",
1659
- "; .start (Demi [2, 0, 0]); .step {start _};",
1783
+ "; .start (Demi [0, 0, 0]); .step {start _};",
1660
1784
  "; [“” (step 5), “” (step 3), “” start]",
1661
- "# [“Demi((),5,0)”, “Demi((),3,0)”, “Demi(<>,0,0)”]",
1785
+ "# [“Demi(1,5,0)”, “Demi(1,3,0)”, “Demi(0,0,0)”]",
1662
1786
  "; [d, a] & {“” (_ 5)}",
1663
- "# [“Demi((),5,0)”, “Demi((),10,3)”]",
1664
- "; “” ([5, 3, 7] | (Demi [2, 0, 0]))",
1665
- "# “Demi((),12,3)”",
1787
+ "# [“Demi(1,5,0)”, “Demi(3,10,3)”]",
1788
+ "; “” ([5, 3, 7] | (Demi [0, 0, 0]))",
1789
+ "# “Demi(3,12,3)”",
1666
1790
  "```",
1667
1791
  "Through a mutable name, application writes the Demi in place",
1668
1792
  "```",
1669
- "; .m_ (Demi [2, 0, 0]);",
1793
+ "; .m_ (Demi [0, 0, 0]);",
1670
1794
  "; m_ 5;",
1671
- "; “” m_",
1672
- "# “Demi((),5,0)”",
1795
+ "; m_ 3;",
1796
+ "; [“” m_, m_.count, m_.phase]",
1797
+ "# [“Demi(2,5,3)”, 2, 2]",
1798
+ "```",
1799
+ "## Application counts",
1800
+ "",
1801
+ "Starting at Count 0 in phase 2, or at Count 1 in phase 1, applying 5, 3, 7 and 2",
1802
+ "in turn grows the Count by exactly one each time and alternates the phase. The",
1803
+ "Size and residual are the alternating route's, from the left or from the right",
1804
+ "```",
1805
+ "; .chain {.s _; [s, (s 5), ((s 5) 3), (((s 5) 3) 7), ((((s 5) 3) 7) 2)]};",
1806
+ "; .c0 (chain (Demi [0, 0, 0])); .c1 (chain (Demi [1, 0, 0]));",
1807
+ "; [c0 & {_.count}, c0 & {_.phase}, c0 & {_.##}, c0 & {_.###}]",
1808
+ "# [[0, 1, 2, 3, 4], [2, 1, 2, 1, 2], [0, 5, 8, 15, 17], [0, 5, 2, 9, 7]]",
1809
+ "; [c1 & {_.count}, c1 & {_.phase}, c1 & {_.##}, c1 & {_.###}]",
1810
+ "# [[1, 2, 3, 4, 5], [1, 2, 1, 2, 1], [0, 5, 8, 15, 17], [0, -5, -2, -9, -7]]",
1811
+ "```",
1812
+ "The Count and the loads together are the state, and the fourth hash of each step",
1813
+ "is that step, Count included",
1814
+ "```",
1815
+ "; [(c0 & {_.####}) = c0, (c1 & {_.####}) = c1]",
1816
+ "# [<>, <>]",
1673
1817
  "```",
1674
1818
  "## Observers",
1675
1819
  "",
1676
- "A Demi's Count is its phase, its Size the total load and its residual the",
1820
+ "A Demi's Count is its stored Count, its Size the total load and its residual the",
1677
1821
  "signed difference, including a present zero-load Demi in either phase",
1678
1822
  "```",
1679
- "; .e (Demi [1, 12, 3]);",
1680
- "; [e.#, e.##, e.###]",
1681
- "# [1, 15, 9]",
1682
- "; [d.#, d.##, d.###, (Demi [1, 0, 0]).#]",
1683
- "# [2, 0, 0, 1]",
1823
+ "; .e (Demi [3, 12, 3]);",
1824
+ "; [e.#, e.##, e.###, e.phase]",
1825
+ "# [3, 15, 9, 1]",
1826
+ "; [d.#, d.##, d.###, (Demi [1, 0, 0]).#, (Demi [1, 0, 0]).phase]",
1827
+ "# [0, 0, 0, 1, 1]",
1684
1828
  "```",
1685
- "So its fourth hash is the same Demi, however often it is taken. It is equal,",
1686
- "not identical: each observation builds a new instance",
1829
+ "Count is `.#`, not phase. The same phase and loads with a different Count are",
1830
+ "different states with the same Size and residual",
1687
1831
  "```",
1688
- "; [e.#### = e, e.#### === e, e.#### == e, ((e.####).####).#### = e]",
1689
- "# [<>, (), <>, <>]",
1690
- "; [d.#### = d, (Demi [1, 0, 0]).#### = (Demi [1, 0, 0])]",
1691
- "# [<>, <>]",
1832
+ "; .f2 (Demi [2, 5, 1]); .f4 (Demi [4, 5, 1]);",
1833
+ "; [f2.phase = f4.phase, f2.## = f4.##, f2.### = f4.###, f2.# = f4.#, f2 = f4, f2 = (Demi [2, 5, 1])]",
1834
+ "# [<>, <>, <>, (), (), <>]",
1835
+ "; [f2.#, f4.#, f2.##, f2.###, f2.phase, f4.phase]",
1836
+ "# [2, 4, 6, 4, 2, 2]",
1692
1837
  "```",
1693
1838
  "A Demi inside an aggregate contributes its declared Size",
1694
1839
  "```",
@@ -1697,101 +1842,183 @@ export const HC_SOURCES = new Map([
1697
1842
  "```",
1698
1843
  "## The fourth hash",
1699
1844
  "",
1700
- "`.####` answers an instance of this class, built from the same source, so it",
1701
- "compares equal to one built here",
1845
+ "`.####` of a Demi is that Demi, however often it is taken. It is equal, not",
1846
+ "identical: each observation builds a new instance. Its Count is kept for every",
1847
+ "Count, including zero",
1848
+ "```",
1849
+ "; [e.#### = e, e.#### === e, e.#### == e, ((e.####).####).#### = e, (e.####).# = e.#]",
1850
+ "# [<>, (), <>, <>, <>]",
1851
+ "; [d.#### = d, (Demi [1, 0, 0]).#### = (Demi [1, 0, 0]), (Demi [100, 5, 3]).####.count, (Demi [0, 3, 0]).#### = (Demi [0, 3, 0])]",
1852
+ "# [<>, <>, 100, <>]",
1853
+ "; [f2.####.# , f4.####.#, f2.#### = f4.####, f2.#### = f2]",
1854
+ "# [2, 4, (), <>]",
1702
1855
  "```",
1703
- "; [[5, 3].#### = (Demi [2, 5, 3]), “hello”.#### = (Demi [1, 3, 2]), [0].#### = (Demi [1, 0, 0])]",
1856
+ "`.####` of a host answers an instance of this class, built from the same source,",
1857
+ "so it compares equal to one built here. The host's whole Count is kept: it is",
1858
+ "not reduced to its parity",
1859
+ "```",
1860
+ "; [[5, 3].#### = (Demi [2, 5, 3]), “hello”.#### = (Demi [5, 3, 2]), [0].#### = (Demi [1, 0, 0])]",
1704
1861
  "# [<>, <>, <>]",
1862
+ "; [[5, 3].####.#, “hello”.####.#, “hello”.####.phase, [5, 3, 7].####.#, [5, 3, 7].####.phase]",
1863
+ "# [2, 5, 1, 3, 1]",
1705
1864
  "; “” [5, 3, 7].####",
1706
- "# “Demi((),12,3)”",
1865
+ "# “Demi(3,12,3)”",
1866
+ "```",
1867
+ "Hosts whose Counts differ by an even number do not share a fourth hash, though",
1868
+ "they share phase and, here, loads",
1869
+ "```",
1870
+ "; [[5, 3].#### = [5, 3, 0, 0].####, [5, 3].####.phase = [5, 3, 0, 0].####.phase, [5, 3].####.## = [5, 3, 0, 0].####.##]",
1871
+ "# [(), <>, <>]",
1707
1872
  "```",
1708
1873
  "It is nil where there is no Demi: an empty host, Count zero, no Count, or no",
1709
- "residual. Properties are not elements, sharing counts each occurrence, and a",
1710
- "group observes as its elements",
1874
+ "residual. A host with no children is not a Demi of Count zero. Properties are",
1875
+ "not elements, sharing counts each occurrence, and a group observes as its",
1876
+ "elements",
1711
1877
  "```",
1712
- "; [[].####, 0.####, ().####, <2,3,5>.####]",
1713
- "# [(), (), (), ()]",
1878
+ "; [[].####, 0.####, ().####, <2,3,5>.####, “”.####]",
1879
+ "# [(), (), (), (), ()]",
1714
1880
  "; .shared [1, 2];",
1715
1881
  "; [[.a 100; 5, 3].#### = [5, 3].####, [shared, shared].#### = (Demi [2, 3, 3]), (5, 3).#### = (Demi [2, 5, 3])]",
1716
1882
  "# [<>, <>, <>]",
1717
1883
  "```",
1884
+ "The two zero-Count cases are different. A constructed `Demi [0, 0, 0]` is a",
1885
+ "present value, while the empty host and the Count 0 have none. They agree on",
1886
+ "Count, Size and residual, so the difference is not read from the observers: the",
1887
+ "fourth hash recognizes an instance of this class (007.25e)",
1888
+ "```",
1889
+ "; [[].# = d.#, [].## = d.##, 0.## = d.##, 0.### = d.###]",
1890
+ "# [<>, (), <>, <>]",
1891
+ "; [[].#### = (), 0.#### = (), d.#### = d, ((Demi [0, 0, 0]).####).count]",
1892
+ "# [<>, <>, <>, 0]",
1893
+ "```",
1894
+ "Zero-Count Demis reached without an application are present too, and so is",
1895
+ "each functional update of one",
1896
+ "```",
1897
+ "; [“” ((Demi [0, 3, 0]).####), “” ((d + 4).####), “” ((d - 2.5).####), “” ((d * 7).####)]",
1898
+ "# [“Demi(0,3,0)”, “Demi(0,0,4)”, “Demi(0,2,0)”, “Demi(0,0,0)”]",
1899
+ "```",
1900
+ "## Only a Demi is a Demi",
1901
+ "",
1902
+ "No class declares its own `.####`. An aggregate that declares a method under",
1903
+ "that name keeps it as an ordinary property, which the fourth hash never runs:",
1904
+ "its fourth hash is derived from its observers like any other Frame's. So a",
1905
+ "method answering a foreign aggregate, an error, nil, itself, or a write",
1906
+ "changes nothing, and nothing in it runs",
1907
+ "```",
1908
+ "; .noted_ [.n 0; .bump_ {@n (_^.n + 1);}];",
1909
+ "; .Liar [.#### {[.# {0}; .## {0}; .### {0}]}];",
1910
+ "; .Loud [.#### {noted_.bump_ (); Demi [0, 0, 0]}];",
1911
+ "; .Selfish [.#### {_^.####}];",
1912
+ "; .Broken [.#### {[].nope}];",
1913
+ "; [Liar.####, Loud.####, Selfish.####, Broken.####, noted_.n]",
1914
+ "# [(), (), (), (), 0]",
1915
+ "; [“” ([.#### {Demi [9, 9, 9]}; 5, 3].####), [.#### {Demi [9, 9, 9]}; 5, 3].#### = [5, 3].####]",
1916
+ "# [“Demi(2,5,3)”, <>]",
1917
+ "```",
1918
+ "Forged observers do not make a Demi. An aggregate declaring Count, Size and",
1919
+ "residual 0, 0, 0 reads exactly as `Demi [0, 0, 0]` does, and still has no Demi,",
1920
+ "because it is not one; with a nonzero Count it gets the derived Demi of those",
1921
+ "observers, a fresh instance of this class, never the aggregate itself",
1922
+ "```",
1923
+ "; .Zero [.# {0}; .## {0}; .### {0}];",
1924
+ "; .Three [.# {3}; .## {5}; .### {1}];",
1925
+ "; [[Zero.#, Zero.##, Zero.###] = [d.#, d.##, d.###], Zero.####, “” Three.####, Three.#### = Three]",
1926
+ "# [<>, (), “Demi(3,3,2)”, ()]",
1927
+ "```",
1928
+ "Fields named like a Demi's are not enough either. Recognition compares the",
1929
+ "whole instance, fields and methods, by typed equality `==` with the Demi the",
1930
+ "constructor builds from the stored `count`, `left` and `right`. So a bare record",
1931
+ "of those fields, one whose phase disagrees with its Count, one whose Count is a",
1932
+ "decimal, and one that adds a field are foreign, and with Count zero they have",
1933
+ "no Demi",
1934
+ "```",
1935
+ "; .Rec [.count 0; .phase 2; .left 0; .right 0];",
1936
+ "; .Fake [.count 0; .phase 1; .left 0; .right 0; .# {_^ .count}; .## {_^ .left + _^ .right}; .### {_^ .left - _^ .right}];",
1937
+ "; .Dec [.count 0.0; .phase 2; .left 0; .right 0; .# {0}; .## {0}; .### {0}];",
1938
+ "; [Rec.####, Fake.####, Dec.####, [.extra 1; .count 0; .left 0; .right 0].####]",
1939
+ "# [(), (), (), ()]",
1940
+ "```",
1941
+ "A Demi with a Count is recognized as one, and what it answers is a fresh",
1942
+ "reconstruction from its stored state, equal to it and not it",
1943
+ "```",
1944
+ "; [(Demi [3, 5, 1]).#### == (Demi [3, 5, 1]), (Demi [3, 5, 1]).#### === (Demi [3, 5, 1]), “” (Demi [3, 5, 1]).####]",
1945
+ "# [<>, (), “Demi(3,5,1)”]",
1946
+ "```",
1718
1947
  "## Observing commutes with applying",
1719
1948
  "",
1720
1949
  "For a nonempty host X, observing X Y is applying X's Demi to Y, and both equal",
1721
- "the observation of the array X Y constructs",
1950
+ "the observation of the array X Y constructs, with Count one greater",
1722
1951
  "```",
1723
1952
  "; .X [5, “ab”, [1, 2]];",
1724
- "; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3})]",
1725
- "# [<>, <>, <>]",
1953
+ "; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3}), (X 7).####.# = (X.####.# + 1)]",
1954
+ "# [<>, <>, <>, <>]",
1726
1955
  "```",
1727
1956
  "The empty host is the boundary. `[].####` is nil, a choice of convention",
1728
1957
  "(011.15g) rather than a theorem, and applying nil answers the argument, so",
1729
- "the equation as written fails there. Lifting the empty host to the zero-load",
1730
- "Demi in phase 2 restores it: that is the initialized-router reading, and it is",
1731
- "also what a reduce starts from",
1958
+ "the equation as written fails there. Lifting the empty host to the Demi of",
1959
+ "Count zero restores it: that is the initialized-router reading, and it is also",
1960
+ "what a reduce starts from",
1732
1961
  "```",
1733
- "; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [2, 0, 0]) 7), ([] 7).#### = ([7] | (Demi [2, 0, 0]))]",
1962
+ "; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [0, 0, 0]) 7), ([] 7).#### = ([7] | (Demi [0, 0, 0]))]",
1734
1963
  "# [(), <>, <>]",
1735
- "; [] | (Demi [2, 0, 0]) = (Demi [2, 0, 0])",
1964
+ "; [] | (Demi [0, 0, 0]) = (Demi [0, 0, 0])",
1736
1965
  "# <>",
1737
1966
  "```",
1738
1967
  "## Scaling and Star",
1739
1968
  "",
1740
- "Scaling multiplies both loads and keeps the phase: zero annihilates, one is",
1741
- "the identity, and scaling composes",
1969
+ "Scaling multiplies both loads and keeps the Count and phase: zero annihilates,",
1970
+ "one is the identity, and scaling composes",
1742
1971
  "```",
1743
- "; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6)]",
1744
- "# [“Demi((),24,6)”, “Demi((),0,0)”, <>, <>]",
1972
+ "; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6), (e.scale_ 2).#]",
1973
+ "# [“Demi(3,24,6)”, “Demi(3,0,0)”, <>, <>, 3]",
1745
1974
  "; e.scale_ (0 - 2)",
1746
1975
  "# $!!.invalid-scale",
1747
1976
  "```",
1748
- "It is the shadow of Star on a nonempty host",
1977
+ "It is the shadow of Star on a nonempty host, Count included",
1749
1978
  "```",
1750
- "; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##))]",
1751
- "# [<>, <>]",
1979
+ "; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##)), ([5, 3] * 3).####.# = [5, 3].####.#]",
1980
+ "# [<>, <>, <>]",
1752
1981
  "```",
1753
1982
  "## Arithmetic",
1754
1983
  "",
1755
1984
  "Three operators act on a Demi's state, each reading its operand through the one",
1756
1985
  "Size observer `x.##`. They are fixed-channel load transformations consistent",
1757
1986
  "with a `RotorRouter`'s channel loads (`hc/rotor-router.hc`), not named Router",
1758
- "methods: the Router declares only `apply_`, `.#`, `.##` and `.###`. `+`, `-`",
1759
- "and `*` **construct a fresh Demi** from observations of their operands: `+` is",
1760
- "tally, depositing `x.##` on the right; `-` is alternator, depositing on the",
1761
- "left; and `*` is inlay, scaling both loads by `x.##` through `scale_`, the Star",
1762
- "shadow. Each keeps the phase, answers a fresh value and leaves its operand as it",
1763
- "was, so they compose by nesting. There is **no** `/`: a Demi declares no",
1764
- "division operator",
1987
+ "methods. `+`, `-` and `*` **construct a fresh Demi** from observations of their",
1988
+ "operands: `+` is tally, depositing `x.##` on the right; `-` is alternator,",
1989
+ "depositing on the left; and `*` is inlay, scaling both loads by `x.##` through",
1990
+ "`scale_`, the Star shadow. Each keeps the Count, and so the phase, answers a",
1991
+ "fresh value and leaves its operand as it was, so they compose by nesting",
1765
1992
  "```",
1766
1993
  "; .D (Demi [2, 5, 3]);",
1767
1994
  "; [“” (D + 4), “” (D - 4), “” (D * 3)]",
1768
- "# [“Demi(<>,5,7)”, “Demi(<>,9,3)”, “Demi(<>,15,9)”]",
1995
+ "# [“Demi(2,5,7)”, “Demi(2,9,3)”, “Demi(2,15,9)”]",
1769
1996
  "; [“” ((D + 4) - 2), “” ((D - 2) + 4), “” ((D + 4) * 3)]",
1770
- "# [“Demi(<>,7,7)”, “Demi(<>,7,7)”, “Demi(<>,15,21)”]",
1997
+ "# [“Demi(2,7,7)”, “Demi(2,7,7)”, “Demi(2,15,21)”]",
1771
1998
  "; “” D",
1772
- "# “Demi(<>,5,3)”",
1999
+ "# “Demi(2,5,3)”",
1773
2000
  "```",
1774
- "A deposit keeps the phase, including phase 1, where application would flip it,",
1775
- "and a zero Size deposits nothing while still answering a Demi. The operand is",
1776
- "measured by its Size, so any sized Frame deposits",
2001
+ "A deposit keeps the Count and phase, including phase 1, where application would",
2002
+ "flip it, and a zero Size deposits nothing while still answering a Demi. The",
2003
+ "operand is measured by its Size, so any sized Frame deposits",
1777
2004
  "```",
1778
- "; [(D + 4).#, (D - 4).#, (D * 3).#]",
1779
- "# [2, 2, 2]",
2005
+ "; [(D + 4).#, (D - 4).#, (D * 3).#, (D + 4).count, (D + 4).phase]",
2006
+ "# [2, 2, 2, 2, 2]",
1780
2007
  "; .P (Demi [1, 5, 3]);",
1781
- "; [“” (P + 4), (P + 4).#, “” (P - 4)]",
1782
- "# [“Demi((),5,7)”, 1, “Demi((),9,3)”]",
2008
+ "; [“” (P + 4), (P + 4).#, (P + 4).phase, “” (P - 4)]",
2009
+ "# [“Demi(1,5,7)”, 1, 1, “Demi(1,9,3)”]",
1783
2010
  "; [“” (D + 0), “” (D - 0), “” (D [3, 4])]",
1784
- "# [“Demi(<>,5,3)”, “Demi(<>,5,3)”, “Demi((),12,3)”]",
2011
+ "# [“Demi(2,5,3)”, “Demi(2,5,3)”, “Demi(3,12,3)”]",
1785
2012
  "```",
1786
- "Deposit is not application and deposit is not subtraction. `D x` flips the",
1787
- "phase and `D + x` does not, so they reach different states; `D - x` adds to the",
1788
- "left load and never takes from the right, so a load stays a whole Count and the",
1789
- "signed residual only rises",
2013
+ "Deposit is not application and deposit is not subtraction. `D x` adds one to the",
2014
+ "Count and flips the phase, and `D + x` does not, so they reach different",
2015
+ "states; `D - x` adds to the left load and never takes from the right, so a load",
2016
+ "stays a whole Count and the signed residual only rises",
1790
2017
  "```",
1791
2018
  "; [(D + 4).###, (D - 4).###, D.###]",
1792
2019
  "# [-2, 6, 2]",
1793
- "; [((D 4).# = (D + 4).#), (D 4).###, (D + 4).###]",
1794
- "# [(), 6, -2]",
2020
+ "; [((D 4).# = (D + 4).#), (D 4).###, (D + 4).###, (D 4).#, (D 4).phase]",
2021
+ "# [(), 6, -2, 3, 1]",
1795
2022
  "```",
1796
2023
  "Order of a right then a left deposit does not matter, and scaling after a",
1797
2024
  "balanced deposit is the Star shadow of scaling first",
@@ -1807,15 +2034,59 @@ export const HC_SOURCES = new Map([
1807
2034
  "; [D + ([].nope), D - ([].nope), D * ([].nope)]",
1808
2035
  "# [$!.name-missing “..., $!.name-missing “..., $!.name-missing “...]",
1809
2036
  "```",
2037
+ "## Deposits by Size",
2038
+ "",
2039
+ "`+` and `-` read their operand through the one Size observer as `*` does, so",
2040
+ "any sized Frame deposits its Size: a decimal its truncated magnitude, text its",
2041
+ "characters, an aggregate its element count, a Demi `L + R`, and a closure one",
2042
+ "per word. These are the review's own examples, from `Demi [0, 0, 0]`",
2043
+ "```",
2044
+ "; [(2.5).##, (1.5).##, (0 - 1.5).##]",
2045
+ "# [2, 1, 1]",
2046
+ "; [“” ((Demi [0, 0, 0]) + 2), “” ((Demi [0, 0, 0]) + 2.5), “” ((Demi [0, 0, 0]) - 1.5), “” ((Demi [1, 2, 2]) * 2.5)]",
2047
+ "# [“Demi(0,0,2)”, “Demi(0,0,2)”, “Demi(0,1,0)”, “Demi(1,4,4)”]",
2048
+ "; [“” (D + 2.5), “” (D - 2.5), “” (P + 0.5), “” (P - (0 - 3.5))]",
2049
+ "# [“Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(1,5,3)”, “Demi(1,8,3)”]",
2050
+ "; [“” (D + “abc”), “” (D - [[], []]), “” (D + (Demi [1, 2, 4])), “” (D - {5 + 3}), “” (D + <>), “” (D - [])]",
2051
+ "# [“Demi(2,5,6)”, “Demi(2,7,3)”, “Demi(2,5,9)”, “Demi(2,14,3)”, “Demi(2,5,4)”, “Demi(2,6,3)”]",
2052
+ "```",
2053
+ "Each keeps the full Count, and with it the phase, in both parities; leaves the",
2054
+ "receiver as it was, even through a mutable name; and refuses a sizeless operand",
2055
+ "with its failure",
2056
+ "```",
2057
+ "; [(D + 2.5).#, (D + 2.5).phase, (P - 1.5).#, (P - 1.5).phase, “” D, “” P]",
2058
+ "# [2, 2, 1, 1, “Demi(2,5,3)”, “Demi(1,5,3)”]",
2059
+ "; .q_ (Demi [2, 5, 3]);",
2060
+ "; [“” (q_ + 2.5), “” (q_ - 2.5), “” (q_ * 2.5), “” q_]",
2061
+ "# [“Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(2,10,6)”, “Demi(2,5,3)”]",
2062
+ "; [D + ([2.5].nope), D - ([2.5].nope), (Demi [0, 0, 0]) + ([].nope)]",
2063
+ "# [$!.name-missing “..., $!.name-missing “..., $!.name-missing “...]",
2064
+ "```",
2065
+ "The argument cannot reach the receiver's names. A decimal is unit-taggable,",
2066
+ "`2.5.Demi` is a tagged number, and an aggregate can hold fields named like the",
2067
+ "receiver's or its locals; none of them changes which state is updated, and",
2068
+ "such an aggregate deposits only its elements' Size, here 4",
2069
+ "```",
2070
+ "; (2.5).Demi",
2071
+ "# 2.5.Demi",
2072
+ "; [“” (D + [.Demi 9; .right 99; .left 99; .count 7; .k 50; 4]), “” (D - [.Demi 9; .left 99; .l 99; .s 50; 4])]",
2073
+ "# [“Demi(2,5,7)”, “Demi(2,9,3)”]",
2074
+ "```",
2075
+ "The functional updates behind them take a Count, so a negative or fractional",
2076
+ "deposit is not a Demi",
2077
+ "```",
2078
+ "; [D.deposit-right_ (0 - 1), D.deposit-left_ 2.5, “” (D.deposit-right_ 2), “” (D.deposit-left_ 2), “” D]",
2079
+ "# [$!!.invalid-demi, $!!.invalid-demi, “Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(2,5,3)”]",
2080
+ "```",
1810
2081
  "`*` scales by the operand's Size, so its domain is every sized Frame: a Demi",
1811
2082
  "contributes `L + R`, an aggregate its element count, a decimal its truncated",
1812
2083
  "magnitude, and a zero Size annihilates both loads. `D * 3` is unchanged, since",
1813
- "`3.## = 3`, and the result keeps the phase in either parity",
2084
+ "`3.## = 3`, and the result keeps the Count in either parity",
1814
2085
  "```",
1815
2086
  "; [“” (D * (Demi [1, 2, 4])), “” (D * [[], []]), “” (D * 2.5), “” (D * 0)]",
1816
- "# [“Demi(<>,30,18)”, “Demi(<>,10,6)”, “Demi(<>,10,6)”, “Demi(<>,0,0)”]",
2087
+ "# [“Demi(2,30,18)”, “Demi(2,10,6)”, “Demi(2,10,6)”, “Demi(2,0,0)”]",
1817
2088
  "; [“” (D * 1), (D * 3).#, (P * 3).#, “” (P * 3)]",
1818
- "# [“Demi(<>,5,3)”, 2, 1, “Demi((),15,9)”]",
2089
+ "# [“Demi(2,5,3)”, 2, 1, “Demi(1,15,9)”]",
1819
2090
  "```",
1820
2091
  "The signed-scalar reading misleads: `+` lowers the residual and `-` raises it,",
1821
2092
  "so `D + 4` is not “larger” than `D`, and `D - 4` is not `D` made smaller",
@@ -1823,31 +2094,127 @@ export const HC_SOURCES = new Map([
1823
2094
  "; [(D + 4).### .< D.###, (D - 4).### .> D.###]",
1824
2095
  "# [<>, <>]",
1825
2096
  "```",
1826
- "## No Demi division (015.11)",
2097
+ "Fixed-channel operators change loads without an application, so they keep the",
2098
+ "Count and can leave a zero Count over nonzero loads. That state is present, and",
2099
+ "its Size and residual read",
2100
+ "```",
2101
+ "; .Y ((Demi [0, 0, 0]) + 4);",
2102
+ "; [“” Y, “” ((Demi [0, 0, 0]) - 4), Y.count, Y.phase, Y.##, Y.###]",
2103
+ "# [“Demi(0,0,4)”, “Demi(0,4,0)”, 0, 2, 4, -4]",
2104
+ "; [“” (D * 3), (D.scale_ 2).#, ((D + 4) 1).#, ((D + 4) 1).phase]",
2105
+ "# [“Demi(2,15,9)”, 2, 3, 1]",
2106
+ "```",
2107
+ "## Rational readings",
2108
+ "",
2109
+ "For `C > 0` the Size reading is `S / C` and the residual reading `Δ / C`, two",
2110
+ "different observables. With `C = 2`, `L = 5`, `R = 1` they are 3 and 2. With the",
2111
+ "loads swapped the Size reading is unchanged and the residual reading changes",
2112
+ "sign. With `L = 5`, `R = 0` they are the improper 5/2, neither 2 nor 3",
2113
+ "```",
2114
+ "; .A (Demi [2, 5, 1]); .B (Demi [2, 1, 5]); .D5 (Demi [2, 5, 0]);",
2115
+ "; [[A.##, A.###, A.size-ratio (), A.residual-ratio ()], [B.##, B.###, B.size-ratio (), B.residual-ratio ()], [D5.##, D5.###, D5.size-ratio (), D5.residual-ratio ()]]",
2116
+ "# [[6, 4, 3, 2], [6, -4, 3, -2], [5, 5, 5/2, 5/2]]",
2117
+ "```",
2118
+ "They differ when the loads do. Non-divisible ratios stay exact and the runtime",
2119
+ "reduces them: 6/4 reads 3/2, 8/6 reads 4/3. At `C = 1` they are the Size and the",
2120
+ "residual, and an odd Count works as an even one does",
2121
+ "```",
2122
+ "; [(Demi [2, 3, 2]).size-ratio (), (Demi [2, 3, 2]).residual-ratio ()]",
2123
+ "# [5/2, 1/2]",
2124
+ "; [(Demi [4, 6, 0]).size-ratio (), (Demi [4, 6, 0]).residual-ratio (), (Demi [4, 5, 1]).size-ratio (), (Demi [4, 5, 1]).residual-ratio ()]",
2125
+ "# [3/2, 3/2, 3/2, 1]",
2126
+ "; [(Demi [6, 10, 2]).size-ratio (), (Demi [6, 10, 2]).residual-ratio (), (Demi [3, 5, 1]).size-ratio (), (Demi [3, 5, 1]).residual-ratio ()]",
2127
+ "# [2, 4/3, 2, 4/3]",
2128
+ "; [(Demi [1, 7, 2]).size-ratio (), (Demi [1, 7, 2]).residual-ratio (), (Demi [1, 2, 7]).size-ratio (), (Demi [1, 2, 7]).residual-ratio ()]",
2129
+ "# [9, 5, 9, -5]",
2130
+ "```",
2131
+ "Two Counts with the same phase and loads give different ratios, as they are",
2132
+ "different states: the ratio is what distinguishes `[2, 5, 1]` from `[4, 5, 1]`",
2133
+ "beyond their identity",
2134
+ "```",
2135
+ "; [f2.size-ratio (), f4.size-ratio (), f2.residual-ratio (), f4.residual-ratio ()]",
2136
+ "# [3, 3/2, 2, 1]",
2137
+ "```",
2138
+ "The readings are exact: a third stays a third and multiplying back by the Count",
2139
+ "returns the Size and the residual, with no float or truncation. A whole reading",
2140
+ "is a FrameInt, a non-whole one a FrameRational, and the residual reading is",
2141
+ "signed",
2142
+ "```",
2143
+ "; [(Demi [3, 1, 0]).size-ratio (), (Demi [3, 0, 1]).residual-ratio (), ((Demi [3, 1, 0]).size-ratio ()) * 3]",
2144
+ "# [1/3, -1/3, 1]",
2145
+ "; [(A.size-ratio ()) * A.count = A.##, (A.residual-ratio ()) * A.count = A.###, (B.residual-ratio ()) * B.count = B.###, (D5.size-ratio ()) * D5.count = D5.##]",
2146
+ "# [<>, <>, <>, <>]",
2147
+ "; [A.size-ratio () ~ ((0 - 1).<>), D5.size-ratio () ~ ((1 / 2).<>), D5.size-ratio () ~ ((0 - 1).<>), B.residual-ratio () ~ ((0 - 1).<>), A.size-ratio () ~ (0.<>)]",
2148
+ "# [<>, <>, (), <>, ()]",
2149
+ "```",
2150
+ "An empty state, a balanced nonempty one and a positive Count over empty loads all",
2151
+ "read zero, in either phase",
2152
+ "```",
2153
+ "; [(Demi [2, 0, 0]).size-ratio (), (Demi [1, 0, 0]).size-ratio (), (Demi [3, 0, 0]).residual-ratio ()]",
2154
+ "# [0, 0, 0]",
2155
+ "; [(Demi [2, 3, 3]).size-ratio (), (Demi [2, 3, 3]).residual-ratio (), (Demi [1, 3, 3]).size-ratio (), (Demi [1, 3, 3]).residual-ratio ()]",
2156
+ "# [3, 0, 6, 0]",
2157
+ "```",
2158
+ "Loads too large for a machine integer give the same exact readings",
2159
+ "```",
2160
+ "; .G (Demi [1000000007, 123456789012345678901234567890, 987654321098765432109876543210]);",
2161
+ "; [(G.size-ratio ()) * G.count = G.##, (G.residual-ratio ()) * G.count = G.###, G.###]",
2162
+ "# [<>, <>, -864197532086419753208641975320]",
2163
+ "```",
2164
+ "## Zero Count",
1827
2165
  "",
1828
- "A Demi declares **no** `/` operator: division is not a Router construction. A",
1829
- "`D / x` is not a Demi operation at all; dispatch falls through to the global",
1830
- "`/`, which has no numeric meaning for a non-numeric left operand and answers",
1831
- "nil, never a signed quotient. A zero or a Demi divisor is nil the same way, so",
1832
- "there is no hidden division-by-zero path and no Demi-as-Spin through another",
1833
- "name. Only a failing operand changes the answer, because the global `/`",
1834
- "propagates an operand that is already an error, exactly as `+`, `-` and `*` do",
2166
+ "At `C = 0` neither ratio is defined, so each is nil. The state is still present,",
2167
+ "and its Size and residual still read, including after loads were added without",
2168
+ "any application. This is absence, not a zero, a division error or an infinity",
1835
2169
  "```",
1836
- "; .Dp (Demi [2, 3, 5]); .E (Demi [1, 2, 4]);",
1837
- "; [D / 2, D / 4, Dp / 2, D / E]",
1838
- "# [(), (), (), ()]",
1839
- "; [D / 0, (Demi [2, 4, 4]) / 0, D / (0 - 4), D / 2.5]",
1840
- "# [(), (), (), ()]",
1841
- "; D / ([].nope)",
2170
+ "; .Z0 (Demi [0, 3, 0]); .Z1 (Demi [0, 0, 0]); .Z2 ((Demi [0, 0, 0]) + 4);",
2171
+ "; [[Z0.##, Z0.###, Z0.size-ratio (), Z0.residual-ratio ()], [Z1.##, Z1.###, Z1.size-ratio (), Z1.residual-ratio ()], [Z2.##, Z2.###, Z2.size-ratio (), Z2.residual-ratio ()]]",
2172
+ "# [[3, 3, (), ()], [0, 0, (), ()], [4, -4, (), ()]]",
2173
+ "```",
2174
+ "One application gives the first ratio: from the zero-Count state the Count is 1",
2175
+ "and the readings are the Size and the residual",
2176
+ "```",
2177
+ "; [(Z1 7).count, (Z1 7).size-ratio (), (Z1 7).residual-ratio (), (Z2 3).count, (Z2 3).size-ratio (), (Z2 3).residual-ratio ()]",
2178
+ "# [1, 7, 7, 1, 7, -1]",
2179
+ "```",
2180
+ "## Unary observations",
2181
+ "",
2182
+ "A reading takes no divisor. It is applied to nil, and an operand is refused",
2183
+ "rather than read as the divisor, so it is neither `/` nor `%%`. The class",
2184
+ "declares no `%%`, which answers nil as for any aggregate without one. Its `/`,",
2185
+ "also spelled `./`, is not a ratio either: it redistributes the Size into that",
2186
+ "many channels and keeps the Count (007.27, below), so `A / 4` is a Demi of four",
2187
+ "loads and no number",
2188
+ "```",
2189
+ "; [A.size-ratio 4, A.residual-ratio [], A.size-ratio 0, A.residual-ratio “abc”]",
2190
+ "# [$!!.unary-observation, $!!.unary-observation, $!!.unary-observation, $!!.unary-observation]",
2191
+ "; [“” (A / 4), A %% 4]",
2192
+ "# [“Demi(2,[2, 2, 1, 1])”, ()]",
2193
+ "```",
2194
+ "A reading at the wrong depth fails safe. Inside a branch `_^` is not the",
2195
+ "receiver, so a reading written that way answers `$!.name-missing` and no ratio",
2196
+ "```",
2197
+ "; .Shallow [.count 2; .left 5; .right 1; .size-ratio {.c (_^ .count); (c .> 0) ? {(_^ .left) / c}}];",
2198
+ "; Shallow.size-ratio ()",
1842
2199
  "# $!.name-missing “...",
1843
2200
  "```",
1844
- "The global language `/` and the `spin` observation in `hc/figures.hc` are",
1845
- "untouched: `spin` still answers the signed residual over a positive Count on",
1846
- "any host, and a plain numeric `/` still divides. Removing the Demi operator",
1847
- "removes only the Demi-specific division",
2201
+ "## Law check",
2202
+ "",
2203
+ "For every Count `1..5` and every pair of loads `0..4` (125 states), multiplying",
2204
+ "each reading by the Count gives back the Size and the residual; and for Count 0,",
2205
+ "the 25 states have both readings absent",
1848
2206
  "```",
1849
- "; [“” (6 / 2), (D.### / 2) = 1]",
1850
- "# [“3”, <>]",
2207
+ "; .ccs [1, 2, 3, 4, 5]; .ls [0, 1, 2, 3, 4];",
2208
+ "; .statesP (ccs &| {.c _; ls &| {.l _; ls & {Demi [c, l, _]}}});",
2209
+ "; .lawP {.k _; .c (k.count); [(((k.size-ratio ()) * c) = k.##), (((k.residual-ratio ()) * c) = k.###)]};",
2210
+ "; .checksP (statesP &| lawP);",
2211
+ "; [statesP.#, checksP.#, checksP = (checksP & {<>})]",
2212
+ "# [125, 250, <>]",
2213
+ "; .statesZ (ls &| {.l _; ls & {Demi [0, l, _]}});",
2214
+ "; .lawZ {.k _; [(k.size-ratio () = ()), (k.residual-ratio () = ())]};",
2215
+ "; .checksZ (statesZ &| lawZ);",
2216
+ "; [statesZ.#, checksZ.#, checksZ = (checksZ & {<>})]",
2217
+ "# [25, 50, <>]",
1851
2218
  "```",
1852
2219
  "## A precise regression: a load read at the wrong depth",
1853
2220
  "",
@@ -1869,14 +2236,486 @@ export const HC_SOURCES = new Map([
1869
2236
  "; [r.phase, r.left]",
1870
2237
  "# [1, 5]",
1871
2238
  "```",
2239
+ "## Against a Router",
2240
+ "",
2241
+ "A `RotorRouter` (`hc/rotor-router.hc`) declares its Count as the number of",
2242
+ "children it has routed, `left.# + right.#`, and its Size and residual from the",
2243
+ "Sizes of those children. That is a structural count of the stored channels, not",
2244
+ "a counter and not its phase. A router that routed two children from the empty",
2245
+ "state shares its Count, Size and residual with the Demi that applied the same",
2246
+ "two Sizes, and so does its fourth hash. This is a comparison of readings, not",
2247
+ "an identity: the router keeps the Frames and a Demi forgets them",
2248
+ "```",
2249
+ "; Routers <- './hc/rotor-router.hc';",
2250
+ "; .rr (((Routers.RotorRouter [[], []]) 5) 1);",
2251
+ "; .kk (((Demi [0, 0, 0]) 5) 1);",
2252
+ "; [rr.#, rr.##, rr.###, kk.count, kk.#, kk.##, kk.###, (rr.left.# + rr.right.#), rr.#### = kk.####, rr.phase = kk.phase]",
2253
+ "# [2, 6, 4, 2, 2, 6, 4, 2, <>, <>]",
2254
+ "; .r4 (((rr 7) 2)); .k4 (((kk 7) 2));",
2255
+ "; [r4.#, k4.count, r4.phase, k4.phase, r4.#### = k4.####, (k4.size-ratio ()), (k4.residual-ratio ())]",
2256
+ "# [4, 4, 2, 2, <>, 15/4, 9/4]",
2257
+ "```",
1872
2258
  "## Importing",
1873
2259
  "",
1874
2260
  "Imported, the file binds the same class. The import is an example line, so",
1875
2261
  "the evaluator, which reads this file without a root, never runs it",
1876
2262
  "```",
1877
2263
  "; Demis <- './hc/demi.hc';",
1878
- "; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [2, 0, 0]) 4)]",
1879
- "# [<>, “Demi((),4,0)”]",
2264
+ "; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [0, 0, 0]) 4)]",
2265
+ "# [<>, “Demi(1,4,0)”]",
2266
+ "",
2267
+ ].join("\n"),
2268
+ ],
2269
+ [
2270
+ "hc/division.hc",
2271
+ [
2272
+ "#!/usr/bin/env hc",
2273
+ "```",
2274
+ "Literal division (occurrence/figure 007.26, 007.27, 007.27c)",
2275
+ "",
2276
+ "Division by n, taken literally, is dealing a pile into n channels in turn: the",
2277
+ "first to channel 0, the next to channel 1, and so on round the n channels.",
2278
+ "Parity is the case n = 2. Nothing about it needs a host divisor, a quotient",
2279
+ "type or a fraction; it redistributes what is there and keeps its total.",
2280
+ "",
2281
+ "`x ./ n` is that dealing for three receivers. `./` is the dotted spelling of `/`",
2282
+ '(GRAMMAR "Mathematical Operators"), so `x / n` means the same, and a pair of',
2283
+ "numbers keeps its exact numeric division: `6 ./ 3` is 2 and `7 ./ 2` is 7/2.",
2284
+ "The divisor is always the channel Count itself: a positive Count, never a Size",
2285
+ "read from some other Frame.",
2286
+ "",
2287
+ "- **A list** (an array or a group) deals its immediate elements whole, in",
2288
+ " order, into n channels: the element at index i goes to channel i mod n.",
2289
+ " Elements are the same Frames, never copied, evaluated, measured or",
2290
+ " flattened, so identity, nesting and duplicates are kept. Properties are not",
2291
+ " elements and are not dealt. The answer is a `RotorRouter` of those n",
2292
+ " channels, read as `.channels`, not a bare list of lists (007.27c): a list",
2293
+ " whose children happen to be lists is a plain list, and a router keeps its",
2294
+ " channels as channels, so dividing the answer again re-deals the same Frames.",
2295
+ " The dealing is native, in `/`.",
2296
+ "- **A RotorRouter** (`hc/rotor-router.hc`) keeps the Frames it routed, so it",
2297
+ " re-deals them: it reconstructs the order they were routed in from its",
2298
+ " channels, which a round-robin history fixes, and routes that history through",
2299
+ " a fresh router of n channels. Its Count is unchanged and its next route goes",
2300
+ " to channel C mod n.",
2301
+ "- **A Demi** (`hc/demi.hc`) forgot its Frames and kept only their Sizes, so it",
2302
+ " deals Size units. `D ./ n` keeps the Count C and the total Size S and",
2303
+ " canonicalizes the loads to S units dealt round-robin into n channels, so the",
2304
+ " first S mod n channels hold ⌈S/n⌉ and the rest ⌊S/n⌋. Its next application",
2305
+ " deposits into channel C mod n.",
2306
+ "",
2307
+ "Router and list deal whole Frames, and a Demi deals Size units. Both conserve",
2308
+ "the summed Size, but their channel loads differ in general: children of Sizes",
2309
+ "5 and 2 dealt whole into two channels load them 5 and 2, while a Demi of Size 7",
2310
+ "normalizes to 4 and 3. No law makes them commute, and none is claimed here.",
2311
+ "",
2312
+ "Refusals are the native ones for all three: a divisor of zero is",
2313
+ "`$!.division-by-zero /`, as it is for numbers, and anything but a Count is",
2314
+ "`$!.division-domain /`, a negative or fractional number, a decimal, text, an",
2315
+ "aggregate or a Demi included. A divisor above both 1,000,000 and the element count is `$!.repetition-size 1000000`, checked before anything is built; up to the element count is always allowed, so the answer stays proportional to the list.",
2316
+ "```",
2317
+ "```",
2318
+ "## Lists",
2319
+ "",
2320
+ "Seven Frames dealt into three channels: the element at index i goes to channel",
2321
+ "i mod 3. Nested arrays, an aggregate with a property, a closure and a group are",
2322
+ "each one element, dealt whole. The answer is the router of those channels",
2323
+ "```",
2324
+ "; .A [1, [2]]; .B “b”; .C {5 + 3}; .D [.k 9; 4]; .E 5; .F (6, 7); .G 7;",
2325
+ "; .xs [A, B, C, D, E, F, G];",
2326
+ "; “” (xs ./ 3)",
2327
+ "# “RotorRouter([[[1, [2]], [.k 9; 4], 7], [“b”, 5], [{ 5 + 3 }, (6, 7)]])”",
2328
+ "; .t ((xs ./ 3).channels);",
2329
+ "; [t, t & {_.#}, (xs / 3) = (xs ./ 3), ((t .0) .1).k, (xs ./ 3).#]",
2330
+ "# [[[[1, [2]], [.k 9; 4], 7], [“b”, 5], [{ 5 + 3 }, (6, 7)]], [3, 2, 2], <>, 9, 7]",
2331
+ "```",
2332
+ "Each channel holds the same Frames, in their original order, each once. A",
2333
+ "Frame that occurs twice is dealt twice, and both are it",
2334
+ "```",
2335
+ "; [(t .0) &| {[_ === A]}, (t .2) &| {[_ === C]}, (t &| {_}).#, (t &| {_}) = [A, D, G, B, E, C, F]]",
2336
+ "# [[<>, (), ()], [<>, ()], 7, <>]",
2337
+ "; [([A, A, A] ./ 2).channels, ([A, A, A] ./ 2).channels &| {_} &| {[_ === A]}]",
2338
+ "# [[[[1, [2]], [1, [2]]], [[1, [2]]]], [<>, <>, <>]]",
2339
+ "```",
2340
+ "Two channels are the binary router, with its `left`, `right` and `phase`. One",
2341
+ "channel is the whole list, and more channels than elements leave the last ones",
2342
+ "empty. An empty list deals into n empty channels; empty elements are dealt",
2343
+ "like any other",
2344
+ "```",
2345
+ "; [“” ([1, 2, 3] ./ 2), ([1, 2, 3] ./ 2).left, ([1, 2, 3] ./ 2).phase]",
2346
+ "# [“RotorRouter([1, 3],[2])”, [1, 3], 1]",
2347
+ "; [(xs ./ 1).channels, ([1, 2] ./ 5).channels, ([] ./ 3).channels, ([[], []] ./ 2).channels]",
2348
+ "# [[[[1, [2]], “b”, { 5 + 3 }, [.k 9; 4], 5, (6, 7), 7]], [[1], [2], [], [], []], [[], [], []], [[[]], [[]]]]",
2349
+ "```",
2350
+ "Properties are not elements, so they are not dealt. A group deals its elements",
2351
+ "too, and its channels are arrays",
2352
+ "```",
2353
+ "; [([.k 1; 1, 2, 3] ./ 2).channels, ((1, 2, 3) ./ 2).channels]",
2354
+ "# [[[1, 3], [2]], [[1, 3], [2]]]",
2355
+ "```",
2356
+ "The channel Counts are the canonical dealing: for seven elements into three",
2357
+ "channels they are 3, 2, 2, whatever the elements are",
2358
+ "```",
2359
+ "; [(xs ./ 3).channels & {_.#}, ((7 [0]) ./ 3).channels & {_.#}, ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ./ 4).channels & {_.#}]",
2360
+ "# [[3, 2, 2], [3, 2, 2], [3, 3, 2, 2]]",
2361
+ "```",
2362
+ "## Dividing a division (007.27c)",
2363
+ "",
2364
+ "A division keeps its channels as channels, so dividing it again reads them",
2365
+ "breadth-first, the first of each channel, then the second of each, and deals",
2366
+ "that sequence: `(X ./ n) ./ m` is `X ./ m`, the same Frames in the same",
2367
+ "order, with no extra nesting. Dividing by the same n again changes nothing",
2368
+ "```",
2369
+ "; .X [A, 2, 3, 4, 5, 6];",
2370
+ "; [“” (X ./ 2), “” ((X ./ 2) ./ 2), ((X ./ 2) ./ 2) = (X ./ 2), ((X ./ 2) ./ 3) = (X ./ 3), ((X ./ 3) ./ 2) = (X ./ 2)]",
2371
+ "# [“RotorRouter([[1, [2]], 3, 5],[2, 4, 6])”, “RotorRouter([[1, [2]], 3, 5],[2, 4, 6])”, <>, <>, <>]",
2372
+ "; [((X ./ 2) ./ 3).channels, (((X ./ 2) ./ 3).channels .0 .0) === A]",
2373
+ "# [[[[1, [2]], 4], [2, 5], [3, 6]], <>]",
2374
+ "```",
2375
+ "A plain list whose children are lists is not a division: its two children are",
2376
+ "two whole Frames, dealt as such, even when they look like channels",
2377
+ "```",
2378
+ "; .N [[1, 3, 5], [2, 4, 6]];",
2379
+ "; [“” (N ./ 2), (N ./ 2).left .0 = [1, 3, 5], (N ./ 2).# , “” ((N ./ 2) ./ 2)]",
2380
+ "# [“RotorRouter([[1, 3, 5]],[[2, 4, 6]])”, <>, 2, “RotorRouter([[1, 3, 5]],[[2, 4, 6]])”]",
2381
+ "```",
2382
+ "Uneven channels read back in dealt order: seven Frames into three channels,",
2383
+ "then into one, give the seven in order; into two they are dealt again from",
2384
+ "that order",
2385
+ "```",
2386
+ "; .Y [1, 2, 3, 4, 5, 6, 7];",
2387
+ "; [“” (Y ./ 3), (((Y ./ 3) ./ 1).channels .0) = Y, “” ((Y ./ 3) ./ 2), ((Y ./ 3) ./ 2) = (Y ./ 2)]",
2388
+ "# [“RotorRouter([[1, 4, 7], [2, 5], [3, 6]])”, <>, “RotorRouter([1, 3, 5, 7],[2, 4, 6])”, <>]",
2389
+ "```",
2390
+ "Channels that no round-robin history left have no dealt order to read, so no",
2391
+ "router holds them and they are not divided: the constructor refuses them, and",
2392
+ "a plain list of such lists is a plain list",
2393
+ "```",
2394
+ "; Routers <- './hc/rotor-router.hc';",
2395
+ "; .RotorRouter Routers.RotorRouter;",
2396
+ "; [RotorRouter [[1], [2, 3]], ([[1], [2, 3]] ./ 2).channels]",
2397
+ "# [$!!.invalid-router, [[[1]], [[2, 3]]]]",
2398
+ "```",
2399
+ "## Refusals",
2400
+ "",
2401
+ "The divisor is a positive Count. Zero is division by zero, and anything else is",
2402
+ "outside the domain, whatever its Size: a negative or fractional number, a",
2403
+ "decimal, text, an aggregate, a Demi. A divisor that is already an error is",
2404
+ "answered as it is",
2405
+ "```",
2406
+ "; [[1, 2] ./ 0, [1, 2] ./ (3 - 1), [1, 2] ./ (0 - 2), [1, 2] ./ (1 / 2), [1, 2] ./ 1.5, [1, 2] ./ “two”, [1, 2] ./ [2]]",
2407
+ "# [$!.division-by-zero /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /]",
2408
+ "; [1, 2] ./ (1 / 0)",
2409
+ "# $!.division-by-zero /",
2410
+ "; [[1, 2] ./ (2 ** 30), [1, 2] ./ 1000001, ([1] ./ 1000).channels.#]",
2411
+ "# [$!.repetition-size 1000000, $!.repetition-size 1000000, 1000]",
2412
+ "```",
2413
+ "Numbers keep exact numeric division, and a Frame that is neither a number nor",
2414
+ "an ordered list still answers nil",
2415
+ "```",
2416
+ "; [6 ./ 3, 7 ./ 2, 7 / 2, “abcd” ./ 2, <1, 2> ./ 2]",
2417
+ "# [2, 7/2, 7/2, (), ()]",
2418
+ "```",
2419
+ "## Conservation and empty channels",
2420
+ "",
2421
+ "The summed Size of the dealt children is the list's Size: each child is in",
2422
+ "exactly one channel. Each channel's load is the sum of its children's Sizes,",
2423
+ "and an empty channel's load is 0. The router's `.##` is that sum. The `.##`",
2424
+ "of its channels taken as a plain list of lists is not, because an empty array",
2425
+ "has Size 1, so an empty channel adds one",
2426
+ "```",
2427
+ "; .load {.c _; (c.# = 0) ? {0} : {c.##}};",
2428
+ "; .loads {_ & {load _}};",
2429
+ "; [loads ([5, 2] ./ 2).channels, loads ([5, 2] ./ 3).channels, (loads ([5, 2] ./ 3).channels).##, [5, 2].##, ([5, 2] ./ 3).##, ([5, 2] ./ 3).channels.##]",
2430
+ "# [[5, 2], [5, 2, 0], 7, 7, 7, 8]",
2431
+ "```",
2432
+ "Zero-Size children take a slot, and empty children count their own Size 1",
2433
+ "```",
2434
+ "; [loads ([0, 0, 0] ./ 2).channels, loads ([[], [], 0] ./ 2).channels, [[], [], 0].##]",
2435
+ "# [[0, 0], [1, 1], 2]",
2436
+ "```",
2437
+ "Dealing measures nothing, so a child whose Size fails is dealt like any other.",
2438
+ "Its failure shows where the channel is measured",
2439
+ "```",
2440
+ "; .Failing [.## {[].nope}; 1];",
2441
+ "; ([Failing, 1] ./ 2).channels & {_.#}",
2442
+ "# [1, 1]",
2443
+ "; ([Failing, 1] ./ 2).##",
2444
+ "# $!.name-missing “...",
2445
+ "```",
2446
+ "## Demi",
2447
+ "",
2448
+ "A Demi of any arity is `Demi [C, loads]`, a Count and a nonempty list of",
2449
+ "Counts. Two loads are the binary Demi `Demi [C, L, R]` itself, the same",
2450
+ "instance, with its `left`, `right` and `phase`; any other arity is a channel",
2451
+ "Demi, which reads as `Demi(C,[…])`. Every Demi stores `count` and `loads`",
2452
+ "```",
2453
+ "; Demis <- './hc/demi.hc';",
2454
+ "; .Demi Demis.Demi;",
2455
+ "; [“” (Demi [3, [5, 2]]), (Demi [3, [5, 2]]) == (Demi [3, 5, 2]), (Demi [3, [5, 2]]).left, (Demi [3, 5, 2]).loads]",
2456
+ "# [“Demi(3,5,2)”, <>, 5, [5, 2]]",
2457
+ "; [“” (Demi [0, [0, 0, 0]]), “” (Demi [4, [7]]), “” (Demi [2, [1, 2, 3, 4]]), (Demi [2, [1, 2, 3]]).loads, (Demi [2, [1, 2, 3]]).count]",
2458
+ "# [“Demi(0,[0, 0, 0])”, “Demi(4,[7])”, “Demi(2,[1, 2, 3, 4])”, [1, 2, 3], 2]",
2459
+ "```",
2460
+ "No channels, a load that is not a Count, and any other shape are refused",
2461
+ "```",
2462
+ "; [Demi [2, []], Demi [2, [1, (0 - 1), 3]], Demi [2, [1, 1.5]], Demi [2, [1, [2]]], Demi [(0 - 2), [1]], Demi [2, 5], Demi [2, [1], 3], Demi [2, [1, 2], 3, 4]]",
2463
+ "# [$!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi]",
2464
+ "```",
2465
+ "A channel Demi observes as its loads do: its Count is C, its Size the sum of",
2466
+ "its loads, and its residual their alternating sum, `e0 − e1 + e2 − …`, the",
2467
+ "list residual, which for two loads is `L − R`",
2468
+ "```",
2469
+ "; .d7 (Demi [3, 5, 2]); .q3 (d7 ./ 3);",
2470
+ "; [q3.#, q3.##, q3.###, q3.count, q3.loads]",
2471
+ "# [3, 7, 3, 3, [3, 2, 2]]",
2472
+ "```",
2473
+ "## Demi division redistributes Size units",
2474
+ "",
2475
+ "`D ./ n` keeps the Count and the Size and deals the Size units round-robin into",
2476
+ "n channels. For S = 7: into 2, 4 and 3; into 3, 3, 2 and 2; into 4, 2, 2, 2",
2477
+ "and 1. Into one channel it is the whole Size, and into more channels than units",
2478
+ "the last are empty",
2479
+ "```",
2480
+ "; [“” (d7 ./ 2), “” (d7 ./ 3), “” (d7 ./ 4), “” (d7 ./ 1), “” (d7 ./ 9)]",
2481
+ "# [“Demi(3,4,3)”, “Demi(3,[3, 2, 2])”, “Demi(3,[2, 2, 2, 1])”, “Demi(3,[7])”, “Demi(3,[1, 1, 1, 1, 1, 1, 1, 0, 0])”]",
2482
+ "```",
2483
+ "`Demi(3,[5,2]) ./ 3` is `Demi(3,[3,2,2])`, and so is the different state",
2484
+ "`Demi(3,[4,3]) ./ 3`. Normalization is many-to-one: equal Count and Size give",
2485
+ "the same result, and the original distribution cannot be recovered",
2486
+ "```",
2487
+ "; [q3 = (Demi [3, [3, 2, 2]]), ((Demi [3, 4, 3]) ./ 3) = q3, (Demi [3, 4, 3]) = d7, (d7 / 3) = q3, q3 = d7]",
2488
+ "# [<>, <>, (), <>, ()]",
2489
+ "```",
2490
+ "It is idempotent, and dividing again renormalizes from the same Count and Size,",
2491
+ "so the earlier division leaves no trace",
2492
+ "```",
2493
+ "; [(q3 ./ 3) = q3, (q3 ./ 2) = (d7 ./ 2), ((d7 ./ 4) ./ 3) = q3, “” (q3 ./ 2), ((q3 ./ 2) ./ 3) = q3]",
2494
+ "# [<>, <>, <>, “Demi(3,4,3)”, <>]",
2495
+ "```",
2496
+ "Zero Size, zero Count, one channel, and more channels than Size or Count",
2497
+ "```",
2498
+ "; [“” ((Demi [0, 0, 0]) ./ 3), “” ((Demi [0, 9, 0]) ./ 4), “” ((Demi [0, 9, 0]) ./ 1), “” ((Demi [2, 1, 1]) ./ 5), “” ((Demi [1, 0, 0]) ./ 2)]",
2499
+ "# [“Demi(0,[0, 0, 0])”, “Demi(0,[3, 2, 2, 2])”, “Demi(0,[9])”, “Demi(2,[1, 1, 0, 0, 0])”, “Demi(1,0,0)”]",
2500
+ "```",
2501
+ "The divisor is a channel Count, refused as a list refuses it, never coerced to",
2502
+ "its Size",
2503
+ "```",
2504
+ "; [d7 ./ 0, d7 ./ (3 - 1), d7 ./ 1.5, d7 ./ (1 / 2), d7 ./ [3], d7 ./ “three”, d7 ./ (Demi [1, 1, 1])]",
2505
+ "# [$!.division-by-zero /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /]",
2506
+ "```",
2507
+ "## Applying after division",
2508
+ "",
2509
+ "After `./ n` the next application deposits into channel C mod n and adds one to",
2510
+ "the Count, a Size of zero included. `q3` has Count 3, so it deposits into",
2511
+ "channels 0, 1, 2, 0 in turn",
2512
+ "```",
2513
+ "; [“” (q3 10), “” ((q3 10) 1), “” (((q3 10) 1) 1), “” ((((q3 10) 1) 1) 1)]",
2514
+ "# [“Demi(4,[13, 2, 2])”, “Demi(5,[13, 3, 2])”, “Demi(6,[13, 3, 3])”, “Demi(7,[14, 3, 3])”]",
2515
+ "; [“” ((Demi [0, [0, 0, 0]]) 4), “” (((Demi [0, [0, 0, 0]]) 4) 0), “” ((((Demi [0, [0, 0, 0]]) 4) 0) 6)]",
2516
+ "# [“Demi(1,[4, 0, 0])”, “Demi(2,[4, 0, 0])”, “Demi(3,[4, 0, 6])”]",
2517
+ "```",
2518
+ "A reduce applies it the same way, and through a mutable name it writes in",
2519
+ "place. One channel takes every deposit, and two channels are the binary Demi's",
2520
+ "parity",
2521
+ "```",
2522
+ "; “” ([5, 2, 7, 1, 0] | (Demi [0, [0, 0, 0]]))",
2523
+ "# “Demi(5,[6, 2, 7])”",
2524
+ "; .m_ (Demi [0, [0, 0, 0]]);",
2525
+ "; m_ 5;",
2526
+ "; m_ 6;",
2527
+ "; [“” m_, “” ((d7 ./ 1) 4), “” ((d7 ./ 2) 4), “” (d7 4)]",
2528
+ "# [“Demi(2,[5, 6, 0])”, “Demi(4,[11])”, “Demi(4,4,7)”, “Demi(4,5,6)”]",
2529
+ "```",
2530
+ "## Demi laws",
2531
+ "",
2532
+ "For every Count 0 to 3, every pair of loads 0 to 4 (100 states) and every n",
2533
+ "from 1 to 4: the Count and Size are kept, there are n loads, they are the",
2534
+ "dealing of S unit Frames into n channels, division is idempotent, and for every",
2535
+ "m from 1 to 4 dividing by n then m is dividing by m",
2536
+ "```",
2537
+ "; .cs [0, 1, 2, 3]; .ls [0, 1, 2, 3, 4]; .ns [1, 2, 3, 4];",
2538
+ "; .states (cs &| {.c _; ls &| {.l _; ls & {Demi [c, l, _]}}});",
2539
+ "; .law {.k _; ns &| {.n _; .q (k ./ n); [q.# = k.#, q.## = k.##, q.loads.# = n, q.loads = (((k.## [1]) ./ n).channels & {_.#}), (q ./ n) = q]}};",
2540
+ "; .renorm {.k _; ns &| {.n _; ns & {.m _; ((k ./ n) ./ m) = (k ./ m)}}};",
2541
+ "; .checks ((states &| law) | (states &| renorm));",
2542
+ "; [states.#, checks.#, checks = (checks & {<>})]",
2543
+ "# [100, 3600, <>]",
2544
+ "```",
2545
+ "## Channel Demi operations",
2546
+ "",
2547
+ "Its fourth hash is intrinsic, as for the binary Demi: a fresh equal channel Demi",
2548
+ "of the same arity, Count zero included. A record that only spells the fields is",
2549
+ "not one, and forged observers give the ordinary derived binary Demi",
2550
+ "```",
2551
+ "; [(q3.####) == q3, (q3.####) === q3, ((Demi [0, [0, 0, 0]]).####) = (Demi [0, [0, 0, 0]]), ([5, 2].#### ./ 3) = (Demi [2, [3, 2, 2]])]",
2552
+ "# [<>, (), <>, <>]",
2553
+ "; [[.count 3; .loads [3, 2, 2]].####, “” ([.count 3; .loads [3, 2, 2]; .# {3}; .## {7}; .### {3}].####)]",
2554
+ "# [(), “Demi(3,5,2)”]",
2555
+ "```",
2556
+ "`*` and `scale_` scale every load and keep the Count; the ratios read Size and",
2557
+ "residual over the Count, nil at Count zero",
2558
+ "```",
2559
+ "; [“” (q3 * 2), “” (q3.scale_ 3), q3.size-ratio (), q3.residual-ratio (), (Demi [0, [3, 2, 2]]).size-ratio ()]",
2560
+ "# [“Demi(3,[6, 4, 4])”, “Demi(3,[9, 6, 6])”, 7/3, 1, ()]",
2561
+ "```",
2562
+ "`+` and `-` follow the residual's signs. The residual adds the loads at even",
2563
+ "indices and subtracts those at odd ones, so `-` deposits `x.##` on the first",
2564
+ "even load, load 0, and raises the residual, and `+` deposits on the first odd",
2565
+ "load, load 1, and lowers it. For two loads these are the binary Demi's left and",
2566
+ "right. Both keep the Count, and both are `deposit-left_` and `deposit-right_`",
2567
+ "by the operand's Size. One load has no odd index, so there `+` is",
2568
+ "`$!!.invalid-arity`",
2569
+ "```",
2570
+ "; [“” (q3 + 1), “” (q3 - 1), q3.###, (q3 + 1).###, (q3 - 1).###, (q3 + 1).#]",
2571
+ "# [“Demi(3,[3, 3, 2])”, “Demi(3,[4, 2, 2])”, 3, 2, 4, 3]",
2572
+ "; [“” ((d7 ./ 4) + 1), “” ((d7 ./ 4) - 2.5), (d7 ./ 1) + 1, “” ((d7 ./ 1) - 1), “” (d7 + 1), “” (d7 - 1)]",
2573
+ "# [“Demi(3,[2, 3, 2, 1])”, “Demi(3,[4, 2, 2, 1])”, $!!.invalid-arity, “Demi(3,[8])”, “Demi(3,5,3)”, “Demi(3,6,2)”]",
2574
+ "; [((q3 + 4) - 2) = ((q3 - 2) + 4), ((q3 + 1) ./ 3) = ((q3 - 1) ./ 3), q3 + ([].nope), q3.deposit-right_ (0 - 1), q3.deposit-left_ 1.5, “” q3]",
2575
+ "# [<>, <>, $!.name-missing “..., $!!.invalid-demi, $!!.invalid-demi, “Demi(3,[3, 2, 2])”]",
2576
+ "```",
2577
+ "## RotorRouter",
2578
+ "",
2579
+ "`RotorRouter [ch0, …, chk−1]` takes k ≥ 1 channel arrays. Two are the binary",
2580
+ "router, with its `left`, `right` and `phase`; every router stores `channels`.",
2581
+ "A round-robin history from channel 0 fills the channels so that the first",
2582
+ "C mod k hold one more than the rest, so the constructor admits exactly the",
2583
+ "channels whose Counts are the dealing of C into k, and refuses every other",
2584
+ "```",
2585
+ "; [[[]], [[], []], [[], [], []], [[], [], [], []]] & {“” (RotorRouter _)}",
2586
+ "# [“RotorRouter([[]])”, “RotorRouter([],[])”, “RotorRouter([[], [], []])”, “RotorRouter([[], [], [], []])”]",
2587
+ "; [[[5]], [[5], [6]], [[5], [], []], [[5], [6], []], [[5, 8], [6], [7]], [[5, 9], [6], [7], [8]]] & {(RotorRouter _).#}",
2588
+ "# [1, 2, 1, 2, 4, 5]",
2589
+ "; [RotorRouter [[1], [2], [3, 4]], RotorRouter [[1], [], [2]], RotorRouter [[1, 2, 3], [4], [5]], RotorRouter [[], [1]], RotorRouter [[1, 2], [3], [4], [5], [6, 7]], RotorRouter []]",
2590
+ "# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
2591
+ "```",
2592
+ "Routing appends the Frame to channel C mod k, from Count 0 through 6 here, so",
2593
+ "every successor is admissible again. Routing nil routes nothing",
2594
+ "```",
2595
+ "; .s0 (RotorRouter [[], [], []]);",
2596
+ "; [0, 1, 2, 3, 4, 5, 6] & {.n _; ((n [0]) | s0).channels & {_.#}}",
2597
+ "# [[0, 0, 0], [1, 0, 0], [1, 1, 0], [1, 1, 1], [2, 1, 1], [2, 2, 1], [2, 2, 2]]",
2598
+ "; [“” ((s0 A) B), (((s0 A) B) C).channels .2 &| {[_ === C]}, (s0 ()).#]",
2599
+ "# [“RotorRouter([[[1, [2]]], [“b”], []])”, [<>], 0]",
2600
+ "```",
2601
+ "## Router division re-deals the Frames",
2602
+ "",
2603
+ "Routing xs from the initial router, then dividing by 3, is the router of",
2604
+ "`xs ./ 3`: the router's history is reconstructed from its channels and dealt",
2605
+ "again. The Count and the summed Size are kept, every Frame is the same Frame,",
2606
+ "and dividing by one gives the history back in routed order",
2607
+ "```",
2608
+ "; .r0 (RotorRouter [[], []]);",
2609
+ "; .r7 (xs | r0); .t3 (r7 ./ 3);",
2610
+ "; [“” t3, t3.channels & {_.#}, t3.# = r7.#, t3.## = r7.##, t3 = (xs ./ 3)]",
2611
+ "# [“RotorRouter([[[1, [2]], [.k 9; 4], 7], [“b”, 5], [{ 5 + 3 }, (6, 7)]])”, [3, 2, 2], <>, <>, <>]",
2612
+ "; [(t3.channels .0) &| {[_ === A]}, (t3.channels .2) &| {[_ === C]}, ((t3.channels .0) .1).k, ((t3 ./ 1).channels .0) = xs]",
2613
+ "# [[<>, (), ()], [<>, ()], 9, <>]",
2614
+ "```",
2615
+ "Division is idempotent and renormalizes: dividing again re-deals the same",
2616
+ "history, so a router divided by 3 and then 2 is the binary router it came",
2617
+ "from. The empty router divides into empty channels",
2618
+ "```",
2619
+ "; [(t3 ./ 3) = t3, (t3 ./ 2) = r7, ((r7 ./ 4) ./ 3) = t3, ((t3 ./ 4) ./ 2) = r7, “” (r0 ./ 3), (r0 ./ 3).#, ((RotorRouter [[], [], []]) ./ 2) = r0]",
2620
+ "# [<>, <>, <>, <>, “RotorRouter([[], [], []])”, 0, <>]",
2621
+ "```",
2622
+ "After division the next route goes to channel C mod n: `t3` has Count 7, so 8,",
2623
+ "9 and 10 go to channels 1, 2 and 0. Divided back into two, it is the binary",
2624
+ "router that routed the same Frames",
2625
+ "```",
2626
+ "; [“” (t3 8), “” ((t3 8) 9), “” (((t3 8) 9) 10)]",
2627
+ "# [“RotorRouter([[[1, [2]], [.k 9; 4], 7], [“b”, 5, 8], [{ 5 + 3 }, (6, 7)]])”, “RotorRouter([[[1, [2]], [.k 9; 4], 7], [“b”, 5, 8], [{ 5 + 3 }, (6, 7), 9]])”, “RotorRouter([[[1, [2]], [.k 9; 4], 7, 10], [“b”, 5, 8], [{ 5 + 3 }, (6, 7), 9]])”]",
2628
+ "; [((t3 8) ./ 2) = (r7 8), (((t3 8) 9) ./ 1).channels .0 = ((xs 8) 9)]",
2629
+ "# [<>, <>]",
2630
+ "```",
2631
+ "Division routes and measures nothing. A Frame held through a mutable name is",
2632
+ "the same Frame after division, so a later write shows; a child whose Size",
2633
+ "fails is re-dealt and fails only where the router is measured; zero-Size",
2634
+ "children and empty arrays take slots, and nested arrays stay whole",
2635
+ "```",
2636
+ "; .kid_ [.n 1; .set_ {@n _;}];",
2637
+ "; .rk ((r0 kid_) ./ 3);",
2638
+ "; kid_.set_ 5;",
2639
+ "; [(rk.channels .0 .0) === kid_, rk.channels .0 .0 .n]",
2640
+ "# [<>, 5]",
2641
+ "; .rf (((r0 Failing) 0) ./ 3);",
2642
+ "; [rf.channels & {_.#}, ((r0 Failing) ./ 3) = (RotorRouter [[Failing], [], []])]",
2643
+ "# [[1, 1, 0], <>]",
2644
+ "; rf.##",
2645
+ "# $!.name-missing “...",
2646
+ "; .rz ((((r0 0) []) <>) ./ 2);",
2647
+ "; [rz.channels, rz.##, rz.###]",
2648
+ "# [[[0, <>], [[]]], 2, 0]",
2649
+ "; [((RotorRouter [[[1, 2]], [[3]]]) ./ 1).channels, ((RotorRouter [[[1, 2]], [[3]]]) ./ 1).## = (RotorRouter [[[1, 2]], [[3]]]).##]",
2650
+ "# [[[[1, 2], [3]]], <>]",
2651
+ "```",
2652
+ "A router's history is not bounded by the channel limit: its readout divides by",
2653
+ "its longest channel's length, which never exceeds the Frames it holds, so a",
2654
+ "one-channel router of 1,000,001 Frames divides into two (PR #482 review)",
2655
+ "```",
2656
+ "; .big ((500001 [1]) | (500000 [1]));",
2657
+ "; [big.#, ((RotorRouter [big]) ./ 2).channels & {_.#}]",
2658
+ "# [1000001, [500001, 500000]]",
2659
+ "```",
2660
+ "Routing appends to channel C mod k directly, without replaying the history, so",
2661
+ "routing grows linearly: three thousand Frames route into three channels in turn",
2662
+ "```",
2663
+ "; .grown ((3000 [1]) | (RotorRouter [[], [], []]));",
2664
+ "; [grown.#, grown.channels & {_.#}, (grown ./ 3) = grown, ((grown ./ 1).channels .0).# ]",
2665
+ "# [3000, [1000, 1000, 1000], <>, 3000]",
2666
+ "```",
2667
+ "The divisor is refused as for a list",
2668
+ "```",
2669
+ "; [r7 ./ 0, r7 ./ (3 - 1), r7 ./ 1.5, r7 ./ [2], r7 ./ (Demi [1, 1, 1]), r7 ./ “two”]",
2670
+ "# [$!.division-by-zero /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /, $!.division-domain /]",
2671
+ "```",
2672
+ "## A router's observers and fourth hash",
2673
+ "",
2674
+ "A router of any arity declares its Count C, its Size, the sum of its channel",
2675
+ "loads, and its residual, their alternating sum, as a channel Demi does. Its",
2676
+ "fourth hash is the Demi of the same arity: a router of k channels other than",
2677
+ "two is recognized intrinsically, as an instance of the shipped class, and",
2678
+ "answers `Demi [C, loads]`, one load per channel, so it routes to channel",
2679
+ "C mod k as its Demi deposits there. The binary router answers the binary Demi",
2680
+ "it always did. At Count zero there is no Demi, for any arity",
2681
+ "```",
2682
+ "; [t3.#, t3.##, t3.###, “” t3.####, t3.#### = (Demi [7, [14, 6, 22]]), t3.####.## = t3.##, t3.####.### = t3.###]",
2683
+ "# [7, 42, 30, “Demi(7,[14, 6, 22])”, <>, <>, <>]",
2684
+ "; [“” (r7.####), ([] ./ 3).####, (RotorRouter [[], [], []]).####, “” ((([] ./ 3) 5).####)]",
2685
+ "# [“Demi(7,24,18)”, (), (), “Demi(1,[5, 0, 0])”]",
2686
+ "```",
2687
+ "So the projection law `(r y).#### = r.#### y` holds for every arity: routing y",
2688
+ "to channel C mod k and observing is depositing `y.##` there",
2689
+ "```",
2690
+ "; .nine [1, 2, 3, 4, 5, 6, 7, 8, 9];",
2691
+ "; [1, 2, 3, 4, 5] & {.r (nine ./ _); ((r 10).####) = ((r.####) 10)}",
2692
+ "# [<>, <>, <>, <>, <>]",
2693
+ "; [“” ((t3 10).####), “” ((nine ./ 1).####), “” ((nine ./ 4).####)]",
2694
+ "# [“Demi(8,[14, 16, 22])”, “Demi(9,[45])”, “Demi(9,[15, 8, 10, 12])”]",
2695
+ "```",
2696
+ "Recognition reads nothing the router computes: a record that only spells",
2697
+ "`channels` is not a router, and a failed child Size is answered as it is",
2698
+ "```",
2699
+ "; [[.channels [[1], [], []]].####, ([Failing] ./ 3).####]",
2700
+ "# [(), $!.name-missing “...]",
2701
+ "```",
2702
+ "## Whole Frames and Size units",
2703
+ "",
2704
+ "Whole-Frame division and Size-unit division agree on the total and differ on",
2705
+ "the channels. Children of Sizes 5 and 2 dealt into two channels load them 5",
2706
+ "and 2, as list and router; the Demi of the same list, normalized, loads them 4",
2707
+ "and 3. They are different states with the same Size, and neither is wrong",
2708
+ "```",
2709
+ "; .two [5, 2];",
2710
+ "; [loads (two ./ 2).channels, ((two | r0) ./ 2).channels & {load _}, “” (two.#### ./ 2), ((two | r0) ./ 2).#### = (two.#### ./ 2), ((two | r0) ./ 2).####.## = (two.#### ./ 2).##]",
2711
+ "# [[5, 2], [5, 2], “Demi(2,4,3)”, (), <>]",
2712
+ "```",
2713
+ "They agree when every child has Size one, since then each Frame is one Size",
2714
+ "unit. With other Sizes they need not",
2715
+ "```",
2716
+ "; .ones [1, 1, 1, 1, 1, 1, 1];",
2717
+ "; [((ones | r0) ./ 3).channels & {load _}, (ones.#### ./ 3).loads, loads ([5, 2, 9, 1] ./ 3).channels, ([5, 2, 9, 1].#### ./ 3).loads]",
2718
+ "# [[3, 2, 2], [3, 2, 2], [6, 2, 9], [6, 6, 5]]",
1880
2719
  "",
1881
2720
  ].join("\n"),
1882
2721
  ],
@@ -2089,14 +2928,16 @@ export const HC_SOURCES = new Map([
2089
2928
  "The fourth observer derives a Demi from Count, Size and residual.",
2090
2929
  "A zero Count or absent residual gives no Demi; errors propagate. A schema used",
2091
2930
  "as an explicit element contributes Size normally, even though its own Demi is nil.",
2092
- "A present Demi has Size L+R and residual L−R. Its Count is the least positive",
2093
- "representative of its stored parity: 2 for all/even and 1 for nil/odd. The same",
2094
- "universal derivation therefore reconstructs its data value on repeated fourth",
2095
- "observation, including present zero loads, without a special fourth-hash rule.",
2931
+ "A present Demi has Count C, Size L+R and residual L−R. Its Count is its full",
2932
+ "application Count (007.25c), and its phase is derived from the parity of that",
2933
+ "Count: 2 for even and 1 for odd. The derivation therefore reconstructs its data",
2934
+ "value on repeated fourth observation, including present zero loads; a Demi of",
2935
+ "Count zero, which the observers cannot tell from an empty host, declares its own",
2936
+ "fourth hash (`hc/demi.hc`).",
2096
2937
  "A present Demi is an instance of the HC class in `hc/demi.hc` (011.20), and",
2097
- "reads as text `Demi(phase,left,right)`. Applying a Demi to Y deposits Y's Size",
2098
- "and flips the phase, so for a nonempty Figure host X, (X Y).#### is",
2099
- "X.#### Y; for an empty host, start from the zero-load Demi in phase 2 instead,",
2938
+ "reads as text `Demi(count,left,right)`. Applying a Demi to Y deposits Y's Size",
2939
+ "and adds one to the Count, so for a nonempty Figure host X, (X Y).#### is",
2940
+ "X.#### Y; for an empty host, start from the Demi of Count zero instead,",
2100
2941
  "because [].#### is nil. Scaling is the method `scale_`, the shadow of Star:",
2101
2942
  "(X * Y).#### is X.####.scale_ (Y.##) for a nonempty host. Count is a terminal",
2102
2943
  "quantity: positive Counts agree with pure Figures of that terminal Size, but 0",
@@ -2104,17 +2945,17 @@ export const HC_SOURCES = new Map([
2104
2945
  "including [0].####.",
2105
2946
  "```",
2106
2947
  "; [[].####, 0.####, “” “hello”.####, <2,3,5>.####]",
2107
- "# [(), (), “Demi((),3,2)”, ()]",
2948
+ "# [(), (), “Demi(5,3,2)”, ()]",
2108
2949
  "; [(10 - 5).#### = 5.####, (0 - 5).#### = 5.####, (5.0).#### = 5.####, “hello”.#### = 5.####]",
2109
2950
  "# [<>, <>, <>, <>]",
2110
2951
  "; [<>.#, <>.##, <>.###, ().##]",
2111
2952
  "# [0, 1, 0, 1]",
2112
2953
  "; [1, 2, 3, 7] & {“” _.####}",
2113
- "# [“Demi((),1,0)”, “Demi(<>,1,1)”, “Demi((),2,1)”, “Demi((),4,3)”]",
2954
+ "# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,2,1)”, “Demi(7,4,3)”]",
2114
2955
  "; [[0], [“hello”], [<2,3,5>,2], {5 + 3}] & {“” _.####}",
2115
- "# [“Demi((),0,0)”, “Demi((),5,0)”, “Demi(<>,3,2)”, “Demi((),8,1)”]",
2956
+ "# [“Demi(1,0,0)”, “Demi(1,5,0)”, “Demi(2,3,2)”, “Demi(3,8,1)”]",
2116
2957
  "; [“” ([[],[]].#### 3), “” (7.####.scale_ 2), ([[],[]] 3).#### = ([[],[]].#### 3)]",
2117
- "# [“Demi((),4,1)”, “Demi((),8,6)”, <>]",
2958
+ "# [“Demi(3,4,1)”, “Demi(7,8,6)”, <>]",
2118
2959
  "```",
2119
2960
  "A RotorRouter, the class in `hc/rotor-router.hc` (011.21), keeps the routed",
2120
2961
  "Figures themselves in two ordered channels and declares the observers that make",
@@ -2123,7 +2964,7 @@ export const HC_SOURCES = new Map([
2123
2964
  "fourth hash is the Figure's.",
2124
2965
  "```",
2125
2966
  "; Routers <- './hc/rotor-router.hc';",
2126
- "; .fr ([[], [[], []], []] | (Routers.RotorRouter [2, [], []]));",
2967
+ "; .fr ([[], [[], []], []] | (Routers.RotorRouter [[], []]));",
2127
2968
  "; [fr.left, fr.right, fr.#### = [[], [[], []], []].####]",
2128
2969
  "# [[[], []], [[[], []]], <>]",
2129
2970
  "",
@@ -2750,96 +3591,206 @@ export const HC_SOURCES = new Map([
2750
3591
  "```",
2751
3592
  "RotorRouter (occurrence/figure 011.21)",
2752
3593
  "",
2753
- "A RotorRouter is a two-channel router that keeps what it routes. It holds a",
2754
- "phase and two ordered arrays, left and right, of the Frames routed into them.",
2755
- "Applying a router to a Frame appends that Frame, the same Frame, to the active",
2756
- "channel and flips the phase. A Demi follows the same alternation by Size alone;",
2757
- "a router keeps the children, so its numerical shadow is a Demi and its state is",
3594
+ "A RotorRouter is a two-channel router that keeps what it routes. Its state is",
3595
+ "two ordered arrays, left and right, of the Frames routed into them, and nothing",
3596
+ "else. Applying a router to a Frame appends that Frame, the same Frame, to the",
3597
+ "channel its Count selects. A Demi follows the same alternation by Size alone; a",
3598
+ "router keeps the children, so its numerical shadow is a Demi and its state is",
2758
3599
  "everything that shadow forgets: which Frames, in what order, and which channel.",
2759
3600
  "",
2760
3601
  "`RotorRouter` is an ordinary HC class, like `Demi` in `hc/demi.hc`: a",
2761
3602
  "constructor closure answering a fresh aggregate whose fields are its state and",
2762
3603
  "whose methods are the class. Import it with",
2763
- "`Routers <- './hc/rotor-router.hc'`, then `Routers.RotorRouter [2, [], []]`.",
2764
- "",
2765
- "**State.** `RotorRouter [phase, left, right]` takes a Count phase and two",
2766
- "arrays. The phase is the state of the next route, encoded as a Demi's is:",
2767
- "2 when left is next and 1 when right is next. A channel is its elements: an",
3604
+ "`Routers <- './hc/rotor-router.hc'`, then `Routers.RotorRouter [[], []]`.",
3605
+ "",
3606
+ "**State (007.25e).** `RotorRouter [left, right]` takes two arrays, the two",
3607
+ "ordered channels. There is no phase argument: the router's Count is",
3608
+ "`C = left.# + right.#`, the children it holds, and its phase is read from the",
3609
+ "parity of C exactly as a Demi's is, 2 when C is even (left next) and 1 when C is",
3610
+ "odd (right next). Earlier versions took `RotorRouter [phase, left, right]`, a",
3611
+ "free phase beside the channels; that form is removed, with no alias, so the",
3612
+ "router's routing phase, its Count and the phase of its Demi are one fact.",
3613
+ "",
3614
+ "**Admissibility.** Routing from empty channels starts left and alternates, so",
3615
+ "every routed history has `left.# = right.#` (C even) or",
3616
+ "`left.# = right.# + 1` (C odd), and conversely every such pair is the one",
3617
+ "history that sent `left.0`, `right.0`, `left.1`, … in turn. The constructor",
3618
+ "admits exactly those pairs and refuses every other pair with",
3619
+ "`$!!.invalid-router`, a named error, as `Demi` refuses with `$!!.invalid-demi`:",
3620
+ "`RotorRouter [[A], [B, C]]` and `RotorRouter [[A, B], []]` are not histories,",
3621
+ "and no history or offset is invented for them. Routing keeps the invariant, so",
3622
+ "every router a program can hold satisfies it. A channel is its elements: an",
2768
3623
  "array's properties are configuration, not routed Frames, so the constructor",
2769
- "keeps the elements in a fresh array of its own, and a channel argument that",
2770
- "declares `apply` cannot change what appending means. Anything else is refused",
2771
- "with `$!!.invalid-router`, a named error, as `Demi` refuses with",
2772
- "`$!!.invalid-demi`.",
2773
- "Any phase and any two channels are a state; nothing requires the channels to",
2774
- "be a history the router could have produced.",
2775
- "",
2776
- "**Routing**, `router x`: append x as one member of the active channel and flip",
2777
- "the phase. Routing never evaluates x, never measures it, and never runs its",
2778
- "methods, so a closure is kept uncalled, an array or group is kept as one",
2779
- "member, and a Frame whose Size fails or runs code is routed like any other. A",
2780
- "Frame of Size zero still takes a slot and flips the phase. It is a mutating",
2781
- "method, `apply_`, so through a name it is a functional update that leaves the",
2782
- "router as it was, and through a mutable name it writes the router in place.",
2783
- "Routing nil routes nothing and leaves the router as it was, as applying a Demi",
2784
- "to nil does. A flagged error such as `1 / 0` is the answer of the expression",
2785
- "that applies the router, so it is never routed.",
2786
- "",
2787
- "**Observers.** A router declares its Count, Size and residual as a Demi does:",
2788
- "its phase, its total load L+R and the signed difference L−R, where each load is",
2789
- "the sum of the Sizes of the children routed into that channel. So `router.####`",
2790
- "derives the router's Demi as it derives any Frame's, and that Demi is the",
2791
- "router's numerical shadow. An empty channel has load 0, the empty sum; a",
2792
- "nonempty channel's load is its native Size, which is that sum. Observation is",
2793
- "where children are measured, so it is where their failures show, and declared",
2794
- "observers run only when the router is observed: routing runs none of them, and",
2795
- "observing writes nothing. The Demi forgets which Frames were routed and their",
2796
- "order, so distinct routers can share one.",
3624
+ "keeps the elements in a fresh array of its own, counts them there, and a",
3625
+ "channel argument that declares `apply` cannot change what appending means.",
3626
+ "Anything that is not a nonempty list of arrays is refused the same way; one",
3627
+ "array or three are routers of another arity (below).",
3628
+ "",
3629
+ "**Routing**, `router x`: append x as one member of the channel the parity of C",
3630
+ "selects; the Count grows by one and the phase flips with it. `router.phase` is",
3631
+ "a field written only together with that append, read from the same parity, so",
3632
+ "it is never independent state. Routing never evaluates x, never measures it,",
3633
+ "and never runs its methods, so a closure is kept uncalled, an array or group is",
3634
+ "kept as one member, and a Frame whose Size fails or runs code is routed like any",
3635
+ "other. A Frame of Size zero still takes a slot and flips the phase. It is a",
3636
+ "mutating method, `apply_`, so through a name it is a functional update that",
3637
+ "leaves the router as it was, and through a mutable name it writes the router in",
3638
+ "place. Routing nil routes nothing and leaves the router as it was, as applying a",
3639
+ "Demi to nil does. A flagged error such as `1 / 0` is the answer of the",
3640
+ "expression that applies the router, so it is never routed.",
3641
+ "",
3642
+ "**Observers.** A router declares its Count, Size and residual as a Demi does",
3643
+ "(007.25c): its Count C, its total load L+R and the signed difference L−R, where",
3644
+ "each load is the sum of the Sizes of the children routed into that channel. So",
3645
+ "`router.####` derives the router's Demi as it derives any Frame's,",
3646
+ "`Demi(C, L, R)`, and that Demi is the router's numerical shadow. Its phase is",
3647
+ "the router's phase, because both are the parity of the same C. An empty channel",
3648
+ "has load 0, the empty sum; a nonempty channel's load is its native Size, which",
3649
+ "is that sum. Observation is where children are measured, so it is where their",
3650
+ "failures show, and declared observers run only when the router is observed:",
3651
+ "routing runs none of them, and observing writes nothing. The Demi forgets which",
3652
+ "Frames were routed and their order, so distinct routers can share one.",
3653
+ "",
3654
+ "**The projection law.** For every router r whose fourth hash exists, that is",
3655
+ "every router with C ≥ 1 whose children have Sizes, and every Frame y,",
3656
+ "`(r y).#### = (r.####) y`: routing y into the channel the parity of C selects",
3657
+ "and then observing adds `y.##` to that channel's load and one to C, which is",
3658
+ "exactly what applying `Demi(C, L, R)` to y does. The empty router `[[], []]` is",
3659
+ "the boundary: it has routed nothing, so like the empty host `[]` its Count is",
3660
+ "zero and `.####` is nil, not a Demi conjured to make the equation look true.",
3661
+ "There the law reads through the zero-Count lifting the Demi class names,",
3662
+ "`(r0 y).#### = (Demi [0, 0, 0]) y`.",
2797
3663
  "",
2798
3664
  "**Text.** A router prints as its fields and methods, and as text reads",
2799
- "`RotorRouter(<>,[…],[…])`, with the phase spelled as the orientation it stands",
2800
- "for and each channel as its spelling.",
3665
+ "`RotorRouter([…],[…])`, each channel as its spelling, the constructor's own",
3666
+ "shape.",
3667
+ "",
3668
+ "**Channels and division (007.27).** Two channels are the arity-two case of k",
3669
+ "ordered channels. `RotorRouter [ch0, …, chk−1]` takes k ≥ 1 arrays; two are",
3670
+ "this binary router, and any other number is a channel router. Every router",
3671
+ "stores `channels`; only the binary one also has `left`, `right` and `phase`,",
3672
+ "which it writes together with `channels`. A round-robin history from channel 0",
3673
+ "leaves the first C mod k channels one longer than the rest, so a channel",
3674
+ "router admits exactly the channels whose Counts are the dealing of C children",
3675
+ "into k, `round-robin [C, k]`, and refuses every other with",
3676
+ "`$!!.invalid-router`.",
3677
+ "Routing appends to channel C mod k, which for k = 2 is the phase's channel,",
3678
+ "directly, as the binary router does: a small cursor, `append-at`, rebuilds the",
3679
+ "list of channels with the Frame added to that one, so a route costs one pass",
3680
+ "over the k channels and never replays the history (PR #482 review).",
3681
+ "Its Size is the sum of its channel loads and its residual their alternating",
3682
+ "sum, as a channel Demi's are. Its fourth hash is the channel Demi of its",
3683
+ "Count and channel loads, `Demi [C, [load0, …]]`: the fourth hash recognizes an",
3684
+ "instance of this class with other than two channels intrinsically, as it",
3685
+ "recognizes a Demi, because the binary Demi the observers derive follows",
3686
+ "parity and not C mod k. So the projection law `(r y).#### = r.#### y` holds",
3687
+ "for every arity; at Count zero there is no Demi. Text reads `RotorRouter([ch0, ch1, …])`.",
3688
+ "",
3689
+ "`router ./ n`, also spelled `router / n`, re-deals the Frames it holds: it",
3690
+ "reconstructs the order they were routed in from its channels, which their",
3691
+ "admissibility fixes, and routes that history through a fresh router of n",
3692
+ "channels, that is, it is the history divided as a list, `history / n`, since",
3693
+ "list division answers the n-channel router of its channels (007.27c).",
3694
+ "Reconstructing the history is the breadth-first readout of 007.27c: the first",
3695
+ "Frame of each channel in channel order, then the second of each, and so on. Every Frame stays the",
3696
+ "same Frame, whole, in order, exactly once, and nothing is evaluated or",
3697
+ "measured; the Count is kept and the next route goes to channel C mod n. The",
3698
+ "history is the dealing inverted: the channels, the short ones padded with a",
3699
+ "sentinel to the longest, are concatenated and dealt into that many channels,",
3700
+ "which are the rounds, and the sentinels removed. One channel is its own",
3701
+ "history, and channels of equal length need no sentinel. The readout divides by",
3702
+ "the longest channel's length, which never exceeds the Frames held, so it is",
3703
+ "never refused by the channel limit. The divisor is refused as a list refuses",
3704
+ "it. `hc/division.hc` is its specification.",
2801
3705
  "",
2802
3706
  "**Methods read their own state through `_^`.** A router is applied to",
2803
3707
  "arbitrary Frames, and a bare name in a method is looked up on the argument",
2804
3708
  "first (spec 7), so a router reads its fields through the receiver, `_^` from",
2805
- "the method body. What a branch needs is bound as a local at method level.",
3709
+ "the method body. What a branch needs is bound as a local at method level. The",
3710
+ "file's own names, `RotorRouter` and `history`, are read through the scope a",
3711
+ "caret ladder reaches, `(_^^ .history)` from the method body, so an argument's",
3712
+ "fields never stand in for them.",
2806
3713
  "```",
2807
3714
  ".channel-load {.c _; (c.# = 0) ? {0} : {c.##}};",
2808
- ".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.p (__ .0); .l (__ .1); .r (__ .2);",
2809
- " ((((p = 2) : {p = 1}) ? {p ~ (0.<>)}) ? {(l ~ ([].<>)) ? {r ~ ([].<>)}}) ? {[",
2810
- " .phase p;",
2811
- " .left (l | []);",
2812
- " .right (r | []);",
2813
- " .apply_ {.x _; .l (_^ .left); .r (_^ .right);",
2814
- " ((_^ .phase) = 2) ? {@left (l x); @phase 1;} : {@right (r x); @phase 2;};};",
2815
- " .# {_^.phase};",
3715
+ ".history {.cs _; .k (cs.#); .w ((cs .0).#); .pad [];",
3716
+ " (k = 1) ? {cs .0} : {(w = 0) ? {[]} : {",
3717
+ " .even ((((cs &| {_}).#) = (k * w)) ? {1} : {0});",
3718
+ " .padded ((even = 1) ? {cs} : {cs & {.ch _; (ch.# = w) ? {ch} : {ch pad}}});",
3719
+ " .flat ((((padded &| {_}) / w) .channels) &| {_});",
3720
+ " (even = 1) ? {flat} : {flat &| {.x _; (x === (_^^^^ .pad)) ? {[]} : {[x]}}}}}};",
3721
+ ".append-at {.at (_ .0); .item (_ .1); [.index 0; .target at; .item item; .out [];",
3722
+ " .apply_ {.v _; .i (_^ .index); .t (_^ .target); .it (_^ .item); .o (_^ .out);",
3723
+ " @out (o ((i = t) ? {it | v} : {v})); @index (i + 1);}]};",
3724
+ ".round-robin {.s (_ .0); .ways (_ .1); .q (((s - (s %% ways)) / ways).##);",
3725
+ " [.low q; .short 0; .ok 1;",
3726
+ " .apply_ {.c _; .lo (_^ .low); .seen (_^ .short); .fine (_^ .ok);",
3727
+ " @ok ((((c = (lo + 1)) ? {seen = 0} : {c = lo}) ? {fine = 1}) ? {1} : {0}); @short ((c = lo) ? {1} : {seen});}]};",
3728
+ ".binary-router {.cs _; .lc (cs .0); .rc (cs .1); [",
3729
+ " .phase (((lc.#) = (rc.#)) ? {2} : {1});",
3730
+ " .left lc;",
3731
+ " .right rc;",
3732
+ " .channels [lc, rc];",
3733
+ " .apply_ {.x _; .l (_^ .left); .r (_^ .right); .n (l.# + r.#);",
3734
+ " ((n %% 2) = 0) ? {.nl (l x); @left nl; @channels [nl, r]; @phase 1;} : {.nr (r x); @right nr; @channels [l, nr]; @phase 2;};};",
3735
+ " .# {.l (_^ .left); .r (_^ .right); l.# + r.#};",
2816
3736
  " .## {(channel-load (_^ .left)) + (channel-load (_^ .right))};",
2817
3737
  " .### {(channel-load (_^ .left)) - (channel-load (_^ .right))};",
2818
- " .toText {“RotorRouter(” (((_^ .phase) = 2) ? {“<>”} : {“()”}) “,” (_^ .left) “,” (_^ .right) “)”}",
2819
- " ]} : {$!!.invalid-router}} : {$!!.invalid-router}};",
3738
+ " ./ {.ways _; ((_^^ .history) (_^ .channels)) / ways};",
3739
+ " .toText {“RotorRouter(” (_^ .left) “,” (_^ .right) “)”}",
3740
+ " ]};",
3741
+ ".channel-router {.cs _; [",
3742
+ " .channels cs;",
3743
+ " .apply_ {.x _; .cs (_^ .channels); .n ((cs & {_.#}).##);",
3744
+ " @channels ((cs | ((_^^ .append-at) [(n %% (cs.#)), [x]])) .out);};",
3745
+ " .# {((_^ .channels) &| {_}).#};",
3746
+ " .## {((_^ .channels) & {channel-load _}).##};",
3747
+ " .### {((_^ .channels) & {channel-load _}).###};",
3748
+ " ./ {.ways _; ((_^^ .history) (_^ .channels)) / ways};",
3749
+ " .toText {“RotorRouter(” (_^ .channels) “)”}",
3750
+ " ]};",
3751
+ ".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) .> 0}) ? {.a __;",
3752
+ " ((a &| {.x _; (x ~ ([].<>)) ? {[]} : {[x]}}).# = 0) ? {.cs (a & {_ | []}); .k (cs.#); .n ((cs &| {_}).#);",
3753
+ " ((k .> 0) ? {(((cs & {_.#}) | (round-robin [n, k])) .ok) = 1}) ? {(k = 2) ? {binary-router cs} : {channel-router cs}} : {$!!.invalid-router}",
3754
+ " } : {$!!.invalid-router}} : {$!!.invalid-router}};",
2820
3755
  "```",
2821
3756
  "## Construction",
2822
3757
  "",
2823
- "A router holds exactly its phase and its two channels. The initial router is",
2824
- "present, phase 2 with both channels empty",
3758
+ "A router holds exactly its two channels, and the phase they fix. The initial",
3759
+ "router is present, both channels empty, Count zero, phase 2",
3760
+ "```",
3761
+ "; .r0 (RotorRouter [[], []]);",
3762
+ "; [r0.phase, r0.left, r0.right, r0.#, “” r0]",
3763
+ "# [2, [], [], 0, “RotorRouter([],[])”]",
3764
+ "```",
3765
+ "Every admissible pair is a router, in the phase its Count fixes: as many",
3766
+ "children left as right is even and phase 2, one more left is odd and phase 1.",
3767
+ "Preloads of any length are admitted on the same terms",
2825
3768
  "```",
2826
- "; .r0 (RotorRouter [2, [], []]);",
2827
- "; [r0.phase, r0.left, r0.right, “” r0]",
2828
- "# [2, [], [], “RotorRouter(<>,[],[])”]",
3769
+ "; [RotorRouter [[5], []], RotorRouter [[5], [6]], RotorRouter [[5, 7], [6]], RotorRouter [[1, 2, 3, 4], [5, 6, 7, 8]], RotorRouter [[1, 2, 3, 4, 5], [6, 7, 8, 9]]] & {[_.#, _.phase]}",
3770
+ "# [[1, 1], [2, 2], [3, 1], [8, 2], [9, 1]]",
2829
3771
  "```",
2830
- "Anything but a phase of 1 or 2 and two arrays is refused",
3772
+ "A pair that is not a left-first alternating history is refused: right ahead of",
3773
+ "left, left more than one ahead, and the old phase-first form, whose three",
3774
+ "arguments are not two channels. No history is invented for them",
2831
3775
  "```",
2832
- "; RotorRouter [3, [], []]",
2833
- "# $!!.invalid-router",
2834
- "; [RotorRouter [(5 - 3), [], []], RotorRouter [2, [], 5], RotorRouter [2, (1, 2), []], RotorRouter [2, []], RotorRouter 5]",
3776
+ "; [RotorRouter [[], [5]], RotorRouter [[5], [6, 7]], RotorRouter [[5, 6], []], RotorRouter [[1, 2, 3], [4]], RotorRouter [[], [1, 2, 3]]]",
2835
3777
  "# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
3778
+ "; [RotorRouter [2, [], []], RotorRouter [1, [5], []], RotorRouter [2, [5]], RotorRouter [1, []]]",
3779
+ "# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
3780
+ "```",
3781
+ "Anything but a nonempty list of arrays is refused. One channel or three are",
3782
+ "not refused: they are routers of another arity (007.27, `hc/division.hc`)",
3783
+ "```",
3784
+ "; [RotorRouter [[], 5], RotorRouter [(1, 2), []], RotorRouter [], RotorRouter [[], [5], []], RotorRouter 5, RotorRouter ()]",
3785
+ "# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
2836
3786
  "```",
2837
3787
  "A channel is its elements. The router keeps them in an array of its own, so a",
2838
- "channel's properties and a declared `apply` do not come with it",
3788
+ "channel's properties and a declared `apply` do not come with it, and only the",
3789
+ "elements are counted for admissibility",
2839
3790
  "```",
2840
3791
  "; .Hijack [.apply {“hijack”}; 1];",
2841
- "; [(RotorRouter [2, [.tag 9; 5], []]).left, ((RotorRouter [2, Hijack, []]) 7).left]",
2842
- "# [[5], [1, 7]]",
3792
+ "; [(RotorRouter [[.tag 9; 5], []]).left, ((RotorRouter [Hijack, []]) 7).right, RotorRouter [[.a 1; .b 2], [5]]]",
3793
+ "# [[5], [7], $!!.invalid-router]",
2843
3794
  "```",
2844
3795
  "## Routing alternates",
2845
3796
  "",
@@ -2848,16 +3799,26 @@ export const HC_SOURCES = new Map([
2848
3799
  "```",
2849
3800
  "; .A [1, [2]]; .B “b”; .C {5 + 3};",
2850
3801
  "; .r3 (((r0 A) B) C);",
2851
- "; [r3.phase, r3.left, r3.right]",
2852
- "# [1, [[1, [2]], { 5 + 3 }], [“b”]]",
3802
+ "; [r3.phase, r3.left, r3.right, r3.#]",
3803
+ "# [1, [[1, [2]], { 5 + 3 }], [“b”], 3]",
2853
3804
  "; “” r3",
2854
- "# “RotorRouter((),[[1, [2]], { 5 + 3 }],[“b”])”",
3805
+ "# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
2855
3806
  "```",
2856
3807
  "The router that was routed into is left as it was",
2857
3808
  "```",
2858
3809
  "; [r0.phase, r0.left, r0.right]",
2859
3810
  "# [2, [], []]",
2860
3811
  "```",
3812
+ "The phase is the parity of the Count after every route, so each successor is",
3813
+ "admissible again: routing from Count 0 through Count 6 alternates",
3814
+ "left, right, left, …",
3815
+ "```",
3816
+ "; .steps [r0, (r0 1), ((r0 1) 2), (((r0 1) 2) 3), ((((r0 1) 2) 3) 4), (((((r0 1) 2) 3) 4) 5), ((((((r0 1) 2) 3) 4) 5) 6)];",
3817
+ "; [steps & {_.#}, steps & {_.phase}, steps & {_.left.#}, steps & {_.right.#}]",
3818
+ "# [[0, 1, 2, 3, 4, 5, 6], [2, 1, 2, 1, 2, 1, 2], [0, 1, 1, 2, 2, 3, 3], [0, 0, 1, 1, 2, 2, 3]]",
3819
+ "; steps & {(RotorRouter [_.left, _.right]) = _}",
3820
+ "# [<>, <>, <>, <>, <>, <>, <>]",
3821
+ "```",
2861
3822
  "## Routing keeps the Frame",
2862
3823
  "",
2863
3824
  "A channel member is the routed Frame itself. An array or a group is routed as",
@@ -2884,40 +3845,42 @@ export const HC_SOURCES = new Map([
2884
3845
  "; [(rk.left.0.set_ 9).n, kid_.n, rk.left.0.n]",
2885
3846
  "# [9, 5, 5]",
2886
3847
  "```",
2887
- "## Independent states",
3848
+ "## Preloaded states",
2888
3849
  "",
2889
- "Any phase and channels construct a router, here phase 1 with a preloaded",
2890
- "left channel. Routing continues from that state",
3850
+ "An admissible preload continues its history: here one child left, so Count 1",
3851
+ "and phase 1, and the next two routes go right then left",
2891
3852
  "```",
2892
- "; .p1 (RotorRouter [1, [A], []]);",
3853
+ "; .p1 (RotorRouter [[A], []]);",
2893
3854
  "; .p2 ((p1 B) C);",
2894
- "; [p2.phase, p2.left, p2.right, p1.phase, p1.right]",
2895
- "# [1, [[1, [2]], { 5 + 3 }], [“b”], 1, []]",
3855
+ "; [p1.phase, p1.#, p2.phase, p2.left, p2.right, p1.right]",
3856
+ "# [1, 1, 1, [[1, [2]], { 5 + 3 }], [“b”], []]",
3857
+ "; [p2 = r3, p2 = (RotorRouter [[A, C], [B]])]",
3858
+ "# [<>, <>]",
2896
3859
  "```",
2897
3860
  "Routers built from the same channel share no writable state: each holds its",
2898
3861
  "own channel array. Through a mutable name, routing writes that router in place",
2899
3862
  "and no other",
2900
3863
  "```",
2901
3864
  "; .ch [A];",
2902
- "; .u (RotorRouter [2, ch, []]); .v (RotorRouter [2, ch, []]);",
2903
- "; .m_ (RotorRouter [2, ch, []]);",
3865
+ "; .u (RotorRouter [ch, []]); .v (RotorRouter [ch, []]);",
3866
+ "; .m_ (RotorRouter [ch, []]);",
2904
3867
  "; m_ B;",
2905
3868
  "; m_ C;",
2906
3869
  "; [m_.phase, m_.left, m_.right, u.left, v.left, ch]",
2907
- "# [2, [[1, [2]], “b”], [{ 5 + 3 }], [[1, [2]]], [[1, [2]]], [[1, [2]]]]",
3870
+ "# [1, [[1, [2]], { 5 + 3 }], [“b”], [[1, [2]]], [[1, [2]]], [[1, [2]]]]",
2908
3871
  "; [u.left === ch, u.left === v.left, u.left.0 === v.left.0]",
2909
3872
  "# [(), (), <>]",
2910
3873
  "```",
2911
3874
  "A router captured by a closure, mapped, or reduced into routes the same way,",
2912
3875
  "and the captured one stays as it was",
2913
3876
  "```",
2914
- "; .start (RotorRouter [2, [], []]); .step {start _};",
3877
+ "; .start (RotorRouter [[], []]); .step {start _};",
2915
3878
  "; [(step 5).left, (step 3).left, start.left]",
2916
3879
  "# [[5], [3], []]",
2917
3880
  "; [r0, p1] & {(_ 5).right}",
2918
3881
  "# [[], [5]]",
2919
3882
  "; “” ([A, B, C] | r0)",
2920
- "# “RotorRouter((),[[1, [2]], { 5 + 3 }],[“b”])”",
3883
+ "# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
2921
3884
  "```",
2922
3885
  "## Routing measures nothing",
2923
3886
  "",
@@ -2942,7 +3905,7 @@ export const HC_SOURCES = new Map([
2942
3905
  "; (r0 Cyclic).####",
2943
3906
  "# $!.cyclic-observation .##",
2944
3907
  "; “” ((r0 Counted).####)",
2945
- "# “Demi((),5,0)”",
3908
+ "# “Demi(1,5,0)”",
2946
3909
  "; counter_.n",
2947
3910
  "# 2",
2948
3911
  "```",
@@ -2957,26 +3920,30 @@ export const HC_SOURCES = new Map([
2957
3920
  "```",
2958
3921
  "Routing nil routes nothing",
2959
3922
  "```",
2960
- "; [(r0 ()).phase, (r0 ()).left]",
2961
- "# [2, []]",
3923
+ "; [(r0 ()).phase, (r0 ()).left, (p1 ()).#]",
3924
+ "# [2, [], 1]",
2962
3925
  "```",
2963
3926
  "## Empty and zero",
2964
3927
  "",
2965
- "The initial router observes as the present zero-load Demi in phase 2. That is",
2966
- "the router's state, and it leaves the fourth hash's convention alone: the",
2967
- "empty host still has no Demi",
3928
+ "The initial router has routed no children, so its Count is zero, and like the",
3929
+ "empty host it has no Demi. Its Size and residual still read zero, and it is a",
3930
+ "present router in phase 2. The Demi of Count zero is a different thing, a Demi",
3931
+ "constructed as such, which routing from the router reaches after one route",
2968
3932
  "```",
2969
- "; [“” (r0.####), (r0.####) = [0, 0].####, [].####]",
2970
- "# [“Demi(<>,0,0)”, <>, ()]",
3933
+ "; [r0.#, r0.##, r0.###, r0.phase, r0.####, [].####]",
3934
+ "# [0, 0, 0, 2, (), ()]",
3935
+ "; Demis <- './hc/demi.hc';",
3936
+ "; [((r0 0).####) = ((Demis.Demi [0, 0, 0]) 0), ((r0 []).####) = ([] []).####]",
3937
+ "# [<>, <>]",
2971
3938
  "```",
2972
3939
  "A Frame of Size zero takes a slot and flips the phase, and an empty array",
2973
3940
  "routed as a child has Size 1, while an empty channel has load 0",
2974
3941
  "```",
2975
3942
  "; .z (r0 0);",
2976
- "; [z.phase, z.left, “” (z.####)]",
2977
- "# [1, [0], “Demi((),0,0)”]",
3943
+ "; [z.phase, z.left, z.#, “” (z.####)]",
3944
+ "# [1, [0], 1, “Demi(1,0,0)”]",
2978
3945
  "; [“” ((r0 []).####), “” (((r0 []) []).####), “” ((((r0 0) 0) 0).####)]",
2979
- "# [“Demi((),1,0)”, “Demi(<>,1,1)”, “Demi((),0,0)”]",
3946
+ "# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,0,0)”]",
2980
3947
  "```",
2981
3948
  "## The router's Demi",
2982
3949
  "",
@@ -2989,59 +3956,79 @@ export const HC_SOURCES = new Map([
2989
3956
  "; [mix.left, mix.right]",
2990
3957
  "# [[“hello”, [[1, 2], [3]], [[], []], { 5 + 3 }], [7, (4, 5), [[], []], <>]]",
2991
3958
  "; [mix.left & {_.##}, mix.right & {_.##}, “” (mix.####)]",
2992
- "# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(<>,22,19)”]",
3959
+ "# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(8,22,19)”]",
2993
3960
  "; “” (((r0 123456789012345678901234567890) 987654321098765432109876543210).####)",
2994
- "# “Demi(<>,123456789012345678901234567890,987654321098765432109876543210)”",
3961
+ "# “Demi(2,123456789012345678901234567890,987654321098765432109876543210)”",
3962
+ "```",
3963
+ "A router's Demi is `Demi(C, L, R)` of its own channels, and its phase is the",
3964
+ "router's phase, for every Count from 1 to 6 and for preloads",
3965
+ "```",
3966
+ "; .sh (steps & {_.####});",
3967
+ "; [sh & {_ = ()}, sh & {_.#}]",
3968
+ "# [[<>, (), (), (), (), (), ()], [(), 1, 2, 3, 4, 5, 6]]",
3969
+ "; [steps &| {.k _; (k.# .> 0) ? {[k.phase = k.####.phase]} : {[]}}, (RotorRouter [[2, 3], [1]]).#### = (Demis.Demi [3, 5, 1])]",
3970
+ "# [[<>, <>, <>, <>, <>, <>], <>]",
2995
3971
  "```",
2996
3972
  "## Observing commutes with routing",
2997
3973
  "",
2998
3974
  "Routing each child of an array X in turn, from the initial router, is the",
2999
3975
  "reduce `X | r0`. Its left channel holds the children at even positions and its",
3000
3976
  "right channel those at odd positions, and its phase is the parity of X's Count.",
3001
- "That interleaving is the invariant a router reached this way keeps: left has",
3002
- "as many children as right in phase 2, and one more in phase 1",
3977
+ "That interleaving is the admissibility invariant, so the same router is",
3978
+ "constructed directly from the two channels",
3003
3979
  "```",
3004
3980
  "; .X [5, “ab”, [1, 2]];",
3005
3981
  "; .rx (X | r0);",
3006
- "; [rx.left, rx.right, rx.phase, rx = (RotorRouter [1, [5, [1, 2]], [“ab”]])]",
3982
+ "; [rx.left, rx.right, rx.phase, rx = (RotorRouter [[5, [1, 2]], [“ab”]])]",
3007
3983
  "# [[5, [1, 2]], [“ab”], 1, <>]",
3008
3984
  "```",
3009
- "For such a router its fourth hash is X's, and routing Y then observing is",
3010
- "observing X Y. The state-level law holds for every router: observing after a",
3011
- "route is applying the router's Demi to the routed Frame",
3985
+ "For every router whose fourth hash exists, routing Y then observing is applying",
3986
+ "the router's Demi to Y, which adds one to the Count. Its fourth hash is X's,",
3987
+ "Count included. The law holds for routers built by routing and for admissible",
3988
+ "preloads alike, in both phases, and for a zero-Size child",
3012
3989
  "```",
3013
3990
  "; .Y [[], [], []];",
3014
- "; [(rx.####) = X.####, ((rx Y).####) = (X Y).####, ((rx Y).####) = ((rx.####) Y)]",
3015
- "# [<>, <>, <>]",
3016
- "; [((p1 Y).####) = ((p1.####) Y), ((p2 {5 + 3}).####) = ((p2.####) {5 + 3}), ((r0 0).####) = ((r0.####) 0)]",
3991
+ "; [(rx.####) = X.####, ((rx Y).####) = (X Y).####, ((rx Y).####) = ((rx.####) Y), (rx.####).# = X.#, ((rx Y).####).# = (X.# + 1)]",
3992
+ "# [<>, <>, <>, <>, <>]",
3993
+ "; [((p1 Y).####) = ((p1.####) Y), ((p2 {5 + 3}).####) = ((p2.####) {5 + 3}), ((p1 0).####) = ((p1.####) 0)]",
3017
3994
  "# [<>, <>, <>]",
3995
+ "; .pre [RotorRouter [[A], []], RotorRouter [[A], [B]], RotorRouter [[A, B], [C]], RotorRouter [[1, 2, 3, 4], [5, 6, 7, 8]], RotorRouter [[1, 2, 3, 4, 5], [6, 7, 8, 9]]];",
3996
+ "; [pre & {((_ Y).####) = ((_.####) Y)}, pre & {((_ 0).####) = ((_.####) 0)}, pre & {(_ Y).phase = ((_.####) Y).phase}]",
3997
+ "# [[<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>]]",
3018
3998
  "```",
3019
- "The empty host is the boundary. `[].####` is nil, so `X.####` fails the first",
3020
- "equation when X is empty, while the initial router observes as a present Demi.",
3021
- "The router is the empty host lifted: routing nothing from it leaves it as it",
3022
- "is, and after one route the two agree again",
3999
+ "The same holds at every step of a walk, Count 1 to 6, and a router can never",
4000
+ "route to the channel its Demi does not deposit into",
3023
4001
  "```",
3024
- "; [([] | r0) = r0, (([] | r0).####) = [].####, (([Y] | r0).####) = ([] Y).####]",
3025
- "# [<>, (), <>]",
4002
+ "; steps &| {.k _; (k.# .> 0) ? {[((k Y).####) = ((k.####) Y)]} : {[]}}",
4003
+ "# [<>, <>, <>, <>, <>, <>]",
4004
+ "; steps &| {.k _; (k.# .> 0) ? {[[((k 4).left.# - k.left.#), (((k.####) 4).left - k.####.left)]]} : {[]}}",
4005
+ "# [[0, 0], [1, 4], [0, 0], [1, 4], [0, 0], [1, 4]]",
3026
4006
  "```",
3027
- "The equation with the fourth hash needs the interleaving. A preloaded router",
3028
- "can break it: one child left and none right in phase 2 is a state no array's",
3029
- "routing reaches, yet its fourth hash equals that of an array whose",
3030
- "history is different",
4007
+ "A failed Size is the answer on both sides: the router routes the Frame and its",
4008
+ "Demi fails when observed, and the Demi refuses the deposit with the same error",
3031
4009
  "```",
3032
- "; .pre (RotorRouter [2, [A], []]);",
3033
- "; [(pre.####) = [A, 0].####, ([A, 0] | r0) = pre]",
3034
- "# [<>, ()]",
4010
+ "; [((p1 Failing).####), ((p1.####) Failing)]",
4011
+ "# [$!.name-missing “..., $!.name-missing “...]",
4012
+ "```",
4013
+ "The empty host is the boundary. `[].####` is nil, so `X.####` fails the first",
4014
+ "equation when X is empty, and so does the initial router, which has routed",
4015
+ "nothing and so has Count zero: it has no Demi, and none is faked. The law there",
4016
+ "reads through the Demi class's zero-Count lifting, `Demi [0, 0, 0]`, and after",
4017
+ "one route the equation holds again",
4018
+ "```",
4019
+ "; [r0.####, ([] | r0) = r0, (([] | r0).####) = [].####, (([Y] | r0).####) = ([] Y).####, ((r0 Y).####) = ((Demis.Demi [0, 0, 0]) Y), ((r0 0).####) = ((Demis.Demi [0, 0, 0]) 0)]",
4020
+ "# [(), <>, <>, <>, <>, <>]",
3035
4021
  "```",
3036
4022
  "## The Demi forgets",
3037
4023
  "",
3038
- "Distinct routers can share a Demi: the fourth hash keeps only the",
3039
- "phase and two sums, not which Frames were routed, nor their order, nor how",
3040
- "the load was split among them",
4024
+ "Distinct routers can share a Demi: the fourth hash keeps only the Count and two",
4025
+ "sums, not which Frames were routed, nor their order, nor how the load was split",
4026
+ "among them. It does keep how many were routed, so a router with fewer children",
4027
+ "and the same loads has a different Demi",
3041
4028
  "```",
3042
- "; .s1 (RotorRouter [2, [2, 3], [1]]); .s2 (RotorRouter [2, [5], [1]]); .s3 (RotorRouter [2, [3, 2], [1]]);",
3043
- "; [s1 = s2, s1 = s3, (s1.####) = (s2.####), (s1.####) = (s3.####)]",
3044
- "# [(), (), <>, <>]",
4029
+ "; .s1 (RotorRouter [[2, 3], [1]]); .s2 (RotorRouter [[5], [1]]); .s3 (RotorRouter [[3, 2], [1]]); .s4 (RotorRouter [[1, 4], [1]]);",
4030
+ "; [s1 = s2, s1 = s3, (s1.####) = (s3.####), (s1.####) = (s4.####), (s1.####) = (s2.####), s1.#, s2.#, s1.##, s2.##]",
4031
+ "# [(), (), <>, <>, (), 3, 2, 6, 6]",
3045
4032
  "```",
3046
4033
  "## Observers, declared",
3047
4034
  "",
@@ -3066,9 +4053,9 @@ export const HC_SOURCES = new Map([
3066
4053
  "## Reading the receiver",
3067
4054
  "",
3068
4055
  "An argument whose fields share the router's names, or its locals', is routed",
3069
- "as one member, and the router reads only its own fields",
4056
+ "as one member, and the router reads only its own fields and its own Count",
3070
4057
  "```",
3071
- "; .masked (r0 [.phase 1; .left [8]; .x 9; .l [7]; 4]);",
4058
+ "; .masked (r0 [.phase 1; .left [8]; .x 9; .l [7]; .n 1; 4]);",
3072
4059
  "; [masked.phase, masked.left.#, masked.left.0.x, masked.right]",
3073
4060
  "# [1, 1, 9, []]",
3074
4061
  "```",
@@ -3096,9 +4083,9 @@ export const HC_SOURCES = new Map([
3096
4083
  "`.###`, which an expectation line, itself a `#…#` comment, cannot hold, so the",
3097
4084
  "printed form is matched here by its beginning",
3098
4085
  "```",
3099
- "; RotorRouter [1, [5], []]",
3100
- "# [.phase 1; .left [5]; .right []; .apply_ {...",
3101
- "; (RotorRouter [1, [5], []]) = [.phase 1; .left [5]; .right []; .apply_ { .x _; .l (_^ .left); .r (_^ .right); ((_^ .phase) = 2) ? { @left (l x); @phase 1; } : { @right (r x); @phase 2; }; }; .# { _^ .phase }; .## { (channel-load (_^ .left)) + (channel-load (_^ .right)) }; .### { (channel-load (_^ .left)) - (channel-load (_^ .right)) }; .toText { “RotorRouter(” (((_^ .phase) = 2) ? { “<>” } : { “()” }) “,” (_^ .left) “,” (_^ .right) “)” };]",
4086
+ "; RotorRouter [[5], []]",
4087
+ "# [.phase 1; .left [5]; .right []; .channels [[5], []]; .apply_ {...",
4088
+ "; (RotorRouter [[5], []]) = [.phase 1; .left [5]; .right []; .channels [[5], []]; .apply_ { .x _; .l (_^ .left); .r (_^ .right); .n (l.# + r.#); ((n %% 2) = 0) ? { .nl (l x); @left nl; @channels [nl, r]; @phase 1; } : { .nr (r x); @right nr; @channels [l, nr]; @phase 2; }; }; .# { .l (_^ .left); .r (_^ .right); l.# + r.# }; .## { (channel-load (_^ .left)) + (channel-load (_^ .right)) }; .### { (channel-load (_^ .left)) - (channel-load (_^ .right)) }; ./ { .ways _; ((_^^ .history) (_^ .channels)) / ways }; .toText { “RotorRouter(” (_^ .left) “,” (_^ .right) “)” };]",
3102
4089
  "# <>",
3103
4090
  "```",
3104
4091
  "## Importing",
@@ -3107,8 +4094,8 @@ export const HC_SOURCES = new Map([
3107
4094
  "importing this file does not import it again",
3108
4095
  "```",
3109
4096
  "; Routers <- './hc/rotor-router.hc';",
3110
- "; [(Routers.RotorRouter [2, [], []]) = r0, “” ((Routers.RotorRouter [2, [], []]) 4), (((Routers.RotorRouter [2, [], []]) 4).####) = [4].####]",
3111
- "# [<>, “RotorRouter((),[4],[])”, <>]",
4097
+ "; [(Routers.RotorRouter [[], []]) = r0, “” ((Routers.RotorRouter [[], []]) 4), (((Routers.RotorRouter [[], []]) 4).####) = [4].####]",
4098
+ "# [<>, “RotorRouter([4],[])”, <>]",
3112
4099
  "",
3113
4100
  ].join("\n"),
3114
4101
  ],