gdp-wired 0.26.0 → 0.28.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/dist/core/accel.d.ts +24 -0
- package/dist/core/accel.js +557 -207
- package/dist/core/bmc.d.ts +4 -1
- package/dist/core/bmc.js +18 -15
- package/dist/core/cycles.d.ts +2 -0
- package/dist/core/cycles.js +1 -1
- package/dist/core/cyclic.js +17 -10
- package/dist/core/data.d.ts +1 -0
- package/dist/core/data.js +73 -18
- package/dist/core/discover.js +64 -25
- package/dist/core/dsl.js +108 -18
- package/dist/core/extract-check.d.ts +52 -2
- package/dist/core/extract-check.js +155 -104
- package/dist/core/extract-read.d.ts +25 -0
- package/dist/core/extract-read.js +55 -14
- package/dist/core/extract-shapes.js +94 -18
- package/dist/core/extract-xstate.js +16 -3
- package/dist/core/extract.d.ts +1 -0
- package/dist/core/extract.js +16 -8
- package/dist/core/fresh.d.ts +9 -0
- package/dist/core/fresh.js +91 -0
- package/dist/core/infer.d.ts +1 -0
- package/dist/core/infer.js +64 -46
- package/dist/core/live.d.ts +15 -0
- package/dist/core/live.js +317 -0
- package/dist/core/machine.js +0 -1
- package/dist/core/nonterm.d.ts +3 -1
- package/dist/core/nonterm.js +103 -25
- package/dist/core/solver.d.ts +21 -0
- package/dist/core/solver.js +8 -0
- package/dist/core/translate.js +69 -19
- package/dist/kernel/cdcl.js +212 -78
- package/dist/kernel/kernel.d.ts +17 -1
- package/dist/kernel/kernel.js +158 -2
- package/dist/kernel/prove.d.ts +30 -4
- package/dist/kernel/prove.js +119 -25
- package/dist/kernel/reader.d.ts +74 -5
- package/dist/kernel/reader.js +531 -75
- package/dist/kernel/simplex.d.ts +26 -1
- package/dist/kernel/simplex.js +148 -14
- package/dist/lean-kernel/emit.d.ts +15 -3
- package/dist/lean-kernel/emit.js +144 -12
- package/dist/lean-kernel/library.js +1 -1
- package/package.json +2 -2
package/dist/core/dsl.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
import { argsKey, carriedView, compileFunction, divName, divisor, divisorsIn, evalC, evalE, interpret, isArithmetic, loadJs, modName, numbersOf, pairedArgs, seeded, withArithmetic } from "./machine.js";
|
|
19
19
|
import { allowed, keysOf, requestEnv, watch } from "./watch.js";
|
|
20
20
|
import { someHolds, substVars } from "./exists.js";
|
|
21
|
-
import { check, checkRecur, foldObligations, loopObligations } from "../kernel/kernel.js";
|
|
22
|
-
import { certLoop, clock, factsFor, grow, proveLaws, proveLiveness, proveStepLaws, usualProof, withDeadline } from "../kernel/prove.js";
|
|
21
|
+
import { check, checkRecur, foldObligations, loopObligations, substC } from "../kernel/kernel.js";
|
|
22
|
+
import { certLoop, clock, counted, factsFor, fullRate, 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";
|
|
@@ -27,6 +27,8 @@ import { findBoundedRun } from "./bmc.js";
|
|
|
27
27
|
import { conjunction, proveKInduction } from "./kind.js";
|
|
28
28
|
import { cycleLemmas, findLeadsTo, findRank } from "./cycles.js";
|
|
29
29
|
import { findNeverEnds } from "./nonterm.js";
|
|
30
|
+
import { leadsByTerms } from "./live.js";
|
|
31
|
+
import { freshLaws } from "./fresh.js";
|
|
30
32
|
// --- terms and conditions -------------------------------------------------------------------------------------------
|
|
31
33
|
const naturalConst = (v) => {
|
|
32
34
|
if (!Number.isSafeInteger(v) || v < 0)
|
|
@@ -2660,9 +2662,27 @@ const refuteBudget = { trials: 60, depth: 6, bound: 3 };
|
|
|
2660
2662
|
const shownRequest = (input) => Object.fromEntries(Object.entries(input).map(([n, x]) => [n, typeof x === 'number' ? x : Object.fromEntries(x)]));
|
|
2661
2663
|
// The search's own runs, before it looks for what the laws need: deeper and wider, from another seed.
|
|
2662
2664
|
const deeperBudget = { trials: 600, depth: 24, bound: 8, seed: 29 };
|
|
2665
|
+
const conjuncts = (c) => (!c ? [] : c.op === 'and' ? c.xs.flatMap(conjuncts) : [c]);
|
|
2666
|
+
function guidesOf(m) {
|
|
2667
|
+
const isInput = (e) => e.op === 'var' && m.inputs.includes(e.name);
|
|
2668
|
+
const free = (e) => !namesIn(e).some(n => m.inputs.includes(n));
|
|
2669
|
+
return conjuncts(m.assume).flatMap(c => {
|
|
2670
|
+
if (c.op !== '=' && c.op !== '<=' && c.op !== '<')
|
|
2671
|
+
return [];
|
|
2672
|
+
const [x, t, up] = isInput(c.a) && free(c.b) && c.op === '=' ? [c.a, c.b, false] : isInput(c.b) && free(c.a) ? [c.b, c.a, c.op !== '='] : [undefined, undefined, false];
|
|
2673
|
+
if (!x || !t)
|
|
2674
|
+
return [];
|
|
2675
|
+
return [(env, st, rand, bound) => { try {
|
|
2676
|
+
return [x.name, evalE(t, env, st, m) + (up ? (c.op === '<' ? 1 : 0) + rand(bound + 1) : 0)];
|
|
2677
|
+
}
|
|
2678
|
+
catch {
|
|
2679
|
+
return undefined;
|
|
2680
|
+
} }];
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2663
2683
|
function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
2664
2684
|
const m = r.machine;
|
|
2665
|
-
const run = interpret(m), rand = seeded(budget.seed ?? 13), bound = budget.bound, shown = shownRequest;
|
|
2685
|
+
const run = interpret(m), rand = seeded(budget.seed ?? 13), bound = budget.bound, shown = shownRequest, guides = budget.mixed ? guidesOf(m) : [];
|
|
2666
2686
|
// (Division by a constant is a function too, its facts Euclid's, which its JavaScript meets: not checked.)
|
|
2667
2687
|
const facts = (m.facts ?? []).filter(f => !isArithmetic(f.name.slice(0, f.name.indexOf(':'))));
|
|
2668
2688
|
const holds = (f, params) => {
|
|
@@ -2683,7 +2703,13 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
2683
2703
|
&& facts.filter(readsParams).every(f => holds(f, params));
|
|
2684
2704
|
try {
|
|
2685
2705
|
for (let trial = 0; trial < budget.trials; trial++) {
|
|
2706
|
+
// (`mixed`: the trials in turn at bounds 1 to 4, every fourth near)
|
|
2707
|
+
const bound = budget.mixed ? 1 + trial % 4 : budget.bound, guided = guides, near = budget.mixed && trial % 4 ? undefined : budget.near;
|
|
2686
2708
|
const params = r.randomParams(rand, bound);
|
|
2709
|
+
if (near)
|
|
2710
|
+
for (const p of m.params)
|
|
2711
|
+
if (near[p] !== undefined && rand(2))
|
|
2712
|
+
params[p] = near[p];
|
|
2687
2713
|
if (m.pre && !evalC(m.pre, params, { scalars: {}, maps: {} }, m) || !factsHold(params))
|
|
2688
2714
|
continue;
|
|
2689
2715
|
const watching = [...laws, ...stepLaws].map(w => ({ w, on: watch(m, run, w, params, bound) }));
|
|
@@ -2696,6 +2722,15 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
2696
2722
|
return broken(w, '@start', st);
|
|
2697
2723
|
for (let d = 0, tries = 0; d < budget.depth && tries < 40; tries++) {
|
|
2698
2724
|
const input = r.randomInput(rand, bound, params);
|
|
2725
|
+
if (near)
|
|
2726
|
+
for (const x of m.inputs)
|
|
2727
|
+
if (near[x] !== undefined && typeof input[x] === 'number' && rand(2))
|
|
2728
|
+
input[x] = near[x];
|
|
2729
|
+
for (const g of guided) {
|
|
2730
|
+
const set = g({ ...params, ...st.scalars }, st, rand, bound);
|
|
2731
|
+
if (set && typeof input[set[0]] === 'number')
|
|
2732
|
+
input[set[0]] = set[1];
|
|
2733
|
+
}
|
|
2699
2734
|
if (!allowed(m, run, params, st, input))
|
|
2700
2735
|
continue;
|
|
2701
2736
|
d++;
|
|
@@ -2714,7 +2749,7 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
2714
2749
|
// variable of a kind is drawn as its kind draws (33 yes/nos drawn from 0..7 almost never make a lawful state).
|
|
2715
2750
|
const steps1 = stepLaws.filter(sl => (sl.steps ?? 1) === 1), given = withKinds(r, laws);
|
|
2716
2751
|
const wide = Object.keys(m.state).length + m.inputs.length >= 32, lawsHere = wide ? given : [], kinded = wide ? r.kindsOfState() : [];
|
|
2717
|
-
for (let trial = 0; !m.history && (steps1.length || lawsHere.length) && trial < budget.trials * 4; trial++) {
|
|
2752
|
+
for (let trial = 0; budget.states !== false && !m.history && (steps1.length || lawsHere.length) && trial < budget.trials * 4; trial++) {
|
|
2718
2753
|
const params = r.randomParams(rand, bound);
|
|
2719
2754
|
if (m.pre && !evalC(m.pre, params, { scalars: {}, maps: {} }, m) || !factsHold(params))
|
|
2720
2755
|
continue;
|
|
@@ -2763,38 +2798,73 @@ export function proveRule(r, laws, opts = {}) {
|
|
|
2763
2798
|
export function proveSteps(r, laws, stepLaws, opts = {}) {
|
|
2764
2799
|
noting(r, laws, stepLaws);
|
|
2765
2800
|
const refuted = refuteByRuns(r, laws, stepLaws);
|
|
2801
|
+
// (a step law broken from a state the laws allow, with no run to it: the laws may need an invariant there, or the run
|
|
2802
|
+
// be further than these runs go; the search goes on from it, as from the kernel's)
|
|
2766
2803
|
if (refuted)
|
|
2767
|
-
return refutedVerdict(refuted);
|
|
2804
|
+
return refuted.run ? refutedVerdict(refuted) : searched(r, laws, stepLaws, refutedVerdict(refuted), opts);
|
|
2768
2805
|
const out = proveStepLaws(r.machine, withKinds(r, laws), stepLaws);
|
|
2769
2806
|
const v = verdictOf(out);
|
|
2770
2807
|
return searched(r, laws, stepLaws, v, opts);
|
|
2771
2808
|
}
|
|
2809
|
+
// The one-step laws as laws the bounded runs read (core/bmc.ts takes laws alone): a ghost per step law, set once a step
|
|
2810
|
+
// it is about breaks it (`then` read with each primed name the step's update), and the law that it is never set. Only a
|
|
2811
|
+
// machine bmc takes (no maps, no history) and a step law over no key; the ghost changes no run of the machine.
|
|
2812
|
+
function stepGhosts(m, stepLaws) {
|
|
2813
|
+
const plain = stepLaws.filter(sl => (sl.steps ?? 1) === 1 && !sl.forall && !sl.keys?.length);
|
|
2814
|
+
if (!plain.length || Object.keys(m.maps ?? {}).length || m.history || m.inputMaps?.length)
|
|
2815
|
+
return undefined;
|
|
2816
|
+
const flags = Object.fromEntries(Object.keys(m.step.flags ?? {}).map(f => [f, { op: 'flag', name: f }]));
|
|
2817
|
+
const after = { vars: Object.fromEntries(Object.keys(m.state).map(n => [`${n}'`, m.step.state?.[n] ?? { op: 'var', name: n }])), maps: {}, flags };
|
|
2818
|
+
const ghosts = {}, out = [];
|
|
2819
|
+
for (const [i, sl] of plain.entries()) {
|
|
2820
|
+
const name = `broken$${i}`, whens = sl.when === undefined ? [] : Array.isArray(sl.when) ? sl.when : [sl.when];
|
|
2821
|
+
if (name in m.state)
|
|
2822
|
+
return undefined;
|
|
2823
|
+
ghosts[name] = { op: 'if', c: { op: 'and', xs: [...whens, { op: 'not', x: substC(sl.then, after) }] }, then: { op: 'const', value: 1 }, else: { op: 'var', name } };
|
|
2824
|
+
out.push({ name: sl.name, holds: { op: '<=', a: { op: 'var', name }, b: { op: 'const', value: 0 } } });
|
|
2825
|
+
}
|
|
2826
|
+
// (as core/compose.ts's `ghost`: each starts at 0, nothing of the machine reads it)
|
|
2827
|
+
try {
|
|
2828
|
+
return { machine: { ...m, state: { ...m.state, ...Object.fromEntries(Object.keys(ghosts).map(n => [n, { op: 'const', value: 0 }])) }, step: { ...m.step, state: { ...m.step.state, ...ghosts } } }, laws: out };
|
|
2829
|
+
}
|
|
2830
|
+
catch {
|
|
2831
|
+
return undefined;
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2772
2834
|
// The search, where the prover alone didn't prove the laws and nothing refuted them: the lemmas first where the rule has
|
|
2773
2835
|
// recurrences or carried lists (the rule made again with them), then invariants over what it then is. The verdict is the
|
|
2774
2836
|
// prover's on the laws with what was found; when nothing is found, the prover's own (with why).
|
|
2775
2837
|
function searched(r, laws, stepLaws, v, opts) {
|
|
2776
2838
|
if ((v.proven && v.checked) || opts.search === false || v.run || v.stuck === 'sat' && !/@step|@\d+ steps/.test(v.goal ?? ''))
|
|
2777
2839
|
return v;
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2840
|
+
// The deeper runs; then runs over small values (keys that meet, small params), whose requests meet their
|
|
2841
|
+
// assumption's equalities and clocks, or near the counterexample the verdict ends at.
|
|
2842
|
+
for (const b of [deeperBudget, { ...deeperBudget, bound: 1, seed: 31, states: false }, { ...deeperBudget, trials: 1200, seed: 41, states: false, mixed: true, ...(v.witness ? { near: v.witness } : {}) }]) {
|
|
2843
|
+
const deeper = refuteByRuns(r, laws, stepLaws, b);
|
|
2844
|
+
if (deeper?.run)
|
|
2845
|
+
return refutedVerdict(deeper);
|
|
2846
|
+
}
|
|
2781
2847
|
const until = clock() + (typeof opts.search === 'object' && opts.search.ms !== undefined ? opts.search.ms : 10_000);
|
|
2782
2848
|
// Bounded runs (core/bmc.ts): a law broken k steps from the start, a model of the kernel's k-step goal, the run taken
|
|
2783
|
-
// by the interpreter. The shallow depths first, within a fortieth of the search's budget (at most 250 ms, counted
|
|
2784
|
-
//
|
|
2785
|
-
// kept from it, so a law the search proves costs no more than the
|
|
2849
|
+
// by the interpreter. The shallow depths first, within a fortieth of the search's budget (at most 250 ms, counted in
|
|
2850
|
+
// the cost model's work: kernel/prove.ts's `counted` with `full`); the deeper ones only where the invariant search
|
|
2851
|
+
// finds nothing, within the tenth (at most a second) kept from it, so a law the search proves costs no more than the
|
|
2852
|
+
// shallow depths.
|
|
2786
2853
|
const total = until - clock(), tail = Math.min(1000, total / 10);
|
|
2787
2854
|
let reached = 0;
|
|
2788
|
-
const
|
|
2855
|
+
const ghosted = stepGhosts(r.machine, stepLaws);
|
|
2856
|
+
// (with the step laws' ghosts, a wall stop too, at the budget: their goals cost the cost model more than its clock
|
|
2857
|
+
// counts, a wide rule's past twice its wall time)
|
|
2858
|
+
const bounded = (ms, from) => counted(fullRate, () => findBoundedRun(ghosted?.machine ?? r.machine, [...laws, ...(ghosted?.laws ?? [])], { ms, from, steps: true, ...(ghosted ? { wall: performance.now() + ms } : {}), progress: k => { reached = k; } }), true);
|
|
2789
2859
|
const refutedBy = (b) => refutedVerdict({ goal: `${b.law} @step (a run of ${b.depth} steps from the start)`, witness: b.witness, run: { params: b.params, trace: b.trace.map(shownRequest) } });
|
|
2790
2860
|
const shallow = bounded(Math.min(250, total / 40), 1);
|
|
2791
2861
|
if (shallow)
|
|
2792
2862
|
return refutedBy(shallow);
|
|
2793
2863
|
// k-induction (core/kind.ts): the plain laws as one, over k = 2, 3, ... steps in a row, the rule's kinds assumed;
|
|
2794
|
-
// within a twentieth of the budget (at most 500 ms, counted
|
|
2864
|
+
// within a twentieth of the budget (at most 500 ms, counted so too).
|
|
2795
2865
|
if (!stepLaws.length && laws.every(l => !l.forall && !l.keys?.length && !l.some?.length)) {
|
|
2796
2866
|
const ms = Math.min(500, total / 20), kinds = withKinds(r, []).filter(k => !laws.some(l => l.name === k.name));
|
|
2797
|
-
const kd = proveKInduction(r.machine, kinds, conjunction(laws), { ms
|
|
2867
|
+
const kd = counted(fullRate, () => proveKInduction(r.machine, kinds, conjunction(laws), { ms }), true);
|
|
2798
2868
|
if (kd.proven && kd.checked)
|
|
2799
2869
|
return { proven: true, checked: true, k: kd.k };
|
|
2800
2870
|
}
|
|
@@ -2814,26 +2884,46 @@ function searched(r, laws, stepLaws, v, opts) {
|
|
|
2814
2884
|
if (c.proven && c.checked)
|
|
2815
2885
|
return { proven: true, checked: true, found: { ...(lemmas ? { lemmas } : {}), facts: c.found.map(f => f.text) } };
|
|
2816
2886
|
}
|
|
2887
|
+
// Laws about the ids a counter hands out (core/fresh.ts), within a tenth of what is left: the laws with them, then
|
|
2888
|
+
// the invariant search with them given.
|
|
2889
|
+
let fresh = [];
|
|
2890
|
+
if (Object.keys(rule.machine.maps ?? {}).length && until - clock() - tail > 1000) {
|
|
2891
|
+
const fm = rule.machine, share = (until - clock() - tail) / 10;
|
|
2892
|
+
fresh = withDeadline(clock() + share, () => freshLaws(fm, rule.kindLaws(), { params: (rand, bound) => rule.randomParams(rand, bound), input: (rand, bound, ps) => rule.randomInput(rand, bound, ps) }, { ms: share }));
|
|
2893
|
+
if (fresh.length) {
|
|
2894
|
+
const given = [...withKinds(rule, laws), ...fresh.map(f => f.law)], out = withDeadline(clock() + share, () => (stepLaws.length ? proveStepLaws(fm, given, stepLaws) : proveLaws(fm, given)));
|
|
2895
|
+
if (out.proven && out.checked)
|
|
2896
|
+
return { proven: true, checked: true, found: { laws: fresh, ...(lemmas ? { lemmas } : {}) } };
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2817
2899
|
const ms = until - clock() - tail;
|
|
2818
2900
|
if (ms < 500)
|
|
2819
2901
|
return v;
|
|
2820
|
-
const inf = inferLaws(rule, laws, stepLaws, { ms, ...(rule === r ? { first: v } : {}) });
|
|
2902
|
+
const inf = inferLaws(rule, [...fresh.map(f => f.law), ...laws], stepLaws, { ms, ...(rule === r && !fresh.length ? { first: v } : {}) });
|
|
2821
2903
|
if (!(inf.proven && inf.checked)) {
|
|
2822
|
-
|
|
2904
|
+
// (a step law's ghost: at most 10 s of it, as its goals cost more than the laws')
|
|
2905
|
+
const deep = bounded(Math.max(0, Math.min(until - clock(), ghosted && !laws.length ? 10_000 : Infinity)), Math.max(1, reached));
|
|
2823
2906
|
if (deep)
|
|
2824
2907
|
return refutedBy(deep);
|
|
2825
2908
|
return { ...v, why: [v.why, `the search found nothing that proves it in ${Math.round(inf.stats.ms)} ms`].filter(Boolean).join('; ') };
|
|
2826
2909
|
}
|
|
2827
2910
|
const { found, stats: _stats, ...verdict } = inf;
|
|
2828
2911
|
void _stats;
|
|
2829
|
-
return { ...verdict, found: { laws: found, ...(lemmas ? { lemmas } : {}) } };
|
|
2912
|
+
return { ...verdict, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) } };
|
|
2830
2913
|
}
|
|
2831
2914
|
export function proveLeadsTo(r, laws, l, opts = {}) {
|
|
2832
2915
|
noting(r, laws, l);
|
|
2833
2916
|
if (laws.some(law => law.some?.length))
|
|
2834
2917
|
throw new Error(`${r.machine.name}: a law with "there exists" goes to proveRule or proveSteps; a liveness takes plain laws (the ones its proof printed, Verdict.witnesses)`);
|
|
2835
2918
|
if (Array.isArray(l.rank) && !l.rank.length) {
|
|
2836
|
-
const
|
|
2919
|
+
const until = clock() + (opts.ms ?? 10_000), draws = { params: (rand, bound) => r.randomParams(rand, bound), input: (rand, bound, ps) => r.randomInput(rand, bound, ps) };
|
|
2920
|
+
let f = findLeadsTo(r.machine, withKinds(r, laws), l, { ...draws, rule: r }, opts);
|
|
2921
|
+
// Where the rank fitted to the runs isn't the one: a rank of the rule's own terms (core/live.ts), in the time left.
|
|
2922
|
+
if (!(f.proven && f.checked) && until - clock() > 500) {
|
|
2923
|
+
const g = leadsByTerms(r.machine, withKinds(r, laws), l, { ...draws, rule: r, state: (rand, bound) => Object.assign({}, ...r.kindsOfState().map(([n, kd]) => kd.random(n, rand, bound))) }, { ms: until - clock() });
|
|
2924
|
+
if (g.proven && g.checked)
|
|
2925
|
+
f = g;
|
|
2926
|
+
}
|
|
2837
2927
|
return { proven: f.proven, checked: f.checked, ...(f.goal ? { goal: f.goal, stuck: f.stuck } : {}), ...(f.witness ? { witness: f.witness } : {}), ...(f.why ? { why: f.why } : {}),
|
|
2838
2928
|
...(f.found ? { found: { rank: f.found.rank, ...(f.laws?.length ? { laws: f.laws.map((law, i) => ({ law, text: f.found.laws[i] ?? law.name })) } : {}) } } : {}) };
|
|
2839
2929
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type Context = Record<string, unknown>;
|
|
2
|
-
import { type Kind, type Rule } from './dsl.js';
|
|
2
|
+
import { Term, type Kind, type Rule } from './dsl.js';
|
|
3
|
+
import { type Rand, type State } from './machine.js';
|
|
3
4
|
import { type Model, type Var } from './extract-read.js';
|
|
4
5
|
import * as I from './extract-ir.js';
|
|
5
6
|
import type { B, N } from './extract-ir.js';
|
|
@@ -59,7 +60,17 @@ export type Snap = {
|
|
|
59
60
|
maps: Record<string, Cells>;
|
|
60
61
|
lists?: Record<string, Raw[]>;
|
|
61
62
|
};
|
|
63
|
+
export declare class Outside extends Error {
|
|
64
|
+
}
|
|
65
|
+
export declare class Refused extends Error {
|
|
66
|
+
}
|
|
67
|
+
export declare const showSnap: (s: Snap) => string;
|
|
68
|
+
export declare const sameSnap: (a: Snap, b: Snap) => string | undefined;
|
|
62
69
|
export declare const kindOfVar: (v: Var, sorts: Sorts, at?: string) => Kind<unknown>;
|
|
70
|
+
export declare function ruleSnap(r: Rule, m: Model, st: State, sorts: Sorts): Snap;
|
|
71
|
+
export declare function ruleState(base: State, s: Snap, m: Model, sorts: Sorts): State;
|
|
72
|
+
export declare function constantsOf(m: Model): number[];
|
|
73
|
+
export declare function draw(sort: Var['sort'], sorts: Sorts, name: string, rand: Rand, near: number[], bound: number, strs: string[]): Raw;
|
|
63
74
|
export type CheckOptions = {
|
|
64
75
|
runs?: number;
|
|
65
76
|
depth?: number;
|
|
@@ -71,8 +82,47 @@ export type CheckOptions = {
|
|
|
71
82
|
modules?: Record<string, unknown>;
|
|
72
83
|
files?: Record<string, string>;
|
|
73
84
|
};
|
|
85
|
+
type Ev = Model['events'][number];
|
|
86
|
+
export type CodeSide = {
|
|
87
|
+
make: (params: Record<string, Raw>) => {
|
|
88
|
+
ok: true;
|
|
89
|
+
value: unknown;
|
|
90
|
+
} | {
|
|
91
|
+
ok: false;
|
|
92
|
+
error: string;
|
|
93
|
+
};
|
|
94
|
+
at: (snap: Snap, params: Record<string, Raw>) => unknown;
|
|
95
|
+
snapOf: (self: unknown, params: Record<string, Raw>) => Snap;
|
|
96
|
+
call: (self: unknown, e: Ev, args: unknown[]) => {
|
|
97
|
+
ok: true;
|
|
98
|
+
value: unknown;
|
|
99
|
+
} | {
|
|
100
|
+
ok: false;
|
|
101
|
+
error: string;
|
|
102
|
+
};
|
|
103
|
+
reduce?: (snap: Snap, e: Ev, args: unknown[], params: Record<string, Raw>) => {
|
|
104
|
+
refused: string;
|
|
105
|
+
} | {
|
|
106
|
+
snap: Snap;
|
|
107
|
+
} | {
|
|
108
|
+
problem: string;
|
|
109
|
+
};
|
|
110
|
+
args: (inputs: Record<string, Raw>, e: Ev) => unknown[];
|
|
111
|
+
setNow: (n: number) => void;
|
|
112
|
+
init?: (snap: Snap, params: Record<string, Raw>) => string | undefined;
|
|
113
|
+
coverage: () => Coverage;
|
|
114
|
+
input?: (v: Var, x: Raw, rand: Rand) => Raw;
|
|
115
|
+
drawSnap?: (rand: Rand) => Snap;
|
|
116
|
+
normalize?: (s: Snap) => Snap;
|
|
117
|
+
edge?: (s: Snap, raw: Record<string, Raw>) => boolean;
|
|
118
|
+
};
|
|
74
119
|
export declare function check(code: string, file: string, m: Model, r: Rule, sorts: Sorts, opts?: CheckOptions & {
|
|
75
120
|
given?: Record<string, 'nat' | 'int'>;
|
|
76
121
|
}): Evidence;
|
|
77
|
-
export declare function
|
|
122
|
+
export declare function drive(m: Model, r: Rule, sorts: Sorts, code: CodeSide, opts?: CheckOptions & {
|
|
123
|
+
given?: Record<string, 'nat' | 'int'>;
|
|
124
|
+
}): Evidence;
|
|
125
|
+
export declare function conditionsOf(m: Model): B[];
|
|
126
|
+
export declare function condAt(c: B, env: Record<string, unknown>): ReturnType<Term['lt']>;
|
|
127
|
+
export declare function evalTerm(t: N | B | I.L, env: Record<string, Raw>, cell?: (map: string, key: Raw, field: string) => Raw): Raw;
|
|
78
128
|
export {};
|