hclang 0.32.1 → 0.33.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.
- package/esm/lib/bundle/hc-sources.js +126 -743
- package/esm/lib/frames/frame-lazy.js +2 -1
- package/esm/lib/frames/frame-list.js +28 -14
- package/esm/lib/frames/frame.js +2 -1
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -690,16 +690,21 @@ export const HC_SOURCES = new Map([
|
|
|
690
690
|
"; [.a 1] & {_}",
|
|
691
691
|
"# []",
|
|
692
692
|
"```",
|
|
693
|
-
"`.#` and `.##` count the elements too, the immediate ones and the
|
|
694
|
-
"them, so neither counts a property.
|
|
695
|
-
"
|
|
693
|
+
"`.#` and `.##` count the elements too, the immediate ones and the terminals",
|
|
694
|
+
"below them, so neither counts a property. A terminal is an element that is not",
|
|
695
|
+
"an aggregate, or an aggregate with no elements: the empty frame is one terminal,",
|
|
696
|
+
"at the root or nested. Every aggregate counts this way, a group as well as an",
|
|
697
|
+
"array. A count is its own size, and any other value has none (#411, issue",
|
|
698
|
+
"occurrence/figure 010.02)",
|
|
696
699
|
"```",
|
|
697
700
|
"; [.meta 1; 2, 3] .#",
|
|
698
701
|
"# 2",
|
|
699
702
|
"; [.meta [1, 2]; [3, []], 4] .##",
|
|
700
|
-
"#
|
|
703
|
+
"# 3",
|
|
701
704
|
"; (1, [2, 3]) .##",
|
|
702
705
|
"# 3",
|
|
706
|
+
"; [[].#, [].##, [[], [[], []]].#, [[], [[], []]].##]",
|
|
707
|
+
"# [0, 1, 2, 3]",
|
|
703
708
|
"; 5.#",
|
|
704
709
|
"# 5",
|
|
705
710
|
"; “abc”.#",
|
|
@@ -1157,687 +1162,147 @@ export const HC_SOURCES = new Map([
|
|
|
1157
1162
|
[
|
|
1158
1163
|
"#!/usr/bin/env hc",
|
|
1159
1164
|
"```",
|
|
1160
|
-
"Figures (#
|
|
1161
|
-
"",
|
|
1162
|
-
"
|
|
1163
|
-
"
|
|
1164
|
-
|
|
1165
|
-
"`
|
|
1166
|
-
"",
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"
|
|
1171
|
-
"
|
|
1172
|
-
"
|
|
1173
|
-
"
|
|
1174
|
-
"a
|
|
1175
|
-
"
|
|
1176
|
-
"",
|
|
1177
|
-
"
|
|
1178
|
-
"
|
|
1179
|
-
"
|
|
1180
|
-
"
|
|
1181
|
-
"
|
|
1182
|
-
"
|
|
1183
|
-
"
|
|
1184
|
-
"
|
|
1185
|
-
"
|
|
1186
|
-
"
|
|
1187
|
-
"
|
|
1188
|
-
"
|
|
1189
|
-
"
|
|
1190
|
-
"
|
|
1191
|
-
"
|
|
1192
|
-
"",
|
|
1193
|
-
"
|
|
1194
|
-
"
|
|
1195
|
-
"
|
|
1196
|
-
"
|
|
1197
|
-
"
|
|
1198
|
-
"",
|
|
1199
|
-
"
|
|
1200
|
-
"
|
|
1201
|
-
"
|
|
1202
|
-
"
|
|
1203
|
-
"
|
|
1204
|
-
"
|
|
1205
|
-
"
|
|
1206
|
-
"
|
|
1207
|
-
"
|
|
1208
|
-
" .
|
|
1209
|
-
"
|
|
1210
|
-
"
|
|
1211
|
-
"
|
|
1212
|
-
"
|
|
1213
|
-
"
|
|
1214
|
-
"
|
|
1215
|
-
"
|
|
1216
|
-
" .
|
|
1217
|
-
"
|
|
1218
|
-
"
|
|
1219
|
-
"
|
|
1220
|
-
"
|
|
1221
|
-
"
|
|
1222
|
-
"
|
|
1223
|
-
"
|
|
1224
|
-
"
|
|
1225
|
-
"
|
|
1226
|
-
"
|
|
1227
|
-
"
|
|
1228
|
-
"
|
|
1229
|
-
"
|
|
1230
|
-
"
|
|
1231
|
-
"
|
|
1232
|
-
"
|
|
1233
|
-
"
|
|
1234
|
-
"
|
|
1235
|
-
"
|
|
1236
|
-
"
|
|
1237
|
-
"
|
|
1238
|
-
"
|
|
1239
|
-
"
|
|
1240
|
-
"
|
|
1241
|
-
"
|
|
1242
|
-
"```",
|
|
1243
|
-
"**Multiplication**, `x.mul y`: y at every cell of x, and `Z` when y is `Z`. It",
|
|
1244
|
-
"counts x's cells and constructs y that many times, so it keeps y's identity in",
|
|
1245
|
-
"every position and forgets x's shape. Without the guard, a one-cell x would",
|
|
1246
|
-
"answer `Figure [Z]`, which is a cell rather than zero",
|
|
1247
|
-
"```;",
|
|
1248
|
-
" .mul {.y _; .n ((_^.cells()).#); (y = Z) ? {Z} : {Figure (n [y])}};",
|
|
1249
|
-
"```",
|
|
1250
|
-
"**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
|
|
1251
|
-
"per child of x, and `Z` when y is `Z`. Manyness marks each child with `B`,",
|
|
1252
|
-
"which is `U`, so it is a tally of the children, and multiplying it by y holds y",
|
|
1253
|
-
"once per child. Multiplication's guard answers `Z` for a zero factor, so this",
|
|
1254
|
-
"needs no guard of its own. It keeps the cell count and forgets both shapes",
|
|
1255
|
-
"```;",
|
|
1256
|
-
" .size_mul {((_^.many()).mul _).size()};",
|
|
1257
|
-
"```",
|
|
1258
|
-
"**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes are the",
|
|
1259
|
-
"same tally and `Z` otherwise. It keeps only whether the cell counts agree",
|
|
1260
|
-
"```;",
|
|
1261
|
-
" .size_equivalent {((_^.size()) = (_.size())) ? {U} : {Z}};",
|
|
1262
|
-
"```",
|
|
1263
|
-
"**Sameness of form**, `x.sameform y`: `B` when `x = y`. It compares child by",
|
|
1264
|
-
"child and forgets identity and reuse",
|
|
1265
|
-
"```;",
|
|
1266
|
-
" .sameform {(_^ = _) ? {B} : {A}};",
|
|
1267
|
-
"```",
|
|
1268
|
-
"**Sameness**, `x.sameness y`: `B` when `x === y`, the same constructed Figure.",
|
|
1269
|
-
"It keeps identity only and forgets form",
|
|
1270
|
-
"```;",
|
|
1271
|
-
" .sameness {(_^ === _) ? {B} : {A}};",
|
|
1272
|
-
"```",
|
|
1273
|
-
"**Withness**, `x.withness [f, …]`: `B` when every f is an immediate child of x,",
|
|
1274
|
-
"the same Figure rather than an equal-looking one. It is relative to one parent,",
|
|
1275
|
-
"the receiver, and forgets the children's order, repeats, and everything below",
|
|
1276
|
-
"them. A requested Figure is absent when no child is identical to it",
|
|
1277
|
-
"```;",
|
|
1278
|
-
" .withness {.kids _^.children;",
|
|
1279
|
-
" .absent (_ &| {.f _; ((kids &| {(_ === f) ? {[f]}}) = []) ? {[f]}});",
|
|
1280
|
-
" (absent = []) ? {B} : {A}};",
|
|
1281
|
-
"```",
|
|
1282
|
-
"**Gap**, `x.gap()`: the absolute value of the alternating sum of the Sizes of",
|
|
1283
|
-
"x's immediate children, `|Size(F₁) − Size(F₂) + Size(F₃) − …|`, read as a",
|
|
1284
|
-
"FrameCount. The empty Figure has Gap `0`, and each child contributes its",
|
|
1285
|
-
"existing Size with a sign that starts positive and flips child by child; Gap",
|
|
1286
|
-
"keeps the sum's size and drops its sign, so it is never negative. Nesting",
|
|
1287
|
-
"reaches a child only through that Size, never through its construction. Gap",
|
|
1288
|
-
"observes rather than constructs, so like Cells, Form and Text it leaves the",
|
|
1289
|
-
"class on purpose: the sum it folds can go negative where no Figure does, so it",
|
|
1290
|
-
"is read as a number rather than a tally (#445). It reads each child's Size the",
|
|
1291
|
-
"way the semiring examples do, as `(_.size()).children.#`, and folds those",
|
|
1292
|
-
"readings with native arithmetic without touching construction, so it never",
|
|
1293
|
-
"asserts arithmetic equations or actual closure: a zero Gap is an observed",
|
|
1294
|
-
"value, not a proof. `_^`",
|
|
1295
|
-
"names the receiver so the alternating fold can read the children in order; the",
|
|
1296
|
-
"fold subtracts the sum of the rest, which flips the sign of every later child,",
|
|
1297
|
-
"and the sign of the whole is dropped last",
|
|
1298
|
-
"```;",
|
|
1299
|
-
" .gap {.kids _^.children;",
|
|
1300
|
-
" .count {(_.size()).children.#};",
|
|
1301
|
-
" .tail {(_ && {(((_ .0) = .0) ? {[()]} : {[[__ .1]]}) .0}) &| {_}};",
|
|
1302
|
-
" .alt {.cs _; (cs = []) ? {0} : {(count (cs .0)) - (alt (tail cs))}};",
|
|
1303
|
-
" .signed (alt kids);",
|
|
1304
|
-
" (signed .< 0) ? {0 - signed} : {signed}};",
|
|
1305
|
-
"```",
|
|
1306
|
-
"**Spin**, `x.spin N`: the signed alternating sum of the Sizes of x's immediate",
|
|
1307
|
-
"children, `Size(F₁) − Size(F₂) + Size(F₃) − …`, divided by a positive integer",
|
|
1308
|
-
"resolution N, read as an exact FrameRational in revolutions (#447). It folds the",
|
|
1309
|
-
"same readings Gap does, in the same order and with the same alternating signs",
|
|
1310
|
-
"that start positive, but it keeps the sign Gap drops, so the two directions read",
|
|
1311
|
-
"as `−` and `+`; the empty Figure has Spin `0` at every N. The signed sum is a",
|
|
1312
|
-
"whole count of revolutions, and `signed / N` divides it into N-ths, which the",
|
|
1313
|
-
"divisor's rung makes an exact ratio that collapses to a whole FrameInt when N",
|
|
1314
|
-
"divides it (#445, FrameCount). Gap is `|signed|`; Spin is `signed / N`, so Spin",
|
|
1315
|
-
"at N and Gap read the same fold and never disagree, and neither constructs: a",
|
|
1316
|
-
"zero Spin is an observed value, not a Fact that a Walk closed. N must be a",
|
|
1317
|
-
"count, bound as `.n <~~1>`, the count type read off a literal, so a non-count N",
|
|
1318
|
-
"— a fraction, a float, a negative, a string — is refused with a native",
|
|
1319
|
-
"`$!.type-error` before any fold, and the observable never answers a sign-flipped",
|
|
1320
|
-
"ratio for a negative N. A count N must also be positive: `N=0` passes the count",
|
|
1321
|
-
"type and is then the native `$!.division-by-zero`, and an empty argument `()`",
|
|
1322
|
-
"binds nothing and falls through to the same division-by-zero. `_^` names the",
|
|
1323
|
-
"receiver so the fold can read the children in order, and N is bound as `n`",
|
|
1324
|
-
"before the fold reads it",
|
|
1325
|
-
"```;",
|
|
1326
|
-
" .spin {.n <~~1> _; .kids _^.children;",
|
|
1327
|
-
" .count {(_.size()).children.#};",
|
|
1328
|
-
" .tail {(_ && {(((_ .0) = .0) ? {[()]} : {[[__ .1]]}) .0}) &| {_}};",
|
|
1329
|
-
" .alt {.cs _; (cs = []) ? {0} : {(count (cs .0)) - (alt (tail cs))}};",
|
|
1330
|
-
" .signed (alt kids);",
|
|
1331
|
-
" (n .< 1) ? {signed / 0} : {signed / n}};",
|
|
1332
|
-
"```",
|
|
1333
|
-
"**Form**, `x.form()`: the plain bracket tree of x, one bracket per Figure, the",
|
|
1334
|
-
"way 005.30c wrote Figures before they were a class. It keeps shape and order,",
|
|
1335
|
-
"and forgets identity and the methods",
|
|
1336
|
-
"```;",
|
|
1337
|
-
" .form {_^.children & {_.form()}};",
|
|
1338
|
-
"```",
|
|
1339
|
-
"**Text**, `“” x`: the form spelled as text, so a Figure interpolates as",
|
|
1340
|
-
"`[[], [[]]]` rather than as every method it declares (#398). Printing x still",
|
|
1341
|
-
"shows its full spelling, which reads back",
|
|
1342
|
-
"```;",
|
|
1343
|
-
" .toText {“” (_^.form())}",
|
|
1344
|
-
"]};",
|
|
1345
|
-
"```",
|
|
1346
|
-
"**The marks.** The observers answer `A`, the Figure with no children, for no",
|
|
1347
|
-
"and `B`, the Figure holding `A`, for yes. Size counts in the same two: `Z`",
|
|
1348
|
-
"reuses `A` as the additive zero and `U` reuses `B` as the unit cell. The class",
|
|
1349
|
-
"reads all four, so they are declared with it rather than in the examples below",
|
|
1350
|
-
"```",
|
|
1351
|
-
".A (Figure []); .B (Figure [A]); .Z A; .U B;",
|
|
1352
|
-
"```",
|
|
1353
|
-
"## Construction",
|
|
1354
|
-
"",
|
|
1355
|
-
"The example family reuses one `A` under both `B` and `E`. Indexing reaches a",
|
|
1356
|
-
"child itself, not a copy",
|
|
1357
|
-
"```",
|
|
1358
|
-
"; .C (Figure [B]); .D (Figure [C]);",
|
|
1359
|
-
"; .E (Figure [A, B]); .F (Figure [B, C]); .G (Figure [E, F]);",
|
|
1360
|
-
"; [(G.children .0) === E, (E.children .1) === B, (F.children .0) === B, (E.children .0) === (B.children .0)]",
|
|
1361
|
-
"# [<>, <>, <>, <>]",
|
|
1362
|
-
"```",
|
|
1363
|
-
"Form is the bracket tree a Figure is built as, and text spells it",
|
|
1364
|
-
"```",
|
|
1365
|
-
"; [(E.form()) = [[], [[]]], (E.form()) = [A.form(), B.form()], ((Figure []).form()) = []]",
|
|
1366
|
-
"# [<>, <>, <>]",
|
|
1367
|
-
"; [(“” E) = “[[], [[]]]”, (“G is ” G) = “G is [[[], [[]]], [[[]], [[[]]]]]”]",
|
|
1165
|
+
"Figures are native frames (#454; issue occurrence/figure 010.02)",
|
|
1166
|
+
"",
|
|
1167
|
+
"A Figure is a finite, property-free nested array built from `[]`. Construction",
|
|
1168
|
+
"is brackets, form is the value itself, immediate size is `.#`, terminal count",
|
|
1169
|
+
"is `.##`, form equality is `=`, and identity is `===`. The empty frame is one",
|
|
1170
|
+
"terminal: `[].#` is 0 and `[].##` is 1.",
|
|
1171
|
+
"",
|
|
1172
|
+
"There are no Figure constructors, marks, tally observers, count aliases or",
|
|
1173
|
+
"comparison wrappers. Use native operations directly. Multiplication that places",
|
|
1174
|
+
"y once per terminal of x is `x.## [y]`. A tally, when wanted, is an explicit",
|
|
1175
|
+
"construction, such as `x & {[[]]}` for one fresh mark per immediate element.",
|
|
1176
|
+
"Native `.##` also counts atoms in mixed trees; this module's traversals stay",
|
|
1177
|
+
"within the Figure domain so reconstruction cannot silently discard properties.",
|
|
1178
|
+
"",
|
|
1179
|
+
"Only operations that add a traversal or calculation remain: `inlay`, `withness`, `gap` and `spin`, with `pure` and `need` for domain validation.",
|
|
1180
|
+
"The traversals validate at their public boundary; their recursive steps use",
|
|
1181
|
+
"native operations directly. Withness returns a native boolean, `<>` or `()`.",
|
|
1182
|
+
"```",
|
|
1183
|
+
"```",
|
|
1184
|
+
"Supported domain: `pure x` accepts property-free nested arrays and rejects",
|
|
1185
|
+
"atoms, strings and property-bearing frames.",
|
|
1186
|
+
"```",
|
|
1187
|
+
".pure {.x _;",
|
|
1188
|
+
" .go {.n _;",
|
|
1189
|
+
" (n = []) ? {<>} : {",
|
|
1190
|
+
" .rebuilt (n & {.e _; e});",
|
|
1191
|
+
" (rebuilt = n) ? {(n &| {(go _) ? {[]} : {[0]}}) = []} : {()}}};",
|
|
1192
|
+
" go x};",
|
|
1193
|
+
"```",
|
|
1194
|
+
"`need x` returns a supported frame itself, or a native refusal.",
|
|
1195
|
+
"```",
|
|
1196
|
+
".need {.x _; (pure x) ? {x} : {unsupported-figure}};",
|
|
1197
|
+
"```",
|
|
1198
|
+
"`inlay x y` replaces every terminal of x with y, retaining nonterminal nesting.",
|
|
1199
|
+
"The replacement is reused by identity; ancestors are freshly constructed.",
|
|
1200
|
+
"The host is validated once, and the replacement can be any native value.",
|
|
1201
|
+
"```",
|
|
1202
|
+
".inlay {.x _; .host x;",
|
|
1203
|
+
" (pure host) ? {",
|
|
1204
|
+
" {.y _;",
|
|
1205
|
+
" .go {.n _; (n = []) ? {y} : {n & {go _}}};",
|
|
1206
|
+
" go host}} : {",
|
|
1207
|
+
" {.y _; need host}}};",
|
|
1208
|
+
"```",
|
|
1209
|
+
"`withness x [f, …]` asks whether every requested frame is an immediate element",
|
|
1210
|
+
"of x by native identity. It returns a native boolean. No requested frames is true.",
|
|
1211
|
+
"```",
|
|
1212
|
+
".withness {.x _; .host x;",
|
|
1213
|
+
" {.fs _;",
|
|
1214
|
+
" .absent (fs &| {.f _; ((host &| {(_ === f) ? {[f]}}) = []) ? {[f]}});",
|
|
1215
|
+
" absent = []}};",
|
|
1216
|
+
"```",
|
|
1217
|
+
"`gap x` is the absolute alternating sum of its immediate elements' `.##`",
|
|
1218
|
+
"counts. The empty frame has Gap 0. The validated host needs no per-child guard.",
|
|
1219
|
+
"```",
|
|
1220
|
+
".gap {.x _; (pure x) ? {",
|
|
1221
|
+
" .tail {(_ && {(((_ .0) = .0) ? {[()]} : {[[__ .1]]}) .0}) &| {_}};",
|
|
1222
|
+
" .alt {.cs _; (cs = []) ? {0} : {(cs .0).## - (alt (tail cs))}};",
|
|
1223
|
+
" .signed (alt x);",
|
|
1224
|
+
" (signed .< 0) ? {0 - signed} : {signed}} : {need x}};",
|
|
1225
|
+
"```",
|
|
1226
|
+
"`spin x N` keeps the sign of the alternating sum and divides by a positive",
|
|
1227
|
+
"count N. Non-count N is a type error; zero is division-by-zero. The host is",
|
|
1228
|
+
"validated before the resolution is checked.",
|
|
1229
|
+
"```",
|
|
1230
|
+
".spin {.x _; .host x;",
|
|
1231
|
+
" (pure host) ? {",
|
|
1232
|
+
" {.n <~~1> _;",
|
|
1233
|
+
" .tail {(_ && {(((_ .0) = .0) ? {[()]} : {[[__ .1]]}) .0}) &| {_}};",
|
|
1234
|
+
" .alt {.cs _; (cs = []) ? {0} : {(cs .0).## - (alt (tail cs))}};",
|
|
1235
|
+
" .signed (alt host);",
|
|
1236
|
+
" (n .< 1) ? {signed / 0} : {signed / n}}} : {",
|
|
1237
|
+
" {.n _; need host}}};",
|
|
1238
|
+
"```",
|
|
1239
|
+
"Native construction, counting and comparisons need no module helpers.",
|
|
1240
|
+
"```",
|
|
1241
|
+
"; .a []; .b [[]]; .e [a, b];",
|
|
1242
|
+
"; [e.#, e.##, [].#, [].##]",
|
|
1243
|
+
"# [2, 2, 0, 1]",
|
|
1244
|
+
"; [e = [[], [[]]], e === [a, b], (e .0) === a]",
|
|
1245
|
+
"# [<>, (), <>]",
|
|
1246
|
+
"; [e.## = [[], []].##, [].## = [[]].##]",
|
|
1368
1247
|
"# [<>, <>]",
|
|
1369
1248
|
"```",
|
|
1370
|
-
"
|
|
1249
|
+
"Native terminal counting needs no enumeration or tally construction.",
|
|
1371
1250
|
"```",
|
|
1372
|
-
"; [
|
|
1251
|
+
"; [(pure []), (pure [[], [[]]]), (pure [[], 5]), (pure [.k 1; []])]",
|
|
1373
1252
|
"# [<>, <>, (), ()]",
|
|
1374
|
-
"
|
|
1375
|
-
"Application appends one child and leaves the receiver alone, so a reduce into",
|
|
1376
|
-
"an empty Figure constructs, and a map extends one Figure per element",
|
|
1377
|
-
"```",
|
|
1378
|
-
"; [(E B) = (Figure [A, B, B]), ((E B).children .2) === B, E = (Figure [A, B])]",
|
|
1379
|
-
"# [<>, <>, <>]",
|
|
1380
|
-
"; [([A, B] | (Figure [])) = E, ([A, B] | (Figure [])) === E]",
|
|
1381
|
-
"# [<>, ()]",
|
|
1382
|
-
"; ([A, B] & (Figure [C])) = [Figure [C, A], Figure [C, B]]",
|
|
1383
|
-
"# <>",
|
|
1384
|
-
"```",
|
|
1385
|
-
"Repetition applies a Figure rather than concatenating, because a Figure",
|
|
1386
|
-
"declares its application: `3 U` is `(U U) U`, and each child it appends is `U`",
|
|
1387
|
-
"itself. U is the operand, never the receiver written",
|
|
1388
|
-
"```",
|
|
1389
|
-
"; [(3 U) = ((U U) U), ((3 U).children .0) === Z, ((3 U).children .2) === U, U = (Figure [Z])]",
|
|
1390
|
-
"# [<>, <>, <>, <>]",
|
|
1391
|
-
"```",
|
|
1392
|
-
"So `n U` is not the tally n. Repetition starts from nil, so its first step",
|
|
1393
|
-
"answers U itself, whose child is `Z`, and `3 U` holds `Z` and two units. A tally",
|
|
1394
|
-
"starts from zero instead: join n units onto `Z`, or construct them. Repetition",
|
|
1395
|
-
"keeps nil as its start, because a declared zero would be a new protocol point",
|
|
1396
|
-
"with this one use (#415)",
|
|
1397
|
-
"```",
|
|
1398
|
-
"; [((3 U).size()).children.#, (((3 [U]) | Z).size()).children.#, ((3 [U]) | Z) = (Figure (3 [U]))]",
|
|
1399
|
-
"# [2, 3, <>]",
|
|
1400
|
-
"```",
|
|
1401
|
-
"A join copies its receiver once and appends in place after that, so it is",
|
|
1402
|
-
"quick, and the receiver and every child keep their identity. Each step still",
|
|
1403
|
-
"copies the children it has so far, because a collect through a name always lands",
|
|
1404
|
-
"on a fresh array (#386). That keeps a join quadratic in pointer copies, about",
|
|
1405
|
-
"0.2 s for 4,096 units, and the observers never join: they construct from a",
|
|
1406
|
-
"stream in one step (#415)",
|
|
1407
|
-
"```",
|
|
1408
|
-
"; .joined ((512 [U]) | Z);",
|
|
1409
|
-
"; [joined.children.#, Z = (Figure []), (joined.children .511) === U]",
|
|
1410
|
-
"# [512, <>, <>]",
|
|
1411
|
-
"; [(E.children & {_ A}) = [Figure [A], Figure [Z, A]], A = (Figure []), B = (Figure [A])]",
|
|
1412
|
-
"# [<>, <>, <>]",
|
|
1413
|
-
"```",
|
|
1414
|
-
"## Manyness and Size",
|
|
1415
|
-
"",
|
|
1416
|
-
"Manyness marks the immediate children and looks no deeper",
|
|
1417
|
-
"```",
|
|
1418
|
-
"; [(A.many()) = A, (E.many()) = (Figure [B, B]), (G.many()) = (E.many()), (E.many()) = (B.many())]",
|
|
1419
|
-
"# [<>, <>, <>, ()]",
|
|
1420
|
-
"```",
|
|
1421
|
-
"Size is recursive cell volume. `Z` is `A` and `U` is `B`, the same mark",
|
|
1422
|
-
"Manyness uses, so a count is itself a Figure of units. Size marks each of the",
|
|
1423
|
-
"cells Cells finds, as Manyness marks each child. Cells tests form, so any Figure",
|
|
1424
|
-
"shaped like `U` is a cell",
|
|
1425
|
-
"```",
|
|
1426
|
-
"; [Z === A, U === B]",
|
|
1253
|
+
"; [(need e) = e, (need e) === e]",
|
|
1427
1254
|
"# [<>, <>]",
|
|
1428
|
-
"; [
|
|
1429
|
-
"#
|
|
1430
|
-
";
|
|
1431
|
-
"
|
|
1432
|
-
"; [
|
|
1433
|
-
"#
|
|
1434
|
-
"; [(row4.many()) = (row4.size()), (deep4.many()) = (deep4.size()), (two_fours.many()) = row2]",
|
|
1435
|
-
"# [<>, (), <>]",
|
|
1255
|
+
"; inlay [.k 1; []] [[]]",
|
|
1256
|
+
"# $!.name-missing “$:Frame.0.unsupported-figure”;",
|
|
1257
|
+
"; inlay 5 [[]]",
|
|
1258
|
+
"# $!.name-missing “$:Frame.0.unsupported-figure”;",
|
|
1259
|
+
"; gap [.k 1; [[], []]]",
|
|
1260
|
+
"# $!.name-missing “$:Frame.0.unsupported-figure”;",
|
|
1436
1261
|
"```",
|
|
1437
|
-
"
|
|
1438
|
-
"
|
|
1439
|
-
"never shaped like `U`. One child can be: `Figure [Z]` has the form of `U`, so",
|
|
1440
|
-
"its Size is one cell, the rule that makes Multiplication guard `Z`, for",
|
|
1441
|
-
"itself and for Tally multiplication",
|
|
1442
|
-
"```",
|
|
1443
|
-
"; [((Figure [row2, row3]).size()) = (row3.children | row2), ((Figure [Z, Z]).size()) = Z, ((Figure [Z]).size()) = (Figure [U])]",
|
|
1444
|
-
"# [<>, <>, <>]",
|
|
1262
|
+
"Inlay preserves nesting and empty replacements; native repetition constructs a",
|
|
1263
|
+
"flat product. Both have the same terminal count on Figures.",
|
|
1445
1264
|
"```",
|
|
1446
|
-
"
|
|
1447
|
-
"in form but not `Z` itself: having no cells and being zero are different facts,",
|
|
1448
|
-
"and Size promises the first. Every unit of a Size is `U` itself",
|
|
1449
|
-
"```",
|
|
1450
|
-
"; [(Z.size()) = Z, (Z.size()) === Z, ((Figure [Z, Z]).size()) = Z, ((U.size()).children .0) === U]",
|
|
1451
|
-
"# [<>, (), <>, <>]",
|
|
1452
|
-
"```",
|
|
1453
|
-
"A tally is its own Size, so Size is idempotent",
|
|
1454
|
-
"```",
|
|
1455
|
-
"; ((two_fours.size()).size()) = (two_fours.size())",
|
|
1456
|
-
"# <>",
|
|
1457
|
-
"```",
|
|
1458
|
-
"Construction from a stream is linear, so a large Size is quick: 256 cells,",
|
|
1459
|
-
"built by Multiplication",
|
|
1460
|
-
"```",
|
|
1461
|
-
"; .row16 (row4.mul row4); .row256 (row16.mul row16);",
|
|
1462
|
-
"; [(row256.size()).children.#, ((row256.size()).children .255) === U]",
|
|
1463
|
-
"# [256, <>]",
|
|
1464
|
-
"```",
|
|
1465
|
-
"A tally reads as a natural number, because its children are an aggregate and",
|
|
1466
|
-
"`.#` counts them. A Figure's own `.#` and `.##` are `0`: its children are a",
|
|
1467
|
-
"property, not its elements, and `.##` counts only what is not an aggregate",
|
|
1468
|
-
"```",
|
|
1469
|
-
"; [E.children.#, (E.many()).children.#, (two_fours.size()).children.#, E.#, E.##, E.children.##] = [2, 2, 8, 0, 0, 0]",
|
|
1470
|
-
"# <>",
|
|
1471
|
-
"```",
|
|
1472
|
-
"A tally built by repetition is its own cells and its own Size, and every cell",
|
|
1473
|
-
"is `U` itself. Multiplication of it constructs y once per cell, each one y",
|
|
1474
|
-
"itself. A Figure whose children are not all cells is still walked",
|
|
1475
|
-
"```",
|
|
1476
|
-
"; .rep (Figure (6 [U]));",
|
|
1477
|
-
"; [(rep.cells()) = rep.children, ((rep.cells()) .5) === U, (rep.size()) = rep, (rep.mul row2) = (Figure (6 [row2])), ((rep.mul row2).children .5) === row2]",
|
|
1478
|
-
"# [<>, <>, <>, <>, <>]",
|
|
1479
|
-
"; [((Figure [row2, U]).cells()) = [U, U, U], (((Figure [row2, U]).cells()) .2) === U]",
|
|
1265
|
+
"; [(inlay [] [[], []]) = [[], []], (inlay [[]] [[], []]) = [[[], []]]]",
|
|
1480
1266
|
"# [<>, <>]",
|
|
1481
|
-
"
|
|
1482
|
-
"Zero is a quotient of zeros. A Figure made of nothing, or of several nothings,",
|
|
1483
|
-
"has no cells and a Size of `Z`'s form, but it is not `Z`, and it keeps its own",
|
|
1484
|
-
"form",
|
|
1485
|
-
"```",
|
|
1486
|
-
"; [((Figure [Z, Z]).cells()) = [], ((Figure [Z, Z]).size()) = Z, (Figure (0 [U])) = Z, (Figure (0 [U])) === Z, (Figure [Z, Z]) = Z]",
|
|
1487
|
-
"# [<>, <>, <>, (), ()]",
|
|
1488
|
-
"```",
|
|
1489
|
-
"Cells answers the cells themselves, in order, wherever they were nested, and",
|
|
1490
|
-
"`.#` reads how many there are, as it reads a tally",
|
|
1491
|
-
"```",
|
|
1492
|
-
"; [(E.cells()) = [B], ((E.cells()) .0) === B, (deep4.cells()) = row4.children, (Z.cells()) = [], ((U.cells()) .0) === U]",
|
|
1493
|
-
"# [<>, <>, <>, <>, <>]",
|
|
1494
|
-
"; [(two_fours.cells()).#, (deep4.cells()).#, (two_fours.size()).children.#] = [8, 4, 8]",
|
|
1495
|
-
"# <>",
|
|
1496
|
-
"```",
|
|
1497
|
-
"## The semiring",
|
|
1498
|
-
"",
|
|
1499
|
-
"The carrier is not raw Figures. Let `F` be the finite, well-founded Figures,",
|
|
1500
|
-
"with the form of `U` as the unit cell, and write `x ≈ y` when",
|
|
1501
|
-
"`(x.size()) = (y.size())`. The carrier is the quotient `F/≈`, with zero `Z` and",
|
|
1502
|
-
"one `U`. Addition is construction, `Figure [x, y]`. Multiplication maps every",
|
|
1503
|
-
"cell of `x.size()` to `y`, so a product reuses `y` once per cell of `x`. A",
|
|
1504
|
-
"product by `Z` is `Z`, because one row of nothing, `Figure [Z]`, has the form of",
|
|
1505
|
-
"`U` and would count as a cell",
|
|
1506
|
-
"```",
|
|
1507
|
-
"; [(U.mul Z) = Z, ((Figure [Z]).size()) = (Figure [U])]",
|
|
1267
|
+
"; [(inlay [[], []] []) = [[], []], (inlay [[]] []) = [[]]]",
|
|
1508
1268
|
"# [<>, <>]",
|
|
1509
|
-
"
|
|
1510
|
-
"That exception is the price of a unit defined by form, and the module pays it",
|
|
1511
|
-
"on purpose (#415). Construction of two or more Figures adds, and construction",
|
|
1512
|
-
"of one wraps: wrapping keeps the Size of anything that is not shaped like zero,",
|
|
1513
|
-
"and wrapping zero makes a cell. Counting cells by identity instead, as `_^ === U`,",
|
|
1514
|
-
"would remove both guards, but a separately built `Figure [Figure []]`, equal to",
|
|
1515
|
-
"`U` in every child, would then have no cells, so Size would no longer be a",
|
|
1516
|
-
"function of form. Tried against the 55 claims this file held at v0.24.0,",
|
|
1517
|
-
"identity cells failed only the three that say a form-equal unit is a cell",
|
|
1518
|
-
"```",
|
|
1519
|
-
"; [(Figure [row2]).size_equivalent row2, (Figure [Z]).size_equivalent U, (Figure [Z]).size_equivalent Z] = [U, U, Z]",
|
|
1269
|
+
"; (inlay [[], [], [[], []]] “x”) = [“x”, “x”, [“x”, “x”]]",
|
|
1520
1270
|
"# <>",
|
|
1521
|
-
"; .
|
|
1522
|
-
"; [
|
|
1523
|
-
"# [<>, ()
|
|
1524
|
-
"
|
|
1525
|
-
"
|
|
1526
|
-
"
|
|
1527
|
-
"```",
|
|
1528
|
-
"; .rectangle23 (row2.mul row3);",
|
|
1529
|
-
"; [rectangle23 = (Figure [row3, row3]), (rectangle23.children .0) === row3, (rectangle23.children .1) === row3]",
|
|
1530
|
-
"# [<>, <>, <>]",
|
|
1531
|
-
"; [(rectangle23.many()) = row2, (rectangle23.size()) = (Figure [U, U, U, U, U, U])]",
|
|
1532
|
-
"# [<>, <>]",
|
|
1533
|
-
"```",
|
|
1534
|
-
"Size takes construction to joining and multiplication to `size_mul`, so both",
|
|
1535
|
-
"recipes respect `≈`; the checks also use differently nested, equal-Size inputs.",
|
|
1536
|
-
"Size, `size_mul` and `size_equivalent` all construct, and none counts, so every",
|
|
1537
|
-
"check here and below compares two constructions (#415)",
|
|
1538
|
-
"```",
|
|
1539
|
-
"; [((Figure [row2, row3]).size()) = (Figure [U, U, U, U, U]), (rectangle23.size()) = ((row2.size()).size_mul (row3.size()))]",
|
|
1540
|
-
"# [<>, <>]",
|
|
1541
|
-
"```",
|
|
1542
|
-
"Size is Multiplication by the unit, and Tally multiplication is Multiplication",
|
|
1543
|
-
"of a Manyness, whatever the nesting",
|
|
1544
|
-
"```",
|
|
1545
|
-
"; [(row2.size()) = (row2.mul U), (deep4.size()) = (deep4.mul U), (Z.size()) = (Z.mul U)]",
|
|
1546
|
-
"# [<>, <>, <>]",
|
|
1547
|
-
"; [(row2.size_mul row3) = (((row2.many()).mul row3).size()), (deep4.size_mul row3) = (((deep4.many()).mul row3).size())]",
|
|
1271
|
+
"; .y [[], [], []]; .host [[], [[], []]]; .r (inlay host y);",
|
|
1272
|
+
"; [((r .0) === y), (((r .1) .0) === y), (((r .1) .1) === y), r === host]",
|
|
1273
|
+
"# [<>, <>, <>, ()]",
|
|
1274
|
+
"; [(inlay [[], []] y).##, ([[], []].## [y]).##]",
|
|
1275
|
+
"# [6, 6]",
|
|
1276
|
+
"; [([[[], []]].## [[[]]]) = [[[]], [[]]], (inlay [[[], []]] [[]]) = [[[[]], [[]]]]]",
|
|
1548
1277
|
"# [<>, <>]",
|
|
1549
1278
|
"```",
|
|
1550
|
-
"
|
|
1551
|
-
"```",
|
|
1552
|
-
"; [(U.size_mul Z) = Z, ((Figure [U]).size_mul Z) = Z, ((U.mul Z).size()) = ((U.size()).size_mul (Z.size()))]",
|
|
1553
|
-
"# [<>, <>, <>]",
|
|
1554
|
-
"; .deep2 (Figure [Figure [row2]]); .deep3 (Figure [Figure [Figure [row3]]]);",
|
|
1555
|
-
"; [row2.size_equivalent deep2, row3.size_equivalent deep3, (Figure [row2, row3]).size_equivalent (Figure [deep2, deep3]), (row2.mul row3).size_equivalent (deep2.mul deep3)] = [U, U, U, U]",
|
|
1556
|
-
"# <>",
|
|
1557
|
-
"```",
|
|
1558
|
-
"Tallies are the natural numbers in unary, so induction gives every semiring law",
|
|
1559
|
-
"on tallies, and transport along Size gives them on `F/≈`. The raw product is not",
|
|
1560
|
-
"commutative: `row2` by `row3` is two rows of three, `row3` by `row2` three rows",
|
|
1561
|
-
"of two, and they agree only in Size. These instances witness each law without",
|
|
1562
|
-
"replacing the proof",
|
|
1279
|
+
"Withness uses identity, and its answer is the native boolean.",
|
|
1563
1280
|
"```",
|
|
1564
|
-
";
|
|
1281
|
+
"; .shared [[]]; .p1 [shared, []]; .p2 [[], shared];",
|
|
1282
|
+
"; [(withness p1 [shared]), (withness p2 [shared]), (withness p1 [[[]]])]",
|
|
1283
|
+
"# [<>, <>, ()]",
|
|
1284
|
+
"; [(withness [] [[[]]]), (withness [shared] [])]",
|
|
1565
1285
|
"# [(), <>]",
|
|
1566
|
-
"; [(Figure [Z, row2]).size_equivalent row2, (Figure [row2, Z]).size_equivalent row2, (U.mul row2).size_equivalent row2, (row2.mul U).size_equivalent row2] = [U, U, U, U]",
|
|
1567
|
-
"# <>",
|
|
1568
1286
|
"```",
|
|
1569
|
-
"
|
|
1570
|
-
"
|
|
1571
|
-
"Each side reads a tally that was constructed, so the reading checks the",
|
|
1572
|
-
"construction rather than replacing it",
|
|
1287
|
+
"Gap and Spin read native terminal counts, including shared branches at every",
|
|
1288
|
+
"occurrence. Reversing two unequal branches reverses Spin's sign.",
|
|
1573
1289
|
"```",
|
|
1574
|
-
"; [(
|
|
1290
|
+
"; [(gap []) = 0, (gap [[[], []]]) = 2, (gap [[[], []], [[], [], []]]) = 1]",
|
|
1575
1291
|
"# [<>, <>, <>]",
|
|
1576
|
-
";
|
|
1577
|
-
"# <>",
|
|
1578
|
-
"; (((row2.mul row3).mul row4).size_equivalent (row2.mul (row3.mul row4))) = U",
|
|
1579
|
-
"# <>",
|
|
1580
|
-
"; [(row2.mul (Figure [row3, row4])).size_equivalent (Figure [row2.mul row3, row2.mul row4]), ((Figure [row2, row3]).mul row4).size_equivalent (Figure [row2.mul row4, row3.mul row4])] = [U, U]",
|
|
1581
|
-
"# <>",
|
|
1582
|
-
"; [(Z.mul row3).size_equivalent Z, (row3.mul Z).size_equivalent Z] = [U, U]",
|
|
1292
|
+
"; (gap [[[], []], [[], [], [], [], []], [[], [], []]]) = 0",
|
|
1583
1293
|
"# <>",
|
|
1584
|
-
"
|
|
1585
|
-
"## Sameness and Withness",
|
|
1586
|
-
"",
|
|
1587
|
-
"Sameness of form is `=` and sameness of the constructed Figure is `===`",
|
|
1588
|
-
"```",
|
|
1589
|
-
"; .B2 (Figure [A]);",
|
|
1590
|
-
"; [B.sameform B2, B.sameness B, B.sameness B2, (E.children .0).sameness A] = [B, B, A, B]",
|
|
1591
|
-
"# <>",
|
|
1592
|
-
"```",
|
|
1593
|
-
"Withness asks whether every requested Figure is an immediate child of the",
|
|
1594
|
-
"receiver, by identity rather than form: `B` is reused under both `E` and `F`,",
|
|
1595
|
-
"while the separately constructed `B2` is a child of neither. An empty parent",
|
|
1596
|
-
"holds nothing, and every one of no Figures is a child of any parent",
|
|
1597
|
-
"```",
|
|
1598
|
-
"; [E.withness [A, B], F.withness [A, B], G.withness [E, F], E.withness [B2]] = [B, A, B, A]",
|
|
1599
|
-
"# <>",
|
|
1600
|
-
"; [A.withness [B], B.withness []] = [A, B]",
|
|
1601
|
-
"# <>",
|
|
1602
|
-
"```",
|
|
1603
|
-
"## Gap",
|
|
1604
|
-
"",
|
|
1605
|
-
"Gap reads the Sizes of a Figure's immediate children, folds them with",
|
|
1606
|
-
"alternating signs, `Size(F₁) − Size(F₂) + Size(F₃) − …`, starting positive, and",
|
|
1607
|
-
"drops the sign. It observes rather than constructs, so it answers a FrameCount,",
|
|
1608
|
-
"never negative, and the empty Figure has Gap `0`. One child is its",
|
|
1609
|
-
"own Size, so `A` and `U` both have Gap `0` because `U`'s one child `Z` has Size",
|
|
1610
|
-
"`0`, while a Figure holding `row2` has Gap `2`. Two children are the difference",
|
|
1611
|
-
"of their Sizes, whichever comes first",
|
|
1612
|
-
"```",
|
|
1613
|
-
"; [(A.gap()) = 0, (U.gap()) = 0, ((Figure [row2]).gap()) = 2, ((Figure [row2, row3]).gap()) = 1, ((Figure [row3, row2]).gap()) = 1]",
|
|
1614
|
-
"# [<>, <>, <>, <>, <>]",
|
|
1615
|
-
"```",
|
|
1616
|
-
"Each child contributes its existing Size, so nesting reaches a child only",
|
|
1617
|
-
"through that Size: a one-child Figure's Gap is that child's Size whatever its",
|
|
1618
|
-
"nesting, and `deep4` nests `row4` to Size 4. The minimal witness is three",
|
|
1619
|
-
"children of Sizes 2, 5 and 3, whose Gap is `0`; the Sizes come from ordinary",
|
|
1620
|
-
"Figures and `row5` is one of Size 5",
|
|
1621
|
-
"```",
|
|
1622
|
-
"; .row5 (Figure [U, U, U, U, U]);",
|
|
1623
|
-
"; [(row5.size()).children.# = 5, ((Figure [row2, row5, row3]).gap()) = 0, ((Figure [row4]).gap()) = 4]",
|
|
1624
|
-
"# [<>, <>, <>]",
|
|
1625
|
-
"; [((Figure [row2, row5, row3]).gap()) = (((row2.size()).children.#) - ((row5.size()).children.#) + ((row3.size()).children.#))]",
|
|
1626
|
-
"# [<>]",
|
|
1627
|
-
"```",
|
|
1628
|
-
"Order still matters: reordering the same three children can change Gap,",
|
|
1629
|
-
"and it is an observation only, never a claim that a Walk is closed",
|
|
1630
|
-
"```",
|
|
1631
|
-
"; [((Figure [row2, row3, row5]).gap()) = 4, ((Figure [row5, row2, row3]).gap()) = 6, ((Figure [row3, row2, row5]).gap()) = 6]",
|
|
1632
|
-
"# [<>, <>, <>]",
|
|
1633
|
-
"```",
|
|
1634
|
-
"A child's own Size decides its contribution, so a child built differently but of",
|
|
1635
|
-
"equal Size contributes the same, and construction, observation and",
|
|
1636
|
-
"interpretation stay apart: Gap reports a number, not a meaning",
|
|
1637
|
-
"```",
|
|
1638
|
-
"; [((Figure [deep4, row2, row3]).gap()) = ((Figure [row4, row2, row3]).gap()), ((Figure [Z, U]).gap()) = 1]",
|
|
1294
|
+
"; [(spin [[[], []], [[], [], [], [], []]] 4) = (0 - (3 / 4)), (spin [[[], [], [], []], [[], []]] 4) = (2 / 4)]",
|
|
1639
1295
|
"# [<>, <>]",
|
|
1640
|
-
"
|
|
1641
|
-
"## Spin",
|
|
1642
|
-
"",
|
|
1643
|
-
"Spin folds the same Sizes Gap does, in the same order with the same signs that",
|
|
1644
|
-
"start positive, but keeps the sign and divides by a positive resolution N,",
|
|
1645
|
-
"answering an exact FrameRational in revolutions. The division selects its rung",
|
|
1646
|
-
"from the divisor, so `signed / N` is a ratio that collapses to a whole FrameInt",
|
|
1647
|
-
"when N divides it, and a positive reading prints without a `+`. The same three",
|
|
1648
|
-
"children of Sizes 2, 5 and 3 whose Gap is `0` have Spin `0` at every N, and",
|
|
1649
|
-
"reversing the two children of a two-child Figure flips the sign: `(2,5)` reads",
|
|
1650
|
-
"`−3/4` and `(5,2)` reads `+3/4` at N=4. The Sizes come from ordinary Figures,",
|
|
1651
|
-
"`row5` of Size 5 above among them, and `Figure [U, Z, U]` has children of Sizes",
|
|
1652
|
-
"1, 0 and 1",
|
|
1653
|
-
"```",
|
|
1654
|
-
"; [((Figure [row2, row5, row3]).spin 4) = 0, ((Figure [row2, row5]).spin 4) = (0 - (3 / 4)), ((Figure [row5, row2]).spin 4) = (3 / 4), ((Figure [U, Z, U]).spin 4) = (1 / 2)]",
|
|
1655
|
-
"# [<>, <>, <>, <>]",
|
|
1656
|
-
"```",
|
|
1657
|
-
"Spin reads each child's Size the way Gap does, so it equals the signed fold",
|
|
1658
|
-
"divided by N, and Gap is its absolute value: the two observers never disagree on",
|
|
1659
|
-
"the same fold",
|
|
1660
|
-
"```",
|
|
1661
|
-
"; [((Figure [row2, row5]).spin 4) = ((((row2.size()).children.#) - ((row5.size()).children.#)) / 4), ((Figure [row5, row2]).spin 4) = (((Figure [row5, row2]).gap()) / 4), ((Figure [row2, row5]).spin 4) = (0 - (((Figure [row2, row5]).gap()) / 4))]",
|
|
1662
|
-
"# [<>, <>, <>]",
|
|
1663
|
-
"```",
|
|
1664
|
-
"The resolution N scales the same signed sum, and `N=1` reads whole signed",
|
|
1665
|
-
"revolutions, so `(2,5)` is `−3` at N=1, `−1` at N=3, and `(5,2)` is `+3/2` at",
|
|
1666
|
-
"N=2. Every reading is exact, keeping both direction and resolution",
|
|
1667
|
-
"```",
|
|
1668
|
-
"; [((Figure [row2, row5]).spin 1) = (0 - 3), ((Figure [row2, row5]).spin 3) = (0 - 1), ((Figure [row5, row2]).spin 2) = (3 / 2)]",
|
|
1669
|
-
"# [<>, <>, <>]",
|
|
1670
|
-
"```",
|
|
1671
|
-
"Spin keeps the sign Gap drops, so a one-child Figure reads its child's Size as a",
|
|
1672
|
-
"positive reading, the empty Figure reads `0` at every N, and nesting reaches a",
|
|
1673
|
-
"child only through its Size: `deep4` contributes 4 just as `row4` does",
|
|
1674
|
-
"```",
|
|
1675
|
-
"; [((Figure [row2]).spin 1) = 2, ((Figure [row2]).spin 4) = (1 / 2), (A.spin 4) = 0, (A.spin 1) = 0]",
|
|
1676
|
-
"# [<>, <>, <>, <>]",
|
|
1677
|
-
"; [((Figure [deep4, row2, row3]).spin 4) = ((Figure [row4, row2, row3]).spin 4), ((Figure [Z, U]).spin 4) = (0 - (1 / 4))]",
|
|
1296
|
+
"; [(spin [[[], []]] 1) = 2, (spin [] 4) = 0]",
|
|
1678
1297
|
"# [<>, <>]",
|
|
1679
|
-
"
|
|
1680
|
-
"N must be a count. The argument is bound as `.n <~~1>`, the count type read off",
|
|
1681
|
-
"a literal, so a non-count N is refused with a native `$!.type-error` before any",
|
|
1682
|
-
"fold or division: a fraction `1/2`, a float `2.5`, a negative `-1` and a string",
|
|
1683
|
-
"`“3”` are all not counts and all refused. A nonzero whole N divides the signed",
|
|
1684
|
-
"sum exactly, so `(5,2)` at N=3 is `1`",
|
|
1685
|
-
"```",
|
|
1686
|
-
"; (Figure [row2, row5]).spin 2.5",
|
|
1298
|
+
"; spin [[[], []]] 2.5",
|
|
1687
1299
|
"# $!.type-error .n <~~1> 2.5",
|
|
1688
|
-
";
|
|
1689
|
-
"# $!.type-error .n <~~1> 1/2",
|
|
1690
|
-
"; (Figure [row2, row5]).spin (0 - 1)",
|
|
1691
|
-
"# $!.type-error .n <~~1> -1",
|
|
1692
|
-
"; (Figure [row2, row5]).spin “3”",
|
|
1693
|
-
"# $!.type-error .n <~~1> “3”",
|
|
1694
|
-
"; (Figure [row5, row2]).spin 3",
|
|
1695
|
-
"# 1",
|
|
1696
|
-
"```",
|
|
1697
|
-
"A positive resolution is still required of a count N: `N=0` passes the count",
|
|
1698
|
-
"type and is then the native division-by-zero, and the empty argument `()` is not",
|
|
1699
|
-
"a count either but binds nothing, so it falls through to the same",
|
|
1700
|
-
"division-by-zero rather than a type error",
|
|
1701
|
-
"```",
|
|
1702
|
-
"; (Figure [row2, row5]).spin 0",
|
|
1300
|
+
"; spin [[[], []]] 0",
|
|
1703
1301
|
"# $!.division-by-zero /",
|
|
1704
|
-
"; (Figure [row2, row5]).spin ()",
|
|
1705
|
-
"# $!.division-by-zero /",
|
|
1706
|
-
"```",
|
|
1707
|
-
"## The Fano plane",
|
|
1708
|
-
"",
|
|
1709
|
-
"Seven originals of identical form, each a fresh `Figure []`, and seven triples",
|
|
1710
|
-
"of identical form `[[], [], []]`. The incidence lives only in which originals",
|
|
1711
|
-
"each triple reuses, so only Withness, by identity, can see it. `b_copy` equals",
|
|
1712
|
-
"every original in form and is a child of no triple",
|
|
1713
1302
|
"```",
|
|
1714
|
-
"
|
|
1715
|
-
"; .originals (Figure [a, b, c, d, e, f, g]);",
|
|
1716
|
-
"; .abd (Figure [a, b, d]); .bce (Figure [b, c, e]); .cdf (Figure [c, d, f]);",
|
|
1717
|
-
"; .deg (Figure [d, e, g]); .efa (Figure [e, f, a]); .fgb (Figure [f, g, b]); .gac (Figure [g, a, c]);",
|
|
1718
|
-
"; .fano (Figure [abd, bce, cdf, deg, efa, fgb, gac]);",
|
|
1719
|
-
"; .Three (Figure [U, U, U]); .b_copy (Figure []);",
|
|
1720
|
-
"; [(originals.many()) = (fano.many()), (fano.children & {_.many()}) = (fano.children & {Three})]",
|
|
1721
|
-
"# [<>, <>]",
|
|
1722
|
-
"; [abd = bce, abd === bce, b = b_copy, b === b_copy]",
|
|
1723
|
-
"# [<>, (), <>, ()]",
|
|
1724
|
-
"; [abd.withness [a, b, d], abd.withness [a, c], abd.withness [b_copy]] = [B, A, A]",
|
|
1725
|
-
"# <>",
|
|
1726
|
-
"```",
|
|
1727
|
-
"`on` answers one Withness mark per triple, so its Size counts the triples that",
|
|
1728
|
-
"hold every requested original. Over every ordered pair, generated rather than",
|
|
1729
|
-
"listed, two distinct originals lie in exactly one triple and each lies in three",
|
|
1730
|
-
"```",
|
|
1731
|
-
"; .on {.points _; Figure (fano.children & {_.withness points})};",
|
|
1732
|
-
"; .point_table (originals.children & {.p _; originals.children & {(on [p, _]).size()}});",
|
|
1733
|
-
"; point_table = (originals.children & {.p _; originals.children & {(p === _) ? {Three} : {Figure [U]}}})",
|
|
1734
|
-
"# <>",
|
|
1303
|
+
"Importing skips the examples and ends on a native true value.",
|
|
1735
1304
|
"```",
|
|
1736
|
-
"
|
|
1737
|
-
"everywhere else",
|
|
1738
|
-
"```",
|
|
1739
|
-
"; (point_table & {_ & {_.children.#}}) = (originals.children & {.p _; originals.children & {(p === _) ? {3} : {1}}})",
|
|
1740
|
-
"# <>",
|
|
1741
|
-
"```",
|
|
1742
|
-
"Dually, `meet` counts the originals two triples share: multiplying their two",
|
|
1743
|
-
"Withness marks leaves one cell exactly when both hold it. The two tables are",
|
|
1744
|
-
"equal, which is the plane's self-duality",
|
|
1745
|
-
"```",
|
|
1746
|
-
"; .meet {.lines _; (Figure (originals.children & {.o _; ((lines .0).withness [o]).mul ((lines .1).withness [o])})).size()};",
|
|
1747
|
-
"; .line_table (fano.children & {.l _; fano.children & {meet [l, _]}});",
|
|
1748
|
-
"; [line_table = (fano.children & {.l _; fano.children & {(l === _) ? {Three} : {Figure [U]}}}), point_table = line_table]",
|
|
1749
|
-
"# [<>, <>]",
|
|
1750
|
-
"```",
|
|
1751
|
-
"`a, b, c, f` are four originals with no three in a triple",
|
|
1752
|
-
"```",
|
|
1753
|
-
"; ([[a, b, c], [a, b, f], [a, c, f], [b, c, f]] & {(on _).size()}) = [Z, Z, Z, Z]",
|
|
1754
|
-
"# <>",
|
|
1755
|
-
"```",
|
|
1756
|
-
"## Closure",
|
|
1757
|
-
"",
|
|
1758
|
-
"Every answer is a Figure, so it can be observed again or become a child, and",
|
|
1759
|
-
"observing does not mutate, even with a local name inside a map",
|
|
1760
|
-
"```",
|
|
1761
|
-
"; [((E.many()).many()) = (E.many()), ((Figure [E.many(), F.size()]).size()) = row4]",
|
|
1762
|
-
"# [<>, <>]",
|
|
1763
|
-
"; .E5 (Figure [A, Figure [A]]);",
|
|
1764
|
-
"; E5.children & {.o _; o};",
|
|
1765
|
-
"; [E5 = (Figure [A, B]), A = (Figure [])]",
|
|
1766
|
-
"# [<>, <>]",
|
|
1767
|
-
"```",
|
|
1768
|
-
"## Reading the methods",
|
|
1769
|
-
"",
|
|
1770
|
-
"A method read through a Figure walks as the atoms of its body, unevaluated",
|
|
1771
|
-
"(#429), so the module can read what an observer is built from. Size is",
|
|
1772
|
-
"Multiplication by the unit, and its body says so",
|
|
1773
|
-
"```",
|
|
1774
|
-
"; (E.size) & {“” _}",
|
|
1775
|
-
"# [“_^”, “.mul”, “U”]",
|
|
1776
|
-
"```",
|
|
1777
|
-
"## Names",
|
|
1778
|
-
"",
|
|
1779
|
-
"A bare name inside a block that a map applies to Figures reads each Figure's",
|
|
1780
|
-
"own members first (spec 7), so it cannot reach the method's. That is why a",
|
|
1781
|
-
"method names its own Figure `_^` and binds `kids` or `n` before its blocks read",
|
|
1782
|
-
"it",
|
|
1783
|
-
"```",
|
|
1784
|
-
"; (E.children & {children}) = [A.children, B.children]",
|
|
1785
|
-
"# <>",
|
|
1786
|
-
"```",
|
|
1787
|
-
"A method's own locals come ahead of any binding where it is called, and a",
|
|
1788
|
-
"Figure passed as an argument contributes only its members, never the names of",
|
|
1789
|
-
"the scope that built it. The Fano plane above already binds `f`, the name",
|
|
1790
|
-
"Withness uses inside its blocks; these bind the other locals",
|
|
1791
|
-
"```",
|
|
1792
|
-
"; .kids 9; .y 9; .n 9; .cells 9; .found 9; .absent 9;",
|
|
1793
|
-
"; [(E.withness [A, B]) = B, (row2.mul row3) = rectangle23, (E.size()) = (Figure [U]), (row2.size_mul row3) = (rectangle23.size())]",
|
|
1794
|
-
"# [<>, <>, <>, <>]",
|
|
1795
|
-
"```",
|
|
1796
|
-
"A method's free names resolve where the method was written, never where its",
|
|
1797
|
-
"receiver was read (#400). So a scope that binds its own `B` and reads a Figure",
|
|
1798
|
-
"by name there still gets the class's `B` back from Manyness",
|
|
1799
|
-
"```",
|
|
1800
|
-
"; .theB B;",
|
|
1801
|
-
"; .rebinds {.B 5; .mine (Figure [A]); ((mine.many()).children .0) === theB};",
|
|
1802
|
-
"; rebinds()",
|
|
1803
|
-
"# <>",
|
|
1804
|
-
"```",
|
|
1805
|
-
"## Functional updates",
|
|
1806
|
-
"",
|
|
1807
|
-
"A mutating method reached through an immutable handle is a functional update,",
|
|
1808
|
-
"and it copies only what it writes (#401). A Figure the receiver holds is never",
|
|
1809
|
-
"written, so the result holds the very same Figure, and identity observers",
|
|
1810
|
-
"answer about it",
|
|
1811
|
-
"```",
|
|
1812
|
-
"; .keeper [.fig E; .touch_ {@fig fig;}];",
|
|
1813
|
-
"; .kept ((keeper.touch_ ()).fig);",
|
|
1814
|
-
"; [kept === E, (kept.children .0) === A]",
|
|
1815
|
-
"# [<>, <>]",
|
|
1816
|
-
"; [kept.sameness kept, kept.withness [kept.children .0]] = [B, B]",
|
|
1817
|
-
"# <>",
|
|
1818
|
-
"```",
|
|
1819
|
-
"A write that constructs answers a new Figure, which is a Figure like any other",
|
|
1820
|
-
"```",
|
|
1821
|
-
"; .grower [.fig E; .grow_ {@fig (fig B);}];",
|
|
1822
|
-
"; .grown ((grower.grow_ ()).fig);",
|
|
1823
|
-
"; [(grown.sameness grown) = B, (grown.withness [grown.children .2]) = B, grown === E]",
|
|
1824
|
-
"# [<>, <>, ()]",
|
|
1825
|
-
"```",
|
|
1826
|
-
"## Spelling",
|
|
1827
|
-
"",
|
|
1828
|
-
"`(x)` is `x`, so `Figure (B)` collects B's elements, of which an object with",
|
|
1829
|
-
"only properties has none. Write `Figure [B]`",
|
|
1830
|
-
"```",
|
|
1831
|
-
"; [(Figure (B)) = A, (Figure [B]) = C]",
|
|
1832
|
-
"# [<>, <>]",
|
|
1833
|
-
"; (Figure [A, B]) = E",
|
|
1834
|
-
"# <>",
|
|
1835
|
-
"```",
|
|
1836
|
-
"Importing this file skips its examples and answers its last form, which the",
|
|
1837
|
-
"hosts' smoke tests read, so the file ends on code that holds however the rest of",
|
|
1838
|
-
"it changes",
|
|
1839
|
-
"```",
|
|
1840
|
-
"B = (Figure [A])",
|
|
1305
|
+
"[] = []",
|
|
1841
1306
|
"",
|
|
1842
1307
|
].join("\n"),
|
|
1843
1308
|
],
|
|
@@ -1998,88 +1463,6 @@ export const HC_SOURCES = new Map([
|
|
|
1998
1463
|
"",
|
|
1999
1464
|
].join("\n"),
|
|
2000
1465
|
],
|
|
2001
|
-
[
|
|
2002
|
-
"hc/modules.hc",
|
|
2003
|
-
[
|
|
2004
|
-
"#!/usr/bin/env hc",
|
|
2005
|
-
"```",
|
|
2006
|
-
"Modules",
|
|
2007
|
-
"A module is HC source read through a resource. `name <- resource` evaluates",
|
|
2008
|
-
"that source in a fresh namespace and binds the namespace to `name` only once",
|
|
2009
|
-
"every form has succeeded, so everything the module declares is reached here",
|
|
2010
|
-
"qualified, through `Figures`, and nothing it declares lands in this file.",
|
|
2011
|
-
"",
|
|
2012
|
-
"Every file in the repository's `hc/` folder ships with the package, so a",
|
|
2013
|
-
"session can include any of them. `'./hc/figures.hc'` names one. The path is",
|
|
2014
|
-
"relative to the root binding, not to this file or to the working directory. The",
|
|
2015
|
-
"CLI's root is a fresh temporary directory, and the harness lays the bundled",
|
|
2016
|
-
"files over it read-only, so this import reads the bytes of `hc/figures.hc`,",
|
|
2017
|
-
"which every host compiles in, so the same import works in the compiled binary,",
|
|
2018
|
-
"the npm package, and the browser playground. That file is a testdoc too: its",
|
|
2019
|
-
"claims count when it is run directly, and none of them count here. Importing",
|
|
2020
|
-
"skips its examples, the lines that begin `; ` outside prose, so only its code",
|
|
2021
|
-
"runs and the namespace holds only what the module declares",
|
|
2022
|
-
"```",
|
|
2023
|
-
"; Figures <- './hc/figures.hc';",
|
|
2024
|
-
"```",
|
|
2025
|
-
"`Figure [c, …]` is the constructor, and every observer is a method that answers",
|
|
2026
|
-
"a Figure. Size answers a tally, one unit cell `U` for every cell, while Manyness",
|
|
2027
|
-
"marks only the immediate children",
|
|
2028
|
-
"```",
|
|
2029
|
-
"; [(Figures.Z.size()) = Figures.Z, (Figures.U.size()) = (Figures.Figure [Figures.U])]",
|
|
2030
|
-
"# [<>, <>]",
|
|
2031
|
-
"; ((Figures.Figure [Figures.U, Figures.U]).many()) = (Figures.Figure [Figures.B, Figures.B])",
|
|
2032
|
-
"# <>",
|
|
2033
|
-
"; ((Figures.Figure [Figures.B]).children .0) === Figures.B",
|
|
2034
|
-
"# <>",
|
|
2035
|
-
"; (“E is ” (Figures.Figure [Figures.A, Figures.B])) = “E is [[], [[]]]”",
|
|
2036
|
-
"# <>",
|
|
2037
|
-
"```",
|
|
2038
|
-
"Sameness of form is `=` and sameness of the constructed Figure is `===`, so `B`",
|
|
2039
|
-
"and a fresh `Figure [A]` agree in form and in Size but are not the same Figure",
|
|
2040
|
-
"```",
|
|
2041
|
-
"; .fresh (Figures.Figure [Figures.A]);",
|
|
2042
|
-
"; [Figures.B.sameform fresh, Figures.B.size_equivalent fresh, Figures.B.sameness Figures.B, Figures.B.sameness fresh] = [Figures.B, Figures.U, Figures.B, Figures.A]",
|
|
2043
|
-
"# <>",
|
|
2044
|
-
"```",
|
|
2045
|
-
"Imported methods compose with Figures built in this file, each with",
|
|
2046
|
-
"`Figures.Figure`. Size counts the cells of a Figure sum and of a Figure product.",
|
|
2047
|
-
"On tallies, joining is a reduce, `ys | x`, `size_mul` multiplies, and the Size",
|
|
2048
|
-
"of a Figure holding two tallies adds them",
|
|
2049
|
-
"```",
|
|
2050
|
-
"; .duo (Figures.Figure [Figures.U, Figures.U]);",
|
|
2051
|
-
"; .trio (Figures.Figure [Figures.U, Figures.U, Figures.U]);",
|
|
2052
|
-
"; .six (Figures.Figure [Figures.U, Figures.U, Figures.U, Figures.U, Figures.U, Figures.U]);",
|
|
2053
|
-
"; [(duo.size()) = duo, ((duo.mul trio).size()) = six, (duo.size_mul trio) = six]",
|
|
2054
|
-
"# [<>, <>, <>]",
|
|
2055
|
-
"; (trio.children | (Figures.Figure [Figures.U])) = (Figures.Figure [Figures.U, Figures.U, Figures.U, Figures.U])",
|
|
2056
|
-
"# <>",
|
|
2057
|
-
"; ((Figures.Figure [Figures.Figure [Figures.U], Figures.Figure [Figures.U]]).size()) = duo",
|
|
2058
|
-
"# <>",
|
|
2059
|
-
"```",
|
|
2060
|
-
"Identity crosses the import boundary. Withness asks for immediate containment",
|
|
2061
|
-
"by `===`, so the module's own `A` is with a parent built here, while a fresh",
|
|
2062
|
-
"`Figure []` of the same form is not",
|
|
2063
|
-
"```",
|
|
2064
|
-
"; .pair (Figures.Figure [Figures.A, Figures.B]);",
|
|
2065
|
-
"; [pair.withness [Figures.A], pair.withness [Figures.Figure []]] = [Figures.B, Figures.A]",
|
|
2066
|
-
"# <>",
|
|
2067
|
-
"```",
|
|
2068
|
-
"The overlay grants reads of the bundled files and nothing else. Writing to one is",
|
|
2069
|
-
"refused,",
|
|
2070
|
-
"and every other path still resolves inside the fresh root, including",
|
|
2071
|
-
"`deno.json`, which exists in the working directory whether the CLI runs from the",
|
|
2072
|
-
"repository root or from `cli/`, and a path under `hc/` that ships no file",
|
|
2073
|
-
"```",
|
|
2074
|
-
"; './hc/figures.hc' “overwrite”",
|
|
2075
|
-
"# $!.resource-read-only './hc/figures.hc'",
|
|
2076
|
-
"; './deno.json' | “”",
|
|
2077
|
-
"# $!.resource-absent './deno.json'",
|
|
2078
|
-
"; './hc/other.hc' | “”",
|
|
2079
|
-
"# $!.resource-absent './hc/other.hc'",
|
|
2080
|
-
"",
|
|
2081
|
-
].join("\n"),
|
|
2082
|
-
],
|
|
2083
1466
|
[
|
|
2084
1467
|
"hc/numerics.hc",
|
|
2085
1468
|
[
|
|
@@ -93,7 +93,8 @@ export class FrameLazy extends FrameExpr {
|
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* A closure walks as the atoms of its body (#429), so `.#` counts them and
|
|
96
|
-
* `.##` the
|
|
96
|
+
* `.##` the terminals below them, as for any aggregate (#411); an empty
|
|
97
|
+
* body is one terminal. The operator
|
|
97
98
|
* reaches a closure as its argument, where a body would otherwise run, so
|
|
98
99
|
* it is answered here before the body is.
|
|
99
100
|
*/
|
|
@@ -136,40 +136,54 @@ export class FrameList extends Frame {
|
|
|
136
136
|
return term.is.statement !== true && !this.holdsAsProperty(term);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
|
-
* `.#` counts this aggregate's elements and `.##` the
|
|
140
|
-
* (
|
|
141
|
-
* one answers here rather than
|
|
139
|
+
* `.#` counts this aggregate's elements (#411) and `.##` the terminals of
|
|
140
|
+
* its structure (issue occurrence/figure 010.02), so neither counts a
|
|
141
|
+
* property. Every aggregate is a list, so each one answers here rather than
|
|
142
|
+
* in its own class.
|
|
142
143
|
*/
|
|
143
144
|
sizeFor(key) {
|
|
144
145
|
if (key === Frame.kCOUNT) {
|
|
145
146
|
return new FrameCount(BigInt(this.countedElements().length));
|
|
146
147
|
}
|
|
147
|
-
const
|
|
148
|
-
return
|
|
148
|
+
const terminals = this.terminalCount(new Set());
|
|
149
|
+
return terminals === undefined
|
|
149
150
|
? Frame.error(`$!.cyclic-aggregate .${key}`)
|
|
150
|
-
: new FrameCount(
|
|
151
|
+
: new FrameCount(terminals);
|
|
151
152
|
}
|
|
152
153
|
/**
|
|
153
|
-
* The
|
|
154
|
-
*
|
|
154
|
+
* The terminals of this aggregate's structure, the nodes with no elements
|
|
155
|
+
* below them. An aggregate with no elements is itself one terminal, at the
|
|
156
|
+
* root or nested, so `[]` counts 1 and `.##` never answers 0 for an
|
|
157
|
+
* aggregate. A nonempty aggregate counts its elements' terminals: each
|
|
158
|
+
* element that is not an aggregate is one terminal, and each aggregate
|
|
159
|
+
* element counts its own, at any depth. Properties are not elements, so an
|
|
160
|
+
* aggregate holding only properties is one terminal too.
|
|
161
|
+
*
|
|
162
|
+
* On finite, property-free nested arrays this is Figure terminal count:
|
|
163
|
+
* `[[], [[], []]].##` is 3. Through v0.32.1 an empty aggregate counted 0,
|
|
164
|
+
* so `.##` counted only the non-aggregate leaves (#411).
|
|
165
|
+
*
|
|
155
166
|
* `path` holds only the aggregates from the root down to this one, so a
|
|
156
167
|
* branch reached twice counts twice, and one that contains itself answers
|
|
157
168
|
* undefined.
|
|
158
169
|
*/
|
|
159
|
-
|
|
170
|
+
terminalCount(path) {
|
|
160
171
|
if (path.has(this))
|
|
161
172
|
return undefined;
|
|
173
|
+
const elements = this.countedElements();
|
|
174
|
+
if (elements.length === 0)
|
|
175
|
+
return 1n;
|
|
162
176
|
path.add(this);
|
|
163
|
-
let
|
|
164
|
-
for (const element of
|
|
177
|
+
let terminals = 0n;
|
|
178
|
+
for (const element of elements) {
|
|
165
179
|
const value = element.referent();
|
|
166
|
-
const below = value instanceof FrameList ? value.
|
|
180
|
+
const below = value instanceof FrameList ? value.terminalCount(path) : 1n;
|
|
167
181
|
if (below === undefined)
|
|
168
182
|
return undefined;
|
|
169
|
-
|
|
183
|
+
terminals += below;
|
|
170
184
|
}
|
|
171
185
|
path.delete(this);
|
|
172
|
-
return
|
|
186
|
+
return terminals;
|
|
173
187
|
}
|
|
174
188
|
/**
|
|
175
189
|
* `n x` for an aggregate concatenates (v0.22.0). The answer is a fresh
|
package/esm/lib/frames/frame.js
CHANGED
|
@@ -572,7 +572,8 @@ Object.defineProperty(Frame, "kCOUNT", {
|
|
|
572
572
|
value: "#"
|
|
573
573
|
});
|
|
574
574
|
/**
|
|
575
|
-
* kLEAVES is the size operator `.##`, an aggregate's
|
|
575
|
+
* kLEAVES is the size operator `.##`, an aggregate's terminal count (#411,
|
|
576
|
+
* issue occurrence/figure 010.02).
|
|
576
577
|
*/
|
|
577
578
|
Object.defineProperty(Frame, "kLEAVES", {
|
|
578
579
|
enumerable: true,
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.33.0";
|