gdp-wired 0.51.0 → 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.
- package/README.md +2 -2
- package/dist/core/accel-refute.d.ts +53 -0
- package/dist/core/accel-refute.js +997 -0
- package/dist/core/cli.d.ts +2 -0
- package/dist/core/cli.js +8 -1
- package/dist/core/cycles.d.ts +2 -0
- package/dist/core/cycles.js +12 -9
- package/dist/core/dsl.d.ts +7 -1
- package/dist/core/dsl.js +147 -26
- package/dist/core/live-support.d.ts +5 -0
- package/dist/core/live-support.js +148 -0
- package/dist/core/live.js +194 -37
- package/dist/core/lockstep.d.ts +5 -0
- package/dist/core/lockstep.js +23 -0
- package/dist/core/ordered-pair-seeds.d.ts +2 -0
- package/dist/core/ordered-pair-seeds.js +109 -0
- package/dist/core/proof-output.d.ts +38 -1
- package/dist/core/proof-output.js +38 -0
- package/dist/core/search-termination.d.ts +4 -0
- package/dist/core/search-termination.js +1 -1
- package/dist/core/source-check.d.ts +4 -1
- package/dist/core/source-check.js +5 -2
- package/dist/core/sparse-kind-proof.d.ts +7 -0
- package/dist/core/sparse-kind-proof.js +49 -0
- package/dist/core/step-seeds.d.ts +46 -0
- package/dist/core/step-seeds.js +316 -0
- package/dist/lean-kernel/Cert.lean +222 -0
- package/dist/lean-kernel/Count.lean +1568 -0
- package/dist/lean-kernel/Ghost.lean +373 -0
- package/dist/lean-kernel/GhostMap.lean +426 -0
- package/dist/lean-kernel/Kernel.lean +2881 -0
- package/dist/lean-kernel/Live.lean +1168 -0
- package/dist/lean-kernel/Progress.lean +543 -0
- package/dist/lean-kernel/Sets.lean +1975 -0
- package/dist/lean-kernel/StepLaw.lean +128 -0
- package/dist/lean-kernel/Steps.lean +477 -0
- package/dist/lean-kernel/Sums.lean +916 -0
- package/dist/lean-kernel/emit.d.ts +4 -0
- package/dist/lean-kernel/emit.js +23 -4
- package/dist/lean-kernel/lean-aggregate/FiniteFold.lean +44 -0
- package/dist/lean-kernel/lean-aggregate/GroupedTransport.lean +308 -0
- package/dist/lean-kernel/lean-aggregate/aggregate.d.ts +13 -0
- package/dist/lean-kernel/lean-aggregate/aggregate.js +68 -0
- package/dist/lean-kernel/lean-aggregate/assets.d.ts +5 -0
- package/dist/lean-kernel/lean-aggregate/assets.js +7 -0
- package/dist/lean-kernel/lean-aggregate/audit.d.ts +3 -0
- package/dist/lean-kernel/lean-aggregate/audit.js +13 -0
- package/dist/lean-kernel/lean-aggregate/exact.d.ts +15 -0
- package/dist/lean-kernel/lean-aggregate/exact.js +51 -0
- package/dist/lean-kernel/lean-aggregate/index.d.ts +19 -0
- package/dist/lean-kernel/lean-aggregate/index.js +52 -0
- package/dist/lean-kernel/lean-aggregate/point-fold.d.ts +27 -0
- package/dist/lean-kernel/lean-aggregate/point-fold.js +79 -0
- package/dist/lean-kernel/lean-aggregate/replay-fold.d.ts +2 -0
- package/dist/lean-kernel/lean-aggregate/replay-fold.js +163 -0
- package/dist/lean-kernel/lean-aggregate/source.d.ts +2 -0
- package/dist/lean-kernel/lean-aggregate/source.js +141 -0
- package/dist/lean-kernel/lean-aggregate/weighted-flags.d.ts +2 -0
- package/dist/lean-kernel/lean-aggregate/weighted-flags.js +26 -0
- package/dist/lean-kernel/lean-aggregate/weighted-replay.d.ts +7 -0
- package/dist/lean-kernel/lean-aggregate/weighted-replay.js +53 -0
- package/dist/lean-kernel/lean-aggregate/weighted-seeded.d.ts +30 -0
- package/dist/lean-kernel/lean-aggregate/weighted-seeded.js +64 -0
- package/dist/lean-kernel/lean-aggregate/weighted.d.ts +18 -0
- package/dist/lean-kernel/lean-aggregate/weighted.js +115 -0
- package/dist/lean-kernel/lean-aggregate/worker.d.ts +10 -0
- package/dist/lean-kernel/lean-aggregate/worker.js +46 -0
- package/docs/lean-aggregate.md +29 -0
- package/package.json +6 -1
package/dist/core/live.js
CHANGED
|
@@ -9,15 +9,20 @@
|
|
|
9
9
|
// - a state variable alone, and the constant 0.
|
|
10
10
|
// The steps are taken from runs from the start and from random states the laws allow, where `from` holds and `to`
|
|
11
11
|
// doesn't (the kernel's goals are about every such state, reached or not): a helpful request's in its region must
|
|
12
|
-
// lower the rank
|
|
12
|
+
// lower the rank unless strong fairness permits an upward handoff. Under weak fairness a step that leaves a
|
|
13
|
+
// region must also lower; the remaining steps must not raise the rank. Components are
|
|
13
14
|
// chosen in order, each one no step raises that lowers the most of those left. The rank is then the kernel's
|
|
14
15
|
// (proveLiveness), with the invariants inferLaws finds where its goals need some. Nothing new is trusted.
|
|
15
16
|
import { evalC, evalE, interpret, seeded, walk } from "./machine.js";
|
|
16
|
-
import { falseC, livenessHelpful, livenessParts, substC, substE } from "../kernel/kernel.js";
|
|
17
|
+
import { falseC, livenessHelpful, livenessParts, plainOf, substC, substE } from "../kernel/kernel.js";
|
|
17
18
|
import { clock, proveLiveness, proveProgress, proveStepLaws, withDeadline } from "../kernel/prove.js";
|
|
18
19
|
import { allowed, watch } from "./watch.js";
|
|
19
20
|
import { showE } from "./cycles.js";
|
|
20
21
|
import { inferLaws } from "./infer.js";
|
|
22
|
+
import { isSourceBound } from "./source-check.js";
|
|
23
|
+
import { withStageDeadline } from "./dsl-deadline.js";
|
|
24
|
+
import { BudgetExpired, WallExpired } from "./wall.js";
|
|
25
|
+
import { WatchdogExpired } from "./search-watchdog.js";
|
|
21
26
|
const id = (t) => JSON.stringify(t);
|
|
22
27
|
const k = (value) => ({ op: 'const', value }), v = (name) => ({ op: 'var', name });
|
|
23
28
|
const sub = (a, b) => ({ op: 'sub', a, b }), plus1 = (a) => ({ op: 'add', a, b: k(1) });
|
|
@@ -136,7 +141,9 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
136
141
|
} };
|
|
137
142
|
const pending = (ps, st) => holds(l.from, ps, st) === true && holds(l.to, ps, st) === false;
|
|
138
143
|
const regions = (ps, st) => helpful.map(h => holds(h.when, ps, st) === true);
|
|
139
|
-
const steps = [];
|
|
144
|
+
const steps = [], finishes = new Set();
|
|
145
|
+
const strong = l.fairness === 'strong';
|
|
146
|
+
const takenIn = (ps, st, input, was) => helpful.flatMap((h, i) => was[i] && Object.entries(h.request).every(([name, term]) => evalE(term, env(ps, st), st, m) === input[name]) ? [i] : []);
|
|
140
147
|
// One step from a pending state: a helpful request in its region (its named inputs at the state, the rest drawn), or
|
|
141
148
|
// any request; kept where it stays pending.
|
|
142
149
|
const take = (ps, st, bound, h) => {
|
|
@@ -149,9 +156,20 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
149
156
|
if (!allowed(m, run, ps, st, input))
|
|
150
157
|
continue;
|
|
151
158
|
const next = run.step(ps, st, input);
|
|
152
|
-
if (pending(ps, st)
|
|
153
|
-
const was = regions(ps, st),
|
|
154
|
-
|
|
159
|
+
if (pending(ps, st)) {
|
|
160
|
+
const was = regions(ps, st), nextPending = pending(ps, next);
|
|
161
|
+
if (strong) {
|
|
162
|
+
const from = takenIn(ps, st, input, was);
|
|
163
|
+
if (nextPending)
|
|
164
|
+
steps.push({ ps, s: st, t: next, lower: false, handoffs: { from, to: regions(ps, next).flatMap((b, i) => b ? [i] : []) } });
|
|
165
|
+
else if (holds(l.to, ps, next))
|
|
166
|
+
for (const i of from)
|
|
167
|
+
finishes.add(i);
|
|
168
|
+
}
|
|
169
|
+
else if (nextPending) {
|
|
170
|
+
const now = regions(ps, next);
|
|
171
|
+
steps.push({ ps, s: st, t: next, lower: h !== undefined || was.some((r, i) => r && !now[i]) });
|
|
172
|
+
}
|
|
155
173
|
}
|
|
156
174
|
return next;
|
|
157
175
|
}
|
|
@@ -202,6 +220,26 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
202
220
|
found++;
|
|
203
221
|
take(ps, st, bound, pick(ps, st));
|
|
204
222
|
}
|
|
223
|
+
// Strong fairness allows an ordinary step to leave a region at the same rank. A helpful step may also keep
|
|
224
|
+
// the rank if it hands off to a strictly higher-level region. Propose levels from sampled distances to a
|
|
225
|
+
// helping region observed to finish; the unchanged checker must prove each handoff, descent and enabledness.
|
|
226
|
+
const dist = helpful.map((_, i) => finishes.has(i) ? 0 : helpful.length);
|
|
227
|
+
if (strong && !l.levels)
|
|
228
|
+
for (let round = 0; round < helpful.length; round++) {
|
|
229
|
+
for (const { handoffs } of steps)
|
|
230
|
+
if (handoffs)
|
|
231
|
+
for (const i of handoffs.from)
|
|
232
|
+
for (const j of handoffs.to) {
|
|
233
|
+
dist[i] = Math.min(dist[i], dist[j] + 1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const levels = strong ? l.levels ?? dist.map(d => helpful.length - d) : undefined;
|
|
237
|
+
const mustLower = (from, to) => from.some(i => !to.some(j => levels[i] < levels[j]));
|
|
238
|
+
if (levels)
|
|
239
|
+
for (const s of steps)
|
|
240
|
+
if (s.handoffs)
|
|
241
|
+
s.lower = mustLower(s.handoffs.from, s.handoffs.to);
|
|
242
|
+
const goalOf = (rank) => ({ ...l, rank, ...(levels ? { levels } : {}) });
|
|
205
243
|
// A goal's counterexample as a step (the kernel names a cell by its map and its key's linear form, `M[d:1,1:2]`): the
|
|
206
244
|
// state, params and request it gives (0 where it gives none), stepped by the interpreter. The step a goal fails at
|
|
207
245
|
// is one the rank must allow; so the ranks are chosen again with it, a few rounds.
|
|
@@ -228,7 +266,9 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
228
266
|
if (!pending(ps, next))
|
|
229
267
|
return false;
|
|
230
268
|
const was = regions(ps, st), now = regions(ps, next), h = /helpful request (\d+)/.exec(goal);
|
|
231
|
-
|
|
269
|
+
const lower = strong ? (h ? mustLower([Number(h[1]) - 1], now.flatMap((b, i) => b ? [i] : [])) :
|
|
270
|
+
mustLower(takenIn(ps, st, input, was), now.flatMap((b, i) => b ? [i] : []))) : !!h || was.some((r, i) => r && !now[i]);
|
|
271
|
+
steps.push({ ps, s: st, t: next, lower });
|
|
232
272
|
return true;
|
|
233
273
|
}
|
|
234
274
|
catch {
|
|
@@ -300,10 +340,10 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
300
340
|
break;
|
|
301
341
|
tried.add(id(rank));
|
|
302
342
|
best ??= rank;
|
|
303
|
-
last =
|
|
304
|
-
if (last
|
|
305
|
-
return { proven: true, checked: true, rank, laws: [], found: { rank: text(rank), laws: [] } };
|
|
306
|
-
if (last
|
|
343
|
+
last = withStageDeadline(clock() + ms * (strong ? 0.9 : 1 / 3), () => proveLiveness(m, laws, goalOf(rank)), () => undefined);
|
|
344
|
+
if (last?.proven && last.checked)
|
|
345
|
+
return { proven: true, checked: true, rank, levels, laws: [], evidence: { machine: m, laws, liveness: goalOf(rank), report: last }, found: { rank: text(rank), laws: [] } };
|
|
346
|
+
if (last?.failed?.witness && fromWitness(last.failed.witness, last.failed.goal))
|
|
307
347
|
learnt = true;
|
|
308
348
|
}
|
|
309
349
|
if (!learnt)
|
|
@@ -312,23 +352,111 @@ export function leadsByTerms(m, laws, l, draws, opts = {}) {
|
|
|
312
352
|
if (!best)
|
|
313
353
|
return { proven: false, checked: false, why: `no rank of the rule's terms that the ${steps.length} steps sampled allow` };
|
|
314
354
|
// the first rank with the invariants its goals need
|
|
315
|
-
const rank = best, lv =
|
|
355
|
+
const rank = best, lv = goalOf(rank), ms = until - clock();
|
|
316
356
|
if (ms > 300) {
|
|
317
357
|
const { stay, cover, helps } = livenessParts(m, lv), inf = inferLaws(draws.rule ?? m, laws, [stay, cover, ...helps], { ms });
|
|
318
358
|
const kept = inf.found.filter(f => !f.law.some?.length), more = kept.map(f => f.law);
|
|
319
359
|
if (inf.proven && more.length) {
|
|
320
|
-
const again =
|
|
321
|
-
if (again
|
|
322
|
-
return { proven: true, checked: true, rank, laws: more, found: { rank: text(rank), laws: kept.map(f => f.text) } };
|
|
360
|
+
const again = withStageDeadline(until, () => proveLiveness(m, [...laws, ...more], lv), () => undefined);
|
|
361
|
+
if (again?.proven && again.checked)
|
|
362
|
+
return { proven: true, checked: true, rank, levels: lv.levels, laws: more, evidence: { machine: m, laws: [...laws, ...more], liveness: lv, report: again }, found: { rank: text(rank), laws: kept.map(f => f.text) } };
|
|
323
363
|
}
|
|
324
364
|
}
|
|
325
365
|
const failed = last?.failed ? { goal: last.failed.goal, stuck: last.failed.stuck, ...(last.failed.witness ? { witness: last.failed.witness } : {}) } : {};
|
|
326
366
|
return { proven: false, checked: false, rank, found: { rank: text(rank), laws: [] }, ...failed, why: `rank ${text(rank)} of the rule's terms, from ${steps.length} steps sampled; the kernel's goals not proven with it` };
|
|
327
367
|
}
|
|
368
|
+
const historyQueries = (m) => Object.keys(m.history?.queries ?? {});
|
|
369
|
+
const unsupportedRingMachine = (m) => {
|
|
370
|
+
// Facts can restrict which parameters start a run. No name or bounded
|
|
371
|
+
// sample certifies a universally quantified fact. Refuse derived inputs,
|
|
372
|
+
// external functions, primitive traps and non-scalar client requests too.
|
|
373
|
+
if (m.primitiveFailure || m.facts?.length || Object.keys(m.fns ?? {}).length || Object.keys(m.leasts ?? {}).length ||
|
|
374
|
+
m.inputMaps?.length || Object.keys(m.counts ?? {}).length || Object.keys(m.sums ?? {}).length)
|
|
375
|
+
return true;
|
|
376
|
+
if (!m.history)
|
|
377
|
+
return false;
|
|
378
|
+
// The progress check supplies placeholders for original history queries.
|
|
379
|
+
// It can show enabledness only if the real assumption cannot read them.
|
|
380
|
+
let flag = false;
|
|
381
|
+
walk(m.assume, o => { if (o.op === 'flag')
|
|
382
|
+
flag = true; });
|
|
383
|
+
return !!(m.history.prune || flag || m.assume && readsC(m.assume, historyQueries(m)) ||
|
|
384
|
+
Object.values(m.step.maps ?? {}).some(w => 'each' in w));
|
|
385
|
+
};
|
|
386
|
+
const natural = (x) => typeof x === 'number' && Number.isSafeInteger(x) && x >= 0;
|
|
387
|
+
function ringScope(m) {
|
|
388
|
+
const plain = plainOf(m), vars = new Set([...m.params, ...Object.keys(plain.state)]);
|
|
389
|
+
// Quantified/flag conditions and functions are not client policy syntax;
|
|
390
|
+
// all reads must be of explicit old state or parameters at every step.
|
|
391
|
+
function term(t, depth = 0) {
|
|
392
|
+
if (!t || depth > 64)
|
|
393
|
+
return false;
|
|
394
|
+
const sub = (x) => term(x, depth + 1);
|
|
395
|
+
switch (t.op) {
|
|
396
|
+
case 'var': return vars.has(t.name);
|
|
397
|
+
case 'const': return natural(t.value);
|
|
398
|
+
case 'get': return Object.hasOwn(plain.maps ?? {}, t.map) && sub(t.key);
|
|
399
|
+
case 'if': return condition(t.c, depth + 1) && sub(t.then) && sub(t.else);
|
|
400
|
+
case 'mul': return natural(t.k) && sub(t.a);
|
|
401
|
+
case 'proj': return (t.k === 0 || t.k === 1) && sub(t.a);
|
|
402
|
+
case 'add':
|
|
403
|
+
case 'sub':
|
|
404
|
+
case 'max':
|
|
405
|
+
case 'min':
|
|
406
|
+
case 'prod':
|
|
407
|
+
case 'tup': return sub(t.a) && sub(t.b);
|
|
408
|
+
default: return false;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function condition(c, depth = 0) {
|
|
412
|
+
if (!c || depth > 64)
|
|
413
|
+
return false;
|
|
414
|
+
switch (c.op) {
|
|
415
|
+
case '<':
|
|
416
|
+
case '<=':
|
|
417
|
+
case '=': return term(c.a, depth + 1) && term(c.b, depth + 1);
|
|
418
|
+
case 'and':
|
|
419
|
+
case 'or': return Array.isArray(c.xs) && c.xs.every(x => condition(x, depth + 1));
|
|
420
|
+
case 'not': return condition(c.x, depth + 1);
|
|
421
|
+
case 'all':
|
|
422
|
+
case 'flag': return false;
|
|
423
|
+
default: return false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return { term, condition };
|
|
427
|
+
}
|
|
428
|
+
const postState = (m) => {
|
|
429
|
+
const plain = plainOf(m); // log sums are state in the actual postcondition
|
|
430
|
+
return { vars: Object.fromEntries(Object.keys(plain.state).map(x => [x, v(`${x}'`)])),
|
|
431
|
+
maps: Object.fromEntries(Object.keys(plain.maps ?? {}).map(map => [map, (key) => ({ op: 'get', map: `${map}'`, key })])), flags: {} };
|
|
432
|
+
};
|
|
328
433
|
export function refutedBy(m, laws, l, ring) {
|
|
329
|
-
|
|
434
|
+
try {
|
|
435
|
+
return checkRing(m, laws, l, ring);
|
|
436
|
+
}
|
|
437
|
+
catch (e) {
|
|
438
|
+
if (e instanceof BudgetExpired || e instanceof WallExpired || e instanceof WatchdogExpired)
|
|
439
|
+
throw e;
|
|
440
|
+
return { refuted: false, why: String(e) };
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function checkRing(m, laws, l, ring) {
|
|
444
|
+
if (isSourceBound(m, [...laws, l]))
|
|
445
|
+
return { refuted: false, why: 'a model ring is not a source counterexample' };
|
|
446
|
+
if (unsupportedRingMachine(m))
|
|
447
|
+
return { refuted: false, why: 'ring proof does not support these machine facts, functions, requests or history effects' };
|
|
448
|
+
livenessParts(m, { ...l, rank: [k(0)] });
|
|
449
|
+
const n = ring.sets.length, queries = historyQueries(m), inputs = m.inputs.filter(i => !queries.includes(i));
|
|
450
|
+
const run = interpret(m), helpful = livenessHelpful(l), scope = ringScope(m);
|
|
451
|
+
const exactNaturals = (xs, names) => Object.keys(xs).length === names.length && names.every(name => Object.hasOwn(xs, name) && natural(xs[name]));
|
|
330
452
|
if (!n)
|
|
331
453
|
return { refuted: false, why: 'no set' };
|
|
454
|
+
if (!exactNaturals(ring.params, m.params) || ring.stem.some(req => !exactNaturals(req, inputs)))
|
|
455
|
+
return { refuted: false, why: 'malformed ring parameters or stem request' };
|
|
456
|
+
if (![l.from, l.to, ...helpful.map(h => h.when), ...ring.sets.map(s => s.holds)].every(c => scope.condition(c)))
|
|
457
|
+
return { refuted: false, why: 'ring predicates must read only the state and parameters' };
|
|
458
|
+
if ([...helpful, ...ring.sets].some(s => Object.entries(s.request).some(([name, t]) => !inputs.includes(name) || !scope.term(t))))
|
|
459
|
+
return { refuted: false, why: 'ring request needs a client field and a state-relative value' };
|
|
332
460
|
if (m.pre && !evalC(m.pre, ring.params, { scalars: {}, maps: {} }, m))
|
|
333
461
|
return { refuted: false, why: 'the params break the precondition' };
|
|
334
462
|
let st = run.init(ring.params);
|
|
@@ -340,25 +468,46 @@ export function refutedBy(m, laws, l, ring) {
|
|
|
340
468
|
const at = (c) => evalC(c, { ...ring.params, ...st.scalars }, st, m);
|
|
341
469
|
if (!at(l.from) || at(l.to) || !at(ring.sets[0].holds))
|
|
342
470
|
return { refuted: false, why: 'the stem ends where `from` doesn\'t hold, `to` does, or outside the first set' };
|
|
343
|
-
const after =
|
|
344
|
-
const
|
|
471
|
+
const after = postState(m);
|
|
472
|
+
const clientRequest = (r) => Object.fromEntries(inputs.map(i => [i, r[i] ?? k(0)]));
|
|
473
|
+
// Replay a full initial lap in the actual interpreter, including request
|
|
474
|
+
// evaluation and hidden queries. Beyond that lap the certificate is about
|
|
475
|
+
// the kernel's unbounded natural model, not indefinite host execution.
|
|
476
|
+
for (const [j, set] of ring.sets.entries()) {
|
|
477
|
+
const req = Object.fromEntries(Object.entries(clientRequest(set.request)).map(([name, t]) => [name, evalE(t, { ...ring.params, ...st.scalars }, st, m)]));
|
|
478
|
+
if (!Object.values(req).every(natural) || !allowed(m, run, ring.params, st, req))
|
|
479
|
+
return { refuted: false, why: `ring ${j + 1}: its first recurring request is not allowed` };
|
|
480
|
+
st = run.step(ring.params, st, req);
|
|
481
|
+
if (!at(l.from) || at(l.to) || !at(ring.sets[(j + 1) % n].holds))
|
|
482
|
+
return { refuted: false, why: `ring ${j + 1}: interpreter did not stay pending and move into the next set` };
|
|
483
|
+
}
|
|
345
484
|
for (const [j, set] of ring.sets.entries()) {
|
|
346
485
|
const next = ring.sets[(j + 1) % n].holds, then = { op: 'and', xs: [substC(next, after), substC(l.from, after), { op: 'not', x: substC(l.to, after) }] };
|
|
347
|
-
const p = proveProgress(m, laws, { name: `${l.name}: ring ${j + 1}`, when: set.holds, then,
|
|
486
|
+
const p = proveProgress(m, laws, { name: `${l.name}: ring ${j + 1}`, when: set.holds, then,
|
|
487
|
+
request: { ...clientRequest(set.request), ...Object.fromEntries(queries.map(q => [q, k(0)])) } });
|
|
348
488
|
if (!p.proven || !p.checked)
|
|
349
489
|
return { refuted: false, why: `ring ${j + 1}: its request not proven allowed and into the next set${p.failed ? ` (${p.failed.goal})` : ''}` };
|
|
490
|
+
if (queries.length) {
|
|
491
|
+
// The interpreter computes the queries from its log. Recheck closure with every query left free, since
|
|
492
|
+
// the placeholder in progress's total request does not bind the original log.
|
|
493
|
+
const req = Object.entries(clientRequest(set.request)).map(([x, t]) => ({ op: '=', a: v(x), b: t }));
|
|
494
|
+
const allQueries = proveStepLaws(m, laws, [{ name: `${l.name}: ring ${j + 1} with query values free`,
|
|
495
|
+
when: { op: 'and', xs: [set.holds, ...req] }, then }]);
|
|
496
|
+
if (!allQueries.proven || !allQueries.checked)
|
|
497
|
+
return { refuted: false, why: `ring ${j + 1}: closure not proven without pinning history queries` };
|
|
498
|
+
}
|
|
350
499
|
}
|
|
351
500
|
// "no allowed request from a state of R_j meets these": a step law whose `then` is false
|
|
352
501
|
const never = (what, ...cs) => { const r = proveStepLaws(m, laws, [{ name: `${l.name}: ${what}`, when: { op: 'and', xs: cs }, then: falseC }]); return r.proven && r.checked; };
|
|
353
502
|
const named = (req) => Object.entries(req).map(([x, t]) => ({ op: '=', a: v(x), b: t }));
|
|
354
503
|
const fair = new Set(['taken', 'weak', 'strong']);
|
|
355
504
|
for (const [i, h] of helpful.entries()) {
|
|
356
|
-
const takes = ring.sets.map(set => Object.entries(h.request).every(([x, t]) => id(
|
|
505
|
+
const takes = ring.sets.map(set => Object.entries(h.request).every(([x, t]) => id(clientRequest(set.request)[x]) === id(t)));
|
|
357
506
|
if (!takes.some(Boolean))
|
|
358
507
|
fair.delete('taken');
|
|
359
508
|
if (!takes.some(Boolean) && !ring.sets.some(set => never(`helpful request ${i + 1} not allowed`, set.holds, ...named(h.request))))
|
|
360
509
|
fair.delete('weak');
|
|
361
|
-
if (!ring.sets.some((set, j) => takes[j] && never(`helpful request ${i + 1} taken in its region`, set.holds, { op: 'not', x: h.when }, ...named(
|
|
510
|
+
if (!ring.sets.some((set, j) => takes[j] && never(`helpful request ${i + 1} taken in its region`, set.holds, { op: 'not', x: h.when }, ...named(clientRequest(set.request))))
|
|
362
511
|
&& !ring.sets.every(set => never(`helpful request ${i + 1} not allowed in its region`, set.holds, h.when, ...named(h.request))))
|
|
363
512
|
fair.delete('strong');
|
|
364
513
|
if (!fair.size)
|
|
@@ -381,7 +530,10 @@ export function refutedBy(m, laws, l, ring) {
|
|
|
381
530
|
// literal of R_{j+1} that R_j's request isn't proven to keep is dropped (Houdini, round the cycle) until each is kept;
|
|
382
531
|
// then refutedBy checks the ring. The first ring refuted; else the first checked; undefined where no cycle is found.
|
|
383
532
|
export function findRing(m, laws, l, draws, opts = {}) {
|
|
533
|
+
if (unsupportedRingMachine(m) || isSourceBound(m, [...laws, l]))
|
|
534
|
+
return;
|
|
384
535
|
const until = clock() + (opts.ms ?? 10_000), rand = seeded(17), run = interpret(m), helpful = livenessHelpful(l), H = helpful.length;
|
|
536
|
+
const queries = new Set(historyQueries(m)), client = m.inputs.filter(i => !queries.has(i));
|
|
385
537
|
const env = (ps, st) => ({ ...ps, ...st.scalars });
|
|
386
538
|
const holds = (c, ps, st) => { try {
|
|
387
539
|
return evalC(c, env(ps, st), st, m);
|
|
@@ -397,29 +549,32 @@ export function findRing(m, laws, l, draws, opts = {}) {
|
|
|
397
549
|
} };
|
|
398
550
|
const pending = (ps, st) => holds(l.from, ps, st) === true && holds(l.to, ps, st) === false;
|
|
399
551
|
const full = (r) => Object.fromEntries(m.inputs.map(i => [i, r[i] ?? k(0)]));
|
|
400
|
-
const concrete = (r, ps, st) => Object.fromEntries(
|
|
552
|
+
const concrete = (r, ps, st) => Object.fromEntries(client.map(i => [i, evalE(r[i] ?? k(0), env(ps, st), st, m)]));
|
|
401
553
|
const atoms = new Map();
|
|
402
|
-
const add = (t) => walk(t, o => {
|
|
403
|
-
|
|
404
|
-
|
|
554
|
+
const add = (t, subst) => walk(t, o => {
|
|
555
|
+
if ((o.op !== '<' && o.op !== '<=' && o.op !== '=') || typeof o.a !== 'object' || typeof o.b !== 'object')
|
|
556
|
+
return;
|
|
557
|
+
const atom = o;
|
|
558
|
+
// Specialize only flag-free comparisons, including those in the separately collected flag definitions.
|
|
559
|
+
if (id(atom).includes('"op":"flag"'))
|
|
560
|
+
return;
|
|
561
|
+
const c = subst ? substC(atom, subst) : atom;
|
|
562
|
+
if (!readsC(c, m.inputs) && scope.condition(c) && !constant(c))
|
|
405
563
|
atoms.set(id(c), c);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
for (const e of Object.values(m.step.state ?? {}))
|
|
413
|
-
add(substE(e, sb));
|
|
414
|
-
}
|
|
564
|
+
});
|
|
565
|
+
const scope = ringScope(m);
|
|
566
|
+
const parts = [m.assume, m.step];
|
|
567
|
+
add([l.from, l.to, helpful.map(h => h.when), parts]);
|
|
568
|
+
for (const h of helpful)
|
|
569
|
+
add(parts, { vars: full(h.request), maps: {}, flags: {} });
|
|
415
570
|
const lits = [...atoms.values()], litsAt = (ps, st) => lits.flatMap(c => { const b = holds(c, ps, st); return b === undefined ? [] : [b ? c : { op: 'not', x: c }]; });
|
|
416
571
|
const keyAt = (ps, st) => lits.map(c => { const b = holds(c, ps, st); return b === undefined ? 2 : +b; }).join('');
|
|
417
|
-
const after =
|
|
572
|
+
const after = postState(m);
|
|
418
573
|
const fair = (cyc) => helpful.every((_, h) => (l.fairness === 'strong'
|
|
419
574
|
? cyc.some(a => a.taken[h] && a.region[h]) || cyc.every(a => !(a.allows[h] && a.region[h]))
|
|
420
575
|
: cyc.some(a => a.taken[h] || !a.allows[h])));
|
|
421
576
|
// a request as terms at a state
|
|
422
|
-
const termsOf = (req, ps, st) => Object.fromEntries(
|
|
577
|
+
const termsOf = (req, ps, st) => Object.fromEntries(client.map(i => [i, helpful.map(h => h.request[i]).find(t => t && value(t, ps, st) === req[i]) ?? k(req[i])]));
|
|
423
578
|
const kept = (when, then, request) => {
|
|
424
579
|
const p = withDeadline(Math.min(until, clock() + 2000), () => proveProgress(m, laws, { name: 'kept', when: { op: 'and', xs: when }, then: { op: 'and', xs: then.map(c => substC(c, after)) }, request: full(request) }));
|
|
425
580
|
return p.proven && p.checked;
|
|
@@ -440,7 +595,7 @@ export function findRing(m, laws, l, draws, opts = {}) {
|
|
|
440
595
|
}
|
|
441
596
|
}
|
|
442
597
|
const ring = { params: ps, stem, sets: sets.map((s, j) => ({ holds: { op: 'and', xs: s }, request: reqs[j] })) };
|
|
443
|
-
return { ring, verdict: refutedBy(m, laws, l, ring) };
|
|
598
|
+
return { ring, verdict: withDeadline(until, () => refutedBy(m, laws, l, ring)) };
|
|
444
599
|
};
|
|
445
600
|
// the cycle run again from where it closed, its requests as terms, for 3,000 steps: each allowed, pending after, at
|
|
446
601
|
// the abstraction it had (so the time passes every deadline small params allow: a cycle a deadline ends is none)
|
|
@@ -448,6 +603,8 @@ export function findRing(m, laws, l, draws, opts = {}) {
|
|
|
448
603
|
try {
|
|
449
604
|
for (let n = 0; n < 3000;)
|
|
450
605
|
for (const [j, a] of cyc.entries()) {
|
|
606
|
+
if (clock() >= until)
|
|
607
|
+
return false;
|
|
451
608
|
const q = concrete(reqs[j], ps, st);
|
|
452
609
|
if (keyAt(ps, st) !== a.key || !allowed(m, run, ps, st, q))
|
|
453
610
|
return false;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { retainFamily } from "./proof-output.js";
|
|
2
|
+
import { clock, withDeadline } from "../kernel/prove.js";
|
|
3
|
+
import { kindConjuncts, sparseKindProof } from "./sparse-kind-proof.js";
|
|
4
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
5
|
+
function renaming(e, self) {
|
|
6
|
+
return JSON.stringify(e, (_key, node) => {
|
|
7
|
+
const t = node;
|
|
8
|
+
return t?.op === 'var' && t.name === self ? { op: '$self' } : node;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function tryLockstepScalars(m, law, kinds, ms) {
|
|
12
|
+
if (law.holds.op !== '=' || law.forall || law.keys?.length || law.some?.length || law.finite ||
|
|
13
|
+
law.holds.a.op !== 'var' || law.holds.b.op !== 'var')
|
|
14
|
+
return;
|
|
15
|
+
const a = law.holds.a.name, b = law.holds.b.name, u = m.step.state?.[a], v = m.step.state?.[b];
|
|
16
|
+
if (!u || !v || a === b || !m.state[a] || !m.state[b] || !same(m.state[a], m.state[b]) || renaming(u, a) !== renaming(v, b))
|
|
17
|
+
return;
|
|
18
|
+
const until = clock() + ms;
|
|
19
|
+
return withDeadline(until, () => {
|
|
20
|
+
const laws = [...kindConjuncts(kinds, [law]), law], proof = sparseKindProof(m, laws, until);
|
|
21
|
+
return proof ? retainFamily({ proven: true, checked: true }, m, laws, proof) : undefined;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Untrusted strengthening proposals for an ordered pair of rows with a shared group key.
|
|
2
|
+
// A successful search must check the original law and this whole family against the same machine.
|
|
3
|
+
import { all, any, not, same, x, get, n } from "./machine.js";
|
|
4
|
+
const isVar = (t, k) => t.op === 'var' && t.name === k;
|
|
5
|
+
const rowRead = (t, k) => t.op === 'get' && isVar(t.key, k) ? t.map : undefined;
|
|
6
|
+
const conjuncts = (c) => c.op === 'and' ? c.xs.flatMap(conjuncts) : [c];
|
|
7
|
+
const forbidden = (c) => {
|
|
8
|
+
if (c.op === 'not')
|
|
9
|
+
return conjuncts(c.x);
|
|
10
|
+
if (c.op === 'or' && c.xs.every(p => p.op === 'not'))
|
|
11
|
+
return c.xs.flatMap(p => conjuncts(p.x));
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const pairGroup = (c, i, j) => {
|
|
15
|
+
if (c.op !== '=')
|
|
16
|
+
return;
|
|
17
|
+
const lr = (a, b) => { const m = rowRead(a, i); return m && m === rowRead(b, j) ? m : undefined; };
|
|
18
|
+
return lr(c.a, c.b) ?? lr(c.b, c.a);
|
|
19
|
+
};
|
|
20
|
+
const rowTest = (c, k) => {
|
|
21
|
+
const e = c.op === 'not' ? c.x : c;
|
|
22
|
+
if (e.op !== '=')
|
|
23
|
+
return;
|
|
24
|
+
const test = (a, b) => { const map = rowRead(a, k); return map && b.op === 'const' ? { map, value: b.value, positive: c.op !== 'not' } : undefined; };
|
|
25
|
+
return test(e.a, e.b) ?? test(e.b, e.a);
|
|
26
|
+
};
|
|
27
|
+
function canAssign(value, tag) {
|
|
28
|
+
const seen = new Set(), stack = [value];
|
|
29
|
+
while (stack.length && seen.size < 2048) {
|
|
30
|
+
const e = stack.pop();
|
|
31
|
+
if (seen.has(e))
|
|
32
|
+
continue;
|
|
33
|
+
seen.add(e);
|
|
34
|
+
if (e.op === 'const' && e.value === tag)
|
|
35
|
+
return true;
|
|
36
|
+
if (e.op === 'if')
|
|
37
|
+
stack.push(e.then, e.else);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// A none-branch of a row selection can rule out old rows in the same group. Read only a
|
|
42
|
+
// simple one-tag absence query; maxima, grouped disjunctions and join predicates aren't tags.
|
|
43
|
+
function selectedTags(m, group, tagMap) {
|
|
44
|
+
const tags = new Set();
|
|
45
|
+
for (const flag of Object.values(m.step.flags ?? {})) {
|
|
46
|
+
if (flag.op !== 'all' || flag.keys?.length || flag.finite)
|
|
47
|
+
continue;
|
|
48
|
+
const cs = forbidden(flag.c);
|
|
49
|
+
if (!cs)
|
|
50
|
+
continue;
|
|
51
|
+
const k = flag.key;
|
|
52
|
+
const sameGroup = cs.some(c => c.op === '=' && [[c.a, c.b], [c.b, c.a]].some(([a, b]) => a && b && rowRead(a, k) === group && b.op === 'var' && m.inputs.includes(b.name)));
|
|
53
|
+
const tests = cs.map(c => rowTest(c, k)).filter(t => t?.map === tagMap && t.positive);
|
|
54
|
+
if (sameGroup && tests.length === 1)
|
|
55
|
+
tags.add(tests[0].value);
|
|
56
|
+
}
|
|
57
|
+
return [...tags];
|
|
58
|
+
}
|
|
59
|
+
// Project the later row to its tag, and project negative row filters out of the
|
|
60
|
+
// earlier row. Close the projected pattern under retagging from an exclusive
|
|
61
|
+
// selector: the old selected tag can precede neither a target nor another
|
|
62
|
+
// selected tag. Infer the coordinates and values from the law, writes and
|
|
63
|
+
// quantified row-selection guards. This deliberately small grammar can miss
|
|
64
|
+
// invariants or propose false ones; neither case can authorize a verdict.
|
|
65
|
+
export function orderedPairSeed(m, law) {
|
|
66
|
+
const i = law.forall, j = law.keys?.[0];
|
|
67
|
+
if (!i || !j || law.keys?.length !== 1 || law.some?.length || law.finite || i === j)
|
|
68
|
+
return;
|
|
69
|
+
const cs = forbidden(law.holds);
|
|
70
|
+
if (!cs || cs.length > 16)
|
|
71
|
+
return;
|
|
72
|
+
const groups = cs.map(c => pairGroup(c, i, j)).filter(g => g !== undefined);
|
|
73
|
+
if (groups.length !== 1 || !Object.hasOwn(m.maps ?? {}, groups[0]))
|
|
74
|
+
return;
|
|
75
|
+
const group = groups[0];
|
|
76
|
+
const frame = [], left = [], right = [];
|
|
77
|
+
for (const c of cs) {
|
|
78
|
+
const l = rowTest(c, i), r = rowTest(c, j);
|
|
79
|
+
if (l)
|
|
80
|
+
left.push(l);
|
|
81
|
+
else if (r)
|
|
82
|
+
right.push(r);
|
|
83
|
+
else if (pairGroup(c, i, j) === group || (c.op === '<' && isVar(c.a, i) && isVar(c.b, j)) ||
|
|
84
|
+
((c.op === '<' || c.op === '<=') && (isVar(c.a, i) || isVar(c.a, j)) && c.b.op === 'var' && Object.hasOwn(m.state, c.b.name)))
|
|
85
|
+
frame.push(c);
|
|
86
|
+
else
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!frame.some(c => c.op === '<' && isVar(c.a, i) && isVar(c.b, j)))
|
|
90
|
+
return;
|
|
91
|
+
const ordered = (tests) => tests.map(t => JSON.stringify([t.map, t.value, t.positive])).sort().join(';');
|
|
92
|
+
if (ordered(left) !== ordered(right) || left.some(t => !Object.hasOwn(m.maps ?? {}, t.map)))
|
|
93
|
+
return;
|
|
94
|
+
const tagOf = left.flatMap(t => {
|
|
95
|
+
const write = Object.hasOwn(m.step.maps ?? {}, t.map) ? m.step.maps[t.map] : undefined;
|
|
96
|
+
if (!t.positive || !write || !canAssign(write.value, t.value))
|
|
97
|
+
return [];
|
|
98
|
+
const prior = selectedTags(m, group, t.map).filter(value => value !== t.value);
|
|
99
|
+
return prior.length === 1 ? [{ tag: t, prior: prior[0] }] : [];
|
|
100
|
+
});
|
|
101
|
+
if (tagOf.length !== 1)
|
|
102
|
+
return;
|
|
103
|
+
const { tag, prior } = tagOf[0];
|
|
104
|
+
const is = (k, map, value) => same(get(map, x(k)), n(value));
|
|
105
|
+
const earlier = all(...left.filter(t => t.positive).map(t => is(i, t.map, t.value)));
|
|
106
|
+
const target = is(j, tag.map, tag.value);
|
|
107
|
+
const blocked = any(all(earlier, target), all(is(i, tag.map, prior), any(is(j, tag.map, prior), target)));
|
|
108
|
+
return { name: `${law.name} [ordered row pairs]`, forall: i, keys: [j], holds: any(not(all(...frame)), not(blocked)) };
|
|
109
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Machine, Law } from './machine.js';
|
|
2
|
-
import type { Instances, Tree } from '../kernel/kernel.js';
|
|
2
|
+
import type { Instances, Liveness, StepLaw, Tree } from '../kernel/kernel.js';
|
|
3
|
+
import type { proveLaws, proveLiveness, proveProgress, proveStepLaws } from '../kernel/prove.js';
|
|
3
4
|
export type ProofOutputNode = {
|
|
4
5
|
kind: 'counted';
|
|
5
6
|
machine: Machine;
|
|
@@ -33,6 +34,41 @@ export declare function withPublicRule<T>(run: (outermost: boolean) => T): T;
|
|
|
33
34
|
export declare const proofOutput: {
|
|
34
35
|
on?: (event: PublicProofOutput) => void;
|
|
35
36
|
};
|
|
37
|
+
type StepProofPacket = {
|
|
38
|
+
machine: Machine;
|
|
39
|
+
family: Law[];
|
|
40
|
+
step: StepLaw;
|
|
41
|
+
report: ReturnType<typeof proveStepLaws>;
|
|
42
|
+
kindProof?: {
|
|
43
|
+
laws: Law[];
|
|
44
|
+
proof: NonNullable<ReturnType<typeof proveLaws>['proof']>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
declare let stepObserver: ((entry: StepProofPacket) => void) | undefined;
|
|
48
|
+
export declare const stepProofOutput: {
|
|
49
|
+
on: typeof stepObserver;
|
|
50
|
+
};
|
|
51
|
+
export declare function retainStepProof<T extends object>(result: T, packet: StepProofPacket): T;
|
|
52
|
+
export declare function publishStepProof<T extends {
|
|
53
|
+
proven: boolean;
|
|
54
|
+
checked: boolean;
|
|
55
|
+
}>(result: T, model: object): T;
|
|
56
|
+
export type LiveProofPacket = {
|
|
57
|
+
machine: Machine;
|
|
58
|
+
laws: Law[];
|
|
59
|
+
liveness: Liveness;
|
|
60
|
+
report: ReturnType<typeof proveLiveness>;
|
|
61
|
+
progress?: ReturnType<typeof proveProgress>;
|
|
62
|
+
};
|
|
63
|
+
declare let liveObserver: ((entry: LiveProofPacket) => void) | undefined;
|
|
64
|
+
export declare const liveProofOutput: {
|
|
65
|
+
on: typeof liveObserver;
|
|
66
|
+
};
|
|
67
|
+
export declare function retainLiveProof<T extends object>(result: T, packet?: LiveProofPacket): T;
|
|
68
|
+
export declare function publishLiveProof<T extends {
|
|
69
|
+
proven: boolean;
|
|
70
|
+
checked: boolean;
|
|
71
|
+
}>(result: T, model: object): T;
|
|
36
72
|
export declare function retainFamily<T extends {
|
|
37
73
|
proven: boolean;
|
|
38
74
|
checked: boolean;
|
|
@@ -51,3 +87,4 @@ export declare function retainCounted<T extends object>(result: T, family: {
|
|
|
51
87
|
}): T;
|
|
52
88
|
export declare function retainFrom<T extends object>(result: T, parents: object[], context?: unknown): T;
|
|
53
89
|
export declare function publishProof<T extends object>(result: T, machine: Machine, laws: Law[]): T;
|
|
90
|
+
export {};
|
|
@@ -17,6 +17,44 @@ export const proofOutput = {
|
|
|
17
17
|
get on() { return observer; },
|
|
18
18
|
set on(value) { records = new WeakMap(); observer = value; }
|
|
19
19
|
};
|
|
20
|
+
let stepObserver;
|
|
21
|
+
let stepRecords = new WeakMap();
|
|
22
|
+
export const stepProofOutput = {
|
|
23
|
+
get on() { return stepObserver; },
|
|
24
|
+
set on(value) { stepRecords = new WeakMap(); stepObserver = value; },
|
|
25
|
+
};
|
|
26
|
+
export function retainStepProof(result, packet) {
|
|
27
|
+
if (stepObserver)
|
|
28
|
+
stepRecords.set(result, packet);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function publishStepProof(result, model) {
|
|
32
|
+
if (stepObserver && result.proven && result.checked) {
|
|
33
|
+
const packet = stepRecords.get(model);
|
|
34
|
+
if (packet)
|
|
35
|
+
stepObserver(packet);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
let liveObserver;
|
|
40
|
+
let liveRecords = new WeakMap();
|
|
41
|
+
export const liveProofOutput = {
|
|
42
|
+
get on() { return liveObserver; },
|
|
43
|
+
set on(value) { liveRecords = new WeakMap(); liveObserver = value; },
|
|
44
|
+
};
|
|
45
|
+
export function retainLiveProof(result, packet) {
|
|
46
|
+
if (liveObserver && packet)
|
|
47
|
+
liveRecords.set(result, packet);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
export function publishLiveProof(result, model) {
|
|
51
|
+
if (liveObserver && result.proven && result.checked) {
|
|
52
|
+
const packet = liveRecords.get(model);
|
|
53
|
+
if (packet)
|
|
54
|
+
liveObserver(packet);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
20
58
|
export function retainFamily(result, machine, laws, proof) {
|
|
21
59
|
if (proofOutput.on && result.proven && result.checked && proof)
|
|
22
60
|
records.set(result, { kind: 'usual', machine, laws, proof });
|
|
@@ -9,5 +9,5 @@ export const terminationWhy = (t) => `${t.kind === 'wall-deadline' ? 'wall deadl
|
|
|
9
9
|
export const completedSourceRefusal = (v) => !!v && v.proven === false && v.checked === false && v.kernelProven === true &&
|
|
10
10
|
(v.translation === 'unchecked' || v.translation === 'error') &&
|
|
11
11
|
v.stopped === undefined && v.termination === undefined && !v.stats?.stopped && v.stats?.termination === undefined;
|
|
12
|
-
export const completedSearch = (v) => !!v && (v.proven && v.checked || v.run !== undefined || completedSourceRefusal(v));
|
|
12
|
+
export const completedSearch = (v) => !!v && (v.proven && v.checked || v.run !== undefined || !!v.fairRing || v.acceleratedRun?.checked === true || completedSourceRefusal(v));
|
|
13
13
|
export const stoppedSearch = (v, termination) => ({ ...v, stopped: true, termination, context: searchContext(v), why: terminationWhy(termination) });
|
|
@@ -28,6 +28,7 @@ export type TranslationFields = {
|
|
|
28
28
|
translationWitness?: NativeObservation;
|
|
29
29
|
kernelProven?: boolean;
|
|
30
30
|
};
|
|
31
|
+
export declare const isSourceBound: (rule: object, laws: object[]) => boolean;
|
|
31
32
|
export declare function inheritSource(from: object, to: object, transparent?: boolean): void;
|
|
32
33
|
export declare function bindSourceMachine(rule: object, machine: object): void;
|
|
33
34
|
export declare function rememberNative(e: object, journal: NativeJournal): void;
|
|
@@ -42,7 +43,9 @@ export declare function translationVerdict<V extends {
|
|
|
42
43
|
checked: boolean;
|
|
43
44
|
why?: string;
|
|
44
45
|
stuck?: string;
|
|
45
|
-
|
|
46
|
+
fairRing?: unknown;
|
|
47
|
+
acceleratedRun?: unknown;
|
|
48
|
+
}>(rule: object, laws: object[], input: V): TranslatedVerdict<V>;
|
|
46
49
|
export declare function requireSourceTranslation(rule: object, laws: object[]): void;
|
|
47
50
|
export declare const nativeSame: (a: unknown, b: unknown) => boolean;
|
|
48
51
|
export declare function nativeSnapshot(value: unknown, seen?: Map<object, unknown>): unknown;
|