gdp-wired 0.46.0 → 0.48.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 +18 -5
- package/dist/core/carry.d.ts +15 -0
- package/dist/core/carry.js +651 -0
- package/dist/core/cli.d.ts +4 -1
- package/dist/core/cli.js +31 -11
- package/dist/core/count-cases.d.ts +24 -0
- package/dist/core/count-cases.js +320 -0
- package/dist/core/count-cert-grow.d.ts +4 -0
- package/dist/core/count-cert-grow.js +37 -0
- package/dist/core/count-cert-transport.d.ts +3 -0
- package/dist/core/count-cert-transport.js +58 -0
- package/dist/core/count-completion.d.ts +9 -0
- package/dist/core/count-completion.js +27 -0
- package/dist/core/count-cubes.d.ts +8 -0
- package/dist/core/count-cubes.js +69 -0
- package/dist/core/count-demand.d.ts +37 -0
- package/dist/core/count-demand.js +361 -0
- package/dist/core/count-facts.d.ts +52 -0
- package/dist/core/count-facts.js +247 -0
- package/dist/core/count-focus-proof.d.ts +8 -0
- package/dist/core/count-focus-proof.js +140 -0
- package/dist/core/count-focused.d.ts +22 -0
- package/dist/core/count-focused.js +676 -0
- package/dist/core/count-ranges.d.ts +5 -0
- package/dist/core/count-ranges.js +65 -0
- package/dist/core/count-recovery/action-guard.d.ts +5 -0
- package/dist/core/count-recovery/action-guard.js +51 -0
- package/dist/core/count-recovery/boolean-core.d.ts +16 -0
- package/dist/core/count-recovery/boolean-core.js +258 -0
- package/dist/core/count-recovery/carried-case.d.ts +2 -0
- package/dist/core/count-recovery/carried-case.js +24 -0
- package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
- package/dist/core/count-recovery/conditional-check-cache.js +130 -0
- package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
- package/dist/core/count-recovery/conditional-cuts.js +318 -0
- package/dist/core/count-recovery/conditional-proof.d.ts +19 -0
- package/dist/core/count-recovery/conditional-proof.js +306 -0
- package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
- package/dist/core/count-recovery/derivability-closure.js +533 -0
- package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
- package/dist/core/count-recovery/empty-count-source.js +40 -0
- package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
- package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
- package/dist/core/count-recovery/field-case.d.ts +5 -0
- package/dist/core/count-recovery/field-case.js +89 -0
- package/dist/core/count-recovery/field-demand.d.ts +46 -0
- package/dist/core/count-recovery/field-demand.js +47 -0
- package/dist/core/count-recovery/field-only.d.ts +3 -0
- package/dist/core/count-recovery/field-only.js +18 -0
- package/dist/core/count-recovery/fold-path.d.ts +6 -0
- package/dist/core/count-recovery/fold-path.js +35 -0
- package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
- package/dist/core/count-recovery/frame-lemmas.js +120 -0
- package/dist/core/count-recovery/guard-cases.d.ts +12 -0
- package/dist/core/count-recovery/guard-cases.js +138 -0
- package/dist/core/count-recovery/key-closure.d.ts +14 -0
- package/dist/core/count-recovery/key-closure.js +62 -0
- package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
- package/dist/core/count-recovery/leaf-allowance.js +7 -0
- package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
- package/dist/core/count-recovery/lift-count-proxies.js +175 -0
- package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
- package/dist/core/count-recovery/live-dependencies.js +76 -0
- package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
- package/dist/core/count-recovery/member-inclusions.js +168 -0
- package/dist/core/count-recovery/member-premises.d.ts +29 -0
- package/dist/core/count-recovery/member-premises.js +114 -0
- package/dist/core/count-recovery/natural-cases.d.ts +6 -0
- package/dist/core/count-recovery/natural-cases.js +59 -0
- package/dist/core/count-recovery/ops.d.ts +6 -0
- package/dist/core/count-recovery/ops.js +8 -0
- package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
- package/dist/core/count-recovery/pre-state-source.js +18 -0
- package/dist/core/count-recovery/rebase-path.d.ts +9 -0
- package/dist/core/count-recovery/rebase-path.js +70 -0
- package/dist/core/count-recovery/rename-proof.d.ts +2 -0
- package/dist/core/count-recovery/rename-proof.js +102 -0
- package/dist/core/count-recovery/row-cases.d.ts +16 -0
- package/dist/core/count-recovery/row-cases.js +291 -0
- package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
- package/dist/core/count-recovery/scalar-guards.js +291 -0
- package/dist/core/count-recovery/source-memo.d.ts +12 -0
- package/dist/core/count-recovery/source-memo.js +67 -0
- package/dist/core/count-select.d.ts +16 -0
- package/dist/core/count-select.js +24 -0
- package/dist/core/count-support.d.ts +598 -0
- package/dist/core/count-support.js +2080 -0
- package/dist/core/count-unions.d.ts +2 -0
- package/dist/core/count-unions.js +139 -0
- package/dist/core/count-witness-flags.d.ts +9 -0
- package/dist/core/count-witness-flags.js +37 -0
- package/dist/core/count-write-frames.d.ts +12 -0
- package/dist/core/count-write-frames.js +206 -0
- package/dist/core/counts.d.ts +20 -2
- package/dist/core/counts.js +807 -156
- package/dist/core/dsl.d.ts +50 -6
- package/dist/core/dsl.js +307 -65
- package/dist/core/effect-schema.d.ts +90 -0
- package/dist/core/effect-schema.js +500 -0
- package/dist/core/effect.d.ts +3 -7
- package/dist/core/effect.js +10 -65
- package/dist/core/exists.d.ts +1 -1
- package/dist/core/exists.js +80 -15
- package/dist/core/extract-check.d.ts +7 -1
- package/dist/core/extract-check.js +161 -19
- package/dist/core/extract-go-check.js +24 -4
- package/dist/core/extract-go.d.ts +7 -0
- package/dist/core/extract-go.js +29 -2
- package/dist/core/extract-read.d.ts +31 -9
- package/dist/core/extract-read.js +36 -11
- package/dist/core/extract-rs.js +58 -14
- package/dist/core/extract-shapes.d.ts +1 -0
- package/dist/core/extract-shapes.js +190 -27
- package/dist/core/extract-standalone.d.ts +3 -0
- package/dist/core/extract-standalone.js +265 -0
- package/dist/core/extract.d.ts +1 -0
- package/dist/core/extract.js +25 -5
- package/dist/core/field-laws.d.ts +2 -0
- package/dist/core/field-laws.js +100 -0
- package/dist/core/finite-frontiers.d.ts +5 -0
- package/dist/core/finite-frontiers.js +116 -0
- package/dist/core/finite-houdini.d.ts +52 -0
- package/dist/core/finite-houdini.js +460 -0
- package/dist/core/finite-model.d.ts +13 -0
- package/dist/core/finite-model.js +68 -0
- package/dist/core/finite-tiny.d.ts +72 -0
- package/dist/core/finite-tiny.js +1052 -0
- package/dist/core/infer.d.ts +1 -1
- package/dist/core/infer.js +32 -9
- package/dist/core/laws.d.ts +2 -1
- package/dist/core/laws.js +76 -19
- package/dist/core/lemma-cuts.d.ts +38 -0
- package/dist/core/lemma-cuts.js +365 -0
- package/dist/core/machine.d.ts +39 -2
- package/dist/core/machine.js +240 -35
- package/dist/core/mutate.d.ts +55 -0
- package/dist/core/mutate.js +210 -0
- package/dist/core/native-domain.d.ts +6 -0
- package/dist/core/native-domain.js +114 -0
- package/dist/core/native-law.d.ts +3 -0
- package/dist/core/native-law.js +174 -0
- package/dist/core/quorum-laws.d.ts +5 -0
- package/dist/core/quorum-laws.js +239 -0
- package/dist/core/relational.js +10 -2
- package/dist/core/relevance.d.ts +4 -0
- package/dist/core/relevance.js +79 -0
- package/dist/core/rs/Cargo.toml +1 -1
- package/dist/core/rs/src/main.rs +458 -9
- package/dist/core/runtime-wall.d.ts +3 -0
- package/dist/core/runtime-wall.js +4 -0
- package/dist/core/sample-step.d.ts +16 -0
- package/dist/core/sample-step.js +28 -0
- package/dist/core/source-check.d.ts +44 -0
- package/dist/core/source-check.js +126 -0
- package/dist/core/source-diagnostic.d.ts +1 -0
- package/dist/core/source-diagnostic.js +34 -0
- package/dist/core/support-budget.d.ts +2 -0
- package/dist/core/support-budget.js +6 -0
- package/dist/core/system.js +2 -0
- package/dist/core/wall.d.ts +6 -0
- package/dist/core/wall.js +23 -0
- package/dist/core/watch.js +4 -0
- package/dist/kernel/cdcl.d.ts +4 -0
- package/dist/kernel/cdcl.js +20 -5
- package/dist/kernel/kernel.d.ts +10 -0
- package/dist/kernel/kernel.js +56 -3
- package/dist/kernel/model-sequence.d.ts +2 -2
- package/dist/kernel/model-sequence.js +4 -3
- package/dist/kernel/model-values.d.ts +2 -0
- package/dist/kernel/model-values.js +60 -0
- package/dist/kernel/prove.d.ts +10 -0
- package/dist/kernel/prove.js +56 -8
- package/dist/kernel/prover-rows.d.ts +29 -0
- package/dist/kernel/prover-rows.js +114 -0
- package/dist/lean-kernel/emit.d.ts +39 -2
- package/dist/lean-kernel/emit.js +136 -24
- package/dist/lean-kernel/lean-terms.d.ts +1 -0
- package/dist/lean-kernel/lean-terms.js +13 -5
- package/dist/lean-kernel/library.js +4 -0
- package/dist/lean-kernel/qalpha.d.ts +7 -0
- package/dist/lean-kernel/qalpha.js +40 -0
- package/package.json +5 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { E } from './machine.js';
|
|
2
|
+
import type { CountDecl, CountInst, MapRead } from '../kernel/kernel.js';
|
|
3
|
+
export declare const zeroOne: (e: E) => boolean;
|
|
4
|
+
export declare function rangeInstances(decls: CountDecl[], reads: MapRead[], taken: Iterable<string>, present?: CountInst[]): CountInst[];
|
|
5
|
+
export declare function rangeViolations(decls: CountDecl[], reads: MapRead[], model: Record<string, number>): MapRead[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { countsForReads } from "./count-facts.js";
|
|
2
|
+
export const zeroOne = (e) => e.op === 'const' ? e.value === 0 || e.value === 1 : e.op === 'if' ? zeroOne(e.then) && zeroOne(e.else) : false;
|
|
3
|
+
export function rangeInstances(decls, reads, taken, present = []) {
|
|
4
|
+
const used = new Set(taken), out = [];
|
|
5
|
+
for (const i of present)
|
|
6
|
+
used.add(i.wit);
|
|
7
|
+
const had = new Set(present.filter(i => i.unit === -1 && i.terms.length === 1 && i.terms[0][0] === 1).map(i => i.terms[0][1]));
|
|
8
|
+
let n = 0;
|
|
9
|
+
for (const read of reads) {
|
|
10
|
+
if (had.has(read[0]))
|
|
11
|
+
continue;
|
|
12
|
+
const count = countsForReads(decls, [read])?.[0];
|
|
13
|
+
if (!count || !zeroOne(count.body))
|
|
14
|
+
continue;
|
|
15
|
+
let wit;
|
|
16
|
+
do
|
|
17
|
+
wit = `w$range$${n++}`;
|
|
18
|
+
while (used.has(wit));
|
|
19
|
+
used.add(wit);
|
|
20
|
+
out.push({ wit, below: count.below, terms: [[1, read[0]]], unit: -1 });
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
// Inspect only fully valued arithmetic bounds. Unassigned or unsupported
|
|
25
|
+
// terms are unknown, not evidence that a model violates a range.
|
|
26
|
+
export function rangeViolations(decls, reads, model) {
|
|
27
|
+
const value = (e) => {
|
|
28
|
+
switch (e.op) {
|
|
29
|
+
case 'const': return e.value;
|
|
30
|
+
case 'var': return model[e.name];
|
|
31
|
+
case 'add': {
|
|
32
|
+
const a = value(e.a), b = value(e.b);
|
|
33
|
+
return a === undefined || b === undefined ? undefined : a + b;
|
|
34
|
+
}
|
|
35
|
+
case 'mul': {
|
|
36
|
+
const a = value(e.a);
|
|
37
|
+
return a === undefined ? undefined : e.k * a;
|
|
38
|
+
}
|
|
39
|
+
case 'sub': {
|
|
40
|
+
const a = value(e.a), b = value(e.b);
|
|
41
|
+
return a === undefined || b === undefined ? undefined : Math.max(0, a - b);
|
|
42
|
+
}
|
|
43
|
+
case 'min':
|
|
44
|
+
case 'max': {
|
|
45
|
+
const a = value(e.a), b = value(e.b);
|
|
46
|
+
return a === undefined || b === undefined ? undefined : e.op === 'min' ? Math.min(a, b) : Math.max(a, b);
|
|
47
|
+
}
|
|
48
|
+
case 'get':
|
|
49
|
+
case 'if':
|
|
50
|
+
case 'prod':
|
|
51
|
+
case 'proj':
|
|
52
|
+
case 'tup': return undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return reads.filter(read => {
|
|
56
|
+
const v = model[read[0]];
|
|
57
|
+
if (v === undefined)
|
|
58
|
+
return false;
|
|
59
|
+
const count = countsForReads(decls, [read])?.[0];
|
|
60
|
+
if (!count || !zeroOne(count.body))
|
|
61
|
+
return false;
|
|
62
|
+
const bound = value(count.below);
|
|
63
|
+
return bound !== undefined && v > bound;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type C, type Machine } from '../machine.js';
|
|
2
|
+
import { type Path } from '../../kernel/kernel.js';
|
|
3
|
+
export declare function actionGuard(m: Machine, selector: string, value: number | undefined): C | undefined;
|
|
4
|
+
export declare function activeCarried(m: Machine, path: Path): Set<string>;
|
|
5
|
+
export declare function copiesRows(m: Machine, root: Path): boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Untrusted action/parameter proposals from the machine's own flag shapes.
|
|
2
|
+
import { any, same, n, walkOnce, x } from "../machine.js";
|
|
3
|
+
import { substC, substE, truth } from "../../kernel/kernel.js";
|
|
4
|
+
import { walkLive } from "./live-dependencies.js";
|
|
5
|
+
export function actionGuard(m, selector, value) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
const flags = Object.fromEntries(Object.entries(m.step.flags ?? {}).map(([name, q]) => [name, q.op === 'all' ? same(x(`?${name}`), n(1)) : q]));
|
|
9
|
+
const guards = [];
|
|
10
|
+
for (const q of Object.values(m.step.flags ?? {})) {
|
|
11
|
+
if (q.op === 'all')
|
|
12
|
+
continue;
|
|
13
|
+
let matches = false;
|
|
14
|
+
walkOnce(q, (o) => { if (o.op === '=' && [[o.a, o.b], [o.b, o.a]].some(([a, b]) => a.op === 'var' && a.name === selector && b.op === 'const' && b.value === value))
|
|
15
|
+
matches = true; });
|
|
16
|
+
if (matches)
|
|
17
|
+
guards.push(substC(q, { vars: {}, maps: {}, flags }));
|
|
18
|
+
}
|
|
19
|
+
return guards.length === 1 ? guards[0] : guards.length ? any(...guards) : undefined;
|
|
20
|
+
}
|
|
21
|
+
export function activeCarried(m, path) {
|
|
22
|
+
const out = new Set(), inputs = new Set(m.inputMaps ?? []);
|
|
23
|
+
for (const [name, q] of Object.entries(m.step.flags ?? {})) {
|
|
24
|
+
if (q.op !== 'all' || truth(same(x(`?${name}`), n(1)), path) !== true)
|
|
25
|
+
continue;
|
|
26
|
+
walkOnce(q.c, (o) => { if (o.op === 'get' && inputs.has(o.map))
|
|
27
|
+
out.add(o.map); });
|
|
28
|
+
}
|
|
29
|
+
if (!out.size && m.inputMaps?.[0])
|
|
30
|
+
out.add(m.inputMaps[0]);
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
// A live same-map read indexed by another input is a copy, unlike the
|
|
34
|
+
// unchanged per-member fallback. Its equal-row case may need both keys split.
|
|
35
|
+
export function copiesRows(m, root) {
|
|
36
|
+
const flags = {};
|
|
37
|
+
let copy = false;
|
|
38
|
+
for (const [name, c] of Object.entries(m.step.flags ?? {}))
|
|
39
|
+
flags[name] = c.op === 'all' ? same(x(`?${name}`), n(1)) : substC(c, { vars: {}, maps: {}, flags });
|
|
40
|
+
for (const [map, write] of Object.entries(m.step.maps ?? {})) {
|
|
41
|
+
if (!('each' in write))
|
|
42
|
+
continue;
|
|
43
|
+
walkLive(substE(write.value, { vars: {}, maps: {}, flags }), root, (o) => {
|
|
44
|
+
if (o.op !== 'get' || o.map !== map)
|
|
45
|
+
return;
|
|
46
|
+
walkOnce(o.key, (key) => { if (key.op === 'var' && key.name !== write.each && m.inputs.includes(key.name))
|
|
47
|
+
copy = true; });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return copy;
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type C } from '../machine.js';
|
|
2
|
+
import { type Goal, type Path, type Tree } from '../../kernel/kernel.js';
|
|
3
|
+
export declare function walkChoices(root: unknown, path: Path, visit: (value: any) => void): void;
|
|
4
|
+
export declare function booleanCandidates(g: Goal, root: Path, wits: Set<string>, extended?: boolean): {
|
|
5
|
+
c: C;
|
|
6
|
+
score: number;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const booleanCore: typeof booleanCoreImpl;
|
|
9
|
+
declare function booleanCoreImpl(g: Goal, root: Path, wits: Set<string>, until: number, trace: object[], options?: {
|
|
10
|
+
model?: boolean;
|
|
11
|
+
folded?: boolean;
|
|
12
|
+
extended?: boolean;
|
|
13
|
+
scalarGuards?: boolean;
|
|
14
|
+
deferCheck?: boolean;
|
|
15
|
+
}): Tree | undefined;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// Untrusted Boolean-core recipe: expose witness membership before unrelated
|
|
2
|
+
// conditional fields. Every terminal branch is an ordinary linear refutation.
|
|
3
|
+
import { same, walkOnce, x } from "../machine.js";
|
|
4
|
+
import { canon, columnTerm, facts, linear, truth } from "../../kernel/kernel.js";
|
|
5
|
+
import { scale, sub } from "../solver.js";
|
|
6
|
+
import { clock } from "../../kernel/prove.js";
|
|
7
|
+
import { walkLive } from "./live-dependencies.js";
|
|
8
|
+
import { foldPath } from "./fold-path.js";
|
|
9
|
+
import { closeKeyReads } from "./key-closure.js";
|
|
10
|
+
import { rebasePath } from "./rebase-path.js";
|
|
11
|
+
import { wallTree, check, refuteFast, grow, rowsAt } from "./ops.js";
|
|
12
|
+
// Unlike dependency slicing, proof-case discovery must still enter the
|
|
13
|
+
// operands of a comparison already forced true: its conditional columns
|
|
14
|
+
// can remain inconsistent until their own guards have been decided.
|
|
15
|
+
export function walkChoices(root, path, visit) {
|
|
16
|
+
const goals = new WeakSet(), conditions = new WeakSet();
|
|
17
|
+
const go = (value, condition = false) => {
|
|
18
|
+
const seen = condition ? conditions : goals;
|
|
19
|
+
if (!value || typeof value !== 'object' || seen.has(value))
|
|
20
|
+
return;
|
|
21
|
+
seen.add(value);
|
|
22
|
+
if (condition && ['not', 'and', 'or', '<', '<=', '='].includes(value.op) && truth(value, path) !== undefined)
|
|
23
|
+
return;
|
|
24
|
+
if (value.op === 'if') {
|
|
25
|
+
const chosen = truth(value.c, path);
|
|
26
|
+
if (chosen !== undefined) {
|
|
27
|
+
go(chosen ? value.then : value.else);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
visit(value);
|
|
31
|
+
go(value.c, true);
|
|
32
|
+
go(value.then);
|
|
33
|
+
go(value.else);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
visit(value);
|
|
37
|
+
for (const child of Array.isArray(value) ? value : Object.values(value))
|
|
38
|
+
go(child, condition);
|
|
39
|
+
};
|
|
40
|
+
go(root);
|
|
41
|
+
}
|
|
42
|
+
export function booleanCandidates(g, root, wits, extended = false) {
|
|
43
|
+
const walk = extended ? walkChoices : walkLive;
|
|
44
|
+
const chosen = new Map(), add = (c, score) => { if (truth(c, root) !== undefined)
|
|
45
|
+
return; const id = JSON.stringify(c), old = chosen.get(id); chosen.set(id, { c, score: score + (old?.score ?? 0) }); };
|
|
46
|
+
for (const h of g.hyps) {
|
|
47
|
+
let c = h;
|
|
48
|
+
while (c.op === 'not')
|
|
49
|
+
c = c.x;
|
|
50
|
+
if (c.op === '<' || c.op === '<=' || c.op === '=')
|
|
51
|
+
add(c, 1000);
|
|
52
|
+
}
|
|
53
|
+
walk(g.hyps, root, (o) => {
|
|
54
|
+
if (o.op === '=' && o.a.op === 'var' && o.b.op === 'var') {
|
|
55
|
+
const a = wits.has(o.a.name), b = wits.has(o.b.name);
|
|
56
|
+
if (!a && !b)
|
|
57
|
+
add(o, 10);
|
|
58
|
+
else if (a !== b)
|
|
59
|
+
add(o, 1500);
|
|
60
|
+
}
|
|
61
|
+
if ((o.op === '<' || o.op === '<=') && o.a.op === 'var' && o.b.op === 'var' && o.a.name !== o.b.name && !wits.has(o.a.name) && !wits.has(o.b.name))
|
|
62
|
+
add(o, extended ? 1400 : 750);
|
|
63
|
+
if (extended && ['<', '<=', '='].includes(o.op)) {
|
|
64
|
+
let left = false, right = false, witness = false;
|
|
65
|
+
walkLive(o.a, root, (e) => { if (e.op === 'get')
|
|
66
|
+
left = true; if (e.op === 'var' && wits.has(e.name))
|
|
67
|
+
witness = true; });
|
|
68
|
+
walkLive(o.b, root, (e) => { if (e.op === 'get')
|
|
69
|
+
right = true; if (e.op === 'var' && wits.has(e.name))
|
|
70
|
+
witness = true; });
|
|
71
|
+
if (left && right && witness)
|
|
72
|
+
add(o, 1000);
|
|
73
|
+
}
|
|
74
|
+
if (!['=', '<='].includes(o.op))
|
|
75
|
+
return;
|
|
76
|
+
// A lowered Boolean map write is still one membership predicate. Prefer
|
|
77
|
+
// its shared 0/1 value over independently splitting every internal guard.
|
|
78
|
+
const value = o.op === '=' && o.b.op === 'const' && o.b.value === 1 ? o.a : o.op === '<=' && o.a.op === 'const' && o.a.value === 1 ? o.b : undefined;
|
|
79
|
+
if (extended && value?.op === 'if' && value.then.op === 'const' && value.then.value === 1 && value.else.op === 'const' && value.else.value === 0) {
|
|
80
|
+
let hit = false;
|
|
81
|
+
walkOnce(value, (e) => { if (e.op === 'var' && wits.has(e.name))
|
|
82
|
+
hit = true; });
|
|
83
|
+
if (hit)
|
|
84
|
+
add(o, 1800);
|
|
85
|
+
}
|
|
86
|
+
const cell = o.op === '=' && o.a.op === 'get' && o.b.op === 'const' && o.b.value === 1 ? o.a : o.op === '<=' && o.a.op === 'const' && o.a.value === 1 && o.b.op === 'get' ? o.b : undefined;
|
|
87
|
+
if (!cell)
|
|
88
|
+
return;
|
|
89
|
+
let hit = false;
|
|
90
|
+
walkOnce(cell.key, (x) => { if (x.op === 'var' && wits.has(x.name))
|
|
91
|
+
hit = true; });
|
|
92
|
+
if (hit)
|
|
93
|
+
add(o, extended ? 1200 : o.op === '<=' ? 100 : 50);
|
|
94
|
+
});
|
|
95
|
+
// Equal witness keys are useful before splitting the two cells' values.
|
|
96
|
+
// Their equality is only a proposal: both key-order branches still check.
|
|
97
|
+
const cells = new Map();
|
|
98
|
+
walk(g.hyps, root, (o) => { if (o.op === 'get' && linear(o.key, root)) {
|
|
99
|
+
const xs = cells.get(o.map) ?? [];
|
|
100
|
+
if (!xs.some(k => JSON.stringify(k) === JSON.stringify(o.key)))
|
|
101
|
+
xs.push(o.key);
|
|
102
|
+
cells.set(o.map, xs);
|
|
103
|
+
} });
|
|
104
|
+
const mentions = (key) => { const out = new Set(); walkOnce(key, (o) => { if (o.op === 'var' && wits.has(o.name))
|
|
105
|
+
out.add(o.name); }); return out; };
|
|
106
|
+
for (const keys of cells.values())
|
|
107
|
+
for (let i = 0; i < keys.length; i++)
|
|
108
|
+
for (let j = i + 1; j < keys.length; j++) {
|
|
109
|
+
const a = keys[i], b = keys[j], wanted = mentions(a);
|
|
110
|
+
if ([...mentions(b)].some(w => wanted.has(w)))
|
|
111
|
+
add(same(a, b), 500);
|
|
112
|
+
}
|
|
113
|
+
return [...chosen.values()];
|
|
114
|
+
}
|
|
115
|
+
export const booleanCore = (...args) => wallTree('tree-reconstruction', () => booleanCoreImpl(...args));
|
|
116
|
+
function booleanCoreImpl(g, root, wits, until, trace, options = {}) {
|
|
117
|
+
const start = clock(), scalarGuards = options.scalarGuards ?? false, extended = options.extended ?? false;
|
|
118
|
+
// Lift the goal's own forced linear facts into the path, with a checked
|
|
119
|
+
// opposite branch for every cut. They need not consume the Boolean pool.
|
|
120
|
+
let pinned = new Map(root);
|
|
121
|
+
const prefix = [];
|
|
122
|
+
const pin = (split) => {
|
|
123
|
+
const id = canon(split);
|
|
124
|
+
if (pinned.get(id)?.holds === true)
|
|
125
|
+
return true;
|
|
126
|
+
if (clock() >= until)
|
|
127
|
+
return false;
|
|
128
|
+
const other = new Map(pinned).set(id, { lin: split, holds: false }), out = refuteFast(rowsAt(g, other), 256);
|
|
129
|
+
const no = out?.kind === 'refuted' ? { leaf: out.steps } : undefined;
|
|
130
|
+
if (!no || (!options.deferCheck && !check(g, no, other)))
|
|
131
|
+
return false;
|
|
132
|
+
prefix.push({ split, no });
|
|
133
|
+
pinned = new Map(pinned).set(id, { lin: split, holds: true });
|
|
134
|
+
return true;
|
|
135
|
+
};
|
|
136
|
+
for (let round = 0; round < 2 && clock() < until; round++)
|
|
137
|
+
for (const h of g.hyps)
|
|
138
|
+
for (const split of facts(h, pinned))
|
|
139
|
+
pin(split);
|
|
140
|
+
// Witness bounds and inactive scalar selectors can follow from the path
|
|
141
|
+
// without appearing as literal decisions. Prove these arithmetic guards
|
|
142
|
+
// before discovering candidates, so dead updates cannot crowd the pool.
|
|
143
|
+
const guards = new Map(), walk = scalarGuards ? walkChoices : walkLive;
|
|
144
|
+
walk(g.hyps, root, (o) => {
|
|
145
|
+
if (o.op === 'if')
|
|
146
|
+
walkOnce(o.c, (c) => {
|
|
147
|
+
if (!['<', '<=', '='].includes(c.op))
|
|
148
|
+
return;
|
|
149
|
+
let witness = false, plain = true;
|
|
150
|
+
walkOnce(c, (e) => { if (e.op === 'var' && wits.has(e.name))
|
|
151
|
+
witness = true; if (['get', 'if', 'sub', 'min', 'max', 'prod', 'tup', 'proj'].includes(e.op))
|
|
152
|
+
plain = false; });
|
|
153
|
+
if (plain && (scalarGuards || witness))
|
|
154
|
+
guards.set(JSON.stringify(c), c);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
for (const c of guards.values())
|
|
158
|
+
for (const split of facts(c, pinned)) {
|
|
159
|
+
if (scalarGuards && truth(c, pinned) !== undefined)
|
|
160
|
+
break;
|
|
161
|
+
if (!pin(split)) {
|
|
162
|
+
const inverse = scale(split, -1);
|
|
163
|
+
inverse['1'] = (inverse['1'] ?? 0) + 1;
|
|
164
|
+
pin(inverse);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const candidates = booleanCandidates(g, scalarGuards ? pinned : root, wits, extended).filter(({ c }) => truth(c, pinned) === undefined);
|
|
168
|
+
const selected = candidates.sort((a, b) => b.score - a.score).slice(0, 8), slots = [];
|
|
169
|
+
const expand = (c) => c.op === '=' ? [{ op: '<=', a: c.a, b: c.b }, { op: '<=', a: c.b, b: c.a }] : [c];
|
|
170
|
+
const cs = selected.flatMap(({ c }, slot) => { const parts = expand(c); slots.push(...parts.map(() => slot)); return parts; });
|
|
171
|
+
let nodes = 0, leaves = 0, last;
|
|
172
|
+
const go = (i, path, keysClosed = false, plan = cs) => {
|
|
173
|
+
if (clock() >= until)
|
|
174
|
+
return undefined;
|
|
175
|
+
nodes++;
|
|
176
|
+
const out = refuteFast(rowsAt(g, path), 1000);
|
|
177
|
+
if (out?.kind === 'refuted')
|
|
178
|
+
return { leaf: out.steps };
|
|
179
|
+
if (i === plan.length) {
|
|
180
|
+
leaves++;
|
|
181
|
+
const out = grow(g, path, { nodes: 0, until, units: true });
|
|
182
|
+
if ('tree' in out)
|
|
183
|
+
return out.tree;
|
|
184
|
+
last ??= { path: [...path], outcome: out.stuck, ...(options.model && 'witness' in out ? { model: out.witness, columns: Object.fromEntries(Object.keys(out.witness ?? {}).filter(name => name.startsWith('⟦')).slice(0, 8).map(name => [name, columnTerm(name)])) } : {}) };
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
if (extended && !keysClosed) {
|
|
188
|
+
let field = false;
|
|
189
|
+
walkOnce(plan[i], (o) => { if (o.op === 'get')
|
|
190
|
+
field = true; });
|
|
191
|
+
if (field) {
|
|
192
|
+
const reads = [];
|
|
193
|
+
walkChoices(g.hyps, path, (o) => { if (o.op === 'get')
|
|
194
|
+
reads.push({ map: o.map, key: o.key }); });
|
|
195
|
+
const begun = clock(), closed = closeKeyReads(g, path, reads, wits, until);
|
|
196
|
+
// Refresh only the unspent choice slots. Fold expression operands, not
|
|
197
|
+
// whole forced hypotheses, so their indicator structure stays visible.
|
|
198
|
+
const folded = new WeakMap(), fold = (e) => {
|
|
199
|
+
const found = folded.get(e);
|
|
200
|
+
if (found)
|
|
201
|
+
return found;
|
|
202
|
+
const out = foldPath({ name: 'candidate operand', hyps: [same(e, x('boolean$probe'))] }, closed.path).goal.hyps[0];
|
|
203
|
+
const result = out?.op === '=' ? out.a : e;
|
|
204
|
+
folded.set(e, result);
|
|
205
|
+
return result;
|
|
206
|
+
};
|
|
207
|
+
const fresh = new Map();
|
|
208
|
+
for (const candidate of booleanCandidates(g, closed.path, wits, true)) {
|
|
209
|
+
const c = candidate.c, normalized = c.op === '<' || c.op === '<=' || c.op === '=' ? { ...c, a: fold(c.a), b: fold(c.b) } : c;
|
|
210
|
+
if (truth(normalized, closed.path) !== undefined)
|
|
211
|
+
continue;
|
|
212
|
+
const id = JSON.stringify(normalized), old = fresh.get(id);
|
|
213
|
+
fresh.set(id, { c: normalized, score: Math.max(old?.score ?? 0, candidate.score) });
|
|
214
|
+
}
|
|
215
|
+
const remaining = Math.max(0, 8 - (slots[i] ?? 8)), refreshed = [...fresh.values()].sort((a, b) => b.score - a.score).slice(0, remaining).flatMap(({ c }) => expand(c));
|
|
216
|
+
let tree = go(0, closed.path, true, refreshed);
|
|
217
|
+
if (tree)
|
|
218
|
+
for (const cut of [...closed.cuts].reverse())
|
|
219
|
+
tree = { split: cut.split, yes: tree, no: cut.no };
|
|
220
|
+
trace.push({ stage: 'key-closure', facts: closed.cuts.length, ms: Math.round(clock() - begun), proposed: !!tree });
|
|
221
|
+
return tree;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const c = plan[i], known = truth(c, path);
|
|
225
|
+
if (known !== undefined)
|
|
226
|
+
return go(i + 1, path, keysClosed, plan);
|
|
227
|
+
if (c.op !== '<' && c.op !== '<=')
|
|
228
|
+
return undefined;
|
|
229
|
+
const a = linear(c.a, path), b = linear(c.b, path);
|
|
230
|
+
if (!a || !b)
|
|
231
|
+
return undefined;
|
|
232
|
+
const split = sub(a, b);
|
|
233
|
+
if (c.op === '<')
|
|
234
|
+
split['1'] = (split['1'] ?? 0) + 1;
|
|
235
|
+
const id = canon(split), yes = go(i + 1, new Map(path).set(id, { lin: split, holds: true }), keysClosed, plan), no = yes && go(i + 1, new Map(path).set(id, { lin: split, holds: false }), keysClosed, plan);
|
|
236
|
+
return yes && no ? { split, yes, no } : undefined;
|
|
237
|
+
};
|
|
238
|
+
let tree = go(0, pinned);
|
|
239
|
+
if (tree) {
|
|
240
|
+
const paths = [new Map(root)];
|
|
241
|
+
for (const p of prefix)
|
|
242
|
+
paths.push(new Map(paths.at(-1)).set(canon(p.split), { lin: p.split, holds: true }));
|
|
243
|
+
let removed = 0;
|
|
244
|
+
for (let i = prefix.length - 1; i >= 0; i--) {
|
|
245
|
+
const p = prefix[i], shorter = rebasePath(g, tree, paths[i + 1], paths[i], until);
|
|
246
|
+
if (shorter) {
|
|
247
|
+
tree = shorter;
|
|
248
|
+
removed++;
|
|
249
|
+
}
|
|
250
|
+
else
|
|
251
|
+
tree = { split: p.split, yes: tree, no: p.no };
|
|
252
|
+
}
|
|
253
|
+
trace.push({ stage: 'pin-prune', removed, kept: prefix.length - removed });
|
|
254
|
+
}
|
|
255
|
+
const accepted = !!tree && (options.deferCheck || check(g, tree, root)), checked = accepted && !options.deferCheck;
|
|
256
|
+
trace.push({ stage: 'boolean-core', facts: prefix.length, cuts: cs.length, nodes, leaves, ms: Math.round(clock() - start), checked, proposed: !!tree, deferred: !!options.deferCheck, ...(options.model ? { choices: cs.map(c => ({ op: c.op, ...('a' in c ? { a: JSON.stringify(c.a).slice(0, 180), b: JSON.stringify(c.b).slice(0, 180) } : {}) })) } : {}), ...(last ? { last } : {}) });
|
|
257
|
+
return accepted ? tree : undefined;
|
|
258
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Untrusted first split for a small count core: carried membership at the
|
|
2
|
+
// certificate's witness, before branching through large post-state terms.
|
|
3
|
+
import { n } from "../machine.js";
|
|
4
|
+
import { canon, linear, truth } from "../../kernel/kernel.js";
|
|
5
|
+
import { sub } from "../solver.js";
|
|
6
|
+
import { clock } from "../../kernel/prove.js";
|
|
7
|
+
import { walkLive } from "./live-dependencies.js";
|
|
8
|
+
import { check, grow } from "./ops.js";
|
|
9
|
+
export function carriedCase(g, root, maps, wits, until, trace) {
|
|
10
|
+
let cell;
|
|
11
|
+
walkLive(g.hyps, root, (o) => { if (!cell && o.op === 'get' && maps.includes(o.map) && o.key.op === 'var' && wits.has(o.key.name) && truth({ op: '<=', a: n(1), b: o }, root) === undefined)
|
|
12
|
+
cell = o; });
|
|
13
|
+
if (!cell)
|
|
14
|
+
return undefined;
|
|
15
|
+
const value = linear(cell, root);
|
|
16
|
+
if (!value)
|
|
17
|
+
return undefined;
|
|
18
|
+
const split = sub({ '1': 1 }, value), id = canon(split), started = clock();
|
|
19
|
+
const noPath = new Map(root).set(id, { lin: split, holds: false }), no = grow(g, noPath, { nodes: 0, until, units: true });
|
|
20
|
+
const yesPath = new Map(root).set(id, { lin: split, holds: true }), yes = 'tree' in no && clock() < until ? grow(g, yesPath, { nodes: 0, until, units: true }) : undefined;
|
|
21
|
+
const tree = 'tree' in no && yes && 'tree' in yes ? { split, yes: yes.tree, no: no.tree } : undefined, checked = !!tree && check(g, tree, root);
|
|
22
|
+
trace.push({ stage: 'carried-core', cell, ms: Math.round(clock() - started), no: 'tree' in no, yes: !!yes && 'tree' in yes, checked });
|
|
23
|
+
return checked ? tree : undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Goal, type LemmaCut, type Path, type Tree } from '../../kernel/kernel.js';
|
|
2
|
+
declare const stats: {
|
|
3
|
+
leafChecks: number;
|
|
4
|
+
leafHits: number;
|
|
5
|
+
leafFallbacks: number;
|
|
6
|
+
fullHyps: number;
|
|
7
|
+
sliceHyps: number;
|
|
8
|
+
independentChecks: number;
|
|
9
|
+
independentHits: number;
|
|
10
|
+
retargetChecks: number;
|
|
11
|
+
retargetHits: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const conditionalProofStats: () => Readonly<typeof stats>;
|
|
14
|
+
/** Keep exactly the hypotheses cited by base/product inputs, then relocate all
|
|
15
|
+
* inputs including square/product offsets. The unchanged kernel checks the
|
|
16
|
+
* sliced literal certificate; malformed and unused products are not dropped. */
|
|
17
|
+
export declare function slicedCheck(goal: Goal, tree: Tree, path: Path): boolean;
|
|
18
|
+
export declare function independentHit(goal: Goal, lemma: LemmaCut): boolean;
|
|
19
|
+
export declare function rememberIndependent(goal: Goal, lemma: LemmaCut): void;
|
|
20
|
+
export declare function retargetHit(lemma: LemmaCut, key: string): LemmaCut | undefined;
|
|
21
|
+
export declare function rememberRetarget(lemma: LemmaCut, key: string, result: LemmaCut): void;
|
|
22
|
+
export declare function targetIndex(goal: Goal, until: number): Map<string, number> | undefined;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Untrusted pre-check accelerators over immutable proof objects. No cached
|
|
2
|
+
// answer replaces checkMC/checkCountedLaws on the final emitted certificate.
|
|
3
|
+
import { canon, check, leafConstraintsReusing as rowsAt } from "../../kernel/kernel.js";
|
|
4
|
+
const stats = { leafChecks: 0, leafHits: 0, leafFallbacks: 0, fullHyps: 0, sliceHyps: 0, independentChecks: 0, independentHits: 0, retargetChecks: 0, retargetHits: 0 };
|
|
5
|
+
export const conditionalProofStats = () => ({ ...stats });
|
|
6
|
+
const pathKey = (path) => JSON.stringify([...path].map(([key, a]) => [key, a.holds, canon(a.lin)]));
|
|
7
|
+
const leaves = new WeakMap();
|
|
8
|
+
/** Keep exactly the hypotheses cited by base/product inputs, then relocate all
|
|
9
|
+
* inputs including square/product offsets. The unchanged kernel checks the
|
|
10
|
+
* sliced literal certificate; malformed and unused products are not dropped. */
|
|
11
|
+
export function slicedCheck(goal, tree, path) {
|
|
12
|
+
if (!('leaf' in tree))
|
|
13
|
+
return check(goal, tree, path);
|
|
14
|
+
let trees = leaves.get(goal);
|
|
15
|
+
if (!trees)
|
|
16
|
+
leaves.set(goal, trees = new WeakMap());
|
|
17
|
+
let paths = trees.get(tree);
|
|
18
|
+
if (!paths)
|
|
19
|
+
trees.set(tree, paths = new Map());
|
|
20
|
+
const key = pathKey(path), old = paths.get(key);
|
|
21
|
+
if (old !== undefined) {
|
|
22
|
+
stats.leafHits++;
|
|
23
|
+
return old;
|
|
24
|
+
}
|
|
25
|
+
stats.leafChecks++;
|
|
26
|
+
stats.fullHyps += goal.hyps.length;
|
|
27
|
+
let ok = false;
|
|
28
|
+
try {
|
|
29
|
+
const rows = rowsAt(goal, path), needed = new Set(), visited = new Set(), squares = tree.squares?.length ?? 0;
|
|
30
|
+
const mark = (i) => {
|
|
31
|
+
if (!Number.isSafeInteger(i) || i < 0)
|
|
32
|
+
throw new Error('invalid input');
|
|
33
|
+
if (visited.has(i))
|
|
34
|
+
return;
|
|
35
|
+
visited.add(i);
|
|
36
|
+
if (i < rows.length) {
|
|
37
|
+
const src = rows[i].src;
|
|
38
|
+
if (src && 'fact' in src)
|
|
39
|
+
needed.add(src.fact);
|
|
40
|
+
}
|
|
41
|
+
else if (i >= rows.length + squares) {
|
|
42
|
+
const product = tree.products?.[i - rows.length - squares];
|
|
43
|
+
if (!product)
|
|
44
|
+
throw new Error('invalid product');
|
|
45
|
+
mark(product[0]);
|
|
46
|
+
mark(product[1]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
for (const step of tree.leaf)
|
|
50
|
+
if (step.kind === 'input')
|
|
51
|
+
mark(step.index);
|
|
52
|
+
for (const [a, b] of tree.products ?? []) {
|
|
53
|
+
mark(a);
|
|
54
|
+
mark(b);
|
|
55
|
+
}
|
|
56
|
+
const small = { ...goal, hyps: [...needed].sort((a, b) => a - b).map(i => goal.hyps[i]) }, target = rowsAt(small, path), at = new Map();
|
|
57
|
+
stats.sliceHyps += small.hyps.length;
|
|
58
|
+
target.forEach((row, i) => { const id = canon(row.lin); if (!at.has(id))
|
|
59
|
+
at.set(id, i); });
|
|
60
|
+
const index = (i) => {
|
|
61
|
+
if (i >= rows.length)
|
|
62
|
+
return i - rows.length + target.length;
|
|
63
|
+
const moved = at.get(canon(rows[i].lin));
|
|
64
|
+
if (moved === undefined)
|
|
65
|
+
throw new Error('missing row');
|
|
66
|
+
return moved;
|
|
67
|
+
};
|
|
68
|
+
const moved = { ...tree, leaf: tree.leaf.map(s => s.kind === 'input' ? { ...s, index: index(s.index) } : s), ...(tree.products ? { products: tree.products.map(([a, b]) => [index(a), index(b)]) } : {}) };
|
|
69
|
+
ok = check(small, moved, path);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
ok = false;
|
|
73
|
+
}
|
|
74
|
+
// Slicing is an optimization, never a new rejection rule. In particular a
|
|
75
|
+
// naturality row may be supported by a hypothesis not otherwise cited.
|
|
76
|
+
if (!ok) {
|
|
77
|
+
stats.leafFallbacks++;
|
|
78
|
+
ok = check(goal, tree, path);
|
|
79
|
+
}
|
|
80
|
+
paths.set(key, ok);
|
|
81
|
+
return ok;
|
|
82
|
+
}
|
|
83
|
+
const independent = new WeakMap();
|
|
84
|
+
export function independentHit(goal, lemma) {
|
|
85
|
+
stats.independentChecks++;
|
|
86
|
+
if (!independent.get(goal)?.has(lemma))
|
|
87
|
+
return false;
|
|
88
|
+
stats.independentHits++;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
export function rememberIndependent(goal, lemma) {
|
|
92
|
+
let set = independent.get(goal);
|
|
93
|
+
if (!set)
|
|
94
|
+
independent.set(goal, set = new WeakSet());
|
|
95
|
+
set.add(lemma);
|
|
96
|
+
}
|
|
97
|
+
// The key includes target slice and matched hypothesis text, never target goal
|
|
98
|
+
// identity or unrelated scope atoms. Only fully mapped transports use this map.
|
|
99
|
+
const retargets = new WeakMap();
|
|
100
|
+
export function retargetHit(lemma, key) {
|
|
101
|
+
stats.retargetChecks++;
|
|
102
|
+
const old = retargets.get(lemma)?.get(key);
|
|
103
|
+
if (old)
|
|
104
|
+
stats.retargetHits++;
|
|
105
|
+
return old;
|
|
106
|
+
}
|
|
107
|
+
export function rememberRetarget(lemma, key, result) {
|
|
108
|
+
let map = retargets.get(lemma);
|
|
109
|
+
if (!map)
|
|
110
|
+
retargets.set(lemma, map = new Map());
|
|
111
|
+
map.set(key, result);
|
|
112
|
+
}
|
|
113
|
+
const indices = new WeakMap();
|
|
114
|
+
export function targetIndex(goal, until) {
|
|
115
|
+
if (!(performance.now() < until))
|
|
116
|
+
return undefined;
|
|
117
|
+
let at = indices.get(goal);
|
|
118
|
+
if (!at) {
|
|
119
|
+
at = new Map();
|
|
120
|
+
for (const [i, h] of goal.hyps.entries()) {
|
|
121
|
+
if (!(performance.now() < until))
|
|
122
|
+
return undefined;
|
|
123
|
+
const key = JSON.stringify(h);
|
|
124
|
+
if (!at.has(key))
|
|
125
|
+
at.set(key, i);
|
|
126
|
+
}
|
|
127
|
+
indices.set(goal, at);
|
|
128
|
+
}
|
|
129
|
+
return at;
|
|
130
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Goal, type LemmaCut, type Path, type Tree } from '../../kernel/kernel.js';
|
|
2
|
+
import { type Lin } from '../solver.js';
|
|
3
|
+
export declare function admitConditionalCut(goal: Goal, source: Goal, tree: Tree, from: Path, scope: Path, cut: Lin, available: LemmaCut[], until: number): LemmaCut | undefined;
|
|
4
|
+
/** Emit an ordinary tree at scope, inlining only active cuts whose exact rows
|
|
5
|
+
* the source proof needs. The returned tree is kernel-checked without lemmas. */
|
|
6
|
+
export declare function inlineConditionalCuts(goal: Goal, source: Goal, tree: Tree, from: Path, scope: Path, lemmas: LemmaCut[], until: number, diagnose?: (event: object) => void): Tree | undefined;
|