gdp-wired 0.47.0 → 0.48.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.
Files changed (170) hide show
  1. package/README.md +15 -4
  2. package/dist/core/carry.d.ts +15 -0
  3. package/dist/core/carry.js +651 -0
  4. package/dist/core/cli.d.ts +3 -1
  5. package/dist/core/cli.js +28 -8
  6. package/dist/core/count-cases.d.ts +24 -0
  7. package/dist/core/count-cases.js +320 -0
  8. package/dist/core/count-cert-grow.d.ts +4 -0
  9. package/dist/core/count-cert-grow.js +37 -0
  10. package/dist/core/count-cert-transport.d.ts +3 -0
  11. package/dist/core/count-cert-transport.js +58 -0
  12. package/dist/core/count-completion.d.ts +9 -0
  13. package/dist/core/count-completion.js +27 -0
  14. package/dist/core/count-cubes.d.ts +8 -0
  15. package/dist/core/count-cubes.js +69 -0
  16. package/dist/core/count-demand.d.ts +37 -0
  17. package/dist/core/count-demand.js +361 -0
  18. package/dist/core/count-facts.d.ts +52 -0
  19. package/dist/core/count-facts.js +247 -0
  20. package/dist/core/count-focus-proof.d.ts +8 -0
  21. package/dist/core/count-focus-proof.js +140 -0
  22. package/dist/core/count-focused.d.ts +22 -0
  23. package/dist/core/count-focused.js +676 -0
  24. package/dist/core/count-ranges.d.ts +5 -0
  25. package/dist/core/count-ranges.js +65 -0
  26. package/dist/core/count-recovery/action-guard.d.ts +5 -0
  27. package/dist/core/count-recovery/action-guard.js +51 -0
  28. package/dist/core/count-recovery/boolean-core.d.ts +16 -0
  29. package/dist/core/count-recovery/boolean-core.js +258 -0
  30. package/dist/core/count-recovery/carried-case.d.ts +2 -0
  31. package/dist/core/count-recovery/carried-case.js +24 -0
  32. package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
  33. package/dist/core/count-recovery/conditional-check-cache.js +130 -0
  34. package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
  35. package/dist/core/count-recovery/conditional-cuts.js +318 -0
  36. package/dist/core/count-recovery/conditional-proof.d.ts +19 -0
  37. package/dist/core/count-recovery/conditional-proof.js +306 -0
  38. package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
  39. package/dist/core/count-recovery/derivability-closure.js +533 -0
  40. package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
  41. package/dist/core/count-recovery/empty-count-source.js +40 -0
  42. package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
  43. package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
  44. package/dist/core/count-recovery/field-case.d.ts +5 -0
  45. package/dist/core/count-recovery/field-case.js +89 -0
  46. package/dist/core/count-recovery/field-demand.d.ts +46 -0
  47. package/dist/core/count-recovery/field-demand.js +47 -0
  48. package/dist/core/count-recovery/field-only.d.ts +3 -0
  49. package/dist/core/count-recovery/field-only.js +18 -0
  50. package/dist/core/count-recovery/fold-path.d.ts +6 -0
  51. package/dist/core/count-recovery/fold-path.js +35 -0
  52. package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
  53. package/dist/core/count-recovery/frame-lemmas.js +120 -0
  54. package/dist/core/count-recovery/guard-cases.d.ts +12 -0
  55. package/dist/core/count-recovery/guard-cases.js +138 -0
  56. package/dist/core/count-recovery/key-closure.d.ts +14 -0
  57. package/dist/core/count-recovery/key-closure.js +62 -0
  58. package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
  59. package/dist/core/count-recovery/leaf-allowance.js +7 -0
  60. package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
  61. package/dist/core/count-recovery/lift-count-proxies.js +175 -0
  62. package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
  63. package/dist/core/count-recovery/live-dependencies.js +76 -0
  64. package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
  65. package/dist/core/count-recovery/member-inclusions.js +168 -0
  66. package/dist/core/count-recovery/member-premises.d.ts +29 -0
  67. package/dist/core/count-recovery/member-premises.js +114 -0
  68. package/dist/core/count-recovery/natural-cases.d.ts +6 -0
  69. package/dist/core/count-recovery/natural-cases.js +59 -0
  70. package/dist/core/count-recovery/ops.d.ts +6 -0
  71. package/dist/core/count-recovery/ops.js +8 -0
  72. package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
  73. package/dist/core/count-recovery/pre-state-source.js +18 -0
  74. package/dist/core/count-recovery/rebase-path.d.ts +9 -0
  75. package/dist/core/count-recovery/rebase-path.js +70 -0
  76. package/dist/core/count-recovery/rename-proof.d.ts +2 -0
  77. package/dist/core/count-recovery/rename-proof.js +102 -0
  78. package/dist/core/count-recovery/row-cases.d.ts +16 -0
  79. package/dist/core/count-recovery/row-cases.js +291 -0
  80. package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
  81. package/dist/core/count-recovery/scalar-guards.js +291 -0
  82. package/dist/core/count-recovery/source-memo.d.ts +12 -0
  83. package/dist/core/count-recovery/source-memo.js +67 -0
  84. package/dist/core/count-select.d.ts +16 -0
  85. package/dist/core/count-select.js +24 -0
  86. package/dist/core/count-support.d.ts +598 -0
  87. package/dist/core/count-support.js +2080 -0
  88. package/dist/core/count-unions.d.ts +2 -0
  89. package/dist/core/count-unions.js +139 -0
  90. package/dist/core/count-witness-flags.d.ts +9 -0
  91. package/dist/core/count-witness-flags.js +37 -0
  92. package/dist/core/count-write-frames.d.ts +12 -0
  93. package/dist/core/count-write-frames.js +206 -0
  94. package/dist/core/counts.d.ts +20 -2
  95. package/dist/core/counts.js +807 -156
  96. package/dist/core/dsl.d.ts +50 -6
  97. package/dist/core/dsl.js +307 -65
  98. package/dist/core/effect.js +8 -1
  99. package/dist/core/exists.d.ts +1 -1
  100. package/dist/core/exists.js +80 -15
  101. package/dist/core/extract-check.d.ts +7 -1
  102. package/dist/core/extract-check.js +130 -13
  103. package/dist/core/extract-read.d.ts +22 -8
  104. package/dist/core/extract-read.js +29 -11
  105. package/dist/core/extract-shapes.js +122 -41
  106. package/dist/core/extract-standalone.js +53 -9
  107. package/dist/core/extract.js +9 -3
  108. package/dist/core/field-laws.d.ts +2 -0
  109. package/dist/core/field-laws.js +100 -0
  110. package/dist/core/finite-frontiers.d.ts +5 -0
  111. package/dist/core/finite-frontiers.js +116 -0
  112. package/dist/core/finite-houdini.d.ts +52 -0
  113. package/dist/core/finite-houdini.js +460 -0
  114. package/dist/core/finite-model.d.ts +13 -0
  115. package/dist/core/finite-model.js +68 -0
  116. package/dist/core/finite-tiny.d.ts +72 -0
  117. package/dist/core/finite-tiny.js +1052 -0
  118. package/dist/core/infer.d.ts +1 -1
  119. package/dist/core/infer.js +32 -9
  120. package/dist/core/laws.d.ts +2 -1
  121. package/dist/core/laws.js +47 -14
  122. package/dist/core/lemma-cuts.d.ts +38 -0
  123. package/dist/core/lemma-cuts.js +365 -0
  124. package/dist/core/machine.d.ts +39 -2
  125. package/dist/core/machine.js +240 -35
  126. package/dist/core/mutate.d.ts +55 -0
  127. package/dist/core/mutate.js +210 -0
  128. package/dist/core/native-domain.d.ts +6 -0
  129. package/dist/core/native-domain.js +114 -0
  130. package/dist/core/native-law.d.ts +3 -0
  131. package/dist/core/native-law.js +174 -0
  132. package/dist/core/quorum-laws.d.ts +5 -0
  133. package/dist/core/quorum-laws.js +239 -0
  134. package/dist/core/relational.js +10 -2
  135. package/dist/core/relevance.d.ts +4 -0
  136. package/dist/core/relevance.js +79 -0
  137. package/dist/core/runtime-wall.d.ts +3 -0
  138. package/dist/core/runtime-wall.js +4 -0
  139. package/dist/core/sample-step.d.ts +16 -0
  140. package/dist/core/sample-step.js +28 -0
  141. package/dist/core/source-check.d.ts +44 -0
  142. package/dist/core/source-check.js +126 -0
  143. package/dist/core/source-diagnostic.d.ts +1 -0
  144. package/dist/core/source-diagnostic.js +34 -0
  145. package/dist/core/support-budget.d.ts +2 -0
  146. package/dist/core/support-budget.js +6 -0
  147. package/dist/core/system.js +2 -0
  148. package/dist/core/wall.d.ts +6 -0
  149. package/dist/core/wall.js +23 -0
  150. package/dist/core/watch.js +4 -0
  151. package/dist/kernel/cdcl.d.ts +4 -0
  152. package/dist/kernel/cdcl.js +20 -5
  153. package/dist/kernel/kernel.d.ts +10 -0
  154. package/dist/kernel/kernel.js +56 -3
  155. package/dist/kernel/model-sequence.d.ts +2 -2
  156. package/dist/kernel/model-sequence.js +4 -3
  157. package/dist/kernel/model-values.d.ts +2 -0
  158. package/dist/kernel/model-values.js +60 -0
  159. package/dist/kernel/prove.d.ts +10 -0
  160. package/dist/kernel/prove.js +56 -8
  161. package/dist/kernel/prover-rows.d.ts +29 -0
  162. package/dist/kernel/prover-rows.js +114 -0
  163. package/dist/lean-kernel/emit.d.ts +39 -2
  164. package/dist/lean-kernel/emit.js +136 -24
  165. package/dist/lean-kernel/lean-terms.d.ts +1 -0
  166. package/dist/lean-kernel/lean-terms.js +13 -5
  167. package/dist/lean-kernel/library.js +4 -0
  168. package/dist/lean-kernel/qalpha.d.ts +7 -0
  169. package/dist/lean-kernel/qalpha.js +40 -0
  170. package/package.json +5 -1
@@ -7,6 +7,7 @@
7
7
  // every other key the step reads).
8
8
  import { boundOf, crossFree, eachParts, historyMachine, tuple, keyTerm, mapArities, plainKey, scope, sumRuntime, tupleParts } from "../kernel/kernel.js";
9
9
  import { add, env, eq, k, le, lt, nat, scale, show, solve, sub, v } from "./solver.js";
10
+ import { runtimeWall } from "./runtime-wall.js";
10
11
  // The one generator of the repo's random draws: x' = (1103515245 x + 12345) mod 2^31, exact (Math.imul). In doubles
11
12
  // the product passes 2^53 and rounds, which folds every seed into one of six short cycles (61 to 10,466 steps; 98.8% of
12
13
  // seeds into the same one). Its period is 2^31 (core/rand.test.ts). Draws are its high bits (the low ones repeat with a
@@ -41,6 +42,47 @@ export const walkOnce = (t, f) => {
41
42
  };
42
43
  go(t);
43
44
  };
45
+ const directBody = (d) => {
46
+ switch (d.kind) {
47
+ case 'div':
48
+ case 'mod': return { kind: d.kind, divisor: d.divisor };
49
+ case 'const': return { kind: d.kind, value: d.value };
50
+ case 'recur': return { kind: d.kind, name: d.name, args: d.args, zero: d.zero, next: d.next, uses: d.uses };
51
+ }
52
+ };
53
+ // Only runtime semantics belong in the snapshot, never Lean definitions or recurrence proof receipts.
54
+ const directDescriptor = (d) => d.kind !== 'recur' ? directBody(d) : {
55
+ ...directBody(d), uses: Object.fromEntries(Object.entries(d.uses).map(([name, fn]) => [name, {
56
+ js: fn.js, arity: fn.arity ?? 1, call: fn.call, direct: fn.direct && directDescriptor(fn.direct),
57
+ }])),
58
+ };
59
+ // Bind a library implementation to the exact source it replaces. Keep the association in JSON too: a WeakMap alone
60
+ // cannot recognize a serialized machine. Overridden source/arity/call is custom code, never the old implementation.
61
+ // This is a consistency check on trusted library metadata, not provenance or validation of arbitrary input.
62
+ export const bindDirect = (fn, direct) => ({ ...directBody(direct), source: { js: fn.js, arity: fn.arity ?? 1, ...(fn.call === undefined ? {} : { call: fn.call }), descriptor: JSON.stringify(directDescriptor(direct)) } });
63
+ export const directOf = (fn) => {
64
+ const d = fn.direct, s = d?.source;
65
+ if (!d || !s || s.js !== fn.js || s.arity !== (fn.arity ?? 1) || s.call !== fn.call)
66
+ return undefined;
67
+ try {
68
+ if (s.descriptor !== JSON.stringify(directDescriptor(d)))
69
+ return undefined;
70
+ switch (d.kind) {
71
+ case 'div':
72
+ case 'mod': return Number.isSafeInteger(d.divisor) && d.divisor >= 1 ? d : undefined;
73
+ case 'const': return Number.isSafeInteger(d.value) && d.value >= 0 ? d : undefined;
74
+ case 'recur': return Array.isArray(d.args) && d.args.length + 1 === s.arity ? d : undefined;
75
+ default: return undefined;
76
+ }
77
+ }
78
+ catch {
79
+ return undefined;
80
+ } // Malformed/cyclic metadata is not a source-free implementation.
81
+ };
82
+ export const sourceFreeFn = (fn) => {
83
+ const d = directOf(fn);
84
+ return !!d && (d.kind !== 'recur' || Object.values(d.uses).every(sourceFreeFn));
85
+ };
44
86
  // A write at one key, for the parts that take no write at every key (the symbolic prover, the GPU synthesizers, the
45
87
  // hand-written shader, the first Lean export): they refuse one by name.
46
88
  export const pointWrite = (w, where) => { if ('each' in w)
@@ -107,8 +149,9 @@ export function arithmetic(ks) {
107
149
  const fns = {}, facts = [];
108
150
  for (const k of [...new Set(ks)].sort((a, b) => a - b)) {
109
151
  const d = divName(k), r = modName(k), key = `x$${r}`, at = (map) => get(map, x(key));
110
- fns[d] = { js: `x => Math.floor(x / ${k})`, lean: `fun x => x / ${k}` };
111
- fns[r] = { js: `x => x % ${k}`, lean: `fun x => x % ${k}` };
152
+ const quotient = { js: `x => Math.floor(x / ${k})`, lean: `fun x => x / ${k}` }, remainder = { js: `x => x % ${k}`, lean: `fun x => x % ${k}` };
153
+ fns[d] = { ...quotient, direct: bindDirect(quotient, { kind: 'div', divisor: k }) };
154
+ fns[r] = { ...remainder, direct: bindDirect(remainder, { kind: 'mod', divisor: k }) };
112
155
  facts.push({ name: `${r}: x = ${k}·(x div ${k}) + x mod ${k}`, forall: key, holds: same(x(key), plus(times(k, at(d)), at(r))) }, { name: `${r}: x mod ${k} < ${k}`, forall: key, holds: less(at(r), n(k)) });
113
156
  }
114
157
  return { fns, facts };
@@ -293,22 +336,103 @@ export function evalE(e, env, st, m) {
293
336
  }
294
337
  // A function's value at a key (the GPU search tabulates functions with it).
295
338
  export const fnValue = (fn, key) => naturalIn(fnOf(fn)(key), `a function at ${key}`);
296
- // A function's JavaScript, compiled once.
339
+ // Call a helper on its arguments, without computing their potentially enormous paired key.
340
+ export const fnCall = (fn, args) => naturalIn(callOf(fn)(...args), 'a function call');
341
+ const directCall = (d) => {
342
+ if (d.kind === 'div')
343
+ return x => Math.floor(x / d.divisor);
344
+ if (d.kind === 'mod')
345
+ return x => x % d.divisor;
346
+ if (d.kind === 'const')
347
+ return () => d.value;
348
+ // Match recurJs: check each completed step, memoize by the fixed arguments, restart for a smaller x.
349
+ // Arithmetic inside an equation is evaluated just as in generated code; no paired key is needed for calls.
350
+ const memo = new Map();
351
+ const value = (e, env) => {
352
+ switch (e.op) {
353
+ case 'const': return e.value;
354
+ case 'var': return env[e.name];
355
+ case 'add': return value(e.a, env) + value(e.b, env);
356
+ case 'sub': return Math.max(0, value(e.a, env) - value(e.b, env));
357
+ case 'mul': return e.k * value(e.a, env);
358
+ case 'prod': return value(e.a, env) * value(e.b, env);
359
+ case 'min': return Math.min(value(e.a, env), value(e.b, env));
360
+ case 'max': return Math.max(value(e.a, env), value(e.b, env));
361
+ case 'if': return condition(e.c, env) ? value(e.then, env) : value(e.else, env);
362
+ case 'get': {
363
+ const fn = d.uses[e.map], args = pairedArgs(e.key, fn.arity ?? 1);
364
+ return args ? callOf(fn)(...args.map(a => value(a, env))) : fnOf(fn)(value(e.key, env));
365
+ }
366
+ case 'tup':
367
+ case 'proj': throw new Error('a recurrence takes no tuple key');
368
+ }
369
+ };
370
+ const condition = (c, env) => {
371
+ switch (c.op) {
372
+ case '<': return value(c.a, env) < value(c.b, env);
373
+ case '<=': return value(c.a, env) <= value(c.b, env);
374
+ case '=': return value(c.a, env) === value(c.b, env);
375
+ case 'and': return c.xs.every(c => condition(c, env));
376
+ case 'or': return c.xs.some(c => condition(c, env));
377
+ case 'not': return !condition(c.x, env);
378
+ case 'flag':
379
+ case 'all': throw new Error('a recurrence takes no flag or quantifier');
380
+ }
381
+ };
382
+ return (x, ...args) => {
383
+ const key = args.join(), env = Object.fromEntries(d.args.map((a, i) => [a, args[i]]));
384
+ let at = memo.get(key);
385
+ if (!at || at[0] > x)
386
+ at = [0, value(d.zero, env)];
387
+ let prev = at[1];
388
+ for (let i = at[0]; i < x; i++) {
389
+ prev = value(d.next, { ...env, x: i, prev });
390
+ if (!Number.isSafeInteger(prev))
391
+ throw new RangeError(`${d.name} passes the safe integers`);
392
+ }
393
+ if (memo.size > 4096)
394
+ memo.clear();
395
+ memo.set(key, [x, prev]);
396
+ return prev;
397
+ };
398
+ };
399
+ const currentFn = (fn, cached) => cached && cached.js === fn.js && cached.arity === fn.arity && cached.call === fn.call && cached.direct === directOf(fn) ? cached.value : undefined;
400
+ const cacheFn = (fn, value) => ({ js: fn.js, arity: fn.arity, call: fn.call, direct: directOf(fn), value });
297
401
  const compiledFns = new WeakMap();
298
402
  const fnOf = (fn) => {
299
- let f = compiledFns.get(fn);
403
+ let f = currentFn(fn, compiledFns.get(fn));
300
404
  if (!f) {
301
- f = compileFunction(['k'], `return (${fn.js})(k)`);
302
- compiledFns.set(fn, f);
405
+ if (directOf(fn)) {
406
+ const call = callOf(fn), arity = fn.arity ?? 1;
407
+ f = key => {
408
+ const args = [];
409
+ let z = key;
410
+ for (let i = 1; i < arity; i++) {
411
+ let s = Math.floor(Math.sqrt(z));
412
+ while (s * s > z)
413
+ s--;
414
+ while ((s + 1) * (s + 1) <= z)
415
+ s++;
416
+ const q = z - s * s;
417
+ args.unshift(q);
418
+ z = s - q;
419
+ }
420
+ return call(z, ...args);
421
+ };
422
+ }
423
+ else
424
+ f = compileFunction(['k'], `return (${fn.js})(k)`);
425
+ compiledFns.set(fn, cacheFn(fn, f));
303
426
  }
304
427
  return f;
305
428
  };
306
429
  const compiledCalls = new WeakMap();
307
430
  const callOf = (fn) => {
308
- let f = compiledCalls.get(fn);
431
+ let f = currentFn(fn, compiledCalls.get(fn));
309
432
  if (!f) {
310
- f = compileFunction([], `return (${fn.call})`)();
311
- compiledCalls.set(fn, f);
433
+ const direct = directOf(fn);
434
+ f = direct ? directCall(direct) : compileFunction([], `return (${fn.call ?? fn.js})`)();
435
+ compiledCalls.set(fn, cacheFn(fn, f));
312
436
  }
313
437
  return f;
314
438
  };
@@ -450,14 +574,15 @@ export function compileC(c, m) {
450
574
  // same value, which need not be the default), and past it the value is the new default.
451
575
  function writeEvery(w, env, st, m, parts = 1, map) {
452
576
  if (parts > 1) {
453
- const t = eachParts(w, parts), same = map !== undefined && unchanged(t, map, env, st, m);
577
+ const t = tupleOf(w, parts), same = map !== undefined && unchanged(t, map, env, st, m);
454
578
  return same ? { cells: new Map(st.maps[map]), default: st.defaults && Object.hasOwn(st.defaults, map) ? st.defaults[map] : m.maps[map] } : writeEveryTuple(t, env, st, m);
455
579
  }
456
580
  if (!plainKey(w.value, w.each)) {
457
581
  const ks = breakKeys(breaksOf(w.value, w.each), env, st, m), top = ks.at(-1);
458
582
  // (each breakpoint on its own, and each stretch between two at one key of it: no read moves and no comparison turns
459
583
  // inside one, so it holds one value; most stretches hold the default, and a stretch that doesn't is filled)
460
- const at = (key) => evalE(w.value, { ...env, [w.each]: key }, st, m);
584
+ // (one environment for every key, the key written into it: evalE reads its environment and never keeps it)
585
+ const env1 = { ...env }, at = (key) => { env1[w.each] = key; return evalE(w.value, env1, st, m); };
461
586
  const fallback = at(top), cells = new Map();
462
587
  for (let i = 0; i + 1 < ks.length; i++) {
463
588
  const key = ks[i], v = at(key);
@@ -475,28 +600,42 @@ function writeEvery(w, env, st, m, parts = 1, map) {
475
600
  }
476
601
  return { cells, default: fallback };
477
602
  }
478
- const keys = keysAt(st, mapsIn(w.value)), past = keys.at(-1);
479
- const fallback = evalE(w.value, { ...env, [w.each]: past }, st, m), cells = new Map();
603
+ const keys = keysAt(st, mapsIn(w.value)), past = keys.at(-1), env1 = { ...env, [w.each]: past };
604
+ const fallback = evalE(w.value, env1, st, m), cells = new Map();
480
605
  for (const key of keys.slice(0, -1)) {
481
- const v = evalE(w.value, { ...env, [w.each]: key }, st, m);
606
+ env1[w.each] = key;
607
+ const v = evalE(w.value, env1, st, m);
482
608
  if (v !== fallback)
483
609
  cells.set(key, v);
484
610
  }
485
611
  return { cells, default: fallback };
486
612
  }
613
+ const tupleWrites = new WeakMap();
614
+ function tupleOf(w, parts) {
615
+ let byParts = tupleWrites.get(w);
616
+ if (!byParts)
617
+ tupleWrites.set(w, (byParts = new Map()));
618
+ let t = byParts.get(parts);
619
+ if (!t) {
620
+ const e = eachParts(w, parts), body = { op: '=', a: e.value, b: { op: 'const', value: 0 } }, free = crossFree(body, e.names);
621
+ t = { ...e, bs: e.names.map(name => breaksOf(free, name)), crossed: JSON.stringify(free) !== JSON.stringify(body), reads: new WeakMap() };
622
+ byParts.set(parts, t);
623
+ }
624
+ return t;
625
+ }
487
626
  // A write at every tuple of a map of n parts, read at its parts (kernel.ts's eachParts): each part's breakpoints together
488
627
  // (as a condition at every tuple of keys reads them), every tuple of them, and each stretch between two breakpoints at
489
628
  // one key of it. Past the last breakpoint in any part the value must be the new default (a value other than it along an
490
629
  // unbounded stretch is cells without end), and a stretch filled in two parts or more at once must read no comparison
491
630
  // between the parts (the value along it then depends on more than the stretch).
492
631
  function writeEveryTuple(t, env, st, m) {
493
- const n = t.names.length, body = { op: '=', a: t.value, b: { op: 'const', value: 0 } }, free = crossFree(body, t.names);
494
- const bs = t.names.map(name => breaksOf(free, name));
495
- const crossed = JSON.stringify(free) !== JSON.stringify(body);
632
+ const n = t.names.length, { bs, crossed } = t;
496
633
  // (parts compared with no other part: each on its own breakpoints; else all of them together, n keys after each)
497
634
  const merged = crossed ? spread(breakKeys({ reads: bs.flatMap(b => b.reads), cmps: bs.flatMap(b => b.cmps) }, env, st, m), n) : undefined;
498
635
  const kss = bs.map(b => merged ?? breakKeys(b, env, st, m));
499
- const at = (xs) => evalE(t.value, { ...env, ...Object.fromEntries(t.names.map((name, i) => [name, xs[i]])) }, st, m);
636
+ // (one environment for every tuple, the parts written into it: evalE reads its environment and never keeps it)
637
+ const env1 = { ...env }, at = (xs) => { for (let i = 0; i < n; i++)
638
+ env1[t.names[i]] = xs[i]; return evalE(t.value, env1, st, m); };
500
639
  const fallback = at(kss.map(ks => ks.at(-1))), cells = new Map();
501
640
  // (each key of a part's keys, and after each the stretch up to the next, at its first key: [key, end) with end the
502
641
  // next; the last key stands for every key past it)
@@ -546,7 +685,9 @@ const tupleKey = (xs) => xs.slice(0, -1).reduceRight((b, a) => cpair(a, b), xs.a
546
685
  // decided at the request (the flags, the inputs, the state), is the map's own cell at the tuple of the parts, as read
547
686
  // (M[k]) or as a member (if(1 <= M[k], 1, 0) where every cell is 0 or 1 already). Then no tuple need be visited.
548
687
  function unchanged(t, map, env, st, m) {
549
- const names = new Set(t.names), reads = (u) => JSON.stringify(u).match(/"name":"([^"]+)"/g)?.some(x => names.has(x.slice(8, -1))) ?? false;
688
+ // (whether a condition reads a part is a fact of the term within its write, read once per term)
689
+ const names = new Set(t.names), reads = (u) => { let r = t.reads.get(u); if (r === undefined)
690
+ t.reads.set(u, (r = JSON.stringify(u).match(/"name":"([^"]+)"/g)?.some(x => names.has(x.slice(8, -1))) ?? false)); return r; };
550
691
  const cond = (c) => {
551
692
  if (!reads(c)) {
552
693
  try {
@@ -625,7 +766,7 @@ class CountCells extends Map {
625
766
  super.set(x, v);
626
767
  } return v; }
627
768
  }
628
- export function carriedView(m, st, input, rename = map => map, params) {
769
+ export function carriedView(m, st, input, rename = map => map, params, checkpoint) {
629
770
  const counts = Object.entries(m.counts ?? {});
630
771
  if (!m.inputMaps?.length && !counts.length)
631
772
  return st;
@@ -649,8 +790,13 @@ export function carriedView(m, st, input, rename = map => map, params) {
649
790
  maps[rename(c)] = new CountCells(x => {
650
791
  const e1 = d.base ? { ...env0, [d.j]: Math.floor(x / d.base), [d.lo]: x % d.base } : { ...env0, [d.j]: x }, n = evalE(d.below, e1, view, m);
651
792
  let sum = 0;
652
- for (let k = 0; k < n; k++)
793
+ for (let k = 0; k < n; k++) {
794
+ if ((k & 255) === 0) {
795
+ runtimeWall.check?.('derived count');
796
+ checkpoint?.();
797
+ }
653
798
  sum = exact(sum + evalE(d.body, { ...e1, [d.key]: k }, view, m));
799
+ }
654
800
  return sum;
655
801
  });
656
802
  defaults[rename(c)] = 0;
@@ -664,7 +810,7 @@ export const numbersOf = (input) => Object.fromEntries(Object.entries(input).fil
664
810
  // it (a caller that may send one checks first, as gdp-wired/gdp's gate does).
665
811
  const refused = (m) => `${m.name}: the request fails the rule's assumption, so no proof covers the step it would take`;
666
812
  // The interpreter: persistent (a step leaves the state it was given as it was), so searches can branch from any state.
667
- export function interpret(m) {
813
+ export function interpret(m, checkpoint) {
668
814
  const { h, plain, carried } = runnable(m), arity = mapArities(plain);
669
815
  const args = (params, input) => {
670
816
  const env = {};
@@ -675,7 +821,7 @@ export function interpret(m) {
675
821
  env[i] = naturalIn(input[i], `input ${i}`);
676
822
  return env;
677
823
  };
678
- const viewed = (st, input, params) => carriedView(m, st, input, undefined, params);
824
+ const viewed = (st, input, params) => carriedView(m, st, input, undefined, params, checkpoint);
679
825
  // The records a request's queries read: with pruning, those not yet spent at its order.
680
826
  const live = (env, st) => {
681
827
  const records = st.history;
@@ -767,14 +913,24 @@ const RUNTIME = [
767
913
  ['$p', `function $p(a, b) { const s = a + b, v = (s % 2 === 0 ? (s / 2) * (s + 1) : s * ((s + 1) / 2)) + b; if (!Number.isSafeInteger(v)) throw new RangeError('a tuple key passed 2^53 - 1, past which the proofs over the naturals no longer describe the run'); return v; }`],
768
914
  ['$u', `function $u(z) { const tri = t => (t % 2 === 0 ? (t / 2) * (t + 1) : t * ((t + 1) / 2)); let s = Math.floor((Math.sqrt(8 * z + 1) - 1) / 2); while (s > 0 && tri(s) > z) s--; while (tri(s + 1) <= z) s++; const b = z - tri(s); return [s - b, b]; }`],
769
915
  ['$m', `function $m(v, what) { if (!(v instanceof Map)) throw new RangeError(what + ' must be a Map of naturals'); for (const [key, x] of v) { $n(key, 'a key of ' + what); $n(x, 'a cell of ' + what); } return v; }`],
770
- ['$keys', `function $keys(maps, names) { const keys = new Set(); let past = 0; for (const c of Object.values(maps)) for (const key of c.keys()) past = Math.max(past, key + 1); for (const n of names) for (const key of maps[n].keys()) keys.add(key); return [...keys, past]; }`],
771
- ['$breaks', `function $breaks(maps, reads, cmps) { const p = new Set([0]); for (const [n, d, minus] of reads) { for (const s of maps[n].keys()) { if (minus) p.add(s + d); else if (s >= d) p.add(s - d); } if (minus) p.add(d); } for (const [v, d, minus] of cmps) { if (minus) { p.add(v + d); p.add(d); } else if (v >= d) p.add(v - d); } const keys = new Set(); for (const q of p) for (let i = -1; i <= 2; i++) if (q + i >= 0) keys.add(q + i); const sorted = [...keys].sort((a, b) => a - b); sorted.push(sorted[sorted.length - 1] + 1); return sorted; }`],
916
+ // ($unique: the naturals of `vals` (each at most `top`) sorted and made unique. A dense range is marked in a reused
917
+ // stamp buffer and read back in key order, no sort and no Set per step; a sparse one falls back to a Set and a sort.
918
+ // The stamp never reaches 2^32 − 1: at that count the buffer is zeroed and the stamps restart at 1, so a stale mark
919
+ // can never equal a live stamp; a grown buffer starts at 0 likewise.)
920
+ ['$unique', `function $unique(vals, top) { if (top > 4 * vals.length + 64 || top > 1048576) return [...new Set(vals)].sort((a, b) => a - b); let buf = $unique.buf; if (!buf || buf.length <= top) { buf = new Uint32Array(Math.max(top + 1, buf ? 2 * buf.length : 256)); $unique.buf = buf; $unique.stamp = 0; } let s = $unique.stamp + 1; if (s >= 0xFFFFFFFF) { buf.fill(0); s = 1; } $unique.stamp = s; for (let i = 0; i < vals.length; i++) buf[vals[i]] = s; const out = []; for (let i = 0; i <= top; i++) if (buf[i] === s) out.push(i); return out; }`],
921
+ ['$keys', `function $keys(maps, names) { const keys = []; let past = 0; for (const n of Object.keys(maps)) for (const key of maps[n].keys()) if (key + 1 > past) past = key + 1; for (const n of names) for (const key of maps[n].keys()) keys.push(key); const out = $unique(keys, past); out.push(past); return out; }`],
922
+ // ($breaks: every breakpoint q of the reads and comparisons and its neighbours q − 1 .. q + 2, sorted and unique, then one
923
+ // past the last. A dense set is marked straight into $unique's stamp buffer (no array of the neighbours and no second
924
+ // pass); a sparse one goes through $unique's Set path. Both give the same list.)
925
+ ['$breaks', `function $breaks(maps, reads, cmps) { const p = [0]; let top = 0; for (const [n, d, minus] of reads) { for (const s of maps[n].keys()) { const q = minus ? s + d : s - d; if (q >= 0) { p.push(q); if (q > top) top = q; } } if (minus) { p.push(d); if (d > top) top = d; } } for (const [v, d, minus] of cmps) { if (minus) { p.push(v + d); p.push(d); if (v + d > top) top = v + d; } else if (v >= d) { p.push(v - d); if (v - d > top) top = v - d; } } const t2 = top + 2; if (t2 > 16 * p.length + 64 || t2 > 1048576) { const vals = []; for (let j = 0; j < p.length; j++) { const q = p[j]; for (let i = -1; i <= 2; i++) if (q + i >= 0) vals.push(q + i); } const out = $unique(vals, t2); out.push(out[out.length - 1] + 1); return out; } let buf = $unique.buf; if (!buf || buf.length <= t2) { buf = new Uint32Array(Math.max(t2 + 1, buf ? 2 * buf.length : 256)); $unique.buf = buf; $unique.stamp = 0; } let s = $unique.stamp + 1; if (s >= 0xFFFFFFFF) { buf.fill(0); s = 1; } $unique.stamp = s; for (let j = 0; j < p.length; j++) { const q = p[j]; for (let i = q > 0 ? q - 1 : 0; i <= q + 2; i++) buf[i] = s; } const out = []; for (let i = 0; i <= t2; i++) if (buf[i] === s) out.push(i); out.push(out[out.length - 1] + 1); return out; }`],
772
926
  // A condition at every two keys that holds wherever x(k) differs from y(k1): only the pairs whose values match are read.
773
927
  ['$join', `function $join(ks, x, y, f) { const by = new Map(); for (const k1 of ks) { const v = y(k1), l = by.get(v); if (l) l.push(k1); else by.set(v, [k1]); } return ks.every(k => { const l = by.get(x(k)); return l === undefined || l.every(k1 => f(k, k1)); }); }`],
774
- ['$spread', `function $spread(keys, n) { const out = new Set(); for (const k of keys) for (let i = 0; i < n; i++) out.add(k + i); return [...out].sort((a, b) => a - b); }`],
928
+ ['$spread', `function $spread(keys, n) { const vals = []; let top = 0; for (const k of keys) for (let i = 0; i < n; i++) { vals.push(k + i); if (k + i > top) top = k + i; } return $unique(vals, top); }`],
775
929
  // (the interpreter's writeEvery: each breakpoint, and each stretch between two at one key of it, filled only where it
776
930
  // holds other than the value past the last)
777
931
  ['$dense', `function $dense(keys, f) { const top = keys[keys.length - 1], d = f(top), cells = new Map(); for (let i = 0; i + 1 < keys.length; i++) { const key = keys[i], v = f(key); if (v !== d) cells.set(key, v); if (keys[i + 1] > key + 1) { const u = f(key + 1); if (u !== d) { if (keys[i + 1] - key > 1000000) throw new RangeError('a write at every key fills a stretch of more than a million keys (' + (key + 1) + ' to ' + (keys[i + 1] - 1) + ')'); for (let k2 = key + 1; k2 < keys[i + 1]; k2++) cells.set(k2, u); } } } return {cells, d}; }`],
932
+ // (a request's count map in the generated code: each cell its sum, computed when first read, as carriedView's CountCells)
933
+ ['$cells', `class $cells extends Map { constructor(at) { super(); this.at = at; } get(x) { let v = super.get(x); if (v === undefined) { v = this.at(x); super.set(x, v); } return v; } }`],
778
934
  ['$every', `function $every(keys, f) { const past = keys[keys.length - 1], d = f(past), cells = new Map(); for (let i = 0; i < keys.length - 1; i++) { const v = f(keys[i]); if (v !== d) cells.set(keys[i], v); } return {cells, d}; }`],
779
935
  ];
780
936
  function runtimeFor(code) {
@@ -809,7 +965,7 @@ function joinOf(c, k, k1) {
809
965
  export function compileJs(m) { return compileJsMode(m, false); }
810
966
  // fastStep keeps the input state persistent. Its fork can wait until every
811
967
  // precondition and right-hand side has been evaluated, just before the writes.
812
- function compileJsMode(m, persistent) {
968
+ function compileJsMode(m, persistent, cells) {
813
969
  const { h, plain, queries, carried } = runnable(m);
814
970
  // (a condition or a write at every key over a tuple key: the interpreter decides those, part by part)
815
971
  const atEvery = [...Object.values(plain.step.flags ?? {}).filter(c => c.op === 'all'), ...Object.values(plain.step.maps ?? {}).filter(w => 'each' in w)];
@@ -889,7 +1045,17 @@ function compileJsMode(m, persistent) {
889
1045
  const parts = names.map(n => breaksOf(body, n));
890
1046
  return `$spread(${breaksJs({ reads: parts.flatMap(b => b.reads), cmps: parts.flatMap(b => b.cmps) })}, ${names.length})`;
891
1047
  };
892
- const every = (w) => { const keys = keysJs(w.value, w.each), dense = !plainKey(w.value, w.each), outer = bound; bound = { [w.each]: 'k' }; const body = ex(w.value); bound = outer; return `${dense ? '$dense' : '$every'}(${keys}, k => ${body})`; };
1048
+ const every = (w, shared) => { const dense = !plainKey(w.value, w.each), keys = shared ?? keysJs(w.value, w.each), outer = bound; bound = { [w.each]: 'k' }; const body = ex(w.value); bound = outer; return `${dense ? '$dense' : '$every'}(${keys}, k => ${body})`; };
1049
+ // Writes at every key with the same breakpoints (the same reads and comparisons) share one list per step, computed once
1050
+ // instead of once per write; a write with breakpoints of its own keeps its own list, since $dense evaluates a write's
1051
+ // value at every key of the list it is given, and a list holding another write's breakpoints would cost it those.
1052
+ const denseWrites = Object.entries(plain.step.maps ?? {}).filter((e) => 'each' in e[1] && !plainKey(e[1].value, e[1].each));
1053
+ const breaksText = new Map(denseWrites.map(([name, w]) => [name, JSON.stringify(breaksOf(w.value, w.each))]));
1054
+ const sharedBreaks = new Map();
1055
+ for (const [text, count] of [...breaksText.values()].reduce((acc, text) => acc.set(text, (acc.get(text) ?? 0) + 1), new Map()))
1056
+ if (count > 1)
1057
+ sharedBreaks.set(text, `bk${sharedBreaks.size}`);
1058
+ const sharedOf = (name) => sharedBreaks.get(breaksText.get(name) ?? '');
893
1059
  const writes = Object.entries(plain.step.maps ?? {});
894
1060
  const env = (input) => `{${[...m.params.map(p => `${id(p)}: $n(params[${id(p)}], ${id(`param ${p}`)})`), ...(input ? carried.map(i => `${id(i)}: $n(input[${id(i)}], ${id(`input ${i}`)})`) : [])].join(', ')}}`;
895
1061
  // Reads go through `maps` (with the maps the request carries); writes go to the state's own.
@@ -914,7 +1080,7 @@ function compileJsMode(m, persistent) {
914
1080
  }
915
1081
  lines.push(...flags.map((name, i) => `const flag${i} = ${cx(plain.step.flags[name])};`),
916
1082
  // The rule's own assumption, as `allowed` (core/watch.ts) reads it (a history's machine assumes more: its relations).
917
- ...(m.assume ? [`if (!${cx(m.assume)}) throw new RangeError(${id(refused(m))});`] : []), `const scalars = {...s, ${Object.entries(plain.step.state ?? {}).map(([name, e]) => `${id(name)}: ${ex(e)}`).join(', ')}};`, ...writes.map(([, w], i) => ('each' in w ? `const write${i} = ${every(w)};` : `const key${i} = ${ex(w.key)}, value${i} = ${ex(w.value)};`)));
1083
+ ...(m.assume ? [`if (!${cx(m.assume)}) throw new RangeError(${id(refused(m))});`] : []), `const scalars = {...s, ${Object.entries(plain.step.state ?? {}).map(([name, e]) => `${id(name)}: ${ex(e)}`).join(', ')}};`, ...[...sharedBreaks].map(([text, bk]) => `const ${bk} = ${breaksJs(JSON.parse(text))};`), ...writes.map(([name, w], i) => ('each' in w ? `const write${i} = ${every(w, sharedOf(name))};` : `const key${i} = ${ex(w.key)}, value${i} = ${ex(w.value)};`)));
918
1084
  if (h)
919
1085
  lines.push(`const keep = ${cx(h.keep)};`);
920
1086
  if (persistent)
@@ -927,7 +1093,25 @@ function compileJsMode(m, persistent) {
927
1093
  else
928
1094
  lines.push('return Object.keys(dft).length ? {scalars, maps: state.maps, defaults: dft} : {scalars, maps: state.maps};');
929
1095
  const fnDefs = fns.map((name, i) => `const fn${i} = (${m.fns[name].js});\n${m.fns[name].call ? `const fnc${i} = (${m.fns[name].call});\n` : ''}`).join('');
930
- const code = `export function init(params) {
1096
+ // The request's counts (carriedView's CountCells, compiled): the view's maps (the state's, the maps the request carries as
1097
+ // given — the step validates them before any write, so a bad one still ends in its RangeError —,
1098
+ // then each count as a $cells whose cell at x is the sum of its body over the keys below its bound, read through the same
1099
+ // view, so a count's body may read another count), as the step reads them through `input`.
1100
+ const cellsCode = cells ? `export function cells(params, state, input, tick) {
1101
+ const env = ${env(true)}, s = state.scalars, dft = {...state.defaults}, maps = {...state.maps${cells.inputMaps.map(mp => `, ${id(mp)}: input[${id(mp)}]`).join('')}};
1102
+ ${Object.entries(cells.decls).map(([c, d]) => {
1103
+ const outer = bound;
1104
+ bound = { ...bound, [d.j]: 'cj', ...(d.base ? { [d.lo]: 'clo' } : {}) };
1105
+ const below = ex(d.below);
1106
+ bound = { ...bound, [d.key]: 'ck' };
1107
+ const body = ex(d.body);
1108
+ bound = outer;
1109
+ return `maps[${id(c)}] = new $cells(x => { const cj = ${d.base ? `Math.floor(x / ${d.base}), clo = x % ${d.base}` : 'x'}; const n = ${below}; let sum = 0; for (let ck = 0; ck < n; ck++) { if ((ck & 255) === 0) tick(); sum = $x(sum + ${body}); } return sum; });`;
1110
+ }).join('\n ')}
1111
+ return maps;
1112
+ }
1113
+ ` : '';
1114
+ const code = `${cellsCode}export function init(params) {
931
1115
  const env = ${env(false)}, s = {};
932
1116
  return {scalars: {${Object.entries(plain.state).map(([name, e]) => `${id(name)}: ${ex(e)}`).join(', ')}}, maps: {${Object.keys(plain.maps ?? {}).map(name => `${id(name)}: new Map()`).join(', ')}}${h ? ', history: [], head: 0' : ''}};
933
1117
  }
@@ -949,24 +1133,45 @@ export function compileFunction(params, body) {
949
1133
  return new Function(...params, body);
950
1134
  }
951
1135
  export const loadJs = (m) => loadJsMode(m, false);
952
- const loadJsMode = (m, persistent) => compileFunction([], `${compileJsMode(m, persistent).replace(/^export function/gm, 'function')}\nreturn {init, fork, step}`)();
1136
+ const loadJsMode = (m, persistent, cells) => compileFunction([], `${compileJsMode(m, persistent, cells).replace(/^export function/gm, 'function')}\nreturn {init, fork, step${cells ? ', cells' : ''}}`)();
953
1137
  // The interpreter's step (persistent: a copy of the state each) through loadJs's, several times faster, a request's counts
954
1138
  // given to it as maps the request carries (carriedView's, each cell its sum when read); none with a history, or where the
955
1139
  // generator refuses the machine.
956
1140
  export function fastStep(m) {
957
- const cs = Object.keys(m.counts ?? {});
1141
+ // (the counts the step itself reads, in its guards, flags, writes or assumption: a count only a law reads is never
1142
+ // computed for a step; a count's body may read another count, so the closure is taken)
1143
+ const all = m.counts ?? {}, read = new Set();
1144
+ walk([m.step, m.assume ?? null, m.pre ?? null], o => { if (o.op === 'get' && o.map in all)
1145
+ read.add(o.map); });
1146
+ for (let grew = true; grew;) {
1147
+ grew = false;
1148
+ for (const c of [...read])
1149
+ walk([all[c].below, all[c].body], o => { if (o.op === 'get' && o.map in all && !read.has(o.map)) {
1150
+ read.add(o.map);
1151
+ grew = true;
1152
+ } });
1153
+ }
1154
+ const cs = Object.keys(all).filter(c => read.has(c));
958
1155
  let js;
1156
+ const decls = Object.fromEntries(cs.map(c => [c, all[c]]));
1157
+ // (the counts compiled with the step, unless the machine has least keys, whose names the step alone computes)
1158
+ const compiledCells = cs.length && !Object.keys(m.leasts ?? {}).length;
959
1159
  try {
960
1160
  if (m.history)
961
1161
  return undefined;
962
- js = loadJsMode({ ...m, counts: undefined, inputMaps: [...m.inputMaps ?? [], ...cs] }, true);
1162
+ js = loadJsMode({ ...m, counts: undefined, inputMaps: [...m.inputMaps ?? [], ...cs] }, true, compiledCells ? { decls, inputMaps: m.inputMaps ?? [] } : undefined);
963
1163
  }
964
1164
  catch {
965
1165
  return undefined;
966
1166
  }
1167
+ const only = cs.length ? { ...m, counts: decls } : m, tick = () => runtimeWall.check?.('derived count');
967
1168
  return (params, st, input) => {
968
- const view = cs.length ? carriedView(m, st, input, undefined, params).maps : {};
969
- return js.step(params, st, cs.length ? { ...input, ...Object.fromEntries(cs.map(c => [c, view[c]])) } : input);
1169
+ if (!cs.length)
1170
+ return js.step(params, st, input);
1171
+ const view = compiledCells ? js.cells(params, st, input, tick) : carriedView(only, st, input, undefined, params).maps, carried = { ...input };
1172
+ for (const c of cs)
1173
+ carried[c] = view[c];
1174
+ return js.step(params, st, carried);
970
1175
  };
971
1176
  }
972
1177
  const cross = (as, f) => as.flatMap(a => f(a.value).map(b => ({ path: [...a.path, ...b.path], value: b.value })));
@@ -0,0 +1,55 @@
1
+ import type { Machine } from './machine.js';
2
+ export type SourceEdit = {
3
+ file: string;
4
+ from: string;
5
+ to: string;
6
+ bug: string;
7
+ name?: string;
8
+ };
9
+ export type MutationSuite = {
10
+ name: string;
11
+ command: string[];
12
+ };
13
+ export type MutationConfig = {
14
+ mutants: SourceEdit[];
15
+ suites: MutationSuite[];
16
+ lawSuite: string;
17
+ cwd?: string;
18
+ timeoutMs?: number;
19
+ };
20
+ export type SuiteReceipt = {
21
+ status: 'caught' | 'missed' | 'error';
22
+ exit: number | null;
23
+ output: string;
24
+ error?: string;
25
+ };
26
+ export type MutationRow = {
27
+ mutant: string;
28
+ bug: string;
29
+ suites: Record<string, SuiteReceipt>;
30
+ };
31
+ export type MutationResult = {
32
+ passed: boolean;
33
+ rows: MutationRow[];
34
+ markdown: string;
35
+ };
36
+ /** Compare each trusted source edit against each suite, restoring exact original bytes in finally.
37
+ * Infrastructure errors (including timeout/signal/output overflow) never count as a killed mutant.
38
+ * No process can restore after SIGKILL or power loss: use a disposable working tree.
39
+ */
40
+ export declare function checkMutations(config: MutationConfig): MutationResult;
41
+ export type DecisionMutationOptions = {
42
+ /** File containing exactly one copy of render(machine); the runner verifies that match. */
43
+ file: string;
44
+ /** Trusted, deterministic source/JSON printer. The same printer handles original and mutated terms. */
45
+ render: (machine: Machine) => string;
46
+ /** Legal numeric encodings of input/parameter choices; never inferred from comparison literals. */
47
+ choices?: Record<string, readonly number[]>;
48
+ maxCandidates?: number;
49
+ };
50
+ /** Derive single-occurrence implementation mutations, not weakened laws or assumptions.
51
+ * Pure scalar decisions only. The explicit printer bridges machine terms to the source artifact under test;
52
+ * this does not claim an automatic inverse mapping from terms to arbitrary hand-written TypeScript.
53
+ * Candidates may be equivalent: only the suites determine which laws kill them.
54
+ */
55
+ export declare function deriveDecisionMutants(machine: Machine, options: DecisionMutationOptions): SourceEdit[];