gdp-wired 0.21.0 → 0.22.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 +1 -1
- package/dist/core/cyclic.d.ts +6 -1
- package/dist/core/cyclic.js +13 -1
- package/dist/core/data.d.ts +1 -0
- package/dist/core/data.js +5 -3
- package/dist/core/dsl.js +13 -6
- package/dist/core/transfer.js +9 -1
- package/dist/kernel/cdcl.d.ts +40 -0
- package/dist/kernel/cdcl.js +543 -0
- package/dist/kernel/prove.d.ts +20 -1
- package/dist/kernel/prove.js +119 -44
- package/dist/kernel/reader.d.ts +79 -0
- package/dist/kernel/reader.js +539 -0
- package/dist/kernel/simplex.d.ts +32 -0
- package/dist/kernel/simplex.js +232 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ sound.
|
|
|
142
142
|
| --- | --- | --- |
|
|
143
143
|
| `kernel/kernel.ts`, `core/check.ts` | **Yes** | Turns a rule and its laws into goals, and checks a proof tree for each: case splits on linear facts, then a linear refutation at each leaf |
|
|
144
144
|
| `kernel/cyclic.ts` | **Yes** | Cyclic proofs: builds each node's goals (its own, and for each node it uses, that node's hypotheses and that the rank drops) and checks each tree with kernel.ts's check. Its twin is `lean-kernel/Cyclic.lean` (`cyclic_sound`), and `lean-kernel/Bridge.lean` carries a cyclic proof of a machine's law, a recurrence's lemmas or a fold's law back to the rule itself |
|
|
145
|
-
| `kernel/prove.ts` | No |
|
|
145
|
+
| `kernel/prove.ts`, `kernel/cdcl.ts` | No | Find the proof trees: case splits, and CDCL over a goal's atoms whose refutation is unfolded into a tree. If they're wrong, the kernel rejects the tree |
|
|
146
146
|
| `lean-kernel/` | Optional | The kernel's twin in Lean 4.34.0, every rule proven sound there with the standard axioms only. The exporter sends the kernel's real trees; tampered ones compute to false |
|
|
147
147
|
| `research/search/`, `research/synth/`, `research/hw/` | No | The GPU searches for breaking runs, and invariant and rank synthesis. Every hit is replayed or proven before it counts |
|
|
148
148
|
| `core/dsl.ts`, `core/compose.ts`, the runtimes | No | The builders and combinators compile to the kernel's plain values; the runtimes are held to a reference evaluator |
|
package/dist/core/cyclic.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { C, E, Law, Machine } from './machine.js';
|
|
2
|
-
import type { Fold, Goal, Instances, StepLaw, Subst, Tree } from '../kernel/kernel.js';
|
|
2
|
+
import type { Fold, Goal, Instances, Loop, StepLaw, Subst, Tree } from '../kernel/kernel.js';
|
|
3
3
|
import { type CNode, type Cyclic, type Fact, type Use } from '../kernel/cyclic.js';
|
|
4
4
|
import { type TStats } from './translate.js';
|
|
5
5
|
export type NodeSpec = Omit<CNode, 'uses' | 'main'> & {
|
|
@@ -77,6 +77,11 @@ export declare function recurNodes(r: RecurCase, usual?: {
|
|
|
77
77
|
};
|
|
78
78
|
export declare const cyclicMachine: (m: Machine, laws?: Law[]) => boolean;
|
|
79
79
|
export declare const uncoveredWhy: (m: Machine, laws?: Law[]) => string | undefined;
|
|
80
|
+
export declare function loopNodes(l: Loop, laws: Law[], rank: E | E[], trees: Record<string, Tree>, st?: TStats): {
|
|
81
|
+
facts: Fact[];
|
|
82
|
+
specs: NodeSpec[];
|
|
83
|
+
why?: string;
|
|
84
|
+
};
|
|
80
85
|
export type UsualStep = {
|
|
81
86
|
sl: StepLaw;
|
|
82
87
|
inst: Instances;
|
package/dist/core/cyclic.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assumed, boundOf, foldObligations, obligations, substC, substE, witnessesOf } from "../kernel/kernel.js";
|
|
1
|
+
import { assumed, boundOf, foldObligations, livenessParts, loopLiveness, loopMachine, loopObligations, obligations, stepLawObligations, substC, substE, witnessesOf } from "../kernel/kernel.js";
|
|
2
2
|
import { baseHyps, descentGoal, instHyps, mainGoal, premiseGoal, refuseCyclic } from "../kernel/cyclic.js";
|
|
3
3
|
import { cellProducts, clock, grow, profile, usedHyps, widen, withDeadline, withinDeadline } from "../kernel/prove.js";
|
|
4
4
|
import { carry, decide, readsFirst, renamer, translate, tstats } from "./translate.js";
|
|
@@ -576,6 +576,18 @@ export const uncoveredWhy = (m, laws = []) => {
|
|
|
576
576
|
walk(val, inKey); }; walk(t, false); return found; };
|
|
577
577
|
return m.history ? 'a history' : laws.some(l => nested(l.holds)) ? 'a law reading a map at a key read from a map' : undefined;
|
|
578
578
|
};
|
|
579
|
+
// A loop's halting as a machine's (kernel.ts's loopObligations: the loop's machine, its laws, and its liveness's step
|
|
580
|
+
// laws: each turn stays or gets there, the rank kept only with its region; some region holds; each turn, helpful, gets
|
|
581
|
+
// there or lowers the rank), its usual trees given: the laws' nodes and the step laws' after them, as machineNodes
|
|
582
|
+
// translates any machine's step laws (each law's instances none: a loop's laws are about no key).
|
|
583
|
+
export function loopNodes(l, laws, rank, trees, st = tstats()) {
|
|
584
|
+
loopObligations(l, laws, rank);
|
|
585
|
+
const m = loopMachine(l), { stay, cover, helps } = livenessParts(m, loopLiveness(l, rank)), instances = Object.fromEntries(laws.map(x => [x.name, {}]));
|
|
586
|
+
const lawGoals = obligations(m, laws, instances), steps = [stay, cover, ...helps].map(sl => { const goal = stepLawObligations(m, laws, {}, sl)[0]; return { sl, inst: {}, goal, tree: trees[goal.name] }; });
|
|
587
|
+
if (lawGoals.some(g => !trees[g.name]) || steps.some(x => !x.tree))
|
|
588
|
+
return { facts: [], specs: [], why: 'a goal without its usual tree' };
|
|
589
|
+
return machineNodes(m, laws, instances, { trees: Object.fromEntries(lawGoals.map(g => [g.name, trees[g.name]])), steps }, st);
|
|
590
|
+
}
|
|
579
591
|
// The run as maps over time: names at time u read as their maps there.
|
|
580
592
|
function trace(m) {
|
|
581
593
|
const maps = [...Object.keys(m.maps ?? {}), ...(m.inputMaps ?? [])];
|
package/dist/core/data.d.ts
CHANGED
package/dist/core/data.js
CHANGED
|
@@ -2790,9 +2790,11 @@ export const showY = (y) => {
|
|
|
2790
2790
|
// Prove a law over datatypes: refuted by a random value where one breaks it; else proven by a cycle the search finds,
|
|
2791
2791
|
// with lemmas found from the values when the law alone isn't (`lemmas: false` turns that off; an array gives lemmas to
|
|
2792
2792
|
// prove and use instead, which the corpus never does).
|
|
2793
|
-
export function proveData(l, opts = {}) {
|
|
2794
|
-
|
|
2795
|
-
|
|
2793
|
+
export function proveData(l, opts = {}) {
|
|
2794
|
+
return counted(dataRate, () => bounded(() => { const until = clock() + (opts.ms ?? 120_000), v = proveDataCounted(l, opts, until); return { ...v, stopped: clock() > until }; }));
|
|
2795
|
+
}
|
|
2796
|
+
function proveDataCounted(l, opts, until) {
|
|
2797
|
+
const t0 = performance.now();
|
|
2796
2798
|
// Where the law calls a non-recursive function, or reaches a recursive one that agrees with a built-in (core/transfer.ts):
|
|
2797
2799
|
// the law alone at one unfolding first, then the law said through them, then the rest of the search on the law.
|
|
2798
2800
|
const plan = opts.transfer === false || opts.induction === false || Array.isArray(opts.lemmas) ? undefined : transferPlan(l);
|
package/dist/core/dsl.js
CHANGED
|
@@ -19,7 +19,7 @@ import { carriedView, compileFunction, divName, divisor, divisorsIn, evalC, eval
|
|
|
19
19
|
import { allowed, keysOf, requestEnv, watch } from "./watch.js";
|
|
20
20
|
import { someHolds, substVars } from "./exists.js";
|
|
21
21
|
import { check, foldObligations, loopObligations } from "../kernel/kernel.js";
|
|
22
|
-
import { factsFor, grow, proveLaws, proveLiveness, proveStepLaws, usualProof, withDeadline } from "../kernel/prove.js";
|
|
22
|
+
import { certLoop, factsFor, grow, proveLaws, proveLiveness, proveStepLaws, usualProof, withDeadline } from "../kernel/prove.js";
|
|
23
23
|
import { certCyclic, certOn, crossCyclic, cyclicOn, foldNodes, proveCyclic, quietly, recurNodes, translatedProof, uncovered } from "./cyclic.js";
|
|
24
24
|
import { discover } from "./discover.js";
|
|
25
25
|
import { inferLaws } from "./infer.js";
|
|
@@ -2813,12 +2813,19 @@ export function crossCheckDecision(d, opts = {}) {
|
|
|
2813
2813
|
}
|
|
2814
2814
|
// With no rank stated, the rank is searched for from the loop's runs (core/cycles.ts's findRank), with the invariants it
|
|
2815
2815
|
// needs (inferLaws), within `ms` (10 s); the verdict is the kernel's on the rank and the laws found, in `found`.
|
|
2816
|
+
// The certificate, by default, is the cyclic proof of its halting goals (kernel/prove.ts's certLoop, translated from the
|
|
2817
|
+
// usual trees, which are then its input and not checked again); where none is made, the usual trees, checked.
|
|
2816
2818
|
export const proveLoop = (l, laws, opts = {}) => {
|
|
2817
|
-
if (
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2819
|
+
if (l.hasRank) {
|
|
2820
|
+
const t0 = performance.now(), goals = loopObligations(l.loop, laws, l.rankTerms), v = goalsVerdict(goals, !certOn());
|
|
2821
|
+
if (!v.proven)
|
|
2822
|
+
return v;
|
|
2823
|
+
const c = certLoop(l.loop, laws, l.rankTerms, v.trees, performance.now() - t0);
|
|
2824
|
+
return c && !c.checked && certOn() ? { ...v, checked: goals.every(g => check(g, v.trees[g.name])) } : v;
|
|
2825
|
+
}
|
|
2826
|
+
const t0 = performance.now(), out = findRank(l.loop, laws, opts);
|
|
2827
|
+
if (out.proven && out.checked && out.rank && out.trees)
|
|
2828
|
+
certLoop(l.loop, [...laws, ...(out.laws ?? [])], out.rank, out.trees, performance.now() - t0);
|
|
2822
2829
|
return { proven: out.proven, checked: out.checked, ...(out.trees ? { trees: out.trees } : {}), ...(out.goal ? { goal: out.goal, stuck: out.stuck } : {}), ...(out.witness ? { witness: out.witness } : {}), ...(out.why ? { why: out.why } : {}),
|
|
2823
2830
|
...(out.found ? { found: { rank: out.found.rank, ...(out.laws?.length ? { laws: out.laws.map((law, i) => ({ law, text: out.found.laws[i] ?? law.name })) } : {}) } } : {}) };
|
|
2824
2831
|
};
|
package/dist/core/transfer.js
CHANGED
|
@@ -44,6 +44,14 @@ function builtinOf(f) {
|
|
|
44
44
|
return true;
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
// Whether `y` is f's bridge law: f at distinct variables equal (either side) to the built-in at them.
|
|
48
|
+
function isBridge(y, f, op) {
|
|
49
|
+
if (y.op !== '=')
|
|
50
|
+
return false;
|
|
51
|
+
const sides = [[y.a, y.b], [y.b, y.a]];
|
|
52
|
+
return sides.some(([c, x]) => c.op === 'call' && c.fn === f.name && c.args.every(a => a.op === 'var') && new Set(c.args.map(a => JSON.stringify(a))).size === c.args.length
|
|
53
|
+
&& JSON.stringify(x) === JSON.stringify(op.x(c.args[0], c.args[1] ?? nat(0))));
|
|
54
|
+
}
|
|
47
55
|
const callsOf = (t) => { const out = []; walkO(t, o => { if (o.op === 'call')
|
|
48
56
|
out.push(o.fn); }); return out; };
|
|
49
57
|
function walkO(t, f) {
|
|
@@ -61,7 +69,7 @@ export function transferPlan(l) {
|
|
|
61
69
|
const p = programOf([l]), bridges = new Map();
|
|
62
70
|
for (const f of p.fns) {
|
|
63
71
|
const op = builtinOf(f);
|
|
64
|
-
if (op)
|
|
72
|
+
if (op && !isBridge(l.holds, f, op))
|
|
65
73
|
bridges.set(f.name, op);
|
|
66
74
|
}
|
|
67
75
|
const unfolds = p.fns.some(f => !recursive(f));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Goal, type Path } from './kernel.js';
|
|
2
|
+
import { type Outcome } from './prove.js';
|
|
3
|
+
export declare const cdclStats: {
|
|
4
|
+
on: boolean;
|
|
5
|
+
runs: number;
|
|
6
|
+
proven: number;
|
|
7
|
+
conflicts: number;
|
|
8
|
+
decisions: number;
|
|
9
|
+
solveMs: number;
|
|
10
|
+
rowsMs: number;
|
|
11
|
+
coreMs: number;
|
|
12
|
+
unfoldMs: number;
|
|
13
|
+
leaves: number;
|
|
14
|
+
resolved: number;
|
|
15
|
+
coreSize: number;
|
|
16
|
+
pathSize: number;
|
|
17
|
+
lpMisses: number;
|
|
18
|
+
resolved2: number;
|
|
19
|
+
unfoldWhy: string;
|
|
20
|
+
orderMs: number;
|
|
21
|
+
boundMs: number;
|
|
22
|
+
openMisses: number;
|
|
23
|
+
lpMs: number;
|
|
24
|
+
lpUnknown: number;
|
|
25
|
+
fmCalls: number;
|
|
26
|
+
pivots: number;
|
|
27
|
+
lpRebuilds: number;
|
|
28
|
+
lpRows: number;
|
|
29
|
+
lpNnz: number;
|
|
30
|
+
lpVars: number;
|
|
31
|
+
lpLoad: number;
|
|
32
|
+
nodes: number;
|
|
33
|
+
boundRounds: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function growCdcl(goal: Goal, root: Path, budget: {
|
|
36
|
+
nodes: number;
|
|
37
|
+
until?: number;
|
|
38
|
+
}, opts?: {
|
|
39
|
+
maxLeaves?: number;
|
|
40
|
+
}): Outcome;
|