gdp-wired 0.53.2 → 0.54.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 +7 -4
- package/dist/core/candidate-seeds.d.ts +5 -2
- package/dist/core/candidate-seeds.js +5 -3
- package/dist/core/covering.d.ts +14 -0
- package/dist/core/covering.js +269 -0
- package/dist/core/dsl.d.ts +1 -0
- package/dist/core/dsl.js +89 -3
- package/dist/core/effect.d.ts +1 -1
- package/dist/core/effect.js +1 -1
- package/dist/core/extract-c.d.ts +1 -1
- package/dist/core/extract-c.js +1 -1
- package/dist/core/extract-ex.d.ts +1 -1
- package/dist/core/extract-ex.js +1 -1
- package/dist/core/extract-go.d.ts +1 -1
- package/dist/core/extract-go.js +1 -1
- package/dist/core/extract-jvm.d.ts +1 -1
- package/dist/core/extract-jvm.js +1 -1
- package/dist/core/extract-py.d.ts +1 -1
- package/dist/core/extract-py.js +1 -1
- package/dist/core/extract-rb.d.ts +1 -1
- package/dist/core/extract-rb.js +1 -1
- package/dist/core/extract-rs.d.ts +1 -1
- package/dist/core/extract-rs.js +1 -1
- package/dist/core/extract-sol.d.ts +1 -1
- package/dist/core/extract-sol.js +1 -1
- package/dist/core/extract-swift.d.ts +1 -1
- package/dist/core/extract-swift.js +1 -1
- package/dist/core/extract.d.ts +1 -1
- package/dist/core/extract.js +1 -1
- package/dist/core/infer.js +144 -28
- package/dist/core/minimize.d.ts +32 -0
- package/dist/core/minimize.js +319 -0
- package/dist/core/unguard-seeds.d.ts +7 -0
- package/dist/core/unguard-seeds.js +138 -0
- package/docs/minimize.md +79 -0
- package/package.json +6 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Extraction } from './extract.js';
|
|
2
2
|
import { type FileURL } from './extract-read.js';
|
|
3
3
|
import { type SModule, type StepOptions, type StepRead } from './extract-step.js';
|
|
4
|
-
export { proveRule, proveSteps } from './dsl.js';
|
|
4
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from './dsl.js';
|
|
5
5
|
export type RbOptions = StepOptions & {
|
|
6
6
|
root?: string;
|
|
7
7
|
ruby?: string;
|
package/dist/core/extract-rb.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Refusal, pathOf, readerRun, statedRefusal } from "./extract-read.js";
|
|
2
2
|
import { asset, entryNames, extractStep, node } from "./extract-step.js";
|
|
3
|
-
export { proveRule, proveSteps } from "./dsl.js";
|
|
3
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from "./dsl.js";
|
|
4
4
|
const here = (f) => asset(`rb/${f}`);
|
|
5
5
|
// The file as the reader lowers it (the class named).
|
|
6
6
|
export function readRuby(file, names, opts = {}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Extraction } from './extract.js';
|
|
2
2
|
import { type FileURL } from './extract-read.js';
|
|
3
3
|
import { type SModule, type StepOptions, type StepRead } from './extract-step.js';
|
|
4
|
-
export { proveRule, proveSteps } from './dsl.js';
|
|
4
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from './dsl.js';
|
|
5
5
|
export type RsOptions = StepOptions & {
|
|
6
6
|
cargo?: string;
|
|
7
7
|
};
|
package/dist/core/extract-rs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Refusal, pathOf, readerRun, statedRefusal } from "./extract-read.js";
|
|
2
2
|
import { asset, buildCheck, compileLimit, entryNames, extractStep, node, stubbed } from "./extract-step.js";
|
|
3
|
-
export { proveRule, proveSteps } from "./dsl.js";
|
|
3
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from "./dsl.js";
|
|
4
4
|
const proc = globalThis.process;
|
|
5
5
|
// The reader, built once per version of its source (into the system's temporary directory).
|
|
6
6
|
export function rsReader(cargo = 'cargo') {
|
|
@@ -3,7 +3,7 @@ import { type FileURL } from './extract-read.js';
|
|
|
3
3
|
import { type SolidityHarness } from './sol-concrete.js';
|
|
4
4
|
export type { SolidityHarness } from './sol-concrete.js';
|
|
5
5
|
import { type SModule, type SType, type StepOptions, type StepRead } from './extract-step.js';
|
|
6
|
-
export { proveRule, proveSteps } from './dsl.js';
|
|
6
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from './dsl.js';
|
|
7
7
|
export type SolOptions = StepOptions & {
|
|
8
8
|
root?: string;
|
|
9
9
|
remappings?: string[];
|
package/dist/core/extract-sol.js
CHANGED
|
@@ -32,7 +32,7 @@ import { Refusal, pathOf, readerRun, statedRefusal } from "./extract-read.js";
|
|
|
32
32
|
import { concreteSolidity, SolidityHarnessRefusal } from "./sol-concrete.js";
|
|
33
33
|
const refuse = (where, what) => { throw new Refusal(where, what); };
|
|
34
34
|
import { asset, checkStep, node, readStep, stepNames } from "./extract-step.js";
|
|
35
|
-
export { proveRule, proveSteps } from "./dsl.js";
|
|
35
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from "./dsl.js";
|
|
36
36
|
export const MOD = 'W256$';
|
|
37
37
|
// (the width the check runs the rule at: past 2^256's half the code's values are the rule's near W)
|
|
38
38
|
const CHECK_W = 2 ** 52;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Extraction } from './extract.js';
|
|
2
2
|
import { type FileURL } from './extract-read.js';
|
|
3
3
|
import { type PArg, type SModule, type StepOptions, type StepRead } from './extract-step.js';
|
|
4
|
-
export { proveRule, proveSteps } from './dsl.js';
|
|
4
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from './dsl.js';
|
|
5
5
|
export type SwiftOptions = StepOptions & {
|
|
6
6
|
swift?: string;
|
|
7
7
|
ctor?: number | string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Refusal, pathOf, readerRun, statedRefusal } from "./extract-read.js";
|
|
2
2
|
import { asset, buildCheck, compileLimit, entryNames, extractStep, node, stubbed } from "./extract-step.js";
|
|
3
|
-
export { proveRule, proveSteps } from "./dsl.js";
|
|
3
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from "./dsl.js";
|
|
4
4
|
const env = () => globalThis.process?.env ?? {};
|
|
5
5
|
const errText = (e) => { const ls = `${e.stdout ?? ''}\n${e.stderr ?? ''}`.split('\n'); return (ls.filter(l => /\berror:/.test(l)).length ? ls.filter(l => /\berror:/.test(l)) : ls.filter(l => /error|fatal/i.test(l))).slice(0, 4).join(' | ').slice(0, 900) || String(e.message).slice(0, 300); };
|
|
6
6
|
const hash = (s) => node('node:crypto').createHash('sha256').update(s).digest('hex').slice(0, 16);
|
package/dist/core/extract.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Sorts } from './extract-print.js';
|
|
|
6
6
|
import { type CheckOptions, type Evidence } from './extract-check.js';
|
|
7
7
|
import { type OrmOptions } from './extract-orm.js';
|
|
8
8
|
export type { OrmOptions } from './extract-orm.js';
|
|
9
|
-
export { proveRule, proveSteps } from './dsl.js';
|
|
9
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from './dsl.js';
|
|
10
10
|
export type ExtractOptions = Omit<ReadOptions, 'entry' | 'functions'> & {
|
|
11
11
|
entry?: string | string[];
|
|
12
12
|
/** @deprecated entry: [...] (the same: several functions over one record, the entry the first) */
|
package/dist/core/extract.js
CHANGED
|
@@ -48,7 +48,7 @@ import { kindOf, mapEmpty, mapKind, natOK, pb, pidx, pk, pnum, pterm, sortsOf }
|
|
|
48
48
|
import { check } from "./extract-check.js";
|
|
49
49
|
import { extractOrm } from "./extract-orm.js";
|
|
50
50
|
// (a rule read is proven from the same import: proveRule(x.rule!, [x.rule!.law(...)]))
|
|
51
|
-
export { proveRule, proveSteps } from "./dsl.js";
|
|
51
|
+
export { minimizeRun, minimizeRunDetailed, proveRule, proveSteps } from "./dsl.js";
|
|
52
52
|
// The names of a model read from TypeScript (the state's layout, each request's arguments, each method's result).
|
|
53
53
|
export function namesOf(m) {
|
|
54
54
|
const out = [], fields = (n) => m.maps.find(d => d.name === n)?.fields.map(f => f.name) ?? [];
|
package/dist/core/infer.js
CHANGED
|
@@ -54,6 +54,28 @@ import { REFUTED, growCdcl } from "../kernel/cdcl.js";
|
|
|
54
54
|
import { eprMeter, withEprCap } from "../kernel/epr.js";
|
|
55
55
|
// a value outside a guard's (or a control value's) values
|
|
56
56
|
const off = (g, v) => v < g.value || v > (g.hi ?? g.value);
|
|
57
|
+
// A shape's value at each of the first N rows, Σ c·v summed in the shape's order from 0, into `col`; the largest of them
|
|
58
|
+
// (-Infinity of none). A function of its own: inferLawsSearchIn's body is too long for the optimizing compilers, and
|
|
59
|
+
// this loop over every shape and row is the candidates' cost.
|
|
60
|
+
function shapeColumn(coef, vals, N, col) {
|
|
61
|
+
const n = coef.length, c0 = n ? coef[0][1] : 0, v0 = n ? vals[coef[0][0]] : undefined, c1 = n > 1 ? coef[1][1] : 0, v1 = n > 1 ? vals[coef[1][0]] : undefined;
|
|
62
|
+
let d = -Infinity;
|
|
63
|
+
for (let j = 0; j < N; j++) {
|
|
64
|
+
observeCubeTest();
|
|
65
|
+
let s = 0;
|
|
66
|
+
if (n)
|
|
67
|
+
s += c0 * v0[j];
|
|
68
|
+
if (n > 1)
|
|
69
|
+
s += c1 * v1[j];
|
|
70
|
+
for (let q = 2; q < n; q++) {
|
|
71
|
+
const t = coef[q];
|
|
72
|
+
s += t[1] * vals[t[0]][j];
|
|
73
|
+
}
|
|
74
|
+
col[j] = s;
|
|
75
|
+
d = Math.max(d, s);
|
|
76
|
+
}
|
|
77
|
+
return d;
|
|
78
|
+
}
|
|
57
79
|
const KEY = 'key$found', KEY2 = 'key2$found', AT = '@', K = '#', SOME = 'k$found';
|
|
58
80
|
// The counted clock's rates, units a millisecond: about the slowest tenth of what Modal's 1-vCPU containers do in each
|
|
59
81
|
// phase (`runs/modal/infer/after2`, GDP_INFER_TRACE=1: requests tried 85 a ms, rows 13,093, forms evaluated 11,240, the
|
|
@@ -1529,8 +1551,10 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1529
1551
|
const forms = [];
|
|
1530
1552
|
candidateCount = () => forms.length;
|
|
1531
1553
|
const NS = rowsS.length, NK = rowsK.length;
|
|
1532
|
-
const at = (coef, vals, j) => { observeCubeTest(); let s = 0; for (
|
|
1533
|
-
|
|
1554
|
+
const at = (coef, vals, j) => { observeCubeTest(); let s = 0; for (let q = 0; q < coef.length; q++) {
|
|
1555
|
+
const t = coef[q];
|
|
1556
|
+
s += t[1] * vals[t[0]][j];
|
|
1557
|
+
} return s; };
|
|
1534
1558
|
const keyNots = plain.filter(i => !atoms[i].param && !atoms[i].int && !atoms[i].term);
|
|
1535
1559
|
// The guards: the choices first, then yes/nos, then small naturals, at most eight; each shape's largest value per
|
|
1536
1560
|
// guard in one pass over (at most 3,000 of) the rows: with each state kept once a stride skips states, not copies, and a
|
|
@@ -1538,15 +1562,42 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1538
1562
|
// a quarter of the time.
|
|
1539
1563
|
const guards = [...modes].sort((p, q) => Number(!!q.choice) - Number(!!p.choice) || Number(!!q.bool) - Number(!!p.bool)).slice(0, 8);
|
|
1540
1564
|
const strideS = Math.max(1, Math.ceil(NS / 3000)), strideK = Math.max(1, Math.ceil(NK / 3000));
|
|
1565
|
+
const colS = new Float64Array(NS), colK = new Float64Array(NK);
|
|
1566
|
+
// Each guard's largest value of a shape, by the guard's value: b[v] = max(b[v] ?? -Infinity, value) at every row, as a map
|
|
1567
|
+
// filled in the rows' order would hold it. A guard's values are mostly small naturals, so those are kept in a table (64
|
|
1568
|
+
// a guard and kind: `slot` is 2g for every row, 2g + 1 for the written ones) with the order each was first met, any
|
|
1569
|
+
// other value in a map beside it; `filled` then writes the map itself, each value at its first row's place.
|
|
1570
|
+
const SMALL = 64, tableMax = new Float64Array(guards.length * 2 * SMALL), tableSeen = new Uint8Array(guards.length * 2 * SMALL);
|
|
1571
|
+
const small = (v) => v >= 0 && v < SMALL && Number.isInteger(v);
|
|
1572
|
+
let firsts = [], others = [];
|
|
1573
|
+
const raise = (slot, v, value) => {
|
|
1574
|
+
if (small(v)) {
|
|
1575
|
+
const cell = slot * SMALL + v;
|
|
1576
|
+
if (tableSeen[cell])
|
|
1577
|
+
tableMax[cell] = Math.max(tableMax[cell], value);
|
|
1578
|
+
else {
|
|
1579
|
+
tableSeen[cell] = 1;
|
|
1580
|
+
tableMax[cell] = Math.max(-Infinity, value);
|
|
1581
|
+
firsts[slot].push(v);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
else {
|
|
1585
|
+
const other = others[slot] ?? (others[slot] = new Map()), old = other.get(v);
|
|
1586
|
+
if (old === undefined)
|
|
1587
|
+
firsts[slot].push(v);
|
|
1588
|
+
other.set(v, Math.max(old ?? -Infinity, value));
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
const filled = (b, slot) => { for (const v of firsts[slot])
|
|
1592
|
+
b.set(v, small(v) ? tableMax[slot * SMALL + v] : others[slot].get(v)); };
|
|
1541
1593
|
const buildUntil = opts.cubes ? 0 : Math.min(until, now() + (until - now()) / 4);
|
|
1542
1594
|
for (const [n_, { coef, cells }] of shapes.entries()) {
|
|
1543
1595
|
if (forms.length > maxCandidates || (n_ % 256 === 0 && (now() > buildUntil || stop())))
|
|
1544
1596
|
break;
|
|
1545
1597
|
const vals = cells ? valsK : valsS, N = cells ? NK : NS, rows = cells ? rowsK : rowsS;
|
|
1546
1598
|
used.rows += N + (coef.length > 2 ? 0 : Math.ceil(N / (cells ? strideK : strideS)));
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
d = Math.max(d, at(coef, vals, j));
|
|
1599
|
+
// (the shape's value at each row, kept for the guards' pass below)
|
|
1600
|
+
const col = cells ? colK : colS, d = shapeColumn(coef, vals, N, col);
|
|
1550
1601
|
if (!Number.isFinite(d))
|
|
1551
1602
|
continue;
|
|
1552
1603
|
forms.push({ coef, d, cells, size: sizeOf(coef) + (cells ? 10 : 0) });
|
|
@@ -1564,19 +1615,35 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1564
1615
|
const most = here.map(() => new Map()), away = cells ? keyNots.map(() => -Infinity) : [];
|
|
1565
1616
|
const mostW = here.map(() => new Map()), awayW = keyNots.map(() => -Infinity);
|
|
1566
1617
|
let written = -Infinity;
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1618
|
+
tableSeen.fill(0);
|
|
1619
|
+
firsts = here.flatMap(() => [[], []]);
|
|
1620
|
+
others = [];
|
|
1621
|
+
// (the pass as a function of its own, for the optimizing compilers: see shapeColumn)
|
|
1622
|
+
const guardPass = () => {
|
|
1623
|
+
for (let j = 0; j < N; j += cells ? strideK : strideS) {
|
|
1624
|
+
observeCubeTest();
|
|
1625
|
+
const value = col[j], wj = w >= 0 && vals[w][j] >= 1;
|
|
1626
|
+
if (wj)
|
|
1627
|
+
written = Math.max(written, value);
|
|
1628
|
+
for (let g = 0; g < here.length; g++) {
|
|
1629
|
+
const v = vals[here[g].atom][j];
|
|
1630
|
+
raise(2 * g, v, value);
|
|
1577
1631
|
if (wj)
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1632
|
+
raise(2 * g + 1, v, value);
|
|
1633
|
+
}
|
|
1634
|
+
// At every key but a scalar's: the largest value away from that key.
|
|
1635
|
+
if (cells)
|
|
1636
|
+
keyNots.forEach((s, g) => { if (rows[j][K] !== valsK[s][j]) {
|
|
1637
|
+
away[g] = Math.max(away[g], value);
|
|
1638
|
+
if (wj)
|
|
1639
|
+
awayW[g] = Math.max(awayW[g], value);
|
|
1640
|
+
} });
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
guardPass();
|
|
1644
|
+
for (let g = 0; g < here.length; g++) {
|
|
1645
|
+
filled(most[g], 2 * g);
|
|
1646
|
+
filled(mostW[g], 2 * g + 1);
|
|
1580
1647
|
}
|
|
1581
1648
|
// (a cell a param apart from a scalar: its guards only where it was written, below)
|
|
1582
1649
|
if (coef.length <= 2) {
|
|
@@ -1846,7 +1913,17 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1846
1913
|
const valuesAt = new WeakMap();
|
|
1847
1914
|
const atomsByField = new Map();
|
|
1848
1915
|
let indexedAtoms = 0;
|
|
1916
|
+
// (the last row's values are asked for again by the next form: one comparison in place of a lookup)
|
|
1917
|
+
let lastEnv, lastValues;
|
|
1849
1918
|
const valuesOf = (env) => {
|
|
1919
|
+
if (env === lastEnv)
|
|
1920
|
+
return lastValues;
|
|
1921
|
+
const vs = valuesOf0(env);
|
|
1922
|
+
lastEnv = env;
|
|
1923
|
+
lastValues = vs;
|
|
1924
|
+
return vs;
|
|
1925
|
+
};
|
|
1926
|
+
const valuesOf0 = (env) => {
|
|
1850
1927
|
let vs = valuesAt.get(env);
|
|
1851
1928
|
if (!vs) {
|
|
1852
1929
|
// Before any view columns exist the original dense scan is cheaper.
|
|
@@ -1879,7 +1956,9 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1879
1956
|
const holdsRow = (f, env) => {
|
|
1880
1957
|
observeCubeTest();
|
|
1881
1958
|
used.evals++;
|
|
1882
|
-
|
|
1959
|
+
return holdsValues(f, env, valuesOf(env));
|
|
1960
|
+
};
|
|
1961
|
+
const holdsValues = (f, env, vs) => {
|
|
1883
1962
|
if (f.never)
|
|
1884
1963
|
return f.never.some(g => off(g, vs[g.atom]));
|
|
1885
1964
|
if (f.nevers)
|
|
@@ -1913,15 +1992,47 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
1913
1992
|
return true;
|
|
1914
1993
|
}
|
|
1915
1994
|
let s = 0;
|
|
1916
|
-
|
|
1917
|
-
|
|
1995
|
+
const coef = f.coef;
|
|
1996
|
+
for (let q = 0; q < coef.length; q++) {
|
|
1997
|
+
const t = coef[q];
|
|
1998
|
+
s += t[1] * vs[t[0]];
|
|
1999
|
+
}
|
|
1918
2000
|
return f.mod ? residue(s, f.mod.k) === f.mod.r : s <= f.d;
|
|
1919
2001
|
};
|
|
2002
|
+
const noRows = [];
|
|
1920
2003
|
const pointOf = (params, st) => ({ scalar: withTerms({ ...params, ...st.scalars }, st), cells: cellRows(params, st), views: views.map(v => v.rowsOf(params, st)) });
|
|
1921
2004
|
// (the atoms a form reads)
|
|
1922
2005
|
const atomsIn = (f) => [...f.coef.map(([i]) => i), ...(f.guard && 'atom' in f.guard ? [f.guard.atom] : []), ...(f.also ?? []).map(a => a.atom), ...(f.never ?? []).map(a => a.atom), ...(f.unreachable ? [f.unreachable.atom] : []), ...(f.nevers ?? []).flat().map(a => a.atom), ...(f.cube ?? []).flatMap(l => ('at' in l ? [l.at.atom] : l.lin.coef.map(([i]) => i)))];
|
|
1923
|
-
const
|
|
1924
|
-
const
|
|
2006
|
+
const judgedBy = (f, u) => !u || !atomsIn(f).some(i => atoms[i].parts.some(([q]) => u.has(atoms[i].cell ? AT + q : q)));
|
|
2007
|
+
const judged = (f, r) => judgedBy(f, unnamed.get(r));
|
|
2008
|
+
const rowsMemo = new WeakMap();
|
|
2009
|
+
let lastRows, lastMemo;
|
|
2010
|
+
const holdsRows = (f, rows) => {
|
|
2011
|
+
const n = rows.length;
|
|
2012
|
+
if (!n)
|
|
2013
|
+
return true;
|
|
2014
|
+
let memo = rows === lastRows ? lastMemo : rowsMemo.get(rows);
|
|
2015
|
+
if (!memo)
|
|
2016
|
+
rowsMemo.set(rows, memo = { rows: [], unnamed: [], values: [] });
|
|
2017
|
+
lastRows = rows;
|
|
2018
|
+
lastMemo = memo;
|
|
2019
|
+
for (let j = 0; j < n; j++) {
|
|
2020
|
+
const r = rows[j];
|
|
2021
|
+
if (memo.rows[j] !== r) {
|
|
2022
|
+
memo.rows[j] = r;
|
|
2023
|
+
memo.unnamed[j] = unnamed.get(r);
|
|
2024
|
+
memo.values[j] = undefined;
|
|
2025
|
+
}
|
|
2026
|
+
if (!judgedBy(f, memo.unnamed[j]))
|
|
2027
|
+
continue;
|
|
2028
|
+
observeCubeTest();
|
|
2029
|
+
used.evals++;
|
|
2030
|
+
if (!holdsValues(f, r, memo.values[j] ?? (memo.values[j] = valuesOf(r))))
|
|
2031
|
+
return false;
|
|
2032
|
+
}
|
|
2033
|
+
return true;
|
|
2034
|
+
};
|
|
2035
|
+
const holdsAt = (f, p) => (f.view !== undefined ? holdsRows(f, p.views[f.view] ?? noRows) : f.cells ? holdsRows(f, p.cells) : holdsRow(f, p.scalar));
|
|
1925
2036
|
// A kernel witness as a point: its scalars, and a cell row per key it reads a map at.
|
|
1926
2037
|
const witnessPoint = (w) => {
|
|
1927
2038
|
const scalar = Object.fromEntries([...scalars, ...m.params].map(v => [v, w[v] ?? 0]));
|
|
@@ -2024,6 +2135,16 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
2024
2135
|
};
|
|
2025
2136
|
// (none on a rule of relations: its moves change a cell at a tuple's code, and its laws are read at every tuple of the
|
|
2026
2137
|
// codes a state holds, a power of them; the engine's small instance is where its samples are)
|
|
2138
|
+
// (the forms alive that a point breaks, each killed; a function of its own for the optimizing compilers: see shapeColumn)
|
|
2139
|
+
const breaks = (post, killed) => {
|
|
2140
|
+
let broke = false;
|
|
2141
|
+
for (const f of alive)
|
|
2142
|
+
if (!killed.has(f) && !holdsAt(f, post)) {
|
|
2143
|
+
killed.add(f);
|
|
2144
|
+
broke = true;
|
|
2145
|
+
}
|
|
2146
|
+
return broke;
|
|
2147
|
+
};
|
|
2027
2148
|
const houdiniUntil = opts.cubes || relStep ? 0 : Math.min(until, now() + Math.max(500, (until - now()) / 4));
|
|
2028
2149
|
for (let quiet = 0; samples.length && now() < houdiniUntil && !stop() && quiet < 3;) {
|
|
2029
2150
|
const killed = new Set();
|
|
@@ -2055,12 +2176,7 @@ function inferLawsSearchIn(target, laws, stepLaws, opts, observed) {
|
|
|
2055
2176
|
continue;
|
|
2056
2177
|
}
|
|
2057
2178
|
const post = pointOf(base.params, next);
|
|
2058
|
-
|
|
2059
|
-
for (const f of alive)
|
|
2060
|
-
if (!killed.has(f) && !holdsAt(f, post)) {
|
|
2061
|
-
killed.add(f);
|
|
2062
|
-
broke = true;
|
|
2063
|
-
}
|
|
2179
|
+
const broke = breaks(post, killed);
|
|
2064
2180
|
if (!broke && !lawful(base.params, next))
|
|
2065
2181
|
ctis.push(pre);
|
|
2066
2182
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Law, type Machine, type Request } from './machine.js';
|
|
2
|
+
import { type Watched } from './watch.js';
|
|
3
|
+
export type RunRequest = Record<string, unknown>;
|
|
4
|
+
export type RunTrace = {
|
|
5
|
+
params: Record<string, number>;
|
|
6
|
+
trace: readonly RunRequest[];
|
|
7
|
+
};
|
|
8
|
+
export type MinimizeOptions = {
|
|
9
|
+
ms?: number;
|
|
10
|
+
params?: Record<string, number>;
|
|
11
|
+
bound?: number;
|
|
12
|
+
shortest?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Minimized<R> = {
|
|
15
|
+
run: R;
|
|
16
|
+
minimal: boolean;
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
replays: number;
|
|
20
|
+
steps: number;
|
|
21
|
+
ms: number;
|
|
22
|
+
};
|
|
23
|
+
type RuleObject = {
|
|
24
|
+
machine: Machine;
|
|
25
|
+
encodeInput?: (input: never) => Request;
|
|
26
|
+
withSumsOf?: (...xs: unknown[]) => RuleObject;
|
|
27
|
+
withDivisors?: (...ks: number[]) => RuleObject;
|
|
28
|
+
};
|
|
29
|
+
type RuleLike = RuleObject | Machine;
|
|
30
|
+
export declare function minimizeRunDetailed<R extends RunTrace | readonly RunRequest[]>(rule: RuleLike, law: Watched, run: R, opts?: MinimizeOptions): Minimized<R>;
|
|
31
|
+
export declare function minimizeRun<R extends RunTrace | readonly RunRequest[]>(rule: RuleLike, law: Law | Watched, run: R, opts?: MinimizeOptions): R;
|
|
32
|
+
export {};
|