hclang 0.42.0 → 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,34 +1481,55 @@ 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
1534
|
"**Arithmetic**, `d + x`, `d - x` and `d * x` (015.11). A class answers an",
|
|
1495
1535
|
"operator by declaring a method under its name, found on the operand and its",
|
|
@@ -1498,74 +1538,62 @@ export const HC_SOURCES = new Map([
|
|
|
1498
1538
|
"is running. All three **construct a fresh Demi state** from the one Size",
|
|
1499
1539
|
"observation `x.##` of their operand, keeping Figure 008's distinction between",
|
|
1500
1540
|
"construction and observation. They are **fixed-channel load transformations**",
|
|
1501
|
-
"on the two-load shadow, consistent with
|
|
1502
|
-
"(`hc/rotor-router.hc`)
|
|
1503
|
-
"
|
|
1504
|
-
"
|
|
1505
|
-
"
|
|
1506
|
-
"`
|
|
1507
|
-
"
|
|
1508
|
-
"
|
|
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.",
|
|
1509
1549
|
"",
|
|
1510
1550
|
"- `d + x` is the **tally** operator: it deposits `x.##` on the **right**,",
|
|
1511
|
-
" `Demi [
|
|
1512
|
-
"
|
|
1513
|
-
" Frame's Size — but it targets a fixed channel without flipping the phase,",
|
|
1514
|
-
" rather than invoking the Router's alternating `apply_`. A sizeless host's",
|
|
1515
|
-
" failure is the answer, as it is for application.",
|
|
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.",
|
|
1516
1553
|
"- `d - x` is the **alternator** operator: it deposits on the **left**,",
|
|
1517
|
-
" `Demi [
|
|
1518
|
-
"
|
|
1519
|
-
"
|
|
1520
|
-
"
|
|
1521
|
-
" `+` and `-`.",
|
|
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 `-`.",
|
|
1522
1558
|
"- `d * x` is the **inlay** operator: it scales both loads by the operand's Size",
|
|
1523
|
-
" `x.##`, `Demi [
|
|
1524
|
-
"
|
|
1525
|
-
"
|
|
1526
|
-
"
|
|
1527
|
-
"
|
|
1528
|
-
"
|
|
1529
|
-
"
|
|
1530
|
-
"
|
|
1531
|
-
"
|
|
1532
|
-
"
|
|
1533
|
-
"
|
|
1534
|
-
"
|
|
1535
|
-
"",
|
|
1536
|
-
"
|
|
1537
|
-
"
|
|
1538
|
-
"
|
|
1539
|
-
"
|
|
1540
|
-
"",
|
|
1541
|
-
"
|
|
1542
|
-
"
|
|
1543
|
-
"
|
|
1544
|
-
"
|
|
1545
|
-
"
|
|
1546
|
-
"
|
|
1547
|
-
"
|
|
1548
|
-
"
|
|
1549
|
-
"
|
|
1550
|
-
"
|
|
1551
|
-
"
|
|
1552
|
-
"
|
|
1553
|
-
"
|
|
1554
|
-
"",
|
|
1555
|
-
"
|
|
1556
|
-
"
|
|
1557
|
-
"
|
|
1558
|
-
"
|
|
1559
|
-
"
|
|
1560
|
-
"
|
|
1561
|
-
"unchanged and still takes a Count directly; `*` equals `d.scale_ (x.##)` for",
|
|
1562
|
-
"every sized `x`. The only removal is the Demi `/` operator: a call that",
|
|
1563
|
-
"previously answered a signed Spin, such as `D / 2`, is no longer a Demi",
|
|
1564
|
-
"operation.",
|
|
1565
|
-
"",
|
|
1566
|
-
"**Text.** A Demi prints as what it is, an aggregate of fields and methods, and",
|
|
1567
|
-
"that reads back as the same Demi. As text it reads `Demi(<>,12,3)`, with the",
|
|
1568
|
-
"phase spelled as the orientation it stands for.",
|
|
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.",
|
|
1569
1597
|
"",
|
|
1570
1598
|
"**Methods read their own state through `_^`.** A bare name inside a method is",
|
|
1571
1599
|
"looked up on the argument first (spec 7), and a Demi is applied to arbitrary",
|
|
@@ -1574,121 +1602,164 @@ export const HC_SOURCES = new Map([
|
|
|
1574
1602
|
"count lexically (spec a06). What a branch needs is bound as a local at method",
|
|
1575
1603
|
"level, where nested blocks read it.",
|
|
1576
1604
|
"```",
|
|
1577
|
-
".Demi {((_ ~ ([].<>)) ? {(__ .#) = 3}) ? {.
|
|
1578
|
-
" (((
|
|
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;",
|
|
1579
1608
|
" .phase p;",
|
|
1580
1609
|
" .left l;",
|
|
1581
1610
|
" .right r;",
|
|
1582
|
-
" .# {_^.
|
|
1611
|
+
" .# {_^.count};",
|
|
1583
1612
|
" .## {_^.left + _^.right};",
|
|
1584
1613
|
" .### {_^.left - _^.right};",
|
|
1585
|
-
" .apply_ {.s (_ .##); .l (_^ .left); .r (_^ .right);",
|
|
1586
|
-
" (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}};",
|
|
1587
1616
|
" .scale_ {.k _; .l (_^ .left); .r (_^ .right);",
|
|
1588
1617
|
" (k ~ (0.<>)) ? {@left (l * k); @right (r * k); _^^} : {$!!.invalid-scale}};",
|
|
1589
|
-
"
|
|
1590
|
-
" (
|
|
1591
|
-
"
|
|
1592
|
-
" (
|
|
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}};",
|
|
1593
1626
|
" .* {.s (_ .##);",
|
|
1594
1627
|
" (s ~ (0.<>)) ? {(_^^ .scale_ s)} : {s}};",
|
|
1595
|
-
" .
|
|
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) “)”}",
|
|
1596
1633
|
" ]} : {$!!.invalid-demi}} : {$!!.invalid-demi}};",
|
|
1597
1634
|
"```",
|
|
1598
1635
|
"## Construction",
|
|
1599
1636
|
"",
|
|
1600
|
-
"A Demi holds
|
|
1601
|
-
"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",
|
|
1602
1640
|
"```",
|
|
1603
|
-
"; .d (Demi [
|
|
1604
|
-
"; [d.phase, d.left, d.right]",
|
|
1605
|
-
"# [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)”]",
|
|
1606
1644
|
"; .a (Demi [2, 5, 3]); .b (Demi [1, 7, 0]);",
|
|
1607
|
-
"; [“” a, “” b, a.left, b.left]",
|
|
1608
|
-
"# [“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",
|
|
1609
1650
|
"```",
|
|
1610
|
-
"
|
|
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]",
|
|
1611
1655
|
"```",
|
|
1612
|
-
"
|
|
1613
|
-
"
|
|
1614
|
-
"
|
|
1615
|
-
"
|
|
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",
|
|
1658
|
+
"```",
|
|
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]",
|
|
1616
1663
|
"```",
|
|
1617
1664
|
"## Application",
|
|
1618
1665
|
"",
|
|
1619
|
-
"Each application deposits the argument's Size into the
|
|
1620
|
-
"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",
|
|
1621
1669
|
"```",
|
|
1622
1670
|
"; “” (d [5, 3])",
|
|
1623
|
-
"# “Demi(
|
|
1671
|
+
"# “Demi(1,8,0)”",
|
|
1624
1672
|
"; “” d",
|
|
1625
|
-
"# “Demi(
|
|
1673
|
+
"# “Demi(0,0,0)”",
|
|
1626
1674
|
"; “” (((d 5) 3) 7)",
|
|
1627
|
-
"# “Demi(
|
|
1675
|
+
"# “Demi(3,12,3)”",
|
|
1628
1676
|
"```",
|
|
1629
|
-
"A Size of zero deposits nothing and still
|
|
1677
|
+
"A Size of zero deposits nothing and still counts, in both phases",
|
|
1630
1678
|
"```",
|
|
1631
|
-
"; [(d 0).phase, ((d 0) 0).phase, (d 0).left, ((d 0) 0).right]",
|
|
1632
|
-
"# [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]",
|
|
1633
1681
|
"```",
|
|
1634
1682
|
"Any Frame is applied by its Size, measured without running it: text, the",
|
|
1635
1683
|
"empty aggregate and all (Size 1 each), nested aggregates, a closure (one per",
|
|
1636
1684
|
"word, so `{5 + 3}` is 9), empty text, and loads too large for a machine integer",
|
|
1637
1685
|
"```",
|
|
1638
1686
|
"; “” ((((((d “hello”) []) <>) [[1, 2], [3]]) {5 + 3}) “”)",
|
|
1639
|
-
"# “Demi(
|
|
1687
|
+
"# “Demi(6,15,7)”",
|
|
1640
1688
|
"; “” ((d 123456789012345678901234567890) 987654321098765432109876543210)",
|
|
1641
|
-
"# “Demi(
|
|
1689
|
+
"# “Demi(2,123456789012345678901234567890,987654321098765432109876543210)”",
|
|
1642
1690
|
"```",
|
|
1643
1691
|
"A Frame without a Size is not deposited: its failure is the answer",
|
|
1644
1692
|
"```",
|
|
1645
1693
|
"; d ([].nope)",
|
|
1646
1694
|
"# $!.name-missing “...",
|
|
1647
1695
|
"; “” d",
|
|
1648
|
-
"# “Demi(
|
|
1696
|
+
"# “Demi(0,0,0)”",
|
|
1649
1697
|
"```",
|
|
1650
1698
|
"Deposit reads the receiver through `_^`, so an argument that holds fields of",
|
|
1651
1699
|
"the same names deposits by its Size and nothing else",
|
|
1652
1700
|
"```",
|
|
1653
|
-
"; “” (d [.
|
|
1654
|
-
"# “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)”",
|
|
1655
1705
|
"```",
|
|
1656
1706
|
"A Demi captured by a closure, mapped, or reduced is applied the same way, and",
|
|
1657
1707
|
"the captured one stays as it was",
|
|
1658
1708
|
"```",
|
|
1659
|
-
"; .start (Demi [
|
|
1709
|
+
"; .start (Demi [0, 0, 0]); .step {start _};",
|
|
1660
1710
|
"; [“” (step 5), “” (step 3), “” start]",
|
|
1661
|
-
"# [“Demi(
|
|
1711
|
+
"# [“Demi(1,5,0)”, “Demi(1,3,0)”, “Demi(0,0,0)”]",
|
|
1662
1712
|
"; [d, a] & {“” (_ 5)}",
|
|
1663
|
-
"# [“Demi(
|
|
1664
|
-
"; “” ([5, 3, 7] | (Demi [
|
|
1665
|
-
"# “Demi(
|
|
1713
|
+
"# [“Demi(1,5,0)”, “Demi(3,10,3)”]",
|
|
1714
|
+
"; “” ([5, 3, 7] | (Demi [0, 0, 0]))",
|
|
1715
|
+
"# “Demi(3,12,3)”",
|
|
1666
1716
|
"```",
|
|
1667
1717
|
"Through a mutable name, application writes the Demi in place",
|
|
1668
1718
|
"```",
|
|
1669
|
-
"; .m_ (Demi [
|
|
1719
|
+
"; .m_ (Demi [0, 0, 0]);",
|
|
1670
1720
|
"; m_ 5;",
|
|
1671
|
-
";
|
|
1672
|
-
"
|
|
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
|
+
"# [<>, <>]",
|
|
1673
1743
|
"```",
|
|
1674
1744
|
"## Observers",
|
|
1675
1745
|
"",
|
|
1676
|
-
"A Demi's Count is its
|
|
1746
|
+
"A Demi's Count is its stored Count, its Size the total load and its residual the",
|
|
1677
1747
|
"signed difference, including a present zero-load Demi in either phase",
|
|
1678
1748
|
"```",
|
|
1679
|
-
"; .e (Demi [
|
|
1680
|
-
"; [e.#, e.##, e
|
|
1681
|
-
"# [
|
|
1682
|
-
"; [d.#, d.##, d.###, (Demi [1, 0, 0])
|
|
1683
|
-
"# [
|
|
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]",
|
|
1684
1754
|
"```",
|
|
1685
|
-
"
|
|
1686
|
-
"
|
|
1755
|
+
"Count is `.#`, not phase. The same phase and loads with a different Count are",
|
|
1756
|
+
"different states with the same Size and residual",
|
|
1687
1757
|
"```",
|
|
1688
|
-
";
|
|
1689
|
-
"
|
|
1690
|
-
"
|
|
1691
|
-
"
|
|
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]",
|
|
1692
1763
|
"```",
|
|
1693
1764
|
"A Demi inside an aggregate contributes its declared Size",
|
|
1694
1765
|
"```",
|
|
@@ -1697,101 +1768,183 @@ export const HC_SOURCES = new Map([
|
|
|
1697
1768
|
"```",
|
|
1698
1769
|
"## The fourth hash",
|
|
1699
1770
|
"",
|
|
1700
|
-
"`.####`
|
|
1701
|
-
"
|
|
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, (), <>]",
|
|
1702
1781
|
"```",
|
|
1703
|
-
"
|
|
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",
|
|
1785
|
+
"```",
|
|
1786
|
+
"; [[5, 3].#### = (Demi [2, 5, 3]), “hello”.#### = (Demi [5, 3, 2]), [0].#### = (Demi [1, 0, 0])]",
|
|
1704
1787
|
"# [<>, <>, <>]",
|
|
1788
|
+
"; [[5, 3].####.#, “hello”.####.#, “hello”.####.phase, [5, 3, 7].####.#, [5, 3, 7].####.phase]",
|
|
1789
|
+
"# [2, 5, 1, 3, 1]",
|
|
1705
1790
|
"; “” [5, 3, 7].####",
|
|
1706
|
-
"# “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
|
+
"# [(), <>, <>]",
|
|
1707
1798
|
"```",
|
|
1708
1799
|
"It is nil where there is no Demi: an empty host, Count zero, no Count, or no",
|
|
1709
|
-
"residual.
|
|
1710
|
-
"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",
|
|
1711
1803
|
"```",
|
|
1712
|
-
"; [[].####, 0.####, ().####, <2,3,5
|
|
1713
|
-
"# [(), (), (), ()]",
|
|
1804
|
+
"; [[].####, 0.####, ().####, <2,3,5>.####, “”.####]",
|
|
1805
|
+
"# [(), (), (), (), ()]",
|
|
1714
1806
|
"; .shared [1, 2];",
|
|
1715
1807
|
"; [[.a 100; 5, 3].#### = [5, 3].####, [shared, shared].#### = (Demi [2, 3, 3]), (5, 3).#### = (Demi [2, 5, 3])]",
|
|
1716
1808
|
"# [<>, <>, <>]",
|
|
1717
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
|
+
"```",
|
|
1718
1873
|
"## Observing commutes with applying",
|
|
1719
1874
|
"",
|
|
1720
1875
|
"For a nonempty host X, observing X Y is applying X's Demi to Y, and both equal",
|
|
1721
|
-
"the observation of the array X Y constructs",
|
|
1876
|
+
"the observation of the array X Y constructs, with Count one greater",
|
|
1722
1877
|
"```",
|
|
1723
1878
|
"; .X [5, “ab”, [1, 2]];",
|
|
1724
|
-
"; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3})]",
|
|
1725
|
-
"# [<>, <>, <>]",
|
|
1879
|
+
"; [(X 7).#### = (X.#### 7), (X 7).#### = [5, “ab”, [1, 2], 7].####, (X {5 + 3}).#### = (X.#### {5 + 3}), (X 7).####.# = (X.####.# + 1)]",
|
|
1880
|
+
"# [<>, <>, <>, <>]",
|
|
1726
1881
|
"```",
|
|
1727
1882
|
"The empty host is the boundary. `[].####` is nil, a choice of convention",
|
|
1728
1883
|
"(011.15g) rather than a theorem, and applying nil answers the argument, so",
|
|
1729
|
-
"the equation as written fails there. Lifting the empty host to the
|
|
1730
|
-
"
|
|
1731
|
-
"
|
|
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",
|
|
1732
1887
|
"```",
|
|
1733
|
-
"; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [
|
|
1888
|
+
"; [([] 7).#### = ([].#### 7), ([] 7).#### = ((Demi [0, 0, 0]) 7), ([] 7).#### = ([7] | (Demi [0, 0, 0]))]",
|
|
1734
1889
|
"# [(), <>, <>]",
|
|
1735
|
-
"; [] | (Demi [
|
|
1890
|
+
"; [] | (Demi [0, 0, 0]) = (Demi [0, 0, 0])",
|
|
1736
1891
|
"# <>",
|
|
1737
1892
|
"```",
|
|
1738
1893
|
"## Scaling and Star",
|
|
1739
1894
|
"",
|
|
1740
|
-
"Scaling multiplies both loads and keeps the phase: zero annihilates,
|
|
1741
|
-
"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",
|
|
1742
1897
|
"```",
|
|
1743
|
-
"; [“” (e.scale_ 2), “” (e.scale_ 0), (e.scale_ 1) = e, ((e.scale_ 2).scale_ 3) = (e.scale_ 6)]",
|
|
1744
|
-
"# [“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]",
|
|
1745
1900
|
"; e.scale_ (0 - 2)",
|
|
1746
1901
|
"# $!!.invalid-scale",
|
|
1747
1902
|
"```",
|
|
1748
|
-
"It is the shadow of Star on a nonempty host",
|
|
1903
|
+
"It is the shadow of Star on a nonempty host, Count included",
|
|
1749
1904
|
"```",
|
|
1750
|
-
"; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##))]",
|
|
1751
|
-
"# [<>, <>]",
|
|
1905
|
+
"; [([5, 3] * 3).#### = ([5, 3].####.scale_ 3), ([[[]], []] * [[], []]).#### = ([[[]], []].####.scale_ ([[], []].##)), ([5, 3] * 3).####.# = [5, 3].####.#]",
|
|
1906
|
+
"# [<>, <>, <>]",
|
|
1752
1907
|
"```",
|
|
1753
1908
|
"## Arithmetic",
|
|
1754
1909
|
"",
|
|
1755
1910
|
"Three operators act on a Demi's state, each reading its operand through the one",
|
|
1756
1911
|
"Size observer `x.##`. They are fixed-channel load transformations consistent",
|
|
1757
1912
|
"with a `RotorRouter`'s channel loads (`hc/rotor-router.hc`), not named Router",
|
|
1758
|
-
"methods
|
|
1759
|
-
"
|
|
1760
|
-
"
|
|
1761
|
-
"
|
|
1762
|
-
"
|
|
1763
|
-
"was, so they compose by nesting. There is **no** `/`: a Demi declares no",
|
|
1764
|
-
"division operator",
|
|
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",
|
|
1765
1918
|
"```",
|
|
1766
1919
|
"; .D (Demi [2, 5, 3]);",
|
|
1767
1920
|
"; [“” (D + 4), “” (D - 4), “” (D * 3)]",
|
|
1768
|
-
"# [“Demi(
|
|
1921
|
+
"# [“Demi(2,5,7)”, “Demi(2,9,3)”, “Demi(2,15,9)”]",
|
|
1769
1922
|
"; [“” ((D + 4) - 2), “” ((D - 2) + 4), “” ((D + 4) * 3)]",
|
|
1770
|
-
"# [“Demi(
|
|
1923
|
+
"# [“Demi(2,7,7)”, “Demi(2,7,7)”, “Demi(2,15,21)”]",
|
|
1771
1924
|
"; “” D",
|
|
1772
|
-
"# “Demi(
|
|
1925
|
+
"# “Demi(2,5,3)”",
|
|
1773
1926
|
"```",
|
|
1774
|
-
"A deposit keeps the phase, including phase 1, where application would
|
|
1775
|
-
"and a zero Size deposits nothing while still answering a Demi. The
|
|
1776
|
-
"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",
|
|
1777
1930
|
"```",
|
|
1778
|
-
"; [(D + 4).#, (D - 4).#, (D * 3)
|
|
1779
|
-
"# [2, 2, 2]",
|
|
1931
|
+
"; [(D + 4).#, (D - 4).#, (D * 3).#, (D + 4).count, (D + 4).phase]",
|
|
1932
|
+
"# [2, 2, 2, 2, 2]",
|
|
1780
1933
|
"; .P (Demi [1, 5, 3]);",
|
|
1781
|
-
"; [“” (P + 4), (P + 4).#, “” (P - 4)]",
|
|
1782
|
-
"# [“Demi(
|
|
1934
|
+
"; [“” (P + 4), (P + 4).#, (P + 4).phase, “” (P - 4)]",
|
|
1935
|
+
"# [“Demi(1,5,7)”, 1, 1, “Demi(1,9,3)”]",
|
|
1783
1936
|
"; [“” (D + 0), “” (D - 0), “” (D [3, 4])]",
|
|
1784
|
-
"# [“Demi(
|
|
1937
|
+
"# [“Demi(2,5,3)”, “Demi(2,5,3)”, “Demi(3,12,3)”]",
|
|
1785
1938
|
"```",
|
|
1786
|
-
"Deposit is not application and deposit is not subtraction. `D x`
|
|
1787
|
-
"phase and `D + x` does not, so they reach different
|
|
1788
|
-
"left load and never takes from the right, so a load
|
|
1789
|
-
"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",
|
|
1790
1943
|
"```",
|
|
1791
1944
|
"; [(D + 4).###, (D - 4).###, D.###]",
|
|
1792
1945
|
"# [-2, 6, 2]",
|
|
1793
|
-
"; [((D 4).# = (D + 4).#), (D 4).###, (D + 4)
|
|
1794
|
-
"# [(), 6, -2]",
|
|
1946
|
+
"; [((D 4).# = (D + 4).#), (D 4).###, (D + 4).###, (D 4).#, (D 4).phase]",
|
|
1947
|
+
"# [(), 6, -2, 3, 1]",
|
|
1795
1948
|
"```",
|
|
1796
1949
|
"Order of a right then a left deposit does not matter, and scaling after a",
|
|
1797
1950
|
"balanced deposit is the Star shadow of scaling first",
|
|
@@ -1807,15 +1960,59 @@ export const HC_SOURCES = new Map([
|
|
|
1807
1960
|
"; [D + ([].nope), D - ([].nope), D * ([].nope)]",
|
|
1808
1961
|
"# [$!.name-missing “..., $!.name-missing “..., $!.name-missing “...]",
|
|
1809
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
|
+
"```",
|
|
1810
2007
|
"`*` scales by the operand's Size, so its domain is every sized Frame: a Demi",
|
|
1811
2008
|
"contributes `L + R`, an aggregate its element count, a decimal its truncated",
|
|
1812
2009
|
"magnitude, and a zero Size annihilates both loads. `D * 3` is unchanged, since",
|
|
1813
|
-
"`3.## = 3`, and the result keeps the
|
|
2010
|
+
"`3.## = 3`, and the result keeps the Count in either parity",
|
|
1814
2011
|
"```",
|
|
1815
2012
|
"; [“” (D * (Demi [1, 2, 4])), “” (D * [[], []]), “” (D * 2.5), “” (D * 0)]",
|
|
1816
|
-
"# [“Demi(
|
|
2013
|
+
"# [“Demi(2,30,18)”, “Demi(2,10,6)”, “Demi(2,10,6)”, “Demi(2,0,0)”]",
|
|
1817
2014
|
"; [“” (D * 1), (D * 3).#, (P * 3).#, “” (P * 3)]",
|
|
1818
|
-
"# [“Demi(
|
|
2015
|
+
"# [“Demi(2,5,3)”, 2, 1, “Demi(1,15,9)”]",
|
|
1819
2016
|
"```",
|
|
1820
2017
|
"The signed-scalar reading misleads: `+` lowers the residual and `-` raises it,",
|
|
1821
2018
|
"so `D + 4` is not “larger” than `D`, and `D - 4` is not `D` made smaller",
|
|
@@ -1823,31 +2020,124 @@ export const HC_SOURCES = new Map([
|
|
|
1823
2020
|
"; [(D + 4).### .< D.###, (D - 4).### .> D.###]",
|
|
1824
2021
|
"# [<>, <>]",
|
|
1825
2022
|
"```",
|
|
1826
|
-
"
|
|
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",
|
|
1827
2091
|
"",
|
|
1828
|
-
"
|
|
1829
|
-
"
|
|
1830
|
-
"
|
|
1831
|
-
"nil, never a signed quotient. A zero or a Demi divisor is nil the same way, so",
|
|
1832
|
-
"there is no hidden division-by-zero path and no Demi-as-Spin through another",
|
|
1833
|
-
"name. Only a failing operand changes the answer, because the global `/`",
|
|
1834
|
-
"propagates an operand that is already an error, exactly as `+`, `-` and `*` do",
|
|
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",
|
|
1835
2095
|
"```",
|
|
1836
|
-
"; .
|
|
1837
|
-
"; [
|
|
1838
|
-
"# [(), (), (), ()]",
|
|
1839
|
-
"
|
|
1840
|
-
"
|
|
1841
|
-
"
|
|
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 ()",
|
|
1842
2122
|
"# $!.name-missing “...",
|
|
1843
2123
|
"```",
|
|
1844
|
-
"
|
|
1845
|
-
"
|
|
1846
|
-
"
|
|
1847
|
-
"
|
|
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",
|
|
1848
2129
|
"```",
|
|
1849
|
-
"; [
|
|
1850
|
-
"
|
|
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, <>]",
|
|
1851
2141
|
"```",
|
|
1852
2142
|
"## A precise regression: a load read at the wrong depth",
|
|
1853
2143
|
"",
|
|
@@ -1869,14 +2159,33 @@ export const HC_SOURCES = new Map([
|
|
|
1869
2159
|
"; [r.phase, r.left]",
|
|
1870
2160
|
"# [1, 5]",
|
|
1871
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
|
+
"```",
|
|
1872
2181
|
"## Importing",
|
|
1873
2182
|
"",
|
|
1874
2183
|
"Imported, the file binds the same class. The import is an example line, so",
|
|
1875
2184
|
"the evaluator, which reads this file without a root, never runs it",
|
|
1876
2185
|
"```",
|
|
1877
2186
|
"; Demis <- './hc/demi.hc';",
|
|
1878
|
-
"; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [
|
|
1879
|
-
"# [<>, “Demi(
|
|
2187
|
+
"; [(Demis.Demi [2, 5, 3]) = [5, 3].####, “” ((Demis.Demi [0, 0, 0]) 4)]",
|
|
2188
|
+
"# [<>, “Demi(1,4,0)”]",
|
|
1880
2189
|
"",
|
|
1881
2190
|
].join("\n"),
|
|
1882
2191
|
],
|
|
@@ -2089,14 +2398,16 @@ export const HC_SOURCES = new Map([
|
|
|
2089
2398
|
"The fourth observer derives a Demi from Count, Size and residual.",
|
|
2090
2399
|
"A zero Count or absent residual gives no Demi; errors propagate. A schema used",
|
|
2091
2400
|
"as an explicit element contributes Size normally, even though its own Demi is nil.",
|
|
2092
|
-
"A present Demi has Size L+R and residual L−R. Its Count is
|
|
2093
|
-
"
|
|
2094
|
-
"
|
|
2095
|
-
"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`).",
|
|
2096
2407
|
"A present Demi is an instance of the HC class in `hc/demi.hc` (011.20), and",
|
|
2097
|
-
"reads as text `Demi(
|
|
2098
|
-
"and
|
|
2099
|
-
"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,",
|
|
2100
2411
|
"because [].#### is nil. Scaling is the method `scale_`, the shadow of Star:",
|
|
2101
2412
|
"(X * Y).#### is X.####.scale_ (Y.##) for a nonempty host. Count is a terminal",
|
|
2102
2413
|
"quantity: positive Counts agree with pure Figures of that terminal Size, but 0",
|
|
@@ -2104,17 +2415,17 @@ export const HC_SOURCES = new Map([
|
|
|
2104
2415
|
"including [0].####.",
|
|
2105
2416
|
"```",
|
|
2106
2417
|
"; [[].####, 0.####, “” “hello”.####, <2,3,5>.####]",
|
|
2107
|
-
"# [(), (), “Demi(
|
|
2418
|
+
"# [(), (), “Demi(5,3,2)”, ()]",
|
|
2108
2419
|
"; [(10 - 5).#### = 5.####, (0 - 5).#### = 5.####, (5.0).#### = 5.####, “hello”.#### = 5.####]",
|
|
2109
2420
|
"# [<>, <>, <>, <>]",
|
|
2110
2421
|
"; [<>.#, <>.##, <>.###, ().##]",
|
|
2111
2422
|
"# [0, 1, 0, 1]",
|
|
2112
2423
|
"; [1, 2, 3, 7] & {“” _.####}",
|
|
2113
|
-
"# [“Demi(
|
|
2424
|
+
"# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,2,1)”, “Demi(7,4,3)”]",
|
|
2114
2425
|
"; [[0], [“hello”], [<2,3,5>,2], {5 + 3}] & {“” _.####}",
|
|
2115
|
-
"# [“Demi(
|
|
2426
|
+
"# [“Demi(1,0,0)”, “Demi(1,5,0)”, “Demi(2,3,2)”, “Demi(3,8,1)”]",
|
|
2116
2427
|
"; [“” ([[],[]].#### 3), “” (7.####.scale_ 2), ([[],[]] 3).#### = ([[],[]].#### 3)]",
|
|
2117
|
-
"# [“Demi(
|
|
2428
|
+
"# [“Demi(3,4,1)”, “Demi(7,8,6)”, <>]",
|
|
2118
2429
|
"```",
|
|
2119
2430
|
"A RotorRouter, the class in `hc/rotor-router.hc` (011.21), keeps the routed",
|
|
2120
2431
|
"Figures themselves in two ordered channels and declares the observers that make",
|
|
@@ -2123,7 +2434,7 @@ export const HC_SOURCES = new Map([
|
|
|
2123
2434
|
"fourth hash is the Figure's.",
|
|
2124
2435
|
"```",
|
|
2125
2436
|
"; Routers <- './hc/rotor-router.hc';",
|
|
2126
|
-
"; .fr ([[], [[], []], []] | (Routers.RotorRouter [
|
|
2437
|
+
"; .fr ([[], [[], []], []] | (Routers.RotorRouter [[], []]));",
|
|
2127
2438
|
"; [fr.left, fr.right, fr.#### = [[], [[], []], []].####]",
|
|
2128
2439
|
"# [[[], []], [[[], []]], <>]",
|
|
2129
2440
|
"",
|
|
@@ -2750,54 +3061,78 @@ export const HC_SOURCES = new Map([
|
|
|
2750
3061
|
"```",
|
|
2751
3062
|
"RotorRouter (occurrence/figure 011.21)",
|
|
2752
3063
|
"",
|
|
2753
|
-
"A RotorRouter is a two-channel router that keeps what it routes.
|
|
2754
|
-
"
|
|
2755
|
-
"Applying a router to a Frame appends that Frame, the same Frame, to the
|
|
2756
|
-
"channel
|
|
2757
|
-
"
|
|
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",
|
|
2758
3069
|
"everything that shadow forgets: which Frames, in what order, and which channel.",
|
|
2759
3070
|
"",
|
|
2760
3071
|
"`RotorRouter` is an ordinary HC class, like `Demi` in `hc/demi.hc`: a",
|
|
2761
3072
|
"constructor closure answering a fresh aggregate whose fields are its state and",
|
|
2762
3073
|
"whose methods are the class. Import it with",
|
|
2763
|
-
"`Routers <- './hc/rotor-router.hc'`, then `Routers.RotorRouter [
|
|
2764
|
-
"",
|
|
2765
|
-
"**State.** `RotorRouter [
|
|
2766
|
-
"
|
|
2767
|
-
"
|
|
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",
|
|
2768
3093
|
"array's properties are configuration, not routed Frames, so the constructor",
|
|
2769
|
-
"keeps the elements in a fresh array of its own,
|
|
2770
|
-
"declares `apply` cannot change what appending means.
|
|
2771
|
-
"
|
|
2772
|
-
"
|
|
2773
|
-
"
|
|
2774
|
-
"
|
|
2775
|
-
"",
|
|
2776
|
-
"
|
|
2777
|
-
"
|
|
2778
|
-
"
|
|
2779
|
-
"
|
|
2780
|
-
"
|
|
2781
|
-
"
|
|
2782
|
-
"
|
|
2783
|
-
"
|
|
2784
|
-
"
|
|
2785
|
-
"
|
|
2786
|
-
"",
|
|
2787
|
-
"
|
|
2788
|
-
"
|
|
2789
|
-
"
|
|
2790
|
-
"
|
|
2791
|
-
"router's
|
|
2792
|
-
"nonempty channel's load is its native Size, which
|
|
2793
|
-
"where children are measured, so it is where their
|
|
2794
|
-
"observers run only when the router is observed:
|
|
2795
|
-
"observing writes nothing. The Demi forgets which
|
|
2796
|
-
"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`.",
|
|
2797
3132
|
"",
|
|
2798
3133
|
"**Text.** A router prints as its fields and methods, and as text reads",
|
|
2799
|
-
"`RotorRouter(
|
|
2800
|
-
"
|
|
3134
|
+
"`RotorRouter([…],[…])`, each channel as its spelling, the constructor's own",
|
|
3135
|
+
"shape.",
|
|
2801
3136
|
"",
|
|
2802
3137
|
"**Methods read their own state through `_^`.** A router is applied to",
|
|
2803
3138
|
"arbitrary Frames, and a bare name in a method is looked up on the argument",
|
|
@@ -2805,41 +3140,57 @@ export const HC_SOURCES = new Map([
|
|
|
2805
3140
|
"the method body. What a branch needs is bound as a local at method level.",
|
|
2806
3141
|
"```",
|
|
2807
3142
|
".channel-load {.c _; (c.# = 0) ? {0} : {c.##}};",
|
|
2808
|
-
".RotorRouter {((_ ~ ([].<>)) ? {(__ .#) =
|
|
2809
|
-
" ((
|
|
2810
|
-
"
|
|
2811
|
-
" .
|
|
2812
|
-
" .
|
|
2813
|
-
" .
|
|
2814
|
-
"
|
|
2815
|
-
"
|
|
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.#};",
|
|
2816
3152
|
" .## {(channel-load (_^ .left)) + (channel-load (_^ .right))};",
|
|
2817
3153
|
" .### {(channel-load (_^ .left)) - (channel-load (_^ .right))};",
|
|
2818
|
-
" .toText {“RotorRouter(” (
|
|
2819
|
-
" ]} : {$!!.invalid-router}} : {$!!.invalid-router}};",
|
|
3154
|
+
" .toText {“RotorRouter(” (_^ .left) “,” (_^ .right) “)”}",
|
|
3155
|
+
" ]} : {$!!.invalid-router}} : {$!!.invalid-router}} : {$!!.invalid-router}};",
|
|
2820
3156
|
"```",
|
|
2821
3157
|
"## Construction",
|
|
2822
3158
|
"",
|
|
2823
|
-
"A router holds exactly its
|
|
2824
|
-
"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",
|
|
3161
|
+
"```",
|
|
3162
|
+
"; .r0 (RotorRouter [[], []]);",
|
|
3163
|
+
"; [r0.phase, r0.left, r0.right, r0.#, “” r0]",
|
|
3164
|
+
"# [2, [], [], 0, “RotorRouter([],[])”]",
|
|
3165
|
+
"```",
|
|
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",
|
|
2825
3169
|
"```",
|
|
2826
|
-
";
|
|
2827
|
-
"
|
|
2828
|
-
"# [2, [], [], “RotorRouter(<>,[],[])”]",
|
|
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]]",
|
|
2829
3172
|
"```",
|
|
2830
|
-
"
|
|
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",
|
|
2831
3176
|
"```",
|
|
2832
|
-
"; RotorRouter [3, [], []]",
|
|
2833
|
-
"# $!!.invalid-router",
|
|
2834
|
-
"; [RotorRouter [(5 - 3), [], []], RotorRouter [2, [], 5], RotorRouter [2, (1, 2), []], RotorRouter [2, []], RotorRouter 5]",
|
|
3177
|
+
"; [RotorRouter [[], [5]], RotorRouter [[5], [6, 7]], RotorRouter [[5, 6], []], RotorRouter [[1, 2, 3], [4]], RotorRouter [[], [1, 2, 3]]]",
|
|
2835
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]",
|
|
2836
3186
|
"```",
|
|
2837
3187
|
"A channel is its elements. The router keeps them in an array of its own, so a",
|
|
2838
|
-
"channel's properties and a declared `apply` do not come with it",
|
|
3188
|
+
"channel's properties and a declared `apply` do not come with it, and only the",
|
|
3189
|
+
"elements are counted for admissibility",
|
|
2839
3190
|
"```",
|
|
2840
3191
|
"; .Hijack [.apply {“hijack”}; 1];",
|
|
2841
|
-
"; [(RotorRouter [
|
|
2842
|
-
"# [[5], [
|
|
3192
|
+
"; [(RotorRouter [[.tag 9; 5], []]).left, ((RotorRouter [Hijack, []]) 7).right, RotorRouter [[.a 1; .b 2], [5]]]",
|
|
3193
|
+
"# [[5], [7], $!!.invalid-router]",
|
|
2843
3194
|
"```",
|
|
2844
3195
|
"## Routing alternates",
|
|
2845
3196
|
"",
|
|
@@ -2848,16 +3199,26 @@ export const HC_SOURCES = new Map([
|
|
|
2848
3199
|
"```",
|
|
2849
3200
|
"; .A [1, [2]]; .B “b”; .C {5 + 3};",
|
|
2850
3201
|
"; .r3 (((r0 A) B) C);",
|
|
2851
|
-
"; [r3.phase, r3.left, r3.right]",
|
|
2852
|
-
"# [1, [[1, [2]], { 5 + 3 }], [“b”]]",
|
|
3202
|
+
"; [r3.phase, r3.left, r3.right, r3.#]",
|
|
3203
|
+
"# [1, [[1, [2]], { 5 + 3 }], [“b”], 3]",
|
|
2853
3204
|
"; “” r3",
|
|
2854
|
-
"# “RotorRouter(
|
|
3205
|
+
"# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
|
|
2855
3206
|
"```",
|
|
2856
3207
|
"The router that was routed into is left as it was",
|
|
2857
3208
|
"```",
|
|
2858
3209
|
"; [r0.phase, r0.left, r0.right]",
|
|
2859
3210
|
"# [2, [], []]",
|
|
2860
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
|
+
"```",
|
|
2861
3222
|
"## Routing keeps the Frame",
|
|
2862
3223
|
"",
|
|
2863
3224
|
"A channel member is the routed Frame itself. An array or a group is routed as",
|
|
@@ -2884,40 +3245,42 @@ export const HC_SOURCES = new Map([
|
|
|
2884
3245
|
"; [(rk.left.0.set_ 9).n, kid_.n, rk.left.0.n]",
|
|
2885
3246
|
"# [9, 5, 5]",
|
|
2886
3247
|
"```",
|
|
2887
|
-
"##
|
|
3248
|
+
"## Preloaded states",
|
|
2888
3249
|
"",
|
|
2889
|
-
"
|
|
2890
|
-
"
|
|
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",
|
|
2891
3252
|
"```",
|
|
2892
|
-
"; .p1 (RotorRouter [
|
|
3253
|
+
"; .p1 (RotorRouter [[A], []]);",
|
|
2893
3254
|
"; .p2 ((p1 B) C);",
|
|
2894
|
-
"; [p2.phase, p2.left, p2.right, p1.
|
|
2895
|
-
"# [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
|
+
"# [<>, <>]",
|
|
2896
3259
|
"```",
|
|
2897
3260
|
"Routers built from the same channel share no writable state: each holds its",
|
|
2898
3261
|
"own channel array. Through a mutable name, routing writes that router in place",
|
|
2899
3262
|
"and no other",
|
|
2900
3263
|
"```",
|
|
2901
3264
|
"; .ch [A];",
|
|
2902
|
-
"; .u (RotorRouter [
|
|
2903
|
-
"; .m_ (RotorRouter [
|
|
3265
|
+
"; .u (RotorRouter [ch, []]); .v (RotorRouter [ch, []]);",
|
|
3266
|
+
"; .m_ (RotorRouter [ch, []]);",
|
|
2904
3267
|
"; m_ B;",
|
|
2905
3268
|
"; m_ C;",
|
|
2906
3269
|
"; [m_.phase, m_.left, m_.right, u.left, v.left, ch]",
|
|
2907
|
-
"# [
|
|
3270
|
+
"# [1, [[1, [2]], { 5 + 3 }], [“b”], [[1, [2]]], [[1, [2]]], [[1, [2]]]]",
|
|
2908
3271
|
"; [u.left === ch, u.left === v.left, u.left.0 === v.left.0]",
|
|
2909
3272
|
"# [(), (), <>]",
|
|
2910
3273
|
"```",
|
|
2911
3274
|
"A router captured by a closure, mapped, or reduced into routes the same way,",
|
|
2912
3275
|
"and the captured one stays as it was",
|
|
2913
3276
|
"```",
|
|
2914
|
-
"; .start (RotorRouter [
|
|
3277
|
+
"; .start (RotorRouter [[], []]); .step {start _};",
|
|
2915
3278
|
"; [(step 5).left, (step 3).left, start.left]",
|
|
2916
3279
|
"# [[5], [3], []]",
|
|
2917
3280
|
"; [r0, p1] & {(_ 5).right}",
|
|
2918
3281
|
"# [[], [5]]",
|
|
2919
3282
|
"; “” ([A, B, C] | r0)",
|
|
2920
|
-
"# “RotorRouter(
|
|
3283
|
+
"# “RotorRouter([[1, [2]], { 5 + 3 }],[“b”])”",
|
|
2921
3284
|
"```",
|
|
2922
3285
|
"## Routing measures nothing",
|
|
2923
3286
|
"",
|
|
@@ -2942,7 +3305,7 @@ export const HC_SOURCES = new Map([
|
|
|
2942
3305
|
"; (r0 Cyclic).####",
|
|
2943
3306
|
"# $!.cyclic-observation .##",
|
|
2944
3307
|
"; “” ((r0 Counted).####)",
|
|
2945
|
-
"# “Demi(
|
|
3308
|
+
"# “Demi(1,5,0)”",
|
|
2946
3309
|
"; counter_.n",
|
|
2947
3310
|
"# 2",
|
|
2948
3311
|
"```",
|
|
@@ -2957,26 +3320,30 @@ export const HC_SOURCES = new Map([
|
|
|
2957
3320
|
"```",
|
|
2958
3321
|
"Routing nil routes nothing",
|
|
2959
3322
|
"```",
|
|
2960
|
-
"; [(r0 ()).phase, (r0 ()).left]",
|
|
2961
|
-
"# [2, []]",
|
|
3323
|
+
"; [(r0 ()).phase, (r0 ()).left, (p1 ()).#]",
|
|
3324
|
+
"# [2, [], 1]",
|
|
2962
3325
|
"```",
|
|
2963
3326
|
"## Empty and zero",
|
|
2964
3327
|
"",
|
|
2965
|
-
"The initial router
|
|
2966
|
-
"
|
|
2967
|
-
"
|
|
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",
|
|
2968
3332
|
"```",
|
|
2969
|
-
"; [
|
|
2970
|
-
"# [
|
|
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
|
+
"# [<>, <>]",
|
|
2971
3338
|
"```",
|
|
2972
3339
|
"A Frame of Size zero takes a slot and flips the phase, and an empty array",
|
|
2973
3340
|
"routed as a child has Size 1, while an empty channel has load 0",
|
|
2974
3341
|
"```",
|
|
2975
3342
|
"; .z (r0 0);",
|
|
2976
|
-
"; [z.phase, z.left, “” (z.####)]",
|
|
2977
|
-
"# [1, [0], “Demi(
|
|
3343
|
+
"; [z.phase, z.left, z.#, “” (z.####)]",
|
|
3344
|
+
"# [1, [0], 1, “Demi(1,0,0)”]",
|
|
2978
3345
|
"; [“” ((r0 []).####), “” (((r0 []) []).####), “” ((((r0 0) 0) 0).####)]",
|
|
2979
|
-
"# [“Demi(
|
|
3346
|
+
"# [“Demi(1,1,0)”, “Demi(2,1,1)”, “Demi(3,0,0)”]",
|
|
2980
3347
|
"```",
|
|
2981
3348
|
"## The router's Demi",
|
|
2982
3349
|
"",
|
|
@@ -2989,59 +3356,79 @@ export const HC_SOURCES = new Map([
|
|
|
2989
3356
|
"; [mix.left, mix.right]",
|
|
2990
3357
|
"# [[“hello”, [[1, 2], [3]], [[], []], { 5 + 3 }], [7, (4, 5), [[], []], <>]]",
|
|
2991
3358
|
"; [mix.left & {_.##}, mix.right & {_.##}, “” (mix.####)]",
|
|
2992
|
-
"# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(
|
|
3359
|
+
"# [[5, 6, 2, 9], [7, 9, 2, 1], “Demi(8,22,19)”]",
|
|
2993
3360
|
"; “” (((r0 123456789012345678901234567890) 987654321098765432109876543210).####)",
|
|
2994
|
-
"# “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
|
+
"# [[<>, <>, <>, <>, <>, <>], <>]",
|
|
2995
3371
|
"```",
|
|
2996
3372
|
"## Observing commutes with routing",
|
|
2997
3373
|
"",
|
|
2998
3374
|
"Routing each child of an array X in turn, from the initial router, is the",
|
|
2999
3375
|
"reduce `X | r0`. Its left channel holds the children at even positions and its",
|
|
3000
3376
|
"right channel those at odd positions, and its phase is the parity of X's Count.",
|
|
3001
|
-
"That interleaving is the invariant
|
|
3002
|
-
"
|
|
3377
|
+
"That interleaving is the admissibility invariant, so the same router is",
|
|
3378
|
+
"constructed directly from the two channels",
|
|
3003
3379
|
"```",
|
|
3004
3380
|
"; .X [5, “ab”, [1, 2]];",
|
|
3005
3381
|
"; .rx (X | r0);",
|
|
3006
|
-
"; [rx.left, rx.right, rx.phase, rx = (RotorRouter [
|
|
3382
|
+
"; [rx.left, rx.right, rx.phase, rx = (RotorRouter [[5, [1, 2]], [“ab”]])]",
|
|
3007
3383
|
"# [[5, [1, 2]], [“ab”], 1, <>]",
|
|
3008
3384
|
"```",
|
|
3009
|
-
"For
|
|
3010
|
-
"
|
|
3011
|
-
"
|
|
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",
|
|
3012
3389
|
"```",
|
|
3013
3390
|
"; .Y [[], [], []];",
|
|
3014
|
-
"; [(rx.####) = X.####, ((rx Y).####) = (X Y).####, ((rx Y).####) = ((rx.####) Y)]",
|
|
3015
|
-
"# [<>, <>, <>]",
|
|
3016
|
-
"; [((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)]",
|
|
3017
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
|
+
"# [[<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>], [<>, <>, <>, <>, <>]]",
|
|
3018
3398
|
"```",
|
|
3019
|
-
"The
|
|
3020
|
-
"
|
|
3021
|
-
"The router is the empty host lifted: routing nothing from it leaves it as it",
|
|
3022
|
-
"is, and after one route the two agree again",
|
|
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",
|
|
3023
3401
|
"```",
|
|
3024
|
-
";
|
|
3025
|
-
"# [<>,
|
|
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]]",
|
|
3026
3406
|
"```",
|
|
3027
|
-
"
|
|
3028
|
-
"
|
|
3029
|
-
"routing reaches, yet its fourth hash equals that of an array whose",
|
|
3030
|
-
"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",
|
|
3031
3409
|
"```",
|
|
3032
|
-
";
|
|
3033
|
-
"
|
|
3034
|
-
"
|
|
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
|
+
"# [(), <>, <>, <>, <>, <>]",
|
|
3035
3421
|
"```",
|
|
3036
3422
|
"## The Demi forgets",
|
|
3037
3423
|
"",
|
|
3038
|
-
"Distinct routers can share a Demi: the fourth hash keeps only the",
|
|
3039
|
-
"
|
|
3040
|
-
"
|
|
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",
|
|
3041
3428
|
"```",
|
|
3042
|
-
"; .s1 (RotorRouter [
|
|
3043
|
-
"; [s1 = s2, s1 = s3, (s1.####) = (
|
|
3044
|
-
"# [(), (), <>,
|
|
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]",
|
|
3045
3432
|
"```",
|
|
3046
3433
|
"## Observers, declared",
|
|
3047
3434
|
"",
|
|
@@ -3066,9 +3453,9 @@ export const HC_SOURCES = new Map([
|
|
|
3066
3453
|
"## Reading the receiver",
|
|
3067
3454
|
"",
|
|
3068
3455
|
"An argument whose fields share the router's names, or its locals', is routed",
|
|
3069
|
-
"as one member, and the router reads only its own fields",
|
|
3456
|
+
"as one member, and the router reads only its own fields and its own Count",
|
|
3070
3457
|
"```",
|
|
3071
|
-
"; .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]);",
|
|
3072
3459
|
"; [masked.phase, masked.left.#, masked.left.0.x, masked.right]",
|
|
3073
3460
|
"# [1, 1, 9, []]",
|
|
3074
3461
|
"```",
|
|
@@ -3096,9 +3483,9 @@ export const HC_SOURCES = new Map([
|
|
|
3096
3483
|
"`.###`, which an expectation line, itself a `#…#` comment, cannot hold, so the",
|
|
3097
3484
|
"printed form is matched here by its beginning",
|
|
3098
3485
|
"```",
|
|
3099
|
-
"; RotorRouter [
|
|
3486
|
+
"; RotorRouter [[5], []]",
|
|
3100
3487
|
"# [.phase 1; .left [5]; .right []; .apply_ {...",
|
|
3101
|
-
"; (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) “)” };]",
|
|
3102
3489
|
"# <>",
|
|
3103
3490
|
"```",
|
|
3104
3491
|
"## Importing",
|
|
@@ -3107,8 +3494,8 @@ export const HC_SOURCES = new Map([
|
|
|
3107
3494
|
"importing this file does not import it again",
|
|
3108
3495
|
"```",
|
|
3109
3496
|
"; Routers <- './hc/rotor-router.hc';",
|
|
3110
|
-
"; [(Routers.RotorRouter [
|
|
3111
|
-
"# [<>, “RotorRouter(
|
|
3497
|
+
"; [(Routers.RotorRouter [[], []]) = r0, “” ((Routers.RotorRouter [[], []]) 4), (((Routers.RotorRouter [[], []]) 4).####) = [4].####]",
|
|
3498
|
+
"# [<>, “RotorRouter([4],[])”, <>]",
|
|
3112
3499
|
"",
|
|
3113
3500
|
].join("\n"),
|
|
3114
3501
|
],
|