gdp-wired 0.48.0 → 0.50.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 +6 -2
- package/dist/core/bmc.js +10 -7
- package/dist/core/candidate-seeds.d.ts +25 -0
- package/dist/core/candidate-seeds.js +90 -0
- package/dist/core/check.js +7 -2
- package/dist/core/cli.js +3 -0
- 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.d.ts +1 -0
- package/dist/core/count-support.js +26 -4
- 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/counted-candidate-seeds.d.ts +12 -0
- package/dist/core/counted-candidate-seeds.js +31 -0
- package/dist/core/counts.d.ts +37 -13
- package/dist/core/counts.js +999 -129
- 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 +32 -2
- package/dist/core/dsl.js +202 -64
- 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 +53 -10
- package/dist/core/field-laws.d.ts +3 -1
- package/dist/core/field-laws.js +159 -3
- 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 +49 -33
- package/dist/core/kind.js +2 -1
- package/dist/core/lemma-cuts.js +11 -10
- package/dist/core/lift-cli.d.ts +11 -0
- package/dist/core/lift-cli.js +113 -0
- 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/proof-output.d.ts +53 -0
- package/dist/core/proof-output.js +38 -0
- 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 +80 -17
- 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/function-instances.d.ts +45 -0
- package/dist/kernel/function-instances.js +460 -0
- package/dist/kernel/kernel.d.ts +47 -1
- package/dist/kernel/kernel.js +417 -68
- package/dist/kernel/prove.d.ts +61 -6
- package/dist/kernel/prove.js +625 -205
- 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/axiom-audit.d.ts +11 -0
- package/dist/lean-kernel/axiom-audit.js +50 -0
- package/dist/lean-kernel/emit.d.ts +34 -3
- package/dist/lean-kernel/emit.js +215 -28
- 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/legacy-family-order.d.ts +1 -0
- package/dist/lean-kernel/legacy-family-order.js +26 -0
- package/dist/lean-kernel/library.js +25 -3
- package/dist/lean-kernel/lift/counted-source-data.d.ts +7 -0
- package/dist/lean-kernel/lift/counted-source-data.js +78 -0
- package/dist/lean-kernel/lift/index.d.ts +82 -0
- package/dist/lean-kernel/lift/index.js +116 -0
- package/dist/lean-kernel/lift/project.d.ts +4 -0
- package/dist/lean-kernel/lift/project.js +15 -0
- package/dist/lean-kernel/lift/proof-capture.d.ts +104 -0
- package/dist/lean-kernel/lift/proof-capture.js +216 -0
- package/dist/lean-kernel/lift/proof-codec.d.ts +28 -0
- package/dist/lean-kernel/lift/proof-codec.js +299 -0
- package/dist/lean-kernel/lift/proof-counted-source.d.ts +16 -0
- package/dist/lean-kernel/lift/proof-counted-source.js +68 -0
- package/dist/lean-kernel/lift/proof-frontier.d.ts +19 -0
- package/dist/lean-kernel/lift/proof-frontier.js +153 -0
- package/dist/lean-kernel/lift/proof-graph.d.ts +17 -0
- package/dist/lean-kernel/lift/proof-graph.js +130 -0
- package/dist/lean-kernel/lift/proof-parts.d.ts +29 -0
- package/dist/lean-kernel/lift/proof-parts.js +131 -0
- package/dist/lean-kernel/lift/proof-prelude.d.ts +2 -0
- package/dist/lean-kernel/lift/proof-prelude.js +38 -0
- package/dist/lean-kernel/lift/proof-witness.d.ts +30 -0
- package/dist/lean-kernel/lift/proof-witness.js +283 -0
- package/dist/lean-kernel/lift/shape.d.ts +5 -0
- package/dist/lean-kernel/lift/shape.js +57 -0
- package/dist/lean-kernel/lift/source-projection.d.ts +16 -0
- package/dist/lean-kernel/lift/source-projection.js +81 -0
- package/dist/lean-kernel/lift/source.d.ts +23 -0
- package/dist/lean-kernel/lift/source.js +111 -0
- package/dist/lean-kernel/lift/witness-alpha.d.ts +9 -0
- package/dist/lean-kernel/lift/witness-alpha.js +31 -0
- package/dist/lean-kernel/lift-legacy.d.ts +58 -0
- package/dist/lean-kernel/lift-legacy.js +84 -0
- package/dist/lean-kernel/lift-names.d.ts +22 -0
- package/dist/lean-kernel/lift-names.js +36 -0
- package/dist/lean-kernel/lift-simulation/index.d.ts +29 -0
- package/dist/lean-kernel/lift-simulation/index.js +352 -0
- package/dist/lean-kernel/lift-simulation/shape.d.ts +41 -0
- package/dist/lean-kernel/lift-simulation/shape.js +173 -0
- package/dist/lean-kernel/lift-special/index.d.ts +36 -0
- package/dist/lean-kernel/lift-special/index.js +241 -0
- package/dist/lean-kernel/lift-special/structural.d.ts +25 -0
- package/dist/lean-kernel/lift-special/structural.js +126 -0
- package/dist/lean-kernel/lift-typed/index.d.ts +35 -0
- package/dist/lean-kernel/lift-typed/index.js +256 -0
- package/dist/lean-kernel/lift-typed/roles.d.ts +17 -0
- package/dist/lean-kernel/lift-typed/roles.js +170 -0
- package/dist/lean-kernel/lift-typed/shape.d.ts +1 -0
- package/dist/lean-kernel/lift-typed/shape.js +12 -0
- package/dist/lean-kernel/lift.d.ts +30 -0
- package/dist/lean-kernel/lift.js +97 -0
- package/package.json +5 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
1
2
|
// Untrusted pre-check accelerators over immutable proof objects. No cached
|
|
2
3
|
// answer replaces checkMC/checkCountedLaws on the final emitted certificate.
|
|
3
4
|
import { canon, check, leafConstraintsReusing as rowsAt } from "../../kernel/kernel.js";
|
|
@@ -112,13 +113,13 @@ export function rememberRetarget(lemma, key, result) {
|
|
|
112
113
|
}
|
|
113
114
|
const indices = new WeakMap();
|
|
114
115
|
export function targetIndex(goal, until) {
|
|
115
|
-
if (!(
|
|
116
|
+
if (!(countedSearchNow() < until))
|
|
116
117
|
return undefined;
|
|
117
118
|
let at = indices.get(goal);
|
|
118
119
|
if (!at) {
|
|
119
120
|
at = new Map();
|
|
120
121
|
for (const [i, h] of goal.hyps.entries()) {
|
|
121
|
-
if (!(
|
|
122
|
+
if (!(countedSearchNow() < until))
|
|
122
123
|
return undefined;
|
|
123
124
|
const key = JSON.stringify(h);
|
|
124
125
|
if (!at.has(key))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
1
2
|
// Untrusted conditional proof transport. No search and no lemma references enter
|
|
2
3
|
// the result: each prerequisite is checked independently, then inlined as a split.
|
|
3
4
|
import { canon, canonFlip, check, leafConstraintsReusing as rowsAt, lemmaPath } from "../../kernel/kernel.js";
|
|
4
5
|
import { add, k, scale } from "../solver.js";
|
|
5
|
-
const alive = (until) =>
|
|
6
|
+
const alive = (until) => countedSearchNow() < until;
|
|
6
7
|
const flip = (lin) => add(k(1), scale(lin, -1));
|
|
7
8
|
const put = (path, lin, holds) => new Map(path).set(canon(lin), { lin, holds });
|
|
8
9
|
const plain = (lin) => Object.keys(lin).every(name => !name.includes('⟦')) && Object.values(lin).every(Number.isSafeInteger);
|
|
@@ -211,7 +212,7 @@ function inline(goal, source, tree, from, scope, base, lemmas, until, diagnose)
|
|
|
211
212
|
}
|
|
212
213
|
/** Transport a refutation to negcut + scope, inline required prior cuts, then
|
|
213
214
|
* minimize its guards and containing-goal hypothesis slice. `until` is an
|
|
214
|
-
* absolute
|
|
215
|
+
* absolute countedSearchNow() deadline, independent of the prover's clock. */
|
|
215
216
|
function admitCut(goal, source, tree, from, scope, cut, available, until) {
|
|
216
217
|
if (!alive(until) || !plain(cut))
|
|
217
218
|
return undefined;
|
|
@@ -311,8 +312,8 @@ export function admitConditionalCut(goal, source, tree, from, scope, cut, availa
|
|
|
311
312
|
/** Emit an ordinary tree at scope, inlining only active cuts whose exact rows
|
|
312
313
|
* the source proof needs. The returned tree is kernel-checked without lemmas. */
|
|
313
314
|
export function inlineConditionalCuts(goal, source, tree, from, scope, lemmas, until, diagnose) {
|
|
314
|
-
const begun =
|
|
315
|
+
const begun = countedSearchNow(), proof = inline(goal, source, tree, from, scope, scope, lemmas, until, diagnose);
|
|
315
316
|
const accepted = !!proof && checked(goal, proof, scope, until);
|
|
316
|
-
diagnose?.({ reason: accepted ? 'complete' : alive(until) ? proof ? 'check-failed' : 'transport-failed' : 'deadline', proposed: !!proof, checked: accepted, wallMs:
|
|
317
|
+
diagnose?.({ reason: accepted ? 'complete' : alive(until) ? proof ? 'check-failed' : 'transport-failed' : 'deadline', proposed: !!proof, checked: accepted, wallMs: countedSearchNow() - begun });
|
|
317
318
|
return accepted ? proof : undefined;
|
|
318
319
|
}
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ReplayDiagnosticContext } from '../count-replay-diagnostic.js';
|
|
2
|
+
export type NativeCutContext = Readonly<{
|
|
3
|
+
counts: Count[];
|
|
4
|
+
frames?: FrameCut[];
|
|
5
|
+
monos?: MonoCut[];
|
|
6
|
+
lins?: LinCut[];
|
|
7
|
+
}>;
|
|
8
|
+
export type TransportPart = 'main' | 'independent-lemma';
|
|
9
|
+
export type ConditionalTransportDecline = Readonly<{
|
|
10
|
+
stage: 'cut-validation' | 'leaf-mapping' | 'lemma-retarget' | 'transport' | 'transport-check' | 'collection' | 'collection-check' | 'exception';
|
|
11
|
+
part: TransportPart;
|
|
12
|
+
reason: string;
|
|
13
|
+
inputIndex?: number;
|
|
14
|
+
sourceRowCount?: number;
|
|
15
|
+
targetRowCount?: number;
|
|
16
|
+
sourceRow?: unknown;
|
|
17
|
+
sourceFact?: unknown;
|
|
18
|
+
sourcePath?: Path;
|
|
19
|
+
targetPath?: Path;
|
|
20
|
+
}>;
|
|
21
|
+
export type ConditionalTransportOptions = Readonly<{
|
|
22
|
+
rethrowBudgetExpired?: boolean;
|
|
23
|
+
diagnostic?: ReplayDiagnosticContext;
|
|
24
|
+
native?: Readonly<{
|
|
25
|
+
from: NativeCutContext;
|
|
26
|
+
to: NativeCutContext;
|
|
27
|
+
}>;
|
|
28
|
+
onDecline?: (detail: ConditionalTransportDecline) => void;
|
|
29
|
+
}>;
|
|
30
|
+
import { type Goal, type LemmaCut, type Path, type Tree, type Count, type FrameCut, type MonoCut, type LinCut } from '../../kernel/kernel.js';
|
|
2
31
|
export { conditionalProofStats } from './conditional-check-cache.js';
|
|
32
|
+
type Context = {
|
|
33
|
+
goal: Goal;
|
|
34
|
+
lemmas: LemmaCut[];
|
|
35
|
+
};
|
|
36
|
+
export declare const snapshotConditionalProofMark: (tree: object) => Readonly<Context> | undefined;
|
|
3
37
|
/** A proposer hint, not an admission check. Rows in tree use lemmaPath at each
|
|
4
38
|
* leaf; branches still use the ordinary split path, exactly as in the kernel. */
|
|
5
39
|
export declare function markConditionalProof(goal: Goal, tree: Tree, lemmas: LemmaCut[]): Tree;
|
|
@@ -9,11 +43,11 @@ export declare function hasConditionalProof(tree: Tree): boolean;
|
|
|
9
43
|
export declare function checkConditionalProof(goal: Goal, tree: Tree, path?: Path): boolean;
|
|
10
44
|
/** Retarget an annotated or mixed proof, without turning cuts into split trees.
|
|
11
45
|
* before/after are ordinary entry paths, not paths already augmented by cuts. */
|
|
12
|
-
export declare function transportConditionalProof(from: Goal, to: Goal, tree: Tree, before: Path, after: Path, until: number): Tree | undefined;
|
|
46
|
+
export declare function transportConditionalProof(from: Goal, to: Goal, tree: Tree, before: Path, after: Path, until: number, options?: ConditionalTransportOptions): Tree | undefined;
|
|
13
47
|
/** Finalize at the empty root. Each local list is guarded by its entry path so
|
|
14
48
|
* exporting it cannot add assumptions to unrelated ordinary siblings. Every
|
|
15
49
|
* leaf is then reindexed, even if it did not originally carry metadata. */
|
|
16
|
-
export declare function collectConditionalCertificate(goal: Goal, tree: Tree, until: number): {
|
|
50
|
+
export declare function collectConditionalCertificate(goal: Goal, tree: Tree, until: number, options?: ConditionalTransportOptions): {
|
|
17
51
|
tree: Tree;
|
|
18
52
|
lemmas: LemmaCut[];
|
|
19
53
|
} | undefined;
|
|
@@ -1,11 +1,37 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
2
|
+
import { BudgetExpired } from "../work-admission.js";
|
|
1
3
|
// Untrusted metadata and exact transport for conditional count proofs. The kernel
|
|
2
4
|
// never reads this WeakMap: only ordinary trees and independent LemmaCuts escape.
|
|
3
|
-
import { canon, canonFlip, check, checkGoalLemmas, facts, leafConstraintsReusing as rowsAt, lemmaPath } from "../../kernel/kernel.js";
|
|
5
|
+
import { canon, canonFlip, check, checkGoalLemmas, facts, leafConstraintsReusing as rowsAt, lemmaPath, framePath, frameOk, monoOk, linOk } from "../../kernel/kernel.js";
|
|
4
6
|
import { add, k, scale } from "../solver.js";
|
|
5
7
|
import { independentHit, rememberIndependent, retargetHit, rememberRetarget, slicedCheck, targetIndex } from "./conditional-check-cache.js";
|
|
6
8
|
export { conditionalProofStats } from "./conditional-check-cache.js";
|
|
9
|
+
const noReport = () => undefined;
|
|
10
|
+
// Failure metadata is observational and must not replace the original refusal.
|
|
11
|
+
const reporter = (options) => detail => { try {
|
|
12
|
+
options?.onDecline?.(detail);
|
|
13
|
+
}
|
|
14
|
+
catch { /* observational callback only */ } return undefined; };
|
|
15
|
+
const mainPath = (native, lemmas, path) => native ? framePath(native.frames ?? [], lemmas, path, native.monos ?? [], native.lins ?? []) : lemmaPath(lemmas, path);
|
|
16
|
+
// Validate actual count definitions before using their cut atoms. Independent
|
|
17
|
+
// lemma trees deliberately never receive this main-tree context.
|
|
18
|
+
function validNative(native) {
|
|
19
|
+
if (!native)
|
|
20
|
+
return true;
|
|
21
|
+
if (!Array.isArray(native.counts))
|
|
22
|
+
return false;
|
|
23
|
+
return (native.frames ?? []).every(cut => frameOk(native.counts, cut))
|
|
24
|
+
&& (native.monos ?? []).every(cut => monoOk(native.counts, cut))
|
|
25
|
+
&& (native.lins ?? []).every(cut => linOk(native.counts, cut));
|
|
26
|
+
}
|
|
7
27
|
const marked = new WeakMap();
|
|
8
|
-
|
|
28
|
+
// Proposer hints on subtrees are not certificate bytes. This getter grants no
|
|
29
|
+
// native proof authority and does not install or alter a mark.
|
|
30
|
+
export const snapshotConditionalProofMark = (tree) => {
|
|
31
|
+
const context = marked.get(tree);
|
|
32
|
+
return context && Object.freeze({ goal: context.goal, lemmas: context.lemmas.slice() });
|
|
33
|
+
};
|
|
34
|
+
const alive = (until) => countedSearchNow() < until;
|
|
9
35
|
const flip = (lin) => add(k(1), scale(lin, -1));
|
|
10
36
|
const put = (path, lin, holds) => new Map(path).set(canon(lin), { lin, holds });
|
|
11
37
|
const sameGoal = (a, b) => a === b || JSON.stringify(a.hyps) === JSON.stringify(b.hyps);
|
|
@@ -64,7 +90,7 @@ function independent(goal, lemmas, until) {
|
|
|
64
90
|
return alive(until);
|
|
65
91
|
}
|
|
66
92
|
const legalSplit = (tree, path) => !path.has(canon(tree.split)) && !Object.keys(tree.split).every(key => key === '1');
|
|
67
|
-
function checked(goal, tree, path, until) {
|
|
93
|
+
function checked(goal, tree, path, until, native) {
|
|
68
94
|
const visit = (t, p, context) => {
|
|
69
95
|
if (!alive(until))
|
|
70
96
|
return false;
|
|
@@ -75,7 +101,7 @@ function checked(goal, tree, path, until) {
|
|
|
75
101
|
context = own;
|
|
76
102
|
}
|
|
77
103
|
if ('leaf' in t)
|
|
78
|
-
return slicedCheck(goal, t,
|
|
104
|
+
return slicedCheck(goal, t, mainPath(native, context.lemmas, p)) && alive(until);
|
|
79
105
|
return legalSplit(t, p) && visit(t.yes, put(p, t.split, true), context)
|
|
80
106
|
&& visit(t.no, put(p, t.split, false), context);
|
|
81
107
|
};
|
|
@@ -104,7 +130,7 @@ const decide = (lin, path) => {
|
|
|
104
130
|
};
|
|
105
131
|
// No solver fallback. Only exact base rows and identical square/product offsets
|
|
106
132
|
// move; a target constant-positive row is already a complete refutation.
|
|
107
|
-
function leaf(from, to, tree, before, after, until) {
|
|
133
|
+
function leaf(from, to, tree, before, after, until, report = noReport, part = 'main') {
|
|
108
134
|
if (!alive(until))
|
|
109
135
|
return undefined;
|
|
110
136
|
const old = rowsAt(from, before), rows = rowsAt(to, after), at = new Map();
|
|
@@ -123,6 +149,10 @@ function leaf(from, to, tree, before, after, until) {
|
|
|
123
149
|
return undefined;
|
|
124
150
|
return i >= old.length ? i - old.length + rows.length : at.get(canon(old[i].lin));
|
|
125
151
|
};
|
|
152
|
+
const missing = (inputIndex, reason) => {
|
|
153
|
+
const sourceRow = old[inputIndex], src = sourceRow?.src;
|
|
154
|
+
return report({ stage: 'leaf-mapping', part, reason, inputIndex, sourceRowCount: old.length, targetRowCount: rows.length, sourceRow, sourceFact: src && 'fact' in src ? from.hyps[src.fact] : undefined, sourcePath: before, targetPath: after });
|
|
155
|
+
};
|
|
126
156
|
const steps = [], products = [];
|
|
127
157
|
for (const step of tree.leaf) {
|
|
128
158
|
if (!alive(until))
|
|
@@ -132,7 +162,7 @@ function leaf(from, to, tree, before, after, until) {
|
|
|
132
162
|
else {
|
|
133
163
|
const i = index(step.index);
|
|
134
164
|
if (i === undefined)
|
|
135
|
-
return
|
|
165
|
+
return missing(step.index, 'missing-input-row');
|
|
136
166
|
steps.push({ ...step, index: i });
|
|
137
167
|
}
|
|
138
168
|
}
|
|
@@ -141,30 +171,30 @@ function leaf(from, to, tree, before, after, until) {
|
|
|
141
171
|
return undefined;
|
|
142
172
|
const i = index(a), j = index(b);
|
|
143
173
|
if (i === undefined || j === undefined)
|
|
144
|
-
return undefined;
|
|
174
|
+
return missing(i === undefined ? a : b, 'missing-product-row');
|
|
145
175
|
products.push([i, j]);
|
|
146
176
|
}
|
|
147
177
|
return alive(until) ? { leaf: steps, ...(tree.products ? { products } : {}), ...(tree.squares ? { squares: tree.squares } : {}) } : undefined;
|
|
148
178
|
}
|
|
149
|
-
function ordinary(from, to, tree, before, after, until) {
|
|
179
|
+
function ordinary(from, to, tree, before, after, until, report = noReport) {
|
|
150
180
|
if (!alive(until))
|
|
151
181
|
return undefined;
|
|
152
182
|
if ('leaf' in tree)
|
|
153
|
-
return leaf(from, to, tree, before, after, until);
|
|
183
|
+
return leaf(from, to, tree, before, after, until, report, 'independent-lemma');
|
|
154
184
|
const known = decide(tree.split, after);
|
|
155
185
|
if (known !== undefined)
|
|
156
|
-
return ordinary(from, to, known ? tree.yes : tree.no, put(before, tree.split, known), after, until);
|
|
157
|
-
const yes = ordinary(from, to, tree.yes, put(before, tree.split, true), put(after, tree.split, true), until);
|
|
158
|
-
const no = yes && ordinary(from, to, tree.no, put(before, tree.split, false), put(after, tree.split, false), until);
|
|
186
|
+
return ordinary(from, to, known ? tree.yes : tree.no, put(before, tree.split, known), after, until, report);
|
|
187
|
+
const yes = ordinary(from, to, tree.yes, put(before, tree.split, true), put(after, tree.split, true), until, report);
|
|
188
|
+
const no = yes && ordinary(from, to, tree.no, put(before, tree.split, false), put(after, tree.split, false), until, report);
|
|
159
189
|
return yes && no ? { split: tree.split, yes, no } : undefined;
|
|
160
190
|
}
|
|
161
191
|
// Preserve mapped source hypotheses, including their order and duplicates. A
|
|
162
192
|
// removed hypothesis is dispensable only if exact independent-proof transport
|
|
163
193
|
// succeeds without it (e.g. an inserted guard is now an explicit entry atom).
|
|
164
194
|
// Even an unsliced source proof gets an explicit slice in an enlarged target.
|
|
165
|
-
function retarget(from, to, lemmas, scope, until, onlyMissing = false) {
|
|
195
|
+
function retarget(from, to, lemmas, scope, until, onlyMissing = false, report = noReport) {
|
|
166
196
|
if (!independent(from, lemmas, until))
|
|
167
|
-
return
|
|
197
|
+
return report({ stage: 'lemma-retarget', part: 'independent-lemma', reason: 'source-independent-check' });
|
|
168
198
|
const out = [], target = targetIndex(to, until);
|
|
169
199
|
if (!target)
|
|
170
200
|
return undefined;
|
|
@@ -208,13 +238,13 @@ function retarget(from, to, lemmas, scope, until, onlyMissing = false) {
|
|
|
208
238
|
// Only explicit scope atoms may replace removed hypotheses. A missing
|
|
209
239
|
// unrelated hypothesis is not silently discarded, even if unused.
|
|
210
240
|
if (!rows.length || !rows.every(row => supplied.has(canon(row))))
|
|
211
|
-
return
|
|
241
|
+
return report({ stage: 'lemma-retarget', part: 'independent-lemma', reason: 'missing-hypothesis', sourceFact: hyp, sourcePath: scope });
|
|
212
242
|
}
|
|
213
243
|
}
|
|
214
244
|
const local = { ...to, hyps: slice.map(i => to.hyps[i]) };
|
|
215
|
-
const tree = ordinary(source, local, lemma.tree, proofPath(lemma.when, lemma.cut), path, until);
|
|
245
|
+
const tree = ordinary(source, local, lemma.tree, proofPath(lemma.when, lemma.cut), path, until, report);
|
|
216
246
|
if (!tree || !alive(until) || !check(local, tree, proofPath(when, lemma.cut)) || !alive(until))
|
|
217
|
-
return
|
|
247
|
+
return report({ stage: 'lemma-retarget', part: 'independent-lemma', reason: 'target-independent-check' });
|
|
218
248
|
const moved = { when, cut: lemma.cut, tree, slice };
|
|
219
249
|
if (key !== undefined)
|
|
220
250
|
rememberRetarget(lemma, key, moved);
|
|
@@ -224,14 +254,17 @@ function retarget(from, to, lemmas, scope, until, onlyMissing = false) {
|
|
|
224
254
|
}
|
|
225
255
|
/** Retarget an annotated or mixed proof, without turning cuts into split trees.
|
|
226
256
|
* before/after are ordinary entry paths, not paths already augmented by cuts. */
|
|
227
|
-
export function transportConditionalProof(from, to, tree, before, after, until) {
|
|
257
|
+
export function transportConditionalProof(from, to, tree, before, after, until, options) {
|
|
258
|
+
const report = reporter(options);
|
|
228
259
|
try {
|
|
260
|
+
if (!validNative(options?.native?.from) || !validNative(options?.native?.to))
|
|
261
|
+
return report({ stage: 'cut-validation', part: 'main', reason: 'invalid-native-cuts-or-counts' });
|
|
229
262
|
const visit = (t, a, b, source, target) => {
|
|
230
263
|
if (!alive(until))
|
|
231
264
|
return undefined;
|
|
232
265
|
const own = marked.get(t);
|
|
233
266
|
if (own) {
|
|
234
|
-
const lemmas = retarget(own.goal, to, own.lemmas, b, until, true);
|
|
267
|
+
const lemmas = retarget(own.goal, to, own.lemmas, b, until, true, report);
|
|
235
268
|
if (!lemmas)
|
|
236
269
|
return undefined;
|
|
237
270
|
source = own;
|
|
@@ -239,7 +272,7 @@ export function transportConditionalProof(from, to, tree, before, after, until)
|
|
|
239
272
|
}
|
|
240
273
|
let out;
|
|
241
274
|
if ('leaf' in t)
|
|
242
|
-
out = leaf(source.goal, to, t,
|
|
275
|
+
out = leaf(source.goal, to, t, mainPath(options?.native?.from, source.lemmas, a), mainPath(options?.native?.to, target.lemmas, b), until, report);
|
|
243
276
|
else {
|
|
244
277
|
const known = decide(t.split, b);
|
|
245
278
|
if (known !== undefined)
|
|
@@ -257,24 +290,31 @@ export function transportConditionalProof(from, to, tree, before, after, until)
|
|
|
257
290
|
return out;
|
|
258
291
|
};
|
|
259
292
|
const out = visit(tree, before, after, { goal: from, lemmas: [] }, { goal: to, lemmas: [] });
|
|
260
|
-
|
|
293
|
+
if (!out)
|
|
294
|
+
return report({ stage: 'transport', part: 'main', reason: alive(until) ? 'tree-transport-refused' : 'deadline' });
|
|
295
|
+
return checked(to, out, after, until, options?.native?.to) ? out : report({ stage: 'transport-check', part: 'main', reason: alive(until) ? 'native-tree-check' : 'deadline' });
|
|
261
296
|
}
|
|
262
|
-
catch {
|
|
263
|
-
|
|
297
|
+
catch (error) {
|
|
298
|
+
if (options?.rethrowBudgetExpired && error instanceof BudgetExpired)
|
|
299
|
+
throw error;
|
|
300
|
+
return reporter(options)({ stage: 'exception', part: 'main', reason: error instanceof Error ? error.name : 'non-error' });
|
|
264
301
|
}
|
|
265
302
|
}
|
|
266
303
|
/** Finalize at the empty root. Each local list is guarded by its entry path so
|
|
267
304
|
* exporting it cannot add assumptions to unrelated ordinary siblings. Every
|
|
268
305
|
* leaf is then reindexed, even if it did not originally carry metadata. */
|
|
269
|
-
export function collectConditionalCertificate(goal, tree, until) {
|
|
306
|
+
export function collectConditionalCertificate(goal, tree, until, options) {
|
|
307
|
+
const report = reporter(options), native = options?.native?.to;
|
|
270
308
|
try {
|
|
309
|
+
if (!validNative(native))
|
|
310
|
+
return report({ stage: 'cut-validation', part: 'main', reason: 'invalid-native-cuts-or-counts' });
|
|
271
311
|
const lemmas = [];
|
|
272
312
|
const collect = (t, path) => {
|
|
273
313
|
if (!alive(until))
|
|
274
314
|
return false;
|
|
275
315
|
const own = marked.get(t);
|
|
276
316
|
if (own) {
|
|
277
|
-
const cuts = retarget(own.goal, goal, own.lemmas, path, until);
|
|
317
|
+
const cuts = retarget(own.goal, goal, own.lemmas, path, until, false, report);
|
|
278
318
|
if (!cuts)
|
|
279
319
|
return false;
|
|
280
320
|
for (const cut of cuts) {
|
|
@@ -286,21 +326,23 @@ export function collectConditionalCertificate(goal, tree, until) {
|
|
|
286
326
|
return 'leaf' in t || legalSplit(t, path) && collect(t.yes, put(path, t.split, true)) && collect(t.no, put(path, t.split, false));
|
|
287
327
|
};
|
|
288
328
|
if (!collect(tree, new Map()))
|
|
289
|
-
return
|
|
329
|
+
return report({ stage: 'collection', part: 'main', reason: alive(until) ? 'cut-or-branch-refused' : 'deadline' });
|
|
290
330
|
const finish = (t, path, context) => {
|
|
291
331
|
if (!alive(until))
|
|
292
332
|
return undefined;
|
|
293
333
|
context = marked.get(t) ?? context;
|
|
294
334
|
if ('leaf' in t)
|
|
295
|
-
return leaf(context.goal, goal, t,
|
|
335
|
+
return leaf(context.goal, goal, t, mainPath(native, context.lemmas, path), mainPath(native, lemmas, path), until, report);
|
|
296
336
|
const yes = finish(t.yes, put(path, t.split, true), context);
|
|
297
337
|
const no = yes && finish(t.no, put(path, t.split, false), context);
|
|
298
338
|
return yes && no ? { split: t.split, yes, no } : undefined;
|
|
299
339
|
};
|
|
300
340
|
const out = finish(tree, new Map(), { goal, lemmas: [] });
|
|
301
|
-
return out && alive(until) && checkGoalLemmas(goal, out, lemmas) && alive(until) ? { tree: out, lemmas } :
|
|
341
|
+
return out && alive(until) && checkGoalLemmas(goal, out, lemmas, native?.frames, native?.counts, native?.monos, native?.lins) && alive(until) ? { tree: out, lemmas } : report({ stage: 'collection-check', part: 'main', reason: alive(until) ? 'native-certificate-check' : 'deadline' });
|
|
302
342
|
}
|
|
303
|
-
catch {
|
|
304
|
-
|
|
343
|
+
catch (error) {
|
|
344
|
+
if (options?.rethrowBudgetExpired && error instanceof BudgetExpired)
|
|
345
|
+
throw error;
|
|
346
|
+
return reporter(options)({ stage: 'exception', part: 'main', reason: error instanceof Error ? error.name : 'non-error' });
|
|
305
347
|
}
|
|
306
348
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
1
2
|
// Untrusted model-driven recovery. Scalar facts are prepared once; numeric
|
|
2
3
|
// countermodels select batches of pointwise facts at bounded row leaves. Every
|
|
3
4
|
// cut and the final tree are independently checked, without new axioms.
|
|
@@ -47,7 +48,7 @@ export function deriveCountClosure(m, ds, g, cert, root, until, trace, options =
|
|
|
47
48
|
let base = new Map(root);
|
|
48
49
|
let leafEnd;
|
|
49
50
|
const alive = () => clock() < until && !pastWall(), building = () => clock() < (leafEnd ?? buildEnd) && !pastWall();
|
|
50
|
-
const wallEnd = () => Math.min(wallAt(),
|
|
51
|
+
const wallEnd = () => Math.min(wallAt(), countedSearchNow() + Math.min(10000, Math.max(0, (leafEnd ?? until) - clock()) * 10));
|
|
51
52
|
const transport = (from, to, t, a, b) => alive() ? withDeadline(Math.min(until, leafEnd ?? until), () => widen(from, to, t, {}, a, b)) : undefined;
|
|
52
53
|
const sourceCache = new WeakMap();
|
|
53
54
|
const source = (path, witness) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
1
2
|
// Untrusted activation case splitting. Every leaf is transported back to
|
|
2
3
|
// the original goal/path, and the complete split tree is checked once more.
|
|
3
4
|
import { plus, n } from "../machine.js";
|
|
@@ -92,7 +93,7 @@ function guardCasesImpl(m, ds, g, cert, guard, until, trace, slot = 0, root = ne
|
|
|
92
93
|
}
|
|
93
94
|
// The complete guard tree below checks active proofs after source transport.
|
|
94
95
|
// Avoid checking the same large active tree before and after that transport.
|
|
95
|
-
const lifted = proof && (sourceOnly ? proof : hasConditionalProof(proof) ? transportConditionalProof(goal, g, proof, path, path, Math.min(wallAt(),
|
|
96
|
+
const lifted = proof && (sourceOnly ? proof : hasConditionalProof(proof) ? transportConditionalProof(goal, g, proof, path, path, Math.min(wallAt(), countedSearchNow() + Math.max(0, end - clock()) * 10)) : widen(goal, g, proof, {}, path, path)), accepted = !!lifted && (active || deferNested || check(g, lifted, path));
|
|
96
97
|
if (accepted && lifted && !hasConditionalProof(lifted))
|
|
97
98
|
options.memo?.put(g, path, lifted);
|
|
98
99
|
if (!active && accepted && lifted && !inactiveLeaf)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Reindex a plain proof into a counted tree whose conditional cuts become
|
|
2
|
+
// active at different descendant paths. Root-only rebasing is insufficient:
|
|
3
|
+
// a newly active cut changes the leaf's input-row numbers.
|
|
4
|
+
import { canon, check } from "../../kernel/kernel.js";
|
|
5
|
+
import { late } from "../../kernel/prove.js";
|
|
6
|
+
import { rebasePath } from "./rebase-path.js";
|
|
7
|
+
export function reframeCountTree(goal, tree, from, to, frame, until) {
|
|
8
|
+
const visit = (node, source, target) => {
|
|
9
|
+
if (late(until))
|
|
10
|
+
return;
|
|
11
|
+
if ('leaf' in node) {
|
|
12
|
+
const at = frame(target), leaf = rebasePath(goal, node, source, at, until);
|
|
13
|
+
return leaf && check(goal, leaf, at) ? leaf : undefined;
|
|
14
|
+
}
|
|
15
|
+
const id = canon(node.split);
|
|
16
|
+
if (target.has(id) || Object.keys(node.split).every(name => name === '1'))
|
|
17
|
+
return;
|
|
18
|
+
const next = (path, holds) => new Map(path).set(id, { lin: node.split, holds });
|
|
19
|
+
const yes = visit(node.yes, next(source, true), next(target, true));
|
|
20
|
+
const no = yes && visit(node.no, next(source, false), next(target, false));
|
|
21
|
+
return yes && no ? { split: node.split, yes, no } : undefined;
|
|
22
|
+
};
|
|
23
|
+
return visit(tree, from, to);
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// An untrusted proof supplies split hints only. Every replacement leaf is
|
|
2
|
+
// proved from the original goal/path by the ordinary linear solver/checker.
|
|
3
|
+
import { canon, check } from "../../kernel/kernel.js";
|
|
4
|
+
import { late, rowsAt } from "../../kernel/prove.js";
|
|
5
|
+
import { solve } from "../solver.js";
|
|
6
|
+
export function replayLinearSkeleton(goal, hint, root, until) {
|
|
7
|
+
const go = (tree, path) => {
|
|
8
|
+
if (late(until))
|
|
9
|
+
return;
|
|
10
|
+
if ('leaf' in tree) {
|
|
11
|
+
const result = solve(rowsAt(goal, path), 2000);
|
|
12
|
+
if (result.kind !== 'refuted')
|
|
13
|
+
return;
|
|
14
|
+
const out = { leaf: result.steps };
|
|
15
|
+
return check(goal, out, path) ? out : undefined;
|
|
16
|
+
}
|
|
17
|
+
const id = canon(tree.split), known = path.get(id)?.holds;
|
|
18
|
+
if (known !== undefined)
|
|
19
|
+
return go(known ? tree.yes : tree.no, path);
|
|
20
|
+
const yes = go(tree.yes, new Map(path).set(id, { lin: tree.split, holds: true }));
|
|
21
|
+
if (!yes)
|
|
22
|
+
return;
|
|
23
|
+
const no = go(tree.no, new Map(path).set(id, { lin: tree.split, holds: false }));
|
|
24
|
+
return no ? { split: tree.split, yes, no } : undefined;
|
|
25
|
+
};
|
|
26
|
+
const tree = go(hint, root);
|
|
27
|
+
return tree && check(goal, tree, root) ? tree : undefined;
|
|
28
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "../wall.js";
|
|
1
2
|
// Untrusted row-equality case proposals. Every ordering branch is covered and
|
|
2
3
|
// every reused recipe is widened and checked at its destination path.
|
|
3
4
|
import { n, same, walkOnce, x } from "../machine.js";
|
|
@@ -227,7 +228,7 @@ function proveRowCasesImpl(g, root, pairs, until, prove, trace, options = {}) {
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
if (old) {
|
|
230
|
-
const end = Math.min(until, clock() + 50), t = hasConditionalProof(old.tree) ? transportConditionalProof(g, g, old.tree, old.path, path, Math.min(wallAt(),
|
|
231
|
+
const end = Math.min(until, clock() + 50), t = hasConditionalProof(old.tree) ? transportConditionalProof(g, g, old.tree, old.path, path, Math.min(wallAt(), countedSearchNow() + Math.max(0, end - clock()) * 10)) : withDeadline(end, () => widen(g, g, old.tree, {}, old.path, path));
|
|
231
232
|
const accepted = !!t && (options.deferToCaller || check(g, t, path));
|
|
232
233
|
if (accepted && t) {
|
|
233
234
|
trace?.({ stage: 'row-case', key, cached: true, ms: Math.round(clock() - begun), checked: !options.deferToCaller, proposed: true, deferred: !!options.deferToCaller });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CountTierBudget } from './count-tier-budget.js';
|
|
2
|
+
export type CountRejectionBudget = Readonly<{
|
|
3
|
+
captureUntil: number;
|
|
4
|
+
rejectionUntil: number;
|
|
5
|
+
rejectionLimit: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function countRejectionBudget(budget: CountTierBudget | undefined, enabled: boolean): CountRejectionBudget | undefined;
|
|
8
|
+
export declare function remainingRejectionAllowance(budget: CountRejectionBudget, now: number): number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// One third of the generation tier, not an absolute provisional-unit ceiling.
|
|
2
|
+
export function countRejectionBudget(budget, enabled) {
|
|
3
|
+
if (!enabled || !budget?.active)
|
|
4
|
+
return;
|
|
5
|
+
const start = budget.until - budget.workAllowance, end = Math.min(budget.until, budget.generationUntil);
|
|
6
|
+
if (![start, end, budget.workAllowance].every(Number.isFinite) || budget.workAllowance < 0)
|
|
7
|
+
throw new RangeError('invalid rejection tier');
|
|
8
|
+
const generation = Math.max(0, end - start), rejectionLimit = generation / 3;
|
|
9
|
+
return Object.freeze({ captureUntil: end - rejectionLimit, rejectionUntil: end, rejectionLimit });
|
|
10
|
+
}
|
|
11
|
+
export function remainingRejectionAllowance(budget, now) {
|
|
12
|
+
if (!Number.isFinite(now))
|
|
13
|
+
throw new RangeError('invalid rejection clock');
|
|
14
|
+
return Math.max(0, Math.min(budget.rejectionLimit, budget.rejectionUntil - now));
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Law } from './machine.js';
|
|
2
|
+
import { type GuardCountContext } from './count-guard-context.js';
|
|
3
|
+
import { type CountRequestBuilder, type CountStrategyProof, type CountStrategyOptions } from './count-strategy.js';
|
|
4
|
+
import { type Instances } from '../kernel/kernel.js';
|
|
5
|
+
export declare function proveCountReplacement(context: GuardCountContext, family: Law[], law: Law, seed: Instances, until: number, requestFor: CountRequestBuilder, observe?: (stage: string, checked: boolean) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Optional ordinary count proof for a guarded row replacement. Every supplied
|
|
2
|
+
// fact is a count instance or a family-law instance, never a trusted premise.
|
|
3
|
+
import { n, x, get, same, walkOnce } from "./machine.js";
|
|
4
|
+
import { discoverCountThresholdWrite } from "./count-write-shape.js";
|
|
5
|
+
import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
|
|
6
|
+
import { countGuardTree } from "./count-guard-tree.js";
|
|
7
|
+
import { countsForReads } from "./count-facts.js";
|
|
8
|
+
import { countPrimitiveUnits } from "./count-primitive-budget.js";
|
|
9
|
+
import { finishCountStrategy, strategyLeafUntil } from "./count-strategy.js";
|
|
10
|
+
import { add, k, scale, sub, solve } from "./solver.js";
|
|
11
|
+
import { check, countedObligations, frameOk, framePath, linear, mcGoal, substC } from "../kernel/kernel.js";
|
|
12
|
+
import { clock, pastWall, rowsAt, withDeadline } from "../kernel/prove.js";
|
|
13
|
+
import { growCdcl } from "../kernel/cdcl.js";
|
|
14
|
+
import { countSearchView, proveCountQuery } from "./count-query.js";
|
|
15
|
+
import { rebasePath } from "./count-recovery/rebase-path.js";
|
|
16
|
+
import { replayLinearSkeleton } from "./count-recovery/replay-linear-skeleton.js";
|
|
17
|
+
export function proveCountReplacement(context, family, law, seed, until, requestFor, observe, options = {}) {
|
|
18
|
+
return withDeadline(until, () => {
|
|
19
|
+
const m = context.machine, shape = context.shape, choice = fixedCountFrameCase(m), index = family.indexOf(law);
|
|
20
|
+
if (!choice || index < 0 || clock() >= until || pastWall())
|
|
21
|
+
return;
|
|
22
|
+
const write = discoverCountThresholdWrite(context.original, shape, choice);
|
|
23
|
+
if (!write || write.increment !== 0 || !write.committedInput || !write.committedCount)
|
|
24
|
+
return;
|
|
25
|
+
const { voteMap, rowMap, width } = shape, sourceName = write.source, newSet = write.input, setMap = context.inputCounts[newSet], quorumMap = context.inputCounts[write.committedInput];
|
|
26
|
+
const outside = context.restrictions.find(e => e.base === setMap && e.input === write.committedInput)?.negative;
|
|
27
|
+
if (!setMap || !quorumMap || !outside)
|
|
28
|
+
return;
|
|
29
|
+
const a = x(law.forall + '#'), b = x(law.keys[0]), i = x(sourceName);
|
|
30
|
+
const flagSub = { vars: {}, maps: {}, flags: Object.fromEntries(Object.entries(m.step.flags ?? {}).map(([name, c]) => [name, c.op === 'all' ? same(x('?' + name), n(1)) : c])) };
|
|
31
|
+
let active = m.step.flags[write.guard];
|
|
32
|
+
for (let depth = 0; depth < 8; depth++)
|
|
33
|
+
active = substC(active, flagSub);
|
|
34
|
+
let unsupported = false;
|
|
35
|
+
walkOnce(active, (node) => { if (node.op === 'flag' || node.op === 'all')
|
|
36
|
+
unsupported = true; });
|
|
37
|
+
if (unsupported)
|
|
38
|
+
return;
|
|
39
|
+
const sourceTerm = get(shape.memberField, i), otherThreshold = get(shape.thresholdField, b), atoms = (c) => c.op === 'and' ? c.xs.flatMap(atoms) : [c];
|
|
40
|
+
const sourceVoteMap = voteMap;
|
|
41
|
+
const rowFields = new Set([shape.membershipMap]);
|
|
42
|
+
const sourceRow = Object.keys(m.counts).find(name => { const d = m.counts[name]; let source = false; const fields = new Set(); walkOnce(d.body, (node) => { if (node.op === 'get')
|
|
43
|
+
fields.add(node.map); if (node.op === 'var' && node.name === sourceName)
|
|
44
|
+
source = true; }); return !d.base && source && fields.size === 1 && fields.has(shape.membershipMap); });
|
|
45
|
+
const difference = (left) => Object.keys(m.counts).find(name => { const d = m.counts[name]; if (d.base || d.body.op !== 'if')
|
|
46
|
+
return false; const cs = atoms(d.body.c); return cs.some(c => c.op === 'not' && (() => { let found = false; walkOnce(c.x, (node) => { if (node.op === 'get' && (left ? node.map === newSet : rowFields.has(node.map)))
|
|
47
|
+
found = true; }); return found; })()) && cs.some(c => { let found = false; walkOnce(c, (node) => { if (node.op === 'get' && (left ? rowFields.has(node.map) : node.map === newSet))
|
|
48
|
+
found = true; }); return found; }); });
|
|
49
|
+
const leftMap = difference(true), rightMap = difference(false), intersection = Object.keys(m.counts).find(name => { const d = m.counts[name]; if (d.base || d.body.op !== 'if' || atoms(d.body.c).some(c => c.op === 'not'))
|
|
50
|
+
return false; const fields = new Set(); walkOnce(d.body, (node) => { if (node.op === 'get')
|
|
51
|
+
fields.add(node.map); }); return fields.has(newSet) && fields.has(shape.membershipMap); });
|
|
52
|
+
if (!sourceRow || !leftMap || !rightMap || !intersection)
|
|
53
|
+
return;
|
|
54
|
+
const scope = JSON.stringify([m, family, seed]);
|
|
55
|
+
let prefix = 'replace$';
|
|
56
|
+
while (scope.includes('"' + prefix))
|
|
57
|
+
prefix = '$' + prefix;
|
|
58
|
+
const labels = Array.from({ length: 15 }, (_, j) => prefix + 'w' + j), instances = { ...ownCountLawInstance(law, seed) };
|
|
59
|
+
instances[law.name] = [...(instances[law.name] ?? []), i, b];
|
|
60
|
+
for (const [name, q] of Object.entries(m.step.flags ?? {}))
|
|
61
|
+
if (q.op === 'all' && !q.keys?.length)
|
|
62
|
+
instances['?' + name] = [...(seed['?' + name] ?? []), ...labels.map(x)];
|
|
63
|
+
const step = countedObligations(m, family, { [law.name]: instances }, index).at(-1);
|
|
64
|
+
if (!step)
|
|
65
|
+
return;
|
|
66
|
+
const base = requestFor(step.goal, step.decls), reads = [...base.reads];
|
|
67
|
+
const key = (map, args) => { const d = m.counts[map.replace(/#$/, '')]; return d.base ? { op: 'add', a: { op: 'mul', k: d.base, a: args[0] }, b: args[1] } : args[0]; };
|
|
68
|
+
const bind = (map, args) => { const at = key(map, args), old = reads.find(r => r[1] === map && JSON.stringify(r[2]) === JSON.stringify(at)); if (old)
|
|
69
|
+
return old[0]; const name = prefix + 'r' + reads.length; reads.push([name, map, at]); return name; };
|
|
70
|
+
const names = { X: bind(sourceRow, [n(0)]), B: bind(rowMap, [i]), preA: bind(rowMap, [a]), A: bind(rowMap + '#', [a]), S: bind(setMap, [n(0)]), Q: bind(quorumMap, [n(0)]), O: bind(outside, [n(0)]), L: bind(leftMap, [n(0)]), R: bind(rightMap, [n(0)]), I: bind(intersection, [n(0)]), V: bind(voteMap + '#', [a, b]), preV: bind(voteMap, [a, b]), weakV: bind(sourceVoteMap, [i, b]) };
|
|
71
|
+
const combinations = [[[1, names.X], [-1, names.B]], [[1, names.B], [-1, names.X]], [[1, names.A], [-1, names.S]], [[1, names.S], [-1, names.A]], [[1, names.B], [-1, names.L], [-1, names.I]], [[-1, names.B], [1, names.L], [1, names.I]], [[1, names.S], [-1, names.R], [-1, names.I]], [[-1, names.S], [1, names.R], [1, names.I]], [[1, names.Q], [-1, names.B]], [[1, names.O], [-1, names.S]], [[1, names.Q], [1, names.O], [-1, names.L], [-1, names.R], [-1, names.I]], [[1, names.V], [-1, names.O]], [[1, names.Q], [-1, names.weakV]], [[1, names.V], [-1, names.preV]], [[1, names.preA], [-1, names.A]]];
|
|
72
|
+
const counts = countsForReads(step.decls, reads);
|
|
73
|
+
if (!counts?.length)
|
|
74
|
+
return;
|
|
75
|
+
const insts = combinations.map((terms, j) => ({ wit: labels[j], below: counts[0].below, terms, unit: 0 })), cert = { reads, insts, picks: [], tree: { leaf: [] }, frames: [] }, goal = mcGoal(step.goal.hyps, step.decls, cert);
|
|
76
|
+
if (!goal)
|
|
77
|
+
return;
|
|
78
|
+
const ask = (path, stage, selected) => {
|
|
79
|
+
if (clock() >= until || pastWall())
|
|
80
|
+
return;
|
|
81
|
+
const p = framePath(cert.frames ?? [], [], path);
|
|
82
|
+
if (options.minimalView && selected !== undefined) {
|
|
83
|
+
const minimal = countSearchView(step.goal, step.decls, cert, insts[selected]);
|
|
84
|
+
if (minimal) {
|
|
85
|
+
const tree = proveCountQuery(goal, p, until, { query: stage + ':' + selected, minimal, direct: true, minimalUnits: countPrimitiveUnits(900, options.leafUnits), fullUnits: countPrimitiveUnits(900, options.leafUnits), leafUnits: options.leafUnits, trace: options.trace });
|
|
86
|
+
observe?.(stage, !!tree);
|
|
87
|
+
return tree;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const direct = solve(rowsAt(goal, p), 2000);
|
|
91
|
+
if (direct.kind === 'refuted') {
|
|
92
|
+
const tree = { leaf: direct.steps };
|
|
93
|
+
if (check(goal, tree, p))
|
|
94
|
+
return tree;
|
|
95
|
+
}
|
|
96
|
+
const hyps = selected === undefined ? step.goal.hyps : step.goal.hyps.filter(h => { let unrelated = false; walkOnce(h, (node) => { if (node.op === 'if' || node.op === 'var' && node.name.startsWith(prefix + 'w') && node.name !== insts[selected].wit)
|
|
97
|
+
unrelated = true; }); return !unrelated; });
|
|
98
|
+
const view = selected === undefined ? goal : mcGoal(hyps, step.decls, { reads, insts: [insts[selected]], picks: [] });
|
|
99
|
+
if (!view)
|
|
100
|
+
return;
|
|
101
|
+
const result = growCdcl(view, p, { nodes: 0, until: Math.min(strategyLeafUntil(until, options), clock() + countPrimitiveUnits(900, options.leafUnits)) }), tree = 'tree' in result ? rebasePath(view, result.tree, p, p, Math.min(strategyLeafUntil(until, options), clock() + countPrimitiveUnits(600, options.leafUnits)), goal) ?? replayLinearSkeleton(goal, result.tree, p, Math.min(strategyLeafUntil(until, options), clock() + countPrimitiveUnits(600, options.leafUnits))) : undefined;
|
|
102
|
+
const checked = !!tree && check(goal, tree, p);
|
|
103
|
+
observe?.(stage, checked);
|
|
104
|
+
return checked ? tree : undefined;
|
|
105
|
+
};
|
|
106
|
+
const split = countGuardTree(until), fact = (j, p, yes) => split.rows([add(...combinations[j].map(([c, v]) => ({ [v]: c })))], p, yes, q => ask(q, 'count-fact', j));
|
|
107
|
+
const facts = (js, p, yes) => js.length ? fact(js[0], p, q => facts(js.slice(1), q, yes)) : yes(p);
|
|
108
|
+
const frame = (p) => { for (const map of [rowMap, voteMap]) {
|
|
109
|
+
const r = reads.find(r => r[1] === map + '#'), pre = reads.find(t => t[1] === map && JSON.stringify(t[2]) === JSON.stringify(r[2]));
|
|
110
|
+
if (!pre)
|
|
111
|
+
continue;
|
|
112
|
+
const cut = { post: r[0], pre: pre[0], when: [...p.values()].map(t => t.holds ? t.lin : add(scale(t.lin, -1), k(1))) };
|
|
113
|
+
if (frameOk(counts, cut))
|
|
114
|
+
cert.frames.push(cut);
|
|
115
|
+
} ; return ask(p, 'no-op'); };
|
|
116
|
+
const arithmetic = (p) => split.rows([{ [names.O]: 2, [names.S]: -1 }], p, q => ask(q, 'main'), q => {
|
|
117
|
+
const differences = [];
|
|
118
|
+
walkOnce(m.step.flags[write.guard], (node) => { if (node.op === 'sub')
|
|
119
|
+
differences.push(node); });
|
|
120
|
+
const cuts = differences.flatMap(e => { if (e.op !== 'sub')
|
|
121
|
+
return []; const a = linear(e.a, p), b = linear(e.b, p); return a && b ? [sub(b, a)] : []; });
|
|
122
|
+
const choose = (j, path) => j === cuts.length ? ask(path, 'overlap') : split.rows([cuts[j]], path, q => choose(j + 1, q), q => choose(j + 1, q));
|
|
123
|
+
return choose(0, q);
|
|
124
|
+
});
|
|
125
|
+
const domain = { op: 'and', xs: [a, b, i].flatMap(t => [{ op: '<', a: t, b: counts[0].below }, { op: '<', a: t, b: n(width) }]) };
|
|
126
|
+
const tree = split.rows(countFrameConditions(choice), new Map(), p => split.condition(domain, p, q => split.condition(active, q, r => split.condition(same(a, i), r, s => facts(Array.from({ length: 11 }, (_, j) => j), s, t => split.condition({ op: '<=', a: otherThreshold, b: sourceTerm }, t, u => fact(11, u, arithmetic), u => fact(12, u, v => ask(v, 'high-threshold')))), s => fact(13, s, t => fact(14, t, u => ask(u, 'unchanged-row')))), frame), q => ask(q, 'outside-domain')), p => ask(p, 'outside-operation'));
|
|
127
|
+
return tree ? finishCountStrategy(m, family, law, instances, voteMap, { ...cert, tree }, until, requestFor, undefined, options) : undefined;
|
|
128
|
+
});
|
|
129
|
+
}
|