metanum 2.1.2 → 2.2.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/test_mixed.js CHANGED
@@ -31,6 +31,24 @@ function checkRT(name, input) {
31
31
  }
32
32
  }
33
33
 
34
+ // ── G0 process gate (hyper_inv spec 4.2.3 / tasks 10.1) ──────────────────────
35
+ // Every line that starts with "FAIL |" or "ERROR |" is counted here, and the
36
+ // end of the file turns any such line into a non-zero process exit code. The
37
+ // legacy helpers above only print; this wrapper adds the exit-code contract
38
+ // without touching a single existing assertion.
39
+ var GATE_COUNTS = { fail: 0, error: 0 };
40
+ (function () {
41
+ var rawLog = console.log;
42
+ console.log = function () {
43
+ var first = arguments[0];
44
+ if (typeof first === "string") {
45
+ if (first.indexOf("FAIL |") === 0) GATE_COUNTS.fail++;
46
+ else if (first.indexOf("ERROR |") === 0) GATE_COUNTS.error++;
47
+ }
48
+ return rawLog.apply(console, arguments);
49
+ };
50
+ })();
51
+
34
52
 
35
53
  // G1 PARSING & ROUND-TRIP
36
54
  // G1.1 letter chains (1-4 letters, symbols, ε) round-trip
@@ -99,6 +117,9 @@ function checkRT(name, input) {
99
117
  // G4.12 h11/h12/h13 count law
100
118
  // G4.13 h20+ : expanded form & count law
101
119
  // G4.14 h20+ with fractional y
120
+ // G4.15 ordinal-level root forms (aperiote_root/r10 … epsilonate_root/repsl)
121
+ // G4.16 huge-y growth (y > COEFF_BOUND sup-collapse must encode λ[y])
122
+ // G7.12 format "null" regression (inner chain null → Γ-collapse)
102
123
  // G5 ENGINE ARRAYS & BEAF
103
124
  // G5.1 engine arrays
104
125
  // G5.2 BEAF ordinal nesting
@@ -185,6 +206,7 @@ function checkRT(name, input) {
185
206
  // G3.29 aperioguate (ω^4)
186
207
  // G3.30 iter (ω^ω)
187
208
  // G3.31 itermult (ω^ω+1)
209
+ // G3.31b iteraperiate (ω^ω+ω)
188
210
  // G3.32 cuboiter (ω^ω*2)
189
211
  // G3.33 expoiter (ω^(ω+1))
190
212
  // G3.34 trioterate (ω^(ω*2))
@@ -283,6 +305,7 @@ function checkRT(name, input) {
283
305
  // G3.29 aperioguate (ω^4)
284
306
  // G3.30 iter (ω^ω)
285
307
  // G3.31 itermult (ω^ω+1)
308
+ // G3.31b iteraperiate (ω^ω+ω)
286
309
  // G3.32 cuboiter (ω^ω*2)
287
310
  // G3.33 expoiter (ω^(ω+1))
288
311
  // G3.34 trioterate (ω^(ω*2))
@@ -796,11 +819,12 @@ checkHR("2{4}3, c=3, b=4", MetaNum(2).arrow(4)(3), 3, 4, 2);
796
819
 
797
820
  //hyperoperation definition from https://googology.fandom.com/wiki/Template:ExtendedOps
798
821
  console.log("\n=== G3.4 aperiote (ω) ===");
799
- checkOp("aper(3,0)", m3.aperiote(0), 9, 0);
800
- checkOp("aper(3,1)", m3.aperiote(1), 27, 0);
801
- checkOp("aper(3,2)", m3.aperiote(2), 7625597484987, 0);
802
- checkOp("aper(3,4)", m3.aperiote(4)); //3↑↑↑↑4
803
- checkOp("aper(4,3)", m4.aperiote(3)); //4↑↑↑3
822
+ // rule 3: x{ω}y = x{ω[y]}y = x{y}y
823
+ checkOp("aper(3,0)", m3.aperiote(0), 0, 0);
824
+ checkOp("aper(3,1)", m3.aperiote(1), 3, 0);
825
+ checkOp("aper(3,2)", m3.aperiote(2), 27, 0);
826
+ checkOp("aper(3,4)", m3.aperiote(4)); //3{4}4 = 3↑↑↑↑4
827
+ checkOp("aper(4,3)", m4.aperiote(3)); //4{3}3 = 4↑↑↑3
804
828
  checkBool("aper NaN", MetaNum.aperiote(m3, MetaNum.NaN).isNaN(), true);
805
829
  checkBool("aper inv NaN", MetaNum.inv_aperiote(m3, MetaNum.NaN).isNaN(), true);
806
830
 
@@ -996,6 +1020,101 @@ checkOp("itmu(4,3)", m4.itermult(3));
996
1020
  checkBool("itmu y=0 NaN", m3.itermult(0).isNaN(), true);
997
1021
  checkBool("itmu NaN", MetaNum.itermult(m3, MetaNum.NaN).isNaN(), true);
998
1022
 
1023
+ // ─── 28b. iteraperiate (ω^ω+ω): (ω^ω+ω)[y] = ω^ω+y, so x{ω^ω+ω}y = x{ω^ω+y}x;
1024
+ // finite y ≥ 2 → layer-1 marker [[y],[1,0,1]] (the height IS the level's
1025
+ // constant term — itermult stores y-1 there), ordinal y → y + [1|ω] + [1|ω^ω] ───
1026
+ console.log("\n=== G3.31b iteraperiate (ω^ω+ω) ===");
1027
+ (function () {
1028
+ checkOp("itap(3,4)", m3.iteraperiate(4));
1029
+ checkOp("itap(4,3)", m4.iteraperiate(3));
1030
+ checkBool("itap y=0 NaN", m3.iteraperiate(0).isNaN(), true);
1031
+ checkBool("itap NaN", MetaNum.iteraperiate(m3, MetaNum.NaN).isNaN(), true);
1032
+ // aliases + static form
1033
+ checkBool("itap/hw0w alias", m3.itap(5).eq(m3.hw0w(5)), true);
1034
+ checkBool("static MetaNum.iteraperiate", MetaNum.iteraperiate(3, 5).eq(m3.iteraperiate(5)), true);
1035
+ // marker: the ω^ω+ω level marker [[0,1],[1,0,1]] (tail ω in r0 CNF, literal
1036
+ // empty constant term) — identical for every finite y ≥ 2
1037
+ // (3{ω^ω+ω}3 ≈ 10{ω^ω+ω}10 at marker scale)
1038
+ checkBool("itap(10,5) marker [[0,1],[1,0,1]]",
1039
+ JSON.stringify(MetaNum(10).iteraperiate(5).array) === "[[0,1],[1,0,1]]" &&
1040
+ MetaNum(10).iteraperiate(5).layer === 1, true);
1041
+ checkBool("itap(10,100) marker [[0,1],[1,0,1]] (finite y share one marker)",
1042
+ JSON.stringify(MetaNum(10).iteraperiate(100).array) === "[[0,1],[1,0,1]]", true);
1043
+ // finite heights sit below marker resolution: constant marker for y = 2..1e6
1044
+ var prev = null, mono = true;
1045
+ for (var yi = 0; yi < [2,3,4,5,100,1e4,1e6].length; yi++) {
1046
+ var yv = MetaNum(10).iteraperiate([2,3,4,5,100,1e4,1e6][yi]);
1047
+ if (prev && !yv.eq(prev)) mono = false;
1048
+ prev = yv;
1049
+ }
1050
+ checkBool("itap(10,y) constant marker for finite y = 2..1e6", mono, true);
1051
+ checkBool("itmu(10,5) < itap(10,5) < cube(10,5)",
1052
+ MetaNum(10).itermult(5).lt(MetaNum(10).iteraperiate(5)) &&
1053
+ MetaNum(10).iteraperiate(5).lt(MetaNum(10).cuboiter(5)), true);
1054
+ checkBool("itap(10,1e6) < cube(10,2) (ω^ω+y < ω^ω+ω^2)",
1055
+ MetaNum(10).iteraperiate(1e6).lt(MetaNum(10).cuboiter(2)), true);
1056
+ // edge cases: y=1, x=1, B2-a, NaN
1057
+ checkBool("itap(7,1) = 7 (a{α}1 = a)", MetaNum(7).iteraperiate(1).eq(MetaNum(7)), true);
1058
+ checkBool("itap(1,5) = 1 (1{α}b = 1)", MetaNum(1).iteraperiate(5).eq(MetaNum(1)), true);
1059
+ // B2-a only collapses the 2-diagonal; 2{λ}y for y ≥ 3 carries the level
1060
+ // marker (the y-dependence is below marker resolution at the ω^ω scale)
1061
+ checkBool("itap(2,3) > 4 and shares the finite-y marker (B2-a is the 2-diagonal only)",
1062
+ MetaNum(2).iteraperiate(3).gt(MetaNum(4)) &&
1063
+ MetaNum(2).iteraperiate(3).eq(MetaNum(2).iteraperiate(5)), true);
1064
+ // base-independence of the marker: every base ≥ 3 gives the same value
1065
+ checkBool("marker base-independent (3,10,4↑↑4 same marker)",
1066
+ m3.iteraperiate(5).eq(MetaNum(10).iteraperiate(5)) &&
1067
+ MetaNum(4).arrow(2)(4).iteraperiate(5).eq(MetaNum(10).iteraperiate(5)), true);
1068
+ // ordinal height: y + [1|ω] + [1|ω^ω]; merge with y's own rows; round-trip
1069
+ var oy = MetaNum(10).itermult(3); // [[0.125],[1,0,1]] layer 1
1070
+ var ov = MetaNum(10).iteraperiate(oy);
1071
+ checkBool("itap(10, ordinal) = y + [1|ω] + [1|ω^ω] (like terms merged)",
1072
+ JSON.stringify(ov.array) === "[[0.125,1],[2,0,1]]" && ov.layer === 1, true);
1073
+ checkBool("ordinal round-trip inv_itap(oy-itap) = oy",
1074
+ ov.inv_iteraperiate(MetaNum(10)).eq(oy), true);
1075
+ var oy2 = MetaNum(10).expoiter(3); // [[10],[3,0,1]] layer 1
1076
+ var ov2 = MetaNum(10).iteraperiate(oy2);
1077
+ checkBool("ordinal round-trip 2 (ω^ω·3 row)",
1078
+ JSON.stringify(ov2.array) === "[[10,1],[4,0,1]]" &&
1079
+ ov2.inv_iteraperiate(MetaNum(10)).eq(oy2), true);
1080
+ // log inverse: the finite marker is constant, so the inverse returns the
1081
+ // minimal reproducing height 2 — verified by forward reproduction
1082
+ var invOk = true, invBad = "";
1083
+ for (var yj = 0; yj < [2,3,5,100].length; yj++) {
1084
+ var yy = [2,3,5,100][yj];
1085
+ var vj = MetaNum(10).iteraperiate(yy);
1086
+ var back = vj.inv_iteraperiate(MetaNum(10));
1087
+ if (!back.eq(MetaNum(2)) ||
1088
+ !MetaNum(10).iteraperiate(back).eq(vj) ||
1089
+ !vj.i_itap(MetaNum(10)).eq(back) ||
1090
+ !vj.iw0w(MetaNum(10)).eq(back) ||
1091
+ !MetaNum.inv_iteraperiate(vj, MetaNum(10)).eq(back)) {
1092
+ invOk = false; invBad = " y=" + yy; break;
1093
+ }
1094
+ }
1095
+ checkBool("itap log inverse returns the minimal reproducing height (y = 2,3,5,100)", invOk, true, invBad);
1096
+ checkBool("i_itap/iw0w/static aliases agree",
1097
+ MetaNum(10).iteraperiate(5).i_itap(MetaNum(10)).eq(MetaNum(2)) &&
1098
+ MetaNum(10).iteraperiate(5).iw0w(MetaNum(10)).eq(MetaNum(2)), true);
1099
+ // root form: marker level → smallest reproducing base; base 2 now also
1100
+ // reproduces the base-independent marker (B2-a no longer collapses it)
1101
+ var v5 = MetaNum(10).iteraperiate(5);
1102
+ checkBool("itap_root(5) = 2 (smallest reproducing base)",
1103
+ v5.iteraperiate_root(5).eq(MetaNum(2)) &&
1104
+ v5.r_itap(5).eq(MetaNum(2)) && v5.rw0w(5).eq(MetaNum(2)) &&
1105
+ MetaNum.iteraperiate_root(v5, 5).eq(MetaNum(2)), true);
1106
+ checkBool("2.itap(5) reproduces the marker value",
1107
+ MetaNum(2).iteraperiate(5).eq(v5), true);
1108
+ checkBool("(2{ω^ω+ω}9).itap_root(9) = 2",
1109
+ MetaNum(2).iteraperiate(9).iteraperiate_root(9).eq(MetaNum(2)), true);
1110
+ checkBool("itap_root y=1 returns the value",
1111
+ MetaNum(7).iteraperiate_root(1).eq(MetaNum(7)), true);
1112
+ checkBool("itap_root of 1 is 1", MetaNum(1).iteraperiate_root(5).eq(MetaNum(1)), true);
1113
+ checkBool("itap_root of a negative value → NaN", MetaNum(-4).iteraperiate_root(5).isNaN(), true);
1114
+ checkBool("itap_root with y ≤ 0 → NaN",
1115
+ MetaNum(10).iteraperiate(5).iteraperiate_root(-5).isNaN(), true);
1116
+ })();
1117
+
999
1118
  // ─── 29. cuboiter (ω^ω*2) ───
1000
1119
  console.log("\n=== G3.32 cuboiter (ω^ω*2) ===");
1001
1120
  checkOp("cube(3,4)", m3.cuboiter(4));
@@ -1035,14 +1154,15 @@ checkBool("epsl NaN", MetaNum.epsilonate(m3, MetaNum.NaN).isNaN(), true);
1035
1154
  // λ[y] layer markers in STANDARD form (finite rows merged into r0, layer
1036
1155
  // lowered as far as it goes — README L17: layer L ⇒ ω^ω^…((L-1) ω^'s)^(bracket)):
1037
1156
  // iter → 10{ω^y}10 (L1 [1,y]); itmu → 10{ω^ω+(y-1)}10 (L1 [1,0,1], r0=y-1)
1038
- // cube → 10{ω^ω+ω^y}10 (L1 r0[…,1@y] + [1,0,1]); expo → 10{ω^ω·y}10 (L1 [y,0,1])
1157
+ // itap → 10{ω^ω+y}10 (L1 [1,0,1], r0=y); cube → 10{ω^ω+ω^y}10 (L1 r0[…,1@y] + [1,0,1]); expo → 10{ω^ω·y}10 (L1 [y,0,1])
1039
1158
  // tria → 10{ω^(ω+y)}10 (L1 [1,y,1]); trix → 10{ω^(ω·y+10)}10 (L1 [1,10,y])
1040
1159
  // apix → 10{ω^(ω^y)}10 (L1 [1,0…0,1] with y zeros)
1041
1160
  console.log("\n=== G3.38 λ[y] layer markers in STANDARD form ===");
1042
- var wOps = ["iterate","itermult","cuboiter","expoiter","trioterate","trixxate","aperixxate"];
1161
+ var wOps = ["iterate","itermult","iteraperiate","cuboiter","expoiter","trioterate","trixxate","aperixxate"];
1043
1162
  var mk35 = {
1044
1163
  iterate: { layer: 0, rows: null }, // exact cascade, layer 0
1045
- itermult: { layer: 1, rows: "[[4],[1,0,1]]" },
1164
+ itermult: { layer: 1, rows: "[[0.375],[1,0,1]]" }, // c0 = (y-2)/8 base-10 normalized
1165
+ iteraperiate: { layer: 1, rows: "[[0,1],[1,0,1]]" }, // level tail ω, constant for finite y
1046
1166
  cuboiter: { layer: 1, rows: "[[10,0,0,0,0,1],[1,0,1]]" },
1047
1167
  expoiter: { layer: 1, rows: "[[10],[5,0,1]]" },
1048
1168
  trioterate: { layer: 1, rows: "[[10],[1,5,1]]" },
@@ -1055,9 +1175,9 @@ for (var wi = 0; wi < wOps.length; wi++) {
1055
1175
  (wexp.rows === null || JSON.stringify(wv.array) === wexp.rows);
1056
1176
  checkBool(wf + "(3,5) λ[5] marker (layer " + wexp.layer + ")", wok, true);
1057
1177
  }
1058
- checkBool("epsl(3,5) = 10{ω^ω^ω^ω^ω}10 → standard form layer 4, row [1,10,1]",
1059
- m3.epsilonate(5).layer === 4 &&
1060
- JSON.stringify(m3.epsilonate(5).array) === "[[10],[1,10,1]]", true);
1178
+ checkBool("epsl(3,5) = 10{ω^ω^ω^ω^ω}10 → FS position layer 3 over the ω³ row [1,0,0,0,1] (5c)",
1179
+ m3.epsilonate(5).layer === 3 &&
1180
+ JSON.stringify(m3.epsilonate(5).array) === "[[10],[1,0,0,0,1]]", true);
1061
1181
  checkBool("epsl(3,2) = 3{ε₀[2]}3 = 3{ω^ω}3 = itmu(3,2)",
1062
1182
  m3.epsilonate(2).eq(m3.itermult(2)), true);
1063
1183
  // the ordinal levels grow with the operation, for every y
@@ -1068,7 +1188,7 @@ for (var wy = 2; wy <= 9; wy++) {
1068
1188
  if (wprev && !wr.gt(wprev)) wmono = false;
1069
1189
  wprev = wr;
1070
1190
  }
1071
- checkBool("ops strictly grow at y=" + wy + " (iter<itmu<cube<expo<tria<trix<apix)", wmono, true);
1191
+ checkBool("ops strictly grow at y=" + wy + " (iter<itmu<itap<cube<expo<tria<trix<apix)", wmono, true);
1072
1192
  }
1073
1193
 
1074
1194
  // precision budget: exact while it fits maxRows/maxCols
@@ -1090,11 +1210,11 @@ console.log("\n=== G3.39 precision budget (maxRows/maxCols) ===");
1090
1210
  var i35 = m3.iterate(5);
1091
1211
  checkBool("iter(3,5) cascade truncated: array[0]=[10], array[1][0]+1, 19 rows",
1092
1212
  JSON.stringify(i35.array[0]) === "[10]" &&
1093
- JSON.stringify(i35.array[1]) === "[2,2,2,0,2,2]" && i35.array.length - 1 === 19, true);
1213
+ JSON.stringify(i35.array[1]) === "[2,1,2,3,4,4]" && i35.array.length - 1 === 19, true);
1094
1214
  var h10000 = m3.h10000(10);
1095
1215
  checkBool("h10000(3,10) cascade truncated: array[0]=[10], array[1][0]+1",
1096
1216
  JSON.stringify(h10000.array[0]) === "[10]" &&
1097
- JSON.stringify(h10000.array[1]) === "[2,2,2,0,9]", true);
1217
+ JSON.stringify(h10000.array[1]) === "[2,0,6,9,9]", true);
1098
1218
  // exact while the enumeration fits: 3{ω^2}3 needs 3^2 = 9 ≤ maxRows rows
1099
1219
  var i32 = m3.iterate(2);
1100
1220
  checkBool("iter(3,2) exact enumeration (no [10] base / no +1 marker)",
@@ -1145,9 +1265,9 @@ console.log("\n=== G3.41 all hyperoperations x=3, y=1 test ===");
1145
1265
  for (var oi = 0; oi < ops.length; oi++) {
1146
1266
  try {
1147
1267
  var res = m3[ops[oi]](1);
1148
- // rule 3 for limit ordinals: x{λ}1 = x{λ[1]}x = x{1}x = x^x, so
1149
- // aperiote(3,1) = 3^3 = 27 (other ops are successor levels -> x)
1150
- var expected1 = ops[oi] === "aperiote" ? 27 : 3;
1268
+ // rule 3 for limit ordinals: x{λ}1 = x{λ[1]}1 = x{1}1 = x for every
1269
+ // op (successor levels give x directly), so aperiote(3,1) = 3 too
1270
+ var expected1 = 3;
1151
1271
  if (res.eq(expected1)) console.log("PASS | " + ops[oi] + "(3,1) | " + res.toString().slice(0, 100));
1152
1272
  else console.log("FAIL | " + ops[oi] + "(3,1) => " + res.toString().slice(0, 100));
1153
1273
  } catch (e) {
@@ -1208,8 +1328,8 @@ console.log("\n=== G3.45 inverse round-trip (small y and y > MSI) ===");
1208
1328
  var m10 = MetaNum(10);
1209
1329
  for (var oi = 0; oi < ops.length; oi++) {
1210
1330
  var fwdS, backS, fwdB, backB;
1211
- // small argument: under rule 3 (x{λ}b = x{λ[b]}x) limit-derived values end
1212
- // on the base x = 10; purely successor-level values still end on 3.
1331
+ // small argument: under rule 3 (x{λ}b = x{λ[b]}b) the inverse recovers y;
1332
+ // a few marker/huge-argument conventions fall back to the base x = 10
1213
1333
  try {
1214
1334
  fwdS = m10[ops[oi]](3);
1215
1335
  backS = fwdS[invOps[oi]](m10);
@@ -1226,7 +1346,11 @@ for (var oi = 0; oi < ops.length; oi++) {
1226
1346
  try {
1227
1347
  fwdB = m10[ops[oi]](mBigBase);
1228
1348
  backB = fwdB[invOps[oi]](m10);
1229
- var okB = !backB.isNaN() && backB.isFinite() && backB.gte(m1) && fwdB.gt(m10);
1349
+ // epsilonate passes the ε₀ ceiling at y > MSI and returns Infinity (the
1350
+ // documented convention), so its inverse is NaN by the non-finite rule
1351
+ var okB = ops[oi] === "epsilonate"
1352
+ ? fwdB.toString() === "Infinity"
1353
+ : !backB.isNaN() && backB.isFinite() && backB.gte(m1) && fwdB.gt(m10);
1230
1354
  console.log((okB ? "PASS" : "FAIL") + " | " + invOps[oi] + " y>MSI | fwd=" +
1231
1355
  fwdB.toString().slice(0, 80) + " back=" + backB.toString().slice(0, 80));
1232
1356
  } catch (e) {
@@ -1376,7 +1500,7 @@ checkArr("powerexpande(1e16,3) array", mL16.powerexpande(3), [[16, 1], [2, 2, 1]
1376
1500
  checkArr("aperiote(3,1e16) array", m3.aperiote(mL16), [[16, 1], [1, 0, 1]]);
1377
1501
  // rule 3: 1e16{ω}3 = 1e16{3}1e16 — the huge base dominates, same marker
1378
1502
  // array as the y>MSI case
1379
- checkArr("aperiote(1e16,3) array", mL16.aperiote(3), [[16, 1, 0, 1]]);
1503
+ checkArr("aperiote(1e16,3) array", mL16.aperiote(3), [[16, 1, 2]]);
1380
1504
  checkArr("expande(3,1e16) array", m3.expande(mL16), [[16, 1], [1, 1, 1]]);
1381
1505
  checkArr("multiexpande(3,1e16) array", m3.multiexpande(mL16), [[16, 1], [1, 2, 1]]);
1382
1506
  checkArr("powerexpande(3,1e16) array", m3.powerexpande(mL16), [[16, 1], [1, 3, 1]]);
@@ -1485,9 +1609,10 @@ checkBool("h21(3,20): lower rows carry x-2 = 1",
1485
1609
  lr.array[1][0] === 9, true);
1486
1610
  }
1487
1611
  }
1488
- // top row carries the fundamental-sequence index y-1
1489
- checkBool("h20(10,1000) top row = ω+999",
1490
- JSON.stringify(MetaNum(10).h20(1000).array[19]) === "[8,999,1]", true);
1612
+ // top row carries the fundamental-sequence level ω+(y-1) with count y-2
1613
+ // (first successor expansion); the rows below it carry x-2 = 8
1614
+ checkBool("h20(10,1000) top row = ω+999, count y-2",
1615
+ JSON.stringify(MetaNum(10).h20(1000).array[19]) === "[998,999,1]", true);
1491
1616
  checkBool("h20(10,MSI) top row = ω+(MSI-1)",
1492
1617
  MetaNum(10).h20(MSI).array[19][1] === MSI - 1, true);
1493
1618
  })();
@@ -1495,28 +1620,28 @@ checkBool("h21(3,20): lower rows carry x-2 = 1",
1495
1620
  // ─────────────────────────────────────
1496
1621
  // Fractional y for every level from ω*2 up (README "Non-integer arguments"):
1497
1622
  // a limit level takes its fundamental sequence at the FULL fractional index and
1498
- // the fractional coefficients resolve against the base x (ω^(k)·(c+f) =
1499
- // ω^(k)·c + ω^(k-1)·(x·f)); a leftover fractional constant becomes a fractional
1500
- // argument one level up: x{γ+f}x = x{γ+1}(2·(x/2)^f).
1623
+ // the fractional coefficients resolve against the operand y (ω^(k)·(c+f) =
1624
+ // ω^(k)·c + ω^(k-1)·(y·f)); a leftover fractional constant becomes a fractional
1625
+ // argument one level up: x{γ+f}y = x{γ+1}(2·(y/2)^f).
1501
1626
  // ─────────────────────────────────────
1502
1627
  console.log("\n=== G3.53 h20+ with fractional y ===");
1503
- checkBool("10{ω*2}2.1 = 10{ω+3}(2*5^0.1)",
1504
- MetaNum(10).h20(2.1).eq(MetaNum(10).powerexpande(2 * Math.pow(5, 0.1))), true);
1505
- checkBool("3{ω*2}2.1 = 3{ω+3}(2*1.5^0.1)",
1506
- MetaNum(3).h20(2.1).eq(MetaNum(3).powerexpande(2 * Math.pow(1.5, 0.1))), true);
1507
- checkBool("10{ω^2}2.1 = 10{ω*2+1}10",
1508
- MetaNum(10).h100(2.1).eq(MetaNum(10).h21(10)), true);
1509
- checkBool("3{ω^2}2.1 = 3{ω*2+1}(2*1.5^0.3)",
1510
- MetaNum(3).h100(2.1).eq(MetaNum(3).h21(2 * Math.pow(1.5, 0.3))), true);
1511
- // 10{ω^ω}2.1 = 10{ω^2.1}10 = 10{ω^2*10^0.1}10 → ω^2+ω*2+5.8925… → next level
1628
+ checkBool("10{ω*2}2.1 = 10{ω+3}(2*(2.1/2)^0.1)",
1629
+ MetaNum(10).h20(2.1).eq(MetaNum(10).powerexpande(2 * Math.pow(2.1 / 2, 0.1))), true);
1630
+ checkBool("3{ω*2}2.1 = 3{ω+3}(2*(2.1/2)^0.1)",
1631
+ MetaNum(3).h20(2.1).eq(MetaNum(3).powerexpande(2 * Math.pow(2.1 / 2, 0.1))), true);
1632
+ checkBool("10{ω^2}2.1 = 10{ω*2+1}(2*(2.1/2)^0.21)",
1633
+ MetaNum(10).h100(2.1).eq(MetaNum(10).h21(2 * Math.pow(2.1 / 2, 0.21))), true);
1634
+ checkBool("3{ω^2}2.1 = 3{ω*2+1}(2*(2.1/2)^0.21)",
1635
+ MetaNum(3).h100(2.1).eq(MetaNum(3).h21(2 * Math.pow(2.1 / 2, 0.21))), true);
1636
+ // 10{ω^ω}2.1 = 10{ω^2.1}2.1 = 10{ω^2*2.1^0.1}2.1 → ω^2+0.339638… → next level
1512
1637
  (function () {
1513
- var rf = MetaNum._resolveFracLevel([0, 0, Math.pow(10, 0.1)], 10);
1638
+ var rf = MetaNum._resolveFracLevel([0, 0, Math.pow(2.1, 0.1)], 2.1);
1514
1639
  var up = rf.ord.slice(); up[0] += 1;
1515
- checkBool("10{ω^ω}2.1 = 10{ω^2+ω*2+6}(2*5^0.8925…) (level " +
1640
+ checkBool("10{ω^ω}2.1 = 10{ω^2+1}(2*(2.1/2)^0.339638…) (level " +
1516
1641
  JSON.stringify(up) + ")",
1517
- JSON.stringify(up) === "[6,2,1]" &&
1642
+ JSON.stringify(up) === "[1,0,1]" &&
1518
1643
  MetaNum(10).iterate(2.1).eq(
1519
- MetaNum._hyperopFromOrdinal(MetaNum(10), MetaNum(2 * Math.pow(5, rf.frac)), up)), true);
1644
+ MetaNum._hyperopFromOrdinal(MetaNum(10), MetaNum(2 * Math.pow(2.1 / 2, rf.frac)), up)), true);
1520
1645
  })();
1521
1646
  // the fraction is not thrown away: y and floor(y) differ
1522
1647
  checkBool("h20(10,2.1) != h20(10,2) and lies strictly between 2 and 3",
@@ -1525,10 +1650,13 @@ checkBool("h20(10,2.1) != h20(10,2) and lies strictly between 2 and 3",
1525
1650
  checkBool("h100(10,10.25) lies strictly between 10 and 11",
1526
1651
  MetaNum(10).h100(10.25).gt(MetaNum(10).h100(10)) &&
1527
1652
  MetaNum(10).h100(10.25).lt(MetaNum(10).h100(11)), true);
1528
- // Monotone in y across the integers for the LIMIT levels. Sampled: the
1529
- // 504-evaluation full grid (7 ops × 2 bases × y=2..10) only re-exercised the
1530
- // same cascade code path, so it is reduced to representative ops/bases/m
1531
- // (still covers ω, ω+1, ω*2, ω² and ω^ω strata and both small bases).
1653
+ // Monotone in y across the integers for the LIMIT levels. The fractional
1654
+ // interpolation anchors at x{γ+1}2 = x{γ}x (README), so the grid step m →
1655
+ // m+f stays monotone while m ≤ x; for m > x the fractional value sits in the
1656
+ // interpolation band [x{γ+1}2, x{γ+1}(m+f)) BELOW the integer grid point —
1657
+ // that is the spec's behavior, checked separately. Sampled: representative
1658
+ // ops/bases/m (still covers ω, ω+1, ω*2, ω² and ω^ω strata and both small
1659
+ // bases).
1532
1660
  (function () {
1533
1661
  var limOps = ["h20", "h30", "h100", "h1000", "iterate"];
1534
1662
  var bad = 0, firstBad = "";
@@ -1536,6 +1664,7 @@ checkBool("h100(10,10.25) lies strictly between 10 and 11",
1536
1664
  for (var b = 0; b < 2; b++) {
1537
1665
  var bx = [3, 10][b];
1538
1666
  for (var m = 2; m <= 10; m += 4) {
1667
+ if (m > bx) continue; // grid monotonicity is guaranteed only for y ≤ x
1539
1668
  var a = MetaNum(bx)[limOps[i]](m), c = MetaNum(bx)[limOps[i]](m + 0.001);
1540
1669
  var d = MetaNum(bx)[limOps[i]](m + 0.5), e = MetaNum(bx)[limOps[i]](m + 1);
1541
1670
  if (!(c.gte(a) && d.gte(c) && e.gte(d))) {
@@ -1544,8 +1673,15 @@ checkBool("h100(10,10.25) lies strictly between 10 and 11",
1544
1673
  }
1545
1674
  }
1546
1675
  }
1547
- checkBool("limit levels monotone across fractional y", bad === 0, true,
1676
+ checkBool("limit levels monotone across fractional y (grid points y ≤ x)", bad === 0, true,
1548
1677
  bad === 0 ? "" : " first failure: " + firstBad);
1678
+ // for m > x the value stays inside the interpolation band anchored at
1679
+ // x{γ}x: h20(3,6.001) = 3{ω+7}(2·(6.001/2)^0.001) ∈ [3{ω+7}2, 3{ω+7}6.001)
1680
+ var lo = MetaNum._hyperopFromOrdinal(MetaNum(3), MetaNum(2), [7, 1]);
1681
+ var vv = MetaNum(3).h20(6.001);
1682
+ var hi = MetaNum._hyperopFromOrdinal(MetaNum(3), MetaNum(6.001), [7, 1]);
1683
+ checkBool("h20(3,6.001) lies in the band [3{ω+7}2, 3{ω+7}6.001) (y > x anchors at x{γ}x)",
1684
+ vv.gte(lo) && vv.lt(hi), true);
1549
1685
  })();
1550
1686
  // the SUCCESSOR rule with a fractional argument is written in the same expanded
1551
1687
  // form: the α-1 row carries the m applications (ceil(y)-2 = m-1) and the cascade
@@ -1698,6 +1834,118 @@ checkBool("h31(10,5.1) < h31(10,5.5) < h31(10,5.9) < h31(10,6)",
1698
1834
  true, bad === 0 ? "" : " first failure: " + firstBad);
1699
1835
  })();
1700
1836
 
1837
+ // ─────────────────────────────────────
1838
+ // v2.2.0 ordinal-level ROOT forms: c.<op>_root(b) = a mirrors the inv_* log
1839
+ // family (c.i_<op>(a) = b). README example:
1840
+ // (10{ω}15).aperiote_root(15) = 10, just like (10{ω}15).i_aper(10) = 15.
1841
+ // Beyond the representation budget the stored value no longer encodes the
1842
+ // base (huge-argument markers; base-independent layer markers at ω^ω+), so
1843
+ // the root returns the smallest base reproducing the stored value — the
1844
+ // same convention hyper_root documents for the finite levels.
1845
+ // ─────────────────────────────────────
1846
+ console.log("\n=== G4.15 ordinal-level root forms ===");
1847
+ (function () {
1848
+ var v = MetaNum(10).aperiote(15); // 10{ω}15
1849
+ checkBool("(10{ω}15).aperiote_root(15) = 10", v.aperiote_root(15).eq(MetaNum(10)), true);
1850
+ checkBool("(10{ω}15).r10(15) = 10 (code alias)", v.r10(15).eq(MetaNum(10)), true);
1851
+ checkBool("(10{ω}15).r_aper(15) = 10 (short alias)", v.r_aper(15).eq(MetaNum(10)), true);
1852
+ checkBool("(10{ω}15).i_aper(10) = 15 (log counterpart)", v.i_aper(MetaNum(10)).eq(MetaNum(15)), true);
1853
+ checkBool("static MetaNum.aperiote_root(10{ω}15, 15) = 10",
1854
+ MetaNum.aperiote_root(MetaNum(10).aperiote(15), MetaNum(15)).eq(MetaNum(10)), true);
1855
+ // edge cases: a{α}1 = a, 1{α}b = 1, 2{α}2 = 4 (B2-a), invalid input → NaN
1856
+ checkBool("aperiote_root y=1 returns the value (a{α}1 = a)", MetaNum(7).aperiote_root(1).eq(MetaNum(7)), true);
1857
+ checkBool("aperiote_root of 1 is 1 (1{α}b = 1)", MetaNum(1).aperiote_root(5).eq(MetaNum(1)), true);
1858
+ checkBool("(2{ω}9).aperiote_root(9) = 2 (2{9}9 roots back to base 2)",
1859
+ MetaNum(2).aperiote(9).aperiote_root(9).eq(MetaNum(2)), true);
1860
+ checkBool("aperiote_root of a negative value → NaN", MetaNum(-4).aperiote_root(5).isNaN(), true);
1861
+ checkBool("aperiote_root with y ≤ 0 → NaN", MetaNum(10).aperiote(15).aperiote_root(-5).isNaN(), true);
1862
+ // exact base recovery at every representable level (aperiote .. iterate)
1863
+ var exact = [["aperiote","aperiote_root"],["expande","expande_root"],
1864
+ ["multiexpande","multiexpande_root"],["powerexpande","powerexpande_root"],
1865
+ ["aperioexpande","aperioexpande_root"],["explode","explode_root"],
1866
+ ["multiexplode","multiexplode_root"],["aperioexplode","aperioexplode_root"],
1867
+ ["detonate","detonate_root"],["aperiodetonate","aperiodetonate_root"],
1868
+ ["aperionate","aperionate_root"],["megote","megote_root"],
1869
+ ["multimegote","multimegote_root"],["aperimegote","aperimegote_root"],
1870
+ ["megoexpande","megoexpande_root"],["aperimegoexpande","aperimegoexpande_root"],
1871
+ ["megoaperionate","megoaperionate_root"],["gigote","gigote_root"],
1872
+ ["aperigigote","aperigigote_root"],["gigoaperionate","gigoaperionate_root"],
1873
+ ["aperiatote","aperiatote_root"],["powiainate","powiainate_root"],
1874
+ ["expandainate","expandainate_root"],["megodainate","megodainate_root"],
1875
+ ["powiairate","powiairate_root"],["aperioguate","aperioguate_root"],
1876
+ ["iterate","iterate_root"]];
1877
+ var bad = 0, firstBad = "";
1878
+ for (var i = 0; i < exact.length; i++) {
1879
+ for (var k = 0; k < 2; k++) {
1880
+ var x = [3, 10][k];
1881
+ var vx = MetaNum(x)[exact[i][0]](5);
1882
+ var a = vx[exact[i][1]](MetaNum(5));
1883
+ if (!a.eq(MetaNum(x))) { bad++; if (!firstBad) firstBad = exact[i][0] + "(" + x + ",5)"; }
1884
+ }
1885
+ }
1886
+ checkBool("root recovers the base: aperiote..iterate (x=3/10, y=5)", bad === 0,
1887
+ true, bad === 0 ? "" : " first failure: " + firstBad);
1888
+ // marker levels (itermult..epsilonate): the stored layer marker is
1889
+ // base-independent (D07 B2-b), so the root is the smallest reproducing
1890
+ // base — 2, since the narrowed B2-a no longer collapses 2{λ}5 to 4 —
1891
+ // verify both that property and the round-trip
1892
+ var marker = [["itermult","itermult_root"],["iteraperiate","iteraperiate_root"],
1893
+ ["cuboiter","cuboiter_root"],
1894
+ ["expoiter","expoiter_root"],["trioterate","trioterate_root"],
1895
+ ["trixxate","trixxate_root"],["aperixxate","aperixxate_root"],
1896
+ ["epsilonate","epsilonate_root"]];
1897
+ var bad2 = 0, firstBad2 = "";
1898
+ for (var j = 0; j < marker.length; j++) {
1899
+ var vm = MetaNum(10)[marker[j][0]](5);
1900
+ var am = vm[marker[j][1]](MetaNum(5));
1901
+ if (!am[marker[j][0]](MetaNum(5)).eq(vm)) { bad2++; if (!firstBad2) firstBad2 = marker[j][0] + " round-trip"; }
1902
+ if (!am.eq(MetaNum(2))) { bad2++; if (!firstBad2) firstBad2 = marker[j][0] + " smallest base"; }
1903
+ }
1904
+ checkBool("marker levels: root = smallest base reproducing the marker (= 2)", bad2 === 0,
1905
+ true, bad2 === 0 ? "" : " first failure: " + firstBad2);
1906
+ })();
1907
+
1908
+ // ─────────────────────────────────────
1909
+ // G4.16 huge-y growth: with a large base, y > COEFF_BOUND(100) used to
1910
+ // collapse to the level λ itself ([1|λ], y-independent). It must instead
1911
+ // store the fundamental-sequence level λ[y] — the same convention the
1912
+ // y ≤ 100 cascade path produces — so results keep growing with y and
1913
+ // stay continuous across y = 100 → 101.
1914
+ // ─────────────────────────────────────
1915
+ console.log("\n=== G4.16 huge-y growth (y > COEFF_BOUND) ===");
1916
+ (function () {
1917
+ var x = MetaNum(4).arrow(3)(4); // 4↑↑↑4 — large base, ordinal engine
1918
+ var ops = ["h20","h30","h100","h40","h110","h120","h2000","h10000"];
1919
+ for (var i = 0; i < ops.length; i++) {
1920
+ var prev = null, mono = true, firstBad = "";
1921
+ for (var j = 0; j < 4; j++) {
1922
+ var y = [101, 1000, 1e4, 1e6][j];
1923
+ var v = new MetaNum(x)[ops[i]](y);
1924
+ if (prev && !v.gt(prev)) { mono = false; if (!firstBad) firstBad = "y=" + y; }
1925
+ prev = v;
1926
+ }
1927
+ checkBool("4↑↑↑4 " + ops[i] + "(y) strictly grows for y = 101..1e6", mono, true,
1928
+ mono ? "" : " first break: " + firstBad);
1929
+ }
1930
+ // the stored ordinal row must be [1|λ[y]]: coefficient equals y
1931
+ checkBool("h20(101) stores [1|ω+101]",
1932
+ JSON.stringify(new MetaNum(x).h20(101).array.slice(-1)) === "[[1,101,1]]", true);
1933
+ checkBool("h100(1e6) stores [1|ω·1000000]",
1934
+ JSON.stringify(new MetaNum(x).h100(1e6).array.slice(-1)) === "[[1,0,1000000]]", true);
1935
+ // continuity across the COEFF_BOUND boundary (value keeps growing):
1936
+ // y=100 ≤ COEFF_BOUND expands the successor cascade [99|ω+99], y=101
1937
+ // stores the huge-argument marker row [1|ω+101]
1938
+ checkBool("h20 continuous across y=100→101",
1939
+ JSON.stringify(new MetaNum(x).h20(100).array.slice(-1)) === "[[99,99,1]]" &&
1940
+ JSON.stringify(new MetaNum(x).h20(101).array.slice(-1)) === "[[1,101,1]]" &&
1941
+ new MetaNum(x).h20(100).lt(new MetaNum(x).h20(101)), true);
1942
+ // 4↑↑4 (smaller large base) must behave identically
1943
+ var x2 = MetaNum(4).arrow(2)(4);
1944
+ checkBool("4↑↑4 h30(101) < h30(1e4) < h30(1e6)",
1945
+ new MetaNum(x2).h30(101).lt(new MetaNum(x2).h30(1e4)) &&
1946
+ new MetaNum(x2).h30(1e4).lt(new MetaNum(x2).h30(1e6)), true);
1947
+ })();
1948
+
1701
1949
  // ─────────────────────────────────────
1702
1950
  // engine arrays: the (y-2) count law
1703
1951
  // x{L}y = x{L-1}^{y-2}(x{L-1}x): 10{25}10 → count-8 rows/cols (the
@@ -1812,14 +2060,23 @@ console.log("\n=== G3.57 D07 2{lambda}2 ===");
1812
2060
  (function () {
1813
2061
  var ops = ["aperiote", "aperionate", "iter", "itermult", "cuboiter", "expoiter",
1814
2062
  "trioterate", "trixxate", "aperixxate", "epsilonate"];
1815
- // B2-a: for base 2 every infinite/successor level collapses to 4 for any
1816
- // integer y >= 2 (rule 3 turns the argument into 2).
2063
+ // B2-a collapses only the 2-diagonal: 2{λ}2 = 2{2}2 = 4 for every level
2064
+ // (rule 3 turns the argument into 2). For y ≥ 3 the new rule 2{λ}y =
2065
+ // 2{λ[y]}y keeps growing with y.
1817
2066
  [2, 3, 5, 1000].forEach(function (y) {
1818
2067
  ops.forEach(function (op) {
1819
2068
  var v = new MetaNum(2)[op](y);
1820
- ok("2{" + op + "}" + y + " === 4", v.eq(4), v.toString());
2069
+ if (y === 2) ok("2{" + op + "}2 === 4 (B2-a diagonal)", v.eq(4), v.toString());
2070
+ else ok("2{" + op + "}" + y + " > 4", v.gt(4), v.toString());
1821
2071
  });
1822
2072
  });
2073
+ // y ≥ 3 grows monotonically for every level, with an exact anchor at ω
2074
+ ops.forEach(function (op) {
2075
+ ok("2{" + op + "}3 < 2{" + op + "}5 < 2{" + op + "}1000",
2076
+ new MetaNum(2)[op](3).lt(new MetaNum(2)[op](5)) &&
2077
+ new MetaNum(2)[op](5).lt(new MetaNum(2)[op](1000)));
2078
+ });
2079
+ ok("2{aperiote}3 === 65536 (2{ω}3 = 2{3}3)", new MetaNum(2).aperiote(3).eq(65536));
1823
2080
  // finite levels must NOT collapse (2{1}3 = 8, 2{2}3 = 16)
1824
2081
  ok("2{1}3 === 8 (finite unaffected)", new MetaNum(2).arrow(1)(3).eq(8));
1825
2082
  ok("2{2}3 === 16 (finite unaffected)", new MetaNum(2).arrow(2)(3).eq(16));
@@ -1866,11 +2123,12 @@ checkArr("BEAF(5,5,5,5,BEAF(5,5,5,5,5))", MetaNum.BEAF(5, 5, 5, 5, beafInner5),
1866
2123
  // expansion: largest-to-smallest evaluation; exact when it fits maxRows-1
1867
2124
  // rows, else base [10] + first kept row count +1
1868
2125
  // ─────────────────────────────────────
1869
- // {2,7,5,5} = 2{ω*4+5}7: rule 3 ends every limit step on the base 2, and
1870
- // 2-2=0 means every cascade count vanishes; 2{α}2 collapses through
1871
- // successors/limits down to the finite anchor 2{k}2=4 — result is exactly 4
1872
- checkBool("BEAF(2,7,5,5) = 4 (base-2 rule-3 collapse)",
1873
- MetaNum.BEAF(2, 7, 5, 5).eq(4), true);
2126
+ // {2,7,5,5} = 2{ω*4+5}7 = 2{ω*4+4}(2{ω*4+5}6) → … — under the unified rule
2127
+ // 2{λ}7 = 2{λ[7]}7 the value keeps growing; only the 2-diagonal collapses to
2128
+ // 4 (2{α}2 = 2{2}2), so the result exceeds 4 and the lower-argument form
2129
+ checkBool("BEAF(2,7,5,5) > 4 and grows with the constant term",
2130
+ MetaNum.BEAF(2, 7, 5, 5).gt(4) &&
2131
+ MetaNum.BEAF(2, 7, 4, 5).lt(MetaNum.BEAF(2, 7, 5, 5)), true);
1874
2132
  // {3,2,4,6} = 3{ω*5+4}2
1875
2133
  checkBool("BEAF(3,2,4,6) top row [1,2,5]",
1876
2134
  JSON.stringify(MetaNum.BEAF(3, 2, 4, 6).array[MetaNum.BEAF(3, 2, 4, 6).array.length - 1])
@@ -2740,7 +2998,7 @@ checkFormat("canonical all-8s keeps α=1 (G600)", "G600", "1.000G600");
2740
2998
  // carry — a cascade that would spell 20 letter types keeps its top two levels,
2741
2999
  // and a combination longer than multiLetterLimit switches to !αAaβ
2742
3000
  // ─────────────────────────────────────
2743
- checkFormat("20-row cascade compresses to two letter types", MetaNum.h10000(3, 10), "Iccc1.000Iccb10");
3001
+ checkFormat("20-row cascade compresses to two letter types", MetaNum.h10000(3, 10), "1.000Ijjk9");
2744
3002
  // a level whose letter name is longer than multiLetterLimit carries to the
2745
3003
  // SINGLE-letter form !αΓβ — "!" adds one ω^ layer on top of the level Γ names
2746
3004
  checkFormat("10-letter level carries to !1.000M9", MetaNum.iter(3, 10), "!1.000M9");
@@ -2754,6 +3012,23 @@ ok("apix(3,5) format round-trip", MetaNum(format(m3.aperixxate(5))).eq(m3.aperix
2754
3012
  checkFormat("short diagonal keeps the letter form", m3.aperixxate(3), "!2.000Aaaa10");
2755
3013
  checkFormat("cascade inner α stays [1,10) (AbAa600)", "AbAa600", "Ab1.000Aa600");
2756
3014
 
3015
+ // ─────────────────────────────────────
3016
+ // ω^ω-family tail-CNF markers: !Aa 整数形式/E形式/F形式/G形式/… 对应
3017
+ // ω^ω+ω^0/1/2/3/… 层级。The r0 tail-CNF digits spell as finOps letters
3018
+ // (E↔ω^1, F↔ω^2, G↔ω^3, …) after the Aa block, with the ω^0 coefficient c0
3019
+ // as the trailing integer — matching the parser's !AaE16 → r0=[16,1] finOps
3020
+ // convention, so every form round-trips exactly.
3021
+ // ─────────────────────────────────────
3022
+ checkFormat("!Aa integer form (ω^ω+1)", MetaNum(10).itermult(10), "!2.000Aa1");
3023
+ checkFormat("E form (ω^ω+ω, iteraperiate marker)", m3.iteraperiate(3), "!2.000AaE0");
3024
+ ok("E form round-trip", MetaNum(format(m3.iteraperiate(3))).eq(m3.iteraperiate(3)));
3025
+ checkFormat("F form (ω^ω+ω^2, cuboiter y=2)", MetaNum(10).cuboiter(2), "!2.000AaF10");
3026
+ ok("F form round-trip", MetaNum(format(MetaNum(10).cuboiter(2))).eq(MetaNum(10).cuboiter(2)));
3027
+ checkFormat("G form (ω^ω+ω^3, cuboiter y=3)", MetaNum(10).cuboiter(3), "!2.000AaG10");
3028
+ ok("G form round-trip", MetaNum(format(MetaNum(10).cuboiter(3))).eq(MetaNum(10).cuboiter(3)));
3029
+ // non-marker height tower chains at the ω^ω layer keep the legacy chain format
3030
+ checkFormat("height tower chain keeps the chain format", MetaNum(3).iterate(1.5e16), "!Aa1.500E16");
3031
+
2757
3032
  // ─────────────────────────────────────
2758
3033
  // issue #14: stacking the SAME function must nest the letter — the rows are a
2759
3034
  // composition, so the top row leads and the row below it (which collapses from
@@ -3009,8 +3284,8 @@ checkFormat("nested arrow(3,arrow(10,10000,10),3) → Aa1.000Aa10,000",
3009
3284
  // v2.0: rule 3 unification + pure dlsdl diagonal [2,10) convention
3010
3285
  // ─────────────────────────────────────────────────────────────────
3011
3286
  console.log("\n=== G6.6 diagonal letter convention ===");
3012
- // rule 3: n{λ}b = n{λ[b]}n
3013
- checkBool("aper(3,5) = 3{5}3", MetaNum.aperiote(3,5).eq(MetaNum(3).arrow(5)(3)), true);
3287
+ // rule 3: n{λ}b = n{λ[b]}b
3288
+ checkBool("aper(3,5) = 3{5}5", MetaNum.aperiote(3,5).eq(MetaNum(3).arrow(5)(5)), true);
3014
3289
  // diagonal letters (ending in 'a'): integer arguments all anchor at 2.000
3015
3290
  [10, 11, 50, 100].forEach(function (b) {
3016
3291
  checkFormat("10{100}" + b + " → 2.000Aa100", MetaNum.arrow(10, 100, b), "2.000Aa100");
@@ -3104,4 +3379,1426 @@ console.log("\n=== G6.8 MetaNum(...).format() instance method ===");
3104
3379
  // ─────────────────────────────────────
3105
3380
  // FORMAT_OPTIONS: every option must take effect. Each check flips the option
3106
3381
  // and asserts the display changes along the option's documented meaning.
3107
- // ─────────────────────────────────────
3382
+ // ─────────────────────────────────────
3383
+ console.log("\n=== G7.12 format() \"null\" regression ===");
3384
+ (function () {
3385
+ // inner r0 chain exceeding the repeat-letter budget used to leak the
3386
+ // literal string "null" into the output; it must fall through to the
3387
+ // Γ-canonical collapse instead. The value that triggered the leak is the
3388
+ // ω-diagonal x{10}x (the pre-unification aperiote); build it directly so
3389
+ // the regression stays pinned even though aperiote now anchors at y.
3390
+ var cases = [["3.3G5","N1.000G5"],["2.4G5","N1.000G5"],["1.5G8","N1.000G8"],["G5","N1.000G5"]];
3391
+ for (var i = 0; i < cases.length; i++) {
3392
+ var got = MetaNum(cases[i][0]).arrow(10)(MetaNum(cases[i][0])).format();
3393
+ checkBool("format(" + cases[i][0] + " ω-diagonal) = " + cases[i][1] + " (no \"null\")",
3394
+ got === cases[i][1], true, got === cases[i][1] ? "" : " got " + got);
3395
+ }
3396
+ // the unified aperiote x{ω}y = x{y}y outputs stay null-free as well
3397
+ var cases2 = [["3.3G5","1.007N10"],["2.4G5","1.007N10"],["1.5G8","1.008N10"],["G5","1.007N10"]];
3398
+ for (var k = 0; k < cases2.length; k++) {
3399
+ var got2 = MetaNum.h10(cases2[k][0], 10).format();
3400
+ checkBool("format(h10(" + cases2[k][0] + ",10)) = " + cases2[k][1] + " (no \"null\")",
3401
+ got2 === cases2[k][1], true, got2 === cases2[k][1] ? "" : " got " + got2);
3402
+ }
3403
+ })();
3404
+ console.log("\n=== G8.9 series and purchase contracts ===");
3405
+ (function () {
3406
+ function checkSeriesValue(name, got, expected) {
3407
+ checkBool(name, got instanceof MetaNum && got.eq(expected), true, "got=" + got + " expected=" + expected);
3408
+ }
3409
+ function independentCost(count, firstPrice, growth, geometric) {
3410
+ var total = 0;
3411
+ var price = firstPrice;
3412
+ for (var i = 0; i < count; i++) {
3413
+ total += price;
3414
+ price = geometric ? price * growth : price + growth;
3415
+ }
3416
+ return total;
3417
+ }
3418
+ function checkPurchase(name, got, resources, priceStart, growth, owned, expected, geometric) {
3419
+ var valid = got instanceof MetaNum && got.isFinite() && got.isint() && got.gte(0) && got.eq(expected);
3420
+ var count = got.toNumber();
3421
+ var firstPrice = geometric ? priceStart * Math.pow(growth, owned) : priceStart + growth * owned;
3422
+ var currentCost = independentCost(count, firstPrice, growth, geometric);
3423
+ var nextCost = independentCost(count + 1, firstPrice, growth, geometric);
3424
+ checkBool(name, valid && currentCost <= resources && nextCost > resources, true,
3425
+ "got=" + got + " cost=" + currentCost + " next=" + nextCost + " expected=" + expected);
3426
+ }
3427
+
3428
+ checkSeriesValue("geometric series uses exactly N items", MetaNum.sumGeometricSeries(5, 1, 2), 31);
3429
+ checkSeriesValue("arithmetic series uses exactly N items", MetaNum.sumArithmeticSeries(5, 1, 2), 25);
3430
+ checkSeriesValue("geometric series equal empty interval", MetaNum.sumGeometricSeries(5, 1, 2, 5), 0);
3431
+ checkSeriesValue("geometric series reverse empty interval", MetaNum.sumGeometricSeries(4, 1, 2, 5), 0);
3432
+ checkSeriesValue("arithmetic series equal empty interval", MetaNum.sumArithmeticSeries(5, 1, 2, 5), 0);
3433
+ checkSeriesValue("arithmetic series reverse empty interval", MetaNum.sumArithmeticSeries(4, 1, 2, 5), 0);
3434
+ checkSeriesValue("geometric series unit ratio", MetaNum.sumGeometricSeries(5, 3, 1), 15);
3435
+ checkSeriesValue("arithmetic series zero add", MetaNum.sumArithmeticSeries(5, 3, 0), 15);
3436
+ checkSeriesValue("geometric series nonzero start index", MetaNum.sumGeometricSeries(5, 3, 2, 2), 21);
3437
+ checkSeriesValue("arithmetic series nonzero start index", MetaNum.sumArithmeticSeries(5, 3, 2, 2), 15);
3438
+
3439
+ for (var n = 0; n <= 10; n++) {
3440
+ checkSeriesValue("geometric independent accumulation N=" + n,
3441
+ MetaNum.sumGeometricSeries(n, 2, 3), independentCost(n, 2, 3, true));
3442
+ checkSeriesValue("arithmetic independent accumulation N=" + n,
3443
+ MetaNum.sumArithmeticSeries(n, 2, 3), independentCost(n, 2, 3, false));
3444
+ }
3445
+
3446
+ var geometricCases = [
3447
+ [100, 1, 2, 0, 6], [100, 1, 2, 2, 4], [62, 1, 2, 0, 5],
3448
+ [63, 1, 2, 0, 6], [100, 2, 1, 7, 50], [0.5, 1, 2, 0, 0],
3449
+ [0, 1, 2, 0, 0], [1.4, 1, 0.5, 0, 1]
3450
+ ];
3451
+ for (var g = 0; g < geometricCases.length; g++) {
3452
+ var gc = geometricCases[g];
3453
+ checkPurchase("geometric purchase " + gc.join("/"),
3454
+ MetaNum.affordGeometricSeries(gc[0], gc[1], gc[2], gc[3]), gc[0], gc[1], gc[2], gc[3], gc[4], true);
3455
+ }
3456
+ checkBool("geometric purchase at decreasing-ratio supremum",
3457
+ MetaNum.affordGeometricSeries(2, 1, 0.5, 0).eq(MetaNum.POSITIVE_INFINITY), true);
3458
+ checkBool("geometric purchase NaN propagation",
3459
+ MetaNum.affordGeometricSeries(MetaNum.NaN, 1, 2, 0).isNaN(), true);
3460
+
3461
+ var arithmeticCases = [
3462
+ [100, 1, 2, 0, 10], [100, 1, 2, 2, 8], [99, 1, 2, 0, 9],
3463
+ [100, 2, 0, 7, 50], [0.5, 1, 2, 0, 0], [0, 1, 2, 0, 0]
3464
+ ];
3465
+ for (var a = 0; a < arithmeticCases.length; a++) {
3466
+ var ac = arithmeticCases[a];
3467
+ checkPurchase("arithmetic purchase " + ac.join("/"),
3468
+ MetaNum.affordArithmeticSeries(ac[0], ac[1], ac[2], ac[3]), ac[0], ac[1], ac[2], ac[3], ac[4], false);
3469
+ }
3470
+ checkBool("arithmetic purchase NaN propagation",
3471
+ MetaNum.affordArithmeticSeries(MetaNum.NaN, 1, 2, 0).isNaN(), true);
3472
+ })();
3473
+ console.log("\n=== G8.10 formatting exports and exact-token contracts ===");
3474
+ (function () {
3475
+ var fmt = require("./format-metanum.js");
3476
+ var exportNames = ["format", "formatFull", "formatWhole", "formatSmall", "formatSingleLetterType",
3477
+ "metaPolarize", "letterName", "symbolName", "getOrdinalLetter", "formatR0AsChain", "FORMAT_OPTIONS",
3478
+ "polarizeFiniteChain", "gammaArgOf", "formatGammaBinary"];
3479
+ for (var i = 0; i < exportNames.length; i++) {
3480
+ var expectedType = exportNames[i] === "FORMAT_OPTIONS" ? "object" : "function";
3481
+ checkBool("format export " + exportNames[i], typeof fmt[exportNames[i]] === expectedType, true);
3482
+ }
3483
+ var savedLimit = fmt.FORMAT_OPTIONS.multiLetterLimit;
3484
+ try {
3485
+ fmt.FORMAT_OPTIONS.multiLetterLimit = 4;
3486
+ checkBool("multiLetterLimit keeps length at limit", fmt.format(MetaNum("Aaaa10")) === "2.000Aaaa10", true);
3487
+ checkBool("multiLetterLimit carries ordinary overflow", fmt.format(MetaNum("Aaaab10")) === "!1.000H10", true);
3488
+ checkBool("multiLetterLimit preserves exact diagonal token", fmt.format(MetaNum("Aaaaa10")) === "Aaaaa10", true);
3489
+ ["Aaaaa3.5", "Aaaaa5", "Aaaaa10"].forEach(function (token) {
3490
+ var value = MetaNum(token);
3491
+ checkBool("exact token round-trip " + token, MetaNum(fmt.format(value)).eq(value), true);
3492
+ });
3493
+ } finally {
3494
+ fmt.FORMAT_OPTIONS.multiLetterLimit = savedLimit;
3495
+ }
3496
+ })();
3497
+
3498
+ console.log("\n=== G8.11 documented public behavior ===");
3499
+ (function () {
3500
+ var fmt = require("./format-metanum.js");
3501
+ checkBool("README aper(3)", MetaNum(2).aper(3).eq(65536), true);
3502
+
3503
+ var savedRows = MetaNum.maxRows;
3504
+ var savedCols = MetaNum.maxCols;
3505
+ try {
3506
+ MetaNum.maxRows = 20;
3507
+ MetaNum.maxCols = 20;
3508
+ checkArr("README Hardy base and eight trailing tens", MetaNum.hardy("1e10+0.5"),
3509
+ [[4581.009607833985,10,10,10,10,10,10,10,10]]);
3510
+ checkArr("README h100 maxRows=20", MetaNum(10).h100(20),
3511
+ [[10],[9,1,19],[8,2,19],[8,3,19],[8,4,19],[8,5,19],[8,6,19],[8,7,19],[8,8,19],[8,9,19],
3512
+ [8,10,19],[8,11,19],[8,12,19],[8,13,19],[8,14,19],[8,15,19],[8,16,19],[8,17,19],[8,18,19],[18,19,19]]);
3513
+ MetaNum.maxRows = 50;
3514
+ checkArr("README h100 maxRows=50", MetaNum(10).h100(20),
3515
+ [[10],[9,1,16],[8,2,16],[8,3,16],[8,4,16],[8,5,16],[8,6,16],[8,7,16],[8,8,16],[8,9,16],
3516
+ [8,0,17],[8,1,17],[8,2,17],[8,3,17],[8,4,17],[8,5,17],[8,6,17],[8,7,17],[8,8,17],[8,9,17],
3517
+ [8,0,18],[8,1,18],[8,2,18],[8,3,18],[8,4,18],[8,5,18],[8,6,18],[8,7,18],[8,8,18],[8,9,18],
3518
+ [8,0,19],[8,1,19],[8,2,19],[8,3,19],[8,4,19],[8,5,19],[8,6,19],[8,7,19],[8,8,19],[8,9,19],
3519
+ [8,10,19],[8,11,19],[8,12,19],[8,13,19],[8,14,19],[8,15,19],[8,16,19],[8,17,19],[8,18,19],[18,19,19]]);
3520
+ MetaNum.maxRows = 20;
3521
+ checkArr("README h13 base 10", MetaNum(10).h13(20),
3522
+ [[10000000000,8,8,8,8,8,8,8,8,8],[8,0,1],[8,1,1],[18,2,1]]);
3523
+ checkArr("README h13 base 3", MetaNum(3).h13(20),
3524
+ [[3638334640023.7783,7625597484984],[1,0,1],[1,1,1],[18,2,1]]);
3525
+ } finally {
3526
+ MetaNum.maxRows = savedRows;
3527
+ MetaNum.maxCols = savedCols;
3528
+ }
3529
+ checkBool("README Hyper-E text", MetaNum(100).toHyperE() === "E2", true);
3530
+ checkArr("README fromArray normalization", MetaNum.fromArray([1e10,520.73,1]), [[10000000000,520,1]]);
3531
+ checkBool("README BEAF omega+1 base 2", MetaNum.BEAF(2,2,1,2).eq(4), true);
3532
+ checkBool("README BEAF omega+1 distinguishable base", MetaNum.BEAF(3,3,1,2).eq(MetaNum(3).h11(3)), true);
3533
+ checkBool("README slog approximation", Math.abs(MetaNum(65536).slog().toNumber() - 1.8342488308601794) <= 1e-12, true);
3534
+ ["Ab", "Ba", "Bb", "Aaa"].forEach(function (prefix) {
3535
+ checkBool("README prefix preserved " + prefix,
3536
+ fmt.format(MetaNum(prefix + "GGFFE8.072E153")) === prefix + "GG3.340G3", true);
3537
+ });
3538
+ })();
3539
+
3540
+ console.log("\n=== G8.12 formatting helper examples ===");
3541
+ (function () {
3542
+ var fmt = require("./format-metanum.js");
3543
+ checkBool("formatWhole example", fmt.formatWhole(MetaNum(1234.56)) === "1,234", true);
3544
+ checkBool("formatSmall example", fmt.formatSmall(MetaNum(0.0001)) === "1.000E-4", true);
3545
+ checkBool("metaPolarize example", JSON.stringify(fmt.metaPolarize([100])) ===
3546
+ JSON.stringify({bottom:1,top:2,height:1,repeat:1}), true);
3547
+ checkBool("letterName example", fmt.letterName(699) === "Aaa", true);
3548
+ checkBool("symbolName examples", fmt.symbolName(0) === "" && fmt.symbolName(1) === "!", true);
3549
+ checkBool("getOrdinalLetter examples", fmt.getOrdinalLetter([[1,0,0,1]]) === "Aaa" && fmt.getOrdinalLetter([]) === null, true);
3550
+ checkBool("formatR0AsChain example", fmt.formatR0AsChain([10,1,2],3) === "FF1.000E10", true);
3551
+ var chainValue = MetaNum.arrow(3,100,3);
3552
+ var polarized = fmt.polarizeFiniteChain(chainValue.array[0], chainValue.array.slice(1));
3553
+ checkBool("polarizeFiniteChain example", polarized !== null &&
3554
+ Math.abs(polarized.bottom - 2.3758120875933075) <= 1e-12 && polarized.repeation === 2 && polarized.arrows === 99, true);
3555
+ var gammaArg = fmt.gammaArgOf(MetaNum("G5"),3,40);
3556
+ checkBool("gammaArgOf example", gammaArg !== null && Math.abs(gammaArg - 5) <= 1e-9, true);
3557
+ checkBool("formatGammaBinary example", fmt.formatGammaBinary(5.5,3,3) === "3.162G5", true);
3558
+ })();
3559
+ console.log("\n=== G8.13 README contract structure ===");
3560
+ (function () {
3561
+ var readme = require("fs").readFileSync("README.md", "utf8");
3562
+ var changelog = readme.split("# Changelog")[1] || "";
3563
+ checkBool("README has one v2.2.0 changelog entry", (changelog.match(/v2\.2\.0/g) || []).length === 1, true);
3564
+ checkBool("README v2.2.0 keeps all capability categories",
3565
+ // terms follow the maintainer-rewritten v2.2.0 entry (2026-11-24): the old
3566
+ // literal-null wording was folded into "fix formatting" in the changelog
3567
+ ["limit rules", "iteraperiate", "root forms", "formatting", "large-base"].every(function (term) {
3568
+ return changelog.indexOf(term) !== -1;
3569
+ }), true);
3570
+ var limitLine = readme.split("\n").filter(function (line) { return line.indexOf("multiLetterLimit") !== -1 && line.indexOf("// 13.") !== -1; })[0] || "";
3571
+ var historyLine = readme.split("\n").filter(function (line) { return line.indexOf("v2.1.1") !== -1; })[0] || "";
3572
+ checkBool("README multiLetterLimit ordinary and exact rules",
3573
+ limitLine.indexOf("Ordinary") !== -1 && limitLine.indexOf("Exact") !== -1 && limitLine.indexOf("64-token") !== -1, true);
3574
+ checkBool("README v2.1.1 ordinary and exact rules",
3575
+ historyLine.indexOf("ordinary") !== -1 && historyLine.indexOf("exact diagonal tokens") !== -1, true);
3576
+ var helperDocs = readme.split("### Formatting helper API")[1] || "";
3577
+ helperDocs = helperDocs.split("**Canonical chain**")[0];
3578
+ var helpers = ["formatWhole", "formatSmall", "metaPolarize", "letterName", "symbolName", "getOrdinalLetter",
3579
+ "formatR0AsChain", "polarizeFiniteChain", "gammaArgOf", "formatGammaBinary"];
3580
+ for (var i = 0; i < helpers.length; i++) {
3581
+ var row = helperDocs.split("\n").filter(function (line) { return line.indexOf("`" + helpers[i]) !== -1; })[0] || "";
3582
+ checkBool("README helper contract " + helpers[i], row.indexOf("→") !== -1 && row.split("|").length >= 5, true);
3583
+ }
3584
+ })();
3585
+
3586
+
3587
+ // ═══════════════════════════════════════════════════════════════════════════
3588
+ // G9 hyper_inv: continuous real-number log/root inverses
3589
+ // (spec .codeartsdoer/specs/hyper_inv/spec.md sections 5.1–5.8,
3590
+ // design.md sections 2.1–2.7, tasks 10.1–12.5)
3591
+ // G9.0 checkInverseCase reporter + evidence bookkeeping (10.1)
3592
+ // G9.1 reporter self-check: injected failure is detectable (10.1)
3593
+ // G9.2 full registry, aliases, parameter order, options (10.2)
3594
+ // G9.3 closed-form non-integer / known integer / sign / reciprocal (10.3)
3595
+ // G9.4 forward anchors and inverse substitution use one forward (10.4)
3596
+ // G9.5 per-family integer / non-integer height and base matrix (11.1)
3597
+ // G9.6 round-trip vs. substitution residual separation (11.2)
3598
+ // G9.7 successor break points m±δ (11.3)
3599
+ // G9.8 fundamental-sequence break points + fractional coefficient (11.4)
3600
+ // G9.9 domain boundaries, multi/no-solution, invalid & non-finite (12.1)
3601
+ // G9.10 markers, saturation, truncation, COEFF/MSI/cap, minimality (12.2)
3602
+ // G9.11 large numbers, tolerance ladder, numeric strings, underflow (12.3)
3603
+ // G9.12 failure injection: budgets, stagnation, fallback, overflow (12.4)
3604
+ // G9.13 input immutability, config isolation, determinism (12.5)
3605
+ // G9.14 summary + process gate (10.1 / 14.2)
3606
+ // ═══════════════════════════════════════════════════════════════════════════
3607
+ console.log("\n=== G9.0 inverse test harness ===");
3608
+
3609
+ var INVERSE_STATS = {
3610
+ total: 0, pass: 0, fail: 0, error: 0, skipped: 0,
3611
+ evidence: { "definition-guaranteed": 0, "representation-level": 0, "numerical-experiment": 0, "not-applicable": 0 },
3612
+ categories: {}, failedCases: []
3613
+ };
3614
+
3615
+ function inverseValueSummary(v) {
3616
+ if (!(v instanceof MetaNum)) return String(v);
3617
+ var arr = JSON.stringify(v.array);
3618
+ if (arr.length > 48) arr = arr.slice(0, 45) + "...";
3619
+ return v.toString().slice(0, 40) + " {sign=" + v.sign + ",layer=" + v.layer + ",array=" + arr + "}";
3620
+ }
3621
+
3622
+ function inverseFailureCategory(status, termination, expectedFailure) {
3623
+ if (expectedFailure) return "expected-outcome";
3624
+ if (status === "non-converged" || status === "bracketing-failed" || status === "stagnated") return "numeric-non-convergence";
3625
+ if (status === "unrecoverable" || status === "unrepresentable" || status === "unsupported-domain") return "representation-unrecoverable";
3626
+ return "requirement-unsatisfied";
3627
+ }
3628
+
3629
+ // checkInverseCase: one line per case with the full spec 10.1 record.
3630
+ // spec = { caseId, requirement, operation, direction, call, run, note,
3631
+ // expect: { status:[..], value, approx:{to,tol}, isNaN, isint,
3632
+ // termination:[..], multipleSolutions, representationLevel,
3633
+ // legacyAnchor, minimalityAttained, residualKind, check },
3634
+ // solError: { from, tol }, residualMax, reproduce: { forward, target } }
3635
+ function checkInverseCase(spec) {
3636
+ var id = spec.caseId, req = spec.requirement || "";
3637
+ INVERSE_STATS.total++;
3638
+ if (spec.run === false) {
3639
+ INVERSE_STATS.skipped++;
3640
+ console.log("SKIP | INV " + id + " | " + req + " | reason: " + (spec.note || "not executed"));
3641
+ return;
3642
+ }
3643
+ var result;
3644
+ try { result = spec.call(); }
3645
+ catch (e) {
3646
+ INVERSE_STATS.error++;
3647
+ INVERSE_STATS.categories["test-environment-error"] = (INVERSE_STATS.categories["test-environment-error"] || 0) + 1;
3648
+ INVERSE_STATS.failedCases.push(id + "(error)");
3649
+ console.log("ERROR | INV " + id + " | " + req + " | call threw: " + e.message);
3650
+ return;
3651
+ }
3652
+ var isResult = result !== null && typeof result === "object" && typeof result.status === "string";
3653
+ var value = isResult ? result.value : result;
3654
+ var problems = [];
3655
+ var expectedFailure = false;
3656
+ var exp = spec.expect || {};
3657
+ if (exp.isNaN) expectedFailure = true;
3658
+ if (exp.status && typeof exp.status === "string") exp.status = [exp.status];
3659
+ if (!isResult && (exp.status || exp.termination || exp.multipleSolutions !== undefined ||
3660
+ exp.representationLevel !== undefined || exp.legacyAnchor !== undefined ||
3661
+ exp.minimalityAttained !== undefined || spec.residualMax !== undefined || spec.residualKind)) {
3662
+ problems.push("diagnostic fields requested but the call returned a plain MetaNum");
3663
+ }
3664
+ if (isResult) {
3665
+ if (exp.status && exp.status.indexOf(result.status) === -1) problems.push("status " + result.status + " not in [" + exp.status.join(",") + "]");
3666
+ if (exp.termination) {
3667
+ if (typeof exp.termination === "string") exp.termination = [exp.termination];
3668
+ if (exp.termination.indexOf(result.termination) === -1) problems.push("termination " + result.termination + " not in [" + exp.termination.join(",") + "]");
3669
+ }
3670
+ if (exp.multipleSolutions !== undefined && result.multipleSolutions !== exp.multipleSolutions) problems.push("multipleSolutions=" + result.multipleSolutions);
3671
+ if (exp.representationLevel !== undefined && result.representationLevel !== exp.representationLevel) problems.push("representationLevel=" + result.representationLevel);
3672
+ if (exp.legacyAnchor !== undefined && result.legacyAnchor !== exp.legacyAnchor) problems.push("legacyAnchor=" + result.legacyAnchor);
3673
+ if (exp.minimalityAttained !== undefined && result.minimalityAttained !== exp.minimalityAttained) problems.push("minimalityAttained=" + result.minimalityAttained);
3674
+ if (exp.residualKind && (!result.residual || result.residual.kind !== exp.residualKind)) problems.push("residualKind=" + (result.residual && result.residual.kind));
3675
+ if (spec.residualMax !== undefined) {
3676
+ var rel = result.residual && result.residual.relative;
3677
+ var cmpv = result.residual && result.residual.comparison;
3678
+ if (rel === null || rel === undefined) {
3679
+ if (cmpv !== 0) problems.push("no faithful residual evidence (kind=" + (result.residual && result.residual.kind) + ", cmp=" + cmpv + ")");
3680
+ } else if (rel > spec.residualMax) problems.push("R_rel=" + rel + " > " + spec.residualMax);
3681
+ }
3682
+ }
3683
+ if (exp.isNaN) { if (!(value instanceof MetaNum) || !value.isNaN()) problems.push("expected NaN, got " + inverseValueSummary(value)); }
3684
+ else if (!exp.allowNaN && (value === undefined || value === null || !(value instanceof MetaNum) || value.isNaN())) {
3685
+ problems.push("expected a finite MetaNum, got " + inverseValueSummary(value));
3686
+ } else {
3687
+ if (exp.value !== undefined && !value.eq(MetaNum(exp.value))) problems.push("value " + inverseValueSummary(value) + " != " + MetaNum(exp.value).toString());
3688
+ if (exp.approx) {
3689
+ var got = value.toNumber();
3690
+ if (!Number.isFinite(got) || Math.abs(got - exp.approx.to) > exp.approx.tol * Math.max(1, Math.abs(exp.approx.to)))
3691
+ problems.push("value " + inverseValueSummary(value) + " outside " + exp.approx.to + "±" + exp.approx.tol);
3692
+ }
3693
+ if (exp.isint !== undefined && value.isint() !== exp.isint) problems.push("isint=" + value.isint() + " expected " + exp.isint);
3694
+ if (spec.solError) {
3695
+ var se = value.sub(MetaNum(spec.solError.from)).toNumber();
3696
+ if (!Number.isFinite(se) || Math.abs(se) > spec.solError.tol * Math.max(1, Math.abs(spec.solError.from)))
3697
+ problems.push("solution error " + se + " > " + spec.solError.tol + "*max(1,|" + spec.solError.from + "|)");
3698
+ }
3699
+ if (spec.reproduce && !(value instanceof MetaNum && value.isNaN())) {
3700
+ // exact anchors reproduce with strict cmp==0; approximate solutions may
3701
+ // instead show a faithfully computable R_rel <= 1e-9 (spec 5.6.1(6))
3702
+ var fwd = spec.reproduce.forward(value), tgt = MetaNum(spec.reproduce.target);
3703
+ var reproduced = fwd instanceof MetaNum && fwd.cmp(tgt) === 0;
3704
+ if (!reproduced && fwd instanceof MetaNum && !fwd.isNaN() && !tgt.isNaN()) {
3705
+ var fn = fwd.toNumber(), tn = tgt.toNumber();
3706
+ if (Number.isFinite(fn) && Number.isFinite(tn)) reproduced = Math.abs(fn - tn) / Math.max(1, Math.abs(tn)) <= 1e-9;
3707
+ }
3708
+ if (!reproduced) problems.push("forward substitution did not reproduce the target");
3709
+ }
3710
+ }
3711
+ var customCheck = exp.check || spec.check;
3712
+ if (customCheck) { var extra = customCheck(result, value); if (extra && extra.length) problems = problems.concat(extra); }
3713
+ var cat = inverseFailureCategory(isResult ? result.status : "(value)", isResult ? result.termination : "", expectedFailure);
3714
+ var evidence = isResult ? (result.evidence || "not-applicable") : "not-applicable";
3715
+ var line = (isResult ? result.status : "value") + " value=" + (value instanceof MetaNum ? value.toString().slice(0, 26) : String(value)) +
3716
+ " term=" + (isResult ? result.termination : "-") +
3717
+ " | solErr=" + (spec.solError ? spec.solError.tol : "-") +
3718
+ " res=" + (isResult && result.residual ? result.residual.kind + "/" + (result.residual.relative === null ? "null" : result.residual.relative) : "-") +
3719
+ " | it/exp/fw/fb=" + (isResult ? [result.iterations, result.expansions, result.forwardEvaluations, result.fallbackCount].join("/") : "-/-/-/-") +
3720
+ " | flags=" + (isResult ? [result.multipleSolutions ? "M" : "-", result.representationLevel ? "R" : "-", result.legacyAnchor ? "L" : "-"].join("") : "-") +
3721
+ " | " + evidence;
3722
+ if (problems.length === 0) {
3723
+ INVERSE_STATS.pass++;
3724
+ INVERSE_STATS.evidence[evidence] = (INVERSE_STATS.evidence[evidence] || 0) + 1;
3725
+ if (!expectedFailure) INVERSE_STATS.categories["expected-outcome"] = (INVERSE_STATS.categories["expected-outcome"] || 0) + 1;
3726
+ else INVERSE_STATS.categories[cat] = (INVERSE_STATS.categories[cat] || 0) + 1;
3727
+ console.log("PASS | INV " + id + " | " + req + " | " + (spec.operation || "") + " " + (spec.direction || "") + " | " + line +
3728
+ (spec.note ? " | note: " + spec.note : ""));
3729
+ } else {
3730
+ INVERSE_STATS.fail++;
3731
+ INVERSE_STATS.categories[cat] = (INVERSE_STATS.categories[cat] || 0) + 1;
3732
+ INVERSE_STATS.failedCases.push(id);
3733
+ console.log("FAIL | INV " + id + " | " + req + " | " + (spec.operation || "") + " " + (spec.direction || "") + " | " + line +
3734
+ " | PROBLEMS: " + problems.join("; "));
3735
+ if (value instanceof MetaNum) console.log(" value detail: " + inverseValueSummary(value));
3736
+ }
3737
+ }
3738
+
3739
+ // G9.1 the reporter itself must be able to see an injected failure (10.1).
3740
+ // The injected FAIL line is captured BEFORE it reaches the process gate and
3741
+ // the bookkeeping is restored, so the self-check never contaminates the gate.
3742
+ (function () {
3743
+ var captured = [];
3744
+ var outerLog = console.log;
3745
+ var savedGateFail = GATE_COUNTS.fail;
3746
+ console.log = function () { captured.push(Array.prototype.join.call(arguments, " ")); };
3747
+ var savedStats = JSON.stringify({ pass: INVERSE_STATS.pass, fail: INVERSE_STATS.fail, total: INVERSE_STATS.total,
3748
+ categories: INVERSE_STATS.categories, failedCases: INVERSE_STATS.failedCases });
3749
+ try {
3750
+ checkInverseCase({
3751
+ caseId: "G9.1.injected", requirement: "10.1 injected failure detection", operation: "harness", direction: "-",
3752
+ call: function () { return MetaNum.hyper_log(7, 2, 0, { diagnostics: true }); },
3753
+ expect: { status: ["wrong-on-purpose"] }
3754
+ });
3755
+ } finally {
3756
+ console.log = outerLog;
3757
+ var restored = JSON.parse(savedStats);
3758
+ INVERSE_STATS.pass = restored.pass; INVERSE_STATS.fail = restored.fail; INVERSE_STATS.total = restored.total;
3759
+ INVERSE_STATS.categories = restored.categories; INVERSE_STATS.failedCases = restored.failedCases;
3760
+ }
3761
+ var injectedLine = captured.filter(function (l) { return l.indexOf("FAIL | INV G9.1.injected") === 0; })[0] || "";
3762
+ checkInverseCase({
3763
+ caseId: "G9.1.1", requirement: "10.1 injected failure is detectable and does not leak into the gate",
3764
+ operation: "harness", direction: "-", call: function () { return MetaNum(1); },
3765
+ expect: { value: 1, check: function () {
3766
+ var p = [];
3767
+ if (!injectedLine) p.push("injected case produced no FAIL line");
3768
+ if (injectedLine.indexOf("PROBLEMS: status exact not in [wrong-on-purpose]") === -1) p.push("FAIL line lacks the problem detail");
3769
+ if (GATE_COUNTS.fail !== savedGateFail) p.push("injected FAIL reached the process gate");
3770
+ if (INVERSE_STATS.fail !== 0) p.push("injected FAIL stayed in the stats");
3771
+ return p;
3772
+ } },
3773
+ note: "injected line captured: " + injectedLine.slice(0, 90)
3774
+ });
3775
+ checkInverseCase({
3776
+ caseId: "G9.1.2", requirement: "10.1 pass-line format carries status/value/termination/residual/counts/evidence",
3777
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(7, 2, 0); },
3778
+ expect: { value: 3.5, isint: false }, solError: { from: 3.5, tol: 1e-12 }
3779
+ });
3780
+ })();
3781
+
3782
+ // ───────────────────────────────────────────────────────────────────────────
3783
+ // G9.2 full registry, aliases, parameter order and options (tasks 10.2)
3784
+ // ───────────────────────────────────────────────────────────────────────────
3785
+ console.log("\n=== G9.2 registry, aliases, parameter order, options ===");
3786
+ // design.md 2.1.4 — one row per named ordinal operation:
3787
+ // [op, log short, log code, root short, root code, base-independent marker?]
3788
+ var INV_REGISTRY = [
3789
+ ["aperiote", "i_aper", "i10", "r_aper", "r10", false],
3790
+ ["expande", "i_expa", "i11", "r_expa", "r11", false],
3791
+ ["multiexpande", "i_muea", "i12", "r_muea", "r12", false],
3792
+ ["powerexpande", "i_poea", "i13", "r_poea", "r13", false],
3793
+ ["aperioexpande", "i_apea", "i20", "r_apea", "r20", false],
3794
+ ["explode", "i_expl", "i21", "r_expl", "r21", false],
3795
+ ["multiexplode", "i_muel", "i22", "r_muel", "r22", false],
3796
+ ["aperioexplode", "i_apel", "i30", "r_apel", "r30", false],
3797
+ ["detonate", "i_deto", "i31", "r_deto", "r31", false],
3798
+ ["aperiodetonate", "i_apdt", "i40", "r_apdt", "r40", false],
3799
+ ["aperionate", "i_apeo", "i100", "r_apeo", "r100", false],
3800
+ ["megote", "i_mego", "i101", "r_mego", "r101", false],
3801
+ ["multimegote", "i_mume", "i102", "r_mume", "r102", false],
3802
+ ["aperimegote", "i_apmg", "i110", "r_apmg", "r110", false],
3803
+ ["megoexpande", "i_mgea", "i111", "r_mgea", "r111", false],
3804
+ ["aperimegoexpande", "i_apme", "i120", "r_apme", "r120", false],
3805
+ ["megoaperionate", "i_mgao", "i200", "r_mgao", "r200", false],
3806
+ ["gigote", "i_gigo", "i201", "r_gigo", "r201", false],
3807
+ ["aperigigote", "i_apgg", "i210", "r_apgg", "r210", false],
3808
+ ["gigoaperionate", "i_ggap", "i300", "r_ggap", "r300", false],
3809
+ ["aperiatote", "i_apat", "i1000", "r_apat", "r1000", false],
3810
+ ["powiainate", "i_pwan", "i1001", "r_pwan", "r1001", false],
3811
+ ["expandainate", "i_epan", "i1010", "r_epan", "r1010", false],
3812
+ ["megodainate", "i_mgan", "i1100", "r_mgan", "r1100", false],
3813
+ ["powiairate", "i_pwar", "i2000", "r_pwar", "r2000", false],
3814
+ ["aperioguate", "i_apgu", "i10000", "r_apgu", "r10000", false],
3815
+ ["iterate", "iww", null, "r_iter", "rww", false],
3816
+ ["itermult", "i_itmu", "iw01", "r_itmu", "rw01", true],
3817
+ ["iteraperiate", "i_itap", "iw0w", "r_itap", "rw0w", true],
3818
+ ["cuboiter", "i_cube", "iwx2", "r_cube", "rwx2", true],
3819
+ ["expoiter", "i_expo", "iwa1", "r_expo", "rwa1", true],
3820
+ ["trioterate", "i_tria", "iwm2", "r_tria", "rwm2", true],
3821
+ ["trixxate", "i_trix", "iwp2", "r_trix", "rwp2", true],
3822
+ ["aperixxate", "i_apix", "iwpw", "r_apix", "rwpw", true],
3823
+ ["epsilonate", "i_epsl", "iepsl", "r_epsl", "repsl", true]
3824
+ ];
3825
+ var INV_DIAG = { diagnostics: true };
3826
+ function invNames(row) {
3827
+ var names = { log: ["inv_" + row[0]], root: [row[0] + "_root", "root_" + row[0], row[3], row[4]] };
3828
+ if (row[1]) names.log.push(row[1]);
3829
+ if (row[2]) names.log.push(row[2]);
3830
+ if (row[0] === "iterate") names.log.push("inv_iter");
3831
+ return names;
3832
+ }
3833
+ (function () {
3834
+ var missing = [];
3835
+ for (var i = 0; i < INV_REGISTRY.length; i++) {
3836
+ var names = invNames(INV_REGISTRY[i]);
3837
+ var all = [INV_REGISTRY[i][0]].concat(names.log, names.root);
3838
+ for (var k = 0; k < all.length; k++) {
3839
+ if (typeof MetaNum(3)[all[k]] !== "function") missing.push("instance " + all[k]);
3840
+ if (typeof MetaNum[all[k]] !== "function") missing.push("static " + all[k]);
3841
+ }
3842
+ }
3843
+ checkInverseCase({
3844
+ caseId: "G9.2.1", requirement: "10.2 / spec 5.2.1(5) every registered op has forward, inv_*, i_*, <op>_root, r_* and the new root_<op> on instance and static",
3845
+ operation: "registry", direction: "-", call: function () { return MetaNum(1); },
3846
+ expect: { value: 1, check: function () { return missing; } },
3847
+ note: INV_REGISTRY.length + " ops; missing=" + (missing.length ? missing.join(",") : "none")
3848
+ });
3849
+ // iteraperiate's seven specified inverse names + inv_iter (spec 5.4.1 b)
3850
+ var v = MetaNum(10).iteraperiate(5), vi = MetaNum(10).iterate(5);
3851
+ // the finite-height marker is the constant ω^ω+ω level marker, so every
3852
+ // inverse name returns the minimal reproducing height 2
3853
+ var itapLog = ["inv_iteraperiate", "i_itap", "iw0w"], itapRoot = ["iteraperiate_root", "root_iteraperiate", "r_itap", "rw0w"];
3854
+ var bad = [], badR = [];
3855
+ itapLog.forEach(function (n) {
3856
+ if (!v[n](10).eq(2)) bad.push("instance " + n);
3857
+ if (!MetaNum[n](v, 10).eq(2)) bad.push("static " + n);
3858
+ });
3859
+ itapRoot.forEach(function (n) {
3860
+ if (!v[n](5).eq(2)) badR.push("instance " + n);
3861
+ if (!MetaNum[n](v, 5).eq(2)) badR.push("static " + n);
3862
+ });
3863
+ if (!vi.inv_iter(10).eq(5)) bad.push("instance inv_iter");
3864
+ if (!MetaNum.inv_iter(vi, 10).eq(5)) bad.push("static inv_iter");
3865
+ checkInverseCase({ caseId: "G9.2.2", requirement: "10.2 iteraperiate: inv_iteraperiate/i_itap/iw0w and root_iteraperiate/iteraperiate_root/r_itap/rw0w all exist and agree on the minimal reproducing height 2; inv_iter kept",
3866
+ operation: "iteraperiate", direction: "log+root", call: function () { return v.inv_iteraperiate(10, INV_DIAG); },
3867
+ expect: { status: ["exact", "approximate"], value: 2, check: function () { return bad.concat(badR); } } });
3868
+ // alias / form equivalence for every op at integer height 3 (value level)
3869
+ var mism = [];
3870
+ var markerRoots = 0;
3871
+ for (var j = 0; j < INV_REGISTRY.length; j++) {
3872
+ var row = INV_REGISTRY[j], op = row[0];
3873
+ var target = MetaNum(3)[op](3);
3874
+ var names2 = invNames(row);
3875
+ var refLog = target["inv_" + op](3);
3876
+ names2.log.forEach(function (n) {
3877
+ if (!target[n](3).eq(refLog)) mism.push(op + "." + n + "(instance)");
3878
+ if (!MetaNum[n](target, 3).eq(refLog)) mism.push(op + "." + n + "(static)");
3879
+ });
3880
+ var refRoot = target[op + "_root"](3);
3881
+ if (!refRoot.eq(row[5] ? 2 : 3)) mism.push(op + " root value " + refRoot.toString());
3882
+ if (row[5]) markerRoots++;
3883
+ names2.root.forEach(function (n) {
3884
+ if (!target[n](3).eq(refRoot)) mism.push(op + "." + n + "(instance)");
3885
+ if (!MetaNum[n](target, 3).eq(refRoot)) mism.push(op + "." + n + "(static)");
3886
+ });
3887
+ }
3888
+ checkInverseCase({ caseId: "G9.2.3", requirement: "10.2 all aliases/forms return the same MetaNum value as inv_<op>/<op>_root (integer height 3, base 3)",
3889
+ operation: "registry", direction: "log+root", call: function () { return MetaNum(1); },
3890
+ expect: { value: 1, check: function () { return mism; } },
3891
+ note: "marker (base-independent) root ops=" + markerRoots + " -> root 2; structural root ops -> 3" });
3892
+ // status-level equivalence incl. options tail for one structural and one marker op
3893
+ [["aperiote", 3], ["iteraperiate", 2]].forEach(function (pair) {
3894
+ var op = pair[0], want = pair[1];
3895
+ var t = MetaNum(3)[op](3);
3896
+ var a = t["inv_" + op](3, INV_DIAG), b = t[invNames(INV_REGISTRY.filter(function (r) { return r[0] === op; })[0]).log[1]](3, INV_DIAG);
3897
+ var c1 = t[op + "_root"](3, INV_DIAG), d = t["root_" + op](3, INV_DIAG), e = MetaNum[op + "_root"](t, 3, INV_DIAG);
3898
+ checkInverseCase({ caseId: "G9.2.4." + op, requirement: "10.2 same input + options => same status/termination through long name, alias, root_<op>, static",
3899
+ operation: op, direction: "log+root", call: function () { return a; },
3900
+ expect: { status: ["exact", "approximate", "minimal-reproducing"], check: function () {
3901
+ var p = [];
3902
+ if (b.status !== a.status || b.value.eq(a.value) === false) p.push("alias status/value differ");
3903
+ [c1, d, e].forEach(function (r) { if (r.status !== c1.status || !r.value.eq(c1.value)) p.push("root alias differs"); });
3904
+ if (!c1.value.eq(want)) p.push("root value " + c1.value.toString());
3905
+ return p;
3906
+ } } });
3907
+ });
3908
+ // parameter order (spec 5.2.1 1-4)
3909
+ var w15 = MetaNum(10).aperiote(15);
3910
+ checkInverseCase({ caseId: "G9.2.5", requirement: "10.2 / spec 5.2.1 named log order (c first, fixed base n second) and root order (c first, fixed height b second)",
3911
+ operation: "aperiote", direction: "log", call: function () { return MetaNum.inv_aperiote(w15, 10, INV_DIAG); },
3912
+ expect: { value: 15, check: function () {
3913
+ var p = [];
3914
+ if (!w15.i_aper(10).eq(15)) p.push("i_aper(10)");
3915
+ if (!w15.i10(10).eq(15)) p.push("i10(10)");
3916
+ if (!MetaNum.i_aper(w15, 10).eq(15)) p.push("static i_aper");
3917
+ if (!w15.aperiote_root(15).eq(10)) p.push("aperiote_root(15)");
3918
+ if (!w15.r10(15).eq(10)) p.push("r10(15)");
3919
+ if (!w15.root_aperiote(15).eq(10)) p.push("root_aperiote(15)");
3920
+ if (!MetaNum.root_aperiote(w15, 15).eq(10)) p.push("static root_aperiote");
3921
+ if (!MetaNum.aperiote_root(w15, 15).eq(10)) p.push("static aperiote_root");
3922
+ return p;
3923
+ } } });
3924
+ checkInverseCase({ caseId: "G9.2.6", requirement: "10.2 / spec 5.2.1 generic order: hyper_log(c,n,α) solves b; hyper_root(c,b,α) solves n; instance curried forms agree",
3925
+ operation: "hyper_log/root", direction: "log+root", call: function () { return MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, INV_DIAG); },
3926
+ expect: { status: "approximate", approx: { to: 2.5, tol: 1e-9 }, check: function () {
3927
+ var p = [], c = MetaNum(2).tetr(2.5), cr = MetaNum(2.5).tetr(2);
3928
+ var inst = c.hyper_log(2)(2, INV_DIAG), st = MetaNum.hyper_root(cr, 2, 2, INV_DIAG), instR = cr.hyper_root(2)(2, INV_DIAG);
3929
+ if (!inst.value.eq(MetaNum(2.5)) && Math.abs(inst.value.toNumber() - 2.5) > 1e-9) p.push("instance hyper_log");
3930
+ if (Math.abs(st.value.toNumber() - 2.5) > 1e-9) p.push("static hyper_root");
3931
+ if (st.status !== instR.status || Math.abs(instR.value.toNumber() - 2.5) > 1e-9) p.push("instance hyper_root");
3932
+ if (!MetaNum.hyper_log(7, 2, 0).eq(3.5) || !MetaNum.hyper_root(7, 2, 0).eq(3.5)) p.push("n/α must not be swapped (7,2,0)");
3933
+ if (!MetaNum.hyper_root(65536, 4, 2).eq(2) || !MetaNum.hyper_log(65536, 2, 2).eq(4)) p.push("b/α must not be swapped (65536)");
3934
+ return p;
3935
+ } } });
3936
+ // omitted vs explicit defaults, diagnostics shape, input encodings
3937
+ (function () {
3938
+ var def = MetaNum.hyper_log(16, 2, 2), exp = MetaNum.hyper_log(16, 2, 2, { tol: 1e-12, maxIterations: 200, maxBracketExpansions: 60, branch: "principal", acceleration: "auto" });
3939
+ var defD = MetaNum.hyper_log(16, 2, 2, INV_DIAG), expD = MetaNum.hyper_log(16, 2, 2, { tol: 1e-12, maxIterations: 200, maxBracketExpansions: 60, branch: "principal", acceleration: "auto", diagnostics: true });
3940
+ checkInverseCase({ caseId: "G9.2.7", requirement: "10.2 / spec 5.2.1(7) omitted options == explicit defaults (value and status)",
3941
+ operation: "hyper_log", direction: "log", call: function () { return defD; },
3942
+ expect: { status: ["exact", "approximate"], value: 3, check: function () {
3943
+ var p = [];
3944
+ if (!(def instanceof MetaNum) || typeof def.status !== "undefined") p.push("default call must return a plain MetaNum");
3945
+ if (!def.eq(exp)) p.push("explicit default options changed the value");
3946
+ if (expD.status !== defD.status || expD.termination !== defD.termination) p.push("explicit default options changed status/termination");
3947
+ return p;
3948
+ } } });
3949
+ var num = MetaNum.hyper_log(7, 2, 0, INV_DIAG), str = MetaNum.hyper_log("7", "2", "0", INV_DIAG), mn = MetaNum.hyper_log(new MetaNum(7), new MetaNum(2), new MetaNum(0), INV_DIAG);
3950
+ var numR = MetaNum.hyper_root(2, 2, 1, INV_DIAG), strR = MetaNum.hyper_root("2", "2", "1", INV_DIAG), mnR = MetaNum.hyper_root(MetaNum(2), MetaNum(2), MetaNum(1), INV_DIAG);
3951
+ var named = w15.inv_aperiote(new MetaNum(10), INV_DIAG);
3952
+ checkInverseCase({ caseId: "G9.2.8", requirement: "10.2 / spec 5.2.1(6) number, numeric string and MetaNum inputs give the same branch and value",
3953
+ operation: "hyper_log/root", direction: "log+root", call: function () { return num; },
3954
+ expect: { status: "exact", value: 3.5, check: function () {
3955
+ var p = [];
3956
+ if (str.status !== num.status || !str.value.eq(num.value)) p.push("string inputs differ (log)");
3957
+ if (mn.status !== num.status || !mn.value.eq(num.value)) p.push("MetaNum inputs differ (log)");
3958
+ if (strR.status !== numR.status || !strR.value.eq(numR.value)) p.push("string inputs differ (root)");
3959
+ if (mnR.status !== numR.status || !mnR.value.eq(numR.value)) p.push("MetaNum inputs differ (root)");
3960
+ if (!named.value.eq(15)) p.push("named log with MetaNum base");
3961
+ return p;
3962
+ } } });
3963
+ var curried = MetaNum(7).hyper_log(2)(0, INV_DIAG);
3964
+ checkInverseCase({ caseId: "G9.2.9", requirement: "10.2 / spec 5.2.1(7) curried instance form accepts a trailing options object after α",
3965
+ operation: "hyper_log", direction: "log", call: function () { return curried; },
3966
+ expect: { status: "exact", value: 3.5, check: function () {
3967
+ var r = MetaNum(7).hyper_root(2)(0, INV_DIAG);
3968
+ return r.status === "exact" && r.value.eq(3.5) ? [] : ["curried hyper_root options"];
3969
+ } } });
3970
+ var bad = [];
3971
+ [["tol", -1], ["maxIterations", 2.5], ["maxIterations", 0], ["branch", "other"], ["acceleration", "newton"], ["diagnostics", "yes"], ["unknownKey", 1]].forEach(function (kv) {
3972
+ var o = { diagnostics: true }; o[kv[0]] = kv[1];
3973
+ var r = MetaNum.hyper_log(16, 2, 2, o);
3974
+ // a non-boolean diagnostics turns the explicit mode off: only the NaN value is observable then
3975
+ var rejected = r.status === undefined ? (r instanceof MetaNum && r.isNaN()) : (r.status === "invalid-input" && r.value.isNaN());
3976
+ if (!rejected) bad.push(kv[0] + "=" + kv[1] + " -> " + (r.status || r.toString()));
3977
+ });
3978
+ checkInverseCase({ caseId: "G9.2.10", requirement: "10.2 / spec 4.1 invalid options (non-positive tol, non-integer budget, illegal branch/acceleration, unknown key) => invalid-input + NaN, nothing executed",
3979
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(16, 2, 2, { diagnostics: true, tol: -1 }); },
3980
+ expect: { status: "invalid-input", isNaN: true, check: function () { return bad; } } });
3981
+ var huge = MetaNum.hyper_log(2, 2, 2, { diagnostics: true, maxIterations: 1e9, maxBracketExpansions: 5e9 });
3982
+ checkInverseCase({ caseId: "G9.2.11", requirement: "10.2 / spec 4.1(2) budgets above the hard limits are clamped to 10000/2048 and recorded in clampedOptions, no long loop",
3983
+ operation: "hyper_log", direction: "log", call: function () { return huge; },
3984
+ expect: { status: "exact", check: function () {
3985
+ return (huge.options.maxIterations === 10000 && huge.options.maxBracketExpansions === 2048 &&
3986
+ huge.options.clampedOptions.maxIterations === 10000 && huge.options.clampedOptions.maxBracketExpansions === 2048) ? [] :
3987
+ ["clampedOptions=" + JSON.stringify(huge.options.clampedOptions)];
3988
+ } } });
3989
+ var lev = MetaNum.hyper_log(2, 2, -0.5, INV_DIAG), lev2 = MetaNum.hyper_log(2, 2, "2.5", INV_DIAG);
3990
+ checkInverseCase({ caseId: "G9.2.12", requirement: "10.2 / spec 5.3.1(12) negative level => invalid-level (never rounded); fractional level 2.5 is accepted as itself",
3991
+ operation: "hyper_log", direction: "log", call: function () { return lev; },
3992
+ expect: { status: "invalid-level", isNaN: true, check: function () {
3993
+ var p = [];
3994
+ if (lev2.level !== "2.5") p.push("level text " + lev2.level);
3995
+ if (typeof MetaNum(3).inv_arrow !== "undefined" || typeof MetaNum(3).root_tetr !== "undefined") p.push("unagreed inv_arrow/root_tetr names must not be created");
3996
+ if (typeof MetaNum(3).inv_nosuchop !== "undefined") p.push("unknown op must not resolve");
3997
+ return p;
3998
+ } } });
3999
+ })();
4000
+ })();
4001
+
4002
+ // ───────────────────────────────────────────────────────────────────────────
4003
+ // G9.3 closed-form non-integer, known integer, sign and reciprocal (10.3)
4004
+ // ───────────────────────────────────────────────────────────────────────────
4005
+ console.log("\n=== G9.3 closed-form non-integer / known integers / signs / reciprocal ===");
4006
+ var LOG2_3 = Math.log(3) / Math.log(2), SQRT2 = Math.sqrt(2);
4007
+ // spec 5.3.1(2) a: independent expectations, never generated by the inverse under test
4008
+ checkInverseCase({ caseId: "G9.3.1", requirement: "spec 5.3.1(2)a hyper_log(7,2,0)=3.5 (2*b=7), non-integer kept", operation: "hyper_log", direction: "log",
4009
+ call: function () { return MetaNum.hyper_log(7, 2, 0, INV_DIAG); }, expect: { status: "exact", value: 3.5, isint: false }, solError: { from: 3.5, tol: 1e-12 }, residualMax: 1e-9 });
4010
+ checkInverseCase({ caseId: "G9.3.2", requirement: "spec 5.3.1(2)a hyper_root(7,2,0)=3.5 (n*2=7), non-integer kept", operation: "hyper_root", direction: "root",
4011
+ call: function () { return MetaNum.hyper_root(7, 2, 0, INV_DIAG); }, expect: { status: "exact", value: 3.5, isint: false }, solError: { from: 3.5, tol: 1e-12 }, residualMax: 1e-9 });
4012
+ checkInverseCase({ caseId: "G9.3.3", requirement: "spec 5.3.1(2)a hyper_log(3,2,1)=log2(3) (independent Math.log formula)", operation: "hyper_log", direction: "log",
4013
+ call: function () { return MetaNum.hyper_log(3, 2, 1, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: LOG2_3, tol: 1e-9 }, residualMax: 1e-9 });
4014
+ checkInverseCase({ caseId: "G9.3.4", requirement: "spec 5.3.1(2)a hyper_root(2,2,1)=sqrt(2) (independent Math.sqrt), even exponent reports multiple solutions", operation: "hyper_root", direction: "root",
4015
+ call: function () { return MetaNum.hyper_root(2, 2, 1, INV_DIAG); }, expect: { status: "approximate", isint: false, multipleSolutions: true }, solError: { from: SQRT2, tol: 1e-9 }, residualMax: 1e-9 });
4016
+ checkInverseCase({ caseId: "G9.3.5", requirement: "spec 5.5.1(2) 10^3.7 log base 10 keeps the non-integer exponent", operation: "hyper_log", direction: "log",
4017
+ call: function () { return MetaNum.hyper_log(Math.pow(10, 3.7), 10, 1, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: 3.7, tol: 1e-9 }, residualMax: 1e-9 });
4018
+ checkInverseCase({ caseId: "G9.3.6", requirement: "spec 5.3.1(2)b 0.5^2.5 log with base 0.5 uses the decreasing branch and keeps the positive height", operation: "hyper_log", direction: "log",
4019
+ call: function () { return MetaNum.hyper_log(Math.pow(0.5, 2.5), 0.5, 1, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: 2.5, tol: 1e-9 }, residualMax: 1e-9 });
4020
+ checkInverseCase({ caseId: "G9.3.7", requirement: "spec 5.3.1(10) negative solutions keep the sign: hyper_log(-7,2,0)=-3.5, hyper_root(-7,2,0)=-3.5", operation: "hyper_log/root", direction: "log+root",
4021
+ call: function () { return MetaNum.hyper_log(-7, 2, 0, INV_DIAG); }, expect: { status: "exact", value: -3.5, isint: false }, solError: { from: -3.5, tol: 1e-12 },
4022
+ check: function () { var r = MetaNum.hyper_root(-7, 2, 0, INV_DIAG); return r.value.eq(-3.5) && r.value.sign === -1 ? [] : ["root -3.5 sign=" + r.value.sign]; } });
4023
+ checkInverseCase({ caseId: "G9.3.8", requirement: "spec 5.3.1(10) zero and (0,1) solutions: hyper_log(0,2,0)=0, hyper_log(0.5,2,0)=0.25", operation: "hyper_log", direction: "log",
4024
+ call: function () { return MetaNum.hyper_log(0, 2, 0, INV_DIAG); }, expect: { status: "exact", value: 0 },
4025
+ check: function () { var r = MetaNum.hyper_log(0.5, 2, 0, INV_DIAG); return r.value.eq(0.25) && r.value.isint() === false ? [] : ["0.25 case " + r.value]; } });
4026
+ checkInverseCase({ caseId: "G9.3.9", requirement: "spec 5.3.1(2)b a (0,1) root keeps the reciprocal encoding, not its inverse or absolute value: hyper_root(0.5,1,1)=0.5", operation: "hyper_root", direction: "root",
4027
+ call: function () { return MetaNum.hyper_root(0.5, 1, 1, INV_DIAG); }, expect: { status: "approximate", approx: { to: 0.5, tol: 1e-12 }, check: function (r) { return r.value.sign === 2 ? [] : ["sign=" + r.value.sign + " (expected reciprocal sign 2)"]; } } });
4028
+ checkInverseCase({ caseId: "G9.3.10", requirement: "spec 5.3.1(10) negative exponents: root(0.25,-2,1)=2, root(-8,-3,1)=-0.5", operation: "hyper_root", direction: "root",
4029
+ call: function () { return MetaNum.hyper_root(0.25, -2, 1, INV_DIAG); }, expect: { status: "exact", value: 2 },
4030
+ check: function () { var r = MetaNum.hyper_root(-8, -3, 1, INV_DIAG); return r.value.eq(-0.5) && r.value.sign === -1 ? [] : ["(-8)^(-1/3) -> " + r.value]; } });
4031
+ checkInverseCase({ caseId: "G9.3.11", requirement: "spec 5.3.1(6)a odd integer exponent: root(-8,3,1)=-2 unique signed root", operation: "hyper_root", direction: "root",
4032
+ call: function () { return MetaNum.hyper_root(-8, 3, 1, INV_DIAG); }, expect: { status: "exact", value: -2, multipleSolutions: false } });
4033
+ checkInverseCase({ caseId: "G9.3.12", requirement: "spec 5.3.1(6)a even integer exponent: root(16,4,1)=2 positive principal root + multipleSolutions", operation: "hyper_root", direction: "root",
4034
+ call: function () { return MetaNum.hyper_root(16, 4, 1, INV_DIAG); }, expect: { status: "exact", value: 2, multipleSolutions: true } });
4035
+ checkInverseCase({ caseId: "G9.3.13", requirement: "spec 5.3.1(10) even exponent with negative target: root(-16,4,1) => no-solution NaN", operation: "hyper_root", direction: "root",
4036
+ call: function () { return MetaNum.hyper_root(-16, 4, 1, INV_DIAG); }, expect: { status: "no-solution", isNaN: true } });
4037
+ checkInverseCase({ caseId: "G9.3.14", requirement: "spec 5.3.1(10) zero with negative integer exponent: root(0,-1,1) => no-solution (no Infinity answer)", operation: "hyper_root", direction: "root",
4038
+ call: function () { return MetaNum.hyper_root(0, -1, 1, INV_DIAG); }, expect: { status: "no-solution", isNaN: true } });
4039
+ checkInverseCase({ caseId: "G9.3.15", requirement: "spec 5.3.1(10) zero with positive integer exponent: root(0,2,1)=0", operation: "hyper_root", direction: "root",
4040
+ call: function () { return MetaNum.hyper_root(0, 2, 1, INV_DIAG); }, expect: { status: "exact", value: 0 } });
4041
+ // known integer anchors (spec 5.6.1 row "已知整数结果") — each checked with strict eq through the public forward
4042
+ checkInverseCase({ caseId: "G9.3.16", requirement: "spec 5.2.1(8)a 2↑↑4: log=4 and root(·,4)=2 via verified integer anchors", operation: "hyper_log/root", direction: "log+root",
4043
+ call: function () { return MetaNum.hyper_log(65536, 2, 2, INV_DIAG); }, expect: { status: "exact", value: 4, isint: true, termination: "verified-integer-anchor" },
4044
+ check: function () { var r = MetaNum.hyper_root(65536, 4, 2, INV_DIAG); return r.status === "exact" && r.value.eq(2) ? [] : ["root " + r.status + " " + r.value]; } });
4045
+ checkInverseCase({ caseId: "G9.3.17", requirement: "spec 5.6.1 3↑↑3: log=3, root(·,3)=3", operation: "hyper_log/root", direction: "log+root",
4046
+ call: function () { return MetaNum.hyper_log(MetaNum(3).arrow(2)(3), 3, 2, INV_DIAG); }, expect: { status: ["exact", "approximate"], value: 3, isint: true },
4047
+ reproduce: { forward: function (x) { return MetaNum(3).arrow(2)(x); }, target: MetaNum(3).arrow(2)(3) },
4048
+ check: function () { return MetaNum.hyper_root(MetaNum(3).arrow(2)(3), 3, 2).eq(3) ? [] : ["3↑↑3 root"]; } });
4049
+ checkInverseCase({ caseId: "G9.3.18", requirement: "spec 5.6.1 10↑↑↑3: log(·,10,3)=3, root(·,3,3)=10 (strict eq; structured target => representation-level anchor may be classed approximate)", operation: "hyper_log/root", direction: "log+root",
4050
+ call: function () { return MetaNum.hyper_log(MetaNum(10).arrow(3)(3), 10, 3, INV_DIAG); }, expect: { status: ["exact", "approximate"], value: 3 },
4051
+ check: function () { return MetaNum.hyper_root(MetaNum(10).arrow(3)(3), 3, 3).eq(10) ? [] : ["10↑↑↑3 root"]; } });
4052
+ checkInverseCase({ caseId: "G9.3.19", requirement: "spec 5.6.1 2{4}3: root(·,3,4)=2 and log(·,2,4)=3", operation: "hyper_log/root", direction: "log+root",
4053
+ call: function () { return MetaNum.hyper_root(MetaNum(2).arrow(4)(3), 3, 4, INV_DIAG); }, expect: { status: ["exact", "approximate"], value: 2 },
4054
+ check: function () { return MetaNum.hyper_log(MetaNum(2).arrow(4)(3), 2, 4).eq(3) ? [] : ["2{4}3 log"]; } });
4055
+ checkInverseCase({ caseId: "G9.3.20", requirement: "spec 5.6.1 2{ω}3=65536: inv_aperiote(2)=3 and aperiote_root(3)=2, both exact", operation: "aperiote", direction: "log+root",
4056
+ call: function () { return MetaNum(2).aperiote(3).inv_aperiote(2, INV_DIAG); }, expect: { status: "exact", value: 3 },
4057
+ reproduce: { forward: function (x) { return MetaNum(2).aperiote(x); }, target: 65536 },
4058
+ check: function () { return MetaNum(2).aperiote(3).aperiote_root(3, INV_DIAG).value.eq(2) ? [] : ["2{ω}3 root"]; } });
4059
+ checkInverseCase({ caseId: "G9.3.21", requirement: "spec 5.6.1 (10{ω}15) root=10 (value), status must not be exact (representation-level anchor)", operation: "aperiote", direction: "root",
4060
+ call: function () { return MetaNum(10).aperiote(15).aperiote_root(15, INV_DIAG); }, expect: { status: ["approximate", "exact"], value: 10, representationLevel: true },
4061
+ reproduce: { forward: function (x) { return x.aperiote(15); }, target: MetaNum(10).aperiote(15)} });
4062
+ checkInverseCase({ caseId: "G9.3.22", requirement: "spec 5.6.1 multiplication anchor hyper_log(14,2,0)=7 (old checkHL vector)", operation: "hyper_log", direction: "log",
4063
+ call: function () { return MetaNum.hyper_log(14, 2, 0, INV_DIAG); }, expect: { status: "exact", value: 7, isint: true } });
4064
+ checkInverseCase({ caseId: "G9.3.23", requirement: "spec 5.6.1 power anchor hyper_log(1e5,10,1)=5, hyper_root(256,8,1)=2, hyper_root(81,4,1)=3 (old checkHL/checkHR vectors)", operation: "hyper_log/root", direction: "log+root",
4065
+ call: function () { return MetaNum.hyper_log(100000, 10, 1, INV_DIAG); }, expect: { status: "exact", value: 5 },
4066
+ check: function () { return MetaNum.hyper_root(256, 8, 1).eq(2) && MetaNum.hyper_root(81, 4, 1).eq(3) ? [] : ["power anchors"]; } });
4067
+ // the 3.49 counter-example: a real solution near an integer must NOT be snapped to it
4068
+ checkInverseCase({ caseId: "G9.3.24", requirement: "spec 5.2.1(8)b / 5.5.1(14) true height 3.49 is returned as 3.49 (not 3 or 4), non-integer, R_rel<=1e-9", operation: "hyper_log", direction: "log",
4069
+ call: function () { return MetaNum.hyper_log(MetaNum(2).tetr(3.49), 2, 2, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: 3.49, tol: 1e-9 }, residualMax: 1e-9,
4070
+ reproduce: { forward: function (x) { return MetaNum(2).tetr(x); }, target: MetaNum(2).tetr(3.49) } });
4071
+ checkInverseCase({ caseId: "G9.3.25", requirement: "spec 5.5.1(14) root of 1.5↑↑2 is 1.5 (not 1 or 2)", operation: "hyper_root", direction: "root",
4072
+ call: function () { return MetaNum.hyper_root(MetaNum(1.5).tetr(2), 2, 2, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: 1.5, tol: 1e-9 }, residualMax: 1e-9,
4073
+ reproduce: { forward: function (x) { return x.tetr(2); }, target: MetaNum(1.5).tetr(2) } });
4074
+ // fractional level: same real solve on the interpolated arrow
4075
+ checkInverseCase({ caseId: "G9.3.26", requirement: "spec 5.1.1(6) fractional level α=2.5 and 3.5: log/root recover 2.5 within 1e-9", operation: "hyper_log/root", direction: "log+root",
4076
+ call: function () { return MetaNum.hyper_log(MetaNum.arrow(2, 2.5, 2.5), 2, 2.5, INV_DIAG); }, expect: { status: "approximate", isint: false }, solError: { from: 2.5, tol: 1e-9 }, residualMax: 1e-9,
4077
+ check: function () {
4078
+ var p = [], r1 = MetaNum.hyper_root(MetaNum.arrow(2.5, 2.5, 2), 2, 2.5), r2 = MetaNum.hyper_log(MetaNum.arrow(2, 3.5, 2.5), 2, 3.5), r3 = MetaNum.hyper_root(MetaNum.arrow(2.5, 3.5, 2), 2, 3.5);
4079
+ [r1, r2, r3].forEach(function (r) { if (r.isNaN() || Math.abs(r.toNumber() - 2.5) > 1e-9) p.push("fractional level " + r); });
4080
+ return p;
4081
+ } });
4082
+
4083
+ // ───────────────────────────────────────────────────────────────────────────
4084
+ // G9.4 forward anchors: inverse substitution uses the one public forward (10.4)
4085
+ // ───────────────────────────────────────────────────────────────────────────
4086
+ console.log("\n=== G9.4 forward anchors and single-forward substitution (10.4) ===");
4087
+ (function () {
4088
+ var p = [];
4089
+ if (!MetaNum(10).aperioexpande(2.1).eq(MetaNum(10).powerexpande(2 * Math.pow(2.1 / 2, 0.1)))) p.push("10{ω*2}2.1 != 10{ω+3}(2*(2.1/2)^0.1)");
4090
+ if (!MetaNum(10).aperionate(2.1).eq(MetaNum(10).explode(2 * Math.pow(2.1 / 2, 0.21)))) p.push("10{ω^2}2.1 != 10{ω*2+1}(2*(2.1/2)^0.21)");
4091
+ if (!MetaNum(10).arrow(1.5)(1.5).gt(MetaNum(10).arrow(1.1)(1.1))) p.push("arrow(x,y,y) monotonic sample");
4092
+ if (!MetaNum.arrow(10, 3.5, 10).gt(MetaNum.arrow(10, 3.4, 10)) || !MetaNum.arrow(10, 3.6, 10).gt(MetaNum.arrow(10, 3.5, 10))) p.push("arrow(10,3.5,10) monotonic sample");
4093
+ if (!MetaNum(2).aperiote(2).eq(4) || !MetaNum(2).aperiote(3).gt(4)) p.push("2{λ}2=4 and 2{λ}3>4");
4094
+ checkInverseCase({ caseId: "G9.4.1", requirement: "10.4 / spec 5.1.1(3-8) forward anchors unchanged: fractional coefficient equivalences, x{y}y / arrow(10,3.5,10) monotonicity, 2{λ}2=4",
4095
+ operation: "forward", direction: "-", call: function () { return MetaNum(1); }, expect: { value: 1, check: function () { return p; } } });
4096
+ var anchors = [["aperiote", 3, 5, "3{ω}5"], ["aperionate", 10, 4, "10{ω^2}4"], ["iterate", 10, 4, "10{ω^ω}4"], ["epsilonate", 10, 4, "10{ε₀}4"], ["expande", 10, 3, "10{ω+1}3"]];
4097
+ anchors.forEach(function (a, i) {
4098
+ var t = MetaNum(a[1])[a[0]](a[2]);
4099
+ checkInverseCase({ caseId: "G9.4.2." + (i + 1), requirement: "10.4 / spec 5.1.1(4) anchor " + a[3] + ": inverse recovers the height and the public forward reproduces the anchor value",
4100
+ operation: a[0], direction: "log", call: function () { return t["inv_" + a[0]](a[1], INV_DIAG); },
4101
+ expect: { status: ["exact", "approximate"], value: a[2] }, reproduce: { forward: function (x) { return MetaNum(a[1])[a[0]](x); }, target: t } });
4102
+ });
4103
+ var t21 = MetaNum(10).expande(2.1);
4104
+ checkInverseCase({ caseId: "G9.4.3", requirement: "10.4 / spec 5.1.1(3) expande(10,2.1) inverse: forward substitution equals the same public value 10{ω}10{ω}(10^0.1)",
4105
+ operation: "expande", direction: "log", call: function () { return t21.inv_expande(10, INV_DIAG); },
4106
+ expect: { status: ["approximate", "exact"], check: function (r) { return (r.residual && r.residual.comparison === 0) || Math.abs(r.value.toNumber() - 2.1) < 1e-4 ? [] : ["not reproduced: " + r.status]; } },
4107
+ reproduce: { forward: function (x) { return MetaNum(10).expande(x); }, target: t21 }, note: "plateau near 2.1: value within 1e-4, reproduction at representation level" });
4108
+ })();
4109
+
4110
+ // ───────────────────────────────────────────────────────────────────────────
4111
+ // G9.5 per-family matrix: integer / non-integer height and base, boundary,
4112
+ // information-loss / illegal scenario (tasks 11.1, spec 5.6.1 rows 1-2,7)
4113
+ // ───────────────────────────────────────────────────────────────────────────
4114
+ console.log("\n=== G9.5 per-family integer / non-integer height and base matrix (11.1) ===");
4115
+ (function () {
4116
+ for (var i = 0; i < INV_REGISTRY.length; i++) {
4117
+ (function (row) {
4118
+ var op = row[0], marker = row[5], t3 = MetaNum(3)[op](3), t1 = MetaNum(7)[op](1);
4119
+ // iteraperiate's finite marker is the constant ω^ω+ω level marker, so the
4120
+ // structural inverse returns the minimal reproducing height 2, not 3
4121
+ var invY3 = (op === "iteraperiate") ? 2 : 3;
4122
+ checkInverseCase({
4123
+ caseId: "G9.5." + op, requirement: "11.1 integer height 3 / integer base 3 / boundary b=1 (c=n) / root b=1 / negative target root",
4124
+ operation: op, direction: "log+root", call: function () { return t3["inv_" + op](3, INV_DIAG); },
4125
+ expect: { status: ["exact", "approximate", "minimal-reproducing"], value: invY3, check: function (r, v) {
4126
+ var p = [];
4127
+ var rt = t3[op + "_root"](3, INV_DIAG);
4128
+ if (!rt.value.eq(marker ? 2 : 3)) p.push("integer base root -> " + rt.value);
4129
+ if (marker && (rt.status !== "minimal-reproducing" || rt.minimalityAttained !== true || rt.multipleSolutions !== true)) p.push("marker root classification " + rt.status + "/" + rt.minimalityAttained);
4130
+ if (!t1["inv_" + op](7).eq(1)) p.push("b=1 log should give 1 (c=n)");
4131
+ if (!t1[op + "_root"](1).eq(7)) p.push("root b=1 should give n=c");
4132
+ if (!MetaNum(-4)[op + "_root"](3).isNaN()) p.push("negative target root must be NaN");
4133
+ return p;
4134
+ } },
4135
+ note: marker ? "base-independent marker family: root = minimum of the declared n>=2 branch" : "structural family"
4136
+ });
4137
+ })(INV_REGISTRY[i]);
4138
+ }
4139
+ // non-integer height (b=2.5) per family — expectations from the forward storage
4140
+ var fracLog = [
4141
+ ["aperiote", "2.5", 2.5, 1e-9], ["expande", "2.5", 2.5, 1e-9], ["multiexpande", "2.5", 2.5, 1e-9], ["powerexpande", "2.5", 2.5, 1e-9],
4142
+ ["aperioexpande", "2.5", 2.5, 1e-9], ["explode", "2.5", 2.5, 1e-9], ["aperioexplode", "2.5", 2.5, 1e-9], ["aperiodetonate", "2.5", 2.5, 1e-9],
4143
+ ["aperionate", "2.5", 2.5, 1e-9], ["megoaperionate", "2.5", 2.5, 1e-9], ["iterate", "2.5", 2.5, 1e-9], ["epsilonate", "2.5", 2.5, 1e-9]
4144
+ ];
4145
+ fracLog.forEach(function (f) {
4146
+ var t = MetaNum(3)[f[0]](2.5);
4147
+ checkInverseCase({ caseId: "G9.5.f." + f[0], requirement: "11.1 non-integer height 2.5 is recovered as a real value (not snapped to 2 or 3) and reproduces the target",
4148
+ operation: f[0], direction: "log", call: function () { return t["inv_" + f[0]](3, INV_DIAG); },
4149
+ expect: { status: ["exact", "approximate"], isint: false }, solError: { from: 2.5, tol: f[3] },
4150
+ reproduce: { forward: function (x) { return MetaNum(3)[f[0]](x); }, target: t } });
4151
+ });
4152
+ // gigoaperionate: the forward is flat on [~2.414, 2.6]; the inverse returns the reproducing edge, not 2.5
4153
+ var gg = MetaNum(3).gigoaperionate(2.5);
4154
+ checkInverseCase({ caseId: "G9.5.f.gigoaperionate", requirement: "11.1 / spec 5.3.1(5) representation plateau: inverse returns the reproducing edge (representation-level), never claims 2.5 exactly",
4155
+ operation: "gigoaperionate", direction: "log", call: function () { return gg.inv_gigoaperionate(3, INV_DIAG); },
4156
+ expect: { status: ["approximate", "minimal-reproducing", "lower-bound"], representationLevel: true, check: function (r, v) {
4157
+ var p = [], x = v.toNumber();
4158
+ if (!(x >= 2.4 && x <= 2.5)) p.push("edge " + x + " outside the known plateau [2.414, 2.6]");
4159
+ if (MetaNum(3).gigoaperionate(v).cmp(gg) !== 0) p.push("edge does not reproduce the target");
4160
+ return p;
4161
+ } } });
4162
+ // aperioguate: the forward is non-monotone at representation level around b=2.5 (F(2.49)=F(2.51)=c, F(2.4709)>c) => no faithful bracket
4163
+ checkInverseCase({ caseId: "G9.5.f.aperioguate", requirement: "11.1 / spec 5.5.3(1) aperioguate b=2.5: forward representation is non-monotone, so the inverse must fail bounded with NaN (no pseudo value)",
4164
+ operation: "aperioguate", direction: "log", call: function () { return MetaNum(3).aperioguate(2.5).inv_aperioguate(3, INV_DIAG); },
4165
+ expect: { status: ["stagnated", "bracketing-failed", "non-converged", "unrecoverable"], isNaN: true },
4166
+ note: "F(3,2.49)=F(3,2.51)=c but F(3,2.4709)>c: no strict bracket exists at double resolution" });
4167
+ // ceil / floor platform families: the legacy integer representative is returned and must be flagged
4168
+ // non-integer height 2.5 in the ω^ω family: the non-integer marker preserves
4169
+ // the fraction — itermult c0 = (5.25-2)/8 lands in the segment (inv → 5.25);
4170
+ // iteraperiate/cuboiter store the constant level marker (inv → the minimal
4171
+ // reproducing height 2), the height itself being below marker resolution
4172
+ [["itermult", 3, 2.5, "ceil-height"], ["iteraperiate", 3, 2, "floor-height"], ["cuboiter", 3, 2, "floor-height"]].forEach(function (f) {
4173
+ var t = MetaNum(f[1])[f[0]](2.5);
4174
+ checkInverseCase({ caseId: "G9.5.f." + f[0], requirement: "11.1 / design 2.4.4 " + f[0] + " at fractional height 2.5: " + (f[0] === "itermult" ? "the non-integer marker preserves the fraction (inv recovers 5.25)" : "the constant level marker loses the height (inv returns the minimal reproducing height 2)") + ", flagged legacy/representation-level, never exact",
4175
+ operation: f[0], direction: "log", call: function () { return t["inv_" + f[0]](f[1], INV_DIAG); },
4176
+ expect: { status: "approximate", value: f[2], legacyAnchor: true, representationLevel: true, multipleSolutions: true, encoding: f[3], isint: f[2] === 2 },
4177
+ reproduce: { forward: function (x) { return MetaNum(f[1])[f[0]](x); }, target: t } });
4178
+ });
4179
+ // non-integer base (n=2.5): structural families solve on the n>=1 branch, marker families give the n>=2 minimum
4180
+ [["aperiote", 2.5], ["expande", 2.5], ["iterate", 2.5], ["aperionate", 2.5], ["iteraperiate", 2], ["epsilonate", 2]].forEach(function (f) {
4181
+ var t = MetaNum(2.5)[f[0]](3);
4182
+ checkInverseCase({ caseId: "G9.5.n." + f[0], requirement: "11.1 non-integer base 2.5 (height 3): root returns a real base (or the declared n>=2 minimum for marker ops) and reproduces the target",
4183
+ operation: f[0], direction: "root", call: function () { return t[f[0] + "_root"](3, INV_DIAG); },
4184
+ expect: { status: ["approximate", "minimal-reproducing"], value: f[1], isint: f[1] !== 2.5 },
4185
+ reproduce: { forward: function (x) { return x[f[0]](3); }, target: t } });
4186
+ });
4187
+ // fractional bases that the forward itself cannot evaluate are recorded, not substituted
4188
+ ["megote", "multimegote", "aperimegote"].forEach(function (op) {
4189
+ checkInverseCase({ caseId: "G9.5.n." + op, requirement: "11.1 non-integer base row cannot be constructed: the forward throws (RangeError) for megote(2.5,3); recorded as not executed, no substitute sample",
4190
+ operation: op, direction: "root", call: function () { return MetaNum(1); }, run: false,
4191
+ note: "forward " + op + "(2.5, 3) => RangeError: Maximum call stack size exceeded (pre-existing forward limitation, out of this feature's scope)" });
4192
+ });
4193
+ // root at fractional height: with the seed rows carried (fix for issue 2),
4194
+ // expande's root recovers base 3 despite the documented F(4,2.5)=10 anomaly;
4195
+ // detonate/aperiodetonate recover 3 through the integer anchor
4196
+ checkInverseCase({ caseId: "G9.5.b.expande", requirement: "11.1 root at fractional height 2.5 for expande: base 3 recovered (the carried seed rows give the solver a clean bracket); the documented forward anomaly F(4,2.5)=10<F(3,2.5) is reported separately",
4197
+ operation: "expande", direction: "root", call: function () { return MetaNum(3).expande(2.5).expande_root(2.5, INV_DIAG); },
4198
+ expect: { status: ["exact", "approximate"], value: 3 },
4199
+ reproduce: { forward: function (x) { return x.expande(2.5); }, target: MetaNum(3).expande(2.5) } });
4200
+ ["detonate", "aperiodetonate"].forEach(function (op) {
4201
+ checkInverseCase({ caseId: "G9.5.b." + op, requirement: "11.1 root at fractional height 2.5: base 3 recovered by a verified integer anchor (representation-level); fractional-base candidates on this op hit NaN forward points and are reported, not substituted",
4202
+ operation: op, direction: "root", call: function () { return MetaNum(3)[op](2.5)[op + "_root"](2.5, INV_DIAG); },
4203
+ expect: { status: ["exact", "approximate"], value: 3 }, reproduce: { forward: function (x) { return x[op](2.5); }, target: MetaNum(3)[op](2.5) } });
4204
+ });
4205
+ checkInverseCase({ caseId: "G9.5.b.aperiote", requirement: "11.1 root at fractional height 2.5 for aperiote: base 3 recovered by verified integer anchor",
4206
+ operation: "aperiote", direction: "root", call: function () { return MetaNum(3).aperiote(2.5).aperiote_root(2.5, INV_DIAG); },
4207
+ expect: { status: ["exact", "approximate"], value: 3 }, reproduce: { forward: function (x) { return x.aperiote(2.5); }, target: MetaNum(3).aperiote(2.5) } });
4208
+ })();
4209
+
4210
+ // ───────────────────────────────────────────────────────────────────────────
4211
+ // G9.6 round-trip vs. substitution residual (11.2): recovering the unknown and
4212
+ // reproducing the target are two independent assertions
4213
+ // ───────────────────────────────────────────────────────────────────────────
4214
+ console.log("\n=== G9.6 round-trip vs. substitution residual separation (11.2) ===");
4215
+ (function () {
4216
+ var rt = [ // [label, target, inverse call, original unknown, tol]
4217
+ ["α=2 log 2↑↑2.5", MetaNum(2).tetr(2.5), function () { return MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, INV_DIAG); }, 2.5],
4218
+ ["α=2 root 1.5↑↑2", MetaNum(1.5).tetr(2), function () { return MetaNum.hyper_root(MetaNum(1.5).tetr(2), 2, 2, INV_DIAG); }, 1.5],
4219
+ ["α=3 log 2{3}2.5", MetaNum.arrow(2, 3, 2.5), function () { return MetaNum.hyper_log(MetaNum.arrow(2, 3, 2.5), 2, 3, INV_DIAG); }, 2.5],
4220
+ ["α=3 root 2.5{3}2", MetaNum.arrow(2.5, 3, 2), function () { return MetaNum.hyper_root(MetaNum.arrow(2.5, 3, 2), 2, 3, INV_DIAG); }, 2.5],
4221
+ ["α=2.5 log", MetaNum.arrow(2, 2.5, 2.5), function () { return MetaNum.hyper_log(MetaNum.arrow(2, 2.5, 2.5), 2, 2.5, INV_DIAG); }, 2.5],
4222
+ ["aperiote(3,1.5)", MetaNum(3).aperiote(1.5), function () { return MetaNum(3).aperiote(1.5).inv_aperiote(3, INV_DIAG); }, 1.5],
4223
+ ["expande(3,2.5)", MetaNum(3).expande(2.5), function () { return MetaNum(3).expande(2.5).inv_expande(3, INV_DIAG); }, 2.5],
4224
+ ["10.tetr(3+1e-6)", MetaNum(10).tetr(3 + 1e-6), function () { return MetaNum.hyper_log(MetaNum(10).tetr(3 + 1e-6), 10, 2, INV_DIAG); }, 3.000001]
4225
+ ];
4226
+ rt.forEach(function (c, i) {
4227
+ checkInverseCase({ caseId: "G9.6.1." + (i + 1), requirement: "11.2 / spec 5.6.1(3-6) round-trip " + c[0] + ": unknown recovered within 1e-9 AND independent forward substitution within R_rel<=1e-9 (or cmp=0)",
4228
+ operation: "mixed", direction: "log/root", call: c[2], expect: { status: ["exact", "approximate"], isint: false },
4229
+ solError: { from: c[3], tol: 1e-9 }, residualMax: 1e-9 });
4230
+ });
4231
+ // reproduction-only: the original non-integer height is NOT recoverable, the representative must be flagged
4232
+ var multi = [
4233
+ ["iteraperiate(3,5.25)", function () { return MetaNum(3).iteraperiate(5.25).inv_iteraperiate(3, INV_DIAG); }, 2, "floor-height", MetaNum(3).iteraperiate(5.25)],
4234
+ ["itermult(3,5.25)", function () { return MetaNum(3).itermult(5.25).inv_itermult(3, INV_DIAG); }, 5.25, "ceil-height", MetaNum(3).itermult(5.25)],
4235
+ ["epsilonate(10,5.25)", function () { return MetaNum(10).epsilonate(5.25).inv_epsilonate(10, INV_DIAG); }, 5.25, "epsilon-layer", MetaNum(10).epsilonate(5.25)],
4236
+ ["iteraperiate_root(5)", function () { return MetaNum(3).iteraperiate(5).iteraperiate_root(5, INV_DIAG); }, 2, null, MetaNum(3).iteraperiate(5)],
4237
+ ["aperiote_root(15) on 10{ω}15", function () { return MetaNum(10).aperiote(15).aperiote_root(15, INV_DIAG); }, 10, null, MetaNum(10).aperiote(15)]
4238
+ ];
4239
+ multi.forEach(function (c, i) {
4240
+ checkInverseCase({ caseId: "G9.6.2." + (i + 1), requirement: "11.2 / spec 5.6.1(5,10) " + c[0] + ": only reproduction is asserted; result must carry representation-level / legacy flags and never claim original-input recovery",
4241
+ operation: "named", direction: "log/root", call: c[1],
4242
+ expect: { status: ["approximate", "minimal-reproducing", "lower-bound"], value: c[2], representationLevel: true, check: function (r) {
4243
+ var p = [];
4244
+ if (r.status === "minimal-reproducing" && r.minimalityAttained !== true) p.push("minimal-reproducing without minimality evidence");
4245
+ if (r.status !== "minimal-reproducing" && r.minimalityAttained === true) p.push("minimality claimed on a non-minimal result");
4246
+ if (c[3] && r.encoding !== c[3]) p.push("encoding " + r.encoding + " expected " + c[3]);
4247
+ return p;
4248
+ } },
4249
+ reproduce: { forward: function (x) { return i === 3 ? x.iteraperiate(5) : i === 4 ? x.aperiote(15) : (i === 0 ? MetaNum(3).iteraperiate(x) : i === 1 ? MetaNum(3).itermult(x) : MetaNum(10).epsilonate(x)); }, target: c[4] },
4250
+ note: "value " + c[2] + " is a reproducing representative, not the original input" });
4251
+ });
4252
+ // structural exactness on a plain finite target: 2{ω}3 = 65536 -> 3, residual is a faithful number residual
4253
+ checkInverseCase({ caseId: "G9.6.3", requirement: "11.2 / spec 5.6.1(6) exact structural recovery on a plain number target carries a number residual (R_abs=R_rel=0), not an unavailable one",
4254
+ operation: "aperiote", direction: "log", call: function () { return MetaNum(2).aperiote(3).inv_aperiote(2, INV_DIAG); },
4255
+ expect: { status: "exact", value: 3, residualKind: "number-absolute-relative", check: function (r) { return r.residual.absolute === 0 && r.residual.relative === 0 ? [] : ["residual " + JSON.stringify(r.residual)]; } } });
4256
+ // saturated / structured target: cmp=0 is representation-level, the numeric residual must stay null
4257
+ checkInverseCase({ caseId: "G9.6.4", requirement: "11.2 / spec 5.6.1(7)a 10↑↑15 (ordinal rows): cmp=0 is reported as representation-level with residual kind ordinal-structure and relative=null (never 0)",
4258
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(MetaNum(10).tetr(15), 10, 2, INV_DIAG); },
4259
+ expect: { status: ["exact", "approximate"], value: 15, representationLevel: true, residualKind: "bracket-only", check: function (r) { return r.residual.relative === null && r.residual.comparison === 0 ? [] : ["residual " + JSON.stringify(r.residual)]; } } });
4260
+ })();
4261
+
4262
+ // ───────────────────────────────────────────────────────────────────────────
4263
+ // G9.7 successor break points m-δ / m / m+δ (11.3)
4264
+ // ───────────────────────────────────────────────────────────────────────────
4265
+ console.log("\n=== G9.7 successor break points ±δ (11.3) ===");
4266
+ // continuity rule: either the inverse lands within `tol` of m+δ (faithful, no
4267
+ // reverse jump, no integer snap) or it is classified as a bounded failure /
4268
+ // representation-level result within the forward's resolution. Never a value on
4269
+ // the wrong side of m, never exactly m when δ≠0 (that would be a rounding jump).
4270
+ function invContinuityProblems(r, m, d, tol) {
4271
+ var p = [];
4272
+ if (r.value.isNaN()) {
4273
+ if (["stagnated", "bracketing-failed", "non-converged", "unrecoverable", "unrepresentable"].indexOf(r.status) === -1) p.push("NaN with unexpected status " + r.status);
4274
+ return p;
4275
+ }
4276
+ var x = r.value.toNumber(), want = m + d;
4277
+ if (!Number.isFinite(x)) { p.push("non-finite value"); return p; }
4278
+ if (d !== 0 && x === m) p.push("snapped to the integer " + m);
4279
+ if ((x - m) * d < 0) p.push("reverse jump: " + x + " is on the wrong side of " + m);
4280
+ if (Math.abs(x - want) > tol) p.push("solution " + x + " farther than " + tol + " from " + want + " (" + r.status + "/" + r.termination + ")");
4281
+ return p;
4282
+ }
4283
+ (function () {
4284
+ [2, 3].forEach(function (m) {
4285
+ [[-1e-6, 1e-6], [1e-6, 1e-6], [-1e-10, 1e-10], [1e-10, 1e-10], [0, 1e-12]].forEach(function (dd) {
4286
+ var d = dd[0], t = MetaNum(2).tetr(m + d);
4287
+ checkInverseCase({ caseId: "G9.7.tetr." + m + "." + d, requirement: "11.3 tetration base 2 at m=" + m + ", δ=" + d + ": inverse lands on m+δ within 1e-9 (definition-guaranteed continuous successor interpolation)",
4288
+ operation: "tetr", direction: "log", call: function () { return MetaNum.hyper_log(t, 2, 2, INV_DIAG); },
4289
+ expect: { status: ["exact", "approximate"], check: function (r) { return invContinuityProblems(r, m, d, dd[1]); } },
4290
+ reproduce: { forward: function (x) { return MetaNum(2).tetr(x); }, target: t } });
4291
+ });
4292
+ });
4293
+ [["expande", 1e-9], ["multiexpande", 1e-9], ["explode", 1e-9]].forEach(function (f) {
4294
+ [2, 3].forEach(function (m) {
4295
+ [-1e-6, 1e-6].forEach(function (d) {
4296
+ var t = MetaNum(3)[f[0]](m + d);
4297
+ checkInverseCase({ caseId: "G9.7." + f[0] + "." + m + "." + d, requirement: "11.3 " + f[0] + " base 3 at m=" + m + ", δ=" + d + ": no reverse jump / integer snap; within 1e-9 when faithfully representable",
4298
+ operation: f[0], direction: "log", call: function () { return t["inv_" + f[0]](3, INV_DIAG); },
4299
+ expect: { status: ["exact", "approximate", "stagnated", "bracketing-failed", "non-converged"], check: function (r) { return invContinuityProblems(r, m, d, f[1]); } },
4300
+ reproduce: { forward: function (x) { return MetaNum(3)[f[0]](x); }, target: t } });
4301
+ });
4302
+ });
4303
+ });
4304
+ // itermult: the forward stores ceil(y)-1, so fractional heights are NOT continuous in storage;
4305
+ // the inverse must flag the legacy platform representative rather than pretend continuity
4306
+ [2, 3].forEach(function (m) {
4307
+ [-1e-6, 0, 1e-6].forEach(function (d) {
4308
+ var t = MetaNum(3).itermult(m + d);
4309
+ checkInverseCase({ caseId: "G9.7.itermult." + m + "." + d, requirement: "11.3 itermult at m=" + m + ", δ=" + d + ": ceil-height platform — result must be a flagged legacy/representation-level representative on the correct side, continuity itself is not assertable",
4310
+ operation: "itermult", direction: "log", call: function () { return t.inv_itermult(3, INV_DIAG); },
4311
+ expect: { status: ["exact", "approximate", "minimal-reproducing", "lower-bound"], check: function (r, v) {
4312
+ var p = [], x = v.toNumber();
4313
+ if (!(r.representationLevel || r.legacyAnchor)) p.push("platform result not flagged (R/L)");
4314
+ if (d !== 0 && x === m && r.legacyAnchor !== true) p.push("unflagged integer snap");
4315
+ if (x < m - 0.01 || x > m + 1.0000001) p.push("platform representative " + x + " outside [m, m+1]");
4316
+ return p;
4317
+ } },
4318
+ reproduce: { forward: function (x) { return MetaNum(3).itermult(x); }, target: t } });
4319
+ });
4320
+ });
4321
+ })();
4322
+
4323
+ // ───────────────────────────────────────────────────────────────────────────
4324
+ // G9.8 fundamental-sequence break points and fractional coefficient (11.4)
4325
+ // ───────────────────────────────────────────────────────────────────────────
4326
+ console.log("\n=== G9.8 fundamental-sequence break points and fractional coefficient (11.4) ===");
4327
+ (function () {
4328
+ [["aperiote", 1e-9], ["aperioexpande", 1e-9], ["aperionate", 1e-9], ["iterate", 1e-9], ["epsilonate", 1e-9]].forEach(function (f) {
4329
+ var ms = f[0] === "aperioexpande" || f[0] === "aperionate" ? [2] : [2, 3];
4330
+ ms.forEach(function (m) {
4331
+ [-1e-6, 1e-6].forEach(function (d) {
4332
+ var t = MetaNum(3)[f[0]](m + d);
4333
+ // ε₀ with y in (1,2): the forward marker stores max(2,floor y)+frac, i.e. the same value as y+1
4334
+ var quirk = f[0] === "epsilonate" && m === 2 && d < 0;
4335
+ checkInverseCase({ caseId: "G9.8." + f[0] + "." + m + "." + d, requirement: "11.4 / spec 5.1.1(4,5) " + f[0] + " at integer point " + m + (quirk ? "-δ" : " ±δ") + ": no level-switch jump; faithful within 1e-9, or representation-level within the forward's resolution" + (quirk ? " (ε₀ marker encodes heights in (1,2) as y+1 — pre-existing forward convention, documented)" : ""),
4336
+ operation: f[0], direction: "log", call: function () { return t["inv_" + f[0]](3, INV_DIAG); },
4337
+ expect: { status: ["exact", "approximate", "stagnated", "bracketing-failed", "non-converged"], allowNaN: true, check: function (r, v) {
4338
+ var p = [];
4339
+ if (r.value.isNaN()) { if (["stagnated", "bracketing-failed", "non-converged"].indexOf(r.status) === -1) p.push("NaN with " + r.status); return p; }
4340
+ var x = v.toNumber(), want = m + d + (quirk ? 1 : 0);
4341
+ var tol = r.representationLevel ? 0.01 : f[1];
4342
+ if (Math.abs(x - want) > tol) p.push("solution " + x + " vs " + want + " (" + r.status + "/" + r.termination + ", R=" + r.representationLevel + ")");
4343
+ if (quirk && !r.representationLevel) p.push("(1,2) ε marker recovery must be flagged representation-level");
4344
+ return p;
4345
+ } },
4346
+ reproduce: { forward: function (x) { return MetaNum(3)[f[0]](x); }, target: t } });
4347
+ });
4348
+ });
4349
+ });
4350
+ // fractional coefficient (spec 5.1.1(5)): 10{ω*2}2.1 and 10{ω^2}2.1 keep the fraction and invert to 2.1
4351
+ [["aperioexpande", "10{ω*2}2.1"], ["aperionate", "10{ω^2}2.1"]].forEach(function (f) {
4352
+ var t = MetaNum(10)[f[0]](2.1);
4353
+ checkInverseCase({ caseId: "G9.8.frac." + f[0], requirement: "11.4 / spec 5.1.1(5) fractional coefficient " + f[1] + ": inverse returns 2.1 (fraction preserved), reproduction at representation level",
4354
+ operation: f[0], direction: "log", call: function () { return t["inv_" + f[0]](10, INV_DIAG); },
4355
+ expect: { status: ["exact", "approximate"], isint: false }, solError: { from: 2.1, tol: 1e-9 },
4356
+ reproduce: { forward: function (x) { return MetaNum(10)[f[0]](x); }, target: t } });
4357
+ });
4358
+ // non-integer marker (spec 5.1.1(5)b resolved): itermult(10, 2.1) stores
4359
+ // c0 = 0.1/8 in the fractional r0 slot, so the inverse recovers 2.1 — the
4360
+ // fraction is preserved, not dropped
4361
+ var tl = MetaNum(10).itermult(2.1);
4362
+ checkInverseCase({ caseId: "G9.8.loss.itermult", requirement: "11.4 / spec 5.1.1(5)b itermult(10,2.1): the non-integer marker keeps the fraction — inverse recovers 2.1 (representation-level structural value)",
4363
+ operation: "itermult", direction: "log", call: function () { return tl.inv_itermult(10, INV_DIAG); },
4364
+ expect: { status: "approximate", value: 2.1, legacyAnchor: true, representationLevel: true, encoding: "ceil-height" },
4365
+ reproduce: { forward: function (x) { return MetaNum(10).itermult(x); }, target: tl } });
4366
+ })();
4367
+
4368
+ // ───────────────────────────────────────────────────────────────────────────
4369
+ // G9.9 domain boundaries, multi/no-solution, invalid & non-finite (12.1)
4370
+ // ───────────────────────────────────────────────────────────────────────────
4371
+ console.log("\n=== G9.9 domain boundaries, multi/no-solution, invalid and non-finite inputs (12.1) ===");
4372
+ (function () {
4373
+ var D = INV_DIAG, p;
4374
+ // zero coefficient / zero exponent constant maps (design 2.4.2)
4375
+ checkInverseCase({ caseId: "G9.9.1", requirement: "12.1 zero coefficient: log(5,0,0) no-solution; log(0,0,0) all real heights reproduce 0 => NaN + unbounded-below + multipleSolutions",
4376
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(5, 0, 0, D); }, expect: { status: "no-solution", isNaN: true },
4377
+ check: function () { var r = MetaNum.hyper_log(0, 0, 0, D); return r.status === "unrecoverable" && r.termination === "unbounded-below" && r.multipleSolutions === true && r.value.isNaN() ? [] : ["log(0,0,0) " + r.status]; } });
4378
+ checkInverseCase({ caseId: "G9.9.2", requirement: "12.1 zero coefficient root: root(5,0,0) no-solution; root(0,0,0) unbounded-below NaN",
4379
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(5, 0, 0, D); }, expect: { status: "no-solution", isNaN: true },
4380
+ check: function () { var r = MetaNum.hyper_root(0, 0, 0, D); return r.status === "unrecoverable" && r.termination === "unbounded-below" && r.multipleSolutions === true ? [] : ["root(0,0,0) " + r.status]; } });
4381
+ checkInverseCase({ caseId: "G9.9.3", requirement: "12.1 base 1 constant map: log(1,1,1) unbounded-below multi; log(2,1,1) no-solution; α=2 log(1,1,2) minimal height 0 (minimal-reproducing, multi); log(2,1,2) no-solution",
4382
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(1, 1, 1, D); }, expect: { status: "unrecoverable", termination: "unbounded-below", multipleSolutions: true, isNaN: true },
4383
+ check: function () {
4384
+ var a = MetaNum.hyper_log(2, 1, 1, D), b = MetaNum.hyper_log(1, 1, 2, D), c = MetaNum.hyper_log(2, 1, 2, D), q = [];
4385
+ if (a.status !== "no-solution") q.push("log(2,1,1) " + a.status);
4386
+ if (b.status !== "minimal-reproducing" || !b.value.eq(0) || b.multipleSolutions !== true || b.minimalityAttained !== true) q.push("log(1,1,2) " + b.status + " " + b.value);
4387
+ if (c.status !== "no-solution") q.push("log(2,1,2) " + c.status);
4388
+ return q;
4389
+ } });
4390
+ checkInverseCase({ caseId: "G9.9.4", requirement: "12.1 zero exponent: root(1,0,1) => lower-bound 0 with minimalityAttained=false; root(2,0,1) no-solution; α=2 root(1,0,2) minimal-reproducing 1",
4391
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(1, 0, 1, D); }, expect: { status: "lower-bound", value: 0, minimalityAttained: false, multipleSolutions: true },
4392
+ check: function () { var a = MetaNum.hyper_root(2, 0, 1, D), b = MetaNum.hyper_root(1, 0, 2, D); return a.status === "no-solution" && b.status === "minimal-reproducing" && b.value.eq(1) ? [] : ["root zero exponent " + a.status + "/" + b.status]; } });
4393
+ checkInverseCase({ caseId: "G9.9.5", requirement: "12.1 / spec 5.3.1(8)b height 1 root: c=7 -> 7; c=0.5 is outside the n>=1 image => no-solution (never copied as 0.5); c=1 -> minimal base 1 (multi)",
4394
+ operation: "aperiote_root", direction: "root", call: function () { return MetaNum(7).aperiote_root(1, D); }, expect: { status: "exact", value: 7 },
4395
+ check: function () { var a = MetaNum(0.5).aperiote_root(1, D), b = MetaNum(1).aperiote_root(1, D); return a.status === "no-solution" && b.status === "minimal-reproducing" && b.value.eq(1) ? [] : ["b=1 roots " + a.status + "/" + b.status]; } });
4396
+ checkInverseCase({ caseId: "G9.9.6", requirement: "12.1 c=0 / c=1: aperiote log c=0 -> b=0 (aperiote(n,0)=0 special); expande log c=0 -> no-solution; root c=0 -> no-solution; log(1,2,2)=0; root(1,2,2) -> minimal base 1",
4397
+ operation: "named", direction: "log+root", call: function () { return MetaNum(0).inv_aperiote(2, D); }, expect: { status: "exact", value: 0 },
4398
+ check: function () {
4399
+ var q = [], a = MetaNum(0).inv_expande(10, D), b = MetaNum(0).aperiote_root(5, D), c = MetaNum.hyper_log(1, 2, 2, D), d = MetaNum.hyper_root(1, 2, 2, D);
4400
+ if (a.status !== "no-solution") q.push("inv_expande c=0 " + a.status);
4401
+ if (b.status !== "no-solution") q.push("root c=0 " + b.status);
4402
+ if (!c.value.eq(0)) q.push("log(1,2,2)");
4403
+ if (d.status !== "minimal-reproducing" || !d.value.eq(1)) q.push("root(1,2,2) " + d.status);
4404
+ return q;
4405
+ } });
4406
+ checkInverseCase({ caseId: "G9.9.7", requirement: "12.1 finite high-level outside image: log(-5,2,2), log(0.5,2,2), root(0.5,2,2) => no-solution (no clamped endpoint)",
4407
+ operation: "hyper_log/root", direction: "log+root", call: function () { return MetaNum.hyper_log(-5, 2, 2, D); }, expect: { status: "no-solution", isNaN: true },
4408
+ check: function () { var a = MetaNum.hyper_log(0.5, 2, 2, D), b = MetaNum.hyper_root(0.5, 2, 2, D); return a.status === "no-solution" && b.status === "no-solution" ? [] : ["outside image " + a.status + "/" + b.status]; } });
4409
+ checkInverseCase({ caseId: "G9.9.8", requirement: "12.1 special fold 2{λ}2=4 (and 2{λ}3>4): log(4,2,3)=2 and aperiote log/root of 4 with base/height 2 => 2 exact; other bases still solved by their own forward",
4410
+ operation: "aperiote", direction: "log+root", call: function () { return MetaNum(4).inv_aperiote(2, D); }, expect: { status: "exact", value: 2 },
4411
+ check: function () {
4412
+ var q = [], f = MetaNum.hyper_log(4, 2, 3, D), r = MetaNum(4).aperiote_root(2, D), o = MetaNum(16).inv_aperiote(2, D);
4413
+ if (!f.value.eq(2)) q.push("log(4,2,3)");
4414
+ if (!r.value.eq(2)) q.push("aperiote_root(2) of 4");
4415
+ if (!MetaNum(2).aperiote(3).gt(4)) q.push("2{λ}3 must exceed 4");
4416
+ if (!MetaNum(2).aperiote(4).inv_aperiote(2).eq(4)) q.push("aperiote(2,4)=2{4}4 must still invert to 4 (other heights are solved by their own forward)");
4417
+ return q;
4418
+ } });
4419
+ checkInverseCase({ caseId: "G9.9.9", requirement: "12.1 unauthenticated domains: 0<n<1 at α=2 log => unsupported-domain; negative height (named root) => unsupported-domain; negative base at α=2 root => unsupported-domain/NaN",
4420
+ operation: "hyper_log/root", direction: "log+root", call: function () { return MetaNum.hyper_log(2, 0.5, 2, D); }, expect: { status: "unsupported-domain", isNaN: true },
4421
+ check: function () {
4422
+ var q = [], a = MetaNum.expande(10, 3).expande_root(-1, D), b = MetaNum(10).aperiote(15).aperiote_root(-5, D), c = MetaNum.hyper_root(16, 2, 2, D), d = MetaNum.hyper_root(-16, 4, 2, D), ind = MetaNum(16).ssrt();
4423
+ if (a.status !== "unsupported-domain" || !a.value.isNaN()) q.push("negative height " + a.status);
4424
+ if (b.status !== "unsupported-domain" || !b.value.isNaN()) q.push("aperiote negative height " + b.status);
4425
+ if (Math.abs(c.value.toNumber() - ind.toNumber()) > 1e-9) q.push("root(16,2,2) should match the independent Lambert-W ssrt(16)=" + ind + ", got " + c.value);
4426
+ if (d.value.isNaN() === false && d.status !== "unsupported-domain") q.push("negative high-level base " + d.status);
4427
+ return q;
4428
+ } });
4429
+ // NaN / ±Infinity in every position (spec 5.3.1(11)) — default returns stay NaN
4430
+ (function () {
4431
+ var q = [];
4432
+ [[NaN, 2, 2], [2, NaN, 2], [2, 2, NaN], [Infinity, 2, 2], [2, Infinity, 2], [2, 2, Infinity], [-Infinity, 2, 2], [2, -Infinity, 2]].forEach(function (args) {
4433
+ ["hyper_log", "hyper_root"].forEach(function (m) {
4434
+ var r = MetaNum[m](args[0], args[1], args[2], D), plain = MetaNum[m](args[0], args[1], args[2]);
4435
+ var want = (isNaN(args[0]) || isNaN(args[1]) || isNaN(args[2])) ? "invalid-input" : "non-finite-input";
4436
+ if (r.status !== want || !r.value.isNaN() || !plain.isNaN()) q.push(m + "(" + args.join(",") + ") -> " + r.status);
4437
+ });
4438
+ });
4439
+ var v = MetaNum(10).aperiote(15);
4440
+ [[function () { return v.inv_aperiote(NaN, D); }, "invalid-input"], [function () { return v.inv_aperiote(Infinity, D); }, "non-finite-input"],
4441
+ [function () { return v.aperiote_root(NaN, D); }, "invalid-input"], [function () { return v.aperiote_root(Infinity, D); }, "non-finite-input"],
4442
+ [function () { return MetaNum.inv_iteraperiate(NaN, 10, D); }, "invalid-input"], [function () { return MetaNum(10).iteraperiate(5).iteraperiate_root(Infinity, D); }, "non-finite-input"]].forEach(function (c) {
4443
+ var r = c[0](); if (r.status !== c[1] || !r.value.isNaN()) q.push("named non-finite -> " + r.status);
4444
+ });
4445
+ if (!MetaNum.inv_aperiote(MetaNum(3), MetaNum.NaN).isNaN()) q.push("old NaN propagation inv_aperiote(3, NaN)");
4446
+ checkInverseCase({ caseId: "G9.9.10", requirement: "12.1 / spec 5.3.1(11) NaN => invalid-input and ±Infinity => non-finite-input in every position of c/n/α/b for generic and named entries; default calls return NaN",
4447
+ operation: "all", direction: "log+root", call: function () { return MetaNum.hyper_log(NaN, 2, 2, D); }, expect: { status: "invalid-input", isNaN: true, check: function () { return q; } } });
4448
+ })();
4449
+ // invalid strings / levels (spec 4.3.2, 5.3.1(12)): the constructor's silent 0 must not be solved as 0
4450
+ (function () {
4451
+ var q = [];
4452
+ [["abc", 2, 2], ["", 2, 2], ["12abc", 2, 2], [2, "abc", 2], [2, 2, "abc"], [2, "1e", 2]].forEach(function (args) {
4453
+ var r = MetaNum.hyper_log(args[0], args[1], args[2], D);
4454
+ if (r.status !== "invalid-input" || !r.value.isNaN()) q.push("hyper_log(" + args.join(",") + ") -> " + r.status);
4455
+ });
4456
+ var r0 = MetaNum.hyper_log("0", 2, 0, D), rv = MetaNum.inv_aperiote("abc", 10, D), rn = MetaNum.aperiote_root("abc", 15, D), ri = MetaNum("abc").hyper_log(2)(2, D);
4457
+ if (!r0.value.eq(0)) q.push("string \"0\" must still be the number 0: " + r0.status);
4458
+ if (rv.status !== "invalid-input" || rn.status !== "invalid-input") q.push("named invalid string " + rv.status + "/" + rn.status);
4459
+ if (ri.status === "invalid-input") q.push("unexpected");
4460
+ [[-1], [-0.5], ["abc"], ["2x"]].forEach(function (lv) { var r = MetaNum.hyper_log(2, 2, lv[0], D); if (r.status !== "invalid-level" && r.status !== "invalid-input") q.push("level " + lv[0] + " -> " + r.status); });
4461
+ checkInverseCase({ caseId: "G9.9.11", requirement: "12.1 / spec 4.3.2 invalid strings => invalid-input NaN (never solved as the constructor's silent 0); negative/unknown levels => invalid-level, never rounded",
4462
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log("abc", 2, 2, D); }, expect: { status: "invalid-input", isNaN: true, check: function () { return q; } } });
4463
+ })();
4464
+ // object inputs the constructor rejects keep raising the constructor's own error (no new exception system)
4465
+ checkInverseCase({ caseId: "G9.9.12", requirement: "12.1 / design 2.4.8 non-numeric objects keep the constructor's own MetaNumError (no new inverse exception type)",
4466
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum(1); },
4467
+ expect: { value: 1, check: function () {
4468
+ var msg = "";
4469
+ try { MetaNum.hyper_log({}, 2, 2); } catch (e) { msg = (e && e.name) + ": " + (e && e.message); }
4470
+ return /MetaNumError/.test(msg) ? [] : ["unexpected: " + msg];
4471
+ } } });
4472
+ // multi-solution: even integer power double root (principal positive), and the 2{λ}2 anchor
4473
+ checkInverseCase({ caseId: "G9.9.13", requirement: "12.1 / spec 5.3.1(6) multiple discrete solutions: root(81,4,1)=3 positive principal with multipleSolutions; root(-81,4,1) no-solution",
4474
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(81, 4, 1, D); }, expect: { status: "exact", value: 3, multipleSolutions: true },
4475
+ check: function () { return MetaNum.hyper_root(-81, 4, 1, D).status === "no-solution" ? [] : ["root(-81,4,1)"]; } });
4476
+ })();
4477
+
4478
+ // ───────────────────────────────────────────────────────────────────────────
4479
+ // G9.10 markers, saturation, truncation, COEFF_BOUND / MSI / cap, minimality (12.2)
4480
+ // ───────────────────────────────────────────────────────────────────────────
4481
+ console.log("\n=== G9.10 markers, saturation, truncation, COEFF/MSI/cap and minimality (12.2) ===");
4482
+ (function () {
4483
+ var D = INV_DIAG;
4484
+ // COEFF_BOUND = 100 boundary on a representative limit operation
4485
+ [[100 - 1e-6, 1e-2, "representation plateau: value within 0.01 of 100"], [100, 1e-12, "integer anchor"], [100 + 1e-6, 1e-6, "just above the bound (representation-level within 1e-6)"], [101, 1e-12, "integer anchor"]].forEach(function (c) {
4486
+ var t = MetaNum(3).aperiote(c[0]);
4487
+ checkInverseCase({ caseId: "G9.10.1." + c[0], requirement: "12.2 / spec 5.6.1 row 'representation boundary' aperiote(3," + c[0] + ") across COEFF_BOUND=100: " + c[2] + "; structure may change, no false exactness",
4488
+ operation: "aperiote", direction: "log", call: function () { return t.inv_aperiote(3, D); },
4489
+ expect: { status: ["approximate", "exact"], check: function (r, v) {
4490
+ var x = v.toNumber(); return Math.abs(x - c[0]) <= c[1] ? [] : ["value " + x + " vs " + c[0] + " (" + r.status + ")"];
4491
+ } },
4492
+ reproduce: { forward: function (x) { return MetaNum(3).aperiote(x); }, target: t }, note: c[2] });
4493
+ });
4494
+ checkInverseCase({ caseId: "G9.10.2", requirement: "12.2 expande(3,99/100/101): complete cascade rows keep the height exactly across the bound",
4495
+ operation: "expande", direction: "log", call: function () { return MetaNum(3).expande(100).inv_expande(3, D); }, expect: { status: "exact", value: 100 },
4496
+ check: function () { return MetaNum(3).expande(99).inv_expande(3).eq(99) && MetaNum(3).expande(101).inv_expande(3).eq(101) ? [] : ["99/101"]; } });
4497
+ // truncation: arrow(10,39,10) (full) and arrow(10,40,10) (truncated: [10] base + first row count+1) under maxRows 20 / 50
4498
+ (function () {
4499
+ var q = [], rows20 = MetaNum.maxRows, cols20 = MetaNum.maxCols, log = [];
4500
+ try {
4501
+ MetaNum.maxRows = 20;
4502
+ var t39 = MetaNum.arrow(10, 39, 10), t40 = MetaNum.arrow(10, 40, 10);
4503
+ var l39 = MetaNum.hyper_log(t39, 10, 39, D), r39 = MetaNum.hyper_root(t39, 10, 39, D);
4504
+ var l40 = MetaNum.hyper_log(t40, 10, 40, D), r40 = MetaNum.hyper_root(t40, 10, 40, D);
4505
+ log.push("maxRows=20: rows " + t39.array.length + "/" + t40.array.length + "; log39 " + l39.status + "/" + l39.value + "; root39 " + r39.status + "/" + r39.value + "; log40 " + l40.status + "/" + l40.value + "; root40 " + r40.status + "/" + r40.value);
4506
+ [[l39, 39], [r39, 39], [l40, 40], [r40, 40]].forEach(function (pair) {
4507
+ var r = pair[0];
4508
+ if (r.status === "exact") q.push("truncated/target at " + pair[1] + " reported exact");
4509
+ if (!r.value.isNaN() && r.representationLevel !== true) q.push("value at " + pair[1] + " without representation-level flag");
4510
+ });
4511
+ if (JSON.stringify(t40.array[0]) !== "[10]") q.push("arrow(10,40,10) should be the truncated [10] form at maxRows=20, got " + JSON.stringify(t40.array[0]));
4512
+ if (!l39.value.eq(10) || !r39.value.eq(10) || !l40.value.eq(10) || !r40.value.eq(10)) q.push("truncation inverses should reproduce 10 at representation level (legacy), not NaN");
4513
+ MetaNum.maxRows = 50;
4514
+ var t40b = MetaNum.arrow(10, 40, 10), l40b = MetaNum.hyper_log(t40b, 10, 40, D), r40b = MetaNum.hyper_root(t40b, 10, 40, D);
4515
+ log.push("maxRows=50: rows " + t40b.array.length + "; log40 " + l40b.status + "/" + l40b.value + "; root40 " + r40b.status + "/" + r40b.value);
4516
+ if (l40b.status === "exact" || r40b.status === "exact") q.push("maxRows=50 inverse reported exact");
4517
+ } finally { MetaNum.maxRows = rows20; MetaNum.maxCols = cols20; }
4518
+ if (MetaNum.maxRows !== rows20 || MetaNum.maxCols !== cols20) q.push("global config not restored");
4519
+ checkInverseCase({ caseId: "G9.10.3", requirement: "12.2 / spec 5.4.1(6) truncated arrays ([10] base, first row +1) never become exact roots/heights; inverses are representation-level; maxRows restored in finally",
4520
+ operation: "arrow(10,39/40,10)", direction: "log+root", call: function () { return MetaNum(1); }, expect: { value: 1, check: function () { return q; } }, note: log.join(" || ") });
4521
+ })();
4522
+ // MSI and the ε₀ ceiling: below / at / above (y > MSI → Infinity per the
4523
+ // documented convention, so its inverse is NaN by the non-finite rule)
4524
+ checkInverseCase({ caseId: "G9.10.4", requirement: "12.2 / spec 5.4.1(7-8) ε₀: y=MSI-1 exact structural; y=MSI saturates to layer MSI-1 (lower-bound, minimalityAttained=false); y>MSI → the forward itself returns Infinity and the inverse reports non-finite-input",
4525
+ operation: "epsilonate", direction: "log", call: function () { return MetaNum(10).epsilonate(9007199254740990).inv_epsilonate(10, D); }, expect: { status: "exact", value: 9007199254740990 },
4526
+ check: function () {
4527
+ var q = [], a = MetaNum(10).epsilonate(9007199254740991).inv_epsilonate(10, D), b = MetaNum(10).epsilonate(1e16);
4528
+ if (a.status !== "lower-bound" || !a.value.eq(9007199254740991) || a.minimalityAttained !== false || a.loss !== "capped") q.push("y=MSI " + a.status + "/" + a.loss);
4529
+ if (b.toString() !== "Infinity") q.push("y=1e16 forward should be Infinity, got " + b);
4530
+ var bi = b.inv_epsilonate(10, D);
4531
+ if (bi.status !== "non-finite-input" || !bi.value.isNaN()) q.push("y=1e16 inverse " + bi.status);
4532
+ return q;
4533
+ } });
4534
+ checkInverseCase({ caseId: "G9.10.5", requirement: "12.2 / spec 5.4.1(7) huge-argument markers: y>MSI inverses stay finite, non-NaN, >=1 (old sanity) and carry representation-level evidence; epsilonate returns Infinity (documented); capped counts are not read as exact applications",
4535
+ operation: "named", direction: "log", call: function () { return MetaNum(10).aperiote(1e16).inv_aperiote(10, D); },
4536
+ expect: { status: ["exact", "approximate", "lower-bound"], value: 1e16, representationLevel: true, check: function () {
4537
+ var q = [], big = MetaNum(1e16);
4538
+ ["expande", "iterate", "itermult"].forEach(function (op) {
4539
+ var r = MetaNum(10)[op](big)["inv_" + op](10, D);
4540
+ if (r.value.isNaN() || !r.value.isFinite() || r.value.lt(1)) q.push(op + " y>MSI -> " + r.status + " " + r.value);
4541
+ if (r.representationLevel !== true) q.push(op + " y>MSI without representation-level flag");
4542
+ if (op === "itermult" && r.legacyAnchor !== true) q.push("itermult capped count must be a legacy anchor");
4543
+ });
4544
+ var eb = MetaNum(10).epsilonate(big);
4545
+ if (eb.toString() !== "Infinity") q.push("epsilonate y>MSI should be Infinity");
4546
+ return q;
4547
+ } } });
4548
+ // base-independent markers: root = 2 on the declared n>=2 branch, with reproduction (old vector kept) and n=1 constant handled
4549
+ (function () {
4550
+ var q = [];
4551
+ INV_REGISTRY.filter(function (r) { return r[5]; }).forEach(function (row) {
4552
+ var op = row[0], v = MetaNum(10)[op](5), r = v[op + "_root"](5, D);
4553
+ if (!r.value.eq(2) || r.status !== "minimal-reproducing" || r.minimalityAttained !== true || r.multipleSolutions !== true) q.push(op + " root " + r.status + "/" + r.value + "/" + r.minimalityAttained);
4554
+ if (!MetaNum(2)[op](5).eq(v)) q.push(op + ": 2 does not reproduce the marker");
4555
+ if (MetaNum(1)[op](5).eq(v)) q.push(op + ": base 1 must be the constant special case, not the marker");
4556
+ var one = MetaNum(1)[op + "_root"](5, D);
4557
+ if (one.status !== "minimal-reproducing" || !one.value.eq(1)) q.push(op + " root of 1 " + one.status);
4558
+ var lower = MetaNum(1.5)[op + "_root"](5, D);
4559
+ if (lower.status !== "unrecoverable") q.push(op + " root of a non-marker (n=1.5 target) " + lower.status);
4560
+ });
4561
+ checkInverseCase({ caseId: "G9.10.6", requirement: "12.2 / spec 5.4.1(4-5) / design 2.4.4(6) base-independent markers (itermult..epsilonate, height 5): root = 2 minimal-reproducing on n>=2 with F(2,5)=c; base 1 constant; non-marker targets unrecoverable; no claim about (1,2)",
4562
+ operation: "marker ops", direction: "root", call: function () { return MetaNum(10).iteraperiate(5).iteraperiate_root(5, D); },
4563
+ expect: { status: "minimal-reproducing", value: 2, minimalityAttained: true, multipleSolutions: true, representationLevel: true, check: function () { return q; } } });
4564
+ })();
4565
+ // non-integer marker: the fraction lives in r0[0] and the inverse recovers it
4566
+ checkInverseCase({ caseId: "G9.10.7", requirement: "12.2 / design 2.4.4(2-3) itermult non-integer marker: c0 = (5.25-2)/8 = 0.40625 in r0[0], inverse recovers 5.25; F(5.25) reproduces, F(5.99) does NOT (the marker is fractional, not a ceil platform) => legacy/approximate, never minimal-reproducing",
4567
+ operation: "itermult", direction: "log", call: function () { return MetaNum(3).itermult(5.25).inv_itermult(3, D); },
4568
+ expect: { status: "approximate", value: 5.25, legacyAnchor: true, representationLevel: true, check: function (r) {
4569
+ var q = [], c = MetaNum(3).itermult(5.25);
4570
+ if (Math.abs(c.array[0][0] - 0.40625) > 1e-15) q.push("c0 " + c.array[0][0] + " != (5.25-2)/8");
4571
+ if (MetaNum(3).itermult(6).eq(c)) q.push("ceil platform must be gone: itermult(6) should differ from itermult(5.25)");
4572
+ if (MetaNum(3).itermult(5.99).eq(c)) q.push("5.99 must not reproduce 5.25's marker");
4573
+ if (r.minimalityAttained === true) q.push("minimality claimed on a fractional marker");
4574
+ return q;
4575
+ } } });
4576
+ checkInverseCase({ caseId: "G9.10.8", requirement: "12.2 / design 2.4.4(3) iteraperiate constant level marker: every finite height (5.25 / 5 / 4.99) shares [[10,1],[1,0,1]], the inverse returns the minimal reproducing height 2; ordinal-height markers [1|ω] / [1|ω^ω] still strip",
4577
+ operation: "iteraperiate", direction: "log", call: function () { return MetaNum(3).iteraperiate(5.25).inv_iteraperiate(3, D); },
4578
+ expect: { status: "approximate", value: 2, legacyAnchor: true, representationLevel: true, check: function (r) {
4579
+ var q = [], c = MetaNum(3).iteraperiate(5.25);
4580
+ if (!MetaNum(3).iteraperiate(5).eq(c) || !MetaNum(3).iteraperiate(4.99).eq(c)) q.push("finite heights must share the constant level marker");
4581
+ if (!r.value.eq(2) || !MetaNum(3).iteraperiate(2).eq(c)) q.push("inverse should return the minimal reproducing height 2");
4582
+ var oy = MetaNum(10).itermult(3), ov = MetaNum(10).iteraperiate(oy);
4583
+ if (!ov.inv_iteraperiate(10).eq(oy)) q.push("ordinal-height [1|ω] strip");
4584
+ var oy2 = MetaNum(10).iteraperiate(3), ov2 = MetaNum(10).iteraperiate(oy2);
4585
+ if (!ov2.inv_iteraperiate(10).eq(oy2)) q.push("ordinal-height [1|ω^ω] strip");
4586
+ return q;
4587
+ } } });
4588
+ // epsilonate fraction: integer exact, fraction approximate + representation-level; y=2 equals iterate (separately verified anchor)
4589
+ checkInverseCase({ caseId: "G9.10.9", requirement: "12.2 / design 2.4.4(5) epsilonate: integer height exact structural, 5.25 recovered as 5.25 (approximate, fraction-preserved, representation-level); y=2 equals iterate(x,x)",
4590
+ operation: "epsilonate", direction: "log", call: function () { return MetaNum(10).epsilonate(5).inv_epsilonate(10, D); }, expect: { status: "exact", value: 5, encoding: "epsilon-layer" },
4591
+ check: function () {
4592
+ var q = [], r = MetaNum(10).epsilonate(5.25).inv_epsilonate(10, D);
4593
+ if (!r.value.eq(5.25) || r.status !== "approximate" || r.encoding !== "epsilon-layer" || r.loss !== "fraction-preserved" || r.representationLevel !== true) q.push("5.25 -> " + r.status + "/" + r.value + "/" + r.loss);
4594
+ if (!MetaNum(10).epsilonate(2).eq(MetaNum(10).iterate(10))) q.push("epsilonate(10,2) must equal iterate(10,10)");
4595
+ if (!MetaNum(10).epsilonate(2).inv_epsilonate(10).eq(2) && !MetaNum(10).epsilonate(2).inv_epsilonate(10).eq(10)) q.push("y=2 anchor inverse");
4596
+ return q;
4597
+ } });
4598
+ })();
4599
+
4600
+ // ───────────────────────────────────────────────────────────────────────────
4601
+ // G9.11 large numbers, tolerance ladder, numeric strings, reciprocal limits (12.3)
4602
+ // ───────────────────────────────────────────────────────────────────────────
4603
+ console.log("\n=== G9.11 large numbers, tolerance ladder, numeric strings and reciprocal limits (12.3) ===");
4604
+ (function () {
4605
+ var D = INV_DIAG;
4606
+ var big = MetaNum(2).tetr(100);
4607
+ checkInverseCase({ caseId: "G9.11.1", requirement: "12.3 / spec 5.6.1 row 'large numbers' layer>0 target 2↑↑100: log => 100 (legacy anchor, bounded iterations), residual is bracket-only with relative=null (no Infinity-Infinity pseudo residual)",
4608
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(big, 2, 2, D); },
4609
+ expect: { status: ["approximate", "exact"], value: 100, representationLevel: true, residualKind: "bracket-only", check: function (r) {
4610
+ var q = []; if (r.residual.relative !== null || r.residual.absolute !== null) q.push("numeric residual must be null for structured targets");
4611
+ if (r.iterations > 200 || r.forwardEvaluations > 400) q.push("unbounded work " + r.iterations + "/" + r.forwardEvaluations); return q; } } });
4612
+ checkInverseCase({ caseId: "G9.11.2", requirement: "12.3 root of 2↑↑100 at height 100 => 2 (legacy, representation-level), cmp-based evidence only",
4613
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(big, 100, 2, D); },
4614
+ expect: { status: ["approximate", "exact"], value: 2, representationLevel: true, residualKind: "bracket-only" } });
4615
+ var nested = MetaNum(10).aperiote(15);
4616
+ checkInverseCase({ caseId: "G9.11.3", requirement: "12.3 nested ordinal rows target 10{ω}15: log => 15 (structural), residual kind meta-comparison / ordinal-structure with null numeric fields; root => 10 (representation-level)",
4617
+ operation: "aperiote", direction: "log+root", call: function () { return nested.inv_aperiote(10, D); },
4618
+ expect: { status: ["exact", "approximate"], value: 15, representationLevel: true, check: function (r) {
4619
+ var q = [], rr = nested.aperiote_root(15, D);
4620
+ if (["meta-comparison", "ordinal-structure", "bracket-only"].indexOf(r.residual.kind) === -1 || r.residual.relative !== null) q.push("log residual " + r.residual.kind);
4621
+ if (!rr.value.eq(10) || rr.status === "exact" || rr.residual.relative !== null) q.push("root residual/status " + rr.status + "/" + rr.residual.kind);
4622
+ return q; } } });
4623
+ // tolerance ladder on one non-integer vector
4624
+ var ladder = [1e-8, 1e-12, 1e-300], runs = [];
4625
+ ladder.forEach(function (tol) { runs.push(MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, { diagnostics: true, tol: tol })); });
4626
+ checkInverseCase({ caseId: "G9.11.4", requirement: "12.3 / spec 5.5.3(3) tolerance ladder on 2↑↑2.5 log: tol=1e-8 and 1e-12 converge within 1e-9 with R_rel<=1e-9; tol=1e-300 (below representation resolution) ends stagnated/approximate, never claims extra precision",
4627
+ operation: "hyper_log", direction: "log", call: function () { return runs[1]; },
4628
+ expect: { status: "approximate", isint: false }, solError: { from: 2.5, tol: 1e-9 }, residualMax: 1e-9, check: function () {
4629
+ var q = [], r8 = runs[0], r300 = runs[2];
4630
+ if (Math.abs(r8.value.toNumber() - 2.5) > 1e-9 || r8.residual.relative > 1e-9) q.push("tol=1e-8 " + r8.status + " " + r8.value + " R=" + r8.residual.relative);
4631
+ if (["stagnated", "non-converged", "approximate"].indexOf(r300.status) === -1) q.push("tol=1e-300 " + r300.status);
4632
+ if (r300.termination === "converged") q.push("tol=1e-300 reported normal convergence");
4633
+ if (!r300.value.isNaN() && r300.representationLevel !== true) q.push("tol=1e-300 finite result must be representation-level");
4634
+ return q; },
4635
+ note: ladder.map(function (t, i) { return "tol=" + t + ": it=" + runs[i].iterations + " fw=" + runs[i].forwardEvaluations + " status=" + runs[i].status + "/" + runs[i].termination + " value=" + runs[i].value + " R=" + runs[i].residual.relative; }).join(" | ") });
4636
+ // semantic equality of number / numeric string / MetaNum encodings at large scale
4637
+ checkInverseCase({ caseId: "G9.11.5", requirement: "12.3 number, numeric string and MetaNum inputs are the same call; a structured value re-parsed from its toString() is lossy and is reported as a precision limit (bounded failure), not as a recovered height",
4638
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(new MetaNum(big), 2, 2, D); },
4639
+ expect: { status: ["approximate", "exact"], value: 100, check: function () {
4640
+ var q = [], s = MetaNum.hyper_log(big.toString(), 2, 2, D), n = MetaNum.hyper_log(1e5, 10, 1, D), ns = MetaNum.hyper_log("1e5", "10", "1", D), nm = MetaNum.hyper_log(MetaNum(1e5), MetaNum(10), MetaNum(1), D);
4641
+ if (["stagnated", "non-converged", "bracketing-failed", "unrecoverable"].indexOf(s.status) === -1 && !s.value.eq(100)) q.push("re-parsed string target must be solved or classified, got " + s.status);
4642
+ if (n.value.eq(5) === false || !ns.value.eq(n.value) || !nm.value.eq(n.value)) q.push("1e5 encodings differ");
4643
+ return q; } },
4644
+ note: "string re-parse of 2↑↑100 gave status=" + MetaNum.hyper_log(big.toString(), 2, 2, D).status + " (documented string-parsing precision limit); 1e5 encodings agree" });
4645
+ // reciprocal / underflow limits (spec 5.5.1(12)b): tiny legal solutions keep the reciprocal structure or fail as unrepresentable, never 0
4646
+ checkInverseCase({ caseId: "G9.11.6", requirement: "12.3 / spec 5.5.1(12)b tiny legal solutions: root(1e-330,2,0)=5e-331 and root(5e-324,10,0)=5e-325 use the reciprocal structure (sign=2), never underflow to 0; plain Number would give 0",
4647
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root("1e-330", 2, 0, D); },
4648
+ expect: { status: "exact", check: function (r, v) {
4649
+ var q = [], r2 = MetaNum.hyper_root("5e-324", 10, 0, D);
4650
+ if (v.eq(0) || v.sign !== 2) q.push("1e-330/2 -> " + v + " sign=" + v.sign);
4651
+ if (r2.value.eq(0) || r2.value.sign !== 2) q.push("5e-324/10 -> " + r2.value + " sign=" + r2.value.sign + " (Number lane: " + (5e-324 / 10) + ")");
4652
+ if (r2.residual.kind === "unavailable" && r2.residual.reason !== "not evaluated") q.push("unexpected unavailable residual");
4653
+ return q; } },
4654
+ reproduce: { forward: function (x) { return x.mul(2); }, target: MetaNum("1e-330") },
4655
+ note: "residual is log-space (the difference is below double resolution); the equality itself is definition-guaranteed by the reciprocal structure" });
4656
+ checkInverseCase({ caseId: "G9.11.7", requirement: "12.3 log of a subnormal target with a large base: log(1e-320,1e10,0)=1e-330 keeps the reciprocal structure",
4657
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log("1e-320", 1e10, 0, D); },
4658
+ expect: { status: "exact", check: function (r, v) { return v.eq(0) || v.sign !== 2 ? ["1e-330 -> " + v] : []; } } });
4659
+ // precision limits are reported, not hidden: double, string parsing, structural counts, normalisation
4660
+ checkInverseCase({ caseId: "G9.11.8", requirement: "12.3 / spec 5.4.1(9) precision limits: a 17-significant-digit string is parsed to double precision and the inverse reports the double-level result (approximate), not the string's extra digits",
4661
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log("2.50000000000000001", 2, 0, D); },
4662
+ expect: { status: ["exact", "approximate"], approx: { to: 1.25, tol: 1e-15 }, isint: false },
4663
+ note: "the string's 18th digit is below double resolution; result is the double-level 1.25 (documented limitation, not arbitrary precision)" });
4664
+ })();
4665
+
4666
+ // ───────────────────────────────────────────────────────────────────────────
4667
+ // G9.12 failure injection (12.4)
4668
+ // ───────────────────────────────────────────────────────────────────────────
4669
+ console.log("\n=== G9.12 failure injection: budgets, stagnation, acceleration fallback, overflow/underflow (12.4) ===");
4670
+ (function () {
4671
+ var D = INV_DIAG;
4672
+ checkInverseCase({ caseId: "G9.12.1", requirement: "12.4 / spec 5.5.1(10) maxIterations=1 on 2↑↑2.5 log => non-converged, NaN, iterations=1, last candidate NOT returned",
4673
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, { diagnostics: true, maxIterations: 1 }); },
4674
+ expect: { status: "non-converged", termination: "iteration-budget-exhausted", isNaN: true, check: function (r) { return r.iterations === 1 ? [] : ["iterations=" + r.iterations]; } } });
4675
+ checkInverseCase({ caseId: "G9.12.2", requirement: "12.4 / spec 5.5.1(4,10) maxBracketExpansions=1 on 2↑↑10.5 log => bracketing-failed / expansion-budget-exhausted, expansions=1, never the last upper bound as the answer",
4676
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(MetaNum(2).tetr(10.5), 2, 2, { diagnostics: true, maxBracketExpansions: 1 }); },
4677
+ expect: { status: "bracketing-failed", termination: "expansion-budget-exhausted", isNaN: true, check: function (r) {
4678
+ return r.expansions === 1 && r.bracket && r.bracket.loCmp === -1 && r.bracket.hiCmp === -1 ? [] : ["expansions=" + r.expansions + " bracket=" + JSON.stringify(r.bracket)]; } } });
4679
+ checkInverseCase({ caseId: "G9.12.3", requirement: "12.4 tol=1e-300 on the 2.5 round trip => stagnated (finite representation-level 2.5 or NaN); never normal convergence",
4680
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, { diagnostics: true, tol: 1e-300 }); },
4681
+ expect: { status: ["stagnated", "non-converged", "approximate"], termination: ["stagnated", "midpoint-not-interior", "iteration-budget-exhausted", "converged"], check: function (r) {
4682
+ var q = []; if (r.termination === "converged") q.push("claimed convergence under tol=1e-300");
4683
+ if (!r.value.isNaN() && r.representationLevel !== true) q.push("finite stagnated result must be representation-level"); return q; } } });
4684
+ var auto = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D), bis = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, { diagnostics: true, acceleration: "bisection" });
4685
+ checkInverseCase({ caseId: "G9.12.4", requirement: "12.4 / design 2.4.5(3) acceleration vs bisection on 2↑↑2.5 (representable secant lane): same branch/criteria, both within 1e-9; auto records fallbackCount>0 (rejected/worsening secant candidates fall back to midpoint, bracket kept valid)",
4686
+ operation: "hyper_log", direction: "log", call: function () { return auto; },
4687
+ expect: { status: "approximate", isint: false }, solError: { from: 2.5, tol: 1e-9 }, residualMax: 1e-9, check: function (r) {
4688
+ var q = [];
4689
+ if (Math.abs(bis.value.toNumber() - 2.5) > 1e-9 || bis.status !== r.status) q.push("bisection differs " + bis.status + " " + bis.value);
4690
+ if (!(r.fallbackCount > 0)) q.push("no acceleration fallback observed (fallbackCount=" + r.fallbackCount + ")");
4691
+ if (bis.fallbackCount !== 0) q.push("bisection must not use acceleration (fb=" + bis.fallbackCount + ")");
4692
+ if (!(r.iterations <= bis.iterations)) q.push("auto took more iterations than bisection " + r.iterations + " vs " + bis.iterations);
4693
+ if (r.bracket && !(r.bracket.lo < r.bracket.hi)) q.push("bracket invalid at exit");
4694
+ return q; },
4695
+ note: "auto it=" + auto.iterations + "/fb=" + auto.fallbackCount + "; bisection it=" + bis.iterations + "/fb=" + bis.fallbackCount });
4696
+ var t = MetaNum(10).tetr(3 + 1e-10), ra = MetaNum.hyper_log(t, 10, 2, D), rb = MetaNum.hyper_log(t, 10, 2, { diagnostics: true, acceleration: "bisection" });
4697
+ checkInverseCase({ caseId: "G9.12.5", requirement: "12.4 10↑↑(3+1e-10) auto vs bisection: bounded termination; if a finite value comes back it is not the integer 3 and is representation-level; otherwise NaN with a failure termination",
4698
+ operation: "hyper_log", direction: "log", call: function () { return ra; },
4699
+ expect: { status: ["stagnated", "non-converged", "bracketing-failed", "approximate", "exact"], check: function (r) {
4700
+ var q = [];
4701
+ [ra, rb].forEach(function (x) {
4702
+ if (x.iterations > 200 || x.forwardEvaluations > 400) q.push("unbounded work " + x.iterations + "/" + x.forwardEvaluations);
4703
+ if (!x.value.isNaN() && (x.value.eq(3) || x.representationLevel !== true)) q.push("finite result " + x.value + " is an integer snap or unflagged");
4704
+ });
4705
+ if (ra.termination === "converged" && Math.abs(ra.value.toNumber() - (3 + 1e-10)) > 1e-9) q.push("converged away from the target height");
4706
+ return q; } },
4707
+ note: "auto " + ra.status + "/" + ra.termination + " it=" + ra.iterations + " fb=" + ra.fallbackCount + " value=" + ra.value + " | bisection " + rb.status + "/" + rb.termination + " it=" + rb.iterations + " value=" + rb.value + " — residual criterion unreachable at double resolution near the steep point; reported as stagnation, not as precision" });
4708
+ // forward NaN / invalid points
4709
+ checkInverseCase({ caseId: "G9.12.6", requirement: "12.4 forward NaN injection: a NaN forward target (expande(3,0)) => invalid-input; zero/negative heights for named roots => unsupported-domain; all bounded, no forward evaluation",
4710
+ operation: "expande", direction: "log+root", call: function () { return MetaNum(3).expande(0).inv_expande(3, D); }, expect: { status: "invalid-input", isNaN: true, check: function () {
4711
+ var q = [], a = MetaNum(10).aperiote(15).aperiote_root(0, D), b = MetaNum(10).aperiote(15).aperiote_root(-5, D);
4712
+ if (a.status !== "unsupported-domain" || a.forwardEvaluations !== 0) q.push("zero height " + a.status);
4713
+ if (b.status !== "unsupported-domain") q.push("negative height " + b.status);
4714
+ return q; } } });
4715
+ checkInverseCase({ caseId: "G9.12.7", requirement: "12.4 / spec 5.5.1(4,10) target beyond the expansion budget's reach (log of 10↑↑(1e19): the solution ~1e19 exceeds 2^60 doublings) => bracketing-failed / expansion-budget-exhausted within 60 expansions, not misreported as mathematical no-solution",
4716
+ operation: "hyper_log", direction: "log", call: function () { return MetaNum.hyper_log(MetaNum(10).tetr(1e19), 10, 2, D); },
4717
+ expect: { status: "bracketing-failed", termination: "expansion-budget-exhausted", isNaN: true, check: function (r) { return r.expansions === 60 && r.forwardEvaluations <= 70 ? [] : ["expansions=" + r.expansions + " fw=" + r.forwardEvaluations]; } } });
4718
+ checkInverseCase({ caseId: "G9.12.8", requirement: "12.4 upper-layer Infinity as a target => non-finite-input (never a finite upper bound); overflow on the analytic side (1e308 root) stays exact via MetaNum arithmetic",
4719
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(Infinity, 2, 2, D); }, expect: { status: "non-finite-input", isNaN: true },
4720
+ check: function () { var r = MetaNum.hyper_root(1e308, 2, 1, D); return r.value.eq(MetaNum(1e154)) || Math.abs(r.value.toNumber() - 1e154) <= 1e154 * 1e-9 ? [] : ["root(1e308,2,1) -> " + r.value]; } });
4721
+ checkInverseCase({ caseId: "G9.12.9", requirement: "12.4 analytic precision limit: root(1e300,1000,1) — the closed-form candidate fails forward verification by error amplification (1.995^1000) and is reported unrecoverable, not returned as a fake root",
4722
+ operation: "hyper_root", direction: "root", call: function () { return MetaNum.hyper_root(1e300, 1000, 1, D); },
4723
+ expect: { status: ["unrecoverable", "approximate"], allowNaN: true, check: function (r) {
4724
+ if (r.value.isNaN()) return r.status === "unrecoverable" && r.termination === "analytic-verification-failed" ? [] : ["unexpected " + r.status + "/" + r.termination];
4725
+ return r.residual.relative !== null && r.residual.relative <= 1e-9 ? [] : ["finite without residual evidence"];
4726
+ } },
4727
+ note: "design 2.4.1(5): a formula candidate that fails substitution is discarded and the path may fail; the small mirror case root(1e-300,1000,1)=0.501 verifies fine" });
4728
+ // forward-side Infinity during bracketing could not be produced by the public forward (MetaNum saturates to finite layer markers) — recorded as not executed
4729
+ checkInverseCase({ caseId: "G9.12.10", requirement: "12.4 'finite target with forward overflow to Infinity inside the bracket': NOT EXECUTED — the public forward saturates to finite ε-markers (epsl(10,epsl(10,5)) = 1ε9007199254740990) instead of Infinity, so no stable vector exists; recorded, not replaced by a smooth sample",
4730
+ operation: "solver", direction: "-", call: function () { return MetaNum(1); }, run: false,
4731
+ note: "closest executed coverage: G9.12.7 (target above image) and G9.12.8 (Infinity target)" });
4732
+ checkInverseCase({ caseId: "G9.12.11", requirement: "12.4 'secant candidate actually rejected for leaving the bracket / worsening residual' — the representable-lane case above shows fallbackCount>0; an injected out-of-bracket candidate cannot be forced without a production hook (not added), so the exact rejection branch is covered only indirectly",
4733
+ operation: "solver", direction: "-", call: function () { return MetaNum(1); }, run: false,
4734
+ note: "indirect coverage via G9.12.4 (fallbackCount=auto>0, bisection=0); no production hook added per 12.4" });
4735
+ })();
4736
+
4737
+ // ───────────────────────────────────────────────────────────────────────────
4738
+ // G9.13 input immutability, global configuration isolation, determinism (12.5)
4739
+ // ───────────────────────────────────────────────────────────────────────────
4740
+ console.log("\n=== G9.13 input immutability, config isolation and determinism (12.5) ===");
4741
+ (function () {
4742
+ var D = INV_DIAG;
4743
+ function snap(m) { return JSON.stringify([m.sign, m.array, m.layer]); }
4744
+ var c = MetaNum(2).tetr(2.5), n = MetaNum(2), v = MetaNum(10).aperiote(15), b = MetaNum(15);
4745
+ var before = [snap(c), snap(n), snap(v), snap(b)];
4746
+ var opts = { tol: 1e-10, diagnostics: true };
4747
+ MetaNum.hyper_log(c, n, 2, opts); MetaNum.hyper_root(MetaNum(1.5).tetr(2), n, 2, { diagnostics: true });
4748
+ v.inv_aperiote(10, { diagnostics: true }); v.aperiote_root(b, { diagnostics: true }); MetaNum.root_aperiote(v, b);
4749
+ var after = [snap(c), snap(n), snap(v), snap(b)];
4750
+ checkInverseCase({ caseId: "G9.13.1", requirement: "12.5 / spec 4.2.2 no input MetaNum is mutated (sign/array/layer identical before/after) and the caller's options object is not modified",
4751
+ operation: "mixed", direction: "log+root", call: function () { return MetaNum.hyper_log(c, n, 2, D); },
4752
+ expect: { status: "approximate", check: function () {
4753
+ var q = []; before.forEach(function (s, i) { if (s !== after[i]) q.push("input " + i + " mutated"); });
4754
+ if (Object.keys(opts).length !== 2 || opts.tol !== 1e-10 || opts.diagnostics !== true) q.push("options mutated: " + JSON.stringify(opts));
4755
+ return q; } } });
4756
+ var rows0 = MetaNum.maxRows, cols0 = MetaNum.maxCols, leaked = "";
4757
+ try { MetaNum.maxRows = 20; MetaNum.maxCols = 12; MetaNum.arrow(10, 40, 10).aperiote_root(40, D); MetaNum(10).aperiote(15).inv_aperiote(10, D); }
4758
+ catch (e) { leaked = e.message; } finally { MetaNum.maxRows = rows0; MetaNum.maxCols = cols0; }
4759
+ checkInverseCase({ caseId: "G9.13.2", requirement: "12.5 temporary maxRows/maxCols are restored in finally and the default configuration is unchanged afterwards",
4760
+ operation: "config", direction: "-", call: function () { return MetaNum(10).aperiote(15).inv_aperiote(10, D); },
4761
+ expect: { value: 15, check: function () { var q = []; if (MetaNum.maxRows !== rows0 || MetaNum.maxCols !== cols0) q.push("config not restored"); if (leaked) q.push("threw: " + leaked); return q; } } });
4762
+ var r1 = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D), r2 = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D);
4763
+ var r3 = MetaNum(10).aperiote(15).aperiote_root(15, D), r4 = MetaNum.root_aperiote(MetaNum(10).aperiote(15), 15, D);
4764
+ checkInverseCase({ caseId: "G9.13.3", requirement: "12.5 / spec 4.2.1 determinism: same input, branch, tol, budgets and representation config => same value, status, termination and counts across repeated calls and alias forms",
4765
+ operation: "mixed", direction: "log+root", call: function () { return r1; },
4766
+ expect: { status: "approximate", check: function () {
4767
+ var q = [];
4768
+ if (!r1.value.eq(r2.value) || r1.status !== r2.status || r1.termination !== r2.termination || r1.iterations !== r2.iterations || r1.forwardEvaluations !== r2.forwardEvaluations || r1.fallbackCount !== r2.fallbackCount) q.push("log repeat differs");
4769
+ if (!r3.value.eq(r4.value) || r3.status !== r4.status || r3.termination !== r4.termination || r3.iterations !== r4.iterations) q.push("alias repeat differs");
4770
+ return q; } } });
4771
+ var snap1 = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D);
4772
+ var originalArray = JSON.stringify(snap1.value.array);
4773
+ snap1.value.array[0][0] = 424242; snap1.options.tol = 5; snap1.iterations = 999; if (snap1.bracket && snap1.bracket.lo instanceof MetaNum) snap1.bracket.lo.array[0][0] = 7;
4774
+ var snap2 = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D);
4775
+ checkInverseCase({ caseId: "G9.13.4", requirement: "12.5 diagnostic snapshots are isolated copies: mutating a returned result's value/options/bracket cannot change later calls or any input",
4776
+ operation: "hyper_log", direction: "log", call: function () { return snap2; },
4777
+ expect: { status: "approximate", check: function () {
4778
+ var q = [];
4779
+ if (JSON.stringify(snap2.value.array) !== originalArray) q.push("later call altered by snapshot mutation");
4780
+ if (snap2.options.tol !== 1e-12 || snap2.iterations === 999) q.push("options/iterations leaked");
4781
+ if (snap(c) !== before[0]) q.push("target mutated through snapshot");
4782
+ return q; } } });
4783
+ checkInverseCase({ caseId: "G9.13.5", requirement: "12.5 no global last-diagnostics state: a diagnostics call leaves no trace observable by a later default call (no Promise, no global)",
4784
+ operation: "hyper_log", direction: "log", call: function () { var p = MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2, D); return MetaNum.hyper_log(MetaNum(2).tetr(2.5), 2, 2); },
4785
+ expect: { approx: { to: 2.5, tol: 1e-9 }, check: function (r, v) {
4786
+ var q = []; if (typeof v.then === "function") q.push("returned a Promise"); if (typeof v.status === "string") q.push("default call returned a diagnostics object"); return q; } } });
4787
+ })();
4788
+
4789
+ // ───────────────────────────────────────────────────────────────────────────
4790
+ // G9.14 inverse summary and process gate (10.1 / 14.2)
4791
+ // ───────────────────────────────────────────────────────────────────────────
4792
+ console.log("\n=== G9.14 inverse test summary and process gate ===");
4793
+ (function () {
4794
+ var ev = INVERSE_STATS.evidence, cats = INVERSE_STATS.categories;
4795
+ console.log("INV SUMMARY | cases=" + INVERSE_STATS.total + " pass=" + INVERSE_STATS.pass + " fail=" + INVERSE_STATS.fail + " error=" + INVERSE_STATS.error + " skipped=" + INVERSE_STATS.skipped);
4796
+ console.log("INV EVIDENCE | definition-guaranteed=" + (ev["definition-guaranteed"] || 0) + " representation-level=" + (ev["representation-level"] || 0) + " numerical-experiment=" + (ev["numerical-experiment"] || 0) + " not-applicable=" + (ev["not-applicable"] || 0));
4797
+ console.log("INV CATEGORIES | " + Object.keys(cats).sort().map(function (k) { return k + "=" + cats[k]; }).join(" "));
4798
+ if (INVERSE_STATS.failedCases.length) console.log("INV FAILED CASES | " + INVERSE_STATS.failedCases.join(", "));
4799
+ var skippedIds = [];
4800
+ console.log("INV NOTE | skipped rows are recorded above as SKIP lines with their reason (never replaced by a success sample)");
4801
+ void skippedIds;
4802
+ process.exitCode = (GATE_COUNTS.fail || GATE_COUNTS.error) ? 1 : 0;
4803
+ console.log("GATE | FAIL lines=" + GATE_COUNTS.fail + " ERROR lines=" + GATE_COUNTS.error + " => exit code " + process.exitCode);
4804
+ })();