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
package/dist/core/counts.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow, traceNow as countedTraceNow, wallDeadline } from "./wall.js";
|
|
2
|
+
import { isLocalCountExpiration } from "./count-tier-budget.js";
|
|
3
|
+
import { withSearchAllowance } from "./count-search-allowance.js";
|
|
4
|
+
import { canUseCountedProxy, withCountedSearchPolicy } from "./search-policy.js";
|
|
5
|
+
import { workRefusalWhy } from "./work-refusal.js";
|
|
6
|
+
import { withEvaluationAdmission } from "./work-observe.js";
|
|
7
|
+
import { finalCountStepDeferralEnabled, closingCountCheck } from "./count-final-step.js";
|
|
1
8
|
import { assumed, checkCountedLaws, checkMC, countedObligations, mcGoal, scope, substC, substE } from "../kernel/kernel.js";
|
|
2
|
-
import { brokenOf, clock, counted, fullRate, grow, modelInstances, wallAt, widen, withDeadline, withWall } from "../kernel/prove.js";
|
|
9
|
+
import { BudgetExpired, brokenOf, clock, counted, fullRate, fullWork, grow, modelInstances, wallAt, widen, withDeadline, withinDeadline, withWall } from "../kernel/prove.js";
|
|
3
10
|
import { REFUTED, cdclStats } from "../kernel/cdcl.js";
|
|
4
11
|
import { modelSequence } from "../kernel/model-sequence.js";
|
|
5
12
|
import { inferLaws } from "./infer.js";
|
|
6
13
|
import { carryCandidates, scanPrefixes } from "./carry.js";
|
|
7
14
|
import { relevantGoals, relevantLaws } from "./relevance.js";
|
|
8
15
|
import { countPoolKey, countSignature, grammarPool, ids, polaritySelection, readTuples, refinementSignature, reservationReadClosure, reservationState, reservePool, prepareSupport, smallSelection, sparseReadInstances, sourceContext, coarseContext, selectedCertificate, chosenView, candidateWork, stableState, UnsupportedCountProposal } from "./count-support.js";
|
|
9
|
-
import { fieldLaws } from "./field-laws.js";
|
|
16
|
+
import { fieldLaws, selectFieldLaws } from "./field-laws.js";
|
|
10
17
|
import { quorumLaws } from "./quorum-laws.js";
|
|
11
18
|
import { countCubes, liftedOneKeyCounts } from "./count-cubes.js";
|
|
12
19
|
import { finiteHoudini } from "./finite-houdini.js";
|
|
@@ -19,6 +26,7 @@ export { attemptShare, supportBudget } from "./support-budget.js";
|
|
|
19
26
|
import { proposeCountUnions } from "./count-unions.js";
|
|
20
27
|
import { focusedCountRecoveryEnabled, proveFocusedCounts } from "./count-focus-proof.js";
|
|
21
28
|
import { preferMemberInclusions } from "./count-recovery/member-inclusions.js";
|
|
29
|
+
import { fixedCountFrameCase, ownCountLawInstance, proveCountFrameGoal } from "./count-frames.js";
|
|
22
30
|
import { independentCountInstances } from "./count-focused.js";
|
|
23
31
|
import { admitMemberWitnesses, instantiateMemberPremises, memberHints, memberPremiseState } from "./count-recovery/member-premises.js";
|
|
24
32
|
import { smallOf, trueSmall } from "./exists.js";
|
|
@@ -26,19 +34,46 @@ import { WallExpired, checkWall, searchWall } from "./wall.js";
|
|
|
26
34
|
import { env } from "./solver.js";
|
|
27
35
|
import { proofOrigins, proposeLemmaCuts } from "./lemma-cuts.js";
|
|
28
36
|
import { countedCertificateHyps, transportCountCertificate } from "./count-cert-transport.js";
|
|
37
|
+
import { scopeCountProof, replayScopedCountProof, isCheckedReducedScope, withCountScopeIdentityObservation, countScopeContextKey } from "./count-proof-scope.js";
|
|
38
|
+
import { assertLiftedWorkLease, prepareCountStrategyMachine, proveCountStrategies, proposeCountStrategiesForClosing, proveCountStrategyKind, proposeCountStrategyKindForClosing, selectedCountStrategies } from "./count-strategies.js";
|
|
39
|
+
import { CountRecipeContexts } from "./count-recipe-context.js";
|
|
40
|
+
import { CountRecipePass, runCountRecipeController } from "./count-recipe-controller.js";
|
|
41
|
+
import { discoverLiftedCountGuard, discoverLiftedCountOperations } from "./count-lifted-shape.js";
|
|
42
|
+
import { completeWorkProfile } from "./work-profile.js";
|
|
43
|
+
import { workLedger } from "./work-admission.js";
|
|
44
|
+
import { exactRaw, workAdd, workSub, zeroWork } from "./work-amount.js";
|
|
45
|
+
import { workMap, workFilter, workEntries } from "./work-collections.js";
|
|
46
|
+
import { countTierBudget, remainingCountTierBudget, ordinaryTierShare } from "./count-tier-budget.js";
|
|
47
|
+
import { countRejectionBudget, remainingRejectionAllowance } from "./count-rejection-budget.js";
|
|
48
|
+
import { countGenerationPhase } from "./count-generation-phase.js";
|
|
49
|
+
import { countReachabilityScreen, optionalReachabilityScreen } from "./count-reachability.js";
|
|
50
|
+
import { reconcileReachableRejections, withoutReachableRejections } from "./count-reachability-reconcile.js";
|
|
51
|
+
import { rejectionStage } from "./rejection-discovery.js";
|
|
52
|
+
import { rejectionFamily } from "./rejection-stage.js";
|
|
53
|
+
import { reserveCountClosing, reserveCheckedCountClosing, countOrdinaryUntil } from "./count-closing-budget.js";
|
|
54
|
+
import { rescopeCountProof } from "./count-proof-rescope.js";
|
|
55
|
+
import { countRescopeFunding } from "./count-rescope-funding.js";
|
|
56
|
+
import { countClosingNeeds } from "./count-closing-needs.js";
|
|
57
|
+
import { countPrerequisiteComponents } from "./count-prerequisite-components.js";
|
|
58
|
+
import { countPrerequisiteSchedule } from "./count-prerequisite-plan.js";
|
|
59
|
+
import { countComponentAttemptBudget } from "./count-component-budget.js";
|
|
60
|
+
import { prepareCountPrerequisiteMemory } from "./count-prerequisite-memory.js";
|
|
61
|
+
import { discoverRowAgreement } from "./row-agreement-shape.js";
|
|
62
|
+
import { countPremiseContext } from "./count-premise-view.js";
|
|
63
|
+
import { countPremiseSearch } from "./count-premise-search.js";
|
|
29
64
|
// (GDP_COUNTS_PROF: where a counted search's time goes, by phase, on stderr at the end; `countsDump.on`, set by research's
|
|
30
65
|
// profiles: each step goal left unknown or with a model past GDP_COUNTS_DUMP_MIN (300) hypotheses, the first GDP_COUNTS_DUMP_N (3))
|
|
31
66
|
export const cprof = {};
|
|
32
67
|
export const countsDump = {};
|
|
33
68
|
const tally = (k, n = 1) => { cprof[k] = (cprof[k] ?? 0) + n; };
|
|
34
|
-
const ptime = (k, f) => { const t =
|
|
69
|
+
const ptime = (k, f) => { const t = countedTraceNow(); try {
|
|
35
70
|
checkWall(k);
|
|
36
71
|
const out = f();
|
|
37
72
|
checkWall(k);
|
|
38
73
|
return out;
|
|
39
74
|
}
|
|
40
75
|
finally {
|
|
41
|
-
cprof[k] = (cprof[k] ?? 0) +
|
|
76
|
+
cprof[k] = (cprof[k] ?? 0) + countedTraceNow() - t;
|
|
42
77
|
} };
|
|
43
78
|
let dumped = 0;
|
|
44
79
|
// (GDP_COUNTS_LAZY=0: every instance and pick certFor proposes in the goal at once, as before; `wide`: the narrow
|
|
@@ -381,7 +416,7 @@ export function certFor(goal, decls, wide = false, most = wide ? 24 : 10, more,
|
|
|
381
416
|
// small instances reach; the guards' count comparisons (guardLaws, `guarded`); one key a row; the engine's minimal ∀
|
|
382
417
|
// cubes of at most two literals (core/infer.ts's `cubes`, read off these small states, within a quarter of the search's
|
|
383
418
|
// budget `ms`, 15 s at most), its template `shapes` (the caller's laws, or an ∃ law's frame), each guard `u < param` loosened where a caller reads u with no param bound.
|
|
384
|
-
export function candidates(src, m, caller, shapes, guarded, ms, until, support = new Set()) {
|
|
419
|
+
export function candidates(src, m, caller, shapes, guarded, ms, until, support = new Set(), publish) {
|
|
385
420
|
const source = 'machine' in src ? src.machine : src;
|
|
386
421
|
const states = ptime('small', () => smallOf(m));
|
|
387
422
|
// (a law of the state only: one the kernel's scope refuses, reading an input or a count of the request (a guard's
|
|
@@ -390,7 +425,9 @@ export function candidates(src, m, caller, shapes, guarded, ms, until, support =
|
|
|
390
425
|
scope(m, [l]);
|
|
391
426
|
return true;
|
|
392
427
|
}
|
|
393
|
-
catch {
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (publish && error instanceof BudgetExpired)
|
|
430
|
+
throw error;
|
|
394
431
|
return false;
|
|
395
432
|
} };
|
|
396
433
|
const trueAll = (l) => clock() < until && ofState(l) && trueSmall(m, [l]);
|
|
@@ -435,9 +472,10 @@ export function candidates(src, m, caller, shapes, guarded, ms, until, support =
|
|
|
435
472
|
const w = { ...c, name: name === c.name ? `${c.name} (any ${shown.join(', ')})` : name, holds: { op: 'or', xs: c.holds.xs.map(d => (d.op === 'not' ? { op: 'not', x: { op: 'and', xs: conjs(d.x).filter(keep) } } : d)) } };
|
|
436
473
|
return trueAll(w) ? w : c;
|
|
437
474
|
};
|
|
438
|
-
const
|
|
475
|
+
const loadedFields = env.GDP_COUNT_STRATEGIES === '1';
|
|
476
|
+
const cubes = cubes0.map(loosened), fields = fieldLaws(m, false, loadedFields);
|
|
439
477
|
const lifted = guarded.filter(l => quorumCandidates.has(l)), ordinary = guarded.filter(l => !quorumCandidates.has(l));
|
|
440
|
-
const newFields = fieldLaws(m).slice(fields.length, fields.length + Math.max(0, 32 - lifted.length));
|
|
478
|
+
const newFields = fieldLaws(m, true, loadedFields).slice(fields.length, fields.length + Math.max(0, 32 - lifted.length));
|
|
441
479
|
if (env.GDP_COUNTS_TRACE)
|
|
442
480
|
console.error(`counts: small ${states.map(({ sts }) => sts.length).join('/')}; cubes ${cubes.length} in ${Math.round(clock() - t1)} ms: ${cubes.map(l => l.name).join('; ')}`);
|
|
443
481
|
// (a candidate whose every conjunct a law before it states, its keys named apart by place, is not proposed again: a
|
|
@@ -450,13 +488,18 @@ export function candidates(src, m, caller, shapes, guarded, ms, until, support =
|
|
|
450
488
|
for (const q of parts(l))
|
|
451
489
|
said.add(q);
|
|
452
490
|
const prefixes = scanPrefixes(m, [...caller, ...kinds, ...guarded, ...rowLaws, ...cubes]);
|
|
491
|
+
const admitted = publish ? [] : undefined;
|
|
453
492
|
const admit = (l) => { const ps = parts(l); if (ps.every(q => said.has(q)) || !trueAll(l))
|
|
454
493
|
return false; for (const q of ps)
|
|
455
|
-
said.add(q);
|
|
494
|
+
said.add(q); if (admitted) {
|
|
495
|
+
admitted.push(l);
|
|
496
|
+
publish?.(admitted.slice());
|
|
497
|
+
} return true; };
|
|
456
498
|
let out = ptime('filter', () => [...kinds, ...ordinary, ...rowLaws, ...fields, ...prefixes, ...cubes].filter(admit));
|
|
457
499
|
const carried = carryCandidates(m, [...caller, ...kinds, ...guarded, ...rowLaws, ...cubes]);
|
|
458
500
|
out.push(...ptime('filter', () => carried.filter(admit)));
|
|
459
|
-
|
|
501
|
+
// (a guarded field law is a weakening: admitted only when the stronger form it weakens was not)
|
|
502
|
+
out.push(...ptime('quorumFilter', () => loadedFields ? selectFieldLaws([...lifted, ...newFields], admit) : [...lifted, ...newFields].filter(admit)));
|
|
460
503
|
if (lifted.length) {
|
|
461
504
|
// Counts used only by rejected liftings must not spawn another family.
|
|
462
505
|
const liftedCounts = new Set([...reads([...caller, ...out], mp => !!m.counts?.[mp]).values()].map(([mp]) => mp));
|
|
@@ -467,6 +510,9 @@ export function candidates(src, m, caller, shapes, guarded, ms, until, support =
|
|
|
467
510
|
if (liftedOneKeyCounts(source, m).some(name => liftedCounts.has(name))) {
|
|
468
511
|
out.push(...ptime('countCubes', () => countCubes(source, m, states, liftedCounts).filter(admit)));
|
|
469
512
|
out = ptime('finiteHoudini', () => finiteHoudini(source, m, caller, out, states, {
|
|
513
|
+
// Deterministic generation prefix: proposals, predecessor checks and
|
|
514
|
+
// request trials share one allowance, not a machine-speed wall stop.
|
|
515
|
+
...(loadedFields ? { workLimit: 2_000 } : {}),
|
|
470
516
|
onFinish: row => { if (env.GDP_COUNTS_TRACE)
|
|
471
517
|
console.error(`counts: finite result ${JSON.stringify(row)}`); },
|
|
472
518
|
onDrop: d => { if (env.GDP_COUNTS_TRACE)
|
|
@@ -556,6 +602,11 @@ export function cone(m, set, attempt, until, houdini = false) {
|
|
|
556
602
|
// --- the counted search ----------------------------------------------------------------------------------------------
|
|
557
603
|
// Scheduling only. Candidate membership never authorizes an assumption or a result.
|
|
558
604
|
export const activeSupport = (set, support) => set.some(l => support.has(l));
|
|
605
|
+
// A selected row strategy runs before either ordinary pass, never after a
|
|
606
|
+
// count-first attempt has already consumed its share. Default order is unchanged.
|
|
607
|
+
function firstCountPass(m, law, countFirst) {
|
|
608
|
+
return countFirst && !(env.GDP_COUNT_STRATEGIES === '1' && discoverRowAgreement(m, law)) ? 1 : 0;
|
|
609
|
+
}
|
|
559
610
|
// Count-specific scheduling needs count or global-state context, not merely a
|
|
560
611
|
// primitive pointwise implication. Otherwise preserve the ordinary family first.
|
|
561
612
|
export function countSupportContext(m, caller, set, support) {
|
|
@@ -563,13 +614,36 @@ export function countSupportContext(m, caller, set, support) {
|
|
|
563
614
|
return { laws: set, support };
|
|
564
615
|
return { laws: set.filter(l => caller.includes(l) || !support.has(l)), support: new Set() };
|
|
565
616
|
}
|
|
566
|
-
export function supportOrder(set, caller, support, forModels = false) {
|
|
617
|
+
export function supportOrder(set, caller, support, forModels = false, m) {
|
|
567
618
|
if (forModels && !activeSupport(set, support))
|
|
568
619
|
return set;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
620
|
+
const ordered = !activeSupport(set, support)
|
|
621
|
+
? [...set.filter(l => !caller.includes(l)), ...set.filter(l => caller.includes(l))]
|
|
622
|
+
: [...set.filter(l => support.has(l) && !caller.includes(l)), ...set.filter(l => caller.includes(l)), ...set.filter(l => !support.has(l) && !caller.includes(l))];
|
|
623
|
+
// Admission order only: keep model hypotheses, family membership, support
|
|
624
|
+
// status and every per-attempt allowance unchanged.
|
|
625
|
+
if (forModels || !m)
|
|
626
|
+
return ordered;
|
|
627
|
+
const countReaders = new Set(ordered.filter(l => reads(l.holds, mp => !!m.counts?.[mp]).size > 0));
|
|
628
|
+
if (env.GDP_COUNT_STRATEGIES === '1') {
|
|
629
|
+
const rows = new Set(ordered.filter(l => !countReaders.has(l) && discoverRowAgreement(m, l)));
|
|
630
|
+
if (rows.size) {
|
|
631
|
+
const ordinary = ordered.filter(l => !countReaders.has(l) && !rows.has(l));
|
|
632
|
+
return [...ordered.filter(l => countReaders.has(l)), ...ordered.filter(l => rows.has(l)),
|
|
633
|
+
...ordinary.filter(l => support.has(l) && !caller.includes(l)), ...ordinary.filter(l => caller.includes(l)),
|
|
634
|
+
...ordinary.filter(l => !support.has(l) && !caller.includes(l))];
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (!countReaders.size)
|
|
638
|
+
return ordered;
|
|
639
|
+
return [...ordered.filter(l => countReaders.has(l)),
|
|
640
|
+
...ordered.filter(l => !countReaders.has(l) && support.has(l) && !caller.includes(l)),
|
|
641
|
+
...ordered.filter(l => !countReaders.has(l) && caller.includes(l)),
|
|
642
|
+
...ordered.filter(l => !countReaders.has(l) && !support.has(l) && !caller.includes(l))];
|
|
572
643
|
}
|
|
644
|
+
// Observation only. The controller catches observer failures; they never
|
|
645
|
+
// replace the production native verdict or replenish its work allowance.
|
|
646
|
+
export const countRecipeClosingCapture = {};
|
|
573
647
|
// On the counted clock (kernel/prove.ts's `counted`, the cost model's work at fullRate a millisecond), as the engine's
|
|
574
648
|
// search is: counted fuel and ordering are unchanged up to the wall cutoff. The
|
|
575
649
|
// wall is an independent hard ceiling, including sampling and generation. A slow
|
|
@@ -583,32 +657,61 @@ function structuredFallback(until, attempt) {
|
|
|
583
657
|
return ordinary;
|
|
584
658
|
checkWall('structured fallback');
|
|
585
659
|
countsDump.on?.({ phase: 'structured-family-expansion' });
|
|
586
|
-
|
|
660
|
+
const structured = attempt(true);
|
|
661
|
+
// A local refusal may have crossed the direct caller's inherited phase.
|
|
662
|
+
// Check before withDeadline restores that phase on the return path.
|
|
663
|
+
checkWall('structured fallback completion');
|
|
664
|
+
return structured;
|
|
587
665
|
}
|
|
588
666
|
export function searchCounted(m0, caller, ms = 60_000) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
667
|
+
const reject = env.GDP_COUNT_REJECTIONS === '1' && env.GDP_COUNT_TIERS === '1' && env.GDP_COUNT_STRATEGIES === '1';
|
|
668
|
+
let m = m0, rejecting = false;
|
|
669
|
+
const run = () => {
|
|
670
|
+
const result = withWall(searchWall(ms), () => {
|
|
671
|
+
try {
|
|
672
|
+
const start = reject ? fullWork() / fullRate : 0;
|
|
673
|
+
const g = ptime('guards', () => guardLaws(m0));
|
|
674
|
+
m = { ...m0, counts: { ...m0.counts, ...g.counts } };
|
|
675
|
+
if (reject && g.laws.some(law => quorumCandidates.has(law))) {
|
|
676
|
+
rejecting = true;
|
|
677
|
+
return withCountedSearchPolicy(true, () => counted(fullRate, () => searchCounted0(m0, g, m, caller, ms, remainingCountTierBudget(start, ms, 1)), true));
|
|
678
|
+
}
|
|
679
|
+
// Leave the native preparation wall before selecting a legacy proxy.
|
|
680
|
+
// Locked rejecting ancestors and ordinary legacy mode keep the old path.
|
|
681
|
+
if (canUseCountedProxy())
|
|
682
|
+
return () => withCountedSearchPolicy(false, () => withWall(searchWall(ms), () => {
|
|
683
|
+
try {
|
|
684
|
+
ptime('small', () => smallOf(m, m0));
|
|
685
|
+
return counted(fullRate, () => searchCounted0(m0, g, m, caller, ms), true);
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
if (!(error instanceof WallExpired))
|
|
689
|
+
throw error;
|
|
690
|
+
return { proven: false, laws: caller, m, why: error.message };
|
|
691
|
+
}
|
|
692
|
+
}));
|
|
693
|
+
ptime('small', () => smallOf(m, m0));
|
|
694
|
+
return counted(fullRate, () => searchCounted0(m0, g, m, caller, ms), true);
|
|
695
|
+
}
|
|
696
|
+
catch (e) {
|
|
697
|
+
if (!(e instanceof WallExpired) && !(rejecting && e instanceof BudgetExpired))
|
|
698
|
+
throw e;
|
|
699
|
+
return { proven: false, laws: caller, m, why: e instanceof BudgetExpired ? workRefusalWhy(e) : e.message };
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
return typeof result === 'function' ? result() : result;
|
|
703
|
+
};
|
|
603
704
|
if (!env.GDP_COUNTS_PROF)
|
|
604
705
|
return run();
|
|
605
706
|
cdclStats.on = true;
|
|
606
|
-
const t =
|
|
607
|
-
console.error(`counts: prof total ${Math.round(
|
|
707
|
+
const t = countedSearchNow(), out = run();
|
|
708
|
+
console.error(`counts: prof total ${Math.round(countedSearchNow() - t)} ms; ${Object.entries(cprof).map(([k2, x]) => `${k2} ${Math.round(x)}`).join(', ')}; cdcl runs ${cdclStats.runs} conflicts ${cdclStats.conflicts} decisions ${cdclStats.decisions} solveMs ${Math.round(cdclStats.solveMs)} rowsMs ${Math.round(cdclStats.rowsMs)} coreMs ${Math.round(cdclStats.coreMs)} unfoldMs ${Math.round(cdclStats.unfoldMs)} lpMs ${Math.round(cdclStats.lpMs)} boundMs ${Math.round(cdclStats.boundMs)} orderMs ${Math.round(cdclStats.orderMs)} fmCalls ${cdclStats.fmCalls} lpMisses ${cdclStats.lpMisses} lpUnknown ${cdclStats.lpUnknown} missMs ${Math.round(cdclStats.missMs)} fastMs ${Math.round(cdclStats.fastMs)} fmOpenMs ${Math.round(cdclStats.fmOpenMs)} fmLeafMs ${Math.round(cdclStats.fmLeafMs)} nodes ${cdclStats.nodes}`);
|
|
608
709
|
return out;
|
|
609
710
|
}
|
|
610
|
-
function searchCounted0(m0, g, m, caller, ms) {
|
|
611
|
-
|
|
711
|
+
function searchCounted0(m0, g, m, caller, ms, tiers) {
|
|
712
|
+
if (tiers)
|
|
713
|
+
return searchCountedWithRejection(m0, g, m, caller, ms, tiers);
|
|
714
|
+
const tierRun = { start: clock(), source: m0 }, until = tierRun.start + ms;
|
|
612
715
|
if (!caller.every(l => clock() < until && trueSmall(m, [l])))
|
|
613
716
|
return { proven: false, laws: caller, m, why: clock() < until ? 'a law fails on the small instances' : 'time' };
|
|
614
717
|
const t1 = clock();
|
|
@@ -620,44 +723,135 @@ function searchCounted0(m0, g, m, caller, ms) {
|
|
|
620
723
|
console.error(`counts: candidates at ${Math.round(clock() - t1)} ms: ${set.map(l => l.name).join('; ')}`);
|
|
621
724
|
const context = countSupportContext(m, caller, set, support);
|
|
622
725
|
return structuredFallback(until, structured => {
|
|
623
|
-
const result = admitCountedFamilyOnce(m, caller, context.laws, context.support, until, structured);
|
|
726
|
+
const result = admitCountedFamilyOnce(m, caller, context.laws, context.support, until, structured, tierRun);
|
|
624
727
|
// Preserve full-context fallback before trying extra witness families.
|
|
625
|
-
return result.proven || context.laws.length === set.length || clock() >= until ? result : admitCountedFamilyOnce(m, caller, set, context.support, until, structured);
|
|
728
|
+
return result.proven || context.laws.length === set.length || clock() >= until ? result : admitCountedFamilyOnce(m, caller, set, context.support, until, structured, tierRun);
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
// Production rejection is a relative size-two pass inside the existing generation
|
|
732
|
+
// tier. Its single ledger and absolute endpoints survive every admission fallback.
|
|
733
|
+
function searchCountedWithRejection(m0, g, m, caller, ms, tiers) {
|
|
734
|
+
const plan = countRejectionBudget(tiers, true);
|
|
735
|
+
if (!plan)
|
|
736
|
+
return searchCounted0(m0, g, m, caller, ms);
|
|
737
|
+
const until = tiers.until, tierRun = { start: until - tiers.workAllowance, budget: tiers, source: m0 }, support = new Set(), originalCounts = { ...m.counts };
|
|
738
|
+
let partial = [...caller];
|
|
739
|
+
const generated = countGenerationPhase(plan.captureUntil, () => {
|
|
740
|
+
for (const law of g.laws) {
|
|
741
|
+
try {
|
|
742
|
+
scope(m, [law]);
|
|
743
|
+
partial.push(law);
|
|
744
|
+
}
|
|
745
|
+
catch (error) {
|
|
746
|
+
if (error instanceof BudgetExpired)
|
|
747
|
+
throw error;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
ptime('small', () => smallOf(m, m0));
|
|
751
|
+
if (!caller.every(law => clock() < until && trueSmall(m, [law])))
|
|
752
|
+
return { valid: false, set: [...caller] };
|
|
753
|
+
const set = env.GDP_COUNTS_GIVEN === '1' ? [...caller] : [...caller, ...candidates(m0, m, caller, caller, g.laws, ms, plan.captureUntil, support, laws => { partial = [...caller, ...laws]; })];
|
|
754
|
+
return { valid: true, set };
|
|
755
|
+
});
|
|
756
|
+
if (!generated.complete)
|
|
757
|
+
m.counts = { ...originalCounts, ...m.counts };
|
|
758
|
+
const bundle = generated.complete ? generated.value : { valid: true, set: partial };
|
|
759
|
+
countsDump.on?.({ phase: 'count-generation-result', complete: generated.complete, ...plan, workAllowance: tiers.workAllowance });
|
|
760
|
+
if (!bundle.valid)
|
|
761
|
+
return { proven: false, laws: caller, m, why: 'a law fails on the small instances' };
|
|
762
|
+
let set = bundle.set;
|
|
763
|
+
countsDump.on?.({ phase: 'candidates', machine: m, laws: set, partial: !generated.complete });
|
|
764
|
+
const allowance = remainingRejectionAllowance(plan, clock());
|
|
765
|
+
const rejections = rejectionStage(m0, m, caller, set, allowance);
|
|
766
|
+
set = rejections.active();
|
|
767
|
+
countsDump.on?.({ phase: 'count-rejection-result', work: rejections.screenWork, replayWork: rejections.work(), removed: rejections.evidence().map(e => ({ kind: e.kind, name: e.law.name })), phases: rejections.phases, remaining: set.length, safety: rejections.safety(), replayEvidence: () => rejections.evidence() });
|
|
768
|
+
countsDump.on?.({ phase: 'post-rejection-candidates', machine: m, laws: set });
|
|
769
|
+
const context = countSupportContext(m, caller, set, support);
|
|
770
|
+
return structuredFallback(until, structured => {
|
|
771
|
+
const result = admitCountedFamilyOnce(m, caller, context.laws, support, until, structured, tierRun, rejections);
|
|
772
|
+
return result.proven || context.laws.length === set.length || clock() >= until ? result : admitCountedFamilyOnce(m, caller, set, support, until, structured, tierRun, rejections);
|
|
626
773
|
});
|
|
627
774
|
}
|
|
628
775
|
// Candidate scheduling only. Every returned family still goes through finish.
|
|
629
|
-
export function admitCountedFamily(m, caller, initial, support, until) {
|
|
630
|
-
|
|
776
|
+
export function admitCountedFamily(m, caller, initial, support, until, tiers) {
|
|
777
|
+
if (tiers && tiers.until !== until)
|
|
778
|
+
throw new RangeError('mismatched tier deadline');
|
|
779
|
+
const tierRun = { start: tiers ? until - tiers.workAllowance : clock(), budget: tiers?.active ? tiers : undefined, source: m };
|
|
780
|
+
return structuredFallback(until, structured => admitCountedFamilyOnce(m, caller, initial, support, until, structured, tierRun));
|
|
631
781
|
}
|
|
632
|
-
function admitCountedFamilyOnce(m, caller, initial, support, until, structured) {
|
|
782
|
+
function admitCountedFamilyOnce(m, caller, initial, support, until, structured, tierRun, rejections) {
|
|
783
|
+
if (rejections)
|
|
784
|
+
initial = rejectionFamily(rejections, initial);
|
|
633
785
|
const previous = proofOrigins.enabled;
|
|
634
786
|
if (env.GDP_COUNT_LEMMA_CUTS === '1')
|
|
635
787
|
proofOrigins.enabled = true;
|
|
636
788
|
try {
|
|
637
|
-
|
|
789
|
+
if (env.GDP_COUNT_STRATEGIES === '1')
|
|
790
|
+
m = prepareCountStrategyMachine(m, initial, until, event => countsDump.on?.({ phase: 'count-strategy-context', ...event }));
|
|
791
|
+
const selected = env.GDP_COUNT_STRATEGIES === '1' && env.GDP_COUNT_TIERS === '1' ? new Set(selectedCountStrategies(m, initial)) : new Set();
|
|
792
|
+
const budget = selected.size ? (tierRun.budget = reserveCountClosing(tierRun.budget ?? countTierBudget(tierRun.start, until, selected.size), finalCountStepDeferralEnabled() && env.GDP_COUNT_CLOSING_RESERVE === '1')) : undefined;
|
|
793
|
+
if (budget)
|
|
794
|
+
countsDump.on?.({ phase: 'count-tier-plan', ...budget, selected: [...selected].map(law => law.name) });
|
|
795
|
+
return admitCountedFamily0(m, caller, initial, support, until, structured, budget, selected, budget && 'closingMode' in budget ? budget.workAllowance : Math.max(0, until - tierRun.start), tierRun, rejections);
|
|
638
796
|
}
|
|
639
797
|
finally {
|
|
640
798
|
proofOrigins.enabled = previous;
|
|
641
799
|
}
|
|
642
800
|
}
|
|
643
|
-
function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
801
|
+
function admitCountedFamily0(m, caller, initial, support, until, structured, budget, selected, workAllowance, tierRun, rejections) {
|
|
644
802
|
if (!caller.every(l => initial.includes(l)))
|
|
645
803
|
return { proven: false, laws: initial, m, why: 'missing caller' };
|
|
646
|
-
let
|
|
647
|
-
|
|
804
|
+
let closingBudget = budget && 'closingMode' in budget ? budget : undefined;
|
|
805
|
+
if (closingBudget)
|
|
806
|
+
until = countOrdinaryUntil(closingBudget);
|
|
807
|
+
const prerequisiteFirst = !!closingBudget && env.GDP_COUNT_PREREQUISITES === '1';
|
|
808
|
+
const proofGuided = prerequisiteFirst && env.GDP_COUNT_PROOF_GUIDED_SCHEDULING === '1';
|
|
809
|
+
const beforeClosing = (body, onLocalExpiration) => {
|
|
810
|
+
if (!prerequisiteFirst)
|
|
811
|
+
return body();
|
|
812
|
+
return withSearchAllowance(until, body, error => {
|
|
813
|
+
if (!isLocalCountExpiration(error, closingBudget.until))
|
|
814
|
+
throw error;
|
|
815
|
+
onLocalExpiration?.();
|
|
816
|
+
return undefined;
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
let set = rejections ? rejectionFamily(rejections, initial) : initial.slice();
|
|
820
|
+
let reach;
|
|
821
|
+
if (proofGuided)
|
|
822
|
+
reach = optionalReachabilityScreen(() => {
|
|
823
|
+
const setup = clock(), key = JSON.stringify(m);
|
|
824
|
+
if (tierRun.reachability?.key !== key)
|
|
825
|
+
tierRun.reachability = { key, screen: countReachabilityScreen(tierRun.source ?? m, m, caller, workAllowance, undefined, tierRun.reachFunding ??= new Map()) };
|
|
826
|
+
const screen = tierRun.reachability.screen;
|
|
827
|
+
set = withoutReachableRejections(set, screen.rejectedNames());
|
|
828
|
+
countsDump.on?.({ phase: 'count-reachability-setup', units: (clock() - setup) * fullRate });
|
|
829
|
+
return screen;
|
|
830
|
+
});
|
|
831
|
+
const scopeEnabled = env.GDP_COUNT_STRATEGIES === '1';
|
|
832
|
+
const attempts = countedAttempts(m, caller, support, proofGuided ? closingBudget.until : until, structured, selected, workAllowance, budget, prerequisiteFirst ? initial : undefined), traced = attempts.traced;
|
|
648
833
|
const isCount = (mp) => !!m.counts?.[mp];
|
|
649
834
|
// Prove the proposed set together. A preliminary cone reproved many helpers in
|
|
650
835
|
// several smaller contexts before asking these same induction goals. Houdini
|
|
651
836
|
// drops failed helpers and carries proofs whose instantiated support survives.
|
|
652
837
|
// Every returned set still passes checkCountedLaws, including all caller laws.
|
|
653
|
-
const finish = (ls, proof) => {
|
|
838
|
+
const finish = (ls, proof, targetFamily = true) => {
|
|
839
|
+
const close = (candidate) => {
|
|
840
|
+
if (!closingBudget)
|
|
841
|
+
return closingCountCheck(() => checkCountedLaws(m, ls, candidate));
|
|
842
|
+
const start = clock();
|
|
843
|
+
countsDump.on?.({ phase: 'count-family-closing', stage: 'start', at: start, end: withinDeadline(closingBudget.until), laws: ls.map(l => l.name) });
|
|
844
|
+
const checked = withDeadline(closingBudget.until, () => closingCountCheck(() => checkCountedLaws(m, ls, candidate)));
|
|
845
|
+
countsDump.on?.({ phase: 'count-family-closing', stage: 'end', checked, at: clock(), units: (clock() - start) * fullRate });
|
|
846
|
+
return checked;
|
|
847
|
+
};
|
|
654
848
|
let proposed = proof;
|
|
655
849
|
if (env.GDP_COUNT_LEMMA_CUTS === '1') {
|
|
656
850
|
// This pass performs no search work. Reuse the enclosing wall deadline; outside one,
|
|
657
851
|
// conservatively cap its wall time by the remaining counted allowance. Neither budget is extended.
|
|
658
|
-
const wall = wallAt(), end = Number.isFinite(wall) ? wall :
|
|
852
|
+
const wall = wallAt(), end = Number.isFinite(wall) ? wall : countedSearchNow() + Math.max(0, until - clock());
|
|
659
853
|
for (const { goal, decls } of countedObligations(m, ls, proof.instances)) {
|
|
660
|
-
if (
|
|
854
|
+
if (countedSearchNow() >= end)
|
|
661
855
|
break;
|
|
662
856
|
const cert = proof.certs[goal.name];
|
|
663
857
|
if (!cert || cert.lemmas?.length)
|
|
@@ -668,71 +862,572 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
668
862
|
proposed = { ...proposed, certs: { ...proposed.certs, [goal.name]: { ...cert, tree: shared.tree, lemmas: shared.lemmas } } };
|
|
669
863
|
}
|
|
670
864
|
}
|
|
671
|
-
if (proposed !== proof && ptime('kernel', () =>
|
|
672
|
-
|
|
673
|
-
|
|
865
|
+
if (proposed !== proof && ptime('kernel', () => close(proposed))) {
|
|
866
|
+
// Sharing may retain a wider independent-cut source slice. Never attach
|
|
867
|
+
// pre-sharing premise metadata to a different final certificate.
|
|
868
|
+
if (!scopeEnabled)
|
|
869
|
+
proof = proposed;
|
|
870
|
+
else {
|
|
871
|
+
const premises = { ...proof.premises };
|
|
872
|
+
for (const law of ls)
|
|
873
|
+
if ([' @start', ' @step'].some(suffix => proposed.certs[law.name + suffix] !== proof.certs[law.name + suffix])) {
|
|
874
|
+
const scoped = ptime('premise-scope', () => scopeCountProof(m, law, ls, { instances: proposed.instances[law.name] ?? {}, certs: proposed.certs }, until));
|
|
875
|
+
if (scoped)
|
|
876
|
+
premises[law.name] = scoped.premises.map(p => p.name);
|
|
877
|
+
else
|
|
878
|
+
delete premises[law.name];
|
|
879
|
+
}
|
|
880
|
+
proof = { ...proposed, premises };
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
else if (!ptime('kernel', () => close(proof)))
|
|
674
884
|
return { proven: false, laws: ls, m, why: 'the kernel refused the set' };
|
|
675
885
|
// Output-only observation, after the unchanged checker accepts every obligation.
|
|
676
|
-
countsDump.on?.({ phase: 'closed-family', machine: m, laws: ls, proof, checked: true });
|
|
886
|
+
countsDump.on?.({ phase: targetFamily ? 'closed-family' : 'closed-subfamily', machine: m, laws: ls, proof, checked: true });
|
|
887
|
+
if (!targetFamily)
|
|
888
|
+
return { proven: false, laws: ls, m, why: 'closed subfamily excludes caller' };
|
|
677
889
|
return { proven: true, laws: ls, m, proof };
|
|
678
890
|
};
|
|
891
|
+
const recipeJoint = () => {
|
|
892
|
+
const prepared = beforeClosing(() => {
|
|
893
|
+
const context = countScopeContextKey(m, set);
|
|
894
|
+
const pass = (tierRun.recipeContexts ??= new CountRecipeContexts()).acquire(context, structured, () => {
|
|
895
|
+
const plan = countPrerequisiteSchedule(m, set, selected, until);
|
|
896
|
+
const members = workMap(set, (law, reference) => ({ name: law.name, reference, recipes: workMap(plan.recipes.get(law.name) ?? [], recipe => {
|
|
897
|
+
const shape = recipe.id === 'lifted' ? discoverLiftedCountGuard(m, law, set) : undefined;
|
|
898
|
+
const operations = shape && discoverLiftedCountOperations(m, shape);
|
|
899
|
+
return { ...recipe, ...(operations ? { caseKeys: workMap(operations, operation => 'op:' + operation.value, 'count recipe case inventory') } : {}) };
|
|
900
|
+
}, 'count recipe inventory') }), 'count member inventory');
|
|
901
|
+
return new CountRecipePass(members, context);
|
|
902
|
+
}, event => countsDump.on?.(event));
|
|
903
|
+
if (!pass)
|
|
904
|
+
return { kind: 'context-changed' };
|
|
905
|
+
return { kind: 'ready', pass,
|
|
906
|
+
lawByName: new Map(workMap(set, law => [law.name, law], 'count recipe law lookup')),
|
|
907
|
+
active: new Set(workMap(set, law => law.name, 'count active inventory')),
|
|
908
|
+
targets: workMap(caller, law => law.name, 'count recipe targets') };
|
|
909
|
+
});
|
|
910
|
+
if (!prepared || prepared.kind !== 'ready')
|
|
911
|
+
return { proven: false, laws: set, m, why: prepared?.kind === 'context-changed' ? 'recipe fixed inventory context changed' : 'recipe planning budget' };
|
|
912
|
+
const { lawByName, active, targets, pass } = prepared;
|
|
913
|
+
const tick = () => workLedger.start('ticks', 1, 'count recipe adapter');
|
|
914
|
+
const reconcile = () => { if (reach)
|
|
915
|
+
for (const name of reach.rejectedNames()) {
|
|
916
|
+
tick();
|
|
917
|
+
active.delete(name);
|
|
918
|
+
} };
|
|
919
|
+
const screen = (law, ordinary, citing) => {
|
|
920
|
+
if (!reach)
|
|
921
|
+
return true;
|
|
922
|
+
try {
|
|
923
|
+
const row = reach.screen(law, ordinary, citing, Infinity, attempts.countermodel(law));
|
|
924
|
+
if (row)
|
|
925
|
+
countsDump.on?.({ phase: 'count-reachability', ...row });
|
|
926
|
+
return !!row && row.outcome !== 'rejected' && reach.safety() !== 'broken';
|
|
927
|
+
}
|
|
928
|
+
finally {
|
|
929
|
+
reconcile();
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
if (beforeClosing(() => { reconcile(); return true; }) !== true)
|
|
933
|
+
return { proven: false, laws: set, m, why: 'recipe reconciliation budget' };
|
|
934
|
+
attempts.houdini = true;
|
|
935
|
+
const transportDeclined = undefined;
|
|
936
|
+
const outcome = runCountRecipeController(pass, targets, {
|
|
937
|
+
active, observe: event => countsDump.on?.(event),
|
|
938
|
+
beforeClosing: countRecipeClosingCapture.on ? controller => countRecipeClosingCapture.on({
|
|
939
|
+
version: 'counted-recipe-closing/v1', controller, m, set, caller, initial, selected, structured,
|
|
940
|
+
closingBudget, until, workAllowance, scopeEnabled, active, reachAbsent: reach === undefined, transportDeclined
|
|
941
|
+
}) : undefined,
|
|
942
|
+
preflight: (name, recipe) => {
|
|
943
|
+
const law = lawByName.get(name);
|
|
944
|
+
// The requested legacy screen allowance is clipped by the existing
|
|
945
|
+
// exact member/phase/root scopes; it never creates a new root.
|
|
946
|
+
return !!law && active.has(name) && (recipe.kind !== 'ordinary' || screen(law, workAllowance, 0));
|
|
947
|
+
},
|
|
948
|
+
construct: (name, recipe, lease) => {
|
|
949
|
+
const law = lawByName.get(name);
|
|
950
|
+
if (!law || !active.has(name) || reach?.safety() === 'broken')
|
|
951
|
+
return;
|
|
952
|
+
let proof;
|
|
953
|
+
if (recipe.kind === 'strategy') {
|
|
954
|
+
if (recipe.caseKeys !== undefined)
|
|
955
|
+
proof = lease && attempts.exactStrategy(law, set, lease);
|
|
956
|
+
else if (recipe.id === 'row' || recipe.id === 'guard')
|
|
957
|
+
proof = attempts.strategyProposal(law, set, recipe.id);
|
|
958
|
+
else
|
|
959
|
+
countsDump.on?.({ phase: 'count-strategy', law: name, stage: 'decline', reason: recipe.id === 'lifted' ? 'missing-lifted-case-inventory' : 'unsupported-strategy-recipe', recipe: recipe.id });
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
let result = traced(law, set, 0, Infinity, false);
|
|
963
|
+
if (!('proof' in result) && !result.refuted && attempts.counted)
|
|
964
|
+
result = traced(law, set, 1, Infinity, false);
|
|
965
|
+
if ('proof' in result)
|
|
966
|
+
proof = result.proof;
|
|
967
|
+
else if (result.expired)
|
|
968
|
+
throw new BudgetExpired('ordinary recipe cutoff');
|
|
969
|
+
}
|
|
970
|
+
return proof;
|
|
971
|
+
},
|
|
972
|
+
capture: (name, recipe, proof) => {
|
|
973
|
+
const law = lawByName.get(name);
|
|
974
|
+
if (!law)
|
|
975
|
+
return;
|
|
976
|
+
const before = workLedger.actual();
|
|
977
|
+
let identity = zeroWork;
|
|
978
|
+
const captured = withCountScopeIdentityObservation(amount => { identity = workAdd(identity, amount); }, () => {
|
|
979
|
+
const scoped = rescopeCountProof(m, law, set, proof, new Set(pass.held().keys()), Infinity, event => countsDump.on?.({ phase: 'count-component-rescope', law: name, ...event }), countRescopeFunding());
|
|
980
|
+
if (!scoped)
|
|
981
|
+
return;
|
|
982
|
+
const checkedReduced = isCheckedReducedScope(scoped, m, set);
|
|
983
|
+
return { payload: scoped, premises: workMap(scoped.premises, p => p.name, 'count recipe scoped names'), checkedReduced };
|
|
984
|
+
});
|
|
985
|
+
countsDump.on?.({ phase: 'count-rescope-identity', law: name, rawWork: exactRaw(identity), rootEpoch: workLedger.snapshot().rootEpoch });
|
|
986
|
+
if (!captured)
|
|
987
|
+
return;
|
|
988
|
+
const effective = new Set();
|
|
989
|
+
for (const dependency of captured.premises) {
|
|
990
|
+
tick();
|
|
991
|
+
effective.add(dependency);
|
|
992
|
+
}
|
|
993
|
+
if (!captured.checkedReduced)
|
|
994
|
+
for (const dependency of recipe.required ?? []) {
|
|
995
|
+
tick();
|
|
996
|
+
effective.add(dependency);
|
|
997
|
+
}
|
|
998
|
+
for (const dependency of effective) {
|
|
999
|
+
tick();
|
|
1000
|
+
const premise = lawByName.get(dependency);
|
|
1001
|
+
if (premise && !screen(premise, 0, workAllowance))
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
return { ...captured, checkCost: workSub(workLedger.actual(), before) };
|
|
1005
|
+
},
|
|
1006
|
+
close: (rows, targetInFamily, wholeClosed) => {
|
|
1007
|
+
const replay = (selected, route) => {
|
|
1008
|
+
const declines = [];
|
|
1009
|
+
const names = new Set(workMap(selected, row => row.id, 'count closing inventory'));
|
|
1010
|
+
const family = workFilter(set, law => names.has(law.name), 'count closing family'), instances = {}, certs = {}, premises = {};
|
|
1011
|
+
if (reach?.safety() === 'broken')
|
|
1012
|
+
return { result: { proven: false, laws: family, m, why: 'reachable caller counterexample' }, replayDeclined: false };
|
|
1013
|
+
for (const row of selected) {
|
|
1014
|
+
tick();
|
|
1015
|
+
// Transport the original captured payload on the unchanged model;
|
|
1016
|
+
// never search, repair a certificate, or reuse a partial first try.
|
|
1017
|
+
const proof = replayScopedCountProof(m, family, row.payload, Infinity, { deferToClosing: true, sourceFamily: set, onDecline: decline => declines.push(decline), diagnostic: { route } });
|
|
1018
|
+
if (!proof) {
|
|
1019
|
+
const decline = declines[declines.length - 1];
|
|
1020
|
+
countsDump.on?.({ phase: 'count-recipe-closing-decline', family: route, member: row.id, obligation: decline?.obligation ?? null, case: decline?.case ?? null, reason: decline?.reason ?? 'unclassified', detail: decline });
|
|
1021
|
+
const why = declines.map(d => 'member=' + d.member + ', obligation=' + (d.obligation ?? '<family>') + ', case=' + d.case + ':' + d.reason + (d.premise ? ', law=' + d.premise : '')).join(' | ');
|
|
1022
|
+
const blockers = decline?.blockers ?? (decline?.reason === 'missing-premise' && decline.premise ? [decline.premise] : []);
|
|
1023
|
+
if (blockers.length)
|
|
1024
|
+
countsDump.on?.({ phase: 'count-recipe-closing-blocker', family: route, member: row.id, laws: blockers, detail: decline });
|
|
1025
|
+
const label = blockers.length ? 'BLOCKER outside-closing-family laws ' + blockers.join(', ') : 'recipe closing replay declined';
|
|
1026
|
+
return { result: { proven: false, laws: family, m, why: label + ' [' + route + ']: ' + (why || 'member=' + row.id + ', unclassified') }, replayDeclined: true };
|
|
1027
|
+
}
|
|
1028
|
+
instances[row.id] = proof.instances;
|
|
1029
|
+
for (const [name, cert] of workEntries(proof.certs, 'count closing certificates'))
|
|
1030
|
+
certs[name] = cert;
|
|
1031
|
+
premises[row.id] = proof.premises ?? row.premises;
|
|
1032
|
+
}
|
|
1033
|
+
if (reach)
|
|
1034
|
+
countsDump.on?.({ phase: 'count-reachability-summary', rows: reach.receipts(initial), replayEvidence: reach.evidence });
|
|
1035
|
+
let hasCallers = targetInFamily;
|
|
1036
|
+
for (const law of caller) {
|
|
1037
|
+
tick();
|
|
1038
|
+
if (!names.has(law.name))
|
|
1039
|
+
hasCallers = false;
|
|
1040
|
+
}
|
|
1041
|
+
return { result: finish(family, { instances, certs, premises }, hasCallers), replayDeclined: false };
|
|
1042
|
+
};
|
|
1043
|
+
// Choose the greatest already CLOSED HELD family before replay. No
|
|
1044
|
+
// supplier reconstruction, retry, new recipe, scope or native fallback.
|
|
1045
|
+
return replay(wholeClosed?.() ?? rows, wholeClosed ? 'whole-held' : 'needed').result;
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
countsDump.on?.({ phase: 'count-recipe-summary', reason: outcome.reason, failure: outcome.failure, closingRoute: outcome.closingRoute, proven: outcome.result?.proven ?? false });
|
|
1049
|
+
const diagnostic = 'recipe pass: ' + outcome.reason + (outcome.failure ? '; ' + outcome.failure.reason : '');
|
|
1050
|
+
if (!outcome.result)
|
|
1051
|
+
return { proven: false, laws: set, m, why: diagnostic };
|
|
1052
|
+
return outcome.result.proven ? outcome.result : { ...outcome.result, why: (outcome.result.why ? outcome.result.why + '; ' : '') + diagnostic };
|
|
1053
|
+
};
|
|
1054
|
+
const joint = () => {
|
|
1055
|
+
const planned = beforeClosing(() => countPrerequisiteSchedule(m, set, selected, until));
|
|
1056
|
+
if (!planned)
|
|
1057
|
+
return { proven: false, laws: set, m, why: 'prerequisite planning budget' };
|
|
1058
|
+
const ranked = [...new Set([...caller, ...supportOrder(set, caller, support, false, m)])];
|
|
1059
|
+
const order = ranked.sort((a, b) => planned.costs.get(a.name) - planned.costs.get(b.name));
|
|
1060
|
+
const restored = prepareCountPrerequisiteMemory(tierRun.prerequisites, m, set), remembered = tierRun.prerequisites = restored.state;
|
|
1061
|
+
const scopes = remembered.scopes, ends = new Map(), attempted = new Set();
|
|
1062
|
+
const queue = countPrerequisiteComponents(order.map(l => l.name), planned.requirements, [...selected].map(l => l.name), [...remembered.committed], { ...planned, discoveryFirst: true, proofGuided, discoveryContexts: remembered.discoveryContexts, targets: caller.map(l => l.name), held: new Map([...scopes].map(([name, scope]) => [name, scope.premises.map(p => p.name)])), discovered: [...remembered.discovered], failed: [...remembered.failed] });
|
|
1063
|
+
const ordinaryCount = Math.max(1, set.filter(l => !selected.has(l)).length);
|
|
1064
|
+
const reachSummary = () => { if (reach)
|
|
1065
|
+
countsDump.on?.({ phase: 'count-reachability-summary', rows: reach.receipts(initial), replayEvidence: reach.evidence }); };
|
|
1066
|
+
let activeAttempt, restarted = false;
|
|
1067
|
+
const members = new Set(order.map(law => law.name));
|
|
1068
|
+
const reconcile = () => {
|
|
1069
|
+
if (!reach)
|
|
1070
|
+
return;
|
|
1071
|
+
const delta = reconcileReachableRejections(queue, members, reach.rejectedNames(), scopes, remembered.committed, activeAttempt);
|
|
1072
|
+
if (!delta.rejected.length)
|
|
1073
|
+
return;
|
|
1074
|
+
activeAttempt = undefined;
|
|
1075
|
+
restarted = true;
|
|
1076
|
+
remembered.failed = new Set(queue.failed());
|
|
1077
|
+
remembered.discoveryContexts = queue.discoveryContexts();
|
|
1078
|
+
set = withoutReachableRejections(set, delta.rejected);
|
|
1079
|
+
countsDump.on?.({ phase: 'count-reachability-invalidated', ...delta });
|
|
1080
|
+
};
|
|
1081
|
+
const probe = (law, ordinary, citing, end) => {
|
|
1082
|
+
if (!reach)
|
|
1083
|
+
return undefined;
|
|
1084
|
+
const screen = reach;
|
|
1085
|
+
reconcile();
|
|
1086
|
+
if (restarted)
|
|
1087
|
+
return undefined;
|
|
1088
|
+
const before = clock();
|
|
1089
|
+
let row;
|
|
1090
|
+
try {
|
|
1091
|
+
row = beforeClosing(() => screen.screen(law, ordinary, citing, end, attempts.countermodel(law)));
|
|
1092
|
+
}
|
|
1093
|
+
finally {
|
|
1094
|
+
reconcile();
|
|
1095
|
+
}
|
|
1096
|
+
if (row)
|
|
1097
|
+
countsDump.on?.({ phase: 'count-reachability', ...row, invocationUnits: (clock() - before) * fullRate });
|
|
1098
|
+
return row;
|
|
1099
|
+
};
|
|
1100
|
+
const updateReserve = () => {
|
|
1101
|
+
if (!proofGuided)
|
|
1102
|
+
return;
|
|
1103
|
+
const costs = [...scopes.values()].flatMap(scope => scope.checkWork === undefined ? [] : [scope.checkWork]);
|
|
1104
|
+
closingBudget = reserveCheckedCountClosing(closingBudget, costs, clock());
|
|
1105
|
+
budget = tierRun.budget = closingBudget;
|
|
1106
|
+
until = closingBudget.searchUntil;
|
|
1107
|
+
countsDump.on?.({ phase: 'count-closing-reserve', at: clock(), checkedPackets: costs.length, checkedWork: costs.reduce((a, b) => a + b, 0), ...closingBudget });
|
|
1108
|
+
};
|
|
1109
|
+
reconcile();
|
|
1110
|
+
updateReserve();
|
|
1111
|
+
attempts.houdini = true;
|
|
1112
|
+
countsDump.on?.({ phase: 'count-prerequisite-plan', premises: Object.fromEntries(planned.requirements), recipes: Object.fromEntries(planned.recipes), until, rootUntil: closingBudget.until });
|
|
1113
|
+
countsDump.on?.({ phase: 'count-prerequisite-memory', held: [...scopes.keys()], members: [...remembered.committed], invalidated: restored.invalidated });
|
|
1114
|
+
const closeReady = () => {
|
|
1115
|
+
const available = new Set(queue.available()), needed = countClosingNeeds(caller.map(l => l.name), scopes);
|
|
1116
|
+
if (![...needed].every(name => available.has(name) && scopes.has(name)))
|
|
1117
|
+
return undefined;
|
|
1118
|
+
const family = set.filter(l => needed.has(l.name)), instances = {}, certs = {}, premises = {};
|
|
1119
|
+
for (const member of family) {
|
|
1120
|
+
const proof = beforeClosing(() => ptime('premise-replay', () => replayScopedCountProof(m, family, scopes.get(member.name), until, { deferToClosing: true, sourceFamily: set })));
|
|
1121
|
+
if (!proof)
|
|
1122
|
+
return { proven: false, laws: set, m, why: 'component replay declined' };
|
|
1123
|
+
instances[member.name] = proof.instances;
|
|
1124
|
+
Object.assign(certs, proof.certs);
|
|
1125
|
+
premises[member.name] = proof.premises ?? [];
|
|
1126
|
+
}
|
|
1127
|
+
reachSummary();
|
|
1128
|
+
return finish(family, { instances, certs, premises });
|
|
1129
|
+
};
|
|
1130
|
+
const alreadyClosed = closeReady();
|
|
1131
|
+
if (alreadyClosed)
|
|
1132
|
+
return alreadyClosed;
|
|
1133
|
+
while (clock() < until) {
|
|
1134
|
+
restarted = false;
|
|
1135
|
+
const decision = queue.next();
|
|
1136
|
+
if (!decision)
|
|
1137
|
+
break;
|
|
1138
|
+
activeAttempt = decision.kind === 'attempt' ? decision.name : undefined;
|
|
1139
|
+
if (decision.kind === 'ready') {
|
|
1140
|
+
let blocked = false;
|
|
1141
|
+
if (reach)
|
|
1142
|
+
for (const name of decision.members) {
|
|
1143
|
+
const member = set.find(l => l.name === name), row = probe(member, 0, scopes.get(name)?.checkWork ?? 0, until);
|
|
1144
|
+
if (reach.safety() === 'broken')
|
|
1145
|
+
return { proven: false, laws: set, m, why: 'reachable caller counterexample' };
|
|
1146
|
+
if (restarted) {
|
|
1147
|
+
blocked = true;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
if (row?.outcome === 'rejected')
|
|
1151
|
+
return { proven: false, laws: set, m, why: 'rejected member remained ready' };
|
|
1152
|
+
if (!row) {
|
|
1153
|
+
blocked = true;
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (blocked)
|
|
1158
|
+
continue;
|
|
1159
|
+
queue.commit(decision.members);
|
|
1160
|
+
for (const name of decision.members) {
|
|
1161
|
+
remembered.committed.add(name);
|
|
1162
|
+
if (reach)
|
|
1163
|
+
countsDump.on?.({ phase: 'count-required-promotion', kind: 'member', law: name, reducedScopeSize: scopes.get(name)?.premises.length ?? 0, committed: true, proposed: true, checked: false });
|
|
1164
|
+
}
|
|
1165
|
+
countsDump.on?.({ phase: 'count-component-closed', members: decision.members, proposed: true, checked: false });
|
|
1166
|
+
for (const name of decision.members)
|
|
1167
|
+
countsDump.on?.({ phase: 'count-prerequisite-complete', law: name, premises: scopes.get(name)?.premises.map(p => p.name) ?? [], proposed: true, component: decision.members });
|
|
1168
|
+
const closed = closeReady();
|
|
1169
|
+
if (closed)
|
|
1170
|
+
return closed;
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
const law = set.find(l => l.name === decision.name), context = set.filter(l => decision.context.includes(l.name));
|
|
1174
|
+
const discoveryOnly = decision.purpose === 'discovery';
|
|
1175
|
+
const ordinaryMembers = decision.component.filter(name => !selected.has(set.find(l => l.name === name))).length;
|
|
1176
|
+
const horizon = Math.min(until, discoveryOnly ? until : budget.strategyUntil + budget.ordinaryFloor * ordinaryMembers / ordinaryCount);
|
|
1177
|
+
const key = JSON.stringify([decision.purpose, decision.component, ...discoveryOnly ? [law.name] : []]), available = new Set(queue.available()), failed = new Set(queue.failed());
|
|
1178
|
+
if (!ends.has(key) || proofGuided && !discoveryOnly) {
|
|
1179
|
+
const eligible = set.filter(l => !available.has(l.name) && !failed.has(l.name)).length;
|
|
1180
|
+
ends.set(key, discoveryOnly ? clock() + Math.max(0, horizon - clock()) / Math.max(1, eligible) : horizon);
|
|
1181
|
+
}
|
|
1182
|
+
const componentEnd = Math.min(horizon, ends.get(key));
|
|
1183
|
+
const unattempted = discoveryOnly ? 1 : Math.max(1, decision.component.filter(name => !scopes.has(name) && (proofGuided || !attempted.has(JSON.stringify([key, name])))).length);
|
|
1184
|
+
const allowStrategy = !discoveryOnly && decision.recipe.kind === 'strategy', start = clock();
|
|
1185
|
+
const { end, allotted, reserved } = countComponentAttemptBudget(clock(), componentEnd, unattempted, 1, proofGuided && !allowStrategy);
|
|
1186
|
+
if (reach && !discoveryOnly && !allowStrategy) {
|
|
1187
|
+
const row = probe(law, allotted, 0, end);
|
|
1188
|
+
if (reach.safety() === 'broken')
|
|
1189
|
+
return { proven: false, laws: set, m, why: 'reachable caller counterexample' };
|
|
1190
|
+
if (restarted) {
|
|
1191
|
+
updateReserve();
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
1194
|
+
if (row?.outcome === 'rejected')
|
|
1195
|
+
return { proven: false, laws: set, m, why: 'rejected prerequisite remained active' };
|
|
1196
|
+
if (!row)
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
attempted.add(JSON.stringify([key, law.name]));
|
|
1200
|
+
if (discoveryOnly)
|
|
1201
|
+
remembered.discovered.add(law.name);
|
|
1202
|
+
countsDump.on?.({ phase: 'count-component-attempt', law: law.name, component: decision.component, mode: decision.phase, recipe: decision.recipe.id, context: decision.context, end, componentEnd, allotted, reserved, discovery: decision.discovery, purpose: decision.purpose, required: queue.required(), ...(proofGuided ? { pass: decision.pass ?? 0 } : {}) });
|
|
1203
|
+
countsDump.on?.({ phase: 'count-tier-attempt', law: law.name, tier: selected.has(law) && allowStrategy ? 'strategy' : 'ordinary', end, allotted });
|
|
1204
|
+
let result = { stuck: 'unknown' }, expired = allotted <= 0;
|
|
1205
|
+
if (allotted > 0)
|
|
1206
|
+
result = withSearchAllowance(end, () => {
|
|
1207
|
+
const invoke = (pass) => traced(law, context, pass, Math.max(0, end - clock()), allowStrategy);
|
|
1208
|
+
const first = invoke(proofGuided ? decision.pass ?? 0 : 0);
|
|
1209
|
+
return !proofGuided && !discoveryOnly && !('proof' in first) && !first.refuted && (!selected.has(law) || !allowStrategy) && attempts.counted && clock() < end ? invoke(1) : first;
|
|
1210
|
+
}, error => { if (!isLocalCountExpiration(error, closingBudget.until))
|
|
1211
|
+
throw error; expired = true; return result; });
|
|
1212
|
+
if (!('proof' in result) && result.expired)
|
|
1213
|
+
expired = true;
|
|
1214
|
+
let scope;
|
|
1215
|
+
if ('proof' in result) {
|
|
1216
|
+
scope = withSearchAllowance(end, () => beforeClosing(() => proofGuided
|
|
1217
|
+
? ptime('premise-rescope', () => rescopeCountProof(m, law, context, result.proof, new Set(scopes.keys()), end, event => countsDump.on?.({ phase: 'count-component-rescope', law: law.name, ...event }), countRescopeFunding()))
|
|
1218
|
+
: ptime('premise-scope', () => scopeCountProof(m, law, context, result.proof, end)),
|
|
1219
|
+
// The enclosing closing reserve may consume this local refusal.
|
|
1220
|
+
// Preserve its classification even when exact admission stops before end.
|
|
1221
|
+
() => { expired = true; }), error => { if (!isLocalCountExpiration(error, withinDeadline(closingBudget.until)))
|
|
1222
|
+
throw error; expired = true; return undefined; });
|
|
1223
|
+
}
|
|
1224
|
+
if ('proof' in result && !scope && !expired && clock() >= end) {
|
|
1225
|
+
const error = new BudgetExpired('component premise scope');
|
|
1226
|
+
if (!isLocalCountExpiration(error, withinDeadline(closingBudget.until)))
|
|
1227
|
+
throw error;
|
|
1228
|
+
expired = true;
|
|
1229
|
+
}
|
|
1230
|
+
let rejectedPremise = false;
|
|
1231
|
+
if (scope && reach) {
|
|
1232
|
+
const citedBy = law.name, reducedScopeSize = scope.premises.length, citingWork = clock() - start;
|
|
1233
|
+
for (const premise of scope.premises) {
|
|
1234
|
+
const dependency = set.find(l => l.name === premise.name);
|
|
1235
|
+
if (!dependency)
|
|
1236
|
+
continue;
|
|
1237
|
+
const row = probe(dependency, 0, citingWork, until);
|
|
1238
|
+
countsDump.on?.({ phase: 'count-required-promotion-screen', law: premise.name, citedBy, reducedScopeSize, screened: !!row, outcome: row?.outcome });
|
|
1239
|
+
if (reach.safety() === 'broken')
|
|
1240
|
+
return { proven: false, laws: set, m, why: 'reachable caller counterexample' };
|
|
1241
|
+
if (restarted) {
|
|
1242
|
+
scope = undefined;
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
if (row?.outcome === 'rejected')
|
|
1246
|
+
rejectedPremise = true;
|
|
1247
|
+
if (!row) {
|
|
1248
|
+
expired = true;
|
|
1249
|
+
scope = undefined;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (rejectedPremise)
|
|
1254
|
+
scope = undefined;
|
|
1255
|
+
}
|
|
1256
|
+
if (restarted) {
|
|
1257
|
+
updateReserve();
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
let status = rejectedPremise ? { kind: 'unknown', reason: 'reachable-refuted premise' } : scope ? { kind: 'proof', citations: scope.premises.map(p => p.name) } : expired ? { kind: 'unknown', reason: 'budget-expired' } : 'proof' in result ? (proofGuided ? { kind: 'unknown', reason: 'checked rescope declined' } : { kind: 'refused', reason: 'returned proof has no valid scope' }) : result.refuted ? { kind: 'refuted' } : { kind: 'unknown', reason: result.reason ?? result.stuck };
|
|
1261
|
+
if ((discoveryOnly || proofGuided) && status.kind === 'refuted')
|
|
1262
|
+
status = { kind: 'unknown', reason: 'narrow-sat' };
|
|
1263
|
+
const outcome = queue.finish(law.name, status);
|
|
1264
|
+
activeAttempt = undefined;
|
|
1265
|
+
remembered.failed = new Set(queue.failed());
|
|
1266
|
+
if (proofGuided)
|
|
1267
|
+
remembered.discoveryContexts = queue.discoveryContexts();
|
|
1268
|
+
for (const invalidated of outcome.invalidated) {
|
|
1269
|
+
scopes.delete(invalidated);
|
|
1270
|
+
remembered.committed.delete(invalidated);
|
|
1271
|
+
}
|
|
1272
|
+
if (outcome.held && scope) {
|
|
1273
|
+
scopes.set(law.name, scope);
|
|
1274
|
+
if (reach)
|
|
1275
|
+
for (const premise of scope.premises)
|
|
1276
|
+
countsDump.on?.({ phase: 'count-required-promotion', kind: 'dependency', law: premise.name, citedBy: law.name, reducedScopeSize: scope.premises.length, committed: false, proposed: true, checked: false });
|
|
1277
|
+
}
|
|
1278
|
+
else if (decision.phase !== 'dissolve')
|
|
1279
|
+
scopes.delete(law.name);
|
|
1280
|
+
updateReserve();
|
|
1281
|
+
countsDump.on?.({ phase: 'count-component-result', law: law.name, mode: decision.phase, purpose: decision.purpose, component: decision.component, at: clock(), outcome: outcome.held ? 'proof' : status.kind, reason: 'reason' in status ? status.reason : undefined, units: (clock() - start) * fullRate, held: outcome.held, failed: queue.failed(), unknown: queue.unknown(), invalidated: outcome.invalidated, retries: queue.retryCount(), premises: scope?.premises.map(p => p.name) ?? [] });
|
|
1282
|
+
}
|
|
1283
|
+
reachSummary();
|
|
1284
|
+
countsDump.on?.({ phase: 'count-prerequisite-incomplete', unknown: queue.unknown(), failed: queue.failed() });
|
|
1285
|
+
return { proven: false, laws: set, m, why: 'component proposals did not close caller' };
|
|
1286
|
+
};
|
|
679
1287
|
const join = (kept = new Map()) => {
|
|
680
|
-
const keptProof = () => ({ instances: Object.fromEntries([...kept].map(([n, pr]) => [n, pr.instances])), certs: Object.assign({}, ...[...kept.values()].map(pr => pr.certs)) });
|
|
1288
|
+
const keptProof = () => ({ instances: Object.fromEntries([...kept].map(([n, pr]) => [n, pr.instances])), certs: Object.assign({}, ...[...kept.values()].map(pr => pr.certs)), ...(scopeEnabled ? { premises: Object.fromEntries([...kept].flatMap(([name, pr]) => pr.premises ? [[name, pr.premises]] : [])) } : {}) });
|
|
681
1289
|
if (caller.every(l => kept.has(l.name)))
|
|
682
1290
|
return finish(set.filter(l => kept.has(l.name)), keptProof());
|
|
683
1291
|
// Each untried law gets an even share of what remains now, not what
|
|
684
1292
|
// remained at round entry. Cheap proofs return their underspend to the pool.
|
|
685
1293
|
let carried = new Map();
|
|
1294
|
+
const scopes = new Map();
|
|
1295
|
+
const neededForSearch = () => countClosingNeeds([...caller.map(l => l.name), ...set.filter(l => selected.has(l) && scopes.has(l.name)).map(l => l.name)], scopes);
|
|
686
1296
|
attempts.houdini = true;
|
|
687
1297
|
for (let round = 0; clock() < until; round++) {
|
|
688
|
-
const { instances, certs } = keptProof();
|
|
1298
|
+
const { instances, certs, premises = {} } = keptProof();
|
|
689
1299
|
const failed = new Set(), proofs = new Map();
|
|
690
|
-
const pending = new Set(set.filter(l => !kept.has(l.name) && !carried.has(l.name)).map(l => l.name));
|
|
691
|
-
//
|
|
692
|
-
|
|
1300
|
+
const pending = new Set(set.filter(l => !selected.has(l) && !kept.has(l.name) && !carried.has(l.name)).map(l => l.name));
|
|
1301
|
+
// Count readers first, then explicit supports and callers; unrelated
|
|
1302
|
+
// scalar helpers cannot consume the whole allowance before count admission.
|
|
1303
|
+
const order = supportOrder(set, caller, support, false, env.GDP_COUNT_STRATEGIES === '1' ? m : undefined);
|
|
1304
|
+
const todo = [...order.filter(l => selected.has(l)), ...order.filter(l => !selected.has(l))];
|
|
1305
|
+
for (let position = 0; position < todo.length; position++) {
|
|
1306
|
+
if (closingBudget && !selected.has(todo[position])) {
|
|
1307
|
+
const needed = neededForSearch();
|
|
1308
|
+
const prerequisites = new Set([...scopes.values()].filter(s => selected.has(set.find(l => l.name === s.owner.name))).flatMap(s => s.premises.map(p => p.name)));
|
|
1309
|
+
let next = todo.findIndex((l, i) => i >= position && prerequisites.has(l.name) && !proofs.has(l.name));
|
|
1310
|
+
if (next < 0)
|
|
1311
|
+
next = todo.findIndex((l, i) => i >= position && needed.has(l.name));
|
|
1312
|
+
if (next > position)
|
|
1313
|
+
[todo[position], todo[next]] = [todo[next], todo[position]];
|
|
1314
|
+
}
|
|
1315
|
+
const law = todo[position];
|
|
693
1316
|
checkWall('Houdini round');
|
|
694
1317
|
if (clock() > until)
|
|
695
1318
|
return { proven: false, laws: set, m, why: 'time' };
|
|
696
1319
|
if (kept.has(law.name))
|
|
697
1320
|
continue;
|
|
698
1321
|
const was = carried.get(law.name);
|
|
699
|
-
const
|
|
1322
|
+
const required = closingBudget ? neededForSearch() : undefined;
|
|
1323
|
+
const focused = required && new Set([...pending].filter(name => required.has(name)));
|
|
1324
|
+
const share = budget && !closingBudget ? ordinaryTierShare(budget, clock(), pending) : attemptShare(until - clock(), focused?.size ? focused : pending);
|
|
700
1325
|
pending.delete(law.name);
|
|
701
1326
|
const structural = support.has(law) && !caller.includes(law);
|
|
702
|
-
const boundedSupport = activeSupport(set, support);
|
|
703
|
-
const allotted = supportBudget(until - clock(), share, boundedSupport && caller.includes(law), structural);
|
|
704
|
-
const supportUntil = Math.min(until, clock() + (boundedSupport ? Math.min(allotted, 5_000) : allotted)), supportWall =
|
|
1327
|
+
const strategy = selected.has(law), boundedSupport = !budget && activeSupport(set, support);
|
|
1328
|
+
const allotted = strategy ? Math.max(0, budget.strategyUntil - clock()) : budget ? share : supportBudget(until - clock(), share, boundedSupport && caller.includes(law), structural);
|
|
1329
|
+
const supportUntil = strategy ? budget.strategyUntil : Math.min(until, clock() + (boundedSupport ? Math.min(allotted, 5_000) : allotted)), supportWall = wallDeadline(countedSearchNow() + 4_800);
|
|
1330
|
+
let proofContext = closingBudget && !strategy && required ? set.filter(l => required.has(l.name) || l === law) : set;
|
|
705
1331
|
const ask = (pass) => {
|
|
706
1332
|
const ms = Math.min(allotted, Math.max(0, (boundedSupport ? supportUntil : until) - clock()));
|
|
707
|
-
|
|
1333
|
+
if (scopeEnabled)
|
|
1334
|
+
countsDump.on?.({ phase: 'houdini-attempt', law: law.name, round, pass });
|
|
1335
|
+
if (budget)
|
|
1336
|
+
countsDump.on?.({ phase: 'count-tier-attempt', law: law.name, tier: strategy ? 'strategy' : 'ordinary', end: supportUntil, allotted });
|
|
1337
|
+
const run = () => {
|
|
1338
|
+
const invoke = (allowance) => strategy ? withDeadline(supportUntil, () => traced(law, proofContext, pass, allowance)) : boundedSupport ? withWall(supportWall, () => withDeadline(supportUntil, () => traced(law, proofContext, pass, allowance))) : traced(law, proofContext, pass, allowance);
|
|
1339
|
+
let result = invoke(ms);
|
|
1340
|
+
if (closingBudget && proofContext !== set && !('proof' in result) && clock() < Math.min(supportUntil, until)) {
|
|
1341
|
+
proofContext = set;
|
|
1342
|
+
result = invoke(Math.min(ms, Math.max(0, Math.min(supportUntil, until) - clock())));
|
|
1343
|
+
}
|
|
1344
|
+
return result;
|
|
1345
|
+
};
|
|
1346
|
+
if (!closingBudget)
|
|
1347
|
+
return run();
|
|
1348
|
+
return withSearchAllowance(Math.min(supportUntil, until), run, error => {
|
|
1349
|
+
if (!isLocalCountExpiration(error, closingBudget.until))
|
|
1350
|
+
throw error;
|
|
1351
|
+
return { stuck: 'unknown' };
|
|
1352
|
+
});
|
|
708
1353
|
};
|
|
709
|
-
const countFirst = (env.GDP_COUNTS_COUNT_FIRST === '1' || boundedSupport && env.GDP_COUNTS_COUNT_FIRST !== '0') && (reads(law.holds, isCount).size > 0 || boundedSupport && !!law.keys?.length);
|
|
1354
|
+
const countFirst = !strategy && firstCountPass(m, law, (env.GDP_COUNTS_COUNT_FIRST === '1' || boundedSupport && env.GDP_COUNTS_COUNT_FIRST !== '0') && (reads(law.holds, isCount).size > 0 || boundedSupport && !!law.keys?.length)) === 1;
|
|
710
1355
|
let r = was ? { proof: was } : ask(countFirst ? 1 : 0);
|
|
711
|
-
if (!('proof' in r) && !r.refuted && (countFirst || attempts.counted))
|
|
1356
|
+
if (!('proof' in r) && !r.refuted && !strategy && (countFirst || attempts.counted))
|
|
712
1357
|
r = ask(countFirst ? 0 : 1);
|
|
1358
|
+
if (closingBudget)
|
|
1359
|
+
countsDump.on?.({ phase: 'count-family-collection', law: law.name, proposed: 'proof' in r, at: clock() });
|
|
713
1360
|
if (!('proof' in r)) {
|
|
714
1361
|
failed.add(law.name);
|
|
715
1362
|
continue;
|
|
716
1363
|
}
|
|
1364
|
+
if (!was && scopeEnabled) {
|
|
1365
|
+
const scoped = ptime('premise-scope', () => scopeCountProof(m, law, proofContext, r.proof, until));
|
|
1366
|
+
if (scoped) {
|
|
1367
|
+
scopes.set(law.name, scoped);
|
|
1368
|
+
r.proof = { ...r.proof, premises: scoped.premises.map(p => p.name) };
|
|
1369
|
+
}
|
|
1370
|
+
else
|
|
1371
|
+
scopes.delete(law.name);
|
|
1372
|
+
if (closingBudget)
|
|
1373
|
+
countsDump.on?.({ phase: 'count-family-scope', law: law.name, scoped: !!scoped, premises: scoped?.premises.map(p => p.name) ?? [] });
|
|
1374
|
+
}
|
|
717
1375
|
proofs.set(law.name, r.proof);
|
|
718
1376
|
instances[law.name] = r.proof.instances;
|
|
1377
|
+
if (r.proof.premises)
|
|
1378
|
+
premises[law.name] = r.proof.premises;
|
|
719
1379
|
Object.assign(certs, r.proof.certs);
|
|
1380
|
+
if (closingBudget) {
|
|
1381
|
+
const needed = countClosingNeeds(caller.map(l => l.name), scopes);
|
|
1382
|
+
if ([...needed].every(name => proofs.has(name) && scopes.has(name))) {
|
|
1383
|
+
const family = set.filter(l => needed.has(l.name)), instances = {}, certs = {}, premises = {};
|
|
1384
|
+
let ready = true;
|
|
1385
|
+
for (const member of family) {
|
|
1386
|
+
const replayed = ptime('premise-replay', () => replayScopedCountProof(m, family, scopes.get(member.name), until, { deferToClosing: true, sourceFamily: set }));
|
|
1387
|
+
if (!replayed) {
|
|
1388
|
+
ready = false;
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
instances[member.name] = replayed.instances;
|
|
1392
|
+
Object.assign(certs, replayed.certs);
|
|
1393
|
+
premises[member.name] = replayed.premises ?? [];
|
|
1394
|
+
}
|
|
1395
|
+
if (ready)
|
|
1396
|
+
return finish(family, { instances, certs, premises });
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
720
1399
|
}
|
|
721
1400
|
if (env.GDP_COUNTS_TRACE)
|
|
722
1401
|
console.error(`counts: round ${round}: ${set.length} laws, ${kept.size} kept, ${carried.size} carried, failed ${[...failed].join('; ').slice(0, 600)}`);
|
|
723
1402
|
if (!failed.size)
|
|
724
|
-
return finish(set, { instances, certs });
|
|
1403
|
+
return closingBudget ? { proven: false, laws: set, m, why: 'closing scope incomplete' } : finish(set, { instances, certs, ...(scopeEnabled ? { premises } : {}) });
|
|
725
1404
|
const next = set.filter(l => !failed.has(l.name) || caller.includes(l));
|
|
726
1405
|
// (only callers fail: drop nothing more, give up)
|
|
727
1406
|
if (next.length === set.length)
|
|
728
1407
|
return { proven: false, laws: set, m, why: `not proven: ${[...failed].join(', ')}` };
|
|
729
|
-
//
|
|
730
|
-
|
|
731
|
-
|
|
1408
|
+
// Instantiating a law does not mean the proof used it. Replay only the
|
|
1409
|
+
// recorded premise scope, against the exact reduced row layout, without
|
|
1410
|
+
// solving again. Missing premises and failed checks reopen the attempt.
|
|
1411
|
+
carried = new Map();
|
|
1412
|
+
if (!scopeEnabled) {
|
|
1413
|
+
const dropped = set.filter(l => !next.includes(l));
|
|
1414
|
+
carried = new Map([...proofs].filter(([, pr]) => dropped.every(d => d.forall && !pr.instances[d.name]?.length)));
|
|
1415
|
+
}
|
|
1416
|
+
else
|
|
1417
|
+
for (const name of proofs.keys()) {
|
|
1418
|
+
const scoped = scopes.get(name);
|
|
1419
|
+
const replayed = scoped && ptime('premise-replay', () => replayScopedCountProof(m, next, scoped, until, { deferToClosing: finalCountStepDeferralEnabled(), sourceFamily: set }));
|
|
1420
|
+
countsDump.on?.({ phase: 'premise-replay', law: name, round, retained: !!replayed, premises: scoped?.premises.map(p => p.name) });
|
|
1421
|
+
if (replayed)
|
|
1422
|
+
carried.set(name, replayed);
|
|
1423
|
+
else
|
|
1424
|
+
scopes.delete(name);
|
|
1425
|
+
}
|
|
732
1426
|
set = next;
|
|
733
1427
|
}
|
|
734
1428
|
return { proven: false, laws: set, m, why: 'time' };
|
|
735
1429
|
};
|
|
1430
|
+
// Flags off retain the exact pre-scoping dependency/carry algorithm.
|
|
736
1431
|
const dependencies = (owner, proof, context) => {
|
|
737
1432
|
const conservative = () => new Set(context.filter(l => !l.forall || proof.instances[l.name]?.length).map(l => l.name)), used = new Set();
|
|
738
1433
|
for (const { goal, decls } of countedObligations(m, context, { [owner.name]: proof.instances }, context.indexOf(owner))) {
|
|
@@ -748,7 +1443,7 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
748
1443
|
}
|
|
749
1444
|
return new Set(context.filter(l => assumed([l], proof.instances).some(h => used.has(json(h)))).map(l => l.name));
|
|
750
1445
|
};
|
|
751
|
-
const
|
|
1446
|
+
const legacyDemand = () => {
|
|
752
1447
|
const known = new Map();
|
|
753
1448
|
attempts.houdini = true;
|
|
754
1449
|
while (clock() < until) {
|
|
@@ -762,7 +1457,7 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
762
1457
|
if (available.has(dep))
|
|
763
1458
|
required.add(dep);
|
|
764
1459
|
}
|
|
765
|
-
const law = supportOrder(set, caller, support).find(l => required.has(l.name) && !known.has(l.name));
|
|
1460
|
+
const law = supportOrder(set, caller, support, false, env.GDP_COUNT_STRATEGIES === '1' ? m : undefined).find(l => required.has(l.name) && !known.has(l.name));
|
|
766
1461
|
if (!law) {
|
|
767
1462
|
const kept = set.filter(l => required.has(l.name)), instances = {}, certs = {};
|
|
768
1463
|
for (const l of kept) {
|
|
@@ -773,7 +1468,7 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
773
1468
|
const cert = saved.proof.certs[src[i].goal.name];
|
|
774
1469
|
if (!cert)
|
|
775
1470
|
return join();
|
|
776
|
-
const a = mcGoal(src[i].goal.hyps, src[i].decls, cert), b = mcGoal(dst[i].goal.hyps, dst[i].decls, cert), lifted = a && b && transportCountCertificate(a, b, cert, wallAt());
|
|
1471
|
+
const a = mcGoal(src[i].goal.hyps, src[i].decls, cert), b = mcGoal(dst[i].goal.hyps, dst[i].decls, cert), lifted = a && b && transportCountCertificate(a, b, cert, wallAt(), { declarations: { from: src[i].decls, to: dst[i].decls }, diagnostic: { member: l.name, obligation: dst[i].goal.name, route: 'retained-family' } });
|
|
777
1472
|
if (!lifted)
|
|
778
1473
|
return join();
|
|
779
1474
|
certs[dst[i].goal.name] = lifted;
|
|
@@ -781,7 +1476,7 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
781
1476
|
}
|
|
782
1477
|
return finish(kept, { instances, certs });
|
|
783
1478
|
}
|
|
784
|
-
const remaining = until - clock(), share = remaining / Math.max(1, set.length - known.size), allotted = supportBudget(remaining, share, caller.includes(law), support.has(law) && !caller.includes(law)), stop = Math.min(until, clock() + Math.min(allotted, 5000)), wall =
|
|
1479
|
+
const remaining = until - clock(), share = remaining / Math.max(1, set.length - known.size), allotted = supportBudget(remaining, share, caller.includes(law), support.has(law) && !caller.includes(law)), stop = Math.min(until, clock() + Math.min(allotted, 5000)), wall = wallDeadline(countedSearchNow() + 4800);
|
|
785
1480
|
const countFirst = env.GDP_COUNTS_COUNT_FIRST !== '0' && (reads(law.holds, isCount).size > 0 || !!law.keys?.length);
|
|
786
1481
|
const ask = (context) => withWall(wall, () => withDeadline(stop, () => {
|
|
787
1482
|
const pass = countFirst ? 1 : 0;
|
|
@@ -809,12 +1504,77 @@ function admitCountedFamily0(m, caller, initial, support, until, structured) {
|
|
|
809
1504
|
}
|
|
810
1505
|
return { proven: false, laws: set, m, why: 'time' };
|
|
811
1506
|
};
|
|
812
|
-
|
|
1507
|
+
const demand = () => {
|
|
1508
|
+
const known = new Map();
|
|
1509
|
+
attempts.houdini = true;
|
|
1510
|
+
while (clock() < until) {
|
|
1511
|
+
if (!activeSupport(set, support))
|
|
1512
|
+
return join();
|
|
1513
|
+
const required = new Set(caller.map(l => l.name)), available = new Set(set.map(l => l.name));
|
|
1514
|
+
for (const name of required) {
|
|
1515
|
+
const saved = known.get(name);
|
|
1516
|
+
if (saved)
|
|
1517
|
+
for (const dep of saved.premises)
|
|
1518
|
+
if (available.has(dep.name))
|
|
1519
|
+
required.add(dep.name);
|
|
1520
|
+
}
|
|
1521
|
+
const law = supportOrder(set, caller, support, false, env.GDP_COUNT_STRATEGIES === '1' ? m : undefined).find(l => required.has(l.name) && !known.has(l.name));
|
|
1522
|
+
if (!law) {
|
|
1523
|
+
const kept = set.filter(l => required.has(l.name)), instances = {}, certs = {}, premises = {};
|
|
1524
|
+
for (const l of kept) {
|
|
1525
|
+
const replayed = ptime('premise-replay', () => replayScopedCountProof(m, kept, known.get(l.name), until, { deferToClosing: finalCountStepDeferralEnabled(), sourceFamily: set }));
|
|
1526
|
+
if (!replayed)
|
|
1527
|
+
return join();
|
|
1528
|
+
instances[l.name] = replayed.instances;
|
|
1529
|
+
premises[l.name] = replayed.premises ?? [];
|
|
1530
|
+
Object.assign(certs, replayed.certs);
|
|
1531
|
+
}
|
|
1532
|
+
return finish(kept, { instances, certs, premises });
|
|
1533
|
+
}
|
|
1534
|
+
const remaining = until - clock(), share = remaining / Math.max(1, set.length - known.size), allotted = supportBudget(remaining, share, caller.includes(law), support.has(law) && !caller.includes(law)), stop = Math.min(until, clock() + Math.min(allotted, 5000));
|
|
1535
|
+
const countFirst = firstCountPass(m, law, env.GDP_COUNTS_COUNT_FIRST !== '0' && (reads(law.holds, isCount).size > 0 || !!law.keys?.length)) === 1;
|
|
1536
|
+
const ask = (context) => withDeadline(stop, () => {
|
|
1537
|
+
const pass = countFirst ? 1 : 0;
|
|
1538
|
+
let result = traced(law, context, pass, Math.min(allotted, Math.max(0, stop - clock())));
|
|
1539
|
+
if (!('proof' in result) && !result.refuted && (countFirst || attempts.counted) && clock() < stop)
|
|
1540
|
+
result = traced(law, context, pass ? 0 : 1, Math.min(allotted, Math.max(0, stop - clock())));
|
|
1541
|
+
return result;
|
|
1542
|
+
});
|
|
1543
|
+
let context = coarseContext(m, set, [...caller, law], support), result = ask(context);
|
|
1544
|
+
if (!('proof' in result) && context.length < set.length && clock() < stop) {
|
|
1545
|
+
context = set;
|
|
1546
|
+
result = ask(context);
|
|
1547
|
+
}
|
|
1548
|
+
countsDump.on?.({ phase: 'demand-attempt', law: law.name, context: context.length, required: required.size, known: known.size, outcome: 'proof' in result ? 'proof' : result.stuck });
|
|
1549
|
+
if ('proof' in result) {
|
|
1550
|
+
const scoped = ptime('premise-scope', () => scopeCountProof(m, law, context, result.proof, until));
|
|
1551
|
+
if (!scoped)
|
|
1552
|
+
return join();
|
|
1553
|
+
known.set(law.name, scoped);
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
if (caller.includes(law))
|
|
1557
|
+
return join();
|
|
1558
|
+
set = set.filter(l => l !== law);
|
|
1559
|
+
for (const [name, saved] of known)
|
|
1560
|
+
if (saved.premises.some(p => p.name === law.name))
|
|
1561
|
+
known.delete(name);
|
|
1562
|
+
}
|
|
1563
|
+
return { proven: false, laws: set, m, why: 'time' };
|
|
1564
|
+
};
|
|
1565
|
+
return prerequisiteFirst ? proofGuided && completeWorkProfile.enabled ? recipeJoint() : joint() : budget ? join() : activeSupport(set, support) ? scopeEnabled ? demand() : legacyDemand() : join();
|
|
813
1566
|
}
|
|
814
1567
|
// The production attempt also serves the fixed-family research replay. Candidate
|
|
815
1568
|
// generation and scheduling stay outside; inference, selection, reservation and
|
|
816
1569
|
// all budget checks have exactly one implementation.
|
|
817
|
-
export function countedAttempts(m, caller, support, until, structured = true) {
|
|
1570
|
+
export function countedAttempts(m, caller, support, until, structured = true, focusedOrStrategies = true, budgetOrWork, tierBudget, shapeFamily) {
|
|
1571
|
+
// Preserve I's boolean/tier API and B's explicit strategy-set/work API.
|
|
1572
|
+
const allowFocused = typeof focusedOrStrategies === 'boolean' ? focusedOrStrategies : true;
|
|
1573
|
+
const strategyOnly = typeof focusedOrStrategies === 'boolean' ? new Set() : focusedOrStrategies;
|
|
1574
|
+
const tiers = typeof budgetOrWork === 'number' ? tierBudget : budgetOrWork;
|
|
1575
|
+
const workAllowance = typeof budgetOrWork === 'number' ? budgetOrWork : tiers?.workAllowance ?? Math.max(0, until - clock());
|
|
1576
|
+
// Capture the enclosing phase before entering any per-law or subset share.
|
|
1577
|
+
const enclosingEnd = withinDeadline(until);
|
|
818
1578
|
// (the law's own names and the request's values that key a map: an action's value keys none)
|
|
819
1579
|
const keys0 = [...[...reads([m.step, m.assume ?? null], () => true).values()].map(([, key]) => key), ...Object.values(m.step.maps ?? {}).flatMap(w => ('each' in w ? [] : [w.key]))];
|
|
820
1580
|
const keyed = m.inputs.filter(i => keys0.some(key => mentions(key, i))).map(v);
|
|
@@ -833,7 +1593,9 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
833
1593
|
// Cone tiers and Houdini may ask the same law again with more instances. Keep a
|
|
834
1594
|
// bounded set of sessions; each independently resets unless its hypotheses are
|
|
835
1595
|
// still present verbatim. This reuses work, never a verdict from a weaker goal.
|
|
836
|
-
const decisions = new Map(), focusEnabled = focusedCountRecoveryEnabled(m);
|
|
1596
|
+
const decisions = new Map(), focusEnabled = allowFocused && focusedCountRecoveryEnabled(m);
|
|
1597
|
+
// Opt-in until the fixed-operation census and preservation gate have been qualified.
|
|
1598
|
+
const frameChoice = env.GDP_COUNT_FRAMES === '1' ? fixedCountFrameCase(m) : undefined;
|
|
837
1599
|
// Scheduling history only, never a cached verdict. A different family must
|
|
838
1600
|
// earn its own ordinary attempts before using the finite recovery search.
|
|
839
1601
|
const plainFailures = new WeakMap();
|
|
@@ -873,7 +1635,7 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
873
1635
|
return completion.genuine ? { stuck: 'sat', refuted: true } : { stuck: pass ? 'unknown' : 'sat' };
|
|
874
1636
|
};
|
|
875
1637
|
// (not where the attempt may widen: its narrow model is no model of the widened goal)
|
|
876
|
-
if (cti && !(supported && pass) && !(houdini && caller.some(l => l.name === law.name) && !widened.has(law.name)) && !ls.some(l => !cti.ls.has(l.name) && reads(l.holds, isCount).size)) {
|
|
1638
|
+
if (cti && !(tiers?.active && ls.some(l => !cti.ls.has(l.name))) && !(supported && pass) && !(houdini && caller.some(l => l.name === law.name) && !widened.has(law.name)) && !ls.some(l => !cti.ls.has(l.name) && reads(l.holds, isCount).size)) {
|
|
877
1639
|
const at0 = Object.fromEntries(Object.entries(cti.at).filter(([n]) => n.startsWith('?') || ls.some(l => l.name === n)));
|
|
878
1640
|
if (!(seed = ptime('mbqi', () => independent(at0, modelInstances(m, modelLaws, at0, cti.gg, cti.w)))))
|
|
879
1641
|
return refuted(cti.gg, cti.w, cti.at);
|
|
@@ -881,7 +1643,51 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
881
1643
|
// Supported obligations seed quantified flags only at demanded source terms.
|
|
882
1644
|
// Ordinary MBQI remains the fallback; arbitrary inputs are not initial witnesses.
|
|
883
1645
|
let at = seed ?? (supported ? {} : Object.fromEntries(Object.entries(m.step.flags ?? {}).flatMap(([f, q]) => (q.op === 'all' && !q.keys?.length ? [[`?${f}`, ts]] : []))));
|
|
1646
|
+
if (pass && frameChoice && ls.includes(law) && reads(law.holds, isCount).size)
|
|
1647
|
+
at = ownCountLawInstance(law, at);
|
|
884
1648
|
const obligations = (i) => ptime('encode', () => countedObligations(m, ls, { [law.name]: i }, ls.indexOf(law)));
|
|
1649
|
+
// A fixed-operation frame proof needs only the ordinary own-key premise.
|
|
1650
|
+
// Try it before count-pool construction. INIT is still a separate obligation:
|
|
1651
|
+
// its zero counts need ordinary unary witnesses, absent from a narrow pool
|
|
1652
|
+
// containing only post-state reads. Neither its truth nor its proof is assumed.
|
|
1653
|
+
if (pass && frameChoice && ls.includes(law) && reads(law.holds, isCount).size) {
|
|
1654
|
+
const end = Math.min(attemptEnd, clock() + Math.min(ms, 500));
|
|
1655
|
+
try {
|
|
1656
|
+
const early = ptime('frames', () => withDeadline(end, () => {
|
|
1657
|
+
const packets = obligations(at), step = packets.at(-1);
|
|
1658
|
+
if (!step)
|
|
1659
|
+
return;
|
|
1660
|
+
const more = () => clock() < end;
|
|
1661
|
+
const request = certFor(step.goal, step.decls, false, 0, more, structured);
|
|
1662
|
+
const maps = new Set([...reads(law.holds, isCount).values()].map(([map]) => map));
|
|
1663
|
+
const cert = proveCountFrameGoal(step.goal, step.decls, request, frameChoice, maps, end, cut => countsDump.on?.({ phase: 'count-cut', law: law.name, goal: step.goal.name, pass, ...cut }));
|
|
1664
|
+
if (!cert)
|
|
1665
|
+
return;
|
|
1666
|
+
const emit = (p, c, phase) => countsDump.on?.({ law: law.name, goal: p.goal.name, pass, phase, rawGoal: p.goal, decls: p.decls, instances: at, certificateRequest: c, hyps: mcGoal(p.goal.hyps, p.decls, c)?.hyps });
|
|
1667
|
+
emit(step, cert, 'frame-proven');
|
|
1668
|
+
const certs = { [step.goal.name]: cert };
|
|
1669
|
+
for (const initial of packets.slice(0, -1)) {
|
|
1670
|
+
const request = certFor(initial.goal, initial.decls, true, 24, more, structured);
|
|
1671
|
+
const gg = mcGoal(initial.goal.hyps, initial.decls, request);
|
|
1672
|
+
const out = gg && grow(gg, new Map(), { nodes: 0, until: end });
|
|
1673
|
+
if (!out || !('tree' in out))
|
|
1674
|
+
return;
|
|
1675
|
+
const c = { reads: request.reads, insts: request.insts, picks: request.picks, tree: out.tree };
|
|
1676
|
+
if (!checkMC(initial.goal.hyps, initial.decls, c))
|
|
1677
|
+
return;
|
|
1678
|
+
emit(initial, c, 'frame-start-proven');
|
|
1679
|
+
certs[initial.goal.name] = c;
|
|
1680
|
+
}
|
|
1681
|
+
return { instances: at, certs };
|
|
1682
|
+
}));
|
|
1683
|
+
if (early)
|
|
1684
|
+
return { proof: early };
|
|
1685
|
+
}
|
|
1686
|
+
catch (error) {
|
|
1687
|
+
if (!(error instanceof WallExpired) || clock() >= attemptEnd)
|
|
1688
|
+
throw error;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
885
1691
|
// (`wide`: the count instances widened once, where a model is left that the narrow ones and the laws don't refute, for
|
|
886
1692
|
// a caller's law or where a read is in none of them: the cone's many refuted candidates keep the narrow ones)
|
|
887
1693
|
// Source-only proposals share one 64-tuple/4-per-source budget for this attempt.
|
|
@@ -902,6 +1708,7 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
902
1708
|
// instance by the reads it names, a pick by its read and terms, so the choice outlives the goal's rebuilds)
|
|
903
1709
|
const chosen = new Set();
|
|
904
1710
|
const selections = new Map();
|
|
1711
|
+
const reservationRenamings = new Map();
|
|
905
1712
|
const poolCache = new Map();
|
|
906
1713
|
const memberSources = new Map();
|
|
907
1714
|
// Demand-driven ranges (Fable b89dd77a / Lane B): retain a goal's demand
|
|
@@ -935,7 +1742,7 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
935
1742
|
};
|
|
936
1743
|
const rawBuild = () => obligations(at).map(({ goal, decls }) => {
|
|
937
1744
|
if (pass && supported && lazyMode === 'wide') {
|
|
938
|
-
if (generation.state.deadline ||
|
|
1745
|
+
if (generation.state.deadline || countedSearchNow() >= wallAt())
|
|
939
1746
|
throw new UnsupportedCountProposal('reservation deadline');
|
|
940
1747
|
let selection = selections.get(goal.name);
|
|
941
1748
|
const reservation = selection && reservationReadClosure(goal, decls, selection.previous, selection.decls, selection.chosen, [...m.params, ...m.inputs, ...Object.keys(m.state)]);
|
|
@@ -956,7 +1763,13 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
956
1763
|
selection = { chosen: new Set(ids(pick)), cap: Math.min(10, pick.insts.length + 2), previous: pick, decls, reserve: reservationState(goal, [m, ls, goal], pool), stable: stableState([m, ls, goal]) };
|
|
957
1764
|
selections.set(goal.name, selection);
|
|
958
1765
|
}
|
|
959
|
-
const
|
|
1766
|
+
const reserved = reservePool(goal, decls, pool0, selection.previous, selection.decls, selection.chosen, selection.reserve, pool, reservation);
|
|
1767
|
+
const full = reserved.full;
|
|
1768
|
+
if (reserved.record.renamed.length) {
|
|
1769
|
+
const prior = reservationRenamings.get(goal.name) ?? [];
|
|
1770
|
+
reservationRenamings.set(goal.name, [...prior, ...reserved.record.renamed]);
|
|
1771
|
+
countsDump.on?.({ phase: 'reservation-alpha', law: law.name, goal: goal.name, renamings: reserved.record.renamed });
|
|
1772
|
+
}
|
|
960
1773
|
const keys = ids(full), lazyRoom = selection.chosen.size < selection.cap;
|
|
961
1774
|
const view = chosenView(full, selection.chosen, selection.cap);
|
|
962
1775
|
const c = withRanges(goal, decls, selectedCertificate(goal, decls, view, selection.stable, lazyRoom), full.reads);
|
|
@@ -1035,7 +1848,7 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
1035
1848
|
return false;
|
|
1036
1849
|
// (broken where no completion of the model meets it: the cells it leaves out at their start, at 1, or one map's
|
|
1037
1850
|
// flipped from either, and an instance's witness at each value below 16)
|
|
1038
|
-
const { fg, keys, wits } = b.pool, active = b.pool.chosen ?? chosen, base = fg.hyps.length - keys.length, ids = keys.flatMap((q, j) => (active.has(q) ? [] : [base + j])),
|
|
1851
|
+
const { fg, keys, wits } = b.pool, active = b.pool.chosen ?? chosen, base = fg.hyps.length - keys.length, ids = keys.flatMap((q, j) => (active.has(q) ? [] : [base + j])), rawJudge = brokenOf(fg), judge = (...args) => withEvaluationAdmission(() => rawJudge(...args));
|
|
1039
1852
|
let bad = ids.length ? judge(w, ids) : [];
|
|
1040
1853
|
const mps = [...new Set(bad.flatMap(i => [...reads(fg.hyps[i], () => true).values()].map(([mp]) => mp)))], one1 = Object.fromEntries(mps.map(mp => [mp, 1]));
|
|
1041
1854
|
for (const d of strict ? [undefined] : [undefined, one1, ...mps.map(mp => ({ [mp]: 1 })), ...mps.map(mp => ({ ...one1, [mp]: 0 }))])
|
|
@@ -1248,15 +2061,29 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
1248
2061
|
return refuted(gg, o.witness, at);
|
|
1249
2062
|
if (!o || !('tree' in o))
|
|
1250
2063
|
return { stuck: gg ? o.stuck ?? '' : '' };
|
|
1251
|
-
certs[goal.name] = { reads: c.reads, insts: c.insts, tree: o.tree, ...('picks' in c && c.picks.length ? { picks: c.picks } : {}) };
|
|
2064
|
+
certs[goal.name] = { ...(reservationRenamings.get(goal.name)?.length ? { proposalProvenance: { kind: 'reservation-alpha', renamings: reservationRenamings.get(goal.name) } } : {}), reads: c.reads, insts: c.insts, tree: o.tree, ...('picks' in c && c.picks.length ? { picks: c.picks } : {}) };
|
|
1252
2065
|
}
|
|
1253
2066
|
if (!again)
|
|
1254
2067
|
return { proof: { instances: at, certs } };
|
|
1255
2068
|
}
|
|
1256
2069
|
};
|
|
1257
|
-
const attempt = (law, ls, pass, ms) => {
|
|
2070
|
+
const attempt = (law, ls, pass, ms, strategyAllowed = true) => {
|
|
1258
2071
|
const end = Math.min(until, clock() + ms);
|
|
1259
|
-
const result = withDeadline(end, () =>
|
|
2072
|
+
const result = withDeadline(end, () => {
|
|
2073
|
+
let remaining = ms;
|
|
2074
|
+
if (strategyAllowed && !pass && env.GDP_COUNT_STRATEGIES === '1' && (!strategyOnly.size || strategyOnly.has(law))) {
|
|
2075
|
+
const proof = ptime('strategies', () => (tiers?.active && finalCountStepDeferralEnabled() ? proposeCountStrategiesForClosing : proveCountStrategies)(m, ls, law, end, (goal, decls) => certFor(goal, decls, false, 0, () => clock() < end, structured), event => countsDump.on?.({ phase: 'count-strategy', law: law.name, pass, end, ...event }), workAllowance, shapeFamily));
|
|
2076
|
+
countsDump.on?.({ phase: 'count-strategy-result', law: law.name, pass, end, checked: !!proof && proof.status !== 'unchecked', ...(proof?.status === 'unchecked' ? { proposed: true, status: 'unchecked' } : {}) });
|
|
2077
|
+
if (proof)
|
|
2078
|
+
return { proof };
|
|
2079
|
+
if (strategyOnly.has(law))
|
|
2080
|
+
return { stuck: 'strategy declined' };
|
|
2081
|
+
remaining = Math.max(0, end - clock());
|
|
2082
|
+
if (!remaining)
|
|
2083
|
+
return { stuck: 'unknown' };
|
|
2084
|
+
}
|
|
2085
|
+
return withDeferredCountRecovery(end, defer => ordinaryAttempt(law, ls, pass, remaining, end, defer), () => !!pass || !counted);
|
|
2086
|
+
});
|
|
1260
2087
|
if (!pass) {
|
|
1261
2088
|
const failures = plainFailures.get(law) ?? new WeakSet();
|
|
1262
2089
|
if (!('proof' in result) && !result.refuted)
|
|
@@ -1267,72 +2094,115 @@ export function countedAttempts(m, caller, support, until, structured = true) {
|
|
|
1267
2094
|
}
|
|
1268
2095
|
return result;
|
|
1269
2096
|
};
|
|
1270
|
-
const traced = (law, ls, pass, ms) => {
|
|
1271
|
-
const t0 = clock(), w0 =
|
|
2097
|
+
const traced = (law, ls, pass, ms, strategyAllowed = true) => {
|
|
2098
|
+
const t0 = clock(), w0 = countedSearchNow(), p0 = { ...cprof };
|
|
1272
2099
|
let r;
|
|
1273
2100
|
try {
|
|
1274
2101
|
const end = Math.min(until, clock() + ms);
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
const wholeGoals = countedObligations(m, ls, { [law.name]: probe.proof.instances }, ls.indexOf(law));
|
|
1297
|
-
const certs = {};
|
|
1298
|
-
let complete = true;
|
|
1299
|
-
for (let i = 0; i < wholeGoals.length; i++) {
|
|
1300
|
-
const part = localGoals[i], whole = wholeGoals[i], c = probe.proof.certs[part.goal.name];
|
|
1301
|
-
if (!c) {
|
|
1302
|
-
complete = false;
|
|
1303
|
-
break;
|
|
2102
|
+
if (tiers?.active) {
|
|
2103
|
+
r = countPremiseSearch(ls, end, localEnd => [false, true].flatMap(guardReads => {
|
|
2104
|
+
const context = countPremiseContext(m, ls, law, localEnd, guardReads);
|
|
2105
|
+
return context ? [context] : [];
|
|
2106
|
+
}), (local, probeEnd) => attempt(law, local, pass, Math.max(0, probeEnd - clock()), strategyAllowed), (context, proposed, localEnd) => {
|
|
2107
|
+
if (!('proof' in proposed))
|
|
2108
|
+
return;
|
|
2109
|
+
const localGoals = countedObligations(m, context.laws, { [law.name]: proposed.proof.instances }, context.laws.indexOf(law));
|
|
2110
|
+
const wholeGoals = countedObligations(m, ls, { [law.name]: proposed.proof.instances }, ls.indexOf(law));
|
|
2111
|
+
if (localGoals.length !== wholeGoals.length)
|
|
2112
|
+
return;
|
|
2113
|
+
const certs = {};
|
|
2114
|
+
for (let i = 0; i < wholeGoals.length; i++) {
|
|
2115
|
+
const part = localGoals[i], whole = wholeGoals[i], cert = proposed.proof.certs[part.goal.name];
|
|
2116
|
+
if (!cert || clock() >= localEnd)
|
|
2117
|
+
return;
|
|
2118
|
+
const from = mcGoal(part.goal.hyps, part.decls, cert), to = mcGoal(whole.goal.hyps, whole.decls, cert);
|
|
2119
|
+
const lifted = from && to && transportCountCertificate(from, to, cert, wallAt(), { declarations: { from: part.decls, to: whole.decls }, diagnostic: { member: law.name, obligation: whole.goal.name, route: 'strategy-proposal' } });
|
|
2120
|
+
if (!lifted || (!(finalCountStepDeferralEnabled() && proposed.proof.status === 'unchecked') && !checkMC(whole.goal.hyps, whole.decls, lifted)))
|
|
2121
|
+
return;
|
|
2122
|
+
certs[whole.goal.name] = lifted;
|
|
1304
2123
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
2124
|
+
return { proof: { instances: proposed.proof.instances, certs, ...(proposed.proof.status === 'unchecked' ? { status: 'unchecked' } : {}) } };
|
|
2125
|
+
}, event => countsDump.on?.({ ...event, law: law.name, pass }), error => error instanceof UnsupportedCountProposal);
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
// Probe only strict subsets, within the existing attempt's allowance. A
|
|
2129
|
+
// subset model is not a verdict: failure always widens to the full set.
|
|
2130
|
+
// Kept certificates must be lifted to that full set's exact row layout.
|
|
2131
|
+
const focused = pass && ls.some(l => support.has(l)) && (reads(law.holds, isCount).size || !caller.includes(law) && !!law.keys?.length) ? sourceContext(m, ls, law, support) : ls;
|
|
2132
|
+
const contexts = [...(focused.length < ls.length ? [{ local: focused, fraction: 1, kind: 'source-context' }] : []), ...(env.GDP_COUNTS_RELEVANCE === '1' ? relevantLaws(m, ls, law, support).map(local => ({ local, fraction: 1 / 6, kind: 'relevance' })) : [])];
|
|
2133
|
+
for (const { local, fraction, kind } of contexts) {
|
|
2134
|
+
const slice = Math.max(0, Math.min(ms * fraction, end - clock()));
|
|
2135
|
+
if (!slice)
|
|
1309
2136
|
break;
|
|
2137
|
+
let probe;
|
|
2138
|
+
try {
|
|
2139
|
+
probe = withDeadline(clock() + slice, () => attempt(law, local, pass, slice, strategyAllowed));
|
|
1310
2140
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
2141
|
+
catch (error) {
|
|
2142
|
+
if (!(error instanceof UnsupportedCountProposal))
|
|
2143
|
+
throw error;
|
|
2144
|
+
continue;
|
|
2145
|
+
}
|
|
2146
|
+
if (!('proof' in probe))
|
|
2147
|
+
continue;
|
|
2148
|
+
const localGoals = countedObligations(m, local, { [law.name]: probe.proof.instances }, local.indexOf(law));
|
|
2149
|
+
const wholeGoals = countedObligations(m, ls, { [law.name]: probe.proof.instances }, ls.indexOf(law));
|
|
2150
|
+
const certs = {};
|
|
2151
|
+
let complete = true;
|
|
2152
|
+
for (let i = 0; i < wholeGoals.length; i++) {
|
|
2153
|
+
const part = localGoals[i], whole = wholeGoals[i], c = probe.proof.certs[part.goal.name];
|
|
2154
|
+
if (!c) {
|
|
2155
|
+
complete = false;
|
|
2156
|
+
break;
|
|
2157
|
+
}
|
|
2158
|
+
const pg = mcGoal(part.goal.hyps, part.decls, c), wg = mcGoal(whole.goal.hyps, whole.decls, c);
|
|
2159
|
+
const lifted = pg && wg && withDeadline(end, () => transportCountCertificate(pg, wg, c, wallAt(), { declarations: { from: part.decls, to: whole.decls }, diagnostic: { member: law.name, obligation: whole.goal.name, route: 'strategy-probe' } }));
|
|
2160
|
+
if (!lifted) {
|
|
2161
|
+
complete = false;
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
if (!checkMC(whole.goal.hyps, whole.decls, lifted)) {
|
|
2165
|
+
complete = false;
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
2168
|
+
certs[whole.goal.name] = lifted;
|
|
2169
|
+
}
|
|
2170
|
+
if (complete) {
|
|
2171
|
+
r = { proof: { instances: probe.proof.instances, certs } };
|
|
2172
|
+
countsDump.on?.({ phase: kind + '-proof', law: law.name, local: local.length, whole: ls.length });
|
|
2173
|
+
return r;
|
|
1314
2174
|
}
|
|
1315
|
-
certs[whole.goal.name] = lifted;
|
|
1316
|
-
}
|
|
1317
|
-
if (complete) {
|
|
1318
|
-
r = { proof: { instances: probe.proof.instances, certs } };
|
|
1319
|
-
countsDump.on?.({ phase: kind + '-proof', law: law.name, local: local.length, whole: ls.length });
|
|
1320
|
-
return r;
|
|
1321
2175
|
}
|
|
2176
|
+
r = attempt(law, ls, pass, Math.max(0, end - clock()), strategyAllowed);
|
|
1322
2177
|
}
|
|
1323
|
-
r = attempt(law, ls, pass, Math.max(0, end - clock()));
|
|
1324
2178
|
}
|
|
1325
2179
|
catch (error) {
|
|
1326
|
-
// A local
|
|
2180
|
+
// A local tier deadline expires this attempt, not the whole enclosing search.
|
|
1327
2181
|
// Invalid or captured proposals are likewise never assumptions.
|
|
1328
|
-
if (!(error instanceof UnsupportedCountProposal) && !(error instanceof WallExpired))
|
|
2182
|
+
if (!(error instanceof UnsupportedCountProposal) && !(error instanceof WallExpired) && !(tiers?.active && isLocalCountExpiration(error, enclosingEnd)))
|
|
1329
2183
|
throw error;
|
|
1330
2184
|
countsDump.on?.({ law: law.name, pass, phase: 'rejected proposal', error: String(error) });
|
|
1331
|
-
r = { stuck: 'unknown' };
|
|
2185
|
+
r = shapeFamily ? { stuck: 'unknown', expired: error instanceof BudgetExpired, reason: String(error) } : { stuck: 'unknown' };
|
|
1332
2186
|
}
|
|
1333
2187
|
if (env.GDP_COUNTS_TRACE?.includes('3'))
|
|
1334
|
-
console.error(`counts: try ${law.name.slice(0, 50)} | ls ${ls.length} pass ${pass} ms ${Math.round(ms)} took ${Math.round(clock() - t0)} wall ${Math.round(
|
|
2188
|
+
console.error(`counts: try ${law.name.slice(0, 50)} | ls ${ls.length} pass ${pass} ms ${Math.round(ms)} took ${Math.round(clock() - t0)} wall ${Math.round(countedSearchNow() - w0)} [${Object.entries(cprof).filter(([k2, x]) => x - (p0[k2] ?? 0) >= 1).map(([k2, x]) => `${k2} ${Math.round(x - (p0[k2] ?? 0))}`).join(' ')}] -> ${'proof' in r ? 'kept' : r.stuck}`);
|
|
1335
2189
|
return r;
|
|
1336
2190
|
};
|
|
1337
|
-
|
|
2191
|
+
// One bounded non-lifted strategy recipe, without ordinary-search fallback.
|
|
2192
|
+
// The explicit lifted lease dispatcher intentionally rejects row/guard kinds.
|
|
2193
|
+
const strategyProposal = (law, ls, kind) => {
|
|
2194
|
+
if (env.GDP_COUNT_STRATEGIES !== '1' || strategyOnly.size && !strategyOnly.has(law))
|
|
2195
|
+
return undefined;
|
|
2196
|
+
const end = withinDeadline(until);
|
|
2197
|
+
return ptime('strategies', () => (tiers?.active && finalCountStepDeferralEnabled() ? proposeCountStrategyKindForClosing : proveCountStrategyKind)(kind, m, ls, law, end, (goal, decls) => certFor(goal, decls, false, 0, () => clock() < end, structured), event => countsDump.on?.({ phase: 'count-strategy', law: law.name, pass: 0, ...event }), workAllowance, shapeFamily));
|
|
2198
|
+
};
|
|
2199
|
+
// Explicit seam for the persistent section46 controller. The legacy traced
|
|
2200
|
+
// path remains unchanged; no plan is inferred from ms, clock or remaining work.
|
|
2201
|
+
const exactStrategy = (law, ls, plan) => {
|
|
2202
|
+
assertLiftedWorkLease(plan);
|
|
2203
|
+
if (env.GDP_COUNT_STRATEGIES !== '1' || strategyOnly.size && !strategyOnly.has(law))
|
|
2204
|
+
return undefined;
|
|
2205
|
+
return ptime('strategies', () => (tiers?.active && finalCountStepDeferralEnabled() ? proposeCountStrategiesForClosing : proveCountStrategies)(m, ls, law, Infinity, (goal, decls) => certFor(goal, decls, false, 0, () => true, structured), event => countsDump.on?.({ phase: 'count-strategy', law: law.name, pass: 0, ...event }), workAllowance, shapeFamily, plan));
|
|
2206
|
+
};
|
|
2207
|
+
return { traced, exactStrategy, strategyProposal, countermodel: (law) => models.get(`1 ${law.name}`)?.w ?? models.get(`0 ${law.name}`)?.w, get counted() { return counted; }, set houdini(value) { houdini = value; } };
|
|
1338
2208
|
}
|