gdp-wired 0.48.0 → 0.49.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 +2 -2
- package/dist/core/bmc.js +10 -7
- package/dist/core/check.js +7 -2
- package/dist/core/count-attempt-work.d.ts +29 -0
- package/dist/core/count-attempt-work.js +96 -0
- package/dist/core/count-boolean-partition.d.ts +5 -0
- package/dist/core/count-boolean-partition.js +47 -0
- package/dist/core/count-bounded-quotient.d.ts +2 -0
- package/dist/core/count-bounded-quotient.js +13 -0
- package/dist/core/count-case-compose.d.ts +20 -0
- package/dist/core/count-case-compose.js +289 -0
- package/dist/core/count-cases.js +3 -2
- package/dist/core/count-cert-rename.d.ts +10 -0
- package/dist/core/count-cert-rename.js +69 -0
- package/dist/core/count-cert-transport.d.ts +10 -2
- package/dist/core/count-cert-transport.js +60 -9
- package/dist/core/count-certificate-minimize.d.ts +57 -0
- package/dist/core/count-certificate-minimize.js +263 -0
- package/dist/core/count-closed-family.d.ts +32 -0
- package/dist/core/count-closed-family.js +143 -0
- package/dist/core/count-closing-budget.d.ts +10 -0
- package/dist/core/count-closing-budget.js +49 -0
- package/dist/core/count-closing-needs.d.ts +5 -0
- package/dist/core/count-closing-needs.js +9 -0
- package/dist/core/count-component-budget.d.ts +5 -0
- package/dist/core/count-component-budget.js +9 -0
- package/dist/core/count-copy-shape.d.ts +11 -0
- package/dist/core/count-copy-shape.js +40 -0
- package/dist/core/count-disjoint-funding.d.ts +75 -0
- package/dist/core/count-disjoint-funding.js +284 -0
- package/dist/core/count-emitter-frame-pool.d.ts +23 -0
- package/dist/core/count-emitter-frame-pool.js +87 -0
- package/dist/core/count-final-step.d.ts +5 -0
- package/dist/core/count-final-step.js +20 -0
- package/dist/core/count-fixed-frame.d.ts +4 -0
- package/dist/core/count-fixed-frame.js +30 -0
- package/dist/core/count-frames.d.ts +25 -0
- package/dist/core/count-frames.js +118 -0
- package/dist/core/count-frozen-guard.d.ts +2 -0
- package/dist/core/count-frozen-guard.js +31 -0
- package/dist/core/count-generation-phase.d.ts +7 -0
- package/dist/core/count-generation-phase.js +33 -0
- package/dist/core/count-guard-composition.d.ts +12 -0
- package/dist/core/count-guard-composition.js +48 -0
- package/dist/core/count-guard-context.d.ts +11 -0
- package/dist/core/count-guard-context.js +50 -0
- package/dist/core/count-guard-facts.d.ts +50 -0
- package/dist/core/count-guard-facts.js +97 -0
- package/dist/core/count-guard-proposals.d.ts +7 -0
- package/dist/core/count-guard-proposals.js +106 -0
- package/dist/core/count-guard-shape.d.ts +18 -0
- package/dist/core/count-guard-shape.js +100 -0
- package/dist/core/count-guard-tree.d.ts +17 -0
- package/dist/core/count-guard-tree.js +125 -0
- package/dist/core/count-leader-facts.d.ts +10 -0
- package/dist/core/count-leader-facts.js +52 -0
- package/dist/core/count-leader.d.ts +10 -0
- package/dist/core/count-leader.js +331 -0
- package/dist/core/count-lemma-transport.d.ts +8 -0
- package/dist/core/count-lemma-transport.js +47 -0
- package/dist/core/count-lifted-budget.d.ts +54 -0
- package/dist/core/count-lifted-budget.js +97 -0
- package/dist/core/count-lifted-copy.d.ts +3 -0
- package/dist/core/count-lifted-copy.js +166 -0
- package/dist/core/count-lifted-increment.d.ts +3 -0
- package/dist/core/count-lifted-increment.js +146 -0
- package/dist/core/count-lifted-load.d.ts +5 -0
- package/dist/core/count-lifted-load.js +179 -0
- package/dist/core/count-lifted-prerequisite.d.ts +14 -0
- package/dist/core/count-lifted-prerequisite.js +53 -0
- package/dist/core/count-lifted-replacement.d.ts +3 -0
- package/dist/core/count-lifted-replacement.js +540 -0
- package/dist/core/count-lifted-shape.d.ts +63 -0
- package/dist/core/count-lifted-shape.js +115 -0
- package/dist/core/count-lifted-strategy.d.ts +7 -0
- package/dist/core/count-lifted-strategy.js +226 -0
- package/dist/core/count-lifted-transports.d.ts +32 -0
- package/dist/core/count-lifted-transports.js +293 -0
- package/dist/core/count-load-shape.d.ts +17 -0
- package/dist/core/count-load-shape.js +67 -0
- package/dist/core/count-minimal-view.d.ts +26 -0
- package/dist/core/count-minimal-view.js +46 -0
- package/dist/core/count-operation-observation.d.ts +9 -0
- package/dist/core/count-operation-observation.js +22 -0
- package/dist/core/count-operation-order.d.ts +5 -0
- package/dist/core/count-operation-order.js +4 -0
- package/dist/core/count-phase.d.ts +9 -0
- package/dist/core/count-phase.js +127 -0
- package/dist/core/count-premise-search.d.ts +9 -0
- package/dist/core/count-premise-search.js +41 -0
- package/dist/core/count-premise-view.d.ts +19 -0
- package/dist/core/count-premise-view.js +220 -0
- package/dist/core/count-prerequisite-components.d.ts +67 -0
- package/dist/core/count-prerequisite-components.js +239 -0
- package/dist/core/count-prerequisite-memory.d.ts +24 -0
- package/dist/core/count-prerequisite-memory.js +37 -0
- package/dist/core/count-prerequisite-plan.d.ts +12 -0
- package/dist/core/count-prerequisite-plan.js +88 -0
- package/dist/core/count-primitive-budget.d.ts +1 -0
- package/dist/core/count-primitive-budget.js +8 -0
- package/dist/core/count-project-free.d.ts +3 -0
- package/dist/core/count-project-free.js +24 -0
- package/dist/core/count-project-witness.d.ts +4 -0
- package/dist/core/count-project-witness.js +48 -0
- package/dist/core/count-proof-rescope.d.ts +14 -0
- package/dist/core/count-proof-rescope.js +71 -0
- package/dist/core/count-proof-scope.d.ts +68 -0
- package/dist/core/count-proof-scope.js +333 -0
- package/dist/core/count-prune-owned-root.d.ts +5 -0
- package/dist/core/count-prune-owned-root.js +27 -0
- package/dist/core/count-query-context.d.ts +3 -0
- package/dist/core/count-query-context.js +7 -0
- package/dist/core/count-query.d.ts +15 -0
- package/dist/core/count-query.js +59 -0
- package/dist/core/count-quorum-leaf.d.ts +9 -0
- package/dist/core/count-quorum-leaf.js +38 -0
- package/dist/core/count-reachability-budget.d.ts +1 -0
- package/dist/core/count-reachability-budget.js +7 -0
- package/dist/core/count-reachability-reconcile.d.ts +11 -0
- package/dist/core/count-reachability-reconcile.js +19 -0
- package/dist/core/count-reachability.d.ts +50 -0
- package/dist/core/count-reachability.js +351 -0
- package/dist/core/count-rebase-path.d.ts +9 -0
- package/dist/core/count-rebase-path.js +68 -0
- package/dist/core/count-recipe-context.d.ts +45 -0
- package/dist/core/count-recipe-context.js +71 -0
- package/dist/core/count-recipe-controller.d.ts +115 -0
- package/dist/core/count-recipe-controller.js +417 -0
- package/dist/core/count-recipe-graph.d.ts +36 -0
- package/dist/core/count-recipe-graph.js +211 -0
- package/dist/core/count-recovery/conditional-check-cache.js +3 -2
- package/dist/core/count-recovery/conditional-cuts.js +5 -4
- package/dist/core/count-recovery/conditional-proof.d.ts +37 -3
- package/dist/core/count-recovery/conditional-proof.js +72 -30
- package/dist/core/count-recovery/derivability-closure.js +2 -1
- package/dist/core/count-recovery/guard-cases.js +2 -1
- package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
- package/dist/core/count-recovery/reframe-tree.js +24 -0
- package/dist/core/count-recovery/replay-linear-skeleton.d.ts +2 -0
- package/dist/core/count-recovery/replay-linear-skeleton.js +28 -0
- package/dist/core/count-recovery/row-cases.js +2 -1
- package/dist/core/count-rejection-budget.d.ts +8 -0
- package/dist/core/count-rejection-budget.js +15 -0
- package/dist/core/count-replacement.d.ts +5 -0
- package/dist/core/count-replacement.js +129 -0
- package/dist/core/count-replay-diagnostic.d.ts +21 -0
- package/dist/core/count-replay-diagnostic.js +49 -0
- package/dist/core/count-replay-skeleton.d.ts +4 -0
- package/dist/core/count-replay-skeleton.js +28 -0
- package/dist/core/count-rescope-funding.d.ts +3 -0
- package/dist/core/count-rescope-funding.js +17 -0
- package/dist/core/count-restrictions.d.ts +11 -0
- package/dist/core/count-restrictions.js +31 -0
- package/dist/core/count-retry-budget.d.ts +67 -0
- package/dist/core/count-retry-budget.js +114 -0
- package/dist/core/count-retry-round.d.ts +24 -0
- package/dist/core/count-retry-round.js +44 -0
- package/dist/core/count-row-agreement.d.ts +35 -0
- package/dist/core/count-row-agreement.js +270 -0
- package/dist/core/count-row-aliases.d.ts +3 -0
- package/dist/core/count-row-aliases.js +59 -0
- package/dist/core/count-row-composition.d.ts +6 -0
- package/dist/core/count-row-composition.js +55 -0
- package/dist/core/count-row-copy-linear.d.ts +4 -0
- package/dist/core/count-row-copy-linear.js +83 -0
- package/dist/core/count-row-copy.d.ts +4 -0
- package/dist/core/count-row-copy.js +94 -0
- package/dist/core/count-row-policy.d.ts +3 -0
- package/dist/core/count-row-policy.js +56 -0
- package/dist/core/count-row-reindex.d.ts +11 -0
- package/dist/core/count-row-reindex.js +126 -0
- package/dist/core/count-row-support.d.ts +9 -0
- package/dist/core/count-row-support.js +42 -0
- package/dist/core/count-row-symmetry.d.ts +7 -0
- package/dist/core/count-row-symmetry.js +100 -0
- package/dist/core/count-scope-hyps.d.ts +2 -0
- package/dist/core/count-scope-hyps.js +163 -0
- package/dist/core/count-scope-row-reuse.d.ts +3 -0
- package/dist/core/count-scope-row-reuse.js +92 -0
- package/dist/core/count-search-allowance.d.ts +1 -0
- package/dist/core/count-search-allowance.js +17 -0
- package/dist/core/count-stabilize-tree.d.ts +9 -0
- package/dist/core/count-stabilize-tree.js +35 -0
- package/dist/core/count-stage-trace.d.ts +8 -0
- package/dist/core/count-stage-trace.js +45 -0
- package/dist/core/count-strategies.d.ts +16 -0
- package/dist/core/count-strategies.js +155 -0
- package/dist/core/count-strategy-premises.d.ts +5 -0
- package/dist/core/count-strategy-premises.js +14 -0
- package/dist/core/count-strategy.d.ts +41 -0
- package/dist/core/count-strategy.js +76 -0
- package/dist/core/count-support.js +3 -2
- package/dist/core/count-tier-budget.d.ts +14 -0
- package/dist/core/count-tier-budget.js +64 -0
- package/dist/core/count-unwritten-prefix.d.ts +24 -0
- package/dist/core/count-unwritten-prefix.js +97 -0
- package/dist/core/count-write-shape.d.ts +15 -0
- package/dist/core/count-write-shape.js +73 -0
- package/dist/core/counts.d.ts +37 -13
- package/dist/core/counts.js +990 -127
- package/dist/core/cycles.js +5 -4
- package/dist/core/cyclic.js +11 -10
- package/dist/core/data.js +16 -15
- package/dist/core/dsl-deadline.d.ts +3 -0
- package/dist/core/dsl-deadline.js +27 -0
- package/dist/core/dsl.d.ts +9 -0
- package/dist/core/dsl.js +156 -51
- package/dist/core/evaluation-admission.d.ts +1 -0
- package/dist/core/evaluation-admission.js +3 -0
- package/dist/core/exists.d.ts +6 -1
- package/dist/core/exists.js +51 -9
- package/dist/core/field-laws.d.ts +3 -1
- package/dist/core/field-laws.js +140 -2
- package/dist/core/finite-houdini.d.ts +6 -0
- package/dist/core/finite-houdini.js +63 -21
- package/dist/core/finite-tiny.js +95 -67
- package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
- package/dist/core/fresh.js +5 -1
- package/dist/core/infer.js +45 -30
- package/dist/core/kind.js +2 -1
- package/dist/core/lemma-cuts.js +11 -10
- package/dist/core/linear-admission.d.ts +14 -0
- package/dist/core/linear-admission.js +151 -0
- package/dist/core/machine.d.ts +5 -2
- package/dist/core/machine.js +105 -31
- package/dist/core/meter.d.ts +22 -0
- package/dist/core/meter.js +34 -0
- package/dist/core/nonterm.js +4 -3
- package/dist/core/prover-row-budget.d.ts +3 -0
- package/dist/core/prover-row-budget.js +106 -0
- package/dist/core/quorum-laws.d.ts +21 -1
- package/dist/core/quorum-laws.js +27 -3
- package/dist/core/rationals.js +3 -2
- package/dist/core/rejection-discovery.d.ts +34 -0
- package/dist/core/rejection-discovery.js +36 -0
- package/dist/core/rejection-stage.d.ts +39 -0
- package/dist/core/rejection-stage.js +205 -0
- package/dist/core/request-quotient.d.ts +8 -0
- package/dist/core/request-quotient.js +299 -0
- package/dist/core/row-agreement-shape.d.ts +15 -0
- package/dist/core/row-agreement-shape.js +68 -0
- package/dist/core/runtime-wall.d.ts +2 -0
- package/dist/core/search-policy.d.ts +15 -0
- package/dist/core/search-policy.js +68 -0
- package/dist/core/solver.d.ts +1 -1
- package/dist/core/solver.js +40 -6
- package/dist/core/step-work.d.ts +12 -0
- package/dist/core/step-work.js +14 -0
- package/dist/core/strategy-premises.d.ts +8 -0
- package/dist/core/strategy-premises.js +64 -0
- package/dist/core/system.js +4 -3
- package/dist/core/table-admission.d.ts +1 -0
- package/dist/core/table-admission.js +3 -0
- package/dist/core/trace-clock.d.ts +3 -0
- package/dist/core/trace-clock.js +16 -0
- package/dist/core/transfer.js +3 -2
- package/dist/core/translate.js +16 -3
- package/dist/core/wall.d.ts +6 -1
- package/dist/core/wall.js +23 -9
- package/dist/core/watch.d.ts +1 -1
- package/dist/core/watch.js +13 -4
- package/dist/core/work-admission.d.ts +164 -0
- package/dist/core/work-admission.js +418 -0
- package/dist/core/work-amount.d.ts +21 -0
- package/dist/core/work-amount.js +80 -0
- package/dist/core/work-collections.d.ts +11 -0
- package/dist/core/work-collections.js +198 -0
- package/dist/core/work-kinds.d.ts +11 -0
- package/dist/core/work-kinds.js +9 -0
- package/dist/core/work-meter.d.ts +8 -0
- package/dist/core/work-meter.js +83 -0
- package/dist/core/work-observe.d.ts +12 -0
- package/dist/core/work-observe.js +39 -0
- package/dist/core/work-profile.d.ts +10 -0
- package/dist/core/work-profile.js +21 -0
- package/dist/core/work-refusal.d.ts +1 -0
- package/dist/core/work-refusal.js +6 -0
- package/dist/interchange/format.js +2 -0
- package/dist/kernel/cdcl.js +93 -40
- package/dist/kernel/epr.js +23 -8
- package/dist/kernel/kernel.d.ts +47 -1
- package/dist/kernel/kernel.js +417 -68
- package/dist/kernel/prove.d.ts +49 -3
- package/dist/kernel/prove.js +468 -122
- package/dist/kernel/prover-rows.d.ts +1 -0
- package/dist/kernel/prover-rows.js +12 -1
- package/dist/kernel/reader.d.ts +1 -1
- package/dist/kernel/reader.js +57 -12
- package/dist/kernel/simplex.js +9 -2
- package/dist/lean-kernel/emit.d.ts +9 -1
- package/dist/lean-kernel/emit.js +144 -22
- package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
- package/dist/lean-kernel/legacy-family-library.js +5 -0
- package/dist/lean-kernel/library.js +3 -3
- package/package.json +1 -1
package/dist/core/finite-tiny.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
import { traceNow as countedTraceNow } from "./wall.js";
|
|
1
2
|
// UNTRUSTED relative-CTI proposals, not a proof, finite cover, or drop decision.
|
|
2
3
|
// The consumer MUST independently check m.pre, ALL m.facts, the WHOLE current
|
|
3
4
|
// family, the source interpreter's enabled step, and each reported post-law. This module owns no
|
|
4
5
|
// solver/kernel policy and never extends the enclosing cooperative wall.
|
|
5
|
-
import { cpair, cunpair, walk } from "./machine.js";
|
|
6
|
+
import { cpair, cunpair, hasFinite, walk, compileFunction } from "./machine.js";
|
|
6
7
|
import { checkWall, WallExpired } from "./wall.js";
|
|
8
|
+
import { tinyNode, tinyTerm, tinyBlock } from "./work-observe.js";
|
|
9
|
+
import { completeWorkProfile } from "./work-profile.js";
|
|
10
|
+
// Only closed generated operators enter this helper. Its lexical tick counts
|
|
11
|
+
// an executed predicate node, interval binding or transition binding; native
|
|
12
|
+
// short-circuit branches that were not executed are not charged.
|
|
13
|
+
const tinyPrefix = completeWorkProfile.enabled ? '__tinyWork();' : '';
|
|
14
|
+
const tinyExpression = (code) => completeWorkProfile.enabled ? `(__tinyWork(),${code})` : code;
|
|
15
|
+
const originalSize = (code) => code.length - (code.split('(__tinyWork(),').length - 1) * ('(__tinyWork(),'.length + 1);
|
|
16
|
+
const tinyCheck = (phase) => { tinyTerm(); checkWall(phase); };
|
|
17
|
+
function tinyNative(body) {
|
|
18
|
+
if (!completeWorkProfile.enabled)
|
|
19
|
+
return compileFunction(['v', 'd'], body);
|
|
20
|
+
const code = tinyPrefix + body;
|
|
21
|
+
const maximum = code.split('__tinyWork()').length - 1;
|
|
22
|
+
const execute = compileFunction(['v', 'd', '__tinyWork'], code);
|
|
23
|
+
return ((v, d) => tinyBlock(maximum, () => execute(v, d, tinyTerm)));
|
|
24
|
+
}
|
|
7
25
|
const unique = (xs) => [...new Set(xs)];
|
|
8
26
|
const conjunction = (xs) => {
|
|
9
27
|
if (xs.includes(false))
|
|
@@ -22,7 +40,7 @@ const dependencyCache = new WeakMap();
|
|
|
22
40
|
const depsOf = (p) => {
|
|
23
41
|
if (typeof p === 'boolean')
|
|
24
42
|
return [];
|
|
25
|
-
|
|
43
|
+
tinyCheck('tiny dependencies');
|
|
26
44
|
const hit = dependencyCache.get(p);
|
|
27
45
|
if (hit)
|
|
28
46
|
return hit;
|
|
@@ -72,7 +90,7 @@ class Compiler {
|
|
|
72
90
|
ref(t) { return `t${t.id}`; }
|
|
73
91
|
slot(i) { const vs = this.slots[i].values; return this.term(`v[${i}]`, [], Math.min(...vs), Math.max(...vs), [i]); }
|
|
74
92
|
binary(op, a, b) {
|
|
75
|
-
|
|
93
|
+
tinyCheck('tiny arithmetic compile');
|
|
76
94
|
const finish = (t) => {
|
|
77
95
|
t.arithmetic = op;
|
|
78
96
|
if (a.values && b.values && a.values.length * b.values.length <= 256)
|
|
@@ -105,7 +123,7 @@ class Compiler {
|
|
|
105
123
|
throw new Unsupported('nonconstant tuple');
|
|
106
124
|
}
|
|
107
125
|
compare(cmp, a, b) {
|
|
108
|
-
|
|
126
|
+
tinyCheck('tiny comparison compile');
|
|
109
127
|
if (cmp === '=') {
|
|
110
128
|
if (a.id === b.id)
|
|
111
129
|
return true;
|
|
@@ -158,7 +176,7 @@ class Compiler {
|
|
|
158
176
|
return out;
|
|
159
177
|
}
|
|
160
178
|
expression(e, env, post = false, stack = []) {
|
|
161
|
-
|
|
179
|
+
tinyCheck('tiny compile expression');
|
|
162
180
|
if (stack.length > 48)
|
|
163
181
|
throw new Unsupported('recursive count/flag');
|
|
164
182
|
switch (e.op) {
|
|
@@ -202,7 +220,7 @@ class Compiler {
|
|
|
202
220
|
const keys = key.values ?? Array.from({ length: key.hi - key.lo + 1 }, (_, i) => key.lo + i);
|
|
203
221
|
let out = this.read(e.map, keys.at(-1), env, post, stack);
|
|
204
222
|
for (const k of keys.slice(0, -1).reverse()) {
|
|
205
|
-
|
|
223
|
+
tinyCheck('tiny dynamic reads');
|
|
206
224
|
out = this.conditional(this.compare('=', key, this.constant(k)), this.read(e.map, k, env, post, stack), out);
|
|
207
225
|
}
|
|
208
226
|
return out;
|
|
@@ -212,7 +230,7 @@ class Compiler {
|
|
|
212
230
|
}
|
|
213
231
|
}
|
|
214
232
|
read(map, key, env, post, stack) {
|
|
215
|
-
|
|
233
|
+
tinyCheck('tiny compile read');
|
|
216
234
|
const id = JSON.stringify([map, key, post, this.environmentKey(env)]);
|
|
217
235
|
const hit = this.reads.get(id);
|
|
218
236
|
if (hit)
|
|
@@ -232,7 +250,7 @@ class Compiler {
|
|
|
232
250
|
throw new Unsupported('nonconstant/large count bound');
|
|
233
251
|
let out = this.constant(0);
|
|
234
252
|
for (let k = 0; k < bound.hi; k++) {
|
|
235
|
-
|
|
253
|
+
tinyCheck('tiny count expansion');
|
|
236
254
|
out = this.binary('add', out, this.expression(d.body, { ...at, [d.key]: k }, post, [...stack, `count:${map}`]));
|
|
237
255
|
}
|
|
238
256
|
return out;
|
|
@@ -256,7 +274,7 @@ class Compiler {
|
|
|
256
274
|
throw new Unsupported(`unknown map ${map}`);
|
|
257
275
|
}
|
|
258
276
|
condition(c, env, post = false, stack = []) {
|
|
259
|
-
|
|
277
|
+
tinyCheck('tiny compile predicate');
|
|
260
278
|
if (stack.length > 48)
|
|
261
279
|
throw new Unsupported('recursive count/flag');
|
|
262
280
|
switch (c.op) {
|
|
@@ -289,21 +307,24 @@ class Compiler {
|
|
|
289
307
|
}
|
|
290
308
|
return value;
|
|
291
309
|
}
|
|
292
|
-
case 'all':
|
|
310
|
+
case 'all':
|
|
311
|
+
if (c.finite !== undefined)
|
|
312
|
+
throw new Unsupported('finite sort quantifier: exact enumeration is not supported by the tiny compiler');
|
|
313
|
+
return conjunction(bindings([c.key, ...c.keys ?? []], this.binders, env).map(at => this.condition(c.c, at, post, stack)));
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
predicateCode(p, rank, used, polarity = true) {
|
|
296
|
-
|
|
317
|
+
tinyCheck('tiny predicate code');
|
|
297
318
|
if (typeof p === 'boolean')
|
|
298
|
-
return String(p === polarity);
|
|
319
|
+
return tinyExpression(String(p === polarity));
|
|
299
320
|
if (p.op === 'not')
|
|
300
|
-
return this.predicateCode(p.x, rank, used, !polarity);
|
|
321
|
+
return tinyExpression(this.predicateCode(p.x, rank, used, !polarity));
|
|
301
322
|
if (p.op === 'and' || p.op === 'or')
|
|
302
|
-
return '(' + p.xs.map(x => this.predicateCode(x, rank, used, polarity)).join((p.op === 'and') === polarity ? '&&' : '||') + ')';
|
|
323
|
+
return tinyExpression('(' + p.xs.map(x => this.predicateCode(x, rank, used, polarity)).join((p.op === 'and') === polarity ? '&&' : '||') + ')');
|
|
303
324
|
used.push(p.a, p.b);
|
|
304
325
|
const ds = unique([...p.a.deps, ...p.b.deps]), ready = rank ? Math.max(-1, ...ds.map(i => rank[i])) + 1 : 0;
|
|
305
326
|
const test = `(${this.ref(p.a)}${p.cmp === '=' ? '===' : p.cmp}${this.ref(p.b)})`;
|
|
306
|
-
return `(${rank && ready > 0 ? `d<${ready}||` : ''}${polarity ? test : '!' + test})
|
|
327
|
+
return tinyExpression(`(${rank && ready > 0 ? `d<${ready}||` : ''}${polarity ? test : '!' + test})`);
|
|
307
328
|
}
|
|
308
329
|
// Three-valued interval truth: -1=false, 0=unknown, 1=true. Only a
|
|
309
330
|
// definitely true target rules out its negation; intersecting bounds stay
|
|
@@ -312,14 +333,14 @@ class Compiler {
|
|
|
312
333
|
const lines = [], ranges = new Map(), truths = new WeakMap();
|
|
313
334
|
let chars = 0, next = 0;
|
|
314
335
|
const emit = (line) => {
|
|
315
|
-
|
|
316
|
-
chars += line
|
|
336
|
+
tinyCheck('tiny interval code');
|
|
337
|
+
chars += originalSize(line);
|
|
317
338
|
if (chars > 65_536)
|
|
318
339
|
throw new Unsupported('large interval screen');
|
|
319
|
-
lines.push(line);
|
|
340
|
+
lines.push(tinyPrefix + line);
|
|
320
341
|
};
|
|
321
342
|
const range = (t) => {
|
|
322
|
-
|
|
343
|
+
tinyCheck('tiny interval term');
|
|
323
344
|
if (t.lo < 0 || t.hi < t.lo)
|
|
324
345
|
throw new Unsupported('non-natural interval');
|
|
325
346
|
const hit = ranges.get(t.id);
|
|
@@ -363,7 +384,7 @@ class Compiler {
|
|
|
363
384
|
return out;
|
|
364
385
|
};
|
|
365
386
|
const truth = (q) => {
|
|
366
|
-
|
|
387
|
+
tinyCheck('tiny interval predicate');
|
|
367
388
|
if (typeof q === 'boolean')
|
|
368
389
|
return q ? '1' : '-1';
|
|
369
390
|
const hit = truths.get(q);
|
|
@@ -390,37 +411,37 @@ class Compiler {
|
|
|
390
411
|
const result = truth(p);
|
|
391
412
|
emit(`return ${result}!==1;`);
|
|
392
413
|
// oxlint-disable-next-line typescript/no-implied-eval
|
|
393
|
-
return
|
|
414
|
+
return tinyNative(lines.join(''));
|
|
394
415
|
}
|
|
395
416
|
compileValues(values, order) {
|
|
396
|
-
|
|
417
|
+
tinyCheck('tiny transition code');
|
|
397
418
|
const rank = order ? this.slots.map((_, i) => order.indexOf(i)) : undefined;
|
|
398
419
|
const seen = new Set(), lines = [];
|
|
399
420
|
let chars = 0;
|
|
400
421
|
const emit = (t) => {
|
|
401
|
-
|
|
422
|
+
tinyCheck('tiny transition terms');
|
|
402
423
|
if (seen.has(t.id))
|
|
403
424
|
return;
|
|
404
425
|
seen.add(t.id);
|
|
405
426
|
t.args.forEach(emit);
|
|
406
427
|
const ready = rank ? Math.max(-1, ...t.deps.map(i => rank[i])) + 1 : 0;
|
|
407
428
|
const line = `const t${t.id}=${ready > 0 ? `d>=${ready}?${t.code}:0` : t.code};`;
|
|
408
|
-
chars += line
|
|
429
|
+
chars += originalSize(line);
|
|
409
430
|
if (chars > 65_536)
|
|
410
431
|
throw new Unsupported('large transition screen');
|
|
411
|
-
lines.push(line);
|
|
432
|
+
lines.push(tinyPrefix + line);
|
|
412
433
|
};
|
|
413
434
|
values.forEach(emit);
|
|
414
435
|
// Only closed AST operators, validated numerical literals and slot indices;
|
|
415
436
|
// callback replay, never this generated transition, authorizes a CTI.
|
|
416
437
|
// oxlint-disable-next-line typescript/no-implied-eval
|
|
417
|
-
return
|
|
438
|
+
return tinyNative(`${lines.join('')}return [${values.map(t => this.ref(t)).join(',')}];`);
|
|
418
439
|
}
|
|
419
440
|
// Upper truth bound, not a two-valued evaluation of an incomplete state.
|
|
420
441
|
// true includes UNKNOWN; false rules out this polarity for every completion.
|
|
421
442
|
// In particular, polarity=false cannot prune on an unassigned atom.
|
|
422
443
|
compile(p, order, polarity = true, readyAt) {
|
|
423
|
-
|
|
444
|
+
tinyCheck('tiny generate screen');
|
|
424
445
|
// Keep native compilation and hot execution in bounded clauses rather
|
|
425
446
|
// than one giant predicate. Partial-assignment polarity is unchanged.
|
|
426
447
|
if (typeof p === 'boolean')
|
|
@@ -446,7 +467,7 @@ class Compiler {
|
|
|
446
467
|
this.compile({ op: p.op, xs: p.xs.slice(middle) }, order, polarity, readyAt)];
|
|
447
468
|
return (v, depth) => {
|
|
448
469
|
for (const test of tests) {
|
|
449
|
-
|
|
470
|
+
tinyCheck('tiny predicate clause');
|
|
450
471
|
if (test(v, depth) !== all)
|
|
451
472
|
return !all;
|
|
452
473
|
}
|
|
@@ -456,7 +477,7 @@ class Compiler {
|
|
|
456
477
|
return this.compileNative(p, order, polarity, readyAt);
|
|
457
478
|
}
|
|
458
479
|
compileNative(p, order, polarity = true, readyAt) {
|
|
459
|
-
|
|
480
|
+
tinyCheck('tiny native clause');
|
|
460
481
|
const rank = readyAt ? readyAt.map(depth => depth - 1) : order ? this.slots.map((_, i) => order.indexOf(i)) : undefined, used = [];
|
|
461
482
|
// An atomic predicate is unknown until ALL of its dependencies are set.
|
|
462
483
|
// Its old per-term placeholders could not affect that result, so return
|
|
@@ -466,33 +487,33 @@ class Compiler {
|
|
|
466
487
|
const ready = rank && atomic ? Math.max(-1, ...depsOf(p).map(i => rank[i])) + 1 : 0;
|
|
467
488
|
const guard = ready > 0 ? `if(d<${ready})return true;` : '';
|
|
468
489
|
const code = this.predicateCode(p, atomic ? undefined : rank, used, polarity), seen = new Set(), lines = [];
|
|
469
|
-
let chars = guard.length + code
|
|
490
|
+
let chars = guard.length + originalSize(code);
|
|
470
491
|
if (chars > 65_536)
|
|
471
492
|
throw new Unsupported('large generated screen');
|
|
472
493
|
const emit = (t) => {
|
|
473
|
-
|
|
494
|
+
tinyCheck('tiny term code');
|
|
474
495
|
if (seen.has(t.id))
|
|
475
496
|
return;
|
|
476
497
|
seen.add(t.id);
|
|
477
498
|
t.args.forEach(emit);
|
|
478
499
|
const termReady = rank && !atomic ? Math.max(-1, ...t.deps.map(i => rank[i])) + 1 : 0;
|
|
479
500
|
const line = `const t${t.id}=${termReady > 0 ? `d>=${termReady}?${t.code}:0` : t.code};`;
|
|
480
|
-
chars += line
|
|
501
|
+
chars += originalSize(line);
|
|
481
502
|
if (chars > 65_536)
|
|
482
503
|
throw new Unsupported('large generated screen');
|
|
483
|
-
lines.push(line);
|
|
504
|
+
lines.push(tinyPrefix + line);
|
|
484
505
|
};
|
|
485
506
|
used.forEach(emit);
|
|
486
507
|
// Closed AST operators, validated numerical literals and slot indices only;
|
|
487
508
|
// no identifier or external function source is interpolated. This is an
|
|
488
509
|
// UNTRUSTED screen: the callback must independently replay every proposal.
|
|
489
510
|
// oxlint-disable-next-line typescript/no-implied-eval
|
|
490
|
-
return
|
|
511
|
+
return tinyNative(`${guard}${lines.join('')}return ${code};`);
|
|
491
512
|
}
|
|
492
513
|
}
|
|
493
514
|
const uniqueTerms = (ts) => [...new Map(ts.map(t => [t.id, t])).values()];
|
|
494
515
|
function bindings(names, domain, env) {
|
|
495
|
-
|
|
516
|
+
tinyCheck('tiny bindings');
|
|
496
517
|
if (!names.length)
|
|
497
518
|
return [env];
|
|
498
519
|
if (names.length > 5)
|
|
@@ -507,7 +528,7 @@ function gridKeys(m, size) {
|
|
|
507
528
|
cells[name] = Array.from({ length: size }, (_, i) => i);
|
|
508
529
|
for (const d of Object.values(m.counts ?? {}))
|
|
509
530
|
walk(d.body, o => {
|
|
510
|
-
|
|
531
|
+
tinyCheck('tiny grid inference');
|
|
511
532
|
if (o.op !== 'get' || !Object.hasOwn(cells, String(o.map)))
|
|
512
533
|
return;
|
|
513
534
|
const key = o.key;
|
|
@@ -525,7 +546,7 @@ function tinyScope(params, stateValues, options) {
|
|
|
525
546
|
return { params: { ...params }, scalarValues: [...stateValues], cellValues: [...stateValues], cells: {}, inputValues: {}, inputCells: {}, binderValues: [], postTargetPruning: options.postTargetPruning === true, postTargetIntervals: options.postTargetIntervals === true, seedNeighborhood: options.seedTransitions !== undefined, seedUniformMaps: options.seedTransitions !== undefined && options.seedUniformMaps === true };
|
|
526
547
|
}
|
|
527
548
|
function tinyLayout(source, m, params, stateValues, scope) {
|
|
528
|
-
|
|
549
|
+
tinyCheck('tiny start');
|
|
529
550
|
if (!stateValues.length || stateValues.length > 4 || stateValues.some(n => !Number.isSafeInteger(n) || n < 0))
|
|
530
551
|
throw new Unsupported('invalid finite value domain');
|
|
531
552
|
if (source.history || source.leasts || source.sums)
|
|
@@ -543,17 +564,17 @@ function tinyLayout(source, m, params, stateValues, scope) {
|
|
|
543
564
|
const slots = Object.keys(source.state).map(name => ({ name, values: stateValues }));
|
|
544
565
|
for (const name of Object.keys(source.maps ?? {}))
|
|
545
566
|
for (const key of scope.cells[name] ?? []) {
|
|
546
|
-
|
|
567
|
+
tinyCheck('tiny state coordinates');
|
|
547
568
|
slots.push({ name, key, values: stateValues });
|
|
548
569
|
}
|
|
549
570
|
const stateSlots = slots.length;
|
|
550
571
|
for (const name of source.inputs) {
|
|
551
|
-
|
|
572
|
+
tinyCheck('tiny request domains');
|
|
552
573
|
// Explicit conjunctive natural bounds are domain hints; other inputs use
|
|
553
574
|
// 0..size. No domain or quotient is a trusted pruning justification.
|
|
554
575
|
let hi = 16, bounded = false;
|
|
555
576
|
for (const c of conjuncts(source.assume ?? { op: 'and', xs: [] })) {
|
|
556
|
-
|
|
577
|
+
tinyCheck('tiny numeric bounds');
|
|
557
578
|
if ((c.op === '<' || c.op === '<=') && c.a.op === 'var' && c.a.name === name) {
|
|
558
579
|
const b = c.b.op === 'const' ? c.b.value : c.b.op === 'var' ? params[c.b.name] : undefined;
|
|
559
580
|
if (b !== undefined) {
|
|
@@ -571,7 +592,7 @@ function tinyLayout(source, m, params, stateValues, scope) {
|
|
|
571
592
|
slots.push({ name, request: true, values });
|
|
572
593
|
}
|
|
573
594
|
for (const name of source.inputMaps ?? []) {
|
|
574
|
-
|
|
595
|
+
tinyCheck('tiny carried coordinates');
|
|
575
596
|
scope.inputCells[name] = Array.from({ length: size }, (_, i) => i);
|
|
576
597
|
for (const key of scope.inputCells[name])
|
|
577
598
|
slots.push({ name, key, request: true, values: [0, 1] });
|
|
@@ -584,7 +605,7 @@ function materializeTiny(source, slots, values, fixed = {}) {
|
|
|
584
605
|
const preState = { scalars: {}, maps: Object.fromEntries(Object.keys(source.maps ?? {}).map(name => [name, new Map()])) };
|
|
585
606
|
const request = Object.fromEntries((source.inputMaps ?? []).map(name => [name, new Map()]));
|
|
586
607
|
for (let i = 0; i < slots.length; i++) {
|
|
587
|
-
|
|
608
|
+
tinyCheck('tiny candidate materialization');
|
|
588
609
|
const s = slots[i], value = s.request && s.key === undefined && Object.hasOwn(fixed, s.name) ? fixed[s.name] : values[i];
|
|
589
610
|
if (s.request) {
|
|
590
611
|
if (s.key === undefined)
|
|
@@ -603,7 +624,7 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
603
624
|
const bases = [], seen = new Set();
|
|
604
625
|
let attempts = 0;
|
|
605
626
|
for (const seed of options.seedTransitions?.slice(-8) ?? []) {
|
|
606
|
-
|
|
627
|
+
tinyCheck('tiny seed projection');
|
|
607
628
|
if (!Object.keys(params).every(key => seed.params[key] === params[key]))
|
|
608
629
|
continue;
|
|
609
630
|
const values = [];
|
|
@@ -620,7 +641,7 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
620
641
|
bases.push(values);
|
|
621
642
|
}
|
|
622
643
|
const attempt = (values, coupled = false) => {
|
|
623
|
-
|
|
644
|
+
tinyCheck('tiny seed attempt');
|
|
624
645
|
if (attempts >= 256)
|
|
625
646
|
return false;
|
|
626
647
|
const key = values.join(',');
|
|
@@ -637,7 +658,7 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
637
658
|
if (options.seedUniformMaps) {
|
|
638
659
|
const grouped = new Map();
|
|
639
660
|
for (const [i, slot] of slots.entries()) {
|
|
640
|
-
|
|
661
|
+
tinyCheck('tiny seed map grouping');
|
|
641
662
|
if (slot.key === undefined)
|
|
642
663
|
continue;
|
|
643
664
|
const key = `${Number(!!slot.request)}:${slot.name}`, group = grouped.get(key) ?? [];
|
|
@@ -649,7 +670,7 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
649
670
|
for (const group of groups)
|
|
650
671
|
for (const base of bases)
|
|
651
672
|
for (const value of slots[group[0]].values) {
|
|
652
|
-
|
|
673
|
+
tinyCheck('tiny seed uniform map');
|
|
653
674
|
if (!group.every(i => slots[i].values.includes(value)) || group.every(i => base[i] === value))
|
|
654
675
|
continue;
|
|
655
676
|
const values = base.slice();
|
|
@@ -665,7 +686,7 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
665
686
|
for (const i of axes)
|
|
666
687
|
for (const base of bases)
|
|
667
688
|
for (const value of slots[i].values) {
|
|
668
|
-
|
|
689
|
+
tinyCheck('tiny seed neighbor');
|
|
669
690
|
if (value === base[i])
|
|
670
691
|
continue;
|
|
671
692
|
const values = base.slice();
|
|
@@ -677,10 +698,12 @@ function walkTinySeedVectors(source, params, slots, options, visit) {
|
|
|
677
698
|
// Cheap finite-grid proposals only: no predicates or native transition code are
|
|
678
699
|
// compiled. The supplied checker must establish every removal independently.
|
|
679
700
|
export function tinySeedCandidates(source, m, params, onCandidate, options = {}) {
|
|
680
|
-
const values = unique([...(options.valueDomain ?? [0, 1])]).sort((a, b) => a - b), start =
|
|
701
|
+
const values = unique([...(options.valueDomain ?? [0, 1])]).sort((a, b) => a - b), start = countedTraceNow();
|
|
681
702
|
const stats = { phase: 'seed-only', scope: tinyScope(params, values, options), completed: false, timedOut: false,
|
|
682
703
|
unsupported: [], models: 0, accepted: 0, coupledModels: 0, coupledAccepted: 0, ms: 0 };
|
|
683
704
|
try {
|
|
705
|
+
if (hasFinite([source, m]))
|
|
706
|
+
throw new Unsupported('finite sort machine: tiny screening is not supported');
|
|
684
707
|
const { slots } = tinyLayout(source, m, params, values, stats.scope);
|
|
685
708
|
walkTinySeedVectors(source, params, slots, options, (vector, coupled) => {
|
|
686
709
|
stats.models++;
|
|
@@ -704,7 +727,7 @@ export function tinySeedCandidates(source, m, params, onCandidate, options = {})
|
|
|
704
727
|
throw e;
|
|
705
728
|
}
|
|
706
729
|
finally {
|
|
707
|
-
stats.ms =
|
|
730
|
+
stats.ms = countedTraceNow() - start;
|
|
708
731
|
}
|
|
709
732
|
return stats;
|
|
710
733
|
}
|
|
@@ -720,11 +743,13 @@ export function tinySeedCandidates(source, m, params, onCandidate, options = {})
|
|
|
720
743
|
*/
|
|
721
744
|
export function tinyFiniteCandidates(source, m, family, params, onCandidate, options = {}) {
|
|
722
745
|
const stateValues = unique([...(options.valueDomain ?? [0, 1])]).sort((a, b) => a - b);
|
|
723
|
-
const start =
|
|
746
|
+
const start = countedTraceNow(), scope = tinyScope(params, stateValues, options);
|
|
724
747
|
const stats = { scope, completed: false, exhausted: false, timedOut: false, unsupported: [], nodes: 0, states: 0, steps: 0, scenarios: 0, candidates: 0, postStatePrunes: 0, postRequestPrunes: 0, postIntervalFallbacks: 0, seedModels: 0, seedCandidates: 0, seedCoupledModels: 0, seedCoupledCandidates: 0, ms: 0 };
|
|
725
748
|
const unknown = (e) => { const reason = e instanceof Error ? e.message : String(e); if (!stats.unsupported.includes(reason))
|
|
726
749
|
stats.unsupported.push(reason); };
|
|
727
750
|
try {
|
|
751
|
+
if (hasFinite([source, m, family]))
|
|
752
|
+
throw new Unsupported('finite sort machine/law: tiny screening is not supported');
|
|
728
753
|
const { slots, stateSlots } = tinyLayout(source, m, params, stateValues, scope);
|
|
729
754
|
const compiler = new Compiler(source, m, params, slots, scope.cells, scope.binderValues);
|
|
730
755
|
const pres = [];
|
|
@@ -732,7 +757,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
732
757
|
pres.push(compiler.condition(source.pre, params));
|
|
733
758
|
const instances = new Map();
|
|
734
759
|
for (const law of family) {
|
|
735
|
-
|
|
760
|
+
tinyCheck('tiny family compile');
|
|
736
761
|
if (law.some?.length) {
|
|
737
762
|
unknown(new Unsupported('existential law'));
|
|
738
763
|
continue;
|
|
@@ -763,7 +788,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
763
788
|
// quotients request coordinates irrelevant to that operation slice.
|
|
764
789
|
const dispatches = new Map();
|
|
765
790
|
walk(source.step, o => {
|
|
766
|
-
|
|
791
|
+
tinyCheck('tiny dispatch inference');
|
|
767
792
|
if (o.op !== '=')
|
|
768
793
|
return;
|
|
769
794
|
const a = o.a, b = o.b;
|
|
@@ -778,7 +803,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
778
803
|
const slices = dispatch ? scope.inputValues[dispatch].map(value => ({ ...params, [dispatch]: value })) : [params];
|
|
779
804
|
const emitted = new Set(), highs = slots.map(s => Math.max(...s.values));
|
|
780
805
|
const writeFlags = new Set();
|
|
781
|
-
walk([source.step.state, source.step.maps], o => {
|
|
806
|
+
walk([source.step.state, source.step.maps], o => { tinyCheck('tiny write flags'); if (o.op === 'flag')
|
|
782
807
|
writeFlags.add(o.name); });
|
|
783
808
|
const slotValue = (c, i, env, post) => {
|
|
784
809
|
const s = slots[i];
|
|
@@ -801,7 +826,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
801
826
|
const flatPreds = (p) => typeof p !== 'boolean' && p.op === 'and' ? p.xs.flatMap(flatPreds) : [p];
|
|
802
827
|
const operations = [];
|
|
803
828
|
for (const fixed of slices) {
|
|
804
|
-
|
|
829
|
+
tinyCheck('tiny operation compile');
|
|
805
830
|
try {
|
|
806
831
|
const outputs = slots.slice(0, stateSlots).map((_, i) => slotValue(compiler, i, fixed, true));
|
|
807
832
|
if (outputs.every((t, i) => t.id === compiler.slot(i).id))
|
|
@@ -815,7 +840,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
815
840
|
const degrees = slots.map((_, i) => clauses.reduce((sum, ds) => sum + (ds.includes(i) ? 1 / Math.max(1, ds.length) : 0), 0));
|
|
816
841
|
const order = slots.map((_, i) => i).filter(i => i >= stateSlots && relevant.has(i)).sort((a, b) => degrees[b] - degrees[a] || a - b);
|
|
817
842
|
operations.push({ fixed, order, gate: compiler.compile(enabled, order), step: compiler.compileValues(outputs), outputs });
|
|
818
|
-
outputs.forEach((t, i) => {
|
|
843
|
+
outputs.forEach((t, i) => { tinyCheck('tiny post ranges'); highs[i] = Math.max(highs[i], t.hi); });
|
|
819
844
|
stats.scenarios++;
|
|
820
845
|
}
|
|
821
846
|
catch (e) {
|
|
@@ -828,7 +853,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
828
853
|
const postCompiler = new Compiler(source, m, params, postSlots, scope.cells, scope.binderValues);
|
|
829
854
|
const targets = [], predicates = [];
|
|
830
855
|
for (const [law, ats] of instances) {
|
|
831
|
-
|
|
856
|
+
tinyCheck('tiny shared post predicates');
|
|
832
857
|
try {
|
|
833
858
|
const p = conjunction(ats.map(at => postCompiler.condition(law.holds, at)));
|
|
834
859
|
if (p === true)
|
|
@@ -852,7 +877,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
852
877
|
const preTest = compiler.compile(pre, stateOrder), v = slots.map(s => s.values[0]);
|
|
853
878
|
if (options.postTargetPruning)
|
|
854
879
|
for (const op of operations) {
|
|
855
|
-
|
|
880
|
+
tinyCheck('tiny post-target circuit');
|
|
856
881
|
try {
|
|
857
882
|
const order = [...stateOrder, ...op.order], rank = slots.map((_, i) => order.indexOf(i));
|
|
858
883
|
// A post coordinate is unknown until every source dependency of its
|
|
@@ -861,7 +886,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
861
886
|
const changed = new Set(op.outputs.flatMap((t, i) => t.id === compiler.slot(i).id ? [] : [i]));
|
|
862
887
|
const needed = new Set(), screens = [];
|
|
863
888
|
for (const [i, law] of targets.entries()) {
|
|
864
|
-
|
|
889
|
+
tinyCheck('tiny post-target predicate');
|
|
865
890
|
const p = predicates[i], deps = depsOf(p);
|
|
866
891
|
// Unchanged primitive dependencies preserve this full-family law.
|
|
867
892
|
if (!deps.some(j => changed.has(j)))
|
|
@@ -925,23 +950,24 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
925
950
|
stats.candidates++;
|
|
926
951
|
if (accepted !== false)
|
|
927
952
|
for (const law of violated) {
|
|
928
|
-
|
|
953
|
+
tinyCheck('tiny proposed targets');
|
|
929
954
|
emitted.add(law);
|
|
930
955
|
}
|
|
931
956
|
};
|
|
932
957
|
const visit = () => {
|
|
933
958
|
stats.states++;
|
|
934
|
-
|
|
959
|
+
tinyCheck('tiny lawful state');
|
|
935
960
|
for (const op of operations) {
|
|
936
|
-
|
|
961
|
+
tinyCheck('tiny operation slice');
|
|
937
962
|
for (let i = stateSlots; i < slots.length; i++)
|
|
938
963
|
v[i] = slots[i].values[0];
|
|
939
964
|
for (const name of source.inputs)
|
|
940
965
|
if (Object.hasOwn(op.fixed, name))
|
|
941
966
|
v[slots.findIndex(s => s.request && s.key === undefined && s.name === name)] = op.fixed[name];
|
|
942
967
|
const requests = (d) => {
|
|
968
|
+
tinyNode();
|
|
943
969
|
stats.nodes++;
|
|
944
|
-
|
|
970
|
+
tinyCheck('tiny request assignment');
|
|
945
971
|
if (!op.gate(v, d))
|
|
946
972
|
return;
|
|
947
973
|
if (op.mayFail && !op.mayFail(v, stateOrder.length + d)) {
|
|
@@ -951,7 +977,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
951
977
|
if (d < op.order.length) {
|
|
952
978
|
const i = op.order[d];
|
|
953
979
|
for (const value of slots[i].values) {
|
|
954
|
-
|
|
980
|
+
tinyCheck('tiny request values');
|
|
955
981
|
v[i] = value;
|
|
956
982
|
requests(d + 1);
|
|
957
983
|
}
|
|
@@ -972,8 +998,9 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
972
998
|
}
|
|
973
999
|
};
|
|
974
1000
|
const states = (d) => {
|
|
1001
|
+
tinyNode();
|
|
975
1002
|
stats.nodes++;
|
|
976
|
-
|
|
1003
|
+
tinyCheck('tiny state assignment');
|
|
977
1004
|
if (!preTest(v, d))
|
|
978
1005
|
return;
|
|
979
1006
|
if (options.postTargetPruning && operations.every(op => !op.mayFail(v, d))) {
|
|
@@ -987,7 +1014,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
987
1014
|
const i = stateOrder[d];
|
|
988
1015
|
// Ones first reaches enabled guards early; both values remain enumerated.
|
|
989
1016
|
for (const value of [...slots[i].values].reverse()) {
|
|
990
|
-
|
|
1017
|
+
tinyCheck('tiny state values');
|
|
991
1018
|
v[i] = value;
|
|
992
1019
|
states(d + 1);
|
|
993
1020
|
}
|
|
@@ -998,6 +1025,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
998
1025
|
// independent callback. Snapshot before callbacks can add later seeds.
|
|
999
1026
|
if (options.seedTransitions)
|
|
1000
1027
|
walkTinySeedVectors(source, params, slots, options, (values, coupled) => {
|
|
1028
|
+
tinyNode();
|
|
1001
1029
|
stats.seedModels++;
|
|
1002
1030
|
stats.nodes++;
|
|
1003
1031
|
if (coupled)
|
|
@@ -1007,7 +1035,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
1007
1035
|
if (!preTest(v, stateOrder.length))
|
|
1008
1036
|
return;
|
|
1009
1037
|
for (const op of operations) {
|
|
1010
|
-
|
|
1038
|
+
tinyCheck('tiny seed operation');
|
|
1011
1039
|
if (slots.some((s, i) => s.request && s.key === undefined && Object.hasOwn(op.fixed, s.name) && v[i] !== op.fixed[s.name]))
|
|
1012
1040
|
continue;
|
|
1013
1041
|
if (!op.gate(v, op.order.length))
|
|
@@ -1045,7 +1073,7 @@ export function tinyFiniteCandidates(source, m, family, params, onCandidate, opt
|
|
|
1045
1073
|
throw e;
|
|
1046
1074
|
}
|
|
1047
1075
|
finally {
|
|
1048
|
-
stats.ms =
|
|
1076
|
+
stats.ms = countedTraceNow() - start;
|
|
1049
1077
|
}
|
|
1050
1078
|
return stats;
|
|
1051
1079
|
}
|