gdp-wired 0.32.0 → 0.33.1
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 +13 -0
- package/dist/core/check.js +20 -6
- package/dist/core/cli.d.ts +13 -3
- package/dist/core/cli.js +77 -23
- package/dist/core/dsl.d.ts +2 -2
- package/dist/core/dsl.js +8 -4
- package/dist/core/exists.js +16 -4
- package/dist/core/infer.d.ts +4 -0
- package/dist/core/infer.js +164 -113
- package/dist/core/laws.d.ts +19 -2
- package/dist/core/laws.js +105 -4
- package/dist/core/machine.d.ts +2 -0
- package/dist/core/machine.js +87 -0
- package/dist/core/relational.d.ts +49 -0
- package/dist/core/relational.js +345 -0
- package/dist/interchange/check.d.ts +16 -0
- package/dist/interchange/check.js +111 -0
- package/dist/interchange/format.d.ts +150 -0
- package/dist/interchange/format.js +678 -0
- package/dist/kernel/epr.d.ts +5 -0
- package/dist/kernel/epr.js +1152 -946
- package/dist/kernel/kernel.d.ts +45 -1
- package/dist/kernel/kernel.js +147 -18
- package/dist/kernel/prove.d.ts +1 -0
- package/dist/kernel/prove.js +4 -4
- package/dist/lean-kernel/emit.d.ts +16 -2
- package/dist/lean-kernel/emit.js +66 -3
- package/package.json +6 -2
package/dist/core/infer.js
CHANGED
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
// rules it out (and the most of those seen) is added; a chosen candidate that nothing supports, or that makes a proof slow, is dropped; the set proven as a whole
|
|
33
33
|
// is the answer, after each chosen candidate the proof doesn't need is taken out again
|
|
34
34
|
import { quietly } from "./cyclic.js";
|
|
35
|
-
import { all, any, atMost, carriedView, loadJs, divisorsIn, evalC, evalE, get, interpret, machineTerms, fnValue, modName, n, not, plus, same, seeded, times, walk, withArithmetic, x } from "./machine.js";
|
|
35
|
+
import { all, any, atMost, carriedView, compileC, compileE, loadJs, divisorsIn, evalC, evalE, get, interpret, machineTerms, fnValue, modName, n, not, plus, same, seeded, times, walk, withArithmetic, x } from "./machine.js";
|
|
36
36
|
import { bool, proveRule, proveSteps, verdictOf } from "./dsl.js";
|
|
37
37
|
import { allowed, keysOf, linKey, watch } from "./watch.js";
|
|
38
|
-
import { clock, counted, decideLaw, decideNote, machineKey, memoHits, withStrict, fullRate, grow, keyValue, lawInstances, proveLaw, proveLaws, proveSetFast, proveStepLaws, stepLawInstances, usedHyps, withDeadline, withModels, withTrees, withWall } from "../kernel/prove.js";
|
|
38
|
+
import { clock, counted, fullWork, decideLaw, decideNote, machineKey, memoHits, withStrict, fullRate, grow, keyValue, lawInstances, proveLaw, proveLaws, proveSetFast, proveStepLaws, stepLawInstances, usedHyps, withDeadline, withModels, withTrees, withWall, withWork } from "../kernel/prove.js";
|
|
39
39
|
import { assumed, obligations, plainOf, stepLawObligations, substC } from "../kernel/kernel.js";
|
|
40
40
|
import { env, gcd, work } from "./solver.js";
|
|
41
41
|
import { bgcd } from "./q.js";
|
|
42
42
|
import { showC, showE } from "./exists.js";
|
|
43
43
|
import { REFUTED, growCdcl } from "../kernel/cdcl.js";
|
|
44
|
+
import { eprMeter, withEprCap } from "../kernel/epr.js";
|
|
44
45
|
// a value outside a guard's (or a control value's) values
|
|
45
46
|
const off = (g, v) => v < g.value || v > (g.hi ?? g.value);
|
|
46
47
|
const KEY = 'key$found', KEY2 = 'key2$found', AT = '@', K = '#', SOME = 'k$found';
|
|
@@ -51,8 +52,10 @@ const KEY = 'key$found', KEY2 = 'key2$found', AT = '@', K = '#', SOME = 'k$found
|
|
|
51
52
|
// frontier corpus's then keeps 3,000 samples, at least as many as 500 ms of wall time gave on 2 vCPU (`runs/modal/infer/
|
|
52
53
|
// before`'s cal2 jobs: 29 to 11,625 trials, 745 to 3,000 samples). Of 100 to 3,000 trials (`runs/modal/infer/grid`),
|
|
53
54
|
// 100 lost a corpus item (metered blocks) and 200 to 3,000 none: 400 is a step above the least that lost none.
|
|
54
|
-
export const inferRates = { tries: 100, rows: 10_000, evals: 10_000, watched: 100, work: 40 };
|
|
55
|
+
export const inferRates = { tries: 100, rows: 10_000, evals: 10_000, watched: 100, work: 40, etries: 80, epr: 500, erows: 100, efull: 220 };
|
|
55
56
|
export const inferRuns = 16_000;
|
|
57
|
+
// (the share of what is left of the search's budget that the engine's clock may spend: GDP_ENGINE_SHARE, 0.95: ring needs 52.2 of its 55)
|
|
58
|
+
const engineShare = Number(env.GDP_ENGINE_SHARE ?? 0.95);
|
|
56
59
|
// GDP_INFER_TRACE=1: each phase's wall time beside what it counted, to stderr (the calibration's numbers).
|
|
57
60
|
const inferTrace = !!env.GDP_INFER_TRACE;
|
|
58
61
|
// The join (below, after the candidates): GDP_JOIN=0 turns it off, for comparing. Its share of what is left of the
|
|
@@ -62,7 +65,7 @@ const inferTrace = !!env.GDP_INFER_TRACE;
|
|
|
62
65
|
// the control state up to 7, and 128 of its values; a goal tried with 6 parts of the set before all of it, 2 forms added
|
|
63
66
|
// at a time.
|
|
64
67
|
const joinOn = env.GDP_JOIN !== '0';
|
|
65
|
-
const joinShare = 0.6, joinQueryMs = 8000,
|
|
68
|
+
const joinShare = 0.6, joinQueryMs = 8000, joinGrowEpr = 300_000, joinGrowWork = 400_000, joinRequestMs = 150, joinWalk = 8, joinPairs = 10, joinRaises = 2, joinSparse = 4, joinCoef = 1000;
|
|
66
69
|
const joinExtras = 24, joinTries = 40, joinBits = 7, joinKeys = 128, joinAttempts = 6, joinAdd = 2;
|
|
67
70
|
// GDP_JOIN_CORE=0: the join's goals by the prover's trees alone, as before (else a model, or a refutation's core, of the
|
|
68
71
|
// CDCL search first, at a quarter of the goal's budget).
|
|
@@ -700,11 +703,21 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
700
703
|
opts = { ...opts, progress: (phase, info) => globalThis.process.stderr.write(`[infer ${phase}] ${JSON.stringify(info)}\n`) };
|
|
701
704
|
const t0 = performance.now(), ms = opts.ms ?? 20000, wallUntil = t0 + ms, rule = isRule(target) ? target.withSumsOf(laws, stepLaws) : undefined;
|
|
702
705
|
// The clock the budgets read (counted milliseconds since the start, or wall time where `timed`), and the stop.
|
|
703
|
-
const timed = !!opts.timed, w0 = work.n, used = { tries: 0, rows: 0, evals: 0, watched: 0 };
|
|
706
|
+
const timed = !!opts.timed, w0 = work.n, used = { tries: 0, rows: 0, evals: 0, watched: 0, erows: 0, etries: 0 };
|
|
704
707
|
const now = () => (timed ? performance.now() - t0
|
|
705
708
|
: used.tries / inferRates.tries + used.rows / inferRates.rows + used.evals / inferRates.evals + used.watched / inferRates.watched + (work.n - w0) / inferRates.work);
|
|
706
709
|
let stopped = false;
|
|
707
710
|
const stop = () => stopped || (stopped = performance.now() > wallUntil);
|
|
711
|
+
// The engine's clock (the stage below, from the small instance on): counted as `now` is, with the EPR path's work
|
|
712
|
+
// (kernel/epr.ts's eprMeter) and the views' rows beside it, so that every choice it makes by its budget (a BFS cut, the
|
|
713
|
+
// filter, a goal's cap, a round's growth) is the same on any machine; the wall (`stop`, `until` past `ms`) only ends it.
|
|
714
|
+
// It starts at the engine's start (`eS`), and its budget, `eUntil`, is fixed there from what the join counted: 0.9
|
|
715
|
+
// of what is left of `ms` once the join's count is taken at 0.3 a millisecond (the join's rates count its work
|
|
716
|
+
// 2 to 14 times faster than a Modal container does it), so the engine ends within the wall on a container somewhat
|
|
717
|
+
// slower than Modal's usual; past `eUntil` it stops as it would past the wall, at the same place on any machine.
|
|
718
|
+
let eS = { now: 0, epr: eprMeter.n, erows: 0, etries: 0, full: fullWork() }, eUntil = ms;
|
|
719
|
+
const vnow = () => (timed ? now() : (used.etries - eS.etries) / inferRates.etries + (eprMeter.n - eS.epr) / inferRates.epr + (used.erows - eS.erows) / inferRates.erows + (fullWork() - eS.full) / inferRates.efull);
|
|
720
|
+
const meters = () => ({ real: Math.round(performance.now() - t0), v: Math.round(vnow()), now: Math.round(now()), full: Math.round(fullWork()), epr: eprMeter.n - eS.epr, erows: used.erows, etries: used.etries, tries: used.tries, rows: used.rows, evals: used.evals, work: work.n - w0 });
|
|
708
721
|
const until = ms;
|
|
709
722
|
let tp = performance.now(), cp = 0, wp = w0;
|
|
710
723
|
const trace = (what, o = {}) => {
|
|
@@ -887,17 +900,16 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
887
900
|
}
|
|
888
901
|
const termAtoms = atoms.filter(a => a.term);
|
|
889
902
|
// a row's term atoms' values, at its state (a term whose value the interpreter can't take: 0)
|
|
903
|
+
const termFns = termAtoms.map(a => compileE(a.term, m));
|
|
890
904
|
const withTerms = (env, st) => {
|
|
891
905
|
if (!termAtoms.length)
|
|
892
906
|
return env;
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
env[a.parts[0][0]] = evalE(a.term, env, st, m);
|
|
896
|
-
}
|
|
897
|
-
catch {
|
|
898
|
-
env[a.parts[0][0]] = 0;
|
|
899
|
-
}
|
|
907
|
+
termAtoms.forEach((a, i) => { try {
|
|
908
|
+
env[a.parts[0][0]] = termFns[i](env, st);
|
|
900
909
|
}
|
|
910
|
+
catch {
|
|
911
|
+
env[a.parts[0][0]] = 0;
|
|
912
|
+
} });
|
|
901
913
|
return env;
|
|
902
914
|
};
|
|
903
915
|
const A = atoms.length, cellAtoms = atoms.flatMap((a, i) => (a.cell ? [i] : []));
|
|
@@ -1679,6 +1691,8 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
1679
1691
|
atoms.push({ name: `${a.parts[0][0]}[${viewText(v, showE(v.places[place]))}]`, parts: a.parts.map(([q, sg]) => [`${AT}${AT}${q}${AT}${vi}:${place}`, sg]), param: false, int: a.int, cell: false, place, view: vi });
|
|
1680
1692
|
}
|
|
1681
1693
|
});
|
|
1694
|
+
const compiled = { frame: compileC(v.frame, m), places: v.places.map(p => compileE(p, m)), extra: extra.map(t => compileE(t.term, m)),
|
|
1695
|
+
xs: extra.map((_, j) => `$x${vi}:${j}`), qs: mapsAt.map((mps, place) => mps.map(mp => `${AT}${AT}${mp}${AT}${vi}:${place}`)) };
|
|
1682
1696
|
const rowsOf = (params, st, full = false) => {
|
|
1683
1697
|
// (`per` values a key; the engine's views (`product`) at most per^keys rows a state, 64 at least, the fewer-valued
|
|
1684
1698
|
// sorts' keys taking all of theirs and the cut on the most-valued: a sort's values past a few are still read where
|
|
@@ -1692,31 +1706,34 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
1692
1706
|
lens[i]--;
|
|
1693
1707
|
}
|
|
1694
1708
|
const cand = all2.map((vs, i) => vs.slice(0, lens[i])), out = [];
|
|
1709
|
+
// (the frame, places and extra terms compiled once a view (`compiled`); one env the keys are set in, as each
|
|
1710
|
+
// assignment's own copy was: a level reads only the keys above it)
|
|
1695
1711
|
const go = (i, env) => {
|
|
1696
1712
|
if (i === v.vars.length) {
|
|
1697
1713
|
try {
|
|
1698
|
-
if (!
|
|
1714
|
+
if (!compiled.frame(env, st))
|
|
1699
1715
|
return;
|
|
1700
1716
|
}
|
|
1701
1717
|
catch {
|
|
1702
1718
|
return;
|
|
1703
1719
|
}
|
|
1704
|
-
const row = { ...params, ...st.scalars,
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
const q = `${AT}${AT}${mp}${AT}${vi}:${place}`;
|
|
1712
|
-
row[q] = cellOf(st, mp, key);
|
|
1713
|
-
cells.push([q, mp, key]);
|
|
1720
|
+
const row = { ...params, ...st.scalars }, cells = [];
|
|
1721
|
+
row[K] = env[v.vars[0]];
|
|
1722
|
+
compiled.extra.forEach((f, j) => { try {
|
|
1723
|
+
row[compiled.xs[j]] = f(env, st);
|
|
1724
|
+
}
|
|
1725
|
+
catch {
|
|
1726
|
+
row[compiled.xs[j]] = 0;
|
|
1714
1727
|
} });
|
|
1728
|
+
mapsAt.forEach((mps, place) => { const key = compiled.places[place](env, st); mps.forEach((mp, h) => { const q = compiled.qs[place][h]; row[q] = cellOf(st, mp, key); cells.push([q, mp, key]); }); });
|
|
1729
|
+
used.erows++;
|
|
1715
1730
|
out.push(mark(withTerms(row, st), st, cells));
|
|
1716
1731
|
return;
|
|
1717
1732
|
}
|
|
1718
|
-
for (const k2 of cand[i])
|
|
1719
|
-
|
|
1733
|
+
for (const k2 of cand[i]) {
|
|
1734
|
+
env[v.vars[i]] = k2;
|
|
1735
|
+
go(i + 1, env);
|
|
1736
|
+
}
|
|
1720
1737
|
};
|
|
1721
1738
|
go(0, { ...params, ...st.scalars });
|
|
1722
1739
|
return out;
|
|
@@ -2182,10 +2199,12 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2182
2199
|
if (!('tree' in quick) && quick.stuck === 'sat' && quick.witness)
|
|
2183
2200
|
return { stuck: 'sat', witness: quick.witness, g: g };
|
|
2184
2201
|
}
|
|
2185
|
-
// (where the engine follows, the usual search
|
|
2186
|
-
// second (decentralized lock's sums pass, 0.
|
|
2187
|
-
// VoteRequestMsg[k]
|
|
2188
|
-
|
|
2202
|
+
// (where the engine follows, the usual search cut at joinGrowWork of the cost model's units and its EPR decisions at
|
|
2203
|
+
// joinGrowEpr units: the proving joins' searches take under a second (decentralized lock's sums pass, 0.8 s, 217k
|
|
2204
|
+
// units and 1.6k), and an unknown one ran 13 s (wo's every k: Leader[k] <= VoteRequestMsg[k], 1.2M and 647k), the
|
|
2205
|
+
// engine's time; counted, where a 2 s wall used to end it, so the join ends where it ends on any machine)
|
|
2206
|
+
const follow = engineFollows();
|
|
2207
|
+
const out = withEprCap(follow ? joinGrowEpr : Infinity, () => withWork(follow ? fullWork() + joinGrowWork : Infinity, () => budgeted(joinQueryMs, until2 => grow(g, new Map(), { nodes: 0, until: until2 }))));
|
|
2189
2208
|
if (!('tree' in out))
|
|
2190
2209
|
return { stuck: out.stuck, witness: out.stuck === 'sat' ? out.witness : undefined, g: g };
|
|
2191
2210
|
for (const h of usedHyps(g, out.tree))
|
|
@@ -2614,8 +2633,10 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2614
2633
|
// to 20,000 states and a seventh of what is left; its states the views' rows first.
|
|
2615
2634
|
// (an instance: the small one (`grow` none, the samples), or `grow` more elements of a sort within `share` ms, its
|
|
2616
2635
|
// BFS uncut and its own draws (the pool's data filter))
|
|
2617
|
-
|
|
2618
|
-
|
|
2636
|
+
// (`visit`: each new state as the BFS finds it, which ends the BFS by answering false: the filter reads as it goes)
|
|
2637
|
+
const instance = (grow, share, rnd, cap = 2_000_000, visit) => {
|
|
2638
|
+
let halt = false;
|
|
2639
|
+
const base = share === undefined, most = base ? 20_000 : cap, combosMax = base ? 2048 : 16_384, reqs = [];
|
|
2619
2640
|
const size = (q) => Math.max(2, Math.min(3, width[ss.indexOf(q)] ?? 2)) + grow(q), keyDom = (q) => Array.from({ length: ordered(q) ? 4 + grow(q) : size(q) }, (_, i) => i);
|
|
2620
2641
|
const fnDom = (q) => Object.keys(m.fns ?? {}).filter(f => vf(`V:${f}`) === vf(q) && ss.includes(ks.find(`F:${f}`))).flatMap(f => keyDom(ks.find(`F:${f}`)).map(k => { try {
|
|
2621
2642
|
return fnValue(m.fns[f], k);
|
|
@@ -2643,8 +2664,8 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2643
2664
|
continue;
|
|
2644
2665
|
pvs.set(JSON.stringify(p), p);
|
|
2645
2666
|
}
|
|
2646
|
-
const t3 =
|
|
2647
|
-
let end2 =
|
|
2667
|
+
const t3 = vnow(), seen = new Set(), small = [];
|
|
2668
|
+
let end2 = vnow() + (share ?? Math.min(4000, (eUntil - vnow()) / 7));
|
|
2648
2669
|
let cut = false;
|
|
2649
2670
|
// (a state's key: its cells off the map's default, in key order, the least under the renamings of each symmetric
|
|
2650
2671
|
// sort's elements: a sort the step neither orders, nor computes on (a function's argument, a param's bound), nor
|
|
@@ -2774,20 +2795,22 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2774
2795
|
catch {
|
|
2775
2796
|
continue;
|
|
2776
2797
|
}
|
|
2777
|
-
const tB =
|
|
2798
|
+
const tB = vnow(), queue = [{ params, st: st0 }], qi = { at: 0 }, bfsEnd = vnow() + (end2 - vnow()) * 0.75 / (pvs.size - reqs.length + 1);
|
|
2778
2799
|
seen.add(keyOf3(queue[0]));
|
|
2779
2800
|
small.push(queue[0]);
|
|
2801
|
+
if (visit && !visit(queue[0]))
|
|
2802
|
+
halt = true;
|
|
2780
2803
|
// (a BFS that won't finish (a quarter of its share gone, 1 s at least, and its queue still a quarter of what it
|
|
2781
2804
|
// found): cut there, the walks half a second after; an instance it does finish is what it was)
|
|
2782
2805
|
const cutAt = base ? tB + Math.max(1000, (bfsEnd - tB) / 4) : Infinity;
|
|
2783
|
-
while (qi.at < queue.length && small.length < most &&
|
|
2784
|
-
if (
|
|
2785
|
-
end2 = Math.min(end2,
|
|
2806
|
+
while (!halt && qi.at < queue.length && small.length < most && vnow() < bfsEnd) {
|
|
2807
|
+
if (vnow() > cutAt && (queue.length - qi.at) * 4 >= small.length) {
|
|
2808
|
+
end2 = Math.min(end2, vnow() + 500);
|
|
2786
2809
|
break;
|
|
2787
2810
|
}
|
|
2788
2811
|
const q0 = queue[qi.at++];
|
|
2789
2812
|
for (const input of combos) {
|
|
2790
|
-
used.
|
|
2813
|
+
used.etries++;
|
|
2791
2814
|
const next = stepOf(params, q0.st, input);
|
|
2792
2815
|
if (!next)
|
|
2793
2816
|
continue;
|
|
@@ -2796,6 +2819,10 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2796
2819
|
seen.add(k1);
|
|
2797
2820
|
small.push(q1);
|
|
2798
2821
|
queue.push(q1);
|
|
2822
|
+
if (visit && !visit(q1)) {
|
|
2823
|
+
halt = true;
|
|
2824
|
+
break;
|
|
2825
|
+
}
|
|
2799
2826
|
}
|
|
2800
2827
|
}
|
|
2801
2828
|
}
|
|
@@ -2811,12 +2838,13 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2811
2838
|
catch {
|
|
2812
2839
|
continue;
|
|
2813
2840
|
}
|
|
2814
|
-
const p2 = { ...params }, q2 = [{ params: p2, st: s0 }], q2i = { at: 0 }, seen2 = new Set([keyOf3(q2[0])]), end3 = Math.min(end2,
|
|
2841
|
+
const p2 = { ...params }, q2 = [{ params: p2, st: s0 }], q2i = { at: 0 }, seen2 = new Set([keyOf3(q2[0])]), end3 = Math.min(end2, vnow() + (bfsEnd - tB));
|
|
2815
2842
|
tableOf.set(p2, tb.fns);
|
|
2816
2843
|
others.push(q2[0]);
|
|
2817
|
-
while (q2i.at < q2.length && others.length < most &&
|
|
2844
|
+
while (!halt && q2i.at < q2.length && others.length < most && vnow() < end3) {
|
|
2818
2845
|
const q0 = q2[q2i.at++];
|
|
2819
2846
|
for (const input of combos) {
|
|
2847
|
+
used.etries++;
|
|
2820
2848
|
const next = stepIn(tb, p2, q0.st, input);
|
|
2821
2849
|
if (!next)
|
|
2822
2850
|
continue;
|
|
@@ -2825,6 +2853,10 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2825
2853
|
seen2.add(k1);
|
|
2826
2854
|
others.push(q1);
|
|
2827
2855
|
q2.push(q1);
|
|
2856
|
+
if (visit && !visit(q1)) {
|
|
2857
|
+
halt = true;
|
|
2858
|
+
break;
|
|
2859
|
+
}
|
|
2828
2860
|
}
|
|
2829
2861
|
}
|
|
2830
2862
|
}
|
|
@@ -2833,16 +2865,16 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2833
2865
|
// (then random walks from its last states, deeper than the BFS's levels reach: each step the first of a few
|
|
2834
2866
|
// requests that changes the state, to the end of its share)
|
|
2835
2867
|
const bfs = small.length;
|
|
2836
|
-
for (let t = 0; cut && reqs.length && small.length < most &&
|
|
2868
|
+
for (let t = 0; !halt && cut && reqs.length && small.length < most && vnow() < end2; t++) {
|
|
2837
2869
|
const from = small[Math.max(0, small.length - 1 - rnd(Math.min(small.length, 64)))], req = reqs.find(q => q.params === from.params);
|
|
2838
2870
|
if (!req)
|
|
2839
2871
|
break;
|
|
2840
2872
|
let at = from.st;
|
|
2841
|
-
for (let d = 0; d < 40 &&
|
|
2873
|
+
for (let d = 0; d < 40 && vnow() < end2; d++) {
|
|
2842
2874
|
let next;
|
|
2843
2875
|
for (let k = 0; k < 16 && !next; k++) {
|
|
2844
2876
|
const input = req.combos[rnd(req.combos.length)];
|
|
2845
|
-
used.
|
|
2877
|
+
used.etries++;
|
|
2846
2878
|
const s2 = stepOf(from.params, at, input);
|
|
2847
2879
|
if (s2 && keyOf3({ params: from.params, st: s2 }) !== keyOf3({ params: from.params, st: at }))
|
|
2848
2880
|
next = s2;
|
|
@@ -2857,14 +2889,13 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
2857
2889
|
}
|
|
2858
2890
|
}
|
|
2859
2891
|
}
|
|
2892
|
+
opts.progress?.('join meters', { at: base ? 'small' : 'filter bfs', ...meters() });
|
|
2860
2893
|
if (base)
|
|
2861
|
-
opts.progress?.('join small instance', { states: small.length, bfs, params: pvs.size, symmetric: sym.slice(0, rens.length > 1 ? sym.length : 0).join(), ms: Math.round(
|
|
2862
|
-
return { small, others, bfs, cut, params: pvs.size, ms: Math.round(
|
|
2894
|
+
opts.progress?.('join small instance', { states: small.length, bfs, params: pvs.size, symmetric: sym.slice(0, rens.length > 1 ? sym.length : 0).join(), ms: Math.round(vnow()), took: Math.round(vnow() - t3) });
|
|
2895
|
+
return { small, others, bfs, cut, params: pvs.size, ms: Math.round(vnow() - t3) };
|
|
2863
2896
|
};
|
|
2864
|
-
let baseMs = 0;
|
|
2865
2897
|
{
|
|
2866
2898
|
const r0 = instance(() => 0, undefined, rand);
|
|
2867
|
-
baseMs = r0.ms;
|
|
2868
2899
|
samples.unshift(...r0.small);
|
|
2869
2900
|
smallAll = [...r0.small, ...r0.others];
|
|
2870
2901
|
}
|
|
@@ -3033,23 +3064,30 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3033
3064
|
// of each sort alone, within a budget of its own (3 s, at most a tenth of what is left: half an instance's share its
|
|
3034
3065
|
// BFS, uncut, the rest reading its states); a cube some row of such a state is in is no law, and goes
|
|
3035
3066
|
function dataFilter(pool) {
|
|
3036
|
-
// (
|
|
3037
|
-
//
|
|
3038
|
-
|
|
3067
|
+
// (in states, not time, so that a slow machine reads what a fast one does: each instance's states read as its BFS
|
|
3068
|
+
// finds them, until they stop killing, `quiet` (150) states in a row that kill no cube (ring's kills come up to its
|
|
3069
|
+
// 529th state, wo's to its 271st, distributed's to its 152nd), `most5` (1,000) at most;
|
|
3070
|
+
// its BFS ends there, a share of the engine's clock (30 s, a third of what is left) its outer bound. A slow
|
|
3071
|
+
// container that read fewer states left ring's pool at 47–61 cubes, not 44, and its first round past the wall:
|
|
3072
|
+
// research/protocols/engine/DESIGN.md, gen/laneA)
|
|
3073
|
+
const t5 = vnow(), share = Math.min(Number(env.GDP_POOL_MS ?? 30_000), (eUntil - t5) / 3);
|
|
3074
|
+
const quiet = Number(env.GDP_POOL_QUIET ?? 150), least5 = Number(env.GDP_POOL_LEAST ?? 0), most5 = Number(env.GDP_POOL_STATES ?? 1_000);
|
|
3039
3075
|
const litAt = (l, r) => ('at' in l ? valueOf(atoms[l.at.atom], r) === l.at.value : l.lin.coef.reduce((s2, [i, c]) => s2 + c * valueOf(atoms[i], r), 0) <= l.lin.d);
|
|
3040
3076
|
const plans = [() => 1, ...(ss.length > 1 ? ss.map(s2 => (q) => (q === s2 ? 1 : 0)) : [])];
|
|
3041
3077
|
let live = pool, states = 0;
|
|
3042
3078
|
for (const [k, grow] of plans.entries()) {
|
|
3043
|
-
if (!live.length ||
|
|
3079
|
+
if (!live.length || stop())
|
|
3044
3080
|
break;
|
|
3045
|
-
const
|
|
3046
|
-
const byView = new Map();
|
|
3081
|
+
const killed = new Set(), byView = new Map();
|
|
3047
3082
|
for (const f of live)
|
|
3048
3083
|
byView.set(f.view, [...(byView.get(f.view) ?? []), f]);
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3084
|
+
let read = 0, still = 0, lastKill = 0;
|
|
3085
|
+
const r = instance(grow, share, seeded(29 + k), most5, q => {
|
|
3086
|
+
if (read >= most5 || (read >= (k ? 0 : least5) && still >= quiet) || stop())
|
|
3087
|
+
return false;
|
|
3052
3088
|
states++;
|
|
3089
|
+
read++;
|
|
3090
|
+
const before = killed.size;
|
|
3053
3091
|
for (const [vi, fs] of byView) {
|
|
3054
3092
|
const alive = fs.filter(f => !killed.has(f));
|
|
3055
3093
|
if (!alive.length)
|
|
@@ -3073,13 +3111,18 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3073
3111
|
nearMiss.set(f, (nearMiss.get(f) ?? 0) + near);
|
|
3074
3112
|
}
|
|
3075
3113
|
}
|
|
3076
|
-
|
|
3114
|
+
if (killed.size > before)
|
|
3115
|
+
lastKill = read;
|
|
3116
|
+
still = killed.size > before ? 0 : still + 1;
|
|
3117
|
+
return read < most5 && (read < (k ? 0 : least5) || still < quiet);
|
|
3118
|
+
});
|
|
3119
|
+
opts.progress?.('join meters', { at: `filter read ${k}`, read, lastKill, bfs: r.small.length + r.others.length, ...meters() });
|
|
3077
3120
|
live = live.filter(f => !killed.has(f));
|
|
3078
3121
|
// (no instance after one that kills nothing; GDP_POOL_STOP=0 runs them all)
|
|
3079
3122
|
if (env.GDP_POOL_STOP !== '0' && k > 0 && !killed.size)
|
|
3080
3123
|
break;
|
|
3081
3124
|
}
|
|
3082
|
-
opts.progress?.('join pool', { made: pool.length, left: live.length, states, ms: Math.round(performance.now() -
|
|
3125
|
+
opts.progress?.('join pool', { made: pool.length, left: live.length, states, ms: Math.round(vnow() - t5), real: Math.round(performance.now() - t0) });
|
|
3083
3126
|
return live;
|
|
3084
3127
|
}
|
|
3085
3128
|
};
|
|
@@ -3103,9 +3146,14 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3103
3146
|
// decentralized lock's) while the caller's law fails from the set.
|
|
3104
3147
|
const engine = () => {
|
|
3105
3148
|
if (sorts && callerLaws.some(l => l.keys?.length) && now() < until && !stop()) {
|
|
3106
|
-
|
|
3149
|
+
if (!timed) {
|
|
3150
|
+
eS = { now: now(), epr: eprMeter.n, erows: used.erows, etries: used.etries, full: fullWork() };
|
|
3151
|
+
eUntil = engineShare * (ms - 0.3 * eS.now);
|
|
3152
|
+
}
|
|
3153
|
+
opts.progress?.('join engine', { wall: Math.round(vnow()), eUntil: Math.round(eUntil) });
|
|
3154
|
+
opts.progress?.('join meters', { at: 'engine', ...meters() });
|
|
3107
3155
|
// (a sums pass's reserve where one follows: 10 s, or a quarter of what is left where less is)
|
|
3108
|
-
const v0 = views.length, reserve = rule?.withMapSums() ? Math.min(10_000, (
|
|
3156
|
+
const v0 = views.length, reserve = rule?.withMapSums() ? Math.min(10_000, (eUntil - vnow()) / 4) : 0;
|
|
3109
3157
|
const implied = (f) => {
|
|
3110
3158
|
const v = views[f.view], sk = { vars: Object.fromEntries(v.vars.map(k => [k, x(`${k}#`)])), maps: {}, flags: {} }, hyps = [substC(v.frame, sk), not(substC(condOf(f), sk))];
|
|
3111
3159
|
for (const l of given) {
|
|
@@ -3122,7 +3170,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3122
3170
|
const near = (f) => (f.cube.some(l => atomsIn(formOf([l])).some(i => callerMaps.has(atoms[i].parts[0][0].split(AT)[2] ?? ''))) ? 0 : 1);
|
|
3123
3171
|
// (the rounds over the data-filtered pool cut to its minimal cubes)
|
|
3124
3172
|
const minPool = env.GDP_POOL !== '0' ? minimal(enumerated()) : { kept: enumerated(), by: new Map() }, made = minPool.kept;
|
|
3125
|
-
const tEngine =
|
|
3173
|
+
const tEngine = vnow();
|
|
3126
3174
|
let cubes = [];
|
|
3127
3175
|
// (in turn by the maps a cube reads, those reading the caller's first: one of each kind before a second of any; in
|
|
3128
3176
|
// a kind, the fewer literals first (DuoAI's minimal clauses), then the cube over more distinct keys (the law its
|
|
@@ -3151,11 +3199,14 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3151
3199
|
if ((whole || f.cube.length <= 2) && !names.has(textOf(f)) && !implied(f))
|
|
3152
3200
|
cubes.push(f);
|
|
3153
3201
|
}
|
|
3154
|
-
opts.progress?.('join enumerated', { views: views.length - v0, cubes: cubes.length, ms: Math.round(
|
|
3202
|
+
opts.progress?.('join enumerated', { views: views.length - v0, cubes: cubes.length, ms: Math.round(vnow()) });
|
|
3203
|
+
opts.progress?.('join meters', { at: 'enumerated', ...meters() });
|
|
3155
3204
|
opts.progress?.('join cubes', { cubes: cubes.map(textOf).join(' | ') });
|
|
3156
3205
|
opts.progress?.('join made', { cubes: made.map(textOf).join(' | ') });
|
|
3157
3206
|
// (a goal's proof within the search's own end, on the cost model's clock: a counted search inside it keeps the end)
|
|
3158
|
-
|
|
3207
|
+
// (a goal's cap, on the engine's clock: the kernel's counted deadline and the EPR path's counted cap, so that the
|
|
3208
|
+
// goal ends at the same place on any machine; the search's wall, only its outer end)
|
|
3209
|
+
const within = (end, f) => { const left = Math.max(0, end - vnow()); return withWall(wallUntil, () => withEprCap(left * inferRates.epr, () => counted(fullRate, () => withDeadline(clock() + left, f), true))); };
|
|
3159
3210
|
// (a model's values past the rule's constants renamed onto small ones in order, a gap kept up to 64: the step then
|
|
3160
3211
|
// runs at every key, and the model's equalities, order, +1 and comparisons with the constants are kept)
|
|
3161
3212
|
const top = Math.max(1024, ...[...JSON.stringify([m.step, m.assume ?? null, m.pre ?? null]).matchAll(/"value":(\d+)/g)].map(q => Number(q[1])));
|
|
@@ -3178,7 +3229,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3178
3229
|
cells.delete(k);
|
|
3179
3230
|
const at = (s2) => ({ scalar: withTerms({ ...params, ...s2.scalars }, s2), cells: [], views: views.map((v, i) => (read.has(i) ? v.rowsOf(params, s2) : [])) });
|
|
3180
3231
|
let post;
|
|
3181
|
-
if (
|
|
3232
|
+
if (vnow() > eUntil)
|
|
3182
3233
|
return false;
|
|
3183
3234
|
try {
|
|
3184
3235
|
post = run.step(params, st, requestOf(w));
|
|
@@ -3187,7 +3238,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3187
3238
|
catch {
|
|
3188
3239
|
return false;
|
|
3189
3240
|
}
|
|
3190
|
-
if (
|
|
3241
|
+
if (vnow() > eUntil)
|
|
3191
3242
|
return false;
|
|
3192
3243
|
const before = at(st);
|
|
3193
3244
|
if (!others.every(g => holdsAt(g, before)))
|
|
@@ -3374,7 +3425,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3374
3425
|
let held = false;
|
|
3375
3426
|
const pres = [], subs = [], preAt = new WeakMap();
|
|
3376
3427
|
let perGoal = 0, houdinied = false;
|
|
3377
|
-
const engineStart =
|
|
3428
|
+
const engineStart = vnow();
|
|
3378
3429
|
const ptOf = (q) => { let pt = preAt.get(q); if (!pt) {
|
|
3379
3430
|
pt = withFnsOf(q.w, () => pointOf(q.params, q.st));
|
|
3380
3431
|
preAt.set(q, pt);
|
|
@@ -3467,7 +3518,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3467
3518
|
// always, GDP_TD=0 never)
|
|
3468
3519
|
if ((env.GDP_TD === '1' || (env.GDP_TD !== '0' && made.length > 24 && made.length <= 64)) && !stop())
|
|
3469
3520
|
withTrees(() => withStrict(() => {
|
|
3470
|
-
const T0 =
|
|
3521
|
+
const T0 = vnow(), ph = (o) => opts.progress?.('join td', { ...o, td: Math.round(vnow() - T0), ...meters() });
|
|
3471
3522
|
const by = minPool.by, q1 = Number(env.GDP_TD_Q1 ?? joinQueryMs / 8), q2 = Number(env.GDP_TD_Q2 ?? q1);
|
|
3472
3523
|
ph({ phase: 'start', made: made.length, before: Math.round(tEngine - t0) });
|
|
3473
3524
|
const fresh = (f) => !names.has(textOf(f)) && !dead.has(textOf(f)) && !implied(f) && !atStart(f);
|
|
@@ -3475,14 +3526,14 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3475
3526
|
ph({ phase: 'pool', cubes: hs.length });
|
|
3476
3527
|
const uses = new Map(), undecided = new Set(), reasked = new Set();
|
|
3477
3528
|
let asked = new Set(hs);
|
|
3478
|
-
for (let r = 0; hs.length &&
|
|
3479
|
-
const ls = [...given, ...hs.map(lawFor)], mm = forLaws(ls).m, failed = new Set(), tr =
|
|
3529
|
+
for (let r = 0; hs.length && vnow() < eUntil && !stop(); r++) {
|
|
3530
|
+
const ls = [...given, ...hs.map(lawFor)], mm = forLaws(ls).m, failed = new Set(), tr = vnow(), at = new Map(hs.map((f, i) => [f, given.length + i]));
|
|
3480
3531
|
const ask = (f, ms2) => {
|
|
3481
|
-
if (
|
|
3532
|
+
if (vnow() > eUntil) {
|
|
3482
3533
|
undecided.add(f);
|
|
3483
3534
|
return;
|
|
3484
3535
|
}
|
|
3485
|
-
const dl = within(Math.min(
|
|
3536
|
+
const dl = within(Math.min(eUntil, vnow() + ms2), () => decideLaw(mm, ls, at.get(f)));
|
|
3486
3537
|
if (!dl) {
|
|
3487
3538
|
undecided.add(f);
|
|
3488
3539
|
return;
|
|
@@ -3504,11 +3555,11 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3504
3555
|
todo = [...todo].sort((a2, b2) => (nearMiss.get(b2) ?? 0) - (nearMiss.get(a2) ?? 0));
|
|
3505
3556
|
let cur = hs.filter(f => !failed.has(f));
|
|
3506
3557
|
for (const f of todo) {
|
|
3507
|
-
if (
|
|
3558
|
+
if (vnow() > eUntil) {
|
|
3508
3559
|
undecided.add(f);
|
|
3509
3560
|
continue;
|
|
3510
3561
|
}
|
|
3511
|
-
const ls2 = [...given, ...cur.map(lawFor)], dl = within(Math.min(
|
|
3562
|
+
const ls2 = [...given, ...cur.map(lawFor)], dl = within(Math.min(eUntil, vnow() + q1), () => decideLaw(mm, ls2, given.length + cur.indexOf(f)));
|
|
3512
3563
|
if (!dl) {
|
|
3513
3564
|
undecided.add(f);
|
|
3514
3565
|
continue;
|
|
@@ -3534,7 +3585,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3534
3585
|
reasked.add(f);
|
|
3535
3586
|
ask(f, Math.max(q1, q2));
|
|
3536
3587
|
}
|
|
3537
|
-
ph({ phase: 'round', round: r, cubes: hs.length, asked: todo.length, second, failed: failed.size, undecided: undecided.size, ms: Math.round(
|
|
3588
|
+
ph({ phase: 'round', round: r, cubes: hs.length, asked: todo.length, second, failed: failed.size, undecided: undecided.size, ms: Math.round(vnow() - tr) });
|
|
3538
3589
|
if (!failed.size)
|
|
3539
3590
|
break;
|
|
3540
3591
|
for (const f of failed)
|
|
@@ -3545,19 +3596,19 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3545
3596
|
// (only the goals whose proofs read a dropped cube, the new ones, and the undecided are asked again)
|
|
3546
3597
|
asked = new Set([...back, ...hs.filter(f => !uses.has(textOf(f)) || uses.get(textOf(f)).some(u => gone.has(u)))]);
|
|
3547
3598
|
}
|
|
3548
|
-
if (stop() ||
|
|
3599
|
+
if (stop() || vnow() > eUntil) {
|
|
3549
3600
|
ph({ phase: 'out of time' });
|
|
3550
3601
|
return;
|
|
3551
3602
|
}
|
|
3552
3603
|
// (GDP_TD_DECIDED=1: the cubes Houdini left undecided out before the caller's goals: the cone of decided cubes)
|
|
3553
3604
|
if (env.GDP_TD_DECIDED === '1')
|
|
3554
3605
|
hs = hs.filter(f => !undecided.has(f));
|
|
3555
|
-
const tc =
|
|
3606
|
+
const tc = vnow(), need = new Set();
|
|
3556
3607
|
const callerFrom = () => {
|
|
3557
3608
|
need.clear();
|
|
3558
3609
|
const ls = [...given, ...hs.map(lawFor), ...(ghost ? [ghost.plain] : [])], mm = withGhost(forLaws(ls).m);
|
|
3559
3610
|
for (const l of [...laws, ...(ghost ? [ghost.plain] : [])]) {
|
|
3560
|
-
const dl = within(Math.min(
|
|
3611
|
+
const dl = within(Math.min(eUntil, vnow() + joinQueryMs), () => decideLaw(mm, ls, ls.findIndex(k => k.name === l.name)));
|
|
3561
3612
|
if (!dl?.proven)
|
|
3562
3613
|
return false;
|
|
3563
3614
|
for (const u of dl.uses)
|
|
@@ -3578,16 +3629,16 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3578
3629
|
todo.push(u);
|
|
3579
3630
|
} };
|
|
3580
3631
|
close();
|
|
3581
|
-
for (let it = 0; callerOk && it < 8 &&
|
|
3632
|
+
for (let it = 0; callerOk && it < 8 && vnow() < eUntil && !stop(); it++) {
|
|
3582
3633
|
const inCone = hs.filter(f => need.has(textOf(f))), open = inCone.filter(f => !uses.has(textOf(f)));
|
|
3583
3634
|
if (!open.length)
|
|
3584
3635
|
break;
|
|
3585
3636
|
const ls = [...given, ...inCone.map(lawFor), ...(ghost ? [ghost.plain] : [])], mm = withGhost(forLaws(ls).m);
|
|
3586
3637
|
let grew = 0, settledN = 0;
|
|
3587
3638
|
for (const f of open) {
|
|
3588
|
-
if (
|
|
3639
|
+
if (vnow() > eUntil)
|
|
3589
3640
|
break;
|
|
3590
|
-
const dl = within(Math.min(
|
|
3641
|
+
const dl = within(Math.min(eUntil, vnow() + q2), () => decideLaw(mm, ls, ls.findIndex(k => k.name === textOf(f))));
|
|
3591
3642
|
if (dl?.proven) {
|
|
3592
3643
|
uses.set(textOf(f), dl.uses);
|
|
3593
3644
|
settledN++;
|
|
@@ -3607,17 +3658,17 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3607
3658
|
break;
|
|
3608
3659
|
}
|
|
3609
3660
|
let cut = hs.filter(f => need.has(textOf(f)));
|
|
3610
|
-
ph({ phase: 'cone', fixpoint: hs.length, undecided: undecided.size, caller: callerOk ? 1 : 0, cone: cut.length, undecidedInCone: cut.filter(f => undecided.has(f)).length, ms: Math.round(
|
|
3661
|
+
ph({ phase: 'cone', fixpoint: hs.length, undecided: undecided.size, caller: callerOk ? 1 : 0, cone: cut.length, undecidedInCone: cut.filter(f => undecided.has(f)).length, ms: Math.round(vnow() - tc) });
|
|
3611
3662
|
if (callerOk)
|
|
3612
|
-
for (let k = 0; k < 24 &&
|
|
3613
|
-
const t2 =
|
|
3663
|
+
for (let k = 0; k < 24 && vnow() < eUntil && !stop(); k++) {
|
|
3664
|
+
const t2 = vnow(), setLaws = [...laws, ...cut.map(lawFor), ...(ghost ? [ghost.some] : [])];
|
|
3614
3665
|
const h0 = memoHits.n, m0 = memoHits.miss;
|
|
3615
3666
|
let v = within(t0 + ms, () => prove(setLaws, true));
|
|
3616
|
-
const hits = memoHits.n - h0, misses = memoHits.miss - m0, fastMs = Math.round(
|
|
3667
|
+
const hits = memoHits.n - h0, misses = memoHits.miss - m0, fastMs = Math.round(vnow() - t2), fast = v.proven && v.checked ? 1 : 0, fastAt = String(v.goal ?? '').slice(0, 100);
|
|
3617
3668
|
if (!(v.proven && v.checked))
|
|
3618
3669
|
v = within(t0 + ms, () => prove(setLaws));
|
|
3619
3670
|
const at = String(v.goal ?? ''), g = v.proven && v.checked ? undefined : cut.find(c => at.startsWith(`${textOf(c)} @`));
|
|
3620
|
-
ph({ phase: 'prove', cubes: cut.length, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(
|
|
3671
|
+
ph({ phase: 'prove', cubes: cut.length, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(vnow() - t2), fastMs, fast, hits, misses, setKey: memoHits.setKey, tdKey: env.GDP_MEMO_TRACE ? machineKey(forLaws([...given, ...cut.map(lawFor)]).m) : '', diff: env.GDP_MEMO_TRACE ? ((x, y) => { let i = 0; while (i < x.length && x[i] === y[i])
|
|
3621
3672
|
i++; return `${i}: ${x.slice(Math.max(0, i - 60), i + 60)} || ${y.slice(Math.max(0, i - 60), i + 60)}`; })(JSON.stringify(forLaws([...given, ...cut.map(lawFor)]).m), memoHits.setJson) : '', fastAt, at: at.slice(0, 100) });
|
|
3622
3673
|
if (v.proven && v.checked) {
|
|
3623
3674
|
why = 'inductive';
|
|
@@ -3648,18 +3699,18 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3648
3699
|
// (DuoAI's: the Houdini fixpoint of the relevant candidates, once, with 40% of the engine's time left: the set, the pending cubes and every cube a
|
|
3649
3700
|
// counterexample ranked in its top eight, a cube the fast proof fails at dropped (the usual proof where it fails at
|
|
3650
3701
|
// a cube the rounds proved), until the whole proves or the time is out)
|
|
3651
|
-
if (!houdinied && !enumProof &&
|
|
3702
|
+
if (!houdinied && !enumProof && vnow() > eUntil - 0.4 * (eUntil - engineStart)) {
|
|
3652
3703
|
houdinied = true;
|
|
3653
3704
|
let hs = [...new Map([...cubes, ...pending, ...pool].filter(g => !dead.has(textOf(g)) && !atStart(g)).map(g => [textOf(g), g])).values()];
|
|
3654
|
-
for (let k = 0; k < 200 && hs.length &&
|
|
3655
|
-
const t2 =
|
|
3705
|
+
for (let k = 0; k < 200 && hs.length && vnow() < eUntil && !stop(); k++) {
|
|
3706
|
+
const t2 = vnow(), hl = [...laws, ...hs.map(lawFor), ...(ghost ? [ghost.some] : [])];
|
|
3656
3707
|
let v = within(t0 + ms, () => prove(hl, true));
|
|
3657
3708
|
const at0 = String(v.goal ?? ''), g0 = v.proven && v.checked ? undefined : hs.find(c => at0.startsWith(`${textOf(c)} @`));
|
|
3658
3709
|
// (or at a law the caller gave, a kind's: no cube to blame, so the usual proof's verdict)
|
|
3659
3710
|
if (!(v.proven && v.checked) && (g0 ? at0.endsWith('@step') && stands.has(lawFor(g0).name) : true))
|
|
3660
3711
|
v = within(t0 + ms, () => prove(hl));
|
|
3661
3712
|
const at = String(v.goal ?? ''), g = v.proven && v.checked ? undefined : hs.find(c => at.startsWith(`${textOf(c)} @`));
|
|
3662
|
-
opts.progress?.('join houdini', { cubes: hs.length, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(
|
|
3713
|
+
opts.progress?.('join houdini', { cubes: hs.length, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(vnow() - t2), at: at.slice(0, 100) });
|
|
3663
3714
|
if (v.proven && v.checked) {
|
|
3664
3715
|
why = 'inductive';
|
|
3665
3716
|
cone = hs;
|
|
@@ -3679,7 +3730,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3679
3730
|
}
|
|
3680
3731
|
let asked = 0, cubeMs = 0, tGoal = 0;
|
|
3681
3732
|
// (later rounds less the sums pass's reserve, unless the caller's law holds from the set: Houdini's part, then)
|
|
3682
|
-
const kUntil = () =>
|
|
3733
|
+
const kUntil = () => eUntil - (round && !held ? reserve : 0);
|
|
3683
3734
|
const real = new Set(), unsure = new Set(), lsAll = [...given, ...cubes.map(lawFor), ...(ghost ? [ghost.plain] : [])], blocked2 = [], mmRound = withGhost(forLaws(lsAll).m), at2 = new Map(cubes.map((g, i) => [g, i]));
|
|
3684
3735
|
const version = versionOf(), startReal = new Set(), promoted = [];
|
|
3685
3736
|
let caller = false, complete = true, again = false, coneTried = false;
|
|
@@ -3689,11 +3740,11 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3689
3740
|
// proof fails at, is left out and the caller asked again (Houdini over the cone), a few times. The memo keeps every
|
|
3690
3741
|
// decision for the round's goals after it. GDP_IC3_CONE=0 off)
|
|
3691
3742
|
const tryCone = () => {
|
|
3692
|
-
const t1 =
|
|
3743
|
+
const t1 = vnow(), out2 = new Set();
|
|
3693
3744
|
for (let it = 0; it < 6; it++) {
|
|
3694
3745
|
const cs = cubes.filter(c => !out2.has(c)), ls2 = it ? [...given, ...cs.map(lawFor), ...(ghost ? [ghost.plain] : [])] : lsAll, mm2 = it ? withGhost(forLaws(ls2).m) : mmRound;
|
|
3695
3746
|
const byName = new Map(cs.map(c => [textOf(c), c])), at3 = new Map(cs.map((c, i) => [c, given.length + i])), need = new Set(), todo = [];
|
|
3696
|
-
const ask = (i) => (
|
|
3747
|
+
const ask = (i) => (vnow() > kUntil() || stop() ? undefined : within(Math.min(kUntil(), vnow() + joinQueryMs / 8), () => decideLaw(mm2, ls2, i)));
|
|
3697
3748
|
const add = (us) => { for (const u of us)
|
|
3698
3749
|
if (!need.has(u)) {
|
|
3699
3750
|
need.add(u);
|
|
@@ -3710,7 +3761,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3710
3761
|
const c = byName.get(todo.pop());
|
|
3711
3762
|
if (!c)
|
|
3712
3763
|
continue;
|
|
3713
|
-
if (
|
|
3764
|
+
if (vnow() > kUntil() || stop())
|
|
3714
3765
|
return false;
|
|
3715
3766
|
const dl = ask(at3.get(c));
|
|
3716
3767
|
if (!dl) {
|
|
@@ -3724,13 +3775,13 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3724
3775
|
}
|
|
3725
3776
|
if (failed) {
|
|
3726
3777
|
out2.add(failed);
|
|
3727
|
-
opts.progress?.('join cone', { round, it, failed: textOf(failed).slice(0, 100), need: need.size, ms: Math.round(
|
|
3778
|
+
opts.progress?.('join cone', { round, it, failed: textOf(failed).slice(0, 100), need: need.size, ms: Math.round(vnow() - t1) });
|
|
3728
3779
|
continue;
|
|
3729
3780
|
}
|
|
3730
3781
|
const cut = cs.filter(c => need.has(textOf(c)));
|
|
3731
3782
|
const v = within(t0 + ms, () => prove([...laws, ...cut.map(lawFor), ...(ghost ? [ghost.some] : [])], true));
|
|
3732
3783
|
const at = String(v.goal ?? ''), g = v.proven && v.checked ? undefined : cut.find(c => at.startsWith(`${textOf(c)} @`));
|
|
3733
|
-
opts.progress?.('join cone', { round, it, cubes: cubes.length, cone: cut.length, undecided: open2, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(
|
|
3784
|
+
opts.progress?.('join cone', { round, it, cubes: cubes.length, cone: cut.length, undecided: open2, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(vnow() - t1), at: at.slice(0, 100) });
|
|
3734
3785
|
if (v.proven && v.checked) {
|
|
3735
3786
|
why = 'inductive';
|
|
3736
3787
|
cone = cut;
|
|
@@ -3747,7 +3798,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3747
3798
|
};
|
|
3748
3799
|
{
|
|
3749
3800
|
for (const goal of [...laws.map(l => l.name), ...(ghost ? [ghost.plain.name] : []), ...cubes]) {
|
|
3750
|
-
if (
|
|
3801
|
+
if (vnow() > kUntil() || stop()) {
|
|
3751
3802
|
complete = false;
|
|
3752
3803
|
break;
|
|
3753
3804
|
}
|
|
@@ -3772,16 +3823,16 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3772
3823
|
// caller's within one); else a model or a refutation of the CDCL search alone, then the proof path's)
|
|
3773
3824
|
if (f) {
|
|
3774
3825
|
if (tGoal)
|
|
3775
|
-
cubeMs +=
|
|
3776
|
-
tGoal =
|
|
3826
|
+
cubeMs += vnow() - tGoal;
|
|
3827
|
+
tGoal = vnow();
|
|
3777
3828
|
asked++;
|
|
3778
3829
|
}
|
|
3779
3830
|
else
|
|
3780
3831
|
tGoal = 0;
|
|
3781
|
-
const tDl =
|
|
3832
|
+
const tDl = vnow(), dlEnd = Math.min(kUntil(), vnow() + (f ? joinQueryMs / 8 : joinQueryMs)), dl = within(dlEnd, () => decideLaw(mm, ls, idx));
|
|
3782
3833
|
// (the EPR path out of time on the caller's goal, or refuting it with a core the kernel's search didn't finish:
|
|
3783
3834
|
// the proof path would be no quicker)
|
|
3784
|
-
const outOfTime = !dl && (
|
|
3835
|
+
const outOfTime = !dl && (vnow() - tDl >= 0.9 * (dlEnd - tDl) || decideNote.refuted);
|
|
3785
3836
|
if (dl?.proven) {
|
|
3786
3837
|
stand(ls[idx].name);
|
|
3787
3838
|
continue;
|
|
@@ -3795,7 +3846,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3795
3846
|
const inst = mapNames.length ? lawInstances(mm, ls, idx) : undefined, g = obligations(mm, ls, inst ? { [ls[idx].name]: inst } : {}, idx)[1];
|
|
3796
3847
|
// (the engine's wall too: a counted budget alone runs on past it, wo's 6 s)
|
|
3797
3848
|
// (its share on the wall too: a counted budget of 2 s ran 8.8 s on wo's 3-key cubes)
|
|
3798
|
-
const quick = budgeted(joinQueryMs / 4, until2 => growCdcl(g, new Map(), { nodes: 0, until: until2 }, { model: true, core: true, wall:
|
|
3849
|
+
const quick = budgeted(joinQueryMs / 4, until2 => growCdcl(g, new Map(), { nodes: 0, until: until2 }, { model: true, core: true, wall: wallUntil }));
|
|
3799
3850
|
if (!('tree' in quick) && quick.why === REFUTED && quick.core) {
|
|
3800
3851
|
const lawAt = lawsFrom(mm, ls, false, inst ?? {});
|
|
3801
3852
|
settled.set(ls[idx].name, [...new Set([...quick.core].map(h => lawAt.get(h)).filter((k) => k !== undefined && k >= given.length && k !== idx).map(k => ls[k].name))]);
|
|
@@ -3811,7 +3862,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3811
3862
|
// (a cube the EPR path doesn't decide: the CDCL search's answer alone; the caller's, the proof path's too)
|
|
3812
3863
|
if (!isReal && !f && !outOfTime) {
|
|
3813
3864
|
proofs++;
|
|
3814
|
-
const r2 = within(Math.min(kUntil() - 2000,
|
|
3865
|
+
const r2 = within(Math.min(kUntil() - 2000, vnow() + Math.max(joinQueryMs * 1.25, (kUntil() - vnow()) / 2)), () => proveLaw(mm, ls, idx));
|
|
3815
3866
|
if (r2.proven) {
|
|
3816
3867
|
stand(ls[idx].name);
|
|
3817
3868
|
continue;
|
|
@@ -3873,10 +3924,10 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3873
3924
|
break;
|
|
3874
3925
|
}
|
|
3875
3926
|
if (!f && !ghosts) {
|
|
3876
|
-
const t1 =
|
|
3927
|
+
const t1 = vnow();
|
|
3877
3928
|
ghosts = ghostsOf();
|
|
3878
3929
|
ghost = ghosts.shift();
|
|
3879
|
-
opts.progress?.('join exists', { law: ghost ? `${ghost.plain.name.slice(0, 160)}; ${ghost.name} := ${JSON.stringify(ghost.step).slice(0, 160)}` : 'none', ms: Math.round(
|
|
3930
|
+
opts.progress?.('join exists', { law: ghost ? `${ghost.plain.name.slice(0, 160)}; ${ghost.name} := ${JSON.stringify(ghost.step).slice(0, 160)}` : 'none', ms: Math.round(vnow() - t1) });
|
|
3880
3931
|
if (ghost) {
|
|
3881
3932
|
again = true;
|
|
3882
3933
|
held = false;
|
|
@@ -3892,7 +3943,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3892
3943
|
(isReal ? real : unsure).add(f);
|
|
3893
3944
|
}
|
|
3894
3945
|
}
|
|
3895
|
-
opts.progress?.('join enumerated', { round, cubes: cubes.length, real: real.size, unsure: unsure.size, caller: caller ? 1 : 0, diagrams: blocked2.length, ms: Math.round(
|
|
3946
|
+
opts.progress?.('join enumerated', { round, cubes: cubes.length, real: real.size, unsure: unsure.size, caller: caller ? 1 : 0, diagrams: blocked2.length, ms: Math.round(vnow()) });
|
|
3896
3947
|
// (optimistic Houdini: an unsure cube holds at every small state and every step from one (they are its rows), so
|
|
3897
3948
|
// it stays; the set's proof decides, a cube it fails at dropped and the rounds go on)
|
|
3898
3949
|
// (IC3's push: the pending cubes asked together, each with the set and every other pending one assumed (one frame),
|
|
@@ -3903,15 +3954,15 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3903
3954
|
const pushed = frame.length;
|
|
3904
3955
|
for (const g of frame)
|
|
3905
3956
|
tried.set(g, version);
|
|
3906
|
-
for (let pass = 0; frame.length && pass < 4 &&
|
|
3957
|
+
for (let pass = 0; frame.length && pass < 4 && vnow() < kUntil() && !stop(); pass++) {
|
|
3907
3958
|
frame = frame.filter((g, i) => !lsAll.some(l => l.name === textOf(g)) && frame.findIndex(h => textOf(h) === textOf(g)) === i);
|
|
3908
3959
|
const lsP = [...lsAll, ...frame.map(lawFor)], mmP = withGhost(forLaws(lsP).m), failed = new Set();
|
|
3909
3960
|
frame.forEach((g, i) => {
|
|
3910
|
-
if (
|
|
3961
|
+
if (vnow() > kUntil()) {
|
|
3911
3962
|
failed.add(g);
|
|
3912
3963
|
return;
|
|
3913
3964
|
}
|
|
3914
|
-
const dl = within(Math.min(kUntil(),
|
|
3965
|
+
const dl = within(Math.min(kUntil(), vnow() + joinQueryMs / 8), () => decideLaw(mmP, lsP, lsAll.length + i));
|
|
3915
3966
|
if (!dl || dl.proven)
|
|
3916
3967
|
return;
|
|
3917
3968
|
failed.add(g);
|
|
@@ -3951,7 +4002,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3951
4002
|
if (asked > 1)
|
|
3952
4003
|
perGoal = Math.max(perGoal, 250, cubeMs / (asked - 1));
|
|
3953
4004
|
// (the next round's new cubes: what a quarter of what is left affords past the goals it asks again, 8 at least)
|
|
3954
|
-
const grow = (kept) => { const ask = kept.filter(g => !kept2.has(g) && !stands.has(lawFor(g).name)).length, afford = perGoal ? Math.floor((
|
|
4005
|
+
const grow = (kept) => { const ask = kept.filter(g => !kept2.has(g) && !stands.has(lawFor(g).name)).length, afford = perGoal ? Math.floor((eUntil - vnow()) / (4 * perGoal)) : 16; return relevant(Math.max(8, Math.min(256 - kept.length, afford - ask)), kept); };
|
|
3955
4006
|
if (blocked2.length) {
|
|
3956
4007
|
if (drops.size)
|
|
3957
4008
|
unstand(drops);
|
|
@@ -3978,8 +4029,8 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3978
4029
|
const gone = [];
|
|
3979
4030
|
let grown = false;
|
|
3980
4031
|
if (complete && !caller && !drops.size)
|
|
3981
|
-
for (let k = 0; k < 24 && !stop() &&
|
|
3982
|
-
const t2 =
|
|
4032
|
+
for (let k = 0; k < 24 && !stop() && vnow() < eUntil; k++) {
|
|
4033
|
+
const t2 = vnow(), setLaws = [...laws, ...cubes.map(lawFor), ...(ghost ? [ghost.some] : [])];
|
|
3983
4034
|
let v = within(t0 + ms, () => prove(setLaws, true));
|
|
3984
4035
|
// (the fast proof failing at a cube whose own goal the rounds proved from this set: the two disagree, and the
|
|
3985
4036
|
// usual proof decides (proveSetFast has a spurious model on ring's own-id law))
|
|
@@ -3987,7 +4038,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
3987
4038
|
if (g0 && at0.endsWith('@step') && stands.has(lawFor(g0).name))
|
|
3988
4039
|
v = within(t0 + ms, () => prove(setLaws));
|
|
3989
4040
|
const at = String(v.goal ?? ''), g = v.proven && v.checked ? undefined : cubes.find(c => at.startsWith(`${textOf(c)} @`));
|
|
3990
|
-
opts.progress?.('join set', { cubes: cubes.length, exists: ghost ? 1 : 0, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(
|
|
4041
|
+
opts.progress?.('join set', { cubes: cubes.length, exists: ghost ? 1 : 0, proven: v.proven && v.checked ? 1 : 0, ms: Math.round(vnow() - t2), at: at.slice(0, 120) });
|
|
3991
4042
|
if (v.proven && v.checked) {
|
|
3992
4043
|
why = 'inductive';
|
|
3993
4044
|
cone = cubes;
|
|
@@ -4279,7 +4330,7 @@ function inferLawsSearch(target, laws, stepLaws = [], opts = {}) {
|
|
|
4279
4330
|
// (a rule whose scalars the runs held at a few values each: no counter, the engine's shape)
|
|
4280
4331
|
if (engineFollows() && why !== 'inductive')
|
|
4281
4332
|
engine();
|
|
4282
|
-
opts.progress?.('join end', { rounds, set: set.length, why, cone: cone.length, ms: Math.round(performance.now() - jT0) });
|
|
4333
|
+
opts.progress?.('join end', { rounds, set: set.length, why, cone: cone.length, ms: Math.round(performance.now() - jT0), ...meters() });
|
|
4283
4334
|
// (unproven, the search below begins as it would have: the candidates and the counterexamples as they were)
|
|
4284
4335
|
if (why === 'inductive')
|
|
4285
4336
|
chosen = cone;
|