gdp-wired 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -6
- package/dist/core/bmc.js +10 -7
- package/dist/core/carry.d.ts +15 -0
- package/dist/core/carry.js +651 -0
- package/dist/core/check.js +7 -2
- package/dist/core/cli.d.ts +3 -1
- package/dist/core/cli.js +28 -8
- 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.d.ts +24 -0
- package/dist/core/count-cases.js +321 -0
- package/dist/core/count-cert-grow.d.ts +4 -0
- package/dist/core/count-cert-grow.js +37 -0
- package/dist/core/count-cert-rename.d.ts +10 -0
- package/dist/core/count-cert-rename.js +69 -0
- package/dist/core/count-cert-transport.d.ts +11 -0
- package/dist/core/count-cert-transport.js +109 -0
- 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-completion.d.ts +9 -0
- package/dist/core/count-completion.js +27 -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-cubes.d.ts +8 -0
- package/dist/core/count-cubes.js +69 -0
- package/dist/core/count-demand.d.ts +37 -0
- package/dist/core/count-demand.js +361 -0
- package/dist/core/count-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-facts.d.ts +52 -0
- package/dist/core/count-facts.js +247 -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-focus-proof.d.ts +8 -0
- package/dist/core/count-focus-proof.js +140 -0
- package/dist/core/count-focused.d.ts +22 -0
- package/dist/core/count-focused.js +676 -0
- package/dist/core/count-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-ranges.d.ts +5 -0
- package/dist/core/count-ranges.js +65 -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/action-guard.d.ts +5 -0
- package/dist/core/count-recovery/action-guard.js +51 -0
- package/dist/core/count-recovery/boolean-core.d.ts +16 -0
- package/dist/core/count-recovery/boolean-core.js +258 -0
- package/dist/core/count-recovery/carried-case.d.ts +2 -0
- package/dist/core/count-recovery/carried-case.js +24 -0
- package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
- package/dist/core/count-recovery/conditional-check-cache.js +131 -0
- package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
- package/dist/core/count-recovery/conditional-cuts.js +319 -0
- package/dist/core/count-recovery/conditional-proof.d.ts +53 -0
- package/dist/core/count-recovery/conditional-proof.js +348 -0
- package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
- package/dist/core/count-recovery/derivability-closure.js +534 -0
- package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
- package/dist/core/count-recovery/empty-count-source.js +40 -0
- package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
- package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
- package/dist/core/count-recovery/field-case.d.ts +5 -0
- package/dist/core/count-recovery/field-case.js +89 -0
- package/dist/core/count-recovery/field-demand.d.ts +46 -0
- package/dist/core/count-recovery/field-demand.js +47 -0
- package/dist/core/count-recovery/field-only.d.ts +3 -0
- package/dist/core/count-recovery/field-only.js +18 -0
- package/dist/core/count-recovery/fold-path.d.ts +6 -0
- package/dist/core/count-recovery/fold-path.js +35 -0
- package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
- package/dist/core/count-recovery/frame-lemmas.js +120 -0
- package/dist/core/count-recovery/guard-cases.d.ts +12 -0
- package/dist/core/count-recovery/guard-cases.js +139 -0
- package/dist/core/count-recovery/key-closure.d.ts +14 -0
- package/dist/core/count-recovery/key-closure.js +62 -0
- package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
- package/dist/core/count-recovery/leaf-allowance.js +7 -0
- package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
- package/dist/core/count-recovery/lift-count-proxies.js +175 -0
- package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
- package/dist/core/count-recovery/live-dependencies.js +76 -0
- package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
- package/dist/core/count-recovery/member-inclusions.js +168 -0
- package/dist/core/count-recovery/member-premises.d.ts +29 -0
- package/dist/core/count-recovery/member-premises.js +114 -0
- package/dist/core/count-recovery/natural-cases.d.ts +6 -0
- package/dist/core/count-recovery/natural-cases.js +59 -0
- package/dist/core/count-recovery/ops.d.ts +6 -0
- package/dist/core/count-recovery/ops.js +8 -0
- package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
- package/dist/core/count-recovery/pre-state-source.js +18 -0
- package/dist/core/count-recovery/rebase-path.d.ts +9 -0
- package/dist/core/count-recovery/rebase-path.js +70 -0
- package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
- package/dist/core/count-recovery/reframe-tree.js +24 -0
- package/dist/core/count-recovery/rename-proof.d.ts +2 -0
- package/dist/core/count-recovery/rename-proof.js +102 -0
- package/dist/core/count-recovery/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.d.ts +16 -0
- package/dist/core/count-recovery/row-cases.js +292 -0
- package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
- package/dist/core/count-recovery/scalar-guards.js +291 -0
- package/dist/core/count-recovery/source-memo.d.ts +12 -0
- package/dist/core/count-recovery/source-memo.js +67 -0
- package/dist/core/count-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-select.d.ts +16 -0
- package/dist/core/count-select.js +24 -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 +598 -0
- package/dist/core/count-support.js +2081 -0
- package/dist/core/count-tier-budget.d.ts +14 -0
- package/dist/core/count-tier-budget.js +64 -0
- package/dist/core/count-unions.d.ts +2 -0
- package/dist/core/count-unions.js +139 -0
- package/dist/core/count-unwritten-prefix.d.ts +24 -0
- package/dist/core/count-unwritten-prefix.js +97 -0
- package/dist/core/count-witness-flags.d.ts +9 -0
- package/dist/core/count-witness-flags.js +37 -0
- package/dist/core/count-write-frames.d.ts +12 -0
- package/dist/core/count-write-frames.js +206 -0
- package/dist/core/count-write-shape.d.ts +15 -0
- package/dist/core/count-write-shape.js +73 -0
- package/dist/core/counts.d.ts +49 -7
- package/dist/core/counts.js +1679 -165
- 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 +59 -6
- package/dist/core/dsl.js +459 -112
- package/dist/core/effect.js +8 -1
- package/dist/core/evaluation-admission.d.ts +1 -0
- package/dist/core/evaluation-admission.js +3 -0
- package/dist/core/exists.d.ts +7 -2
- package/dist/core/exists.js +131 -24
- package/dist/core/extract-check.d.ts +7 -1
- package/dist/core/extract-check.js +130 -13
- package/dist/core/extract-read.d.ts +22 -8
- package/dist/core/extract-read.js +29 -11
- package/dist/core/extract-shapes.js +122 -41
- package/dist/core/extract-standalone.js +53 -9
- package/dist/core/extract.js +9 -3
- package/dist/core/field-laws.d.ts +4 -0
- package/dist/core/field-laws.js +238 -0
- package/dist/core/finite-frontiers.d.ts +5 -0
- package/dist/core/finite-frontiers.js +116 -0
- package/dist/core/finite-houdini.d.ts +58 -0
- package/dist/core/finite-houdini.js +502 -0
- package/dist/core/finite-model.d.ts +13 -0
- package/dist/core/finite-model.js +68 -0
- package/dist/core/finite-tiny.d.ts +72 -0
- package/dist/core/finite-tiny.js +1080 -0
- package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
- package/dist/core/fresh.js +5 -1
- package/dist/core/infer.d.ts +1 -1
- package/dist/core/infer.js +76 -38
- package/dist/core/kind.js +2 -1
- package/dist/core/laws.d.ts +2 -1
- package/dist/core/laws.js +47 -14
- package/dist/core/lemma-cuts.d.ts +38 -0
- package/dist/core/lemma-cuts.js +366 -0
- package/dist/core/linear-admission.d.ts +14 -0
- package/dist/core/linear-admission.js +151 -0
- package/dist/core/machine.d.ts +44 -4
- package/dist/core/machine.js +342 -63
- package/dist/core/meter.d.ts +22 -0
- package/dist/core/meter.js +34 -0
- package/dist/core/mutate.d.ts +55 -0
- package/dist/core/mutate.js +210 -0
- package/dist/core/native-domain.d.ts +6 -0
- package/dist/core/native-domain.js +114 -0
- package/dist/core/native-law.d.ts +3 -0
- package/dist/core/native-law.js +174 -0
- package/dist/core/nonterm.js +4 -3
- package/dist/core/prover-row-budget.d.ts +3 -0
- package/dist/core/prover-row-budget.js +106 -0
- package/dist/core/quorum-laws.d.ts +25 -0
- package/dist/core/quorum-laws.js +263 -0
- 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/relational.js +10 -2
- package/dist/core/relevance.d.ts +4 -0
- package/dist/core/relevance.js +79 -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 +5 -0
- package/dist/core/runtime-wall.js +4 -0
- package/dist/core/sample-step.d.ts +16 -0
- package/dist/core/sample-step.js +28 -0
- package/dist/core/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/source-check.d.ts +44 -0
- package/dist/core/source-check.js +126 -0
- package/dist/core/source-diagnostic.d.ts +1 -0
- package/dist/core/source-diagnostic.js +34 -0
- package/dist/core/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/support-budget.d.ts +2 -0
- package/dist/core/support-budget.js +6 -0
- package/dist/core/system.js +6 -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 +11 -0
- package/dist/core/wall.js +37 -0
- package/dist/core/watch.d.ts +1 -1
- package/dist/core/watch.js +15 -2
- 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.d.ts +4 -0
- package/dist/kernel/cdcl.js +109 -41
- package/dist/kernel/epr.js +23 -8
- package/dist/kernel/kernel.d.ts +56 -0
- package/dist/kernel/kernel.js +466 -64
- package/dist/kernel/model-sequence.d.ts +2 -2
- package/dist/kernel/model-sequence.js +4 -3
- package/dist/kernel/model-values.d.ts +2 -0
- package/dist/kernel/model-values.js +60 -0
- package/dist/kernel/prove.d.ts +59 -3
- package/dist/kernel/prove.js +524 -130
- package/dist/kernel/prover-rows.d.ts +30 -0
- package/dist/kernel/prover-rows.js +125 -0
- package/dist/kernel/reader.d.ts +1 -1
- package/dist/kernel/reader.js +57 -12
- package/dist/kernel/simplex.js +9 -2
- package/dist/lean-kernel/emit.d.ts +47 -2
- package/dist/lean-kernel/emit.js +270 -36
- package/dist/lean-kernel/lean-terms.d.ts +1 -0
- package/dist/lean-kernel/lean-terms.js +13 -5
- package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
- package/dist/lean-kernel/legacy-family-library.js +5 -0
- package/dist/lean-kernel/library.js +4 -0
- package/dist/lean-kernel/qalpha.d.ts +7 -0
- package/dist/lean-kernel/qalpha.js +40 -0
- package/package.json +5 -1
package/dist/kernel/prove.js
CHANGED
|
@@ -11,14 +11,26 @@
|
|
|
11
11
|
import { cpair, evalC, evalE, walkOnce } from "../core/machine.js";
|
|
12
12
|
import { add, costs, env, k, refuteFast, scale, solve, sub, v, work } from "../core/solver.js";
|
|
13
13
|
import { checkRefutation } from "../core/check.js";
|
|
14
|
+
import { fullWork as rawFullWork } from "../core/work-meter.js";
|
|
15
|
+
import { stepWork, stepWorkProfile } from "../core/step-work.js";
|
|
16
|
+
import { completeWorkProfile } from "../core/work-profile.js";
|
|
17
|
+
import { projectedSearchWork, proxySearchState } from "../core/search-policy.js";
|
|
18
|
+
import { BudgetExpired, admittedWork, startWork, workLedger } from "../core/work-admission.js";
|
|
19
|
+
import { workDivide, workFromNumber, workMultiply, workToNumber } from "../core/work-amount.js";
|
|
20
|
+
export { BudgetExpired } from "../core/work-admission.js";
|
|
21
|
+
import { traceNow, withTraceWorkScope } from "../core/trace-clock.js";
|
|
14
22
|
import { allowNode, allowTranslated, certCyclic, certOn, certSearch, stepCertFloor, translateMs, closingInsts, crossCyclic, cyclicOn, cycLog, hasQuantified, loopNodes, machineNodes, proveCyclic, reqTS, searchedStepNodes, skMachine, timedKind, withWitness, translatedProof, uncovered, uncoveredWhy } from "../core/cyclic.js";
|
|
15
23
|
import { proveSome, someLaws } from "../core/exists.js";
|
|
16
24
|
import { REFUTED, growCdcl } from "./cdcl.js";
|
|
17
25
|
import { decide, eprMeter, pastEprCap, patternsOf, withEprCap } from "./epr.js";
|
|
18
26
|
import { projected, tupleParts } from "./kernel.js";
|
|
27
|
+
import { modelValueTerms } from "./model-values.js";
|
|
28
|
+
import { proverRows } from "./prover-rows.js";
|
|
19
29
|
import { assumed, atomOf, boundOf, canon, canonFlip, cellParts, columnTerm, decided, factorsOf, isCell, isMonomial, stepZone, check, checkLaws, checkStepLaws, historyMachine, plainOf, substC, substE, leafConstraints, leafConstraintsReusing, reusing, linear, livenessHelpful, livenessParts, strongly, loopMachine, obligations, plainKey, progressObligations, stepLawObligations, trueC, truth, unreachable, witnessesOf, withProducts } from "./kernel.js";
|
|
20
30
|
// The atoms the path leaves open, in evaluation order: deciding any of them makes progress.
|
|
21
31
|
function openE(e, path, out) {
|
|
32
|
+
if (completeWorkProfile.enabled)
|
|
33
|
+
checkWorkEndpoint('open expression');
|
|
22
34
|
switch (e.op) {
|
|
23
35
|
case 'var':
|
|
24
36
|
case 'const': return;
|
|
@@ -49,6 +61,8 @@ function openE(e, path, out) {
|
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
function openC(c, path, out) {
|
|
64
|
+
if (completeWorkProfile.enabled)
|
|
65
|
+
checkWorkEndpoint('open condition');
|
|
52
66
|
if (truth(c, path) !== undefined)
|
|
53
67
|
return;
|
|
54
68
|
if (c.op === 'flag' || c.op === 'all')
|
|
@@ -77,6 +91,8 @@ function openC(c, path, out) {
|
|
|
77
91
|
// conjunction of settled parts / a linear comparison. A disjunction is settled only once one disjunct is left open and
|
|
78
92
|
// that one is settled: facts from its last disjunct are not all its content while a case inside it is still open.
|
|
79
93
|
function openH(c, path, out, positive = true) {
|
|
94
|
+
if (completeWorkProfile.enabled)
|
|
95
|
+
checkWorkEndpoint('open hypothesis');
|
|
80
96
|
if (c.op === 'not')
|
|
81
97
|
return openH(c.x, path, out, !positive);
|
|
82
98
|
if ((c.op === 'and' && positive) || (c.op === 'or' && !positive))
|
|
@@ -177,6 +193,8 @@ function openCells(rows, path) {
|
|
|
177
193
|
const dec = (lin) => path.get(canon(lin))?.holds ?? (path.has(canonFlip(lin)) ? !path.get(canonFlip(lin)).holds : undefined);
|
|
178
194
|
for (let i = 0; i < names.length; i++)
|
|
179
195
|
for (let j = i + 1; j < names.length; j++) {
|
|
196
|
+
if (completeWorkProfile.enabled)
|
|
197
|
+
checkWorkEndpoint('open cell pair');
|
|
180
198
|
if (cs[i].map !== cs[j].map)
|
|
181
199
|
continue;
|
|
182
200
|
if (cs[i].keys || cs[j].keys) {
|
|
@@ -257,17 +275,17 @@ export function parseKey(text) {
|
|
|
257
275
|
// the time in the solver and in building rows. Off unless `profile.on`; the counters cost nothing then.
|
|
258
276
|
export const profile = { on: false, goals: [], solves: 0, solveMs: 0, rowsMs: 0, nodes: 0 };
|
|
259
277
|
const timed = (f, add) => { if (!profile.on)
|
|
260
|
-
return f(); const t =
|
|
278
|
+
return f(); const t = traceNow(); try {
|
|
261
279
|
return f();
|
|
262
280
|
}
|
|
263
281
|
finally {
|
|
264
|
-
add(
|
|
282
|
+
add(traceNow() - t);
|
|
265
283
|
} };
|
|
266
284
|
export const solveKinds = {};
|
|
267
285
|
const solveP = (rows, maxRows) => {
|
|
268
286
|
if (!profile.on)
|
|
269
287
|
return solve(rows, maxRows);
|
|
270
|
-
const t =
|
|
288
|
+
const t = traceNow(), out = solve(rows, maxRows), ms = traceNow() - t;
|
|
271
289
|
profile.solves++;
|
|
272
290
|
profile.solveMs += ms;
|
|
273
291
|
const s = (solveKinds[out.kind] ??= { n: 0, ms: 0, rows: 0 });
|
|
@@ -291,28 +309,54 @@ export const cellProducts = { on: false };
|
|
|
291
309
|
let deadline = Infinity, deadlineEpr = 0;
|
|
292
310
|
// EPR has its own work counter. Debit it from a counted deadline, not from clock(): the protocol engine already
|
|
293
311
|
// accounts for EPR in its own clock. A scope's anchor charges all its queries, including nested and failed ones.
|
|
294
|
-
const
|
|
312
|
+
const searchRate = () => proxySearchState()?.rate ?? rate;
|
|
313
|
+
const eprTimeSince = (start) => searchRate() ? (eprMeter.n - start) / searchRate() : 0;
|
|
295
314
|
// The clock every budget here reads (grow's `until`, withDeadline's; core/cyclic.ts's and core/data.ts's searches): wall
|
|
296
315
|
// time, or within `counted` the work the prover has done (the solver's rows read and made, each node's rows), `perMs`
|
|
297
316
|
// units a millisecond, so that what a search's budget lets it try, and so its verdict, doesn't depend on the machine's
|
|
298
317
|
// speed. A counted search inside another reads the outer's clock.
|
|
299
318
|
// With `full`, the clock reads the cost model below in place of work.n.
|
|
300
319
|
let rate = 0, meter = () => work.n;
|
|
301
|
-
export const clock = () =>
|
|
320
|
+
export const clock = () => {
|
|
321
|
+
const proxy = proxySearchState();
|
|
322
|
+
if (proxy)
|
|
323
|
+
return proxy.rate ? (proxy.model ? projectedSearchWork() : work.n) / proxy.rate : projectedSearchWork() / fullRate;
|
|
324
|
+
return completeWorkProfile.enabled ? workToNumber(workDivide(admittedWork(), workFromNumber(fullRate))) : stepWorkProfile.enabled ? fullWork() / fullRate : (rate ? meter() / rate : performance.now());
|
|
325
|
+
};
|
|
302
326
|
export function counted(perMs, f, full = false) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
327
|
+
return withTraceWorkScope(() => {
|
|
328
|
+
const proxy = proxySearchState();
|
|
329
|
+
if (proxy) {
|
|
330
|
+
if (proxy.rate)
|
|
331
|
+
return f();
|
|
332
|
+
const outer = proxy.deadline, outerEpr = proxy.deadlineEpr, model = proxy.model;
|
|
333
|
+
proxy.rate = perMs;
|
|
334
|
+
proxy.model = full;
|
|
335
|
+
proxy.deadline = Infinity;
|
|
336
|
+
try {
|
|
337
|
+
return f();
|
|
338
|
+
}
|
|
339
|
+
finally {
|
|
340
|
+
proxy.rate = 0;
|
|
341
|
+
proxy.model = model;
|
|
342
|
+
proxy.deadline = outer;
|
|
343
|
+
proxy.deadlineEpr = outerEpr;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (rate || completeWorkProfile.enabled)
|
|
347
|
+
return f();
|
|
348
|
+
const outer = deadline;
|
|
349
|
+
rate = perMs;
|
|
350
|
+
deadline = Infinity;
|
|
351
|
+
meter = full ? fullWork : () => work.n;
|
|
352
|
+
try {
|
|
353
|
+
return f();
|
|
354
|
+
}
|
|
355
|
+
finally {
|
|
356
|
+
rate = 0;
|
|
357
|
+
deadline = outer;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
316
360
|
}
|
|
317
361
|
// The cost model: what a query does, by kind (core/solver.ts's costs), each weighed to the milliseconds a Modal 2-vCPU
|
|
318
362
|
// container takes for it, `fullRate` units a millisecond at the median query: elimination's pairs and the float
|
|
@@ -322,30 +366,186 @@ export function counted(perMs, f, full = false) {
|
|
|
322
366
|
// the solver and each node read, which the incremental search reads whole no more: on 7,027 root queries of 20 ms or
|
|
323
367
|
// more (research/query/fit.py on runs/query/cal2: the 332 step goals, CHC sat and unsat, ITS, the false step goals and
|
|
324
368
|
// the real-world corpus), work.n did 28 to 377 units a ms (p10, p90), the model 120 to 401.
|
|
325
|
-
const model = [['fm', 2.33], ['fcells', 0.0123], ['plainRows', 7.93], ['values', 0.672], ['copies', 0.735], ['edges', 0.0435],
|
|
326
|
-
['scan', 0.0765], ['pivotRows', 0.599], ['unitRows', 15.6], ['unfoldRows', 0.735], ['goalNodes', 0.492], ['translateRows', 7.93]];
|
|
327
369
|
export const fullRate = 250;
|
|
328
|
-
export const fullWork = () =>
|
|
329
|
-
|
|
370
|
+
export const fullWork = () => stepWork() + rawFullWork();
|
|
371
|
+
// Only heuristic readers use this. fullWork and every admission stay authoritative.
|
|
372
|
+
export const searchWork = () => proxySearchState() ? projectedSearchWork() : fullWork();
|
|
373
|
+
// Explicit synchronous work scopes. The default paths do not enter one yet:
|
|
374
|
+
// count/plain migrations and legacy deadline-reset semantics are separate steps.
|
|
375
|
+
let budgetUnitsEnd;
|
|
376
|
+
let admissionRefusedAt;
|
|
377
|
+
export const inBudget = () => completeWorkProfile.enabled ? workLedger.inBudget() : budgetUnitsEnd !== undefined;
|
|
378
|
+
export const inWorkScope = () => inBudget() || rate !== 0 || stepWorkProfile.enabled;
|
|
379
|
+
// Search endpoints follow the active clock; legacy real walls remain separate.
|
|
380
|
+
export const searchNow = () => inWorkScope() ? clock() : performance.now();
|
|
381
|
+
export const budgetEnd = () => {
|
|
382
|
+
if (proxySearchState())
|
|
383
|
+
return Infinity;
|
|
384
|
+
if (!completeWorkProfile.enabled)
|
|
385
|
+
return (budgetUnitsEnd ?? Infinity) / fullRate;
|
|
386
|
+
const end = workLedger.endpoint();
|
|
387
|
+
return end === null ? Infinity : workToNumber(workDivide(end, workFromNumber(fullRate)));
|
|
388
|
+
};
|
|
389
|
+
// Hard-stop checkpoints must not turn a local search deadline into a whole-run stop.
|
|
390
|
+
export function checkWorkEndpoint(phase) {
|
|
391
|
+
if (completeWorkProfile.enabled) {
|
|
392
|
+
workLedger.check(phase);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (budgetUnitsEnd !== undefined && (admissionRefusedAt === budgetUnitsEnd || fullWork() > budgetUnitsEnd))
|
|
396
|
+
throw new BudgetExpired(phase);
|
|
397
|
+
}
|
|
398
|
+
// Pre-step admission for new native primitive counters. No credit is minted and
|
|
399
|
+
// no local deadline is promoted to whole-search cancellation.
|
|
400
|
+
export function checkWorkAdmission(units, phase) {
|
|
401
|
+
if (!Number.isFinite(units) || units < 0)
|
|
402
|
+
throw new RangeError('work charge must be finite and nonnegative');
|
|
403
|
+
if (completeWorkProfile.enabled) {
|
|
404
|
+
workLedger.checkAmount(workFromNumber(units), phase);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (budgetUnitsEnd !== undefined && (admissionRefusedAt === budgetUnitsEnd || fullWork() + units > budgetUnitsEnd)) {
|
|
408
|
+
admissionRefusedAt = budgetUnitsEnd;
|
|
409
|
+
throw new BudgetExpired(phase);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export function remainingWork() {
|
|
413
|
+
if (completeWorkProfile.enabled) {
|
|
414
|
+
const left = workLedger.available();
|
|
415
|
+
return left === null ? Infinity : workToNumber(left);
|
|
416
|
+
}
|
|
417
|
+
return budgetUnitsEnd === undefined ? Infinity : admissionRefusedAt === budgetUnitsEnd ? 0 : Math.max(0, budgetUnitsEnd - fullWork());
|
|
418
|
+
}
|
|
419
|
+
export function checkBudget(phase) {
|
|
420
|
+
if (completeWorkProfile.enabled) {
|
|
421
|
+
workLedger.check(phase);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (budgetUnitsEnd !== undefined && (admissionRefusedAt === budgetUnitsEnd || fullWork() > budgetUnitsEnd
|
|
425
|
+
|| completeWorkProfile.enabled && clock() > withinDeadline(budgetEnd())))
|
|
426
|
+
throw new BudgetExpired(phase);
|
|
427
|
+
}
|
|
428
|
+
export function withBudget(units, f) {
|
|
429
|
+
if (completeWorkProfile.enabled) {
|
|
430
|
+
const grant = typeof units === 'number' ? workFromNumber(units) : units;
|
|
431
|
+
// Opening a real quota must not introduce a heuristic counted region.
|
|
432
|
+
if (proxySearchState())
|
|
433
|
+
return withTraceWorkScope(() => workLedger.withBudget(grant, () => {
|
|
434
|
+
checkBudget('entry');
|
|
435
|
+
const result = f();
|
|
436
|
+
checkBudget('completion');
|
|
437
|
+
return result;
|
|
438
|
+
}));
|
|
439
|
+
return counted(fullRate, () => workLedger.withBudget(grant, () => {
|
|
440
|
+
checkBudget('entry');
|
|
441
|
+
const result = f();
|
|
442
|
+
checkBudget('completion');
|
|
443
|
+
return result;
|
|
444
|
+
}), true);
|
|
445
|
+
}
|
|
446
|
+
if (typeof units !== 'number')
|
|
447
|
+
throw new Error('exact work budgets require the full-work profile');
|
|
448
|
+
if (!Number.isFinite(units) || units < 0)
|
|
449
|
+
throw new RangeError('work budget must be finite and nonnegative');
|
|
450
|
+
// Never silently interpret units using a legacy work.n/count-rate island.
|
|
451
|
+
if (rate && meter !== fullWork)
|
|
452
|
+
throw new Error('work budget requires the outer full-work clock');
|
|
453
|
+
return counted(fullRate, () => {
|
|
454
|
+
checkWorkEndpoint('inherited admission');
|
|
455
|
+
const previous = budgetUnitsEnd, previousRefused = admissionRefusedAt;
|
|
456
|
+
budgetUnitsEnd = Math.min(previous ?? Infinity, workCap, fullWork() + units);
|
|
457
|
+
try {
|
|
458
|
+
return withWork(budgetUnitsEnd, () => withDeadline(budgetEnd(), () => {
|
|
459
|
+
checkBudget('entry');
|
|
460
|
+
const result = f();
|
|
461
|
+
// The final checker is inside the allowance, not free completion work.
|
|
462
|
+
checkBudget('completion');
|
|
463
|
+
return result;
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
466
|
+
finally {
|
|
467
|
+
// A refusal at a shared endpoint remains visible after an inner scope;
|
|
468
|
+
// a genuinely smaller child allowance cannot poison a larger parent.
|
|
469
|
+
admissionRefusedAt = admissionRefusedAt === budgetUnitsEnd && previous === budgetUnitsEnd ? previous : previousRefused;
|
|
470
|
+
budgetUnitsEnd = previous;
|
|
471
|
+
}
|
|
472
|
+
}, true);
|
|
473
|
+
}
|
|
330
474
|
// A goal's own budget where its caller gives none, outside a counted search: the cost model's work, groundRate units a
|
|
331
475
|
// millisecond of the budget (below fullRate: the queries of 10 s or more did 163 to 271 units a ms at their median, by
|
|
332
476
|
// group of the run above, so a long goal's budget takes about the wall time it had), so a goal left unknown is left so
|
|
333
477
|
// on any machine; a deadline it is grown within stays.
|
|
334
478
|
const groundRate = 180;
|
|
335
479
|
let workCap = Infinity;
|
|
336
|
-
export const withWork = (cap, f) => {
|
|
337
|
-
|
|
480
|
+
export const withWork = (cap, f) => {
|
|
481
|
+
if (completeWorkProfile.enabled) {
|
|
482
|
+
if (cap === Infinity)
|
|
483
|
+
return f();
|
|
484
|
+
return workLedger.withEndpoint('work-cap', typeof cap === 'number' ? workFromNumber(cap) : cap, f);
|
|
485
|
+
}
|
|
486
|
+
if (typeof cap !== 'number')
|
|
487
|
+
throw new Error('exact work caps require the full-work profile');
|
|
488
|
+
const outer = workCap;
|
|
489
|
+
workCap = Math.min(outer, cap);
|
|
490
|
+
try {
|
|
491
|
+
return f();
|
|
492
|
+
}
|
|
493
|
+
finally {
|
|
494
|
+
workCap = outer;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
// Internal search caps are proxy state only; explicit withWork remains native.
|
|
498
|
+
const searchWorkCap = () => proxySearchState()?.workCap ?? workCap;
|
|
499
|
+
export function withSearchWork(cap, f) {
|
|
500
|
+
const proxy = proxySearchState();
|
|
501
|
+
if (!proxy)
|
|
502
|
+
return withWork(cap, f);
|
|
503
|
+
const outer = proxy.workCap;
|
|
504
|
+
proxy.workCap = Math.min(outer, cap);
|
|
505
|
+
try {
|
|
506
|
+
return f();
|
|
507
|
+
}
|
|
508
|
+
finally {
|
|
509
|
+
proxy.workCap = outer;
|
|
510
|
+
}
|
|
338
511
|
}
|
|
339
|
-
finally {
|
|
340
|
-
workCap = outer;
|
|
341
|
-
} };
|
|
342
512
|
// Past a budget's end on the clock, or past the work a goal's own budget allows.
|
|
343
513
|
// A wall-clock end beside the clock's (withWall: the search's own end, core/dsl.ts): work the counted clock doesn't count
|
|
344
514
|
// (the EPR path's propositional search, a node's propagation, building a large goal's rows) stops there too, and past it
|
|
345
515
|
// every goal is left unknown, whatever its own budget. Untrusted: it only stops a search.
|
|
346
516
|
let wallEnd = Infinity;
|
|
347
|
-
|
|
348
|
-
export
|
|
517
|
+
// Capture the producer's clock domain before nested counted() changes it.
|
|
518
|
+
export const wallDeadline = (end, domain) => ({ end, domain: domain ?? (inWorkScope() || proxySearchState()?.rate ? 'counted' : 'real') });
|
|
519
|
+
// A legacy counted clock is not an opt-in work-only cancellation policy.
|
|
520
|
+
// Preserve its inherited real wall; only explicit work scopes/profiles elide it.
|
|
521
|
+
const workOnlyWall = () => inBudget() || stepWorkProfile.enabled;
|
|
522
|
+
export const pastWall = () => {
|
|
523
|
+
checkWorkEndpoint('prover boundary');
|
|
524
|
+
const proxy = proxySearchState();
|
|
525
|
+
if (proxy)
|
|
526
|
+
return clock() > withinDeadline(Infinity) || (!workOnlyWall() && proxy.wallEnd !== Infinity && performance.now() > proxy.wallEnd);
|
|
527
|
+
return (inWorkScope() && clock() > withinDeadline(budgetEnd()))
|
|
528
|
+
|| (!workOnlyWall() && wallEnd !== Infinity && performance.now() > wallEnd);
|
|
529
|
+
};
|
|
530
|
+
export function withWall(limit, f) {
|
|
531
|
+
const proxy = proxySearchState();
|
|
532
|
+
// Untagged legacy endpoints retain their old policy. Search producers tag
|
|
533
|
+
// their domain explicitly, so counted milliseconds never become real time.
|
|
534
|
+
const { end, domain } = typeof limit === 'number' ? wallDeadline(limit, workOnlyWall() || proxy?.rate ? 'counted' : 'real') : limit;
|
|
535
|
+
if (domain === 'counted')
|
|
536
|
+
return withDeadline(Math.min(budgetEnd(), end), f);
|
|
537
|
+
if (workOnlyWall())
|
|
538
|
+
return f();
|
|
539
|
+
if (proxy) {
|
|
540
|
+
const outer = proxy.wallEnd;
|
|
541
|
+
proxy.wallEnd = Math.min(outer, end);
|
|
542
|
+
try {
|
|
543
|
+
return f();
|
|
544
|
+
}
|
|
545
|
+
finally {
|
|
546
|
+
proxy.wallEnd = outer;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
349
549
|
const outer = wallEnd;
|
|
350
550
|
wallEnd = Math.min(outer, end);
|
|
351
551
|
try {
|
|
@@ -357,12 +557,46 @@ export function withWall(end, f) {
|
|
|
357
557
|
}
|
|
358
558
|
// Past the wall or the deadline in force: a goal grown now is left unknown at once.
|
|
359
559
|
const ranOut = () => pastWall() || withinDeadline(Infinity) <= clock();
|
|
360
|
-
//
|
|
361
|
-
export const wallAt = () =>
|
|
362
|
-
|
|
560
|
+
// Active-clock endpoint; inherited real walls are checked separately by pastWall.
|
|
561
|
+
export const wallAt = () => {
|
|
562
|
+
const proxy = proxySearchState();
|
|
563
|
+
if (proxy)
|
|
564
|
+
return workOnlyWall() || proxy.rate ? withinDeadline(Infinity) : proxy.wallEnd;
|
|
565
|
+
return inWorkScope() ? withinDeadline(budgetEnd()) : wallEnd;
|
|
566
|
+
};
|
|
567
|
+
export const late = (until) => {
|
|
568
|
+
checkWorkEndpoint('prover poll');
|
|
569
|
+
const proxy = proxySearchState();
|
|
570
|
+
if (proxy)
|
|
571
|
+
return clock() > until || (proxy.workCap !== Infinity && searchWork() > proxy.workCap) || pastWall();
|
|
572
|
+
return clock() > until || (workCap !== Infinity && fullWork() > workCap) || pastWall();
|
|
573
|
+
};
|
|
363
574
|
// A budget's end, within the deadline (a translation's own bound, core/cyclic.ts's, kept by the export's GDP_CERT_MS).
|
|
364
|
-
export const withinDeadline = (until) =>
|
|
575
|
+
export const withinDeadline = (until) => {
|
|
576
|
+
const proxy = proxySearchState();
|
|
577
|
+
if (proxy)
|
|
578
|
+
return Math.min(until, proxy.deadline - eprTimeSince(proxy.deadlineEpr));
|
|
579
|
+
return completeWorkProfile.enabled ? Math.min(until, budgetEnd()) : Math.min(until, deadline - eprTimeSince(deadlineEpr));
|
|
580
|
+
};
|
|
365
581
|
export function withDeadline(until, f) {
|
|
582
|
+
const proxy = proxySearchState();
|
|
583
|
+
if (proxy) {
|
|
584
|
+
const outer = proxy.deadline, outerEpr = proxy.deadlineEpr;
|
|
585
|
+
proxy.deadline = withinDeadline(until);
|
|
586
|
+
proxy.deadlineEpr = eprMeter.n;
|
|
587
|
+
try {
|
|
588
|
+
return f();
|
|
589
|
+
}
|
|
590
|
+
finally {
|
|
591
|
+
proxy.deadline = outer;
|
|
592
|
+
proxy.deadlineEpr = outerEpr;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (completeWorkProfile.enabled) {
|
|
596
|
+
if (until === Infinity)
|
|
597
|
+
return f();
|
|
598
|
+
return workLedger.withEndpoint('deadline', workMultiply(workFromNumber(until), workFromNumber(fullRate)), f);
|
|
599
|
+
}
|
|
366
600
|
const outer = deadline, outerEpr = deadlineEpr;
|
|
367
601
|
deadline = withinDeadline(until);
|
|
368
602
|
deadlineEpr = eprMeter.n;
|
|
@@ -374,6 +608,9 @@ export function withDeadline(until, f) {
|
|
|
374
608
|
deadlineEpr = outerEpr;
|
|
375
609
|
}
|
|
376
610
|
}
|
|
611
|
+
// Full-accounting closing snapshots keep absolute endpoints and the legacy
|
|
612
|
+
// clock anchors as data. This observer never rebases deadlines or resets fuel.
|
|
613
|
+
export const snapshotProofClock = () => ({ rate, deadline, deadlineEpr, budgetUnitsEnd, admissionRefusedAt, workCap, wallEnd });
|
|
377
614
|
// `units: false`: the goal's own order, no units first (a caller after a model, not a proof: a run guided by the
|
|
378
615
|
// prover's witnesses, say, whose models units would steer).
|
|
379
616
|
export function grow(goal, path = new Map(), budget) {
|
|
@@ -381,8 +618,8 @@ export function grow(goal, path = new Map(), budget) {
|
|
|
381
618
|
return { stuck: 'unknown', path, why: outOfBudget(goal, 'time', path.size) };
|
|
382
619
|
if (!budget) {
|
|
383
620
|
const ms = Math.max(20_000, 1_000 * goal.hyps.length);
|
|
384
|
-
if (!
|
|
385
|
-
return
|
|
621
|
+
if (!searchRate())
|
|
622
|
+
return withSearchWork(searchWork() + groundRate * ms, () => grow(goal, path, { nodes: 0 }));
|
|
386
623
|
budget = { nodes: 0, until: clock() + ms };
|
|
387
624
|
}
|
|
388
625
|
const end = withinDeadline(budget.until ?? Infinity);
|
|
@@ -401,14 +638,16 @@ export function grow(goal, path = new Map(), budget) {
|
|
|
401
638
|
proveDump(goal);
|
|
402
639
|
}
|
|
403
640
|
if (proveTrace && !path.size && !budget.nodes) {
|
|
404
|
-
const t =
|
|
405
|
-
console.error(`[grow] ${goal.name}: ${goal.hyps.length} hyps, ${budget.nodes} nodes, ${Math.round(
|
|
641
|
+
const t = traceNow(), out = growRoot(goal, path, budget);
|
|
642
|
+
console.error(`[grow] ${goal.name}: ${goal.hyps.length} hyps, ${budget.nodes} nodes, ${Math.round(traceNow() - t)} ms, ${'tree' in out ? 'proven' : `${out.stuck}${out.why ? ` (${out.why})` : ''}`}`);
|
|
406
643
|
return out;
|
|
407
644
|
}
|
|
408
645
|
// (a root goal grown before within `withTrees`: its tree again; a tree is the kernel's to check wherever it goes)
|
|
409
646
|
const key = treeCache.on && !path.size && !budget.nodes ? treeKey(goal) : undefined, had = key === undefined ? undefined : treeCache.trees.get(key);
|
|
410
|
-
if (had)
|
|
647
|
+
if (had) {
|
|
648
|
+
treeReuseStats.hits++;
|
|
411
649
|
return { tree: had, nodes: 0 };
|
|
650
|
+
}
|
|
412
651
|
if (key !== undefined) {
|
|
413
652
|
const out = growKept(goal, path, budget);
|
|
414
653
|
if ('tree' in out)
|
|
@@ -420,7 +659,8 @@ export function grow(goal, path = new Map(), budget) {
|
|
|
420
659
|
// Trees of root goals kept by their hypotheses (and the search's modes) while `withTrees` runs: core/infer.ts proves each
|
|
421
660
|
// law of a set alone (proveLaw) and then the set as a whole (proveRule), the same goals twice. At most 2,000 trees, and
|
|
422
661
|
// goals of at most 4 MB written out.
|
|
423
|
-
const
|
|
662
|
+
export const treeReuseStats = { hits: 0, kept: 0 };
|
|
663
|
+
const treeCache = { on: 0, trees: new Map(), keep(key, tree) { treeReuseStats.kept++; if (this.trees.size >= 2000)
|
|
424
664
|
this.trees.clear(); this.trees.set(key, tree); } };
|
|
425
665
|
const treeKey = (goal) => { const text = JSON.stringify(goal.hyps); return text.length > 4_000_000 ? undefined : `${cellProducts.on ? 1 : 0}${unitsNow ? 1 : 0}${text}`; };
|
|
426
666
|
// GDP_TREES=0: no tree kept (each goal grown every time it is asked).
|
|
@@ -441,11 +681,11 @@ export function withTrees(f) {
|
|
|
441
681
|
// its wall time and counted work, its outcome, and how many queries it is inside.
|
|
442
682
|
export const queryHook = { depth: 0 };
|
|
443
683
|
export function logged(kind, goal, f) {
|
|
444
|
-
const t0 =
|
|
684
|
+
const t0 = traceNow(), w0 = work.n;
|
|
445
685
|
queryHook.depth++;
|
|
446
686
|
try {
|
|
447
687
|
const out = f();
|
|
448
|
-
queryHook.on?.({ kind, goal, ms:
|
|
688
|
+
queryHook.on?.({ kind, goal, ms: traceNow() - t0, work: work.n - w0, out, depth: queryHook.depth - 1 });
|
|
449
689
|
return out;
|
|
450
690
|
}
|
|
451
691
|
finally {
|
|
@@ -460,9 +700,9 @@ function growKept(goal, path, budget) {
|
|
|
460
700
|
function growKept0(goal, path, budget) {
|
|
461
701
|
if (!profile.on || path.size || budget.nodes)
|
|
462
702
|
return growRoot(goal, path, budget);
|
|
463
|
-
const t =
|
|
703
|
+
const t = traceNow(), s0 = profile.solves, m0 = profile.solveMs, r0 = profile.rowsMs, n0 = profile.nodes;
|
|
464
704
|
const out = growRoot(goal, path, budget);
|
|
465
|
-
profile.goals.push({ name: goal.name, ms:
|
|
705
|
+
profile.goals.push({ name: goal.name, ms: traceNow() - t, nodes: profile.nodes - n0, solves: profile.solves - s0, solveMs: profile.solveMs - m0, rowsMs: profile.rowsMs - r0, proven: 'tree' in out });
|
|
466
706
|
return out;
|
|
467
707
|
}
|
|
468
708
|
// The share of a root goal's budget the CDCL search gets (GDP_CDCL_SHARE; 0 turns it off), and the quick search's nodes
|
|
@@ -506,11 +746,11 @@ function eprFirst(goal, budget, whole = true, stop = () => pastWall() || pastEpr
|
|
|
506
746
|
if (d.sat)
|
|
507
747
|
return { stuck: 'sat', witness: d.witness, diagram: d.diagram, path: new Map(), why: 'a model' };
|
|
508
748
|
const last = goal.hyps.length - 1, core = d.core.includes(last) ? d.core : [...d.core, last], part = { name: goal.name, hyps: core.map(i => goal.hyps[i]) };
|
|
509
|
-
const now = clock(), end = withinDeadline(budget.until ?? Infinity), w =
|
|
749
|
+
const now = clock(), end = withinDeadline(budget.until ?? Infinity), w = searchWork();
|
|
510
750
|
eprScope.busy = true;
|
|
511
751
|
try {
|
|
512
752
|
const share = whole ? 0.5 : 1;
|
|
513
|
-
const out =
|
|
753
|
+
const out = withSearchWork(searchWorkCap() === Infinity ? Infinity : w + share * (searchWorkCap() - w), () => grow(part, new Map(), { nodes: 0, until: end === Infinity ? end : now + share * (end - now) }));
|
|
514
754
|
if (!('tree' in out)) {
|
|
515
755
|
eprLast.refuted = true;
|
|
516
756
|
return undefined;
|
|
@@ -599,8 +839,8 @@ export const wideFor = (goal) => !wideBusy && goal.hyps.length >= wideAt && term
|
|
|
599
839
|
// (`keep`: a part's tree kept as the part's, with the part and its hypotheses' indices in the whole as its core, not
|
|
600
840
|
// widened: settle's, whose final proof is made over the instances its proofs read)
|
|
601
841
|
export function growWide(goal, budget, ask = (g, until) => grow(g, new Map(), { nodes: 0, until }), keep = false) {
|
|
602
|
-
const hyps = goal.hyps, last = hyps.length - 1, broken = brokenOf(goal), now = clock(), w =
|
|
603
|
-
const end = withinDeadline(budget.until ?? Infinity), span = wideShare * (end - now), room = wideShare * (
|
|
842
|
+
const hyps = goal.hyps, last = hyps.length - 1, broken = brokenOf(goal), now = clock(), w = searchWork();
|
|
843
|
+
const end = withinDeadline(budget.until ?? Infinity), span = wideShare * (end - now), room = wideShare * (searchWorkCap() - w), until = now + span;
|
|
604
844
|
const part = new Set([last]), near = new Set(cellsIn(hyps[last])), cells = new Map();
|
|
605
845
|
const cellsAt = (i) => { let c = cells.get(i); if (!c)
|
|
606
846
|
cells.set(i, (c = cellsIn(hyps[i]))); return c; };
|
|
@@ -614,24 +854,24 @@ export function growWide(goal, budget, ask = (g, until) => grow(g, new Map(), {
|
|
|
614
854
|
// (a part's own budget: what the whole's search spends on as many nodes, four times over (a node of the part reads
|
|
615
855
|
// that much less), at least a sixteenth of the share: a part that a small budget doesn't settle leaves the goal)
|
|
616
856
|
const ids = [...part].sort((a, b) => a - b), g = { name: goal.name, hyps: ids.map(i => hyps[i]) }, f = Math.max(1 / 16, Math.min(1, 4 * part.size / hyps.length));
|
|
617
|
-
const t0 =
|
|
857
|
+
const t0 = traceNow(), at = clock();
|
|
618
858
|
wideScope.judge = w => !broken(w, ids, true).length;
|
|
619
859
|
let out;
|
|
620
860
|
try {
|
|
621
|
-
out =
|
|
861
|
+
out = withSearchWork(Math.min(w + room, searchWork() + f * room), () => ask(g, Math.min(until, at + f * span)));
|
|
622
862
|
}
|
|
623
863
|
finally {
|
|
624
864
|
wideScope.judge = undefined;
|
|
625
865
|
}
|
|
626
866
|
wideHook.on?.(g, out);
|
|
627
867
|
if (wideTrace)
|
|
628
|
-
console.error(`[wide] ${goal.name.slice(0, 40)}: part ${g.hyps.length} of ${hyps.length}, ${'tree' in out ? 'tree' : out.stuck} in ${Math.round(
|
|
868
|
+
console.error(`[wide] ${goal.name.slice(0, 40)}: part ${g.hyps.length} of ${hyps.length}, ${'tree' in out ? 'tree' : out.stuck} in ${Math.round(traceNow() - t0)} ms${'tree' in out ? '' : ` ${out.why?.slice(0, 50) ?? ''}`}`);
|
|
629
869
|
if ('tree' in out && keep) {
|
|
630
870
|
wideStats.trees++;
|
|
631
871
|
return { tree: out.tree, nodes: out.nodes, part: g, core: ids };
|
|
632
872
|
}
|
|
633
873
|
if ('tree' in out) {
|
|
634
|
-
const tree =
|
|
874
|
+
const tree = withSearchWork(w + room, () => withDeadline(until, () => widen(g, goal, out.tree)));
|
|
635
875
|
if (tree)
|
|
636
876
|
wideStats.trees++;
|
|
637
877
|
return tree && { tree, nodes: out.nodes };
|
|
@@ -715,8 +955,8 @@ function growRoot(goal, path, budget) {
|
|
|
715
955
|
}
|
|
716
956
|
if (root) {
|
|
717
957
|
if (cdcl) {
|
|
718
|
-
const now = clock(), end = withinDeadline(budget.until ?? Infinity), w =
|
|
719
|
-
const out =
|
|
958
|
+
const now = clock(), end = withinDeadline(budget.until ?? Infinity), w = searchWork();
|
|
959
|
+
const out = withSearchWork(searchWorkCap() === Infinity ? Infinity : w + cdclShare * (searchWorkCap() - w), () => growCdcl(goal, path, { nodes: 0, until: end === Infinity ? end : now + cdclShare * (end - now) }));
|
|
720
960
|
// (with `realModels.on`, a model whose products don't multiply out is no model: the CDCL search reads a product as
|
|
721
961
|
// a name of its own, where the plain search below multiplies rows; a goal whose products only its cases bring,
|
|
722
962
|
// core/nonterm.ts's x' := x·y)
|
|
@@ -750,9 +990,14 @@ function growPlain(goal, path, budget) {
|
|
|
750
990
|
const full = timed(() => rowsAt(goal, path), ms => { profile.rowsMs += ms; });
|
|
751
991
|
work.n += 1 + full.length;
|
|
752
992
|
costs.plainNodes++;
|
|
753
|
-
|
|
993
|
+
if (!completeWorkProfile.enabled)
|
|
994
|
+
costs.plainRows += full.length;
|
|
754
995
|
const columns = [...path.values()].some(a => Object.keys(a.lin).some(key => key.startsWith('⟦')));
|
|
755
|
-
const idx = full.flatMap((r, i) =>
|
|
996
|
+
const idx = full.flatMap((r, i) => {
|
|
997
|
+
if (completeWorkProfile.enabled)
|
|
998
|
+
startWork('plainRows', 1, 'plain row processing');
|
|
999
|
+
return columns || !Object.keys(r.lin).some(key => key.startsWith('⟦')) ? [i] : [];
|
|
1000
|
+
});
|
|
756
1001
|
const rows = idx.map(i => full[i]), at = (i) => (i < rows.length ? idx[i] : full.length + i - rows.length);
|
|
757
1002
|
const leafOf = (steps0, products0, squares0) => {
|
|
758
1003
|
const { steps, products, squares } = products0 || squares0 ? trimmed(rows.length, steps0, products0 ?? [], squares0 ?? []) : { steps: steps0, products: undefined, squares: undefined };
|
|
@@ -1060,10 +1305,22 @@ export function rowsAt(goal, path) {
|
|
|
1060
1305
|
if (!rows) {
|
|
1061
1306
|
if (byPath.size >= 4096)
|
|
1062
1307
|
byPath.clear();
|
|
1063
|
-
byPath.set(id, (rows = leafConstraintsReusing(goal, path)));
|
|
1308
|
+
byPath.set(id, (rows = env.GDP_ROWS_SHARED === '0' ? leafConstraintsReusing(goal, path) : proverRows(goal, path)));
|
|
1064
1309
|
}
|
|
1065
1310
|
return rows;
|
|
1066
1311
|
}
|
|
1312
|
+
// Untrusted capture may reuse an existing proposal without forcing a cache
|
|
1313
|
+
// miss to materialize another table. Same lookup as rowsAt; no cache mutation,
|
|
1314
|
+
// metering, checking, or authority to accept a certificate.
|
|
1315
|
+
export function cachedRowsAt(goal, path) {
|
|
1316
|
+
const byPath = rowsSeen.get(goal);
|
|
1317
|
+
if (!byPath)
|
|
1318
|
+
return undefined;
|
|
1319
|
+
let id = '';
|
|
1320
|
+
for (const [key, a] of path)
|
|
1321
|
+
id += `${a.holds ? '+' : '-'}${key}|`;
|
|
1322
|
+
return byPath.get(id);
|
|
1323
|
+
}
|
|
1067
1324
|
function lift(goal, tree, from, to) {
|
|
1068
1325
|
const own = to.size; // the decision's row: the last of `from`'s path rows, below every later split's
|
|
1069
1326
|
const reads = (t) => ('leaf' in t ? t.leaf.some(st => st.kind === 'input' && st.index === own) || (t.products ?? []).some(([i, j]) => i === own || j === own) : reads(t.yes) || reads(t.no));
|
|
@@ -1104,6 +1361,7 @@ function lift(goal, tree, from, to) {
|
|
|
1104
1361
|
};
|
|
1105
1362
|
return go(tree, from, to);
|
|
1106
1363
|
}
|
|
1364
|
+
import { rememberProofRows } from "../core/lemma-cuts.js";
|
|
1107
1365
|
// A tree for a weaker goal (some hypotheses left out, some conjuncts of one left out) made a tree for the whole: at any
|
|
1108
1366
|
// path a leaf's rows are among the whole goal's (each hypothesis' facts are a hypothesis' own, the cells, terms and
|
|
1109
1367
|
// naturals they read a subset), so each input is renumbered to the same row there, a square or product past the rows
|
|
@@ -1152,6 +1410,7 @@ export function widen(part, whole, tree, opaque = {}, pp = new Map(), wp = pp) {
|
|
|
1152
1410
|
if (pastWall())
|
|
1153
1411
|
return undefined;
|
|
1154
1412
|
const rw = rowsAt(whole, wp), at = new Map();
|
|
1413
|
+
const remember = (out) => { rememberProofRows(out, whole, wp, rw); return out; };
|
|
1155
1414
|
rw.forEach((r, i) => { const key = canon(r.lin); if (!at.has(key))
|
|
1156
1415
|
at.set(key, i); });
|
|
1157
1416
|
const map = (i) => { if (i >= rp.length)
|
|
@@ -1182,10 +1441,10 @@ export function widen(part, whole, tree, opaque = {}, pp = new Map(), wp = pp) {
|
|
|
1182
1441
|
if (ok && names.length && !checkRefutation(withProducts(rw, products, squares), leaf))
|
|
1183
1442
|
ok = false;
|
|
1184
1443
|
if (ok)
|
|
1185
|
-
return { leaf, ...(tree.products ? { products } : {}), ...(tree.squares ? { squares: squares } : {}) };
|
|
1444
|
+
return remember({ leaf, ...(tree.products ? { products } : {}), ...(tree.squares ? { squares: squares } : {}) });
|
|
1186
1445
|
const absurd = rw.findIndex(r => Object.keys(r.lin).every(key => key === '1') && (r.lin['1'] ?? 0) > 0);
|
|
1187
1446
|
if (absurd >= 0)
|
|
1188
|
-
return { leaf: [{ kind: 'input', index: absurd }] };
|
|
1447
|
+
return remember({ leaf: [{ kind: 'input', index: absurd }] });
|
|
1189
1448
|
const out = grow(whole, wp);
|
|
1190
1449
|
return 'tree' in out ? out.tree : undefined;
|
|
1191
1450
|
}
|
|
@@ -1194,9 +1453,10 @@ const nearSeen = new WeakMap();
|
|
|
1194
1453
|
// (the names a term reads, its shared parts walked once: a witness read at each of its uses is one object)
|
|
1195
1454
|
const namesOf = (t) => {
|
|
1196
1455
|
const out = new Set();
|
|
1197
|
-
walkOnce(t, o => {
|
|
1456
|
+
walkOnce(t, o => { if (!completeWorkProfile.enabled)
|
|
1457
|
+
costs.goalNodes++; for (const [key, v] of Object.entries(o))
|
|
1198
1458
|
if ((key === 'name' || key === 'map') && typeof v === 'string')
|
|
1199
|
-
out.add(v); });
|
|
1459
|
+
out.add(v); }, completeWorkProfile.enabled ? () => startWork('goalNodes', 1, 'goal name traversal') : undefined);
|
|
1200
1460
|
return out;
|
|
1201
1461
|
};
|
|
1202
1462
|
export function nearOf(goal) {
|
|
@@ -1223,9 +1483,12 @@ function unitsOf(goal) {
|
|
|
1223
1483
|
// Forced by the root's rows without a solver: a row the atom is (or is the negation of), or the bounds the rows give
|
|
1224
1484
|
// single variables (x <= c, x >= c) deciding it whichever way its variables go.
|
|
1225
1485
|
const root = new Map(), rows = leafConstraints(goal, root), seen = new Set(), given = new Set();
|
|
1226
|
-
|
|
1486
|
+
if (!completeWorkProfile.enabled)
|
|
1487
|
+
costs.unitRows += rows.length;
|
|
1227
1488
|
const lo = new Map(), hi = new Map();
|
|
1228
1489
|
for (const r of rows) {
|
|
1490
|
+
if (completeWorkProfile.enabled)
|
|
1491
|
+
startWork('unitRows', 1, 'unit row processing');
|
|
1229
1492
|
given.add(canon(r.lin));
|
|
1230
1493
|
const vs = Object.keys(r.lin).filter(key => key !== '1');
|
|
1231
1494
|
if (vs.length !== 1)
|
|
@@ -1354,7 +1617,8 @@ function growFocused(goal, path, focus, budget, near = focus) {
|
|
|
1354
1617
|
// (each node reads its whole leaf, counted as growPlain counts a node's rows)
|
|
1355
1618
|
const leaf = leafConstraints(goal, path);
|
|
1356
1619
|
work.n += 1 + leaf.length;
|
|
1357
|
-
|
|
1620
|
+
if (!completeWorkProfile.enabled)
|
|
1621
|
+
costs.plainRows += leaf.length;
|
|
1358
1622
|
const verdict = solveNear(leaf, [...near, ...[...path.values()].slice(-1).map(a => a.lin)]);
|
|
1359
1623
|
if (verdict.kind === 'refuted')
|
|
1360
1624
|
return { tree: { leaf: verdict.steps }, nodes: budget.nodes };
|
|
@@ -1376,10 +1640,13 @@ function growFocused(goal, path, focus, budget, near = focus) {
|
|
|
1376
1640
|
// read (a param every step reads) joins no rows: through it every step is near every other.
|
|
1377
1641
|
function solveNear(rows, seeds) {
|
|
1378
1642
|
const uses = new Map();
|
|
1379
|
-
for (const r of rows)
|
|
1643
|
+
for (const r of rows) {
|
|
1644
|
+
if (completeWorkProfile.enabled)
|
|
1645
|
+
startWork('plainRows', 1, 'focused row processing');
|
|
1380
1646
|
for (const key in r.lin)
|
|
1381
1647
|
if (key !== '1')
|
|
1382
1648
|
uses.set(key, (uses.get(key) ?? 0) + 1);
|
|
1649
|
+
}
|
|
1383
1650
|
const hub = (key) => (uses.get(key) ?? 0) > Math.max(16, rows.length / 8);
|
|
1384
1651
|
const reach = new Set(seeds.flatMap(l => Object.keys(l).filter(key => key !== '1')));
|
|
1385
1652
|
for (let hop = 0; hop < 2; hop++) {
|
|
@@ -1649,8 +1916,19 @@ export function modelInstances(m, laws, inst, goal, w, most = 64, sorted = false
|
|
|
1649
1916
|
return;
|
|
1650
1917
|
const until = evals + Math.max(256, Math.floor((20_000 - evals) / Math.max(1, left--)));
|
|
1651
1918
|
const have = new Set(), had = out[id] ?? [], n = names.length, sorts = sortsOf(body, names, atoms);
|
|
1919
|
+
const keyNames = new Set();
|
|
1920
|
+
eachRead(e => {
|
|
1921
|
+
if (fns.includes(e.map))
|
|
1922
|
+
return;
|
|
1923
|
+
const text = JSON.stringify(e.key);
|
|
1924
|
+
for (const name of names)
|
|
1925
|
+
if (text.includes(`"name":${JSON.stringify(name)}`))
|
|
1926
|
+
keyNames.add(name);
|
|
1927
|
+
}).inC(body);
|
|
1928
|
+
// Arithmetic-only naturals range over comparison boundaries, not map keys.
|
|
1929
|
+
// The model chooses constants; assumed/check still validate ordinary law instances.
|
|
1652
1930
|
// (a law at one key assumed at a term of every value its sort takes already: nothing to add)
|
|
1653
|
-
if (n === 1) {
|
|
1931
|
+
if (n === 1 && keyNames.has(names[0])) {
|
|
1654
1932
|
const covered = new Set(had.map(valueOf));
|
|
1655
1933
|
if ([...sorts[0].keys()].every(v2 => covered.has(v2)))
|
|
1656
1934
|
return;
|
|
@@ -1691,7 +1969,37 @@ export function modelInstances(m, laws, inst, goal, w, most = 64, sorted = false
|
|
|
1691
1969
|
added++;
|
|
1692
1970
|
return;
|
|
1693
1971
|
}
|
|
1694
|
-
|
|
1972
|
+
const domain = [...sorts[i]], seen = new Set(domain.map(([, e]) => JSON.stringify(e)));
|
|
1973
|
+
const add = (value, term) => {
|
|
1974
|
+
const key = JSON.stringify(term);
|
|
1975
|
+
if (!seen.has(key)) {
|
|
1976
|
+
seen.add(key);
|
|
1977
|
+
domain.push([value, term]);
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
if (!keyNames.has(names[i])) {
|
|
1981
|
+
const free = new Set(names.slice(i));
|
|
1982
|
+
const extra = modelValueTerms(body, names[i], free, e => {
|
|
1983
|
+
try {
|
|
1984
|
+
return evalE(e, read(at), st, mm);
|
|
1985
|
+
}
|
|
1986
|
+
catch {
|
|
1987
|
+
return undefined;
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
// Keep symbolic instances: their current value is not their identity.
|
|
1991
|
+
// Stable arithmetic witnesses must coexist with equal-valued row terms,
|
|
1992
|
+
// not replace them. Existing tuple/evaluation budgets still bound both.
|
|
1993
|
+
if (extra.length)
|
|
1994
|
+
for (const [v2] of sorts[i])
|
|
1995
|
+
add(v2, { op: 'const', value: v2 });
|
|
1996
|
+
for (const e of extra) {
|
|
1997
|
+
const v2 = valueOf(e);
|
|
1998
|
+
if (v2 !== undefined)
|
|
1999
|
+
add(v2, e);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
for (const [v2, e] of domain)
|
|
1695
2003
|
go(i + 1, { ...at, [names[i]]: v2 }, [...terms, e]);
|
|
1696
2004
|
};
|
|
1697
2005
|
go(0, {}, []);
|
|
@@ -1721,8 +2029,8 @@ export function modelInstances(m, laws, inst, goal, w, most = 64, sorted = false
|
|
|
1721
2029
|
export const modelShare = 3;
|
|
1722
2030
|
// (GDP_MODELS_TRACE=1: each model round, its goal and the tuples a model adds, on stderr)
|
|
1723
2031
|
const modelsTrace = !!env.GDP_MODELS_TRACE, modelFloor = Number(env.GDP_MODEL_FLOOR ?? 1_000);
|
|
1724
|
-
const costNow = () => (
|
|
1725
|
-
const within = (ms, f) => (
|
|
2032
|
+
const costNow = () => (searchRate() ? clock() : searchWork() / groundRate);
|
|
2033
|
+
const within = (ms, f) => (searchRate() ? withDeadline(clock() + ms, f) : withSearchWork(searchWork() + groundRate * ms, f));
|
|
1726
2034
|
export function withModels(m, laws, inst, goalOf, ask, modelOf, settled) {
|
|
1727
2035
|
return withPatterns(m, laws, () => modelsLoop(m, laws, inst, goalOf, ask, modelOf, settled));
|
|
1728
2036
|
}
|
|
@@ -2038,7 +2346,7 @@ const arity = (m, laws, n) => {
|
|
|
2038
2346
|
// built so far read a function at, and, where the seed doesn't cover them (no seed, positions that shift, a law about
|
|
2039
2347
|
// several keys), the every-key laws and flags at every key they read a map at (a law about several keys at tuples
|
|
2040
2348
|
// relating `focus`, the goals' own keys).
|
|
2041
|
-
function instancesFor(m, laws, build, opts = {}) {
|
|
2349
|
+
export function instancesFor(m, laws, build, opts = {}) {
|
|
2042
2350
|
const seed = opts.seed && [...new Map(opts.seed.map(e => [JSON.stringify(e), e])).values()];
|
|
2043
2351
|
let inst = opts.start ?? (seed ? { ...Object.fromEntries(laws.filter(l => l.forall).map(l => [l.name, l.keys?.length ? [] : seed])), ...flagInstances(m, seed, opts.focus) } : {});
|
|
2044
2352
|
const reads = opts.reads ?? (!opts.seed || shifts(m) || laws.some(l => l.keys?.length) || pairFlags(m));
|
|
@@ -2297,8 +2605,8 @@ export const decideLawHook = {};
|
|
|
2297
2605
|
export function decideLaw(m, laws, i, rounds = modelRounds) {
|
|
2298
2606
|
if (!decideLawHook.on)
|
|
2299
2607
|
return decideLaw0(m, laws, i, rounds);
|
|
2300
|
-
const t0 =
|
|
2301
|
-
decideLawHook.on(m, laws, i, out,
|
|
2608
|
+
const t0 = traceNow(), out = decideLaw0(m, laws, i, rounds);
|
|
2609
|
+
decideLawHook.on(m, laws, i, out, traceNow() - t0);
|
|
2302
2610
|
return out;
|
|
2303
2611
|
}
|
|
2304
2612
|
// (why decideLaw last answered nothing: `refuted`, the abstraction refuted a goal whose core's proof didn't finish, a
|
|
@@ -2312,7 +2620,7 @@ function decideLaw0(m, laws, i, rounds) {
|
|
|
2312
2620
|
return withPatterns(m, laws, () => {
|
|
2313
2621
|
if (!eprScope.patterns)
|
|
2314
2622
|
return undefined;
|
|
2315
|
-
const out = settled(m, laws, i, rounds, false);
|
|
2623
|
+
const out = settled(m, laws, i, rounds, false, 'decision');
|
|
2316
2624
|
// (a proof's support: the laws its goals' proofs read)
|
|
2317
2625
|
return !out ? undefined : 'proofs' in out ? { proven: true, uses: [...new Set(Object.values(out.proofs).flatMap(p => [...p.uses.keys()]))] } : out.stuck === 'sat' ? { proven: false, goal: out.goal, stuck: 'sat', witness: out.witness, ...(out.diagram ? { diagram: out.diagram } : {}) } : undefined;
|
|
2318
2626
|
});
|
|
@@ -2320,21 +2628,59 @@ function decideLaw0(m, laws, i, rounds) {
|
|
|
2320
2628
|
// (GDP_MEMO_CAP: how many machines' decisions are kept, 4 by default; the hits and misses counted for the engine's trace)
|
|
2321
2629
|
const memoCap = Number(env.GDP_MEMO_CAP ?? 4);
|
|
2322
2630
|
export const memoHits = { n: 0, miss: 0, setKey: '', setJson: '' };
|
|
2631
|
+
export const memoReuseStats = { hitChecks: 0, hitCheckFailures: 0, coldRetries: 0, proofRetries: 0, modelRetries: 0, seedRetries: 0, modelHits: 0, modelsIgnored: 0, discardedSeeds: 0, wholeRetries: 0, decisionHits: 0, lawHits: 0, setHits: 0 };
|
|
2323
2632
|
export const machineKey = (m) => { const s = JSON.stringify(m); let h = 0; for (let i = 0; i < s.length; i++)
|
|
2324
2633
|
h = (h * 31 + s.charCodeAt(i)) | 0; return `${s.length}:${h}`; };
|
|
2325
2634
|
const memos = new Map(), machineText = new WeakMap(), lawText = new WeakMap();
|
|
2635
|
+
// Alpha hits are untrusted hints: non-exact proofs are checked locally; non-exact models go cold.
|
|
2326
2636
|
// (texts up to a renaming of fresh names, x$12: a rule's machine and kinds' laws are made again with
|
|
2327
2637
|
// fresh binders, so the same machine had another text each time and no decision was found again; GDP_MEMO_ALPHA=0 off)
|
|
2328
2638
|
const alpha = env.GDP_MEMO_ALPHA !== '0';
|
|
2329
2639
|
const alphaText = (s) => { if (!alpha)
|
|
2330
2640
|
return s; const to = new Map(); return s.replace(/([A-Za-z_?]+)\$(\d+)/g, (w, p) => { let r = to.get(w); if (!r)
|
|
2331
2641
|
to.set(w, (r = `${p}$_${to.size}`)); return r; }); };
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2642
|
+
const textsOfLaw = (l) => { let t = lawText.get(l); if (!t) {
|
|
2643
|
+
const exact = JSON.stringify([l.holds, l.forall ?? null, l.keys ?? null]);
|
|
2644
|
+
lawText.set(l, (t = { exact, text: alphaText(exact) }));
|
|
2645
|
+
} return t; };
|
|
2646
|
+
const textOfLaw = (l) => textsOfLaw(l).text;
|
|
2647
|
+
const textsOfMachine = (m) => { let t = machineText.get(m); if (!t) {
|
|
2648
|
+
const exact = JSON.stringify(m);
|
|
2649
|
+
machineText.set(m, (t = { exact, text: alphaText(exact) }));
|
|
2650
|
+
} return t; };
|
|
2651
|
+
// Exact query context belongs to each entry, not to a shared alpha-keyed machine slot.
|
|
2652
|
+
const memoContext = (m, laws) => ({ machine: textsOfMachine(m).exact, laws: new Map(laws.map(l => [l.name, textsOfLaw(l).exact])) });
|
|
2653
|
+
const memoAttempt = () => ({ cold: new Set(), reused: new Set(), fresh: new Map() });
|
|
2654
|
+
function exactMemoContext(context, m, laws) {
|
|
2655
|
+
return context.machine === textsOfMachine(m).exact && laws.every(l => context.laws.get(l.name) === textsOfLaw(l).exact);
|
|
2656
|
+
}
|
|
2657
|
+
function discardMemo(memo, name, attempt, reason = 'proof') {
|
|
2658
|
+
memo.proven.delete(name);
|
|
2659
|
+
memo.models.delete(name);
|
|
2660
|
+
if (!attempt.cold.has(name)) {
|
|
2661
|
+
attempt.cold.add(name);
|
|
2662
|
+
memoReuseStats.coldRetries++;
|
|
2663
|
+
memoReuseStats[`${reason}Retries`]++;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
function checkMemoLaw(m, laws, i, cached) {
|
|
2667
|
+
const proofs = {}, byName = new Map(laws.map(l => [l.name, l]));
|
|
2668
|
+
// Widen usually makes fresh leaves, but its grow fallback may return a cached tree.
|
|
2669
|
+
// New tree objects drop every goal-local WeakMap annotation before source extraction.
|
|
2670
|
+
const currentTree = (t) => 'leaf' in t ? { ...t } : { ...t, yes: currentTree(t.yes), no: currentTree(t.no) };
|
|
2671
|
+
for (const g of obligations(m, laws, { [laws[i].name]: cached.inst }, i)) {
|
|
2672
|
+
const p = cached.proofs[g.name], widened = p && widen(p.part, g, p.tree);
|
|
2673
|
+
const tree = widened && currentTree(widened);
|
|
2674
|
+
if (!tree || !check(g, tree))
|
|
2675
|
+
return undefined;
|
|
2676
|
+
// Read current row sources, never the cached support/tuple metadata.
|
|
2677
|
+
const src = sourcesOf(m, laws, cached.inst, g, usedHyps(g, tree));
|
|
2678
|
+
proofs[g.name] = { part: g, tree, uses: new Map((src ? [...src.keys()] : laws.map(l => l.name)).map(n => [n, textOfLaw(byName.get(n))])), ...(src ? { tuples: src } : {}) };
|
|
2679
|
+
}
|
|
2680
|
+
return { text: textOfLaw(laws[i]), context: memoContext(m, laws), inst: cached.inst, proofs };
|
|
2681
|
+
}
|
|
2334
2682
|
function memoOf(m) {
|
|
2335
|
-
|
|
2336
|
-
if (key === undefined)
|
|
2337
|
-
machineText.set(m, (key = alphaText(JSON.stringify(m))));
|
|
2683
|
+
const key = textsOfMachine(m).text;
|
|
2338
2684
|
let memo = memos.get(key);
|
|
2339
2685
|
if (!memo) {
|
|
2340
2686
|
if (memos.size >= memoCap)
|
|
@@ -2346,24 +2692,56 @@ function memoOf(m) {
|
|
|
2346
2692
|
const stands = (p, byName) => [...p.uses].every(([n, t]) => { const l = byName.get(n); return !!l && textOfLaw(l) === t; });
|
|
2347
2693
|
// Law i settled, from what was kept where it still stands (a proof whose support is in the set, a model of a set holding
|
|
2348
2694
|
// this one): else its goals settled again, those whose proofs stand kept.
|
|
2349
|
-
function settled(m, laws, i, rounds, usual) {
|
|
2695
|
+
function settled(m, laws, i, rounds, usual, consumer = 'decision', attempt = memoAttempt()) {
|
|
2350
2696
|
const law = laws[i], memo = memoOf(m), byName = new Map(laws.map(l => [l.name, l])), text = textOfLaw(law);
|
|
2351
|
-
|
|
2697
|
+
if (attempt.fresh.has(law.name))
|
|
2698
|
+
return attempt.fresh.get(law.name);
|
|
2699
|
+
const was = !attempt.cold.has(law.name) ? memo.proven.get(law.name) : undefined;
|
|
2700
|
+
let prev = was?.text === text ? was : undefined;
|
|
2701
|
+
const exact = prev && exactMemoContext(prev.context, m, laws);
|
|
2352
2702
|
if (prev && Object.values(prev.proofs).every(p => stands(p, byName))) {
|
|
2353
|
-
|
|
2354
|
-
|
|
2703
|
+
let valid = exact ? prev : undefined;
|
|
2704
|
+
if (!exact) {
|
|
2705
|
+
memoReuseStats.hitChecks++;
|
|
2706
|
+
valid = checkMemoLaw(m, laws, i, prev);
|
|
2707
|
+
}
|
|
2708
|
+
if (valid) {
|
|
2709
|
+
memoHits.n++;
|
|
2710
|
+
memoReuseStats[`${consumer}Hits`]++;
|
|
2711
|
+
attempt.reused.add(law.name);
|
|
2712
|
+
return valid;
|
|
2713
|
+
}
|
|
2714
|
+
memoReuseStats.hitCheckFailures++;
|
|
2715
|
+
discardMemo(memo, law.name, attempt);
|
|
2716
|
+
prev = undefined;
|
|
2717
|
+
}
|
|
2718
|
+
else if (prev && !exact) {
|
|
2719
|
+
// A partial renamed proof is not a verdict: stale instances/kept goals must not end this attempt.
|
|
2720
|
+
memoReuseStats.discardedSeeds++;
|
|
2721
|
+
discardMemo(memo, law.name, attempt, 'seed');
|
|
2722
|
+
prev = undefined;
|
|
2355
2723
|
}
|
|
2356
2724
|
memoHits.miss++;
|
|
2357
|
-
const mo = rounds === modelRounds ? memo.models.get(law.name) : undefined;
|
|
2358
|
-
if (mo && (!strict(usual) || mo.strict) && mo.text === text && laws.every(l => mo.set.get(l.name) === textOfLaw(l)))
|
|
2359
|
-
|
|
2725
|
+
const mo = !attempt.cold.has(law.name) && rounds === modelRounds ? memo.models.get(law.name) : undefined;
|
|
2726
|
+
if (mo && (!strict(usual) || mo.strict) && mo.text === text && laws.every(l => mo.set.get(l.name) === textOfLaw(l))) {
|
|
2727
|
+
if (exactMemoContext(mo.context, m, laws)) {
|
|
2728
|
+
memoReuseStats.modelHits++;
|
|
2729
|
+
return mo.model;
|
|
2730
|
+
}
|
|
2731
|
+
// A renamed negative is only a hint. Do not let it bypass the one native cold attempt.
|
|
2732
|
+
memoReuseStats.modelsIgnored++;
|
|
2733
|
+
discardMemo(memo, law.name, attempt, 'model');
|
|
2734
|
+
prev = undefined;
|
|
2735
|
+
}
|
|
2360
2736
|
const out = settle(m, laws, i, rounds, usual, prev);
|
|
2361
2737
|
const cap = (x) => { if (x.size >= 4096)
|
|
2362
2738
|
x.clear(); return x; };
|
|
2363
2739
|
if (out && 'proofs' in out)
|
|
2364
2740
|
cap(memo.proven).set(law.name, out);
|
|
2365
2741
|
else if (out?.stuck === 'sat' && rounds === modelRounds)
|
|
2366
|
-
cap(memo.models).set(law.name, { text, model: out, strict: strict(usual), set: new Map(laws.map(l => [l.name, textOfLaw(l)])) });
|
|
2742
|
+
cap(memo.models).set(law.name, { text, context: memoContext(m, laws), model: out, strict: strict(usual), set: new Map(laws.map(l => [l.name, textOfLaw(l)])) });
|
|
2743
|
+
if (attempt.cold.has(law.name))
|
|
2744
|
+
attempt.fresh.set(law.name, out);
|
|
2367
2745
|
return out;
|
|
2368
2746
|
}
|
|
2369
2747
|
// The fast path's machines: no history, sums or "there exists" (their goals are other machines' or need witnesses).
|
|
@@ -2484,7 +2862,7 @@ function settle(m, laws, i, rounds, usual, prev) {
|
|
|
2484
2862
|
break;
|
|
2485
2863
|
}
|
|
2486
2864
|
if (!more)
|
|
2487
|
-
return { text: textOfLaw(law), inst, proofs };
|
|
2865
|
+
return { text: textOfLaw(law), context: memoContext(m, laws), inst, proofs };
|
|
2488
2866
|
inst = more;
|
|
2489
2867
|
}
|
|
2490
2868
|
}
|
|
@@ -2511,39 +2889,51 @@ export function proveSetFast(m, laws) {
|
|
|
2511
2889
|
if (!fastShape(m, laws))
|
|
2512
2890
|
return someLaws(laws) && fastShape(m, laws.map(l => ({ name: l.name, holds: l.holds }))) ? proveSome(m, laws, { whole: proveSetFast }) : proveLaws(m, laws);
|
|
2513
2891
|
return withPatterns(m, laws, () => pointed(laws, () => {
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2516
|
-
const
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
const
|
|
2526
|
-
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
if (!
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2892
|
+
const attempt = memoAttempt();
|
|
2893
|
+
const run = () => {
|
|
2894
|
+
const at = [];
|
|
2895
|
+
for (let i = 0; i < laws.length; i++) {
|
|
2896
|
+
const out = settled(m, laws, i, modelRounds, true, 'set', attempt);
|
|
2897
|
+
if (!('proofs' in out))
|
|
2898
|
+
return { proven: false, nodes: 0, leaves: 0, checked: false, failed: { goal: out.goal, stuck: out.stuck, ...(out.witness ? { witness: out.witness } : {}), ...(out.why ? { why: out.why } : {}), ...(out.diagram ? { diagram: out.diagram } : {}) } };
|
|
2899
|
+
at.push(out);
|
|
2900
|
+
}
|
|
2901
|
+
const instances = {}, trees = {}, byName = new Map(laws.map(l => [l.name, l]));
|
|
2902
|
+
let nodes = 0, leaves = 0;
|
|
2903
|
+
for (const [i, law] of laws.entries()) {
|
|
2904
|
+
// (each law about keys at the tuples the proofs read; all of them where a proof's sources weren't read)
|
|
2905
|
+
const s = at[i], ps = Object.values(s.proofs), all = ps.some(p => !p.tuples);
|
|
2906
|
+
const inst = all ? s.inst : Object.fromEntries(Object.entries(s.inst).map(([n, ks]) => {
|
|
2907
|
+
const l = byName.get(n), k = l ? widthOf(l) : 1;
|
|
2908
|
+
return [n, !l ? ks : ks.filter((_, j) => ps.some(p => p.tuples.get(n)?.has(JSON.stringify(ks.slice(j - (j % k), j - (j % k) + k)))))];
|
|
2909
|
+
}));
|
|
2910
|
+
instances[law.name] = inst;
|
|
2911
|
+
for (const g of obligations(m, laws, { [law.name]: inst }, i)) {
|
|
2912
|
+
const p = s.proofs[g.name];
|
|
2913
|
+
let tree = p && widen(p.part, g, p.tree);
|
|
2914
|
+
if (!tree) {
|
|
2915
|
+
const o = grow(g);
|
|
2916
|
+
if (!('tree' in o))
|
|
2917
|
+
return stuckAt(g, o, nodes, leaves);
|
|
2918
|
+
tree = o.tree;
|
|
2919
|
+
nodes += o.nodes;
|
|
2920
|
+
}
|
|
2921
|
+
trees[g.name] = tree;
|
|
2922
|
+
leaves += countLeaves(tree);
|
|
2540
2923
|
}
|
|
2541
|
-
trees[g.name] = tree;
|
|
2542
|
-
leaves += countLeaves(tree);
|
|
2543
2924
|
}
|
|
2925
|
+
const proof = { instances, trees };
|
|
2926
|
+
return { proven: true, nodes, leaves, checked: checkLaws(m, laws, proof), proof };
|
|
2927
|
+
};
|
|
2928
|
+
const out = run(), retry = [...attempt.reused].filter(name => !attempt.cold.has(name));
|
|
2929
|
+
if ((!out.proven || !out.checked) && retry.length) {
|
|
2930
|
+
memoReuseStats.wholeRetries++;
|
|
2931
|
+
const memo = memoOf(m);
|
|
2932
|
+
for (const name of retry)
|
|
2933
|
+
discardMemo(memo, name, attempt);
|
|
2934
|
+
return run();
|
|
2544
2935
|
}
|
|
2545
|
-
|
|
2546
|
-
return { proven: true, nodes, leaves, checked: checkLaws(m, laws, proof), proof };
|
|
2936
|
+
return out;
|
|
2547
2937
|
}));
|
|
2548
2938
|
}
|
|
2549
2939
|
export function proveLaw(m, laws, i) {
|
|
@@ -2556,7 +2946,7 @@ export function proveLaw(m, laws, i) {
|
|
|
2556
2946
|
// proof, which widens and checks; wo's "a leader has the voting quorum's votes" from its 40-law set, 0.45 s there
|
|
2557
2947
|
// against 25 s to unknown here)
|
|
2558
2948
|
return withPatterns(m, laws, () => {
|
|
2559
|
-
const out = eprScope.patterns && fastShape(m, laws) ? settled(m, laws, i, modelRounds, false) : undefined;
|
|
2949
|
+
const out = eprScope.patterns && fastShape(m, laws) ? settled(m, laws, i, modelRounds, false, 'law') : undefined;
|
|
2560
2950
|
if (out && 'proofs' in out)
|
|
2561
2951
|
return { proven: true };
|
|
2562
2952
|
if (out?.stuck === 'sat')
|
|
@@ -2583,7 +2973,7 @@ function proveOne(m, laws, i) {
|
|
|
2583
2973
|
const memo = memoOf(m);
|
|
2584
2974
|
if (memo.proven.size >= 4096)
|
|
2585
2975
|
memo.proven.clear();
|
|
2586
|
-
memo.proven.set(law.name, { text: textOfLaw(law), inst: at, proofs });
|
|
2976
|
+
memo.proven.set(law.name, { text: textOfLaw(law), context: memoContext(m, laws), inst: at, proofs });
|
|
2587
2977
|
};
|
|
2588
2978
|
const few = triggered(pm, laws, inst, i2 => obligations(m, laws, { [law.name]: i2 }, i), law.forall ? [`${law.forall}#`] : []);
|
|
2589
2979
|
if (!sameInstances(few, inst)) {
|
|
@@ -2650,7 +3040,8 @@ export const withStrict = (f) => { const o = strictOn; strictOn = true; try {
|
|
|
2650
3040
|
finally {
|
|
2651
3041
|
strictOn = o;
|
|
2652
3042
|
} };
|
|
2653
|
-
//
|
|
3043
|
+
// By immutable machine and ordered, exact law context, including all binding metadata.
|
|
3044
|
+
export const sortMemoStats = { hits: 0, misses: 0 };
|
|
2654
3045
|
const sortsMemo = new WeakMap();
|
|
2655
3046
|
const sortPlacesOn = env.GDP_SORT_PLACES !== '0';
|
|
2656
3047
|
function sortsOf(m, laws) {
|
|
@@ -2791,13 +3182,16 @@ function instanceSortGuard(m, laws) {
|
|
|
2791
3182
|
let byLaws = sortsMemo.get(m);
|
|
2792
3183
|
if (!byLaws)
|
|
2793
3184
|
sortsMemo.set(m, (byLaws = new Map()));
|
|
2794
|
-
const lk = laws.map(l => l.name).
|
|
3185
|
+
const lk = JSON.stringify(laws.map(l => [l.name, textsOfLaw(l).exact]));
|
|
2795
3186
|
let s = byLaws.get(lk);
|
|
2796
3187
|
if (!s) {
|
|
3188
|
+
sortMemoStats.misses++;
|
|
2797
3189
|
if (byLaws.size >= 64)
|
|
2798
3190
|
byLaws.clear();
|
|
2799
3191
|
byLaws.set(lk, (s = sortsOf(m, laws)));
|
|
2800
3192
|
}
|
|
3193
|
+
else
|
|
3194
|
+
sortMemoStats.hits++;
|
|
2801
3195
|
const S = s;
|
|
2802
3196
|
const keysOf = (n) => {
|
|
2803
3197
|
if (n.startsWith('?')) {
|
|
@@ -2884,12 +3278,12 @@ function proveLawsAsGiven(m, laws, defer) {
|
|
|
2884
3278
|
const modes = cyclicOn() || certOn(), hist = modes && m.history ? historyMachine(m) : undefined, mc = hist ? hist.machine : m;
|
|
2885
3279
|
const why = modes ? (sumsWhy(m) ?? uncoveredWhy(mc, laws)) : undefined, cert = certOn() && !why;
|
|
2886
3280
|
usualCheck.on = !cert && !defer;
|
|
2887
|
-
const t0 =
|
|
3281
|
+
const t0 = traceNow(), out = fast ?? (() => { try {
|
|
2888
3282
|
return proveThinned(m, laws, { ...instances });
|
|
2889
3283
|
}
|
|
2890
3284
|
finally {
|
|
2891
3285
|
usualCheck.on = true;
|
|
2892
|
-
} })(), usualMs =
|
|
3286
|
+
} })(), usualMs = traceNow() - t0;
|
|
2893
3287
|
if (out.proof)
|
|
2894
3288
|
usualProof.last = { m, laws, proof: out.proof };
|
|
2895
3289
|
const inst = out.proof?.instances ?? instances;
|
|
@@ -3040,7 +3434,7 @@ export function stepLawInstances(m, laws) {
|
|
|
3040
3434
|
function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
3041
3435
|
if (!base.proof)
|
|
3042
3436
|
return { proven: false, nodes: base.nodes, leaves: base.leaves, checked: false };
|
|
3043
|
-
const t0 =
|
|
3437
|
+
const t0 = traceNow();
|
|
3044
3438
|
const plain = plainOf(m);
|
|
3045
3439
|
// Each step law its own instances, from its own goal: the keys the step and the laws read, and its own (a k-step
|
|
3046
3440
|
// law's later frames read keys no other step law has); where positions shift or a law is about several keys, the
|
|
@@ -3057,7 +3451,7 @@ function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
|
3057
3451
|
const ownMs = {};
|
|
3058
3452
|
for (const sl of stepLaws)
|
|
3059
3453
|
for (const goal of stepLawObligations(m, laws, perStep[sl.name] ?? instances, sl)) {
|
|
3060
|
-
const g0 =
|
|
3454
|
+
const g0 = traceNow();
|
|
3061
3455
|
const full = perStep[sl.name] ?? instances, few = triggered(plain, laws, full, inst => stepLawObligations(m, laws, inst, sl), [sl.forall, ...(sl.keys ?? [])].flatMap(k => (k ? [k] : [])));
|
|
3062
3456
|
let out = sameInstances(few, full) ? grow(goal) : grow(stepLawObligations(m, laws, few, sl).find(g => g.name === goal.name) ?? goal);
|
|
3063
3457
|
if ('tree' in out && !sameInstances(few, full))
|
|
@@ -3091,12 +3485,12 @@ function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
|
3091
3485
|
trees[goal.name] = out.tree;
|
|
3092
3486
|
nodes += out.nodes;
|
|
3093
3487
|
leaves += countLeaves(out.tree);
|
|
3094
|
-
ownMs[sl.name] = (ownMs[sl.name] ?? 0) +
|
|
3488
|
+
ownMs[sl.name] = (ownMs[sl.name] ?? 0) + traceNow() - g0;
|
|
3095
3489
|
}
|
|
3096
3490
|
// (every step law proven: the laws' certificate, or their check, as proveLaws makes it; its time not the step laws')
|
|
3097
|
-
const r0 =
|
|
3491
|
+
const r0 = traceNow();
|
|
3098
3492
|
ready();
|
|
3099
|
-
const usual0 = t0 +
|
|
3493
|
+
const usual0 = t0 + traceNow() - r0;
|
|
3100
3494
|
const proof = { laws: base.proof, instances, ...(Object.keys(perStep).length ? { perStep } : {}), trees };
|
|
3101
3495
|
// Step laws of a machine the cyclic instances cover (one step, or several over no map) are translated with the laws
|
|
3102
3496
|
// (core/cyclic.ts); the rest are counted as no instance's.
|
|
@@ -3116,7 +3510,7 @@ function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
|
3116
3510
|
if (!why && one.length && out.checked) {
|
|
3117
3511
|
const all = one.map(sl => { const inst = perStep[sl.name] ?? instances, goal = stepLawObligations(m, laws, inst, sl)[0]; return { sl, inst, goal, tree: trees[goal.name] }; });
|
|
3118
3512
|
const translatedOf = (steps) => (st) => translatedProof(() => JSON.stringify(['steps', plain, laws, base.proof.instances, steps.map(x => [x.sl, x.inst])]), reused => timedKind('instance', 0, () => machineNodes(plain, laws, base.proof.instances, { trees: base.proof.trees, steps, lawsMade: reused }, st)), st, () => JSON.stringify(['machine', plain, laws, base.proof.instances]));
|
|
3119
|
-
const usualMs =
|
|
3513
|
+
const usualMs = traceNow() - usual0;
|
|
3120
3514
|
if (cyclicOn())
|
|
3121
3515
|
crossCyclic('step law', m.name, true, undefined, usualMs, translatedOf(all));
|
|
3122
3516
|
// (where the step laws' proof together isn't made, each step law's alone: one the translation misses leaves the
|
|
@@ -3147,7 +3541,7 @@ function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
|
3147
3541
|
const b = machineNodes(plain, laws, base.proof.instances);
|
|
3148
3542
|
return proveCyclic(b.facts, [...b.specs, ...searchedStepNodes(plain, laws, rest.map(sl => ({ law: sl, instances: perStep[sl.name] ?? instances })), b.facts, b.specs)]);
|
|
3149
3543
|
};
|
|
3150
|
-
const c = certCyclic('step law', m.name, undefined, searchedSteps,
|
|
3544
|
+
const c = certCyclic('step law', m.name, undefined, searchedSteps, traceNow() - usual0);
|
|
3151
3545
|
for (const sl of c.checked ? [] : rest)
|
|
3152
3546
|
miss(sl, `${restWhy(sl)}: ${c.why}`);
|
|
3153
3547
|
}
|
|
@@ -3159,7 +3553,7 @@ function proveStepLawsAsGiven(m, laws, stepLaws, base, ready = () => { }) {
|
|
|
3159
3553
|
// Progress (kernel.ts's progressObligations): the laws proven first, then each goal, the every-key laws assumed at every
|
|
3160
3554
|
// key the goals read a map at.
|
|
3161
3555
|
export function proveProgress(m, laws, p) {
|
|
3162
|
-
const t0 =
|
|
3556
|
+
const t0 = traceNow(), base = proveLaws(m, laws);
|
|
3163
3557
|
if (!base.proven || !base.checked)
|
|
3164
3558
|
return { proven: false, nodes: base.nodes, leaves: base.leaves, ...(base.failed ? { failed: base.failed } : {}), checked: false };
|
|
3165
3559
|
const ls = base.laws ?? laws;
|
|
@@ -3202,7 +3596,7 @@ export function proveProgress(m, laws, p) {
|
|
|
3202
3596
|
});
|
|
3203
3597
|
return found?.out ?? last;
|
|
3204
3598
|
};
|
|
3205
|
-
const c = certCyclic('progress', m.name, translated, certSearch() ? allowed : undefined,
|
|
3599
|
+
const c = certCyclic('progress', m.name, translated, certSearch() ? allowed : undefined, traceNow() - t0);
|
|
3206
3600
|
if (!c.checked) {
|
|
3207
3601
|
const why = `a request allowed: ${c.why}`;
|
|
3208
3602
|
uncovered('progress', m.name, why);
|