gdp-wired 0.50.6 → 0.52.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 (91) hide show
  1. package/README.md +2 -2
  2. package/dist/core/accel-refute.d.ts +53 -0
  3. package/dist/core/accel-refute.js +997 -0
  4. package/dist/core/cli.d.ts +2 -0
  5. package/dist/core/cli.js +8 -1
  6. package/dist/core/cycles.d.ts +2 -0
  7. package/dist/core/cycles.js +12 -9
  8. package/dist/core/dsl.d.ts +11 -2
  9. package/dist/core/dsl.js +194 -29
  10. package/dist/core/fixed-division.d.ts +9 -0
  11. package/dist/core/fixed-division.js +87 -0
  12. package/dist/core/fixed-integers.d.ts +33 -0
  13. package/dist/core/fixed-integers.js +279 -0
  14. package/dist/core/live-support.d.ts +5 -0
  15. package/dist/core/live-support.js +148 -0
  16. package/dist/core/live.js +194 -37
  17. package/dist/core/lockstep.d.ts +5 -0
  18. package/dist/core/lockstep.js +23 -0
  19. package/dist/core/machine.d.ts +1 -0
  20. package/dist/core/machine.js +33 -3
  21. package/dist/core/ordered-pair-seeds.d.ts +2 -0
  22. package/dist/core/ordered-pair-seeds.js +109 -0
  23. package/dist/core/proof-output.d.ts +38 -1
  24. package/dist/core/proof-output.js +38 -0
  25. package/dist/core/search-termination.d.ts +4 -0
  26. package/dist/core/search-termination.js +1 -1
  27. package/dist/core/source-check.d.ts +4 -1
  28. package/dist/core/source-check.js +5 -2
  29. package/dist/core/sparse-kind-proof.d.ts +7 -0
  30. package/dist/core/sparse-kind-proof.js +49 -0
  31. package/dist/core/step-seeds.d.ts +46 -0
  32. package/dist/core/step-seeds.js +316 -0
  33. package/dist/kernel/integer-primitives.d.ts +38 -0
  34. package/dist/kernel/integer-primitives.js +179 -0
  35. package/dist/kernel/kernel.d.ts +1 -0
  36. package/dist/kernel/kernel.js +44 -5
  37. package/dist/kernel/prove.js +13 -0
  38. package/dist/kernel/word-division-cuts.d.ts +6 -0
  39. package/dist/kernel/word-division-cuts.js +69 -0
  40. package/dist/kernel/word-division.d.ts +12 -0
  41. package/dist/kernel/word-division.js +167 -0
  42. package/dist/lean-kernel/Cert.lean +222 -0
  43. package/dist/lean-kernel/Count.lean +1568 -0
  44. package/dist/lean-kernel/Ghost.lean +373 -0
  45. package/dist/lean-kernel/GhostMap.lean +426 -0
  46. package/dist/lean-kernel/Kernel.lean +2881 -0
  47. package/dist/lean-kernel/Live.lean +1168 -0
  48. package/dist/lean-kernel/Progress.lean +543 -0
  49. package/dist/lean-kernel/Sets.lean +1975 -0
  50. package/dist/lean-kernel/StepLaw.lean +128 -0
  51. package/dist/lean-kernel/Steps.lean +477 -0
  52. package/dist/lean-kernel/Sums.lean +916 -0
  53. package/dist/lean-kernel/emit.d.ts +8 -1
  54. package/dist/lean-kernel/emit.js +59 -15
  55. package/dist/lean-kernel/integer-primitives.d.ts +17 -0
  56. package/dist/lean-kernel/integer-primitives.js +81 -0
  57. package/dist/lean-kernel/lean-aggregate/FiniteFold.lean +44 -0
  58. package/dist/lean-kernel/lean-aggregate/GroupedTransport.lean +308 -0
  59. package/dist/lean-kernel/lean-aggregate/aggregate.d.ts +13 -0
  60. package/dist/lean-kernel/lean-aggregate/aggregate.js +68 -0
  61. package/dist/lean-kernel/lean-aggregate/assets.d.ts +5 -0
  62. package/dist/lean-kernel/lean-aggregate/assets.js +7 -0
  63. package/dist/lean-kernel/lean-aggregate/audit.d.ts +3 -0
  64. package/dist/lean-kernel/lean-aggregate/audit.js +13 -0
  65. package/dist/lean-kernel/lean-aggregate/exact.d.ts +15 -0
  66. package/dist/lean-kernel/lean-aggregate/exact.js +51 -0
  67. package/dist/lean-kernel/lean-aggregate/index.d.ts +19 -0
  68. package/dist/lean-kernel/lean-aggregate/index.js +52 -0
  69. package/dist/lean-kernel/lean-aggregate/point-fold.d.ts +27 -0
  70. package/dist/lean-kernel/lean-aggregate/point-fold.js +79 -0
  71. package/dist/lean-kernel/lean-aggregate/replay-fold.d.ts +2 -0
  72. package/dist/lean-kernel/lean-aggregate/replay-fold.js +163 -0
  73. package/dist/lean-kernel/lean-aggregate/source.d.ts +2 -0
  74. package/dist/lean-kernel/lean-aggregate/source.js +141 -0
  75. package/dist/lean-kernel/lean-aggregate/weighted-flags.d.ts +2 -0
  76. package/dist/lean-kernel/lean-aggregate/weighted-flags.js +26 -0
  77. package/dist/lean-kernel/lean-aggregate/weighted-replay.d.ts +7 -0
  78. package/dist/lean-kernel/lean-aggregate/weighted-replay.js +53 -0
  79. package/dist/lean-kernel/lean-aggregate/weighted-seeded.d.ts +30 -0
  80. package/dist/lean-kernel/lean-aggregate/weighted-seeded.js +64 -0
  81. package/dist/lean-kernel/lean-aggregate/weighted.d.ts +18 -0
  82. package/dist/lean-kernel/lean-aggregate/weighted.js +115 -0
  83. package/dist/lean-kernel/lean-aggregate/worker.d.ts +10 -0
  84. package/dist/lean-kernel/lean-aggregate/worker.js +46 -0
  85. package/dist/lean-kernel/library.js +13 -0
  86. package/dist/lean-kernel/word-division-export.d.ts +26 -0
  87. package/dist/lean-kernel/word-division-export.js +172 -0
  88. package/dist/lean-kernel/word-division-lower.d.ts +10 -0
  89. package/dist/lean-kernel/word-division-lower.js +103 -0
  90. package/docs/lean-aggregate.md +29 -0
  91. package/package.json +6 -1
@@ -51,6 +51,8 @@ type LawOut = SearchTerminationFields & Omit<TranslationFields, 'translationWitn
51
51
  from?: 'any';
52
52
  verdict: 'proven' | 'broken' | 'unknown' | 'not read';
53
53
  run?: string[];
54
+ fairRing?: Verdict['fairRing'];
55
+ acceleratedRun?: Verdict['acceleratedRun'];
54
56
  replayed?: string;
55
57
  why?: string;
56
58
  assumes?: string[];
package/dist/core/cli.js CHANGED
@@ -787,7 +787,10 @@ function prove(x0, l, ms, proven, ctx, work = ctx?.work) {
787
787
  catch (e) {
788
788
  return { ...base, kind: 'leads to', verdict: 'unknown', why: e.message, ms: cliNow() - t0 };
789
789
  }
790
- return { ...base, ...translationOf(v), ...searchOf(v), kind: 'leads to', verdict: v.proven && v.checked ? 'proven' : 'unknown', ...(v.proven && v.checked ? {} : { why: whyOf(v, [v.goal, v.stuck, v.why].filter(Boolean).join('; ') || 'not proven') }), ms: cliNow() - t0 };
790
+ const checked = v.proven && v.checked, ring = v.translation === undefined ? v.fairRing : undefined;
791
+ return { ...base, ...translationOf(v), ...searchOf(v), kind: 'leads to', verdict: checked ? 'proven' : 'unknown',
792
+ ...(ring ? { fairRing: ring, why: `a model fair ring stays pending (${ring.stem.length} stem steps, ${ring.sets.length} recurring sets); native source replay unavailable` } :
793
+ checked ? {} : { why: whyOf(v, [v.goal, v.stuck, v.why].filter(Boolean).join('; ') || 'not proven') }), ms: cliNow() - t0 };
791
794
  }
792
795
  let b, two;
793
796
  // (a law that can't be built is not read, with why: never the whole check aborted)
@@ -844,6 +847,10 @@ function prove(x0, l, ms, proven, ctx, work = ctx?.work) {
844
847
  if (!v.run)
845
848
  v = { ...v, why: `broken from a state the laws allow (from = "any"), no run from the start found reaching it` };
846
849
  }
850
+ const accelerated = v.translation === undefined && v.acceleratedRun?.checked ? v.acceleratedRun : undefined;
851
+ if (accelerated)
852
+ return { ...base, ...searchOf(v), kind, verdict: 'unknown', acceleratedRun: accelerated,
853
+ why: `an accelerated model run of ${accelerated.totalSteps} admitted steps breaks the law; native source replay unavailable`, ms: cliNow() - t0 };
847
854
  const brokenAt = !!(ctx?.from && !v.proven && !v.run && !searchOf(v).stopped && v.stuck === 'sat' && v.witness);
848
855
  let verdict = v.proven && v.checked && !(ctx?.from && v.assumes) ? 'proven' : v.run || brokenAt ? 'broken' : 'unknown', replayed;
849
856
  if (v.translation === 'unchecked')
@@ -115,7 +115,9 @@ export type Sampler = {
115
115
  export type LeadsVerdict = {
116
116
  proven: boolean;
117
117
  checked: boolean;
118
+ evidence?: import('./proof-output.ts').LiveProofPacket;
118
119
  rank?: E[];
120
+ levels?: number[];
119
121
  laws?: Law[];
120
122
  found?: {
121
123
  rank: string;
@@ -6,6 +6,7 @@ import { and, proveCyclic, vars as vs } from "./cyclic.js";
6
6
  import { canon, env, gcd, konst, pivot, plus, ratioRow, refuteFast, solve, subst, times, vars, work } from "./solver.js";
7
7
  import { clock, grow, proveLaws, proveLiveness, proveStepLaws, withDeadline } from "../kernel/prove.js";
8
8
  import { inferLaws } from "./infer.js";
9
+ import { withStageDeadline } from "./dsl-deadline.js";
9
10
  import { bgcd } from "./q.js";
10
11
  import { generators, houdini, relationOf, tightBounds } from "./relation.js";
11
12
  // --- terms ----------------------------------------------------------------------------------------------------------
@@ -1892,9 +1893,11 @@ export function findLeadsTo(m, laws, l, sample, opts = {}) {
1892
1893
  const ms = until - clock();
1893
1894
  if (ms < 200)
1894
1895
  break;
1895
- const v = withDeadline(clock() + ms * (i === 0 && !strong.size ? 0.5 : 0.25), () => proveLiveness(m, laws, { ...l, rank }));
1896
+ const v = withStageDeadline(clock() + ms * (i === 0 && !strong.size ? 0.5 : 0.25), () => proveLiveness(m, laws, { ...l, rank }), () => undefined);
1897
+ if (!v)
1898
+ continue;
1896
1899
  if (v.proven && v.checked)
1897
- return { proven: true, checked: true, rank, laws: [], found: { rank: rankText(rank), laws: [] } };
1900
+ return { proven: true, checked: true, rank, levels: v.levels, laws: [], evidence: { machine: m, laws, liveness: { ...l, rank, ...(v.levels ? { levels: v.levels } : {}) }, report: v }, found: { rank: rankText(rank), laws: [] } };
1898
1901
  tried.set(id(rank), v);
1899
1902
  }
1900
1903
  const samples = [[...points.values()].map(env => ({ env, calls: new Set() }))];
@@ -1906,21 +1909,21 @@ export function findLeadsTo(m, laws, l, sample, opts = {}) {
1906
1909
  if (!rank)
1907
1910
  return { proven: false, checked: false, why: noRank };
1908
1911
  const text = rankText(rank), lv = { ...l, rank };
1909
- const first = tried.get(id(rank)) ?? withDeadline(until, () => proveLiveness(m, laws, lv));
1910
- if (first.proven && first.checked)
1911
- return { proven: true, checked: true, rank, laws: [], found: { rank: text, laws: [] } };
1912
+ const first = tried.get(id(rank)) ?? withStageDeadline(until, () => proveLiveness(m, laws, lv), () => undefined);
1913
+ if (first?.proven && first.checked)
1914
+ return { proven: true, checked: true, rank, levels: first.levels, laws: [], evidence: { machine: m, laws, liveness: { ...lv, ...(first.levels ? { levels: first.levels } : {}) }, report: first }, found: { rank: text, laws: [] } };
1912
1915
  const ms = until - clock();
1913
1916
  if (ms > 300) {
1914
1917
  const { stay, cover, helps } = livenessParts(m, lv), inf = inferLaws(sample.rule ?? m, laws, [stay, cover, ...helps], { ms });
1915
1918
  // (laws about every key too: a liveness about every key needs those of its key's cells)
1916
1919
  const kept = inf.found.filter(f => !f.law.some?.length), more = kept.map(f => f.law);
1917
1920
  if (inf.proven && more.length) {
1918
- const again = withDeadline(until + 5000, () => proveLiveness(m, [...laws, ...more], lv));
1919
- if (again.proven && again.checked)
1920
- return { proven: true, checked: true, rank, laws: more, found: { rank: text, laws: kept.map(f => f.text) } };
1921
+ const again = withStageDeadline(until, () => proveLiveness(m, [...laws, ...more], lv), () => undefined);
1922
+ if (again?.proven && again.checked)
1923
+ return { proven: true, checked: true, rank, levels: again.levels, laws: more, evidence: { machine: m, laws: [...laws, ...more], liveness: { ...lv, ...(again.levels ? { levels: again.levels } : {}) }, report: again }, found: { rank: text, laws: kept.map(f => f.text) } };
1921
1924
  }
1922
1925
  }
1923
- const failed = first.failed ? { goal: first.failed.goal, stuck: first.failed.stuck, ...(first.failed.witness ? { witness: first.failed.witness } : {}) } : {};
1926
+ const failed = first?.failed ? { goal: first.failed.goal, stuck: first.failed.stuck, ...(first.failed.witness ? { witness: first.failed.witness } : {}) } : {};
1924
1927
  if (!fitted)
1925
1928
  return { proven: false, checked: false, ...failed, why: `${noRank}; rank ${text}, which the runs allow, not proven, nor with the invariants found` };
1926
1929
  return { proven: false, checked: false, rank, found: { rank: text, laws: [] }, ...failed, why: `rank ${text} from the runs; the kernel's goals not proven with it` };
@@ -1,9 +1,14 @@
1
+ import { FixedWord } from './fixed-integers.js';
2
+ export { fixedInt, FixedWord, fixedFailure, fixedSelect } from './fixed-integers.js';
1
3
  import { type TranslationFields } from './source-check.js';
2
4
  import { type C, type E, type Fn, type Law, type Recurrence, type Machine, type Rand, type Request, type State, type Sum } from './machine.js';
3
5
  import { type Fold, type Ghosted, type Goal, type Liveness, type Loop, type Recur, type StepLaw, type Tree } from '../kernel/kernel.js';
4
6
  import { type Report, type ModelRoundPolicy } from '../kernel/prove.js';
5
7
  import { type WorkAmount } from './work-amount.js';
6
- import { findRing } from './live.js';
8
+ import { type AcceleratedRun, type AcceleratedSegment, checkAcceleratedRun, findAcceleratedRefutation, formatAcceleratedSummary } from './accel-refute.js';
9
+ export type { AcceleratedRun, AcceleratedSegment };
10
+ export { checkAcceleratedRun, findAcceleratedRefutation, formatAcceleratedSummary };
11
+ import { findRing, type Ring } from './live.js';
7
12
  export type TermLike = Term | number;
8
13
  export declare const termOf: (t: TermLike) => E;
9
14
  export type Rounding = 'halfEven' | 'halfUp' | 'halfDown' | 'halfAway';
@@ -56,6 +61,7 @@ export declare function when<K extends string>(c: Cond, then: Choice<K>, otherwi
56
61
  export declare function when(c: Cond, then: Str, otherwise: Str | string): Str;
57
62
  export declare function when(c: Cond, then: string, otherwise: Str): Str;
58
63
  export declare function when<V>(c: Cond, then: Maybe<V>, otherwise: Maybe<V>): Maybe<V>;
64
+ export declare function when(c: Cond, then: FixedWord, otherwise: FixedWord): FixedWord;
59
65
  export declare function when(c: Cond, then: Cond, otherwise: Cond): Cond;
60
66
  export declare function when<C extends Cases, T extends string>(c: Cond, then: Variant<C, T>, otherwise: Variant<C, T>): Variant<C, T>;
61
67
  export declare function when<T extends Record<string, unknown>>(c: Cond, then: T, otherwise: T): T;
@@ -549,7 +555,7 @@ type ValuesOf<K extends Kinds> = {
549
555
  [n in keyof K]: K[n] extends Kind<infer V> ? V : never;
550
556
  };
551
557
  type Obj = object;
552
- type Writes<V> = V extends Decimal ? DecimalLike | string : V extends Int ? IntLike : V extends Cond ? Cond | boolean : V extends Choice<infer K> ? Choice<K> | K : V extends Maybe<infer W> ? Maybe<W> | Writes<W> | null : V extends Str ? Str | string : V extends Variant<infer C, infer T> ? Variant<C, T> | VariantWrite<C, T> : V extends Term ? TermLike : V extends Record<string, unknown> ? {
558
+ type Writes<V> = V extends FixedWord ? FixedWord : V extends Decimal ? DecimalLike | string : V extends Int ? IntLike : V extends Cond ? Cond | boolean : V extends Choice<infer K> ? Choice<K> | K : V extends Maybe<infer W> ? Maybe<W> | Writes<W> | null : V extends Str ? Str | string : V extends Variant<infer C, infer T> ? Variant<C, T> | VariantWrite<C, T> : V extends Term ? TermLike : V extends Record<string, unknown> ? {
553
559
  [k in keyof V]: Writes<V[k]>;
554
560
  } : TermLike;
555
561
  type Update<S extends Obj, M extends Obj> = Partial<{
@@ -940,6 +946,9 @@ export type Verdict = TranslationFields & import('./search-termination.ts').Sear
940
946
  k?: number;
941
947
  assumes?: Assumes;
942
948
  rank?: E | E[];
949
+ levels?: number[];
950
+ fairRing?: Ring;
951
+ acceleratedRun?: AcceleratedRun;
943
952
  };
944
953
  export type Assumes = {
945
954
  states: 'reachable';
package/dist/core/dsl.js CHANGED
@@ -1,4 +1,4 @@
1
- import { retainFrom, retainCounted, publishProof, withPublicRule } from "./proof-output.js";
1
+ import { retainFrom, retainCounted, publishProof, withPublicRule, retainStepProof, publishStepProof, retainLiveProof, publishLiveProof } from "./proof-output.js";
2
2
  import { searchNow as countedSearchNow } from "./wall.js";
3
3
  // Typed builders for machines, decisions and loops: names are declared once and come back as typed values, so a
4
4
  // misspelled name, a law that reads a request, or a step that sets an undeclared variable is a TypeScript error, and
@@ -17,19 +17,26 @@ import { searchNow as countedSearchNow } from "./wall.js";
17
17
  //
18
18
  // A step returns its updates as one object: every right-hand side reads the state before the step, as the kernel and
19
19
  // both runtimes do.
20
+ import { FixedWord, fixedFailure, fixedSelect } from "./fixed-integers.js";
21
+ import { captureFixed } from "./fixed-division.js";
22
+ export { fixedInt, FixedWord, fixedFailure, fixedSelect } from "./fixed-integers.js";
20
23
  import { binder, copyVariable, encodeBinders, generatedVariable, guardReserved, internalName, plainDeclaration, variable } from "./dsl-binders.js";
21
24
  import { candidates, cone, searchCounted } from "./counts.js";
22
25
  import { proveCandidateSeeds } from "./candidate-seeds.js";
26
+ import { orderedPairSeed } from "./ordered-pair-seeds.js";
27
+ import { tryLockstepScalars } from "./lockstep.js";
23
28
  import { proveCountedCandidateSeeds } from "./counted-candidate-seeds.js";
24
- import { bindSourceMachine, inheritSource, translationVerdict } from "./source-check.js";
29
+ import { stepSeedFamilies, tryStepSeed } from "./step-seeds.js";
30
+ import { bindSourceMachine, inheritSource, isSourceBound, translationVerdict } from "./source-check.js";
25
31
  import { env as knobs } from "./solver.js";
26
32
  import { argsKey, bindDirect, directOf, machineTerms, part, tuple, carriedView, compileFunction, divName, divisor, divisorsIn, evalC, evalE, fnCall, hasFinite, interpret, isArithmetic, loadJs, modName, numbersOf, pairedArgs, seeded, sourceFreeFn, withArithmetic } from "./machine.js";
27
33
  import { allowed, keysOf, requestEnv, watch, watchWork } from "./watch.js";
28
34
  import { ghostOf, proveSome, skolemOf, someHolds, substVars, substVarsE, witnessSupport } from "./exists.js";
29
35
  import { check, mapArities, checkRecur, foldObligations, ghostedMachine, loopObligations, someOfGhostsOk, substC, sumMachine } from "../kernel/kernel.js";
30
36
  import { certLoop, clock, counted, factsFor, fullRate, grow, pastWall, proveLaw, proveLaws, proveLiveness, proveSetFast, proveStepLaws, usualProof, withModelRounds, withWall } from "../kernel/prove.js";
31
- import { WallExpired, checkWall, checkBudget, checkWorkEndpoint, searchWall, withBudget, BudgetExpired } from "./wall.js";
37
+ import { WallExpired, checkWall, checkBudget, checkWorkEndpoint, searchWall, withBudget, inBudget, BudgetExpired } from "./wall.js";
32
38
  import { completeWorkProfile } from "./work-profile.js";
39
+ import { stepWorkProfile } from "./step-work.js";
33
40
  import { workLedger } from "./work-admission.js";
34
41
  import { withStageAllowance, withStageDeadline, withStageWall, withStageWork, remainingStageWork } from "./dsl-deadline.js";
35
42
  import { completedSearch, searchContext, stoppedSearch } from "./search-termination.js";
@@ -41,10 +48,13 @@ import { certCyclic, certOn, crossCyclic, cyclicOn, foldNodes, proveCyclic, quie
41
48
  import { discover } from "./discover.js";
42
49
  import { inferLaws, inferRates } from "./infer.js";
43
50
  import { findBoundedRun } from "./bmc.js";
51
+ import { checkAcceleratedRun, findAcceleratedRefutation, formatAcceleratedSummary } from "./accel-refute.js";
52
+ export { checkAcceleratedRun, findAcceleratedRefutation, formatAcceleratedSummary };
44
53
  import { conjunction, proveKInduction } from "./kind.js";
45
54
  import { cycleLemmas, findLeadsTo, findRank } from "./cycles.js";
46
55
  import { findNeverEnds } from "./nonterm.js";
47
56
  import { findRing, leadsByTerms } from "./live.js";
57
+ import { leadsByWriteSupports } from "./live-support.js";
48
58
  import { freshLaws } from "./fresh.js";
49
59
  // --- terms and conditions -------------------------------------------------------------------------------------------
50
60
  const naturalConst = (v) => {
@@ -129,6 +139,8 @@ export const not = (c) => c.not();
129
139
  export const min = (a, b) => new Term({ op: 'min', a: termOf(a), b: termOf(b) }, both(valOf(a), valOf(b), Math.min));
130
140
  export const max = (a, b) => new Term({ op: 'max', a: termOf(a), b: termOf(b) }, both(valOf(a), valOf(b), Math.max));
131
141
  export function when(c, then, otherwise) {
142
+ if (then instanceof FixedWord && otherwise instanceof FixedWord)
143
+ return fixedSelect(c, then, otherwise);
132
144
  if (then instanceof Cond && otherwise instanceof Cond)
133
145
  return choose(c, then, otherwise);
134
146
  if (then instanceof Variant && otherwise instanceof Variant) {
@@ -178,6 +190,8 @@ const isRecord = (x) => typeof x === 'object' && x !== null && Object.getPrototy
178
190
  // missing in both or present in both and the same, a variant in the same case with the same fields, a record field by
179
191
  // field.
180
192
  export function same(a, b) {
193
+ if (a instanceof FixedWord && b instanceof FixedWord)
194
+ return a.eq(b);
181
195
  if (a instanceof Cond && b instanceof Cond)
182
196
  return a.iff(b);
183
197
  if (a instanceof Choice && b instanceof Choice)
@@ -1954,7 +1968,8 @@ export class Rule {
1954
1968
  const { kind, init: start } = x;
1955
1969
  kinded.push([n, kind]);
1956
1970
  if (typeof start === 'function') {
1957
- const parts = (p) => kind.store(n, start(p));
1971
+ const parts = (p) => { const value = start(p); const stored = kind.store(n, value); if (Object.values(stored).some(t => { const f = fixedFailure(t); return f && f.ok !== false; }))
1972
+ throw new Error(`primitive traps in initializer ${n} are not supported`); return stored; };
1958
1973
  for (const part of kind.vars(n))
1959
1974
  entries.push([part, p => parts(p)[part]]);
1960
1975
  }
@@ -2457,7 +2472,31 @@ export class Rule {
2457
2472
  if (!(n in flags))
2458
2473
  flags[n] = out;
2459
2474
  }
2460
- const updates = { ...s.step?.(env) };
2475
+ const capturedFixed = captureFixed(() => s.step?.(env));
2476
+ for (const [name, condition] of Object.entries(capturedFixed.flags)) {
2477
+ if (name in env || Object.hasOwn(flags, name))
2478
+ throw new Error(`${s.name}: fixed division flag collision ${name}`);
2479
+ flags[name] = condition;
2480
+ }
2481
+ const updates = { ...capturedFixed.value };
2482
+ // Preserve primitive effects before a kind flattens its value into natural limbs.
2483
+ const primitiveFailures = [], seenPrimitive = new Set(), seenFailure = new Set();
2484
+ const inspectPrimitive = (value) => {
2485
+ if (!value || typeof value !== 'object' || seenPrimitive.has(value))
2486
+ return;
2487
+ seenPrimitive.add(value);
2488
+ const failure = fixedFailure(value);
2489
+ if (failure && !seenFailure.has(failure.c)) {
2490
+ seenFailure.add(failure.c);
2491
+ primitiveFailures.push(failure.c);
2492
+ }
2493
+ if (Object.getPrototypeOf(value) === Object.prototype || Array.isArray(value))
2494
+ Object.values(value).forEach(inspectPrimitive);
2495
+ };
2496
+ Object.values(updates).forEach(inspectPrimitive);
2497
+ const primitiveFailure = primitiveFailures.length ? { op: 'or', xs: primitiveFailures } : undefined;
2498
+ if (primitiveFailure && (s.record || s.counts?.length || s.sums.length || s.ghost))
2499
+ throw new Error(`${s.name}: primitive traps with history, counts, sums or ghosts are not yet supported`);
2461
2500
  // A kinded variable's update, as its variables' terms.
2462
2501
  for (const [n, k] of s.kinded ?? []) {
2463
2502
  const u = updates[n];
@@ -2479,6 +2518,17 @@ export class Rule {
2479
2518
  else
2480
2519
  state[n] = hoist.term(termOf(u));
2481
2520
  }
2521
+ // A failure is retained as a stuttering branch for kernel obligations, not
2522
+ // assumed away. Runtime evaluation throws before any scalar/map/history write.
2523
+ if (primitiveFailure) {
2524
+ for (const [name, value] of Object.entries(state))
2525
+ state[name] = { op: 'if', c: primitiveFailure, then: variable(name), else: value };
2526
+ for (const [name, write] of Object.entries(maps)) {
2527
+ if ('each' in write)
2528
+ throw new Error(`${s.name}: primitive traps in per-key writes are not yet supported`);
2529
+ maps[name] = { ...write, value: { op: 'if', c: primitiveFailure, then: { op: 'get', map: name, key: write.key }, else: write.value } };
2530
+ }
2531
+ }
2482
2532
  // An existential in a precondition or the assumption: a value the params or the request bring (a param or an input
2483
2533
  // the runtimes find, encodeParams and encodeInput), fresh for each existential and, for a request, each step.
2484
2534
  const pre0 = pulledOut(s.pre.map(f => f(pEnv)), `${s.name}: a precondition`, 'some$p'), as0 = pulledOut(s.assume.map(f => f(env)), `${s.name}: the assumption`, 'some$a');
@@ -2516,6 +2566,7 @@ export class Rule {
2516
2566
  ];
2517
2567
  const m = {
2518
2568
  name: s.name, params, inputs,
2569
+ ...(primitiveFailure ? { primitiveFailure } : {}),
2519
2570
  state: Object.fromEntries(s.state.map(([n, init]) => [n, typeof init === 'number' ? termOf(init) : termOf(init(pEnv))])),
2520
2571
  ...(s.maps.length ? { maps: Object.fromEntries(s.maps) } : {}),
2521
2572
  ...(s.carried?.length ? { inputMaps: s.carried } : {}),
@@ -3346,7 +3397,7 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
3346
3397
  return undefined;
3347
3398
  }
3348
3399
  // The kernel's report as a verdict: its first goal left unproven, with its counterexample and why.
3349
- export const verdictOf = (out) => retainFrom(({ proven: out.proven, checked: out.checked, ...(out.failed ? { goal: out.failed.goal, stuck: out.failed.stuck, ...(out.failed.witness ? { witness: out.failed.witness } : {}), ...(out.failed.why ? { why: out.failed.why } : {}) } : {}) }), [out]);
3400
+ export const verdictOf = (out) => retainFrom(({ proven: out.proven && out.checked, checked: out.checked, ...(out.failed ? { goal: out.failed.goal, stuck: out.failed.stuck, ...(out.failed.witness ? { witness: out.failed.witness } : {}), ...(out.failed.why ? { why: out.failed.why } : {}) } : {}), ...(out.proven && !out.checked ? { stuck: 'unknown', why: 'kernel rejected the candidate proof' } : {}) }), [out]);
3350
3401
  const refutedVerdict = (out) => ({ proven: false, checked: false, goal: out.goal, stuck: 'sat', witness: out.witness, ...(out.run ? { run: out.run } : {}) });
3351
3402
  // The divisors some laws read (modBy, divBy), noted on the rule so its machine declares them: a law may come from
3352
3403
  // another instance of the same rule (a factory called twice).
@@ -3413,17 +3464,17 @@ function watchdogVerdict(ms, run) {
3413
3464
  export function proveRule(r, laws, opts = {}) {
3414
3465
  return watchdogVerdict(opts.watchdogMs, () => withModelRounds(opts.modelRounds, () => withPublicRule(outermost => {
3415
3466
  const captureMachine = r.machine, hasCounts = !!Object.keys(captureMachine.counts ?? {}).length;
3416
- const result = workVerdict(opts, plan => withPublicSearchPolicy(hasCounts, () => proveRuleWall(r, laws, plan)));
3467
+ const result = workVerdict(opts, plan => withPublicSearchPolicy(hasCounts, () => proveRuleWall(r, laws, plan, captureMachine)));
3417
3468
  return outermost ? publishProof(result, captureMachine, laws) : result;
3418
3469
  })));
3419
3470
  }
3420
- function proveRuleWall(r, laws, opts) {
3471
+ function proveRuleWall(r, laws, opts, captureMachine) {
3421
3472
  const ms = typeof opts.search === 'object' ? opts.search.ms : undefined;
3422
3473
  const run = () => {
3423
3474
  let result;
3424
3475
  try {
3425
3476
  checkWall('rule preflight');
3426
- const out = result = proveRuleIn(r, laws, opts);
3477
+ const out = result = proveRuleIn(r, laws, opts, captureMachine);
3427
3478
  if (!completedSearch(out) && !(out.stopped && out.termination))
3428
3479
  checkWall('rule result');
3429
3480
  return out;
@@ -3440,7 +3491,7 @@ function proveRuleWall(r, laws, opts) {
3440
3491
  const result = ms === undefined ? run() : withWall(searchWall(ms), run);
3441
3492
  return retainFrom(translationVerdict(r, laws, result), [result]);
3442
3493
  }
3443
- function proveRuleIn(r, laws, opts) {
3494
+ function proveRuleIn(r, laws, opts, captureMachine) {
3444
3495
  r = r.withSumsOf(laws, opts.candidateSeeds?.laws ?? []);
3445
3496
  noting(r, laws);
3446
3497
  if (opts.candidateSeeds) {
@@ -3472,8 +3523,44 @@ function proveRuleIn(r, laws, opts) {
3472
3523
  // A state the laws allow whose step breaks one, with no run to it (a wide rule's: what the kernel's step goal would end
3473
3524
  // at), is a counterexample to induction: the laws may still hold, so the search goes on from it, as from the kernel's.
3474
3525
  // (A step law broken so is refused, proveSteps below: it holds from every state the laws allow, reached or not.)
3526
+ if (refuted?.run)
3527
+ return refutedVerdict(refuted);
3528
+ // A narrowly matched candidate gets a bounded attempt before unrestricted
3529
+ // inference. A failed helper proof is not a verdict about the caller's law.
3530
+ const search = typeof opts.search === 'object' ? opts.search : undefined;
3531
+ const seedMs = search?.ms ?? 10_000;
3532
+ if (opts.search !== false && opts.from !== 'any' && !opts.candidateSeeds && laws.length === 1 &&
3533
+ !captureMachine.history && !Object.keys(captureMachine.sums ?? {}).length && !Object.keys(captureMachine.counts ?? {}).length &&
3534
+ !Object.keys(r.machine.sums ?? {}).length) {
3535
+ const law = laws[0];
3536
+ if (search?.work === undefined && !completeWorkProfile.enabled && seedMs > 0 && Number.isFinite(seedMs)) {
3537
+ const lockstep = tryLockstepScalars(captureMachine, law, withKinds(r, [law]).slice(0, -1), Math.min(seedMs / 2, 26_000));
3538
+ if (lockstep)
3539
+ return lockstep;
3540
+ }
3541
+ if (!Object.keys(captureMachine.fns ?? {}).length && law.forall && law.keys?.length === 1 &&
3542
+ (search?.work !== undefined || seedMs > 0 && Number.isFinite(seedMs))) {
3543
+ const start = countedSearchNow(), prove = () => {
3544
+ const seed = orderedPairSeed(captureMachine, law);
3545
+ if (!seed)
3546
+ return undefined;
3547
+ const out = proveLaws(captureMachine, withKinds(r, [seed, law]));
3548
+ if (!out.proven || !out.checked)
3549
+ return undefined;
3550
+ const found = [{ text: seed.name, law: seed }];
3551
+ return retainFrom({ ...verdictOf(out), found: { laws: found }, ...withAssumes(found) }, [out], { kind: 'inference', original: captureMachine, laws });
3552
+ };
3553
+ const out = search?.work === undefined
3554
+ ? withStageWall(start + seedMs * (2 / 3), prove, () => undefined)
3555
+ : withStageWork(remainingStageWork(search.work, 2), prove, () => undefined);
3556
+ if (out)
3557
+ return out;
3558
+ if (search?.work === undefined && search?.ms === undefined && !completeWorkProfile.enabled)
3559
+ opts = { ...opts, search: { ...search, ms: Math.max(0, seedMs - (countedSearchNow() - start)) } };
3560
+ }
3561
+ }
3475
3562
  if (refuted)
3476
- return refuted.run ? refutedVerdict(refuted) : searched(r, laws, [], refutedVerdict(refuted), opts);
3563
+ return searched(r, laws, [], refutedVerdict(refuted), opts);
3477
3564
  // A rule with counts: its goals are the counted ones (core/counts.ts searches them; the kernel checks the set).
3478
3565
  if (r.machine.counts && Object.keys(r.machine.counts).length) {
3479
3566
  const c = searchCounted(r.machine, withKinds(r, laws), typeof opts.search === 'object' ? opts.search.ms ?? 60_000 : 60_000);
@@ -3520,7 +3607,8 @@ function proveStepsWall(r, laws, stepLaws, opts) {
3520
3607
  };
3521
3608
  const verdict = opts.from !== 'any' || ms === undefined ? run()
3522
3609
  : withWall(countedSearchNow() + ms, run);
3523
- return translationVerdict(r, [...laws, ...stepLaws], verdict);
3610
+ const translated = translationVerdict(r, [...laws, ...stepLaws], verdict);
3611
+ return publishStepProof(translated, verdict);
3524
3612
  }
3525
3613
  function proveStepsIn(r, laws, stepLaws, opts) {
3526
3614
  r = r.withSumsOf(laws, stepLaws);
@@ -3529,11 +3617,48 @@ function proveStepsIn(r, laws, stepLaws, opts) {
3529
3617
  checkWorkEndpoint('refutation result');
3530
3618
  // (a step law broken from a state the laws allow, with no run to it: the laws may need an invariant there, or the run
3531
3619
  // be further than these runs go; the search goes on from it, as from the kernel's)
3532
- if (refuted)
3533
- return refuted.run ? refutedVerdict(refuted) : searched(r, laws, stepLaws, refutedVerdict(refuted), opts);
3534
- const out = proveStepLaws(r.machine, withKinds(r, laws), stepLaws);
3535
- const v = verdictOf(out);
3536
- return searched(r, laws, stepLaws, v, opts);
3620
+ if (refuted?.run)
3621
+ return refutedVerdict(refuted);
3622
+ const m = r.machine;
3623
+ // A bounded search for reachable-state supports. Keep from-any proofs,
3624
+ // explicit work accounting and real counterexample preflight unchanged.
3625
+ const sl = stepLaws.length === 1 ? stepLaws[0] : undefined;
3626
+ const search = typeof opts.search === 'object' ? opts.search : undefined;
3627
+ const ms = Math.min(55_000, (search?.ms ?? 10_000) * (11 / 12));
3628
+ let fallback = opts;
3629
+ const enabled = sl && opts.search !== false && opts.from !== 'any' &&
3630
+ search?.work === undefined && !inBudget() && !completeWorkProfile.enabled && ms > 0 && Number.isFinite(search?.ms ?? 10_000);
3631
+ const trySeeds = (law) => {
3632
+ const started = countedSearchNow();
3633
+ const seeded = withStageDeadline(clock() + ms, () => {
3634
+ for (const seeds of stepSeedFamilies(m, law).slice(0, law.forall ? 1 : 2)) {
3635
+ const found = quietly(() => tryStepSeed(m, laws, r.kindLaws(), law, seeds));
3636
+ if (found?.checked.proven && found.checked.checked && found.checked.proof)
3637
+ return { ...found, seeds };
3638
+ }
3639
+ return undefined;
3640
+ }, () => undefined);
3641
+ if (seeded) {
3642
+ const found = seeded.seeds.map(law => ({ law, text: law.name }));
3643
+ return retainStepProof({ ...verdictOf(seeded.checked), found: { laws: found }, ...withAssumes(found) }, { machine: m, family: seeded.family, step: law, report: seeded.checked, ...(seeded.kindProof ? { kindProof: seeded.kindProof } : {}) });
3644
+ }
3645
+ const elapsed = Math.max(0, countedSearchNow() - started);
3646
+ if (elapsed >= 1)
3647
+ fallback = { ...opts, search: { ...search, ms: Math.max(0, (search?.ms ?? 10_000) - elapsed) } };
3648
+ return undefined;
3649
+ };
3650
+ // For a one-row law the sparse attempt avoids the large default instance
3651
+ // set entirely. The other shapes only try seeding after a non-inductive step.
3652
+ const sparse = enabled && sl?.forall && !laws.length ? trySeeds(sl) : undefined;
3653
+ if (sparse)
3654
+ return sparse;
3655
+ const v = refuted ? refutedVerdict(refuted) : verdictOf(proveStepLaws(m, withKinds(r, laws), stepLaws));
3656
+ if (enabled && sl && !sl.forall && v.stuck === 'sat') {
3657
+ const strengthened = trySeeds(sl);
3658
+ if (strengthened)
3659
+ return strengthened;
3660
+ }
3661
+ return searched(r, laws, stepLaws, v, fallback);
3537
3662
  }
3538
3663
  // The one-step laws as laws the bounded runs read (core/bmc.ts takes laws alone): a ghost per step law, set once a step
3539
3664
  // it is about breaks it (`then` read with each primed name the step's update), and the law that it is never set. Only a
@@ -3581,7 +3706,7 @@ function searched(r, laws, stepLaws, v, opts) {
3581
3706
  }
3582
3707
  function searchedIn(r, laws, stepLaws, v, opts) {
3583
3708
  const any = opts.from === 'any';
3584
- if ((v.proven && v.checked) || opts.search === false || v.run || v.stuck === 'sat' && (any || !/@step|@\d+ steps/.test(v.goal ?? '')))
3709
+ if ((v.proven && v.checked) || opts.search === false || v.run || v.acceleratedRun?.checked || v.stuck === 'sat' && (any || !/@step|@\d+ steps/.test(v.goal ?? '')))
3585
3710
  return v;
3586
3711
  // The deeper runs; then runs over small values (keys that meet, small params), whose requests meet their
3587
3712
  // assumption's equalities and clocks, or near the counterexample the verdict ends at.
@@ -3608,7 +3733,7 @@ function searchedIn(r, laws, stepLaws, v, opts) {
3608
3733
  return searchedUntil(r, laws, stepLaws, v, opts, until);
3609
3734
  return withStageWall(countedSearchNow() + Math.max(0, until - clock()), () => {
3610
3735
  const out = searchedUntil(r, laws, stepLaws, v, opts, until);
3611
- if (!(out.proven && out.checked) && !out.run)
3736
+ if (!completedSearch(out))
3612
3737
  checkWall('search result');
3613
3738
  return out;
3614
3739
  }, () => stoppedSearch(v, { kind: 'work-exhausted', phase: 'search stage', scope: 'stage' }));
@@ -3648,6 +3773,22 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
3648
3773
  if (kd?.proven && kd.checked)
3649
3774
  return { proven: true, checked: true, k: kd.k, assumes: { states: 'reachable', laws: [] } };
3650
3775
  }
3776
+ // A compressed repeat is untrusted until the unchanged kernel proves its
3777
+ // admitted affine steps and exact replay checks the original failed law.
3778
+ // Translated source requires its own native replay; a model repeat is not it.
3779
+ if (!any && !stepLaws.length && !isSourceBound(r, laws) && !stepWorkProfile.enabled && !inBudget() &&
3780
+ laws.every(l => !l.forall && !l.keys?.length && !l.some?.length) && total > 1_000) {
3781
+ const ms = Math.min(1_500, total / 12), machine = r.machine;
3782
+ const acc = counted(fullRate, () => withStageAllowance(ms, () => findAcceleratedRefutation(machine, laws, {
3783
+ ms,
3784
+ wall: performance.now() + ms,
3785
+ shownRequest,
3786
+ randomParams: (rand, bound) => r.randomParams(rand, bound),
3787
+ randomInput: (rand, bound, ps) => r.randomInput(rand, bound, ps),
3788
+ }), () => undefined), true);
3789
+ if (acc?.checked && checkAcceleratedRun(machine, laws, acc))
3790
+ return { proven: false, checked: false, goal: `${acc.law} @accelerated (${formatAcceleratedSummary(acc)})`, stuck: 'sat', witness: acc.witness, acceleratedRun: acc };
3791
+ }
3651
3792
  let rule = r, lemmas;
3652
3793
  const { fns, lists } = r.parts;
3653
3794
  if (lists.length || fns.some(([, d]) => recurOf(d))) {
@@ -3863,23 +4004,43 @@ const withAssumes = (found) => (found.length ? { assumes: reachableBy(found) } :
3863
4004
  // The rule a keyed liveness is proven on: the rule with its key as one more param (a natural), any other rule as it is.
3864
4005
  export const keyed = (r, l) => (l.forall ? r.params({ [l.forall]: nat }) : r);
3865
4006
  export function proveLeadsTo(r, laws, l, opts = {}) {
3866
- return translationVerdict(r, [...laws, l], proveLeadsToIn(r, laws, l, opts));
4007
+ const out = proveLeadsToIn(r, laws, l, opts, !isSourceBound(r, [...laws, l]));
4008
+ return publishLiveProof(translationVerdict(r, [...laws, l], out), out);
3867
4009
  }
3868
- function proveLeadsToIn(r, laws, l, opts) {
4010
+ function proveLeadsToIn(r, laws, l, opts, allowRing) {
3869
4011
  r = keyed(r, l).withSumsOf(laws, l);
3870
4012
  noting(r, laws, l);
3871
4013
  if (laws.some(law => law.some?.length))
3872
4014
  throw new Error(`${r.machine.name}: a law with "there exists" goes to proveRule or proveSteps; a liveness takes plain laws (the ones its proof printed, Verdict.witnesses)`);
3873
4015
  if (Array.isArray(l.rank) && !l.rank.length) {
3874
- const until = clock() + (opts.ms ?? 10_000), draws = { params: (rand, bound) => r.randomParams(rand, bound), input: (rand, bound, ps) => r.randomInput(rand, bound, ps) };
4016
+ const ms = opts.ms ?? 10_000, until = clock() + ms;
4017
+ const draws = { params: (rand, bound) => r.randomParams(rand, bound), input: (rand, bound, ps) => r.randomInput(rand, bound, ps) };
4018
+ const m = r.machine, ringMs = Math.min(15_000, ms / 4);
4019
+ // History queries can keep a helpful request disabled indefinitely. Search
4020
+ // for a checked ring within the normal grant; never use a model ring as a
4021
+ // counterexample for extracted source or with unverified function facts.
4022
+ if (m.history && allowRing && !completeWorkProfile.enabled && ringMs > 1000 && Number.isFinite(ms)) {
4023
+ const found = withStageDeadline(clock() + ringMs, () => findRing(m, withKinds(r, laws), l, draws, { ms: ringMs }), () => undefined);
4024
+ if (found?.verdict.refuted)
4025
+ return { proven: false, checked: false, goal: l.name, stuck: 'sat', fairRing: found.ring };
4026
+ }
3875
4027
  // (the laws about the keys a counter hands out or a high-water mark bounds, core/fresh.ts, within a twentieth: given
3876
4028
  // to both searches, each proven again with the rank)
3877
4029
  const share = (until - clock()) / 20, fresh = Object.keys(r.machine.maps ?? {}).length ? withStageDeadline(clock() + share, () => freshLaws(r.machine, r.kindLaws(), draws, { ms: share }), () => []) : [];
3878
4030
  laws = [...laws, ...fresh.map(x => x.law)];
3879
- let f = findLeadsTo(r.machine, withKinds(r, laws), l, { ...draws, rule: r }, { ms: until - clock() });
4031
+ const ds = { ...draws, rule: r, state: (rand, bound) => Object.assign({}, ...r.kindsOfState().map(([n, kd]) => kd.random(n, rand, bound))) };
4032
+ // Strong fairness admits upward helpful handoffs at a fixed rank. Give guard-distance ranks a bounded first
4033
+ // look: the affine fit can spend the entire grant without finding a truncated distance to a guard bound.
4034
+ const firstMs = Math.min(15_000, (until - clock()) / 4), base = withKinds(r, laws);
4035
+ const early = completeWorkProfile.enabled ? undefined : withStageDeadline(Math.min(until, clock() + firstMs), () => l.fairness === 'strong' ?
4036
+ (firstMs > 1000 ? leadsByTerms(r.machine, base, l, ds, { ms: firstMs }) : undefined) :
4037
+ leadsByWriteSupports(r.machine, base, l, firstMs), () => undefined);
4038
+ let f = early?.proven && early.checked ? early : until > clock() ?
4039
+ findLeadsTo(r.machine, base, l, { ...draws, rule: r }, { ms: until - clock() }) :
4040
+ { proven: false, checked: false, why: 'liveness search reached its deadline' };
3880
4041
  // Where the rank fitted to the runs isn't the one: a rank of the rule's own terms (core/live.ts), in the time left.
3881
4042
  if (!(f.proven && f.checked) && until - clock() > 500) {
3882
- const g = leadsByTerms(r.machine, withKinds(r, laws), l, { ...draws, rule: r, state: (rand, bound) => Object.assign({}, ...r.kindsOfState().map(([n, kd]) => kd.random(n, rand, bound))) }, { ms: until - clock() });
4043
+ const g = leadsByTerms(r.machine, withKinds(r, laws), l, ds, { ms: until - clock() });
3883
4044
  if (g.proven && g.checked)
3884
4045
  f = g;
3885
4046
  }
@@ -3898,17 +4059,21 @@ function proveLeadsToIn(r, laws, l, opts) {
3898
4059
  }
3899
4060
  }
3900
4061
  const helpers = [...fresh, ...(f.laws ?? []).map((law, i) => ({ law, text: f.found?.laws[i] ?? law.name }))];
3901
- return { proven: f.proven, checked: f.checked, ...(f.proven && f.rank ? { rank: f.rank } : {}), ...(f.goal ? { goal: f.goal, stuck: f.stuck } : {}), ...(f.witness ? { witness: f.witness } : {}), ...(f.why ? { why: f.why } : {}),
3902
- ...(f.found ? { found: { rank: f.found.rank, ...(helpers.length ? { laws: helpers } : {}) } } : {}), ...(f.proven ? withAssumes(helpers) : {}) };
4062
+ return retainLiveProof({ proven: f.proven, checked: f.checked, ...(f.proven && f.rank ? { rank: f.rank } : {}), ...(f.proven && f.levels ? { levels: f.levels } : {}), ...(f.goal ? { goal: f.goal, stuck: f.stuck } : {}), ...(f.witness ? { witness: f.witness } : {}), ...(f.why ? { why: f.why } : {}),
4063
+ ...(f.found ? { found: { rank: f.found.rank, ...(helpers.length ? { laws: helpers } : {}) } } : {}), ...(f.proven ? withAssumes(helpers) : {}) }, 'evidence' in f ? f.evidence : undefined);
3903
4064
  }
3904
- const out = proveLiveness(r.machine, withKinds(r, laws), l);
3905
- return verdictOf(out);
4065
+ const machine = r.machine, family = withKinds(r, laws), out = proveLiveness(machine, family, l);
4066
+ const liveness = out.levels ? { ...l, levels: out.levels } : l;
4067
+ return retainLiveProof({ ...verdictOf(out), ...(out.proven && out.checked && out.levels ? { levels: out.levels } : {}) }, { machine, laws: family, liveness, report: out });
3906
4068
  }
3907
4069
  // A leads-to refuted by a fair run that never gets there (core/live.ts's findRing, checked by refutedBy): a stem from
3908
4070
  // the start, then round a ring of sets each request of which the kernel proves allowed and into the next set, fair to
3909
4071
  // each helpful request (taken in the ring, or never allowed in a set). Undefined where none is found within `ms`.
3910
4072
  export function refuteLeadsTo(r, laws, l, opts = {}) {
3911
- const k = keyed(r, l);
4073
+ if (isSourceBound(r, [...laws, l]) || completeWorkProfile.enabled)
4074
+ return undefined;
4075
+ const k = keyed(r, l).withSumsOf(laws, l);
4076
+ noting(k, laws, l);
3912
4077
  return findRing(k.machine, withKinds(k, laws), l, { params: (rand, bound) => k.randomParams(rand, bound), input: (rand, bound, ps) => k.randomInput(rand, bound, ps) }, opts);
3913
4078
  }
3914
4079
  // `ms`: the budget (the prover's own per goal, 20 s or a second a hypothesis, where none is given), on the clock the
@@ -0,0 +1,9 @@
1
+ import { FixedWord, type DivisionRounding, type Overflow } from './fixed-integers.js';
2
+ import { Cond } from './dsl.js';
3
+ export { wordDivisionKey, wordDivisionName } from '../kernel/word-division.js';
4
+ type C = Cond['c'];
5
+ export declare function captureFixed<T>(f: () => T): {
6
+ value: T;
7
+ flags: Record<string, C>;
8
+ };
9
+ export declare function divideFixed(a: FixedWord, b: FixedWord, rounding: DivisionRounding, mode: Overflow, remainder: boolean): FixedWord;