gdp-wired 0.12.1 → 0.12.2
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/dist/core/solver.js +8 -2
- package/dist/kernel/kernel.js +1 -1
- package/dist/kernel/prove.js +13 -3
- package/dist/lean-kernel/library.js +2 -2
- package/package.json +1 -1
package/dist/core/solver.js
CHANGED
|
@@ -100,7 +100,12 @@ export function solve(constraints, maxRows = 20_000) {
|
|
|
100
100
|
const neg = byKey.get(negKey(r));
|
|
101
101
|
if (neg === undefined || neg === r)
|
|
102
102
|
continue;
|
|
103
|
-
|
|
103
|
+
let x;
|
|
104
|
+
for (const name in lins[r])
|
|
105
|
+
if (name !== '1' && Math.abs(lins[r][name]) === 1) {
|
|
106
|
+
x = name;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
104
109
|
if (x === undefined)
|
|
105
110
|
continue;
|
|
106
111
|
// up: the row of the pair with +x, down: with −x.
|
|
@@ -139,9 +144,10 @@ export function solve(constraints, maxRows = 20_000) {
|
|
|
139
144
|
// Each variable's rows by sign, in one pass (variables in the order they first appear).
|
|
140
145
|
const index = new Map();
|
|
141
146
|
for (const r of rows)
|
|
142
|
-
for (const
|
|
147
|
+
for (const x in lins[r]) {
|
|
143
148
|
if (x === '1')
|
|
144
149
|
continue;
|
|
150
|
+
const c = lins[r][x];
|
|
145
151
|
let e = index.get(x);
|
|
146
152
|
if (!e)
|
|
147
153
|
index.set(x, (e = { pos: [], neg: [], posUnit: true, negUnit: true }));
|
package/dist/kernel/kernel.js
CHANGED
|
@@ -1120,7 +1120,7 @@ export function stepLawObligations(machine, laws, instances, sl) {
|
|
|
1120
1120
|
const m = machine.history ? historyMachine(machine).machine : machine;
|
|
1121
1121
|
scope(m, laws);
|
|
1122
1122
|
const k = sl.steps ?? 1;
|
|
1123
|
-
// Past 64 the cost is the bound (proving grows about as k³: 64 steps in about
|
|
1123
|
+
// Past 64 the cost is the bound (proving grows about as k³: 64 steps in about 5 s on Modal; Lean checks 32 in about 14 s, 64 in about 47 s).
|
|
1124
1124
|
if (!Number.isInteger(k) || k < 1 || k > 64)
|
|
1125
1125
|
throw new Error(`step law ${sl.name}: steps is a whole number from 1 to 64`);
|
|
1126
1126
|
const whens = sl.when === undefined ? [] : Array.isArray(sl.when) ? sl.when : [sl.when];
|
package/dist/kernel/prove.js
CHANGED
|
@@ -412,15 +412,25 @@ function growFocused(goal, path, focus, budget, near = focus) {
|
|
|
412
412
|
}
|
|
413
413
|
// A refutation from the rows near some facts (the rows reachable from their variables in two hops, each row joining the
|
|
414
414
|
// variables it reads), its inputs renumbered to the whole leaf's. A cut about one step of a long run needs that step's
|
|
415
|
-
// rows, not the run's; a cut it misses is only a cut not made (the plain search still follows).
|
|
415
|
+
// rows, not the run's; a cut it misses is only a cut not made (the plain search still follows). A variable most rows
|
|
416
|
+
// read (a param every step reads) joins no rows: through it every step is near every other.
|
|
416
417
|
function solveNear(rows, seeds) {
|
|
418
|
+
const uses = new Map();
|
|
419
|
+
for (const r of rows)
|
|
420
|
+
for (const key in r.lin)
|
|
421
|
+
if (key !== '1')
|
|
422
|
+
uses.set(key, (uses.get(key) ?? 0) + 1);
|
|
423
|
+
const hub = (key) => (uses.get(key) ?? 0) > Math.max(16, rows.length / 8);
|
|
417
424
|
const reach = new Set(seeds.flatMap(l => Object.keys(l).filter(key => key !== '1')));
|
|
418
|
-
for (let hop = 0; hop < 2; hop++)
|
|
425
|
+
for (let hop = 0; hop < 2; hop++) {
|
|
426
|
+
// One hop: the rows reading what was reached before it (not what this hop adds, or one pass runs along the run).
|
|
427
|
+
const from = new Set(reach);
|
|
419
428
|
for (const r of rows) {
|
|
420
429
|
const keys = Object.keys(r.lin).filter(key => key !== '1');
|
|
421
|
-
if (keys.some(key =>
|
|
430
|
+
if (keys.some(key => from.has(key) && !hub(key)))
|
|
422
431
|
keys.forEach(key => reach.add(key));
|
|
423
432
|
}
|
|
433
|
+
}
|
|
424
434
|
const picked = rows.flatMap((r, i) => (Object.keys(r.lin).every(key => key === '1' || reach.has(key)) ? [i] : []));
|
|
425
435
|
const near = solve(picked.map(i => rows[i]));
|
|
426
436
|
return near.kind === 'refuted' ? { kind: 'refuted', steps: near.steps.map(st => (st.kind === 'input' ? { ...st, index: picked[st.index] } : st)) } : near;
|