gdp-wired 0.25.0 → 0.26.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 +14 -9
- package/dist/core/accel.d.ts +1 -1
- package/dist/core/accel.js +336 -101
- package/dist/core/bmc.d.ts +8 -0
- package/dist/core/bmc.js +263 -97
- package/dist/core/cycles.d.ts +2 -3
- package/dist/core/cycles.js +35 -131
- package/dist/core/cyclic.d.ts +4 -1
- package/dist/core/cyclic.js +86 -64
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +89 -118
- package/dist/core/discover.js +2 -3
- package/dist/core/dsl.d.ts +3 -2
- package/dist/core/dsl.js +21 -18
- package/dist/core/exists.js +7 -14
- package/dist/core/extract-check.d.ts +3 -2
- package/dist/core/extract-check.js +137 -50
- package/dist/core/extract-print.d.ts +1 -0
- package/dist/core/extract-print.js +26 -3
- package/dist/core/extract-read.d.ts +85 -4
- package/dist/core/extract-read.js +295 -34
- package/dist/core/extract-shapes.d.ts +14 -0
- package/dist/core/extract-shapes.js +608 -78
- package/dist/core/extract-xstate.d.ts +5 -1
- package/dist/core/extract-xstate.js +618 -184
- package/dist/core/extract.js +73 -27
- package/dist/core/infer.js +72 -18
- package/dist/core/machine.d.ts +6 -0
- package/dist/core/machine.js +35 -3
- package/dist/core/nonterm.d.ts +5 -1
- package/dist/core/nonterm.js +109 -41
- package/dist/core/q.d.ts +1 -0
- package/dist/core/q.js +2 -2
- package/dist/core/relation.d.ts +1 -0
- package/dist/core/relation.js +20 -36
- package/dist/core/solver.d.ts +12 -0
- package/dist/core/solver.js +76 -30
- package/dist/core/transfer.js +22 -13
- package/dist/core/translate.d.ts +1 -1
- package/dist/core/translate.js +22 -49
- package/dist/core/xstate.d.ts +6 -1
- package/dist/core/xstate.js +336 -55
- package/dist/kernel/cdcl.js +1 -2
- package/dist/kernel/prove.d.ts +6 -1
- package/dist/kernel/prove.js +96 -82
- package/dist/kernel/reader.d.ts +1 -0
- package/dist/kernel/reader.js +4 -3
- package/dist/kernel/simplex.d.ts +1 -1
- package/dist/kernel/simplex.js +13 -1
- package/package.json +3 -2
package/dist/core/translate.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// A usual proof's tree made a cyclic node's. Untrusted: kernel/cyclic.ts checks the proof it ends in.
|
|
2
|
+
//
|
|
3
|
+
// An instance's node after a step (core/cyclic.ts: a machine's law after a step from t − 1, a recurrence's lemma after
|
|
4
|
+
// a step to x, a fold's law from a node's children) is the usual rule's step goal read over the instance's cells: each
|
|
5
|
+
// state variable s as s@[t − 1], each map's cell M[k] as M@[(t − 1) + k·Ω], a fresh key k# as the node's own k. Its
|
|
6
|
+
// goal is built so that it holds every hypothesis of that goal read so (and more: the run's bounds, the naturals), and
|
|
7
|
+
// the usual goal's tree is then read over it: each column of the usual goal (a variable, a cell, a term column, a
|
|
8
|
+
// monomial) is a linear form of the node's goal (`renamer`), each split the renamed split, each leaf's rows found again
|
|
9
|
+
// among the node's rows at the renamed path. A leaf whose rows aren't all there (two cells the path proves equal, whose
|
|
10
|
+
// keys over Ω the node's path doesn't yet compare) is grown again on the node's goal at its path (`regrown`); a split the
|
|
11
|
+
// node's path already decides is followed, not made again.
|
|
12
|
+
import { walk } from "./machine.js";
|
|
13
|
+
import { add, env, refuteFast, scale, solve } from "./solver.js";
|
|
2
14
|
import { checkRefutation } from "./check.js";
|
|
3
15
|
import { canon, canonFlip, columnTerm, factorsOf, isCell, isMonomial, leafConstraintsReusing, linear, substE, truth, withProducts } from "../kernel/kernel.js";
|
|
4
|
-
import { cellProducts, clock, grow } from "../kernel/prove.js";
|
|
16
|
+
import { cellProducts, clock, grow, parseKey } from "../kernel/prove.js";
|
|
17
|
+
import { times } from "../kernel/reader.js";
|
|
5
18
|
const omega = 'O$';
|
|
6
|
-
const debugOn = () => !!
|
|
7
|
-
// The kernel's product of two linear forms (kernel.ts's `times`): each monomial its factors sorted, joined by '*'.
|
|
8
|
-
function times(a, b) {
|
|
9
|
-
const out = [];
|
|
10
|
-
for (const [p, cp] of Object.entries(a))
|
|
11
|
-
for (const [q, cq] of Object.entries(b)) {
|
|
12
|
-
if (p.includes('⟦') || q.includes('⟦'))
|
|
13
|
-
return undefined;
|
|
14
|
-
const fs = [...(p === '1' ? [] : factorsOf(p)), ...(q === '1' ? [] : factorsOf(q))].sort();
|
|
15
|
-
out.push({ [fs.length ? fs.join('*') : '1']: cp * cq });
|
|
16
|
-
}
|
|
17
|
-
return add(...out);
|
|
18
|
-
}
|
|
19
|
+
const debugOn = () => !!env.GDP_CYCLIC_DEBUG;
|
|
19
20
|
// A cell's key, from its name (`M[key]`, the key's canonical text, whose names may be cells themselves).
|
|
20
|
-
|
|
21
|
-
const text = cell.slice(cell.indexOf('[') + 1, -1), out = {};
|
|
22
|
-
let depth = 0, start = 0;
|
|
23
|
-
for (let i = 0; i <= text.length; i++) {
|
|
24
|
-
const ch = text[i];
|
|
25
|
-
if (ch === '[')
|
|
26
|
-
depth++;
|
|
27
|
-
else if (ch === ']')
|
|
28
|
-
depth--;
|
|
29
|
-
else if ((ch === ',' && depth === 0) || i === text.length) {
|
|
30
|
-
if (i > start) {
|
|
31
|
-
const part = text.slice(start, i), at = part.lastIndexOf(':');
|
|
32
|
-
out[part.slice(0, at)] = Number(part.slice(at + 1));
|
|
33
|
-
}
|
|
34
|
-
start = i + 1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
21
|
+
const keyOf = (cell) => parseKey(cell.slice(cell.indexOf('[') + 1, -1));
|
|
39
22
|
export function renamer(r) {
|
|
40
23
|
const terms = new Map(), memo = new WeakMap(), cells = r.cells ?? {};
|
|
41
24
|
const col = (name, wp) => {
|
|
@@ -391,19 +374,14 @@ function choiceAtom(g, wp) {
|
|
|
391
374
|
// The cells of the conclusion refuted at the path (reads it gives no rows of yet among them).
|
|
392
375
|
function conclCells(g, wp) {
|
|
393
376
|
const out = [];
|
|
394
|
-
|
|
395
|
-
if (!x || typeof x !== 'object')
|
|
396
|
-
return;
|
|
377
|
+
walk(g.hyps.at(-1), x => {
|
|
397
378
|
const o = x;
|
|
398
379
|
if (o.op === 'get' && o.map.endsWith('@')) {
|
|
399
380
|
const l = linear(o, wp);
|
|
400
381
|
if (l)
|
|
401
382
|
out.push(...Object.keys(l));
|
|
402
383
|
}
|
|
403
|
-
|
|
404
|
-
walk(val);
|
|
405
|
-
};
|
|
406
|
-
walk(g.hyps.at(-1));
|
|
384
|
+
});
|
|
407
385
|
return out;
|
|
408
386
|
}
|
|
409
387
|
// Two cells over time at keys u + a·Ω and u + b·Ω: a = b decided first, then the keys' difference, its other side
|
|
@@ -452,7 +430,7 @@ export function close(g, wp, st, until) {
|
|
|
452
430
|
return y && n ? { split: next, yes: y, no: n } : undefined;
|
|
453
431
|
}
|
|
454
432
|
st.regrown++;
|
|
455
|
-
if (
|
|
433
|
+
if (env.GDP_CYCLIC_DEBUG)
|
|
456
434
|
console.error(`[close] ${g.name}: grown again at ${[...wp.values()].map(a => `${JSON.stringify(a.lin)} ${a.holds}`).join('; ')}`);
|
|
457
435
|
return regrow(g, wp, until);
|
|
458
436
|
}
|
|
@@ -487,18 +465,13 @@ export function carry(g, nFacts, nUses, st, until) {
|
|
|
487
465
|
// The times before (t ∸ 1, x ∸ 1, y ∸ 1, each a choice until c <= v is decided), decided after the guards: then the
|
|
488
466
|
// cells at t − 1 and at (t − 1) + 1 are the same reads.
|
|
489
467
|
const prev = [], seenPrev = new Set();
|
|
490
|
-
|
|
491
|
-
if (!x || typeof x !== 'object')
|
|
492
|
-
return;
|
|
468
|
+
walk(g.hyps, x => {
|
|
493
469
|
const o = x;
|
|
494
470
|
if (o.op === 'sub' && o.a.op === 'var' && o.b.op === 'const' && !seenPrev.has(`${o.a.name}-${o.b.value}`)) {
|
|
495
471
|
seenPrev.add(`${o.a.name}-${o.b.value}`);
|
|
496
472
|
prev.push({ op: '<=', a: o.b, b: o.a });
|
|
497
473
|
}
|
|
498
|
-
|
|
499
|
-
walk(val);
|
|
500
|
-
};
|
|
501
|
-
walk(g.hyps);
|
|
474
|
+
});
|
|
502
475
|
const guardsIn = (c, wp, out) => {
|
|
503
476
|
if (c.op === 'and') {
|
|
504
477
|
for (const x of c.xs)
|
package/dist/core/xstate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Kind,
|
|
1
|
+
import { type Kind, Cond } from './dsl.js';
|
|
2
2
|
import { type Chart } from './chart.js';
|
|
3
3
|
type Obj = Record<string, any>;
|
|
4
4
|
type XAction = string | {
|
|
@@ -47,9 +47,11 @@ export type Bridge = {
|
|
|
47
47
|
guards?: ReadonlyMap<unknown, Guard>;
|
|
48
48
|
actions?: ReadonlyMap<unknown, Action>;
|
|
49
49
|
};
|
|
50
|
+
ignore?: string[];
|
|
50
51
|
};
|
|
51
52
|
export type MachineLike = object;
|
|
52
53
|
export declare function fromXState(machine: MachineLike, opts?: Bridge): Chart<Obj, Obj, Obj>;
|
|
54
|
+
export declare function eventsOf(machine: MachineLike): string[];
|
|
53
55
|
export type XActor = {
|
|
54
56
|
send: (e: never) => void;
|
|
55
57
|
getSnapshot: () => {
|
|
@@ -65,6 +67,9 @@ export declare function conforms(c: Chart<Obj, Obj, Obj>, machine: MachineLike,
|
|
|
65
67
|
seed?: number;
|
|
66
68
|
params?: Obj;
|
|
67
69
|
payload?: (event: string, rand: (n: number) => number) => Obj;
|
|
70
|
+
beforeSend?: (event: string, payload: Obj) => void;
|
|
71
|
+
context?: string[];
|
|
72
|
+
event?: (type: string, payload: Obj) => Obj;
|
|
68
73
|
}): {
|
|
69
74
|
checked: number;
|
|
70
75
|
failure?: string;
|