hclang 0.41.1 → 0.43.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`,
|
|
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
|
|
1206
|
-
"phase p = 2 for even n (left next), 1 for odd n (right next). Read these
|
|
1207
|
-
"`.left`, `.right`, `.phase`. n is
|
|
1208
|
-
"identities, properties and the distribution
|
|
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
|
|
1228
|
-
"
|
|
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(
|
|
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).#### =
|
|
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(
|
|
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
|
|
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
|
|
1275
|
-
"secretly stored in []. A zero Size deposit still
|
|
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 [
|
|
1287
|
+
"; ([] Y).#### = ((Demis.Demi [0, 0, 0]) Y)",
|
|
1283
1288
|
"# <>",
|
|
1284
|
-
"; [“” [0].####, “” ([0].#### 0), [].#### = [0].####]",
|
|
1285
|
-
"# [“Demi(
|
|
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(
|
|
1289
|
-
"
|
|
1290
|
-
"
|
|
1291
|
-
"
|
|
1292
|
-
"
|
|
1293
|
-
"
|
|
1294
|
-
"
|
|
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(
|
|
1298
|
-
"; [(swap (q Y)) = ((swap q) Y), (swap ((q Y) [])) = (((swap q) Y) []), (swap (q.scale_ 3)) = ((swap q).scale_ 3)
|
|
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
|
|
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
|
|
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
|
-
"; [
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
1452
|
-
"Applying a Demi to a Frame deposits that Frame's Size into the
|
|
1453
|
-
"
|
|
1454
|
-
"
|
|
1455
|
-
"
|
|
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,66 +1481,119 @@ 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 [
|
|
1466
|
-
"",
|
|
1467
|
-
"**State.** `Demi [
|
|
1468
|
-
"
|
|
1469
|
-
"
|
|
1470
|
-
"
|
|
1471
|
-
"
|
|
1472
|
-
"
|
|
1473
|
-
|
|
1474
|
-
"
|
|
1484
|
+
"`Demis.Demi [0, 0, 0]`.",
|
|
1485
|
+
"",
|
|
1486
|
+
"**State (007.25c).** `Demi [C, L, R]` takes three Counts, any of them zero. `C`",
|
|
1487
|
+
"is the full application Count the state has recorded, not its parity, so",
|
|
1488
|
+
"`Demi [2, 5, 1]` and `Demi [4, 5, 1]` are different states that agree in phase",
|
|
1489
|
+
"and in both loads. Anything else is refused with `$!!.invalid-demi`, a named",
|
|
1490
|
+
"error, as Figures refuses an unsupported host. This replaces the phase-only",
|
|
1491
|
+
"`Demi [phase, L, R]` of earlier versions, where `phase` was 1 or 2 and the",
|
|
1492
|
+
'number of applications was forgotten: `Demi [2, 5, 3]` used to mean "an even',
|
|
1493
|
+
'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',
|
|
1494
|
+
"its Count. `Demi [0, 0, 0]` is the neutral start.",
|
|
1495
|
+
"",
|
|
1496
|
+
"**Count and phase.** `d.count` and `d.#` are the stored `C`. The phase is a",
|
|
1497
|
+
"derived field, `d.phase`, a two-state reading of the Count's parity and never",
|
|
1498
|
+
"the integer `C %% 2`: 2 when `C` is even, `C = 0` included, left next, and 1",
|
|
1499
|
+
"when it is odd, right next. It is a Count rather than all or nil because a",
|
|
1500
|
+
"field cannot hold nil, and a Count keeps the odd phase present. It is derived,",
|
|
1501
|
+
"not independent state: it is written only together with `C`, so the fields are",
|
|
1502
|
+
"the whole state and two Demis are `=` exactly when their Count and loads are.",
|
|
1503
|
+
"States with the same phase and loads but different Counts stay distinguishable.",
|
|
1475
1504
|
"",
|
|
1476
1505
|
"**Observers.** A Demi declares its own Count, Size and residual (011.20): its",
|
|
1477
|
-
"
|
|
1506
|
+
"Count `C`, its total load `L+R` and the signed difference `L−R`. An aggregate",
|
|
1478
1507
|
"otherwise observes its elements, and a Demi has none, so without these it",
|
|
1479
|
-
"would observe as 0, 1, 0. Its fourth hash
|
|
1480
|
-
"
|
|
1481
|
-
"",
|
|
1482
|
-
"
|
|
1483
|
-
"
|
|
1484
|
-
"
|
|
1485
|
-
"
|
|
1486
|
-
"
|
|
1508
|
+
"would observe as 0, 1, 0. Its fourth hash is not declared: no class can",
|
|
1509
|
+
"declare `.####`. The derivation from the three observers cannot tell an empty",
|
|
1510
|
+
"host from a Demi of Count zero, because both read 0, 0, 0, and it answers nil",
|
|
1511
|
+
"for either. A Demi of Count zero is a present state, so the fourth hash",
|
|
1512
|
+
"recognizes an instance of this class intrinsically (007.25e,",
|
|
1513
|
+
"`lib/frames/fourth-hash.ts`): a Frame whose stored `count`, `left` and `right`",
|
|
1514
|
+
"are Counts and which is `==` to the Demi this constructor builds from them",
|
|
1515
|
+
"answers that fresh reconstruction, an equal instance for every `C`. Nothing of",
|
|
1516
|
+
"the source runs, so a foreign aggregate that forges `#`, `##`, `###` or a",
|
|
1517
|
+
"`.####` method gets only the ordinary derived fourth hash. `[].####` and",
|
|
1518
|
+
"`0.####` stay nil: those are hosts with no children, and a host with no",
|
|
1519
|
+
"children has no Demi.",
|
|
1520
|
+
"",
|
|
1521
|
+
"**Application**, `d x`: observe x's Size once, deposit it into the channel the",
|
|
1522
|
+
"phase selects (left in phase 2, right in phase 1) and add one to the Count,",
|
|
1523
|
+
"which flips the phase. A Size of zero still counts. If x has no Size, its",
|
|
1524
|
+
"failure is the answer rather than a deposit. It is a mutating method, `apply_`,",
|
|
1525
|
+
"so through a name, `d x` is a functional update: it answers a new Demi and",
|
|
1526
|
+
"leaves d unchanged.",
|
|
1487
1527
|
"",
|
|
1488
1528
|
"**Scaling**, `d.scale_ k`: multiply both loads by a Count k, keeping the",
|
|
1489
|
-
"
|
|
1490
|
-
"`x.####.scale_ (y.##)` for a nonempty host x. `scale_` stays,
|
|
1491
|
-
"fourth hash and Star correspondence use; `d * k`
|
|
1492
|
-
"through the operator below.",
|
|
1529
|
+
"Count. It is the numerical shadow of Star: `(x * y).####` is",
|
|
1530
|
+
"`x.####.scale_ (y.##)` for a nonempty host x, Count included. `scale_` stays,",
|
|
1531
|
+
"as the name the fourth hash and Star correspondence use; `d * k` answers the",
|
|
1532
|
+
"same Demi through the operator below.",
|
|
1493
1533
|
"",
|
|
1494
|
-
"**Arithmetic**, `d + x`, `d - x
|
|
1495
|
-
"
|
|
1534
|
+
"**Arithmetic**, `d + x`, `d - x` and `d * x` (015.11). A class answers an",
|
|
1535
|
+
"operator by declaring a method under its name, found on the operand and its",
|
|
1496
1536
|
"declared parents, the chain its other methods come from, so an operator in a",
|
|
1497
1537
|
"method body keeps its global meaning rather than recurring into the class that",
|
|
1498
|
-
"is running.
|
|
1499
|
-
"
|
|
1500
|
-
"construction and observation
|
|
1501
|
-
"
|
|
1502
|
-
"
|
|
1503
|
-
"",
|
|
1504
|
-
"
|
|
1505
|
-
"
|
|
1506
|
-
"
|
|
1507
|
-
"
|
|
1508
|
-
"
|
|
1509
|
-
"
|
|
1510
|
-
"- `d
|
|
1511
|
-
"
|
|
1512
|
-
"
|
|
1513
|
-
"
|
|
1514
|
-
"
|
|
1515
|
-
"
|
|
1516
|
-
"",
|
|
1517
|
-
"
|
|
1518
|
-
"
|
|
1519
|
-
"
|
|
1520
|
-
"
|
|
1521
|
-
"",
|
|
1522
|
-
"
|
|
1523
|
-
"
|
|
1524
|
-
"
|
|
1538
|
+
"is running. All three **construct a fresh Demi state** from the one Size",
|
|
1539
|
+
"observation `x.##` of their operand, keeping Figure 008's distinction between",
|
|
1540
|
+
"construction and observation. They are **fixed-channel load transformations**",
|
|
1541
|
+
"on the two-load shadow, consistent with the channel loads of a `RotorRouter`",
|
|
1542
|
+
"(`hc/rotor-router.hc`): `+` and `-` add `x.##` to one fixed channel's load the",
|
|
1543
|
+
"way a route adds a Frame's Size to the channel it lands in, and `*` is the Star",
|
|
1544
|
+
"shadow `scale_`. These are correspondences, not a claim that the Router",
|
|
1545
|
+
"declares named `+`, `-` or `*` methods. None of the three is application: **all",
|
|
1546
|
+
"keep `C`** and so the phase, and each answers a fresh value and leaves `d` as it",
|
|
1547
|
+
"was. Because they change loads without an application, they can reach a state",
|
|
1548
|
+
"no run of applications reaches, such as `C = 0` with a nonzero load.",
|
|
1549
|
+
"",
|
|
1550
|
+
"- `d + x` is the **tally** operator: it deposits `x.##` on the **right**,",
|
|
1551
|
+
" `Demi [C, L, R + x.##]`. A sizeless host's failure is the answer, as it is for",
|
|
1552
|
+
" application. It is `d.deposit-right_ (x.##)`, a load-only functional update.",
|
|
1553
|
+
"- `d - x` is the **alternator** operator: it deposits on the **left**,",
|
|
1554
|
+
" `Demi [C, L + x.##, R]`, as `d.deposit-left_ (x.##)`. It is not subtraction: a deposit only ever adds, so",
|
|
1555
|
+
" a load never goes negative and stays a whole Count. Right deposition lowers",
|
|
1556
|
+
" the signed residual `L − R` and left deposition raises it, the reverse of",
|
|
1557
|
+
" ordinary signed-scalar `+` and `-`.",
|
|
1558
|
+
"- `d * x` is the **inlay** operator: it scales both loads by the operand's Size",
|
|
1559
|
+
" `x.##`, `Demi [C, sL, sR]` for `s = x.##`, keeping `C`. It reads the operand",
|
|
1560
|
+
" through the one Size observer, as `+` and `-` do, so any sized Frame scales a",
|
|
1561
|
+
" Demi, not only a bare Count. It is literally `d.scale_ (x.##)`.",
|
|
1562
|
+
"",
|
|
1563
|
+
"None of the three names the `Demi` constructor inside its method. A bare name",
|
|
1564
|
+
"in a method is looked up on the argument first (spec 7), and a decimal is",
|
|
1565
|
+
"unit-taggable, so inside `d + 2.5` the name `Demi` read `2.5.Demi`, a tagged",
|
|
1566
|
+
"number, and applying that to `[C, L, R]` was `$!.repetition-domain` (007.25e,",
|
|
1567
|
+
"PR #480 review). Each operator now hands the one Size it observed to a",
|
|
1568
|
+
"load-only functional update on the receiver, `deposit-right_`, `deposit-left_`",
|
|
1569
|
+
"or `scale_`, so `D + 2.5`, `D - 2.5` and `D * 2.5` all read `(2.5).## = 2`.",
|
|
1570
|
+
"`deposit-right_ k` and `deposit-left_ k` take a Count and refuse anything else",
|
|
1571
|
+
"with `$!!.invalid-demi`, since a negative deposit is no Demi.",
|
|
1572
|
+
"",
|
|
1573
|
+
"**Rational readings (007.25).** Because `C` is kept, two exact ratios are read",
|
|
1574
|
+
"from the state. They are unary observations of the stored state, not `/` and",
|
|
1575
|
+
"not `%%`, and they take no divisor. HC runs a method only when it is applied to",
|
|
1576
|
+
"something, so they are applied to nil, `d.size-ratio ()`; any other operand is",
|
|
1577
|
+
"`$!!.unary-observation`, so `d.size-ratio 4` is refused rather than read as a",
|
|
1578
|
+
"division by 4.",
|
|
1579
|
+
"",
|
|
1580
|
+
"- `d.size-ratio ()` is `S / C` for `S = L + R`, exact and nonnegative.",
|
|
1581
|
+
"- `d.residual-ratio ()` is `Δ / C` for `Δ = L − R`, exact and signed.",
|
|
1582
|
+
"",
|
|
1583
|
+
"Both are **nil when `C = 0`**, whatever the loads: the state exists and its Size",
|
|
1584
|
+
"and residual still read, but the ratio is absent, so there is no `0/0`, infinity",
|
|
1585
|
+
"or invented zero. They are different observables and neither replaces Size or",
|
|
1586
|
+
"residual; `C`, `S / C` and `Δ / C` together give back `S` and `Δ`. The answer is",
|
|
1587
|
+
"the language's exact `/`: a FrameRational when not whole, such as `5/2`, which",
|
|
1588
|
+
"the runtime keeps in lowest terms (the improper `6/4` reads `3/2`), and a",
|
|
1589
|
+
"FrameInt when whole, since the runtime collapses a whole rational. It is never a",
|
|
1590
|
+
"float or an integer quotient and remainder. The Count is a number the state",
|
|
1591
|
+
"stores or an application adds to; it is not a Frame-native witness of history,",
|
|
1592
|
+
"and `S / C` and `Δ / C` are arithmetic readings of it, not a construction of",
|
|
1593
|
+
"rational geometry.",
|
|
1594
|
+
"",
|
|
1595
|
+
"**Text.** A Demi prints as what it is, an aggregate of fields and methods. As",
|
|
1596
|
+
"text it reads `Demi(C,L,R)`, with the Count and both loads.",
|
|
1525
1597
|
"",
|
|
1526
1598
|
"**Methods read their own state through `_^`.** A bare name inside a method is",
|
|
1527
1599
|
"looked up on the argument first (spec 7), and a Demi is applied to arbitrary",
|
|
@@ -1530,123 +1602,164 @@ export const HC_SOURCES = new Map([
|
|
|
1530
1602
|
"count lexically (spec a06). What a branch needs is bound as a local at method",
|
|
1531
1603
|
"level, where nested blocks read it.",
|
|
1532
1604
|
"```",
|
|
1533
|
-
".Demi {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.
|
|
1534
|
-
" (((
|
|
1605
|
+
".Demi {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.c (__ .0); .l (__ .1); .r (__ .2);",
|
|
1606
|
+
" (((c ~ (0.<>)) ? {l ~ (0.<>)}) ? {r ~ (0.<>)}) ? {.p (((c %% 2) = 0) ? {2} : {1}); [",
|
|
1607
|
+
" .count c;",
|
|
1535
1608
|
" .phase p;",
|
|
1536
1609
|
" .left l;",
|
|
1537
1610
|
" .right r;",
|
|
1538
|
-
" .# {_^.
|
|
1611
|
+
" .# {_^.count};",
|
|
1539
1612
|
" .## {_^.left + _^.right};",
|
|
1540
1613
|
" .### {_^.left - _^.right};",
|
|
1541
|
-
" .apply_ {.s (_ .##); .l (_^ .left); .r (_^ .right);",
|
|
1542
|
-
" (s ~ (0.<>)) ? {(
|
|
1614
|
+
" .apply_ {.s (_ .##); .c (_^ .count); .l (_^ .left); .r (_^ .right); .p (_^ .phase);",
|
|
1615
|
+
" (s ~ (0.<>)) ? {(p = 2) ? {@left (l + s); @phase 1;} : {@right (r + s); @phase 2;}; @count (c + 1); _^^} : {s}};",
|
|
1543
1616
|
" .scale_ {.k _; .l (_^ .left); .r (_^ .right);",
|
|
1544
1617
|
" (k ~ (0.<>)) ? {@left (l * k); @right (r * k); _^^} : {$!!.invalid-scale}};",
|
|
1545
|
-
"
|
|
1546
|
-
" (
|
|
1547
|
-
"
|
|
1548
|
-
" (
|
|
1549
|
-
"
|
|
1550
|
-
" (
|
|
1551
|
-
"
|
|
1552
|
-
" (
|
|
1553
|
-
"
|
|
1618
|
+
" .deposit-right_ {.k _; .r (_^ .right);",
|
|
1619
|
+
" (k ~ (0.<>)) ? {@right (r + k); _^^} : {$!!.invalid-demi}};",
|
|
1620
|
+
" .deposit-left_ {.k _; .l (_^ .left);",
|
|
1621
|
+
" (k ~ (0.<>)) ? {@left (l + k); _^^} : {$!!.invalid-demi}};",
|
|
1622
|
+
" .+ {.s (_ .##);",
|
|
1623
|
+
" (s ~ (0.<>)) ? {(_^^ .deposit-right_ s)} : {s}};",
|
|
1624
|
+
" .- {.s (_ .##);",
|
|
1625
|
+
" (s ~ (0.<>)) ? {(_^^ .deposit-left_ s)} : {s}};",
|
|
1626
|
+
" .* {.s (_ .##);",
|
|
1627
|
+
" (s ~ (0.<>)) ? {(_^^ .scale_ s)} : {s}};",
|
|
1628
|
+
" .size-ratio {.c (_^ .count); .s (_^ .##); .u ((_ = ()) ? {1} : {0});",
|
|
1629
|
+
" (c .> 0) ? {(u = 1) ? {s / c} : {$!!.unary-observation}}};",
|
|
1630
|
+
" .residual-ratio {.c (_^ .count); .d (_^ .###); .u ((_ = ()) ? {1} : {0});",
|
|
1631
|
+
" (c .> 0) ? {(u = 1) ? {d / c} : {$!!.unary-observation}}};",
|
|
1632
|
+
" .toText {“Demi(” (_^ .count) “,” (_^ .left) “,” (_^ .right) “)”}",
|
|
1554
1633
|
" ]} : {$!!.invalid-demi}} : {$!!.invalid-demi}};",
|
|
1555
1634
|
"```",
|
|
1556
1635
|
"## Construction",
|
|
1557
1636
|
"",
|
|
1558
|
-
"A Demi holds
|
|
1559
|
-
"from the same constructor share nothing",
|
|
1637
|
+
"A Demi holds its Count and its two loads, and the phase that Count fixes. Each",
|
|
1638
|
+
"instance is its own: two built from the same constructor share nothing. The",
|
|
1639
|
+
"neutral start `Demi [0, 0, 0]` is present, in phase 2",
|
|
1560
1640
|
"```",
|
|
1561
|
-
"; .d (Demi [
|
|
1562
|
-
"; [d.phase, d.left, d.right]",
|
|
1563
|
-
"# [2, 0, 0]",
|
|
1641
|
+
"; .d (Demi [0, 0, 0]);",
|
|
1642
|
+
"; [d.count, d.phase, d.left, d.right, d.#, d.##, d.###, “” d]",
|
|
1643
|
+
"# [0, 2, 0, 0, 0, 0, 0, “Demi(0,0,0)”]",
|
|
1564
1644
|
"; .a (Demi [2, 5, 3]); .b (Demi [1, 7, 0]);",
|
|
1565
|
-
"; [“” a, “” b, a.left, b.left]",
|
|
1566
|
-
"# [“Demi(
|
|
1645
|
+
"; [“” a, “” b, a.left, b.left, a.phase, b.phase]",
|
|
1646
|
+
"# [“Demi(2,5,3)”, “Demi(1,7,0)”, 5, 7, 2, 1]",
|
|
1647
|
+
"```",
|
|
1648
|
+
"Any Counts are a state. The phase is read from the parity of the Count, never",
|
|
1649
|
+
"from the Count itself: even is phase 2, zero included, and odd is phase 1",
|
|
1650
|
+
"```",
|
|
1651
|
+
"; [0, 1, 2, 3, 4, 5, 100, 101] & {(Demi [_, 5, 3]).phase}",
|
|
1652
|
+
"# [2, 1, 2, 1, 2, 1, 2, 1]",
|
|
1653
|
+
"; [(Demi [2, 5, 3]).#, (Demi [4, 5, 3]).#, (Demi [100, 5, 3]).count, (Demi [100, 5, 3]).phase, (Demi [3, 5, 3]).phase]",
|
|
1654
|
+
"# [2, 4, 100, 2, 1]",
|
|
1567
1655
|
"```",
|
|
1568
|
-
"
|
|
1656
|
+
"A positive Count over empty loads and nonzero loads over a zero Count are both",
|
|
1657
|
+
"states. Anything that is not three Counts is refused",
|
|
1569
1658
|
"```",
|
|
1570
|
-
"; Demi [3, 0, 0]",
|
|
1571
|
-
"#
|
|
1572
|
-
"; [Demi [2, (0 - 1), 0], Demi [
|
|
1573
|
-
"# [$!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi]",
|
|
1659
|
+
"; [“” (Demi [3, 0, 0]), “” (Demi [0, 3, 0]), “” (Demi [0, 0, 4])]",
|
|
1660
|
+
"# [“Demi(3,0,0)”, “Demi(0,3,0)”, “Demi(0,0,4)”]",
|
|
1661
|
+
"; [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]]",
|
|
1662
|
+
"# [$!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi, $!!.invalid-demi]",
|
|
1574
1663
|
"```",
|
|
1575
1664
|
"## Application",
|
|
1576
1665
|
"",
|
|
1577
|
-
"Each application deposits the argument's Size into the
|
|
1578
|
-
"the phase. The receiver is left
|
|
1666
|
+
"Each application deposits the argument's Size into the channel the phase",
|
|
1667
|
+
"selects and adds one to the Count, which flips the phase. The receiver is left",
|
|
1668
|
+
"as it was",
|
|
1579
1669
|
"```",
|
|
1580
1670
|
"; “” (d [5, 3])",
|
|
1581
|
-
"# “Demi(
|
|
1671
|
+
"# “Demi(1,8,0)”",
|
|
1582
1672
|
"; “” d",
|
|
1583
|
-
"# “Demi(
|
|
1673
|
+
"# “Demi(0,0,0)”",
|
|
1584
1674
|
"; “” (((d 5) 3) 7)",
|
|
1585
|
-
"# “Demi(
|
|
1675
|
+
"# “Demi(3,12,3)”",
|
|
1586
1676
|
"```",
|
|
1587
|
-
"A Size of zero deposits nothing and still
|
|
1677
|
+
"A Size of zero deposits nothing and still counts, in both phases",
|
|
1588
1678
|
"```",
|
|
1589
|
-
"; [(d 0).phase, ((d 0) 0).phase, (d 0).left, ((d 0) 0).right]",
|
|
1590
|
-
"# [1, 2, 0, 0]",
|
|
1679
|
+
"; [(d 0).count, ((d 0) 0).count, (d 0).phase, ((d 0) 0).phase, (d 0).left, ((d 0) 0).right]",
|
|
1680
|
+
"# [1, 2, 1, 2, 0, 0]",
|
|
1591
1681
|
"```",
|
|
1592
1682
|
"Any Frame is applied by its Size, measured without running it: text, the",
|
|
1593
1683
|
"empty aggregate and all (Size 1 each), nested aggregates, a closure (one per",
|
|
1594
1684
|
"word, so `{5 + 3}` is 9), empty text, and loads too large for a machine integer",
|
|
1595
1685
|
"```",
|
|
1596
1686
|
"; “” ((((((d “hello”) []) <>) [[1, 2], [3]]) {5 + 3}) “”)",
|
|
1597
|
-
"# “Demi(
|
|
1687
|
+
"# “Demi(6,15,7)”",
|
|
1598
1688
|
"; “” ((d 123456789012345678901234567890) 987654321098765432109876543210)",
|
|
1599
|
-
"# “Demi(
|
|
1689
|
+
"# “Demi(2,123456789012345678901234567890,987654321098765432109876543210)”",
|
|
1600
1690
|
"```",
|
|
1601
1691
|
"A Frame without a Size is not deposited: its failure is the answer",
|
|
1602
1692
|
"```",
|
|
1603
1693
|
"; d ([].nope)",
|
|
1604
1694
|
"# $!.name-missing “...",
|
|
1605
1695
|
"; “” d",
|
|
1606
|
-
"# “Demi(
|
|
1696
|
+
"# “Demi(0,0,0)”",
|
|
1607
1697
|
"```",
|
|
1608
1698
|
"Deposit reads the receiver through `_^`, so an argument that holds fields of",
|
|
1609
1699
|
"the same names deposits by its Size and nothing else",
|
|
1610
1700
|
"```",
|
|
1611
|
-
"; “” (d [.
|
|
1612
|
-
"# “Demi(
|
|
1701
|
+
"; “” (d [.count 50; .left 99; .phase 1; .s 100; 4])",
|
|
1702
|
+
"# “Demi(1,4,0)”",
|
|
1703
|
+
"; “” ((Demi [2, 5, 3]) [.count 50; .left 99; .right 7; 4])",
|
|
1704
|
+
"# “Demi(3,9,3)”",
|
|
1613
1705
|
"```",
|
|
1614
1706
|
"A Demi captured by a closure, mapped, or reduced is applied the same way, and",
|
|
1615
1707
|
"the captured one stays as it was",
|
|
1616
1708
|
"```",
|
|
1617
|
-
"; .start (Demi [
|
|
1709
|
+
"; .start (Demi [0, 0, 0]); .step {start _};",
|
|
1618
1710
|
"; [“” (step 5), “” (step 3), “” start]",
|
|
1619
|
-
"# [“Demi(
|
|
1711
|
+
"# [“Demi(1,5,0)”, “Demi(1,3,0)”, “Demi(0,0,0)”]",
|
|
1620
1712
|
"; [d, a] & {“” (_ 5)}",
|
|
1621
|
-
"# [“Demi(
|
|
1622
|
-
"; “” ([5, 3, 7] | (Demi [
|
|
1623
|
-
"# “Demi(
|
|
1713
|
+
"# [“Demi(1,5,0)”, “Demi(3,10,3)”]",
|
|
1714
|
+
"; “” ([5, 3, 7] | (Demi [0, 0, 0]))",
|
|
1715
|
+
"# “Demi(3,12,3)”",
|
|
1624
1716
|
"```",
|
|
1625
1717
|
"Through a mutable name, application writes the Demi in place",
|
|
1626
1718
|
"```",
|
|
1627
|
-
"; .m_ (Demi [
|
|
1719
|
+
"; .m_ (Demi [0, 0, 0]);",
|
|
1628
1720
|
"; m_ 5;",
|
|
1629
|
-
";
|
|
1630
|
-
"
|
|
1721
|
+
"; m_ 3;",
|
|
1722
|
+
"; [“” m_, m_.count, m_.phase]",
|
|
1723
|
+
"# [“Demi(2,5,3)”, 2, 2]",
|
|
1724
|
+
"```",
|
|
1725
|
+
"## Application counts",
|
|
1726
|
+
"",
|
|
1727
|
+
"Starting at Count 0 in phase 2, or at Count 1 in phase 1, applying 5, 3, 7 and 2",
|
|
1728
|
+
"in turn grows the Count by exactly one each time and alternates the phase. The",
|
|
1729
|
+
"Size and residual are the alternating route's, from the left or from the right",
|
|
1730
|
+
"```",
|
|
1731
|
+
"; .chain {.s _; [s, (s 5), ((s 5) 3), (((s 5) 3) 7), ((((s 5) 3) 7) 2)]};",
|
|
1732
|
+
"; .c0 (chain (Demi [0, 0, 0])); .c1 (chain (Demi [1, 0, 0]));",
|
|
1733
|
+
"; [c0 & {_.count}, c0 & {_.phase}, c0 & {_.##}, c0 & {_.###}]",
|
|
1734
|
+
"# [[0, 1, 2, 3, 4], [2, 1, 2, 1, 2], [0, 5, 8, 15, 17], [0, 5, 2, 9, 7]]",
|
|
1735
|
+
"; [c1 & {_.count}, c1 & {_.phase}, c1 & {_.##}, c1 & {_.###}]",
|
|
1736
|
+
"# [[1, 2, 3, 4, 5], [1, 2, 1, 2, 1], [0, 5, 8, 15, 17], [0, -5, -2, -9, -7]]",
|
|
1737
|
+
"```",
|
|
1738
|
+
"The Count and the loads together are the state, and the fourth hash of each step",
|
|
1739
|
+
"is that step, Count included",
|
|
1740
|
+
"```",
|
|
1741
|
+
"; [(c0 & {_.####}) = c0, (c1 & {_.####}) = c1]",
|
|
1742
|
+
"# [<>, <>]",
|
|
1631
1743
|
"```",
|
|
1632
1744
|
"## Observers",
|
|
1633
1745
|
"",
|
|
1634
|
-
"A Demi's Count is its
|
|
1746
|
+
"A Demi's Count is its stored Count, its Size the total load and its residual the",
|
|
1635
1747
|
"signed difference, including a present zero-load Demi in either phase",
|
|
1636
1748
|
"```",
|
|
1637
|
-
"; .e (Demi [
|
|
1638
|
-
"; [e.#, e.##, e
|
|
1639
|
-
"# [
|
|
1640
|
-
"; [d.#, d.##, d.###, (Demi [1, 0, 0])
|
|
1641
|
-
"# [
|
|
1749
|
+
"; .e (Demi [3, 12, 3]);",
|
|
1750
|
+
"; [e.#, e.##, e.###, e.phase]",
|
|
1751
|
+
"# [3, 15, 9, 1]",
|
|
1752
|
+
"; [d.#, d.##, d.###, (Demi [1, 0, 0]).#, (Demi [1, 0, 0]).phase]",
|
|
1753
|
+
"# [0, 0, 0, 1, 1]",
|
|
1642
1754
|
"```",
|
|
1643
|
-
"
|
|
1644
|
-
"
|
|
1755
|
+
"Count is `.#`, not phase. The same phase and loads with a different Count are",
|
|
1756
|
+
"different states with the same Size and residual",
|
|
1645
1757
|
"```",
|
|
1646
|
-
";
|
|
1647
|
-
"
|
|
1648
|
-
"
|
|
1649
|
-
"
|
|
1758
|
+
"; .f2 (Demi [2, 5, 1]); .f4 (Demi [4, 5, 1]);",
|
|
1759
|
+
"; [f2.phase = f4.phase, f2.## = f4.##, f2.### = f4.###, f2.# = f4.#, f2 = f4, f2 = (Demi [2, 5, 1])]",
|
|
1760
|
+
"# [<>, <>, <>, (), (), <>]",
|
|
1761
|
+
"; [f2.#, f4.#, f2.##, f2.###, f2.phase, f4.phase]",
|
|
1762
|
+
"# [2, 4, 6, 4, 2, 2]",
|
|
1650
1763
|
"```",
|
|
1651
1764
|
"A Demi inside an aggregate contributes its declared Size",
|
|
1652
1765
|
"```",
|
|
@@ -1655,99 +1768,183 @@ export const HC_SOURCES = new Map([
|
|
|
1655
1768
|
"```",
|
|
1656
1769
|
"## The fourth hash",
|
|
1657
1770
|
"",
|
|
1658
|
-
"`.####`
|
|
1659
|
-
"
|
|
1771
|
+
"`.####` of a Demi is that Demi, however often it is taken. It is equal, not",
|
|
1772
|
+
"identical: each observation builds a new instance. Its Count is kept for every",
|
|
1773
|
+
"Count, including zero",
|
|
1774
|
+
"```",
|
|
1775
|
+
"; [e.#### = e, e.#### === e, e.#### == e, ((e.####).####).#### = e, (e.####).# = e.#]",
|
|
1776
|
+
"# [<>, (), <>, <>, <>]",
|
|
1777
|
+
"; [d.#### = d, (Demi [1, 0, 0]).#### = (Demi [1, 0, 0]), (Demi [100, 5, 3]).####.count, (Demi [0, 3, 0]).#### = (Demi [0, 3, 0])]",
|
|
1778
|
+
"# [<>, <>, 100, <>]",
|
|
1779
|
+
"; [f2.####.# , f4.####.#, f2.#### = f4.####, f2.#### = f2]",
|
|
1780
|
+
"# [2, 4, (), <>]",
|
|
1781
|
+
"```",
|
|
1782
|
+
"`.####` of a host answers an instance of this class, built from the same source,",
|
|
1783
|
+
"so it compares equal to one built here. The host's whole Count is kept: it is",
|
|
1784
|
+
"not reduced to its parity",
|
|
1660
1785
|
"```",
|
|
1661
|
-
"; [[5, 3].#### = (Demi [2, 5, 3]), “hello”.#### = (Demi [
|
|
1786
|
+
"; [[5, 3].#### = (Demi [2, 5, 3]), “hello”.#### = (Demi [5, 3, 2]), [0].#### = (Demi [1, 0, 0])]",
|
|
1662
1787
|
"# [<>, <>, <>]",
|
|
1788
|
+
"; [[5, 3].####.#, “hello”.####.#, “hello”.####.phase, [5, 3, 7].####.#, [5, 3, 7].####.phase]",
|
|
1789
|
+
"# [2, 5, 1, 3, 1]",
|
|
1663
1790
|
"; “” [5, 3, 7].####",
|
|
1664
|
-
"# “Demi(
|
|
1791
|
+
"# “Demi(3,12,3)”",
|
|
1792
|
+
"```",
|
|
1793
|
+
"Hosts whose Counts differ by an even number do not share a fourth hash, though",
|
|
1794
|
+
"they share phase and, here, loads",
|
|
1795
|
+
"```",
|
|
1796
|
+
"; [[5, 3].#### = [5, 3, 0, 0].####, [5, 3].####.phase = [5, 3, 0, 0].####.phase, [5, 3].####.## = [5, 3, 0, 0].####.##]",
|
|
1797
|
+
"# [(), <>, <>]",
|
|
1665
1798
|
"```",
|
|
1666
1799
|
"It is nil where there is no Demi: an empty host, Count zero, no Count, or no",
|
|
1667
|
-
"residual.
|
|
1668
|
-
"group observes as its
|
|
1800
|
+
"residual. A host with no children is not a Demi of Count zero. Properties are",
|
|
1801
|
+
"not elements, sharing counts each occurrence, and a group observes as its",
|
|
1802
|
+
"elements",
|
|
1669
1803
|
"```",
|
|
1670
|
-
"; [[].####, 0.####, ().####, <2,3,5
|
|
1671
|
-
"# [(), (), (), ()]",
|
|
1804
|
+
"; [[].####, 0.####, ().####, <2,3,5>.####, “”.####]",
|
|
1805
|
+
"# [(), (), (), (), ()]",
|
|
1672
1806
|
"; .shared [1, 2];",
|
|
1673
1807
|
"; [[.a 100; 5, 3].#### = [5, 3].####, [shared, shared].#### = (Demi [2, 3, 3]), (5, 3).#### = (Demi [2, 5, 3])]",
|
|
1674
1808
|
"# [<>, <>, <>]",
|
|
1675
1809
|
"```",
|
|
1810
|
+
"The two zero-Count cases are different. A constructed `Demi [0, 0, 0]` is a",
|
|
1811
|
+
"present value, while the empty host and the Count 0 have none. They agree on",
|
|
1812
|
+
"Count, Size and residual, so the difference is not read from the observers: the",
|
|
1813
|
+
"fourth hash recognizes an instance of this class (007.25e)",
|
|
1814
|
+
"```",
|
|
1815
|
+
"; [[].# = d.#, [].## = d.##, 0.## = d.##, 0.### = d.###]",
|
|
1816
|
+
"# [<>, (), <>, <>]",
|
|
1817
|
+
"; [[].#### = (), 0.#### = (), d.#### = d, ((Demi [0, 0, 0]).####).count]",
|
|
1818
|
+
"# [<>, <>, <>, 0]",
|
|
1819
|
+
"```",
|
|
1820
|
+
"Zero-Count Demis reached without an application are present too, and so is",
|
|
1821
|
+
"each functional update of one",
|
|
1822
|
+
"```",
|
|
1823
|
+
"; [“” ((Demi [0, 3, 0]).####), “” ((d + 4).####), “” ((d - 2.5).####), “” ((d * 7).####)]",
|
|
1824
|
+
"# [“Demi(0,3,0)”, “Demi(0,0,4)”, “Demi(0,2,0)”, “Demi(0,0,0)”]",
|
|
1825
|
+
"```",
|
|
1826
|
+
"## Only a Demi is a Demi",
|
|
1827
|
+
"",
|
|
1828
|
+
"No class declares its own `.####`. An aggregate that declares a method under",
|
|
1829
|
+
"that name keeps it as an ordinary property, which the fourth hash never runs:",
|
|
1830
|
+
"its fourth hash is derived from its observers like any other Frame's. So a",
|
|
1831
|
+
"method answering a foreign aggregate, an error, nil, itself, or a write",
|
|
1832
|
+
"changes nothing, and nothing in it runs",
|
|
1833
|
+
"```",
|
|
1834
|
+
"; .noted_ [.n 0; .bump_ {@n (_^.n + 1);}];",
|
|
1835
|
+
"; .Liar [.#### {[.# {0}; .## {0}; .### {0}]}];",
|
|
1836
|
+
"; .Loud [.#### {noted_.bump_ (); Demi [0, 0, 0]}];",
|
|
1837
|
+
"; .Selfish [.#### {_^.####}];",
|
|
1838
|
+
"; .Broken [.#### {[].nope}];",
|
|
1839
|
+
"; [Liar.####, Loud.####, Selfish.####, Broken.####, noted_.n]",
|
|
1840
|
+
"# [(), (), (), (), 0]",
|
|
1841
|
+
"; [“” ([.#### {Demi [9, 9, 9]}; 5, 3].####), [.#### {Demi [9, 9, 9]}; 5, 3].#### = [5, 3].####]",
|
|
1842
|
+
"# [“Demi(2,5,3)”, <>]",
|
|
1843
|
+
"```",
|
|
1844
|
+
"Forged observers do not make a Demi. An aggregate declaring Count, Size and",
|
|
1845
|
+
"residual 0, 0, 0 reads exactly as `Demi [0, 0, 0]` does, and still has no Demi,",
|
|
1846
|
+
"because it is not one; with a nonzero Count it gets the derived Demi of those",
|
|
1847
|
+
"observers, a fresh instance of this class, never the aggregate itself",
|
|
1848
|
+
"```",
|
|
1849
|
+
"; .Zero [.# {0}; .## {0}; .### {0}];",
|
|
1850
|
+
"; .Three [.# {3}; .## {5}; .### {1}];",
|
|
1851
|
+
"; [[Zero.#, Zero.##, Zero.###] = [d.#, d.##, d.###], Zero.####, “” Three.####, Three.#### = Three]",
|
|
1852
|
+
"# [<>, (), “Demi(3,3,2)”, ()]",
|
|
1853
|
+
"```",
|
|
1854
|
+
"Fields named like a Demi's are not enough either. Recognition compares the",
|
|
1855
|
+
"whole instance, fields and methods, by typed equality `==` with the Demi the",
|
|
1856
|
+
"constructor builds from the stored `count`, `left` and `right`. So a bare record",
|
|
1857
|
+
"of those fields, one whose phase disagrees with its Count, one whose Count is a",
|
|
1858
|
+
"decimal, and one that adds a field are foreign, and with Count zero they have",
|
|
1859
|
+
"no Demi",
|
|
1860
|
+
"```",
|
|
1861
|
+
"; .Rec [.count 0; .phase 2; .left 0; .right 0];",
|
|
1862
|
+
"; .Fake [.count 0; .phase 1; .left 0; .right 0; .# {_^ .count}; .## {_^ .left + _^ .right}; .### {_^ .left - _^ .right}];",
|
|
1863
|
+
"; .Dec [.count 0.0; .phase 2; .left 0; .right 0; .# {0}; .## {0}; .### {0}];",
|
|
1864
|
+
"; [Rec.####, Fake.####, Dec.####, [.extra 1; .count 0; .left 0; .right 0].####]",
|
|
1865
|
+
"# [(), (), (), ()]",
|
|
1866
|
+
"```",
|
|
1867
|
+
"A Demi with a Count is recognized as one, and what it answers is a fresh",
|
|
1868
|
+
"reconstruction from its stored state, equal to it and not it",
|
|
1869
|
+
"```",
|
|
1870
|
+
"; [(Demi [3, 5, 1]).#### == (Demi [3, 5, 1]), (Demi [3, 5, 1]).#### === (Demi [3, 5, 1]), “” (Demi [3, 5, 1]).####]",
|
|
1871
|
+
"# [<>, (), “Demi(3,5,1)”]",
|
|
1872
|
+
"```",
|
|
1676
1873
|
"## Observing commutes with applying",
|
|
1677
1874
|
"",
|
|
1678
1875
|
"For a nonempty host X, observing X Y is applying X's Demi to Y, and both equal",
|
|
1679
|
-
"the observation of the array X Y constructs",
|
|
1876
|
+
"the observation of the array X Y constructs, with Count one greater",
|
|
1680
1877
|
"```",
|
|
1681
1878
|
"; .X [5, “ab”, [1, 2]];",
|
|
1682
|
-
"; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3})]",
|
|
1683
|
-
"# [<>, <>, <>]",
|
|
1879
|
+
"; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3}), (X 7).####.# = (X.####.# + 1)]",
|
|
1880
|
+
"# [<>, <>, <>, <>]",
|
|
1684
1881
|
"```",
|
|
1685
1882
|
"The empty host is the boundary. `[].####` is nil, a choice of convention",
|
|
1686
1883
|
"(011.15g) rather than a theorem, and applying nil answers the argument, so",
|
|
1687
|
-
"the equation as written fails there. Lifting the empty host to the
|
|
1688
|
-
"
|
|
1689
|
-
"
|
|
1884
|
+
"the equation as written fails there. Lifting the empty host to the Demi of",
|
|
1885
|
+
"Count zero restores it: that is the initialized-router reading, and it is also",
|
|
1886
|
+
"what a reduce starts from",
|
|
1690
1887
|
"```",
|
|
1691
|
-
"; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [
|
|
1888
|
+
"; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [0, 0, 0]) 7), ([] 7).#### = ([7] | (Demi [0, 0, 0]))]",
|
|
1692
1889
|
"# [(), <>, <>]",
|
|
1693
|
-
"; [] | (Demi [
|
|
1890
|
+
"; [] | (Demi [0, 0, 0]) = (Demi [0, 0, 0])",
|
|
1694
1891
|
"# <>",
|
|
1695
1892
|
"```",
|
|
1696
1893
|
"## Scaling and Star",
|
|
1697
1894
|
"",
|
|
1698
|
-
"Scaling multiplies both loads and keeps the phase: zero annihilates,
|
|
1699
|
-
"the identity, and scaling composes",
|
|
1895
|
+
"Scaling multiplies both loads and keeps the Count and phase: zero annihilates,",
|
|
1896
|
+
"one is the identity, and scaling composes",
|
|
1700
1897
|
"```",
|
|
1701
|
-
"; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6)]",
|
|
1702
|
-
"# [“Demi(
|
|
1898
|
+
"; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6), (e.scale_ 2).#]",
|
|
1899
|
+
"# [“Demi(3,24,6)”, “Demi(3,0,0)”, <>, <>, 3]",
|
|
1703
1900
|
"; e.scale_ (0 - 2)",
|
|
1704
1901
|
"# $!!.invalid-scale",
|
|
1705
1902
|
"```",
|
|
1706
|
-
"It is the shadow of Star on a nonempty host",
|
|
1903
|
+
"It is the shadow of Star on a nonempty host, Count included",
|
|
1707
1904
|
"```",
|
|
1708
|
-
"; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##))]",
|
|
1709
|
-
"# [<>, <>]",
|
|
1905
|
+
"; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##)), ([5, 3] * 3).####.# = [5, 3].####.#]",
|
|
1906
|
+
"# [<>, <>, <>]",
|
|
1710
1907
|
"```",
|
|
1711
1908
|
"## Arithmetic",
|
|
1712
1909
|
"",
|
|
1713
|
-
"
|
|
1714
|
-
"
|
|
1715
|
-
"
|
|
1716
|
-
"
|
|
1717
|
-
"
|
|
1718
|
-
"
|
|
1910
|
+
"Three operators act on a Demi's state, each reading its operand through the one",
|
|
1911
|
+
"Size observer `x.##`. They are fixed-channel load transformations consistent",
|
|
1912
|
+
"with a `RotorRouter`'s channel loads (`hc/rotor-router.hc`), not named Router",
|
|
1913
|
+
"methods. `+`, `-` and `*` **construct a fresh Demi** from observations of their",
|
|
1914
|
+
"operands: `+` is tally, depositing `x.##` on the right; `-` is alternator,",
|
|
1915
|
+
"depositing on the left; and `*` is inlay, scaling both loads by `x.##` through",
|
|
1916
|
+
"`scale_`, the Star shadow. Each keeps the Count, and so the phase, answers a",
|
|
1917
|
+
"fresh value and leaves its operand as it was, so they compose by nesting",
|
|
1719
1918
|
"```",
|
|
1720
1919
|
"; .D (Demi [2, 5, 3]);",
|
|
1721
1920
|
"; [“” (D + 4), “” (D - 4), “” (D * 3)]",
|
|
1722
|
-
"# [“Demi(
|
|
1723
|
-
"; [(D / 2), ((D + 4) / 2)]",
|
|
1724
|
-
"# [1, -1]",
|
|
1921
|
+
"# [“Demi(2,5,7)”, “Demi(2,9,3)”, “Demi(2,15,9)”]",
|
|
1725
1922
|
"; [“” ((D + 4) - 2), “” ((D - 2) + 4), “” ((D + 4) * 3)]",
|
|
1726
|
-
"# [“Demi(
|
|
1923
|
+
"# [“Demi(2,7,7)”, “Demi(2,7,7)”, “Demi(2,15,21)”]",
|
|
1727
1924
|
"; “” D",
|
|
1728
|
-
"# “Demi(
|
|
1925
|
+
"# “Demi(2,5,3)”",
|
|
1729
1926
|
"```",
|
|
1730
|
-
"A deposit keeps the phase, including phase 1, where application would
|
|
1731
|
-
"and a zero Size deposits nothing while still answering a Demi. The
|
|
1732
|
-
"measured by its Size, so any sized Frame deposits",
|
|
1927
|
+
"A deposit keeps the Count and phase, including phase 1, where application would",
|
|
1928
|
+
"flip it, and a zero Size deposits nothing while still answering a Demi. The",
|
|
1929
|
+
"operand is measured by its Size, so any sized Frame deposits",
|
|
1733
1930
|
"```",
|
|
1734
|
-
"; [(D + 4).#, (D - 4).#, (D * 3)
|
|
1735
|
-
"# [2, 2, 2]",
|
|
1931
|
+
"; [(D + 4).#, (D - 4).#, (D * 3).#, (D + 4).count, (D + 4).phase]",
|
|
1932
|
+
"# [2, 2, 2, 2, 2]",
|
|
1736
1933
|
"; .P (Demi [1, 5, 3]);",
|
|
1737
|
-
"; [“” (P + 4), (P + 4).#, “” (P - 4)]",
|
|
1738
|
-
"# [“Demi(
|
|
1934
|
+
"; [“” (P + 4), (P + 4).#, (P + 4).phase, “” (P - 4)]",
|
|
1935
|
+
"# [“Demi(1,5,7)”, 1, 1, “Demi(1,9,3)”]",
|
|
1739
1936
|
"; [“” (D + 0), “” (D - 0), “” (D [3, 4])]",
|
|
1740
|
-
"# [“Demi(
|
|
1937
|
+
"# [“Demi(2,5,3)”, “Demi(2,5,3)”, “Demi(3,12,3)”]",
|
|
1741
1938
|
"```",
|
|
1742
|
-
"Deposit is not application and deposit is not subtraction. `D x`
|
|
1743
|
-
"phase and `D + x` does not, so they reach different
|
|
1744
|
-
"left load and never takes from the right, so a load
|
|
1745
|
-
"signed residual only rises",
|
|
1939
|
+
"Deposit is not application and deposit is not subtraction. `D x` adds one to the",
|
|
1940
|
+
"Count and flips the phase, and `D + x` does not, so they reach different",
|
|
1941
|
+
"states; `D - x` adds to the left load and never takes from the right, so a load",
|
|
1942
|
+
"stays a whole Count and the signed residual only rises",
|
|
1746
1943
|
"```",
|
|
1747
1944
|
"; [(D + 4).###, (D - 4).###, D.###]",
|
|
1748
1945
|
"# [-2, 6, 2]",
|
|
1749
|
-
"; [((D 4).# = (D + 4).#), (D 4).###, (D + 4)
|
|
1750
|
-
"# [(), 6, -2]",
|
|
1946
|
+
"; [((D 4).# = (D + 4).#), (D 4).###, (D + 4).###, (D 4).#, (D 4).phase]",
|
|
1947
|
+
"# [(), 6, -2, 3, 1]",
|
|
1751
1948
|
"```",
|
|
1752
1949
|
"Order of a right then a left deposit does not matter, and scaling after a",
|
|
1753
1950
|
"balanced deposit is the Star shadow of scaling first",
|
|
@@ -1755,20 +1952,67 @@ export const HC_SOURCES = new Map([
|
|
|
1755
1952
|
"; [((D + 4) - 2) = ((D - 2) + 4), ((D + 4) * 3) = ((D * 3) + 12)]",
|
|
1756
1953
|
"# [<>, <>]",
|
|
1757
1954
|
"```",
|
|
1758
|
-
"A sizeless host refuses, its failure the answer, as
|
|
1759
|
-
"
|
|
1760
|
-
"
|
|
1761
|
-
"
|
|
1762
|
-
"
|
|
1763
|
-
"
|
|
1764
|
-
"
|
|
1765
|
-
"
|
|
1766
|
-
"
|
|
1767
|
-
"
|
|
1768
|
-
"
|
|
1769
|
-
"
|
|
1770
|
-
"
|
|
1771
|
-
"
|
|
1955
|
+
"A sizeless host refuses on all three operators, its failure the answer, as",
|
|
1956
|
+
"application refuses it. `*` reads its operand's Size rather than demanding a",
|
|
1957
|
+
"bare Count, so a Demi, an aggregate or a decimal works through its `.##`, while",
|
|
1958
|
+
"`D * 0` still annihilates",
|
|
1959
|
+
"```",
|
|
1960
|
+
"; [D + ([].nope), D - ([].nope), D * ([].nope)]",
|
|
1961
|
+
"# [$!.name-missing “..., $!.name-missing “..., $!.name-missing “...]",
|
|
1962
|
+
"```",
|
|
1963
|
+
"## Deposits by Size",
|
|
1964
|
+
"",
|
|
1965
|
+
"`+` and `-` read their operand through the one Size observer as `*` does, so",
|
|
1966
|
+
"any sized Frame deposits its Size: a decimal its truncated magnitude, text its",
|
|
1967
|
+
"characters, an aggregate its element count, a Demi `L + R`, and a closure one",
|
|
1968
|
+
"per word. These are the review's own examples, from `Demi [0, 0, 0]`",
|
|
1969
|
+
"```",
|
|
1970
|
+
"; [(2.5).##, (1.5).##, (0 - 1.5).##]",
|
|
1971
|
+
"# [2, 1, 1]",
|
|
1972
|
+
"; [“” ((Demi [0, 0, 0]) + 2), “” ((Demi [0, 0, 0]) + 2.5), “” ((Demi [0, 0, 0]) - 1.5), “” ((Demi [1, 2, 2]) * 2.5)]",
|
|
1973
|
+
"# [“Demi(0,0,2)”, “Demi(0,0,2)”, “Demi(0,1,0)”, “Demi(1,4,4)”]",
|
|
1974
|
+
"; [“” (D + 2.5), “” (D - 2.5), “” (P + 0.5), “” (P - (0 - 3.5))]",
|
|
1975
|
+
"# [“Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(1,5,3)”, “Demi(1,8,3)”]",
|
|
1976
|
+
"; [“” (D + “abc”), “” (D - [[], []]), “” (D + (Demi [1, 2, 4])), “” (D - {5 + 3}), “” (D + <>), “” (D - [])]",
|
|
1977
|
+
"# [“Demi(2,5,6)”, “Demi(2,7,3)”, “Demi(2,5,9)”, “Demi(2,14,3)”, “Demi(2,5,4)”, “Demi(2,6,3)”]",
|
|
1978
|
+
"```",
|
|
1979
|
+
"Each keeps the full Count, and with it the phase, in both parities; leaves the",
|
|
1980
|
+
"receiver as it was, even through a mutable name; and refuses a sizeless operand",
|
|
1981
|
+
"with its failure",
|
|
1982
|
+
"```",
|
|
1983
|
+
"; [(D + 2.5).#, (D + 2.5).phase, (P - 1.5).#, (P - 1.5).phase, “” D, “” P]",
|
|
1984
|
+
"# [2, 2, 1, 1, “Demi(2,5,3)”, “Demi(1,5,3)”]",
|
|
1985
|
+
"; .q_ (Demi [2, 5, 3]);",
|
|
1986
|
+
"; [“” (q_ + 2.5), “” (q_ - 2.5), “” (q_ * 2.5), “” q_]",
|
|
1987
|
+
"# [“Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(2,10,6)”, “Demi(2,5,3)”]",
|
|
1988
|
+
"; [D + ([2.5].nope), D - ([2.5].nope), (Demi [0, 0, 0]) + ([].nope)]",
|
|
1989
|
+
"# [$!.name-missing “..., $!.name-missing “..., $!.name-missing “...]",
|
|
1990
|
+
"```",
|
|
1991
|
+
"The argument cannot reach the receiver's names. A decimal is unit-taggable,",
|
|
1992
|
+
"`2.5.Demi` is a tagged number, and an aggregate can hold fields named like the",
|
|
1993
|
+
"receiver's or its locals; none of them changes which state is updated, and",
|
|
1994
|
+
"such an aggregate deposits only its elements' Size, here 4",
|
|
1995
|
+
"```",
|
|
1996
|
+
"; (2.5).Demi",
|
|
1997
|
+
"# 2.5.Demi",
|
|
1998
|
+
"; [“” (D + [.Demi 9; .right 99; .left 99; .count 7; .k 50; 4]), “” (D - [.Demi 9; .left 99; .l 99; .s 50; 4])]",
|
|
1999
|
+
"# [“Demi(2,5,7)”, “Demi(2,9,3)”]",
|
|
2000
|
+
"```",
|
|
2001
|
+
"The functional updates behind them take a Count, so a negative or fractional",
|
|
2002
|
+
"deposit is not a Demi",
|
|
2003
|
+
"```",
|
|
2004
|
+
"; [D.deposit-right_ (0 - 1), D.deposit-left_ 2.5, “” (D.deposit-right_ 2), “” (D.deposit-left_ 2), “” D]",
|
|
2005
|
+
"# [$!!.invalid-demi, $!!.invalid-demi, “Demi(2,5,5)”, “Demi(2,7,3)”, “Demi(2,5,3)”]",
|
|
2006
|
+
"```",
|
|
2007
|
+
"`*` scales by the operand's Size, so its domain is every sized Frame: a Demi",
|
|
2008
|
+
"contributes `L + R`, an aggregate its element count, a decimal its truncated",
|
|
2009
|
+
"magnitude, and a zero Size annihilates both loads. `D * 3` is unchanged, since",
|
|
2010
|
+
"`3.## = 3`, and the result keeps the Count in either parity",
|
|
2011
|
+
"```",
|
|
2012
|
+
"; [“” (D * (Demi [1, 2, 4])), “” (D * [[], []]), “” (D * 2.5), “” (D * 0)]",
|
|
2013
|
+
"# [“Demi(2,30,18)”, “Demi(2,10,6)”, “Demi(2,10,6)”, “Demi(2,0,0)”]",
|
|
2014
|
+
"; [“” (D * 1), (D * 3).#, (P * 3).#, “” (P * 3)]",
|
|
2015
|
+
"# [“Demi(2,5,3)”, 2, 1, “Demi(1,15,9)”]",
|
|
1772
2016
|
"```",
|
|
1773
2017
|
"The signed-scalar reading misleads: `+` lowers the residual and `-` raises it,",
|
|
1774
2018
|
"so `D + 4` is not “larger” than `D`, and `D - 4` is not `D` made smaller",
|
|
@@ -1776,6 +2020,125 @@ export const HC_SOURCES = new Map([
|
|
|
1776
2020
|
"; [(D + 4).### .< D.###, (D - 4).### .> D.###]",
|
|
1777
2021
|
"# [<>, <>]",
|
|
1778
2022
|
"```",
|
|
2023
|
+
"Fixed-channel operators change loads without an application, so they keep the",
|
|
2024
|
+
"Count and can leave a zero Count over nonzero loads. That state is present, and",
|
|
2025
|
+
"its Size and residual read",
|
|
2026
|
+
"```",
|
|
2027
|
+
"; .Y ((Demi [0, 0, 0]) + 4);",
|
|
2028
|
+
"; [“” Y, “” ((Demi [0, 0, 0]) - 4), Y.count, Y.phase, Y.##, Y.###]",
|
|
2029
|
+
"# [“Demi(0,0,4)”, “Demi(0,4,0)”, 0, 2, 4, -4]",
|
|
2030
|
+
"; [“” (D * 3), (D.scale_ 2).#, ((D + 4) 1).#, ((D + 4) 1).phase]",
|
|
2031
|
+
"# [“Demi(2,15,9)”, 2, 3, 1]",
|
|
2032
|
+
"```",
|
|
2033
|
+
"## Rational readings",
|
|
2034
|
+
"",
|
|
2035
|
+
"For `C > 0` the Size reading is `S / C` and the residual reading `Δ / C`, two",
|
|
2036
|
+
"different observables. With `C = 2`, `L = 5`, `R = 1` they are 3 and 2. With the",
|
|
2037
|
+
"loads swapped the Size reading is unchanged and the residual reading changes",
|
|
2038
|
+
"sign. With `L = 5`, `R = 0` they are the improper 5/2, neither 2 nor 3",
|
|
2039
|
+
"```",
|
|
2040
|
+
"; .A (Demi [2, 5, 1]); .B (Demi [2, 1, 5]); .D5 (Demi [2, 5, 0]);",
|
|
2041
|
+
"; [[A.##, A.###, A.size-ratio (), A.residual-ratio ()], [B.##, B.###, B.size-ratio (), B.residual-ratio ()], [D5.##, D5.###, D5.size-ratio (), D5.residual-ratio ()]]",
|
|
2042
|
+
"# [[6, 4, 3, 2], [6, -4, 3, -2], [5, 5, 5/2, 5/2]]",
|
|
2043
|
+
"```",
|
|
2044
|
+
"They differ when the loads do. Non-divisible ratios stay exact and the runtime",
|
|
2045
|
+
"reduces them: 6/4 reads 3/2, 8/6 reads 4/3. At `C = 1` they are the Size and the",
|
|
2046
|
+
"residual, and an odd Count works as an even one does",
|
|
2047
|
+
"```",
|
|
2048
|
+
"; [(Demi [2, 3, 2]).size-ratio (), (Demi [2, 3, 2]).residual-ratio ()]",
|
|
2049
|
+
"# [5/2, 1/2]",
|
|
2050
|
+
"; [(Demi [4, 6, 0]).size-ratio (), (Demi [4, 6, 0]).residual-ratio (), (Demi [4, 5, 1]).size-ratio (), (Demi [4, 5, 1]).residual-ratio ()]",
|
|
2051
|
+
"# [3/2, 3/2, 3/2, 1]",
|
|
2052
|
+
"; [(Demi [6, 10, 2]).size-ratio (), (Demi [6, 10, 2]).residual-ratio (), (Demi [3, 5, 1]).size-ratio (), (Demi [3, 5, 1]).residual-ratio ()]",
|
|
2053
|
+
"# [2, 4/3, 2, 4/3]",
|
|
2054
|
+
"; [(Demi [1, 7, 2]).size-ratio (), (Demi [1, 7, 2]).residual-ratio (), (Demi [1, 2, 7]).size-ratio (), (Demi [1, 2, 7]).residual-ratio ()]",
|
|
2055
|
+
"# [9, 5, 9, -5]",
|
|
2056
|
+
"```",
|
|
2057
|
+
"Two Counts with the same phase and loads give different ratios, as they are",
|
|
2058
|
+
"different states: the ratio is what distinguishes `[2, 5, 1]` from `[4, 5, 1]`",
|
|
2059
|
+
"beyond their identity",
|
|
2060
|
+
"```",
|
|
2061
|
+
"; [f2.size-ratio (), f4.size-ratio (), f2.residual-ratio (), f4.residual-ratio ()]",
|
|
2062
|
+
"# [3, 3/2, 2, 1]",
|
|
2063
|
+
"```",
|
|
2064
|
+
"The readings are exact: a third stays a third and multiplying back by the Count",
|
|
2065
|
+
"returns the Size and the residual, with no float or truncation. A whole reading",
|
|
2066
|
+
"is a FrameInt, a non-whole one a FrameRational, and the residual reading is",
|
|
2067
|
+
"signed",
|
|
2068
|
+
"```",
|
|
2069
|
+
"; [(Demi [3, 1, 0]).size-ratio (), (Demi [3, 0, 1]).residual-ratio (), ((Demi [3, 1, 0]).size-ratio ()) * 3]",
|
|
2070
|
+
"# [1/3, -1/3, 1]",
|
|
2071
|
+
"; [(A.size-ratio ()) * A.count = A.##, (A.residual-ratio ()) * A.count = A.###, (B.residual-ratio ()) * B.count = B.###, (D5.size-ratio ()) * D5.count = D5.##]",
|
|
2072
|
+
"# [<>, <>, <>, <>]",
|
|
2073
|
+
"; [A.size-ratio () ~ ((0 - 1).<>), D5.size-ratio () ~ ((1 / 2).<>), D5.size-ratio () ~ ((0 - 1).<>), B.residual-ratio () ~ ((0 - 1).<>), A.size-ratio () ~ (0.<>)]",
|
|
2074
|
+
"# [<>, <>, (), <>, ()]",
|
|
2075
|
+
"```",
|
|
2076
|
+
"An empty state, a balanced nonempty one and a positive Count over empty loads all",
|
|
2077
|
+
"read zero, in either phase",
|
|
2078
|
+
"```",
|
|
2079
|
+
"; [(Demi [2, 0, 0]).size-ratio (), (Demi [1, 0, 0]).size-ratio (), (Demi [3, 0, 0]).residual-ratio ()]",
|
|
2080
|
+
"# [0, 0, 0]",
|
|
2081
|
+
"; [(Demi [2, 3, 3]).size-ratio (), (Demi [2, 3, 3]).residual-ratio (), (Demi [1, 3, 3]).size-ratio (), (Demi [1, 3, 3]).residual-ratio ()]",
|
|
2082
|
+
"# [3, 0, 6, 0]",
|
|
2083
|
+
"```",
|
|
2084
|
+
"Loads too large for a machine integer give the same exact readings",
|
|
2085
|
+
"```",
|
|
2086
|
+
"; .G (Demi [1000000007, 123456789012345678901234567890, 987654321098765432109876543210]);",
|
|
2087
|
+
"; [(G.size-ratio ()) * G.count = G.##, (G.residual-ratio ()) * G.count = G.###, G.###]",
|
|
2088
|
+
"# [<>, <>, -864197532086419753208641975320]",
|
|
2089
|
+
"```",
|
|
2090
|
+
"## Zero Count",
|
|
2091
|
+
"",
|
|
2092
|
+
"At `C = 0` neither ratio is defined, so each is nil. The state is still present,",
|
|
2093
|
+
"and its Size and residual still read, including after loads were added without",
|
|
2094
|
+
"any application. This is absence, not a zero, a division error or an infinity",
|
|
2095
|
+
"```",
|
|
2096
|
+
"; .Z0 (Demi [0, 3, 0]); .Z1 (Demi [0, 0, 0]); .Z2 ((Demi [0, 0, 0]) + 4);",
|
|
2097
|
+
"; [[Z0.##, Z0.###, Z0.size-ratio (), Z0.residual-ratio ()], [Z1.##, Z1.###, Z1.size-ratio (), Z1.residual-ratio ()], [Z2.##, Z2.###, Z2.size-ratio (), Z2.residual-ratio ()]]",
|
|
2098
|
+
"# [[3, 3, (), ()], [0, 0, (), ()], [4, -4, (), ()]]",
|
|
2099
|
+
"```",
|
|
2100
|
+
"One application gives the first ratio: from the zero-Count state the Count is 1",
|
|
2101
|
+
"and the readings are the Size and the residual",
|
|
2102
|
+
"```",
|
|
2103
|
+
"; [(Z1 7).count, (Z1 7).size-ratio (), (Z1 7).residual-ratio (), (Z2 3).count, (Z2 3).size-ratio (), (Z2 3).residual-ratio ()]",
|
|
2104
|
+
"# [1, 7, 7, 1, 7, -1]",
|
|
2105
|
+
"```",
|
|
2106
|
+
"## Unary observations",
|
|
2107
|
+
"",
|
|
2108
|
+
"A reading takes no divisor. It is applied to nil, and an operand is refused",
|
|
2109
|
+
"rather than read as the divisor, so it is neither `/` nor `%%`. The class",
|
|
2110
|
+
"declares neither operator, so they answer nil as for any aggregate without one",
|
|
2111
|
+
"```",
|
|
2112
|
+
"; [A.size-ratio 4, A.residual-ratio [], A.size-ratio 0, A.residual-ratio “abc”]",
|
|
2113
|
+
"# [$!!.unary-observation, $!!.unary-observation, $!!.unary-observation, $!!.unary-observation]",
|
|
2114
|
+
"; [A / 4, A %% 4]",
|
|
2115
|
+
"# [(), ()]",
|
|
2116
|
+
"```",
|
|
2117
|
+
"A reading at the wrong depth fails safe. Inside a branch `_^` is not the",
|
|
2118
|
+
"receiver, so a reading written that way answers `$!.name-missing` and no ratio",
|
|
2119
|
+
"```",
|
|
2120
|
+
"; .Shallow [.count 2; .left 5; .right 1; .size-ratio {.c (_^ .count); (c .> 0) ? {(_^ .left) / c}}];",
|
|
2121
|
+
"; Shallow.size-ratio ()",
|
|
2122
|
+
"# $!.name-missing “...",
|
|
2123
|
+
"```",
|
|
2124
|
+
"## Law check",
|
|
2125
|
+
"",
|
|
2126
|
+
"For every Count `1..5` and every pair of loads `0..4` (125 states), multiplying",
|
|
2127
|
+
"each reading by the Count gives back the Size and the residual; and for Count 0,",
|
|
2128
|
+
"the 25 states have both readings absent",
|
|
2129
|
+
"```",
|
|
2130
|
+
"; .ccs [1, 2, 3, 4, 5]; .ls [0, 1, 2, 3, 4];",
|
|
2131
|
+
"; .statesP (ccs &| {.c _; ls &| {.l _; ls & {Demi [c, l, _]}}});",
|
|
2132
|
+
"; .lawP {.k _; .c (k.count); [(((k.size-ratio ()) * c) = k.##), (((k.residual-ratio ()) * c) = k.###)]};",
|
|
2133
|
+
"; .checksP (statesP &| lawP);",
|
|
2134
|
+
"; [statesP.#, checksP.#, checksP = (checksP & {<>})]",
|
|
2135
|
+
"# [125, 250, <>]",
|
|
2136
|
+
"; .statesZ (ls &| {.l _; ls & {Demi [0, l, _]}});",
|
|
2137
|
+
"; .lawZ {.k _; [(k.size-ratio () = ()), (k.residual-ratio () = ())]};",
|
|
2138
|
+
"; .checksZ (statesZ &| lawZ);",
|
|
2139
|
+
"; [statesZ.#, checksZ.#, checksZ = (checksZ & {<>})]",
|
|
2140
|
+
"# [25, 50, <>]",
|
|
2141
|
+
"```",
|
|
1779
2142
|
"## A precise regression: a load read at the wrong depth",
|
|
1780
2143
|
"",
|
|
1781
2144
|
"Carets count lexically, so inside a branch `_^` is the method's own scope, not",
|
|
@@ -1796,14 +2159,33 @@ export const HC_SOURCES = new Map([
|
|
|
1796
2159
|
"; [r.phase, r.left]",
|
|
1797
2160
|
"# [1, 5]",
|
|
1798
2161
|
"```",
|
|
2162
|
+
"## Against a Router",
|
|
2163
|
+
"",
|
|
2164
|
+
"A `RotorRouter` (`hc/rotor-router.hc`) declares its Count as the number of",
|
|
2165
|
+
"children it has routed, `left.# + right.#`, and its Size and residual from the",
|
|
2166
|
+
"Sizes of those children. That is a structural count of the stored channels, not",
|
|
2167
|
+
"a counter and not its phase. A router that routed two children from the empty",
|
|
2168
|
+
"state shares its Count, Size and residual with the Demi that applied the same",
|
|
2169
|
+
"two Sizes, and so does its fourth hash. This is a comparison of readings, not",
|
|
2170
|
+
"an identity: the router keeps the Frames and a Demi forgets them",
|
|
2171
|
+
"```",
|
|
2172
|
+
"; Routers <- './hc/rotor-router.hc';",
|
|
2173
|
+
"; .rr (((Routers.RotorRouter [[], []]) 5) 1);",
|
|
2174
|
+
"; .kk (((Demi [0, 0, 0]) 5) 1);",
|
|
2175
|
+
"; [rr.#, rr.##, rr.###, kk.count, kk.#, kk.##, kk.###, (rr.left.# + rr.right.#), rr.#### = kk.####, rr.phase = kk.phase]",
|
|
2176
|
+
"# [2, 6, 4, 2, 2, 6, 4, 2, <>, <>]",
|
|
2177
|
+
"; .r4 (((rr 7) 2)); .k4 (((kk 7) 2));",
|
|
2178
|
+
"; [r4.#, k4.count, r4.phase, k4.phase, r4.#### = k4.####, (k4.size-ratio ()), (k4.residual-ratio ())]",
|
|
2179
|
+
"# [4, 4, 2, 2, <>, 15/4, 9/4]",
|
|
2180
|
+
"```",
|
|
1799
2181
|
"## Importing",
|
|
1800
2182
|
"",
|
|
1801
2183
|
"Imported, the file binds the same class. The import is an example line, so",
|
|
1802
2184
|
"the evaluator, which reads this file without a root, never runs it",
|
|
1803
2185
|
"```",
|
|
1804
2186
|
"; Demis <- './hc/demi.hc';",
|
|
1805
|
-
"; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [
|
|
1806
|
-
"# [<>, “Demi(
|
|
2187
|
+
"; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [0, 0, 0]) 4)]",
|
|
2188
|
+
"# [<>, “Demi(1,4,0)”]",
|
|
1807
2189
|
"",
|
|
1808
2190
|
].join("\n"),
|
|
1809
2191
|
],
|
|
@@ -2016,14 +2398,16 @@ export const HC_SOURCES = new Map([
|
|
|
2016
2398
|
"The fourth observer derives a Demi from Count, Size and residual.",
|
|
2017
2399
|
"A zero Count or absent residual gives no Demi; errors propagate. A schema used",
|
|
2018
2400
|
"as an explicit element contributes Size normally, even though its own Demi is nil.",
|
|
2019
|
-
"A present Demi has Size L+R and residual L−R. Its Count is
|
|
2020
|
-
"
|
|
2021
|
-
"
|
|
2022
|
-
"observation, including present zero loads
|
|
2401
|
+
"A present Demi has Count C, Size L+R and residual L−R. Its Count is its full",
|
|
2402
|
+
"application Count (007.25c), and its phase is derived from the parity of that",
|
|
2403
|
+
"Count: 2 for even and 1 for odd. The derivation therefore reconstructs its data",
|
|
2404
|
+
"value on repeated fourth observation, including present zero loads; a Demi of",
|
|
2405
|
+
"Count zero, which the observers cannot tell from an empty host, declares its own",
|
|
2406
|
+
"fourth hash (`hc/demi.hc`).",
|
|
2023
2407
|
"A present Demi is an instance of the HC class in `hc/demi.hc` (011.20), and",
|
|
2024
|
-
"reads as text `Demi(
|
|
2025
|
-
"and
|
|
2026
|
-
"X.#### Y; for an empty host, start from the
|
|
2408
|
+
"reads as text `Demi(count,left,right)`. Applying a Demi to Y deposits Y's Size",
|
|
2409
|
+
"and adds one to the Count, so for a nonempty Figure host X, (X Y).#### is",
|
|
2410
|
+
"X.#### Y; for an empty host, start from the Demi of Count zero instead,",
|
|
2027
2411
|
"because [].#### is nil. Scaling is the method `scale_`, the shadow of Star:",
|
|
2028
2412
|
"(X * Y).#### is X.####.scale_ (Y.##) for a nonempty host. Count is a terminal",
|
|
2029
2413
|
"quantity: positive Counts agree with pure Figures of that terminal Size, but 0",
|
|
@@ -2031,17 +2415,17 @@ export const HC_SOURCES = new Map([
|
|
|
2031
2415
|
"including [0].####.",
|
|
2032
2416
|
"```",
|
|
2033
2417
|
"; [[].####, 0.####, “” “hello”.####, <2,3,5>.####]",
|
|
2034
|
-
"# [(), (), “Demi(
|
|
2418
|
+
"# [(), (), “Demi(5,3,2)”, ()]",
|
|
2035
2419
|
"; [(10 - 5).#### = 5.####, (0 - 5).#### = 5.####, (5.0).#### = 5.####, “hello”.#### = 5.####]",
|
|
2036
2420
|
"# [<>, <>, <>, <>]",
|
|
2037
2421
|
"; [<>.#, <>.##, <>.###, ().##]",
|
|
2038
2422
|
"# [0, 1, 0, 1]",
|
|
2039
2423
|
"; [1, 2, 3, 7] & {“” _.####}",
|
|
2040
|
-
"# [“Demi(
|
|
2424
|
+
"# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,2,1)”, “Demi(7,4,3)”]",
|
|
2041
2425
|
"; [[0], [“hello”], [<2,3,5>,2], {5 + 3}] & {“” _.####}",
|
|
2042
|
-
"# [“Demi(
|
|
2426
|
+
"# [“Demi(1,0,0)”, “Demi(1,5,0)”, “Demi(2,3,2)”, “Demi(3,8,1)”]",
|
|
2043
2427
|
"; [“” ([[],[]].#### 3), “” (7.####.scale_ 2), ([[],[]] 3).#### = ([[],[]].#### 3)]",
|
|
2044
|
-
"# [“Demi(
|
|
2428
|
+
"# [“Demi(3,4,1)”, “Demi(7,8,6)”, <>]",
|
|
2045
2429
|
"```",
|
|
2046
2430
|
"A RotorRouter, the class in `hc/rotor-router.hc` (011.21), keeps the routed",
|
|
2047
2431
|
"Figures themselves in two ordered channels and declares the observers that make",
|
|
@@ -2050,7 +2434,7 @@ export const HC_SOURCES = new Map([
|
|
|
2050
2434
|
"fourth hash is the Figure's.",
|
|
2051
2435
|
"```",
|
|
2052
2436
|
"; Routers <- './hc/rotor-router.hc';",
|
|
2053
|
-
"; .fr ([[], [[], []], []] | (Routers.RotorRouter [
|
|
2437
|
+
"; .fr ([[], [[], []], []] | (Routers.RotorRouter [[], []]));",
|
|
2054
2438
|
"; [fr.left, fr.right, fr.#### = [[], [[], []], []].####]",
|
|
2055
2439
|
"# [[[], []], [[[], []]], <>]",
|
|
2056
2440
|
"",
|
|
@@ -2677,54 +3061,78 @@ export const HC_SOURCES = new Map([
|
|
|
2677
3061
|
"```",
|
|
2678
3062
|
"RotorRouter (occurrence/figure 011.21)",
|
|
2679
3063
|
"",
|
|
2680
|
-
"A RotorRouter is a two-channel router that keeps what it routes.
|
|
2681
|
-
"
|
|
2682
|
-
"Applying a router to a Frame appends that Frame, the same Frame, to the
|
|
2683
|
-
"channel
|
|
2684
|
-
"
|
|
3064
|
+
"A RotorRouter is a two-channel router that keeps what it routes. Its state is",
|
|
3065
|
+
"two ordered arrays, left and right, of the Frames routed into them, and nothing",
|
|
3066
|
+
"else. Applying a router to a Frame appends that Frame, the same Frame, to the",
|
|
3067
|
+
"channel its Count selects. A Demi follows the same alternation by Size alone; a",
|
|
3068
|
+
"router keeps the children, so its numerical shadow is a Demi and its state is",
|
|
2685
3069
|
"everything that shadow forgets: which Frames, in what order, and which channel.",
|
|
2686
3070
|
"",
|
|
2687
3071
|
"`RotorRouter` is an ordinary HC class, like `Demi` in `hc/demi.hc`: a",
|
|
2688
3072
|
"constructor closure answering a fresh aggregate whose fields are its state and",
|
|
2689
3073
|
"whose methods are the class. Import it with",
|
|
2690
|
-
"`Routers <- './hc/rotor-router.hc'`, then `Routers.RotorRouter [
|
|
2691
|
-
"",
|
|
2692
|
-
"**State.** `RotorRouter [
|
|
2693
|
-
"
|
|
2694
|
-
"
|
|
3074
|
+
"`Routers <- './hc/rotor-router.hc'`, then `Routers.RotorRouter [[], []]`.",
|
|
3075
|
+
"",
|
|
3076
|
+
"**State (007.25e).** `RotorRouter [left, right]` takes two arrays, the two",
|
|
3077
|
+
"ordered channels. There is no phase argument: the router's Count is",
|
|
3078
|
+
"`C = left.# + right.#`, the children it holds, and its phase is read from the",
|
|
3079
|
+
"parity of C exactly as a Demi's is, 2 when C is even (left next) and 1 when C is",
|
|
3080
|
+
"odd (right next). Earlier versions took `RotorRouter [phase, left, right]`, a",
|
|
3081
|
+
"free phase beside the channels; that form is removed, with no alias, so the",
|
|
3082
|
+
"router's routing phase, its Count and the phase of its Demi are one fact.",
|
|
3083
|
+
"",
|
|
3084
|
+
"**Admissibility.** Routing from empty channels starts left and alternates, so",
|
|
3085
|
+
"every routed history has `left.# = right.#` (C even) or",
|
|
3086
|
+
"`left.# = right.# + 1` (C odd), and conversely every such pair is the one",
|
|
3087
|
+
"history that sent `left.0`, `right.0`, `left.1`, … in turn. The constructor",
|
|
3088
|
+
"admits exactly those pairs and refuses every other pair with",
|
|
3089
|
+
"`$!!.invalid-router`, a named error, as `Demi` refuses with `$!!.invalid-demi`:",
|
|
3090
|
+
"`RotorRouter [[A], [B, C]]` and `RotorRouter [[A, B], []]` are not histories,",
|
|
3091
|
+
"and no history or offset is invented for them. Routing keeps the invariant, so",
|
|
3092
|
+
"every router a program can hold satisfies it. A channel is its elements: an",
|
|
2695
3093
|
"array's properties are configuration, not routed Frames, so the constructor",
|
|
2696
|
-
"keeps the elements in a fresh array of its own,
|
|
2697
|
-
"declares `apply` cannot change what appending means.
|
|
2698
|
-
"
|
|
2699
|
-
"
|
|
2700
|
-
"
|
|
2701
|
-
"
|
|
2702
|
-
"",
|
|
2703
|
-
"
|
|
2704
|
-
"
|
|
2705
|
-
"
|
|
2706
|
-
"
|
|
2707
|
-
"
|
|
2708
|
-
"
|
|
2709
|
-
"
|
|
2710
|
-
"
|
|
2711
|
-
"
|
|
2712
|
-
"
|
|
2713
|
-
"",
|
|
2714
|
-
"
|
|
2715
|
-
"
|
|
2716
|
-
"
|
|
2717
|
-
"
|
|
2718
|
-
"router's
|
|
2719
|
-
"nonempty channel's load is its native Size, which
|
|
2720
|
-
"where children are measured, so it is where their
|
|
2721
|
-
"observers run only when the router is observed:
|
|
2722
|
-
"observing writes nothing. The Demi forgets which
|
|
2723
|
-
"order, so distinct routers can share one.",
|
|
3094
|
+
"keeps the elements in a fresh array of its own, counts them there, and a",
|
|
3095
|
+
"channel argument that declares `apply` cannot change what appending means.",
|
|
3096
|
+
"Anything that is not two arrays is refused the same way.",
|
|
3097
|
+
"",
|
|
3098
|
+
"**Routing**, `router x`: append x as one member of the channel the parity of C",
|
|
3099
|
+
"selects; the Count grows by one and the phase flips with it. `router.phase` is",
|
|
3100
|
+
"a field written only together with that append, read from the same parity, so",
|
|
3101
|
+
"it is never independent state. Routing never evaluates x, never measures it,",
|
|
3102
|
+
"and never runs its methods, so a closure is kept uncalled, an array or group is",
|
|
3103
|
+
"kept as one member, and a Frame whose Size fails or runs code is routed like any",
|
|
3104
|
+
"other. A Frame of Size zero still takes a slot and flips the phase. It is a",
|
|
3105
|
+
"mutating method, `apply_`, so through a name it is a functional update that",
|
|
3106
|
+
"leaves the router as it was, and through a mutable name it writes the router in",
|
|
3107
|
+
"place. Routing nil routes nothing and leaves the router as it was, as applying a",
|
|
3108
|
+
"Demi to nil does. A flagged error such as `1 / 0` is the answer of the",
|
|
3109
|
+
"expression that applies the router, so it is never routed.",
|
|
3110
|
+
"",
|
|
3111
|
+
"**Observers.** A router declares its Count, Size and residual as a Demi does",
|
|
3112
|
+
"(007.25c): its Count C, its total load L+R and the signed difference L−R, where",
|
|
3113
|
+
"each load is the sum of the Sizes of the children routed into that channel. So",
|
|
3114
|
+
"`router.####` derives the router's Demi as it derives any Frame's,",
|
|
3115
|
+
"`Demi(C, L, R)`, and that Demi is the router's numerical shadow. Its phase is",
|
|
3116
|
+
"the router's phase, because both are the parity of the same C. An empty channel",
|
|
3117
|
+
"has load 0, the empty sum; a nonempty channel's load is its native Size, which",
|
|
3118
|
+
"is that sum. Observation is where children are measured, so it is where their",
|
|
3119
|
+
"failures show, and declared observers run only when the router is observed:",
|
|
3120
|
+
"routing runs none of them, and observing writes nothing. The Demi forgets which",
|
|
3121
|
+
"Frames were routed and their order, so distinct routers can share one.",
|
|
3122
|
+
"",
|
|
3123
|
+
"**The projection law.** For every router r whose fourth hash exists, that is",
|
|
3124
|
+
"every router with C ≥ 1 whose children have Sizes, and every Frame y,",
|
|
3125
|
+
"`(r y).#### = (r.####) y`: routing y into the channel the parity of C selects",
|
|
3126
|
+
"and then observing adds `y.##` to that channel's load and one to C, which is",
|
|
3127
|
+
"exactly what applying `Demi(C, L, R)` to y does. The empty router `[[], []]` is",
|
|
3128
|
+
"the boundary: it has routed nothing, so like the empty host `[]` its Count is",
|
|
3129
|
+
"zero and `.####` is nil, not a Demi conjured to make the equation look true.",
|
|
3130
|
+
"There the law reads through the zero-Count lifting the Demi class names,",
|
|
3131
|
+
"`(r0 y).#### = (Demi [0, 0, 0]) y`.",
|
|
2724
3132
|
"",
|
|
2725
3133
|
"**Text.** A router prints as its fields and methods, and as text reads",
|
|
2726
|
-
"`RotorRouter(
|
|
2727
|
-
"
|
|
3134
|
+
"`RotorRouter([…],[…])`, each channel as its spelling, the constructor's own",
|
|
3135
|
+
"shape.",
|
|
2728
3136
|
"",
|
|
2729
3137
|
"**Methods read their own state through `_^`.** A router is applied to",
|
|
2730
3138
|
"arbitrary Frames, and a bare name in a method is looked up on the argument",
|
|
@@ -2732,41 +3140,57 @@ export const HC_SOURCES = new Map([
|
|
|
2732
3140
|
"the method body. What a branch needs is bound as a local at method level.",
|
|
2733
3141
|
"```",
|
|
2734
3142
|
".channel-load {.c _; (c.# = 0) ? {0} : {c.##}};",
|
|
2735
|
-
".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) =
|
|
2736
|
-
" ((
|
|
2737
|
-
"
|
|
2738
|
-
" .
|
|
2739
|
-
" .
|
|
2740
|
-
" .
|
|
2741
|
-
"
|
|
2742
|
-
"
|
|
3143
|
+
".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) = 2}) ? {.l (__ .0); .r (__ .1);",
|
|
3144
|
+
" ((l ~ ([].<>)) ? {r ~ ([].<>)}) ? {.lc (l | []); .rc (r | []); .a (lc.#); .b (rc.#);",
|
|
3145
|
+
" ((a = b) : {a = (b + 1)}) ? {[",
|
|
3146
|
+
" .phase ((a = b) ? {2} : {1});",
|
|
3147
|
+
" .left lc;",
|
|
3148
|
+
" .right rc;",
|
|
3149
|
+
" .apply_ {.x _; .l (_^ .left); .r (_^ .right); .n (l.# + r.#);",
|
|
3150
|
+
" ((n %% 2) = 0) ? {@left (l x); @phase 1;} : {@right (r x); @phase 2;};};",
|
|
3151
|
+
" .# {.l (_^ .left); .r (_^ .right); l.# + r.#};",
|
|
2743
3152
|
" .## {(channel-load (_^ .left)) + (channel-load (_^ .right))};",
|
|
2744
3153
|
" .### {(channel-load (_^ .left)) - (channel-load (_^ .right))};",
|
|
2745
|
-
" .toText {“RotorRouter(” (
|
|
2746
|
-
" ]} : {$!!.invalid-router}} : {$!!.invalid-router}};",
|
|
3154
|
+
" .toText {“RotorRouter(” (_^ .left) “,” (_^ .right) “)”}",
|
|
3155
|
+
" ]} : {$!!.invalid-router}} : {$!!.invalid-router}} : {$!!.invalid-router}};",
|
|
2747
3156
|
"```",
|
|
2748
3157
|
"## Construction",
|
|
2749
3158
|
"",
|
|
2750
|
-
"A router holds exactly its
|
|
2751
|
-
"present,
|
|
3159
|
+
"A router holds exactly its two channels, and the phase they fix. The initial",
|
|
3160
|
+
"router is present, both channels empty, Count zero, phase 2",
|
|
2752
3161
|
"```",
|
|
2753
|
-
"; .r0 (RotorRouter [
|
|
2754
|
-
"; [r0.phase, r0.left, r0.right, “” r0]",
|
|
2755
|
-
"# [2, [], [], “RotorRouter(
|
|
3162
|
+
"; .r0 (RotorRouter [[], []]);",
|
|
3163
|
+
"; [r0.phase, r0.left, r0.right, r0.#, “” r0]",
|
|
3164
|
+
"# [2, [], [], 0, “RotorRouter([],[])”]",
|
|
2756
3165
|
"```",
|
|
2757
|
-
"
|
|
3166
|
+
"Every admissible pair is a router, in the phase its Count fixes: as many",
|
|
3167
|
+
"children left as right is even and phase 2, one more left is odd and phase 1.",
|
|
3168
|
+
"Preloads of any length are admitted on the same terms",
|
|
2758
3169
|
"```",
|
|
2759
|
-
"; RotorRouter [3, [], []]",
|
|
2760
|
-
"#
|
|
2761
|
-
"
|
|
3170
|
+
"; [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]}",
|
|
3171
|
+
"# [[1, 1], [2, 2], [3, 1], [8, 2], [9, 1]]",
|
|
3172
|
+
"```",
|
|
3173
|
+
"A pair that is not a left-first alternating history is refused: right ahead of",
|
|
3174
|
+
"left, left more than one ahead, and the old phase-first form, whose three",
|
|
3175
|
+
"arguments are not two channels. No history is invented for them",
|
|
3176
|
+
"```",
|
|
3177
|
+
"; [RotorRouter [[], [5]], RotorRouter [[5], [6, 7]], RotorRouter [[5, 6], []], RotorRouter [[1, 2, 3], [4]], RotorRouter [[], [1, 2, 3]]]",
|
|
2762
3178
|
"# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
|
|
3179
|
+
"; [RotorRouter [2, [], []], RotorRouter [1, [5], []], RotorRouter [2, [5]], RotorRouter [1, []]]",
|
|
3180
|
+
"# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
|
|
3181
|
+
"```",
|
|
3182
|
+
"Anything but two arrays is refused",
|
|
3183
|
+
"```",
|
|
3184
|
+
"; [RotorRouter [[], 5], RotorRouter [(1, 2), []], RotorRouter [[]], RotorRouter [[], [], []], RotorRouter 5, RotorRouter ()]",
|
|
3185
|
+
"# [$!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router, $!!.invalid-router]",
|
|
2763
3186
|
"```",
|
|
2764
3187
|
"A channel is its elements. The router keeps them in an array of its own, so a",
|
|
2765
|
-
"channel's properties and a declared `apply` do not come with it",
|
|
3188
|
+
"channel's properties and a declared `apply` do not come with it, and only the",
|
|
3189
|
+
"elements are counted for admissibility",
|
|
2766
3190
|
"```",
|
|
2767
3191
|
"; .Hijack [.apply {“hijack”}; 1];",
|
|
2768
|
-
"; [(RotorRouter [
|
|
2769
|
-
"# [[5], [
|
|
3192
|
+
"; [(RotorRouter [[.tag 9; 5], []]).left, ((RotorRouter [Hijack, []]) 7).right, RotorRouter [[.a 1; .b 2], [5]]]",
|
|
3193
|
+
"# [[5], [7], $!!.invalid-router]",
|
|
2770
3194
|
"```",
|
|
2771
3195
|
"## Routing alternates",
|
|
2772
3196
|
"",
|
|
@@ -2775,16 +3199,26 @@ export const HC_SOURCES = new Map([
|
|
|
2775
3199
|
"```",
|
|
2776
3200
|
"; .A [1, [2]]; .B “b”; .C {5 + 3};",
|
|
2777
3201
|
"; .r3 (((r0 A) B) C);",
|
|
2778
|
-
"; [r3.phase, r3.left, r3.right]",
|
|
2779
|
-
"# [1, [[1, [2]], { 5 + 3 }], [“b”]]",
|
|
3202
|
+
"; [r3.phase, r3.left, r3.right, r3.#]",
|
|
3203
|
+
"# [1, [[1, [2]], { 5 + 3 }], [“b”], 3]",
|
|
2780
3204
|
"; “” r3",
|
|
2781
|
-
"# “RotorRouter(
|
|
3205
|
+
"# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
|
|
2782
3206
|
"```",
|
|
2783
3207
|
"The router that was routed into is left as it was",
|
|
2784
3208
|
"```",
|
|
2785
3209
|
"; [r0.phase, r0.left, r0.right]",
|
|
2786
3210
|
"# [2, [], []]",
|
|
2787
3211
|
"```",
|
|
3212
|
+
"The phase is the parity of the Count after every route, so each successor is",
|
|
3213
|
+
"admissible again: routing from Count 0 through Count 6 alternates",
|
|
3214
|
+
"left, right, left, …",
|
|
3215
|
+
"```",
|
|
3216
|
+
"; .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)];",
|
|
3217
|
+
"; [steps & {_.#}, steps & {_.phase}, steps & {_.left.#}, steps & {_.right.#}]",
|
|
3218
|
+
"# [[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]]",
|
|
3219
|
+
"; steps & {(RotorRouter [_.left, _.right]) = _}",
|
|
3220
|
+
"# [<>, <>, <>, <>, <>, <>, <>]",
|
|
3221
|
+
"```",
|
|
2788
3222
|
"## Routing keeps the Frame",
|
|
2789
3223
|
"",
|
|
2790
3224
|
"A channel member is the routed Frame itself. An array or a group is routed as",
|
|
@@ -2811,40 +3245,42 @@ export const HC_SOURCES = new Map([
|
|
|
2811
3245
|
"; [(rk.left.0.set_ 9).n, kid_.n, rk.left.0.n]",
|
|
2812
3246
|
"# [9, 5, 5]",
|
|
2813
3247
|
"```",
|
|
2814
|
-
"##
|
|
3248
|
+
"## Preloaded states",
|
|
2815
3249
|
"",
|
|
2816
|
-
"
|
|
2817
|
-
"
|
|
3250
|
+
"An admissible preload continues its history: here one child left, so Count 1",
|
|
3251
|
+
"and phase 1, and the next two routes go right then left",
|
|
2818
3252
|
"```",
|
|
2819
|
-
"; .p1 (RotorRouter [
|
|
3253
|
+
"; .p1 (RotorRouter [[A], []]);",
|
|
2820
3254
|
"; .p2 ((p1 B) C);",
|
|
2821
|
-
"; [p2.phase, p2.left, p2.right, p1.
|
|
2822
|
-
"# [1, [[1, [2]], { 5 + 3 }], [“b”],
|
|
3255
|
+
"; [p1.phase, p1.#, p2.phase, p2.left, p2.right, p1.right]",
|
|
3256
|
+
"# [1, 1, 1, [[1, [2]], { 5 + 3 }], [“b”], []]",
|
|
3257
|
+
"; [p2 = r3, p2 = (RotorRouter [[A, C], [B]])]",
|
|
3258
|
+
"# [<>, <>]",
|
|
2823
3259
|
"```",
|
|
2824
3260
|
"Routers built from the same channel share no writable state: each holds its",
|
|
2825
3261
|
"own channel array. Through a mutable name, routing writes that router in place",
|
|
2826
3262
|
"and no other",
|
|
2827
3263
|
"```",
|
|
2828
3264
|
"; .ch [A];",
|
|
2829
|
-
"; .u (RotorRouter [
|
|
2830
|
-
"; .m_ (RotorRouter [
|
|
3265
|
+
"; .u (RotorRouter [ch, []]); .v (RotorRouter [ch, []]);",
|
|
3266
|
+
"; .m_ (RotorRouter [ch, []]);",
|
|
2831
3267
|
"; m_ B;",
|
|
2832
3268
|
"; m_ C;",
|
|
2833
3269
|
"; [m_.phase, m_.left, m_.right, u.left, v.left, ch]",
|
|
2834
|
-
"# [
|
|
3270
|
+
"# [1, [[1, [2]], { 5 + 3 }], [“b”], [[1, [2]]], [[1, [2]]], [[1, [2]]]]",
|
|
2835
3271
|
"; [u.left === ch, u.left === v.left, u.left.0 === v.left.0]",
|
|
2836
3272
|
"# [(), (), <>]",
|
|
2837
3273
|
"```",
|
|
2838
3274
|
"A router captured by a closure, mapped, or reduced into routes the same way,",
|
|
2839
3275
|
"and the captured one stays as it was",
|
|
2840
3276
|
"```",
|
|
2841
|
-
"; .start (RotorRouter [
|
|
3277
|
+
"; .start (RotorRouter [[], []]); .step {start _};",
|
|
2842
3278
|
"; [(step 5).left, (step 3).left, start.left]",
|
|
2843
3279
|
"# [[5], [3], []]",
|
|
2844
3280
|
"; [r0, p1] & {(_ 5).right}",
|
|
2845
3281
|
"# [[], [5]]",
|
|
2846
3282
|
"; “” ([A, B, C] | r0)",
|
|
2847
|
-
"# “RotorRouter(
|
|
3283
|
+
"# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
|
|
2848
3284
|
"```",
|
|
2849
3285
|
"## Routing measures nothing",
|
|
2850
3286
|
"",
|
|
@@ -2869,7 +3305,7 @@ export const HC_SOURCES = new Map([
|
|
|
2869
3305
|
"; (r0 Cyclic).####",
|
|
2870
3306
|
"# $!.cyclic-observation .##",
|
|
2871
3307
|
"; “” ((r0 Counted).####)",
|
|
2872
|
-
"# “Demi(
|
|
3308
|
+
"# “Demi(1,5,0)”",
|
|
2873
3309
|
"; counter_.n",
|
|
2874
3310
|
"# 2",
|
|
2875
3311
|
"```",
|
|
@@ -2884,26 +3320,30 @@ export const HC_SOURCES = new Map([
|
|
|
2884
3320
|
"```",
|
|
2885
3321
|
"Routing nil routes nothing",
|
|
2886
3322
|
"```",
|
|
2887
|
-
"; [(r0 ()).phase, (r0 ()).left]",
|
|
2888
|
-
"# [2, []]",
|
|
3323
|
+
"; [(r0 ()).phase, (r0 ()).left, (p1 ()).#]",
|
|
3324
|
+
"# [2, [], 1]",
|
|
2889
3325
|
"```",
|
|
2890
3326
|
"## Empty and zero",
|
|
2891
3327
|
"",
|
|
2892
|
-
"The initial router
|
|
2893
|
-
"
|
|
2894
|
-
"
|
|
3328
|
+
"The initial router has routed no children, so its Count is zero, and like the",
|
|
3329
|
+
"empty host it has no Demi. Its Size and residual still read zero, and it is a",
|
|
3330
|
+
"present router in phase 2. The Demi of Count zero is a different thing, a Demi",
|
|
3331
|
+
"constructed as such, which routing from the router reaches after one route",
|
|
2895
3332
|
"```",
|
|
2896
|
-
"; [
|
|
2897
|
-
"# [
|
|
3333
|
+
"; [r0.#, r0.##, r0.###, r0.phase, r0.####, [].####]",
|
|
3334
|
+
"# [0, 0, 0, 2, (), ()]",
|
|
3335
|
+
"; Demis <- './hc/demi.hc';",
|
|
3336
|
+
"; [((r0 0).####) = ((Demis.Demi [0, 0, 0]) 0), ((r0 []).####) = ([] []).####]",
|
|
3337
|
+
"# [<>, <>]",
|
|
2898
3338
|
"```",
|
|
2899
3339
|
"A Frame of Size zero takes a slot and flips the phase, and an empty array",
|
|
2900
3340
|
"routed as a child has Size 1, while an empty channel has load 0",
|
|
2901
3341
|
"```",
|
|
2902
3342
|
"; .z (r0 0);",
|
|
2903
|
-
"; [z.phase, z.left, “” (z.####)]",
|
|
2904
|
-
"# [1, [0], “Demi(
|
|
3343
|
+
"; [z.phase, z.left, z.#, “” (z.####)]",
|
|
3344
|
+
"# [1, [0], 1, “Demi(1,0,0)”]",
|
|
2905
3345
|
"; [“” ((r0 []).####), “” (((r0 []) []).####), “” ((((r0 0) 0) 0).####)]",
|
|
2906
|
-
"# [“Demi(
|
|
3346
|
+
"# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,0,0)”]",
|
|
2907
3347
|
"```",
|
|
2908
3348
|
"## The router's Demi",
|
|
2909
3349
|
"",
|
|
@@ -2916,59 +3356,79 @@ export const HC_SOURCES = new Map([
|
|
|
2916
3356
|
"; [mix.left, mix.right]",
|
|
2917
3357
|
"# [[“hello”, [[1, 2], [3]], [[], []], { 5 + 3 }], [7, (4, 5), [[], []], <>]]",
|
|
2918
3358
|
"; [mix.left & {_.##}, mix.right & {_.##}, “” (mix.####)]",
|
|
2919
|
-
"# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(
|
|
3359
|
+
"# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(8,22,19)”]",
|
|
2920
3360
|
"; “” (((r0 123456789012345678901234567890) 987654321098765432109876543210).####)",
|
|
2921
|
-
"# “Demi(
|
|
3361
|
+
"# “Demi(2,123456789012345678901234567890,987654321098765432109876543210)”",
|
|
3362
|
+
"```",
|
|
3363
|
+
"A router's Demi is `Demi(C, L, R)` of its own channels, and its phase is the",
|
|
3364
|
+
"router's phase, for every Count from 1 to 6 and for preloads",
|
|
3365
|
+
"```",
|
|
3366
|
+
"; .sh (steps & {_.####});",
|
|
3367
|
+
"; [sh & {_ = ()}, sh & {_.#}]",
|
|
3368
|
+
"# [[<>, (), (), (), (), (), ()], [(), 1, 2, 3, 4, 5, 6]]",
|
|
3369
|
+
"; [steps &| {.k _; (k.# .> 0) ? {[k.phase = k.####.phase]} : {[]}}, (RotorRouter [[2, 3], [1]]).#### = (Demis.Demi [3, 5, 1])]",
|
|
3370
|
+
"# [[<>, <>, <>, <>, <>, <>], <>]",
|
|
2922
3371
|
"```",
|
|
2923
3372
|
"## Observing commutes with routing",
|
|
2924
3373
|
"",
|
|
2925
3374
|
"Routing each child of an array X in turn, from the initial router, is the",
|
|
2926
3375
|
"reduce `X | r0`. Its left channel holds the children at even positions and its",
|
|
2927
3376
|
"right channel those at odd positions, and its phase is the parity of X's Count.",
|
|
2928
|
-
"That interleaving is the invariant
|
|
2929
|
-
"
|
|
3377
|
+
"That interleaving is the admissibility invariant, so the same router is",
|
|
3378
|
+
"constructed directly from the two channels",
|
|
2930
3379
|
"```",
|
|
2931
3380
|
"; .X [5, “ab”, [1, 2]];",
|
|
2932
3381
|
"; .rx (X | r0);",
|
|
2933
|
-
"; [rx.left, rx.right, rx.phase, rx = (RotorRouter [
|
|
3382
|
+
"; [rx.left, rx.right, rx.phase, rx = (RotorRouter [[5, [1, 2]], [“ab”]])]",
|
|
2934
3383
|
"# [[5, [1, 2]], [“ab”], 1, <>]",
|
|
2935
3384
|
"```",
|
|
2936
|
-
"For
|
|
2937
|
-
"
|
|
2938
|
-
"
|
|
3385
|
+
"For every router whose fourth hash exists, routing Y then observing is applying",
|
|
3386
|
+
"the router's Demi to Y, which adds one to the Count. Its fourth hash is X's,",
|
|
3387
|
+
"Count included. The law holds for routers built by routing and for admissible",
|
|
3388
|
+
"preloads alike, in both phases, and for a zero-Size child",
|
|
2939
3389
|
"```",
|
|
2940
3390
|
"; .Y [[], [], []];",
|
|
2941
|
-
"; [(rx.####) = X.####, ((rx Y).####) = (X Y).####, ((rx Y).####) = ((rx.####) Y)]",
|
|
2942
|
-
"# [<>, <>, <>]",
|
|
2943
|
-
"; [((p1 Y).####) = ((p1.####) Y), ((p2 {5 + 3}).####) = ((p2.####) {5 + 3}), ((
|
|
3391
|
+
"; [(rx.####) = X.####, ((rx Y).####) = (X Y).####, ((rx Y).####) = ((rx.####) Y), (rx.####).# = X.#, ((rx Y).####).# = (X.# + 1)]",
|
|
3392
|
+
"# [<>, <>, <>, <>, <>]",
|
|
3393
|
+
"; [((p1 Y).####) = ((p1.####) Y), ((p2 {5 + 3}).####) = ((p2.####) {5 + 3}), ((p1 0).####) = ((p1.####) 0)]",
|
|
2944
3394
|
"# [<>, <>, <>]",
|
|
3395
|
+
"; .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]]];",
|
|
3396
|
+
"; [pre & {((_ Y).####) = ((_.####) Y)}, pre & {((_ 0).####) = ((_.####) 0)}, pre & {(_ Y).phase = ((_.####) Y).phase}]",
|
|
3397
|
+
"# [[<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>]]",
|
|
2945
3398
|
"```",
|
|
2946
|
-
"The
|
|
2947
|
-
"
|
|
2948
|
-
"The router is the empty host lifted: routing nothing from it leaves it as it",
|
|
2949
|
-
"is, and after one route the two agree again",
|
|
3399
|
+
"The same holds at every step of a walk, Count 1 to 6, and a router can never",
|
|
3400
|
+
"route to the channel its Demi does not deposit into",
|
|
2950
3401
|
"```",
|
|
2951
|
-
";
|
|
2952
|
-
"# [<>,
|
|
3402
|
+
"; steps &| {.k _; (k.# .> 0) ? {[((k Y).####) = ((k.####) Y)]} : {[]}}",
|
|
3403
|
+
"# [<>, <>, <>, <>, <>, <>]",
|
|
3404
|
+
"; steps &| {.k _; (k.# .> 0) ? {[[((k 4).left.# - k.left.#), (((k.####) 4).left - k.####.left)]]} : {[]}}",
|
|
3405
|
+
"# [[0, 0], [1, 4], [0, 0], [1, 4], [0, 0], [1, 4]]",
|
|
2953
3406
|
"```",
|
|
2954
|
-
"
|
|
2955
|
-
"
|
|
2956
|
-
"routing reaches, yet its fourth hash equals that of an array whose",
|
|
2957
|
-
"history is different",
|
|
3407
|
+
"A failed Size is the answer on both sides: the router routes the Frame and its",
|
|
3408
|
+
"Demi fails when observed, and the Demi refuses the deposit with the same error",
|
|
2958
3409
|
"```",
|
|
2959
|
-
";
|
|
2960
|
-
"
|
|
2961
|
-
"
|
|
3410
|
+
"; [((p1 Failing).####), ((p1.####) Failing)]",
|
|
3411
|
+
"# [$!.name-missing “..., $!.name-missing “...]",
|
|
3412
|
+
"```",
|
|
3413
|
+
"The empty host is the boundary. `[].####` is nil, so `X.####` fails the first",
|
|
3414
|
+
"equation when X is empty, and so does the initial router, which has routed",
|
|
3415
|
+
"nothing and so has Count zero: it has no Demi, and none is faked. The law there",
|
|
3416
|
+
"reads through the Demi class's zero-Count lifting, `Demi [0, 0, 0]`, and after",
|
|
3417
|
+
"one route the equation holds again",
|
|
3418
|
+
"```",
|
|
3419
|
+
"; [r0.####, ([] | r0) = r0, (([] | r0).####) = [].####, (([Y] | r0).####) = ([] Y).####, ((r0 Y).####) = ((Demis.Demi [0, 0, 0]) Y), ((r0 0).####) = ((Demis.Demi [0, 0, 0]) 0)]",
|
|
3420
|
+
"# [(), <>, <>, <>, <>, <>]",
|
|
2962
3421
|
"```",
|
|
2963
3422
|
"## The Demi forgets",
|
|
2964
3423
|
"",
|
|
2965
|
-
"Distinct routers can share a Demi: the fourth hash keeps only the",
|
|
2966
|
-
"
|
|
2967
|
-
"
|
|
3424
|
+
"Distinct routers can share a Demi: the fourth hash keeps only the Count and two",
|
|
3425
|
+
"sums, not which Frames were routed, nor their order, nor how the load was split",
|
|
3426
|
+
"among them. It does keep how many were routed, so a router with fewer children",
|
|
3427
|
+
"and the same loads has a different Demi",
|
|
2968
3428
|
"```",
|
|
2969
|
-
"; .s1 (RotorRouter [
|
|
2970
|
-
"; [s1 = s2, s1 = s3, (s1.####) = (
|
|
2971
|
-
"# [(), (), <>,
|
|
3429
|
+
"; .s1 (RotorRouter [[2, 3], [1]]); .s2 (RotorRouter [[5], [1]]); .s3 (RotorRouter [[3, 2], [1]]); .s4 (RotorRouter [[1, 4], [1]]);",
|
|
3430
|
+
"; [s1 = s2, s1 = s3, (s1.####) = (s3.####), (s1.####) = (s4.####), (s1.####) = (s2.####), s1.#, s2.#, s1.##, s2.##]",
|
|
3431
|
+
"# [(), (), <>, <>, (), 3, 2, 6, 6]",
|
|
2972
3432
|
"```",
|
|
2973
3433
|
"## Observers, declared",
|
|
2974
3434
|
"",
|
|
@@ -2993,9 +3453,9 @@ export const HC_SOURCES = new Map([
|
|
|
2993
3453
|
"## Reading the receiver",
|
|
2994
3454
|
"",
|
|
2995
3455
|
"An argument whose fields share the router's names, or its locals', is routed",
|
|
2996
|
-
"as one member, and the router reads only its own fields",
|
|
3456
|
+
"as one member, and the router reads only its own fields and its own Count",
|
|
2997
3457
|
"```",
|
|
2998
|
-
"; .masked (r0 [.phase 1; .left [8]; .x 9; .l [7]; 4]);",
|
|
3458
|
+
"; .masked (r0 [.phase 1; .left [8]; .x 9; .l [7]; .n 1; 4]);",
|
|
2999
3459
|
"; [masked.phase, masked.left.#, masked.left.0.x, masked.right]",
|
|
3000
3460
|
"# [1, 1, 9, []]",
|
|
3001
3461
|
"```",
|
|
@@ -3023,9 +3483,9 @@ export const HC_SOURCES = new Map([
|
|
|
3023
3483
|
"`.###`, which an expectation line, itself a `#…#` comment, cannot hold, so the",
|
|
3024
3484
|
"printed form is matched here by its beginning",
|
|
3025
3485
|
"```",
|
|
3026
|
-
"; RotorRouter [
|
|
3486
|
+
"; RotorRouter [[5], []]",
|
|
3027
3487
|
"# [.phase 1; .left [5]; .right []; .apply_ {...",
|
|
3028
|
-
"; (RotorRouter [
|
|
3488
|
+
"; (RotorRouter [[5], []]) = [.phase 1; .left [5]; .right []; .apply_ { .x _; .l (_^ .left); .r (_^ .right); .n (l.# + r.#); ((n %% 2) = 0) ? { @left (l x); @phase 1; } : { @right (r x); @phase 2; }; }; .# { .l (_^ .left); .r (_^ .right); l.# + r.# }; .## { (channel-load (_^ .left)) + (channel-load (_^ .right)) }; .### { (channel-load (_^ .left)) - (channel-load (_^ .right)) }; .toText { “RotorRouter(” (_^ .left) “,” (_^ .right) “)” };]",
|
|
3029
3489
|
"# <>",
|
|
3030
3490
|
"```",
|
|
3031
3491
|
"## Importing",
|
|
@@ -3034,8 +3494,8 @@ export const HC_SOURCES = new Map([
|
|
|
3034
3494
|
"importing this file does not import it again",
|
|
3035
3495
|
"```",
|
|
3036
3496
|
"; Routers <- './hc/rotor-router.hc';",
|
|
3037
|
-
"; [(Routers.RotorRouter [
|
|
3038
|
-
"# [<>, “RotorRouter(
|
|
3497
|
+
"; [(Routers.RotorRouter [[], []]) = r0, “” ((Routers.RotorRouter [[], []]) 4), (((Routers.RotorRouter [[], []]) 4).####) = [4].####]",
|
|
3498
|
+
"# [<>, “RotorRouter([4],[])”, <>]",
|
|
3039
3499
|
"",
|
|
3040
3500
|
].join("\n"),
|
|
3041
3501
|
],
|