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
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// Compose fixed-operation proposals onto one unrestricted counted STEP goal.
|
|
2
|
+
// Every leaf is reindexed; the complete certificate is checked at the end.
|
|
3
|
+
import { all, n, same, x } from "./machine.js";
|
|
4
|
+
import { deferFinalCountStep } from "./count-final-step.js";
|
|
5
|
+
import { traceNow } from "./trace-clock.js";
|
|
6
|
+
import { transportCountLemmas } from "./count-lemma-transport.js";
|
|
7
|
+
import { recordCountStrategyPremises } from "./count-strategy-premises.js";
|
|
8
|
+
import { finishCountStrategy } from "./count-strategy.js";
|
|
9
|
+
import { finiteCountChoice } from "./count-cases.js";
|
|
10
|
+
import { countCertificateRenamer } from "./count-cert-rename.js";
|
|
11
|
+
import { countStageTrace } from "./count-stage-trace.js";
|
|
12
|
+
import { dedupeCountInstances, minimizeCountCertificate } from "./count-certificate-minimize.js";
|
|
13
|
+
import { countRowReindexer, operationRefutation } from "./count-row-reindex.js";
|
|
14
|
+
import { boundOf, substC, canon, canonFlip, checkMC, countedObligations, framePath, mcGoal } from "../kernel/kernel.js";
|
|
15
|
+
import { fullRate, fullWork, late, rowsAt, withDeadline } from "../kernel/prove.js";
|
|
16
|
+
import { BudgetExpired } from "./work-admission.js";
|
|
17
|
+
import { proverRowsReusingFacts } from "../kernel/prover-rows.js";
|
|
18
|
+
import { add, k } from "./solver.js";
|
|
19
|
+
export function composeCountOperationProofs(context, family, law, cases, until, requestFor, observe, options = {}) {
|
|
20
|
+
return withDeadline(until, () => {
|
|
21
|
+
const trace = countStageTrace(options.trace, 'composition-total');
|
|
22
|
+
try {
|
|
23
|
+
trace.mark('composition-setup', 'untrusted-assembly');
|
|
24
|
+
const timed = (stage, run) => {
|
|
25
|
+
if (!options.trace)
|
|
26
|
+
return run();
|
|
27
|
+
const work = fullWork(), wall = traceNow(), value = run();
|
|
28
|
+
options.trace({ stage, wallMs: traceNow() - wall, units: (fullWork() - work) / fullRate, ...(typeof value === 'boolean' ? { checked: value } : {}) });
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const m = context.machine, choice = finiteCountChoice(m), target = family.indexOf(law);
|
|
32
|
+
if (!choice || target < 0 || late(until))
|
|
33
|
+
return;
|
|
34
|
+
const [operation, values] = choice, ordered = [...values].sort((a, b) => a - b);
|
|
35
|
+
if (cases.length !== ordered.length || ordered.some(value => cases.filter(c => c.value === value).length !== 1))
|
|
36
|
+
return;
|
|
37
|
+
trace.mark('certificate-prefix', 'untrusted-assembly');
|
|
38
|
+
let prefix = 'countCase$';
|
|
39
|
+
const scope = JSON.stringify([m, family, cases]);
|
|
40
|
+
while (scope.includes('"' + prefix))
|
|
41
|
+
prefix = '$' + prefix;
|
|
42
|
+
trace.mark('merge-setup', 'untrusted-assembly');
|
|
43
|
+
const common = { reads: [], insts: [], picks: [], frames: [], monos: [], lins: [], ...(options.slicedLemmas ? { lemmas: [] } : {}), tree: { leaf: [] } };
|
|
44
|
+
const readNames = new Map(), instanceNames = new Map(), tuples = new Map();
|
|
45
|
+
let instances = {};
|
|
46
|
+
const sources = [];
|
|
47
|
+
let transferring;
|
|
48
|
+
const arity = (name) => {
|
|
49
|
+
const found = [...family, ...(m.facts ?? [])].find(l => l.name === name);
|
|
50
|
+
if (found)
|
|
51
|
+
return found.forall ? 1 + (found.keys?.length ?? 0) : 0;
|
|
52
|
+
const flag = name.startsWith('?') && m.step.flags?.[name.slice(1)];
|
|
53
|
+
return flag && flag.op === 'all' ? boundOf(flag).length : undefined;
|
|
54
|
+
};
|
|
55
|
+
for (const value of ordered) {
|
|
56
|
+
trace.mark('merge-case', 'untrusted-assembly', value);
|
|
57
|
+
if (late(until))
|
|
58
|
+
return;
|
|
59
|
+
const source = cases.find(c => c.value === value), raw = source.proof.certs[`${law.name} @step`];
|
|
60
|
+
if (!raw || (!options.slicedLemmas && raw.lemmas?.length) || raw.picks?.length)
|
|
61
|
+
return;
|
|
62
|
+
const renamed = new Map();
|
|
63
|
+
for (const [id, map, key] of raw.reads) {
|
|
64
|
+
const signature = JSON.stringify([map, key]);
|
|
65
|
+
let name = readNames.get(signature);
|
|
66
|
+
if (!name) {
|
|
67
|
+
name = prefix + 'r' + common.reads.length;
|
|
68
|
+
readNames.set(signature, name);
|
|
69
|
+
common.reads.push([name, map, key]);
|
|
70
|
+
}
|
|
71
|
+
renamed.set(id, name);
|
|
72
|
+
}
|
|
73
|
+
for (const inst of raw.insts) {
|
|
74
|
+
const terms = inst.terms.map(([coefficient, id]) => [coefficient, renamed.get(id) ?? id]);
|
|
75
|
+
const signature = JSON.stringify([inst.unit, inst.below, [...terms].sort((a, b) => a[1].localeCompare(b[1]) || a[0] - b[0])]);
|
|
76
|
+
let name = instanceNames.get(signature);
|
|
77
|
+
if (!name) {
|
|
78
|
+
name = prefix + 'w' + common.insts.length;
|
|
79
|
+
instanceNames.set(signature, name);
|
|
80
|
+
common.insts.push({ ...inst, wit: name, terms });
|
|
81
|
+
}
|
|
82
|
+
if (renamed.has(inst.wit) && renamed.get(inst.wit) !== name)
|
|
83
|
+
return;
|
|
84
|
+
renamed.set(inst.wit, name);
|
|
85
|
+
}
|
|
86
|
+
const rename = countCertificateRenamer(renamed, until), cert = rename.certificate(raw);
|
|
87
|
+
if (new Set(cert.reads.map(r => r[0])).size !== cert.reads.length)
|
|
88
|
+
return;
|
|
89
|
+
const local = {};
|
|
90
|
+
for (const [name, terms] of Object.entries(source.proof.instances)) {
|
|
91
|
+
const n = arity(name);
|
|
92
|
+
if (n === undefined || n === 0 && terms.length || n && terms.length % n)
|
|
93
|
+
return;
|
|
94
|
+
const converted = terms.map(rename.expression);
|
|
95
|
+
local[name] = converted;
|
|
96
|
+
const seen = tuples.get(name) ?? new Set();
|
|
97
|
+
tuples.set(name, seen);
|
|
98
|
+
if (n)
|
|
99
|
+
for (let i = 0; i < converted.length; i += n) {
|
|
100
|
+
const tuple = converted.slice(i, i + n), key = JSON.stringify(tuple);
|
|
101
|
+
if (!seen.has(key)) {
|
|
102
|
+
seen.add(key);
|
|
103
|
+
(instances[name] ??= []).push(...tuple);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const key of ['frames', 'monos', 'lins']) {
|
|
108
|
+
const known = new Set(common[key].map(c => JSON.stringify(c)));
|
|
109
|
+
for (const cut of cert[key] ?? [])
|
|
110
|
+
if (!known.has(JSON.stringify(cut))) {
|
|
111
|
+
known.add(JSON.stringify(cut));
|
|
112
|
+
common[key].push(cut);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
sources.push({ value, cert, instances: local });
|
|
116
|
+
}
|
|
117
|
+
if (options.minimize) {
|
|
118
|
+
const compact = dedupeCountInstances(family, m.facts ?? [], instances);
|
|
119
|
+
instances = compact.instances;
|
|
120
|
+
options.trace?.({ stage: 'minimize-instances', removed: compact.removed.length });
|
|
121
|
+
}
|
|
122
|
+
trace.mark('target-obligation-build', 'untrusted-assembly');
|
|
123
|
+
const packet = countedObligations(m, family, { [law.name]: instances }, target).at(-1), goal = mcGoal(packet.goal.hyps, packet.decls, common);
|
|
124
|
+
if (!goal)
|
|
125
|
+
return;
|
|
126
|
+
trace.mark('reindex-setup', 'untrusted-assembly');
|
|
127
|
+
let sourceGoals;
|
|
128
|
+
if (options.slicedLemmas) {
|
|
129
|
+
sourceGoals = new Map();
|
|
130
|
+
const flagSubs = Object.create(null);
|
|
131
|
+
for (const [name, c] of Object.entries(m.step.flags ?? {}))
|
|
132
|
+
flagSubs[name] = c.op === 'all' ? same(x('?' + name), n(1)) : substC(c, { vars: {}, maps: {}, flags: flagSubs });
|
|
133
|
+
const normalized = (c) => substC(c, { vars: {}, maps: {}, flags: flagSubs });
|
|
134
|
+
for (const source of sources) {
|
|
135
|
+
if (!source.cert.lemmas?.length)
|
|
136
|
+
continue;
|
|
137
|
+
const fixed = { ...m, assume: all(...(m.assume ? [m.assume] : []), same(x(operation), n(source.value))) }, packet = countedObligations(fixed, family, { [law.name]: source.instances }, target).at(-1), from = mcGoal(packet.goal.hyps, packet.decls, source.cert);
|
|
138
|
+
if (!from)
|
|
139
|
+
return;
|
|
140
|
+
sourceGoals.set(source.value, from);
|
|
141
|
+
const lemmas = transportCountLemmas(from, goal, source.cert.lemmas, { assumed: normalized(fixed.assume), retained: m.assume ? normalized(m.assume) : undefined, when: [add({ [operation]: 1 }, k(-source.value)), add({ [operation]: -1 }, k(source.value))] }, until);
|
|
142
|
+
if (!lemmas) {
|
|
143
|
+
observe?.('lemma-transport-declined', source.value);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
common.lemmas.push(...lemmas);
|
|
147
|
+
observe?.('lemma-transport:' + lemmas.length, source.value);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const stats = { hits: 0, layouts: 0 }, offsets = options.reindexMode !== 'exact';
|
|
151
|
+
const reindex = countRowReindexer(goal, { offsets, stats });
|
|
152
|
+
const materializeRows = options.reindexFactsOnly ? proverRowsReusingFacts : rowsAt;
|
|
153
|
+
const fallback = (path) => late(until) ? undefined :
|
|
154
|
+
operationRefutation(materializeRows(goal, framePath(common.frames, common.lemmas ?? [], path, common.monos, common.lins)), operation);
|
|
155
|
+
const transport = (sourceGoal, source, tree, before, after) => {
|
|
156
|
+
if (late(until))
|
|
157
|
+
return;
|
|
158
|
+
if ('split' in tree) {
|
|
159
|
+
const id = canon(tree.split), known = Object.keys(tree.split).every(k => k === '1') ? (tree.split['1'] ?? 0) <= 0 : after.get(id)?.holds ?? (after.has(canonFlip(tree.split)) ? !after.get(canonFlip(tree.split)).holds : undefined);
|
|
160
|
+
const add = (p, holds) => new Map(p).set(id, { lin: tree.split, holds });
|
|
161
|
+
if (known !== undefined)
|
|
162
|
+
return transport(sourceGoal, source, known ? tree.yes : tree.no, add(before, known), after);
|
|
163
|
+
const yes = transport(sourceGoal, source, tree.yes, add(before, true), add(after, true)), no = yes && transport(sourceGoal, source, tree.no, add(before, false), add(after, false));
|
|
164
|
+
return yes && no ? { split: tree.split, yes, no } : undefined;
|
|
165
|
+
}
|
|
166
|
+
const old = materializeRows(sourceGoal, framePath(source.frames ?? [], source.lemmas ?? [], before, source.monos ?? [], source.lins ?? [])), current = materializeRows(goal, framePath(common.frames, common.lemmas ?? [], after, common.monos, common.lins)), index = reindex(sourceGoal, old, current);
|
|
167
|
+
const leaf = [];
|
|
168
|
+
for (const step of tree.leaf) {
|
|
169
|
+
if (step.kind !== 'input')
|
|
170
|
+
leaf.push(step);
|
|
171
|
+
else {
|
|
172
|
+
const i = index(step.index);
|
|
173
|
+
if (i === undefined) {
|
|
174
|
+
const impossible = fallback(after);
|
|
175
|
+
if (impossible) {
|
|
176
|
+
observe?.('impossible-path', transferring);
|
|
177
|
+
return impossible;
|
|
178
|
+
}
|
|
179
|
+
observe?.('missing-row:' + (old[step.index] ? canon(old[step.index].lin) : step.index), transferring);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
;
|
|
183
|
+
leaf.push({ ...step, index: i });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const products = [];
|
|
187
|
+
for (const [a, b] of tree.products ?? []) {
|
|
188
|
+
const i = index(a), j = index(b);
|
|
189
|
+
if (i === undefined || j === undefined)
|
|
190
|
+
return;
|
|
191
|
+
products.push([i, j]);
|
|
192
|
+
}
|
|
193
|
+
return { leaf, ...(tree.products ? { products } : {}), ...(tree.squares ? { squares: tree.squares } : {}) };
|
|
194
|
+
};
|
|
195
|
+
const branch = (i, path) => {
|
|
196
|
+
if (late(until))
|
|
197
|
+
return;
|
|
198
|
+
if (i === ordered.length)
|
|
199
|
+
return fallback(path);
|
|
200
|
+
const value = ordered[i], source = sources.find(c => c.value === value), upper = add({ [operation]: 1 }, k(-value)), lower = add({ [operation]: -1 }, k(value));
|
|
201
|
+
const yesUpper = new Map(path).set(canon(upper), { lin: upper, holds: true }), exact = new Map(yesUpper).set(canon(lower), { lin: lower, holds: true });
|
|
202
|
+
trace.mark('source-obligation-build', 'untrusted-assembly', value);
|
|
203
|
+
const fixed = { ...m, assume: all(...(m.assume ? [m.assume] : []), same(x(operation), n(value))) }, original = countedObligations(fixed, family, { [law.name]: source.instances }, target).at(-1), from = sourceGoals?.get(value) ?? mcGoal(original.goal.hyps, original.decls, source.cert);
|
|
204
|
+
if (!from)
|
|
205
|
+
return;
|
|
206
|
+
trace.mark('reindex-case', 'untrusted-assembly', value);
|
|
207
|
+
transferring = value;
|
|
208
|
+
observe?.('reindex', value);
|
|
209
|
+
const yes = transport(from, source.cert, source.cert.tree, new Map(), exact), tooLow = yes && fallback(new Map(yesUpper).set(canon(lower), { lin: lower, holds: false })), no = tooLow && branch(i + 1, new Map(path).set(canon(upper), { lin: upper, holds: false }));
|
|
210
|
+
return yes && tooLow && no ? { split: upper, yes: { split: lower, yes, no: tooLow }, no } : undefined;
|
|
211
|
+
};
|
|
212
|
+
const tree = timed('compose-reindex', () => branch(0, new Map()));
|
|
213
|
+
if (!tree) {
|
|
214
|
+
if (!offsets || late(until))
|
|
215
|
+
return;
|
|
216
|
+
trace.pause();
|
|
217
|
+
observe?.('offset-retry-exact');
|
|
218
|
+
return composeCountOperationProofs(context, family, law, cases, until, requestFor, observe, { ...options, reindexMode: 'exact' });
|
|
219
|
+
}
|
|
220
|
+
trace.mark('tree-shape-check', 'untrusted-assembly');
|
|
221
|
+
observe?.('offset-layouts', stats.layouts);
|
|
222
|
+
observe?.('offset-hits', stats.hits);
|
|
223
|
+
observe?.('final-check');
|
|
224
|
+
const shape = (t, path) => {
|
|
225
|
+
if ('leaf' in t)
|
|
226
|
+
return;
|
|
227
|
+
const key = canon(t.split);
|
|
228
|
+
if (path.has(key))
|
|
229
|
+
return 'repeated:' + key;
|
|
230
|
+
if (Object.keys(t.split).every(k => k === '1'))
|
|
231
|
+
return 'constant:' + key;
|
|
232
|
+
const next = new Set(path).add(key);
|
|
233
|
+
return shape(t.yes, next) ?? shape(t.no, next);
|
|
234
|
+
};
|
|
235
|
+
const badShape = shape(tree, new Set());
|
|
236
|
+
if (badShape)
|
|
237
|
+
observe?.('bad-tree-shape:' + badShape);
|
|
238
|
+
const original = { ...common, tree };
|
|
239
|
+
let certificate = original;
|
|
240
|
+
if (options.minimize) {
|
|
241
|
+
trace.mark('certificate-minimize', 'untrusted-assembly');
|
|
242
|
+
const smaller = minimizeCountCertificate(packet.goal.hyps, packet.decls, original, until);
|
|
243
|
+
certificate = smaller.cert;
|
|
244
|
+
options.trace?.({ stage: 'minimize', ...smaller.stats });
|
|
245
|
+
}
|
|
246
|
+
trace.pause();
|
|
247
|
+
const finish = (certificate) => options.initial ? (() => {
|
|
248
|
+
trace.mark('final-obligation-build', 'untrusted-assembly');
|
|
249
|
+
const packets = countedObligations(m, family, { [law.name]: instances }, target);
|
|
250
|
+
if (packets.length !== 2 || late(until))
|
|
251
|
+
return;
|
|
252
|
+
const initial = packets[0], step = packets[1], cert = certificate;
|
|
253
|
+
const deferred = deferFinalCountStep(options.familyProposal);
|
|
254
|
+
if (deferred)
|
|
255
|
+
observe?.('step-proposal');
|
|
256
|
+
else {
|
|
257
|
+
trace.mark('native-step-check', 'trusted-check');
|
|
258
|
+
if (!timed('compose-native-step', () => checkMC(step.goal.hyps, step.decls, cert)))
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
trace.mark('native-init-check', 'trusted-check');
|
|
262
|
+
if (!timed('compose-native-initial', () => checkMC(initial.goal.hyps, initial.decls, options.initial)))
|
|
263
|
+
return;
|
|
264
|
+
trace.mark('certificate-return', 'untrusted-assembly');
|
|
265
|
+
return late(until) ? undefined : { instances, certs: { [step.goal.name]: cert, [initial.goal.name]: options.initial }, ...(deferred ? { status: 'unchecked' } : {}) };
|
|
266
|
+
})() : finishCountStrategy(m, family, law, instances, context.shape.voteMap, certificate, until, requestFor, (stage, checked) => observe?.(stage + ':' + checked), { tailTrace: options.trace, familyProposal: options.familyProposal });
|
|
267
|
+
let result = finish(certificate);
|
|
268
|
+
if (!result && certificate !== original && !late(until)) {
|
|
269
|
+
options.trace?.({ stage: 'minimize-fallback' });
|
|
270
|
+
result = finish(original);
|
|
271
|
+
}
|
|
272
|
+
if (!result && offsets && !late(until)) {
|
|
273
|
+
trace.pause();
|
|
274
|
+
observe?.('offset-retry-exact');
|
|
275
|
+
return composeCountOperationProofs(context, family, law, cases, until, requestFor, observe, { ...options, reindexMode: 'exact' });
|
|
276
|
+
}
|
|
277
|
+
return result && recordCountStrategyPremises(family, result);
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
if (options.propagateBudgetExpiry && error instanceof BudgetExpired)
|
|
281
|
+
throw error;
|
|
282
|
+
observe?.('compose-error:' + (error instanceof Error ? error.message : String(error)));
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
trace.finish();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type CountCert, type CountDecl, type Goal, type Instances } from '../kernel/kernel.js';
|
|
3
|
+
type Packet = {
|
|
4
|
+
goal: Goal;
|
|
5
|
+
decls: CountDecl[];
|
|
6
|
+
};
|
|
7
|
+
export declare function finiteCountChoice(m: Machine): [string, Set<number>] | undefined;
|
|
8
|
+
export { selectCountBounds, type CountBoundCandidate, type CountBoundSelection } from './count-select.js';
|
|
9
|
+
export declare function withoutCountWitnesses(m: Machine, laws: Law[], at: Instances, discard: ReadonlySet<string>): Instances;
|
|
10
|
+
export type CountCaseOptions = {
|
|
11
|
+
deferCheck?: boolean;
|
|
12
|
+
propose?: (goal: Goal, decls: CountDecl[]) => Pick<CountCert, 'reads' | 'insts'>;
|
|
13
|
+
localModels?: boolean;
|
|
14
|
+
saturate?: boolean;
|
|
15
|
+
queryMs?: number;
|
|
16
|
+
coreLimit?: number;
|
|
17
|
+
units?: boolean;
|
|
18
|
+
corePointOnly?: boolean;
|
|
19
|
+
trace?: (event: Record<string, unknown>) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function proveCountCases(m: Machine, laws: Law[], at: Instances, cert: Pick<CountCert, 'reads' | 'insts'>, until: number, build: (at: Instances) => Packet, options?: CountCaseOptions): {
|
|
22
|
+
instances: Instances;
|
|
23
|
+
cert: CountCert;
|
|
24
|
+
} | undefined;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "./wall.js";
|
|
2
|
+
// Untrusted finite-input case search for a fixed counted certificate. A small
|
|
3
|
+
// model/core query chooses ordinary instances; every combined tree is checked
|
|
4
|
+
// against the unspecialized counted obligation before it is returned, unless
|
|
5
|
+
// an enclosing final-certificate check explicitly defers this pre-check.
|
|
6
|
+
import { walkOnce, x } from "./machine.js";
|
|
7
|
+
import { boundOf, canon, check, checkMC, linear, mcGoal, truth } from "../kernel/kernel.js";
|
|
8
|
+
import { atPoint, clock, grow, modelInstances, pastWall, usedHyps, wallAt, widen, withDeadline } from "../kernel/prove.js";
|
|
9
|
+
import { sub } from "./solver.js";
|
|
10
|
+
import { seedCountWitnessFlags } from "./count-witness-flags.js";
|
|
11
|
+
import { modelSequence } from "../kernel/model-sequence.js";
|
|
12
|
+
import { REFUTED } from "../kernel/cdcl.js";
|
|
13
|
+
import { selectCountBounds } from "./count-select.js";
|
|
14
|
+
import { actionGuard } from "./count-recovery/action-guard.js";
|
|
15
|
+
import { guardCases } from "./count-recovery/guard-cases.js";
|
|
16
|
+
import { appendCountCert } from "./count-cert-grow.js";
|
|
17
|
+
import { independentCountInstances } from "./count-focused.js";
|
|
18
|
+
import { fieldCase } from "./count-recovery/field-case.js";
|
|
19
|
+
import { sourceProofMemo } from "./count-recovery/source-memo.js";
|
|
20
|
+
import { collectConditionalCertificate, hasConditionalProof, transportConditionalProof } from "./count-recovery/conditional-proof.js";
|
|
21
|
+
import { activeWriteKey, rowPairs, writesReadState } from "./count-recovery/row-cases.js";
|
|
22
|
+
import { frameLemmas } from "./count-recovery/frame-lemmas.js";
|
|
23
|
+
import { refuteFast, rowsAt } from "./count-recovery/ops.js";
|
|
24
|
+
export function finiteCountChoice(m) {
|
|
25
|
+
const values = new Map();
|
|
26
|
+
walkOnce([m.step, m.assume], (o) => {
|
|
27
|
+
if (o.op !== '=')
|
|
28
|
+
return;
|
|
29
|
+
const [a, b] = o.a.op === 'var' ? [o.a, o.b] : [o.b, o.a];
|
|
30
|
+
if (a.op !== 'var' || b.op !== 'const' || !m.inputs.includes(a.name))
|
|
31
|
+
return;
|
|
32
|
+
const vs = values.get(a.name) ?? new Set();
|
|
33
|
+
vs.add(b.value);
|
|
34
|
+
values.set(a.name, vs);
|
|
35
|
+
});
|
|
36
|
+
return [...values].filter(([, v]) => v.size > 2 && v.size <= 16).sort((a, b) => b[1].size - a[1].size)[0];
|
|
37
|
+
}
|
|
38
|
+
export { selectCountBounds } from "./count-select.js";
|
|
39
|
+
// Remove whole tuples mentioning count witnesses no longer in the packet.
|
|
40
|
+
// This only weakens the available source context; its proof is checked again.
|
|
41
|
+
export function withoutCountWitnesses(m, laws, at, discard) {
|
|
42
|
+
if (!discard.size)
|
|
43
|
+
return at;
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const [name, terms] of Object.entries(at)) {
|
|
46
|
+
const law = laws.find(l => l.name === name), flag = name.startsWith('?') ? m.step.flags?.[name.slice(1)] : undefined;
|
|
47
|
+
const arity = law ? 1 + (law.keys?.length ?? 0) : flag?.op === 'all' ? boundOf(flag).length : 1, kept = [];
|
|
48
|
+
for (let i = 0; i < terms.length; i += arity) {
|
|
49
|
+
const tuple = terms.slice(i, i + arity);
|
|
50
|
+
let unwanted = false;
|
|
51
|
+
walkOnce(tuple, (o) => { if (o.op === 'var' && discard.has(o.name))
|
|
52
|
+
unwanted = true; });
|
|
53
|
+
if (!unwanted)
|
|
54
|
+
kept.push(...tuple);
|
|
55
|
+
}
|
|
56
|
+
out[name] = kept;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function selectedCase(m, laws, at, cert, packet, path, until, build, options) {
|
|
61
|
+
const full = mcGoal(packet.goal.hyps, packet.decls, cert);
|
|
62
|
+
if (!full || !cert.insts.length)
|
|
63
|
+
return undefined;
|
|
64
|
+
const offset = full.hyps.length - cert.insts.length, base = { ...full, hyps: full.hyps.slice(0, offset) }, excluded = new Set();
|
|
65
|
+
const candidates = cert.insts.flatMap((_, index) => { const h = full.hyps[offset + index]; return h?.op === 'or' && h.xs[0]?.op === '<=' ? [{ index, bound: h.xs[0] }] : []; });
|
|
66
|
+
while (clock() < until && !pastWall()) {
|
|
67
|
+
const selected = selectCountBounds(base, candidates.filter(c => !excluded.has(c.index)), until, { path, queryMs: options.queryMs, trace: options.trace });
|
|
68
|
+
if (!selected || selected.fallback)
|
|
69
|
+
return undefined;
|
|
70
|
+
const chosen = new Set(selected.indices), insts = cert.insts.filter((_, i) => chosen.has(i)), slim = { ...cert, insts };
|
|
71
|
+
const discard = new Set(cert.insts.filter((_, i) => !chosen.has(i)).map(c => c.wit)), clean = withoutCountWitnesses(m, laws, at, discard);
|
|
72
|
+
const instances = seedCountWitnessFlags(m, clean, [{ decls: packet.decls, cert: slim }], true), source = build(instances), goal = mcGoal(source.goal.hyps, source.decls, slim);
|
|
73
|
+
if (!goal)
|
|
74
|
+
return undefined;
|
|
75
|
+
let confirmed = new Map(path), failed;
|
|
76
|
+
const cuts = [];
|
|
77
|
+
for (const index of selected.indices) {
|
|
78
|
+
const bound = candidates.find(c => c.index === index).bound;
|
|
79
|
+
if (truth(bound, confirmed) === true)
|
|
80
|
+
continue;
|
|
81
|
+
if (bound.op !== '<=') {
|
|
82
|
+
failed = index;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
const a = linear(bound.a, confirmed), b = linear(bound.b, confirmed);
|
|
86
|
+
if (!a || !b) {
|
|
87
|
+
failed = index;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
const split = sub(a, b), id = canon(split), noPath = new Map(confirmed).set(id, { lin: split, holds: false });
|
|
91
|
+
const proof = grow(goal, noPath, { nodes: 0, until: Math.min(until, clock() + (options.queryMs ?? 200)), units: options.units });
|
|
92
|
+
if (!('tree' in proof)) {
|
|
93
|
+
failed = index;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
cuts.push({ split, no: proof.tree });
|
|
97
|
+
confirmed = new Map(confirmed).set(id, { lin: split, holds: true });
|
|
98
|
+
}
|
|
99
|
+
if (failed !== undefined) {
|
|
100
|
+
excluded.add(failed);
|
|
101
|
+
options.trace?.({ stage: 'count-core-excluded', index: failed, excluded: [...excluded] });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const closed = grow(goal, confirmed, { nodes: 0, until, units: options.units });
|
|
105
|
+
if (!('tree' in closed))
|
|
106
|
+
return undefined;
|
|
107
|
+
let tree = closed.tree;
|
|
108
|
+
for (const cut of cuts.reverse())
|
|
109
|
+
tree = { split: cut.split, yes: tree, no: cut.no };
|
|
110
|
+
if (!check(goal, tree, path))
|
|
111
|
+
return undefined;
|
|
112
|
+
options.trace?.({ stage: 'count-case-certificate', before: cert.insts.length, after: insts.length, indices: selected.indices, hyps: goal.hyps.length });
|
|
113
|
+
return { goal, tree, indices: selected.indices };
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
export function proveCountCases(m, laws, at, cert, until, build, options = {}) {
|
|
118
|
+
return withDeadline(until, () => {
|
|
119
|
+
if (clock() >= until || pastWall())
|
|
120
|
+
return undefined;
|
|
121
|
+
const choice = finiteCountChoice(m);
|
|
122
|
+
if (!choice)
|
|
123
|
+
return undefined;
|
|
124
|
+
const [name, vs] = choice, cuts = [...vs].sort((a, b) => a - b), path = new Map(), conditions = [];
|
|
125
|
+
const splitAt = (v) => v ? { [name]: 1, '1': -v } : { [name]: 1 };
|
|
126
|
+
let activeCert = cert, packet = build(at), root = mcGoal(packet.goal.hyps, packet.decls, activeCert);
|
|
127
|
+
if (!root)
|
|
128
|
+
return undefined;
|
|
129
|
+
let goal = { ...root, name: packet.goal.name };
|
|
130
|
+
const rebuild = () => {
|
|
131
|
+
packet = build(at);
|
|
132
|
+
if (options.propose) {
|
|
133
|
+
const known = new Set(cert.reads.map(r => JSON.stringify(r.slice(1))));
|
|
134
|
+
let missing = false;
|
|
135
|
+
walkOnce(packet.goal.hyps, (o) => { if (o.op === 'get' && packet.decls.some(d => d.map === o.map) && !known.has(JSON.stringify([o.map, o.key])))
|
|
136
|
+
missing = true; });
|
|
137
|
+
if (missing && appendCountCert(cert, options.propose(packet.goal, packet.decls), packet.goal.hyps)) {
|
|
138
|
+
at = seedCountWitnessFlags(m, at, [{ decls: packet.decls, cert }], true);
|
|
139
|
+
packet = build(at);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
root = mcGoal(packet.goal.hyps, packet.decls, activeCert);
|
|
143
|
+
if (root)
|
|
144
|
+
goal = { ...root, name: packet.goal.name };
|
|
145
|
+
return !!root;
|
|
146
|
+
};
|
|
147
|
+
const seq = modelSequence(), records = [], branches = [];
|
|
148
|
+
const fallbackPath = new Map(cuts.map(value => { const lin = splitAt(value); return [canon(lin), { lin, holds: false }]; })), fallbackResult = refuteFast(rowsAt(goal, fallbackPath), 256);
|
|
149
|
+
const fallbackTree = fallbackResult?.kind === 'refuted' ? { leaf: fallbackResult.steps } : undefined, needed = fallbackTree ? usedHyps(goal, fallbackTree, fallbackPath) : new Set();
|
|
150
|
+
const fallback = fallbackTree ? { goal, tree: fallbackTree, indices: cert.insts.flatMap((_, i) => needed.has(goal.hyps.length - cert.insts.length + i) ? [i] : []) } : undefined;
|
|
151
|
+
options.trace?.({ stage: 'case-fallback', proposed: !!fallback });
|
|
152
|
+
const memo = sourceProofMemo(m, packet.goal.name), initial = at, merged = { ...at }, previous = atPoint.on;
|
|
153
|
+
atPoint.on = !options.corePointOnly;
|
|
154
|
+
const coreGrow = (g, end) => { const before = atPoint.on; atPoint.on = true; try {
|
|
155
|
+
return grow(g, new Map(), { nodes: 0, until: end, units: options.units });
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
atPoint.on = before;
|
|
159
|
+
} };
|
|
160
|
+
try {
|
|
161
|
+
for (const [i, value] of [...cuts, undefined].entries()) {
|
|
162
|
+
if (clock() >= until || pastWall())
|
|
163
|
+
return undefined;
|
|
164
|
+
const split = value === undefined ? undefined : splitAt(value), cut = value === undefined ? undefined : { op: '<=', a: x(name), b: { op: 'const', value } };
|
|
165
|
+
if (split)
|
|
166
|
+
path.set(canon(split), { lin: split, holds: true });
|
|
167
|
+
const root = new Map(path), tails = options.saturate && value !== undefined ? cuts.filter(v => v > value) : [];
|
|
168
|
+
for (const v of tails) {
|
|
169
|
+
const lin = splitAt(v);
|
|
170
|
+
path.set(canon(lin), { lin, holds: true });
|
|
171
|
+
}
|
|
172
|
+
const prefix = [...conditions, ...cut ? [cut] : [], ...tails.map(v => ({ op: '<=', a: x(name), b: { op: 'const', value: v } }))];
|
|
173
|
+
branches.push({ prefix, path: new Map(path), root, tails });
|
|
174
|
+
if (value === undefined && fallback) {
|
|
175
|
+
records.push({ ...fallback, path: new Map(path), from: fallbackPath });
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (options.localModels) {
|
|
179
|
+
at = initial;
|
|
180
|
+
if (!rebuild())
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
let tree, source, from, indices = cert.insts.map((_, j) => j);
|
|
184
|
+
const caseEnd = Math.min(until, clock() + Math.max(600, (until - clock()) / (cuts.length + 1 - i - (fallback ? 1 : 0))));
|
|
185
|
+
const claim = packet.goal.hyps.at(-1), rowDependent = activeWriteKey(m, path) !== undefined && rowPairs(m, cert, path, claim).length > 0;
|
|
186
|
+
tree = rowDependent ? undefined : fieldCase(m, goal, cert, claim, path, Math.min(caseEnd, clock() + 150), e => options.trace?.({ value, ...e }));
|
|
187
|
+
if (tree) {
|
|
188
|
+
source = goal;
|
|
189
|
+
from = new Map(path);
|
|
190
|
+
}
|
|
191
|
+
if (!tree && !writesReadState(m, cert, path, claim)) {
|
|
192
|
+
tree = frameLemmas(goal, cert, Math.min(caseEnd, clock() + 150), [], path, { deferCheck: true });
|
|
193
|
+
options.trace?.({ value, stage: 'write-free-case', proposed: !!tree });
|
|
194
|
+
if (tree) {
|
|
195
|
+
source = goal;
|
|
196
|
+
from = new Map(path);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const guard = actionGuard(m, name, value);
|
|
200
|
+
if (!tree && guard) {
|
|
201
|
+
const events = [], begun = clock(), derived = guardCases(m, packet.decls, goal, cert, guard, caseEnd, events, 0, path, { deferCheck: true, claim: packet.goal.hyps.at(-1), memo, conditional: true });
|
|
202
|
+
for (const event of events)
|
|
203
|
+
options.trace?.({ value, ...event });
|
|
204
|
+
options.trace?.({ value, stage: 'case-derivations', ms: Math.round(clock() - begun), proposed: !!derived });
|
|
205
|
+
if (derived) {
|
|
206
|
+
tree = derived;
|
|
207
|
+
source = goal;
|
|
208
|
+
from = new Map(path);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const selected = !tree && selectedCase(m, laws, at, cert, packet, path, caseEnd, build, options);
|
|
212
|
+
if (!tree)
|
|
213
|
+
packet = build(at); // Restore a builder after local selection attempts.
|
|
214
|
+
if (selected) {
|
|
215
|
+
const kept = new Set(selected.indices), slim = { ...cert, insts: cert.insts.filter((_, j) => kept.has(j)) };
|
|
216
|
+
at = seedCountWitnessFlags(m, at, [{ decls: packet.decls, cert: slim }], true);
|
|
217
|
+
tree = selected.tree;
|
|
218
|
+
source = selected.goal;
|
|
219
|
+
from = new Map(path);
|
|
220
|
+
indices = selected.indices;
|
|
221
|
+
}
|
|
222
|
+
for (let round = 0; !tree && round < 6 && clock() < caseEnd && !pastWall(); round++) {
|
|
223
|
+
const part = { name: goal.name, hyps: [...prefix, ...goal.hyps] }, start = clock(), q = seq(part, Math.min(caseEnd, clock() + (options.queryMs ?? 200)));
|
|
224
|
+
options.trace?.({ value, stage: 'query', round, hyps: part.hyps.length, ms: Math.round(clock() - start), outcome: 'tree' in q ? 'tree' : q.stuck, core: q.core?.length });
|
|
225
|
+
if (!('tree' in q) && q.why === REFUTED && q.core?.length && q.core.length <= (options.coreLimit ?? Infinity)) {
|
|
226
|
+
const core = { name: goal.name, hyps: q.core.map(j => part.hyps[j]) }, out = coreGrow(core, caseEnd);
|
|
227
|
+
options.trace?.({ value, stage: 'core', hyps: core.hyps.length, outcome: 'tree' in out ? 'tree' : out.stuck });
|
|
228
|
+
if ('tree' in out) {
|
|
229
|
+
tree = out.tree;
|
|
230
|
+
source = core;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (tree || 'tree' in q || q.stuck !== 'sat' || !q.witness)
|
|
234
|
+
break;
|
|
235
|
+
const proposed = modelInstances(m, laws, at, part, q.witness, 8);
|
|
236
|
+
const next = proposed && independentCountInstances(m, laws, at, proposed, cert.insts.map(i => i.wit));
|
|
237
|
+
if (!next)
|
|
238
|
+
break;
|
|
239
|
+
at = next;
|
|
240
|
+
if (!rebuild())
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
if (!tree && clock() < caseEnd && !pastWall()) {
|
|
244
|
+
const part = { name: goal.name, hyps: [...prefix, ...goal.hyps] }, out = grow(part, new Map(), { nodes: 0, until: caseEnd, units: options.units });
|
|
245
|
+
options.trace?.({ value, stage: 'grow', outcome: 'tree' in out ? 'tree' : out.stuck });
|
|
246
|
+
if ('tree' in out) {
|
|
247
|
+
tree = out.tree;
|
|
248
|
+
source = part;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
records.push(tree && source ? { goal: source, tree, path: new Map(path), indices, ...(from ? { from } : {}) } : undefined);
|
|
252
|
+
if (options.localModels)
|
|
253
|
+
for (const [n, terms] of Object.entries(at))
|
|
254
|
+
merged[n] = [...merged[n] ?? [], ...terms.slice(initial[n]?.length ?? 0)];
|
|
255
|
+
for (const v of tails)
|
|
256
|
+
path.delete(canon(splitAt(v)));
|
|
257
|
+
if (split) {
|
|
258
|
+
path.set(canon(split), { lin: split, holds: false });
|
|
259
|
+
conditions.push({ op: 'not', x: cut });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (options.localModels) {
|
|
263
|
+
at = merged;
|
|
264
|
+
if (!rebuild())
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const missing = records.flatMap((r, i) => r ? [] : [i]);
|
|
268
|
+
for (const [j, i] of missing.entries()) {
|
|
269
|
+
if (clock() >= until || pastWall())
|
|
270
|
+
break;
|
|
271
|
+
const { prefix, path: p } = branches[i], part = { name: goal.name, hyps: [...prefix, ...goal.hyps] };
|
|
272
|
+
const end = Math.min(until, clock() + (until - clock()) / (missing.length - j)), guard = actionGuard(m, name, cuts[i]), events = [];
|
|
273
|
+
const derived = guard && guardCases(m, packet.decls, goal, cert, guard, end, events, 0, p, { deferCheck: true, claim: packet.goal.hyps.at(-1), memo, conditional: true });
|
|
274
|
+
for (const event of events)
|
|
275
|
+
options.trace?.({ value: cuts[i], ...event });
|
|
276
|
+
if (derived) {
|
|
277
|
+
records[i] = { goal, tree: derived, path: p, from: p, indices: cert.insts.map((_, j) => j) };
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const out = grow(part, new Map(), { nodes: 0, until: end, units: options.units });
|
|
281
|
+
if ('tree' in out)
|
|
282
|
+
records[i] = { goal: part, tree: out.tree, path: p, indices: cert.insts.map((_, j) => j) };
|
|
283
|
+
}
|
|
284
|
+
if (records.some(r => !r))
|
|
285
|
+
return undefined;
|
|
286
|
+
const kept = new Set(records.flatMap(r => r?.indices ?? [])), discard = new Set(cert.insts.filter((_, i) => !kept.has(i)).map(c => c.wit));
|
|
287
|
+
activeCert = { ...cert, insts: cert.insts.filter((_, i) => kept.has(i)) };
|
|
288
|
+
at = withoutCountWitnesses(m, laws, at, discard);
|
|
289
|
+
if (!rebuild())
|
|
290
|
+
return undefined;
|
|
291
|
+
options.trace?.({ stage: 'count-cases-certificate', before: cert.insts.length, after: activeCert.insts.length });
|
|
292
|
+
const trees = records.map((r, i) => {
|
|
293
|
+
let tree = r && (hasConditionalProof(r.tree) ? transportConditionalProof(r.goal, goal, r.tree, r.from ?? new Map(), r.path, Math.min(wallAt(), countedSearchNow() + Math.max(0, until - clock()) * 10)) : widen(r.goal, goal, r.tree, {}, r.from ?? new Map(), r.path));
|
|
294
|
+
if (!tree)
|
|
295
|
+
return undefined;
|
|
296
|
+
const { root, tails } = branches[i];
|
|
297
|
+
for (let j = tails.length - 1; j >= 0; j--) {
|
|
298
|
+
const before = new Map(root);
|
|
299
|
+
for (const v of tails.slice(0, j)) {
|
|
300
|
+
const lin = splitAt(v);
|
|
301
|
+
before.set(canon(lin), { lin, holds: true });
|
|
302
|
+
}
|
|
303
|
+
const upper = [...before.keys()].indexOf(canon(splitAt(cuts[i]))), bad = before.size;
|
|
304
|
+
if (upper < 0)
|
|
305
|
+
return undefined;
|
|
306
|
+
tree = { split: splitAt(tails[j]), yes: tree, no: { leaf: [{ kind: 'input', index: upper }, { kind: 'input', index: bad }, { kind: 'combine', a: 0, b: 1, ma: 1, mb: 1 }] } };
|
|
307
|
+
}
|
|
308
|
+
return tree;
|
|
309
|
+
});
|
|
310
|
+
let tree = trees.at(-1);
|
|
311
|
+
for (let i = cuts.length - 1; i >= 0; i--)
|
|
312
|
+
tree = tree && trees[i] ? { split: splitAt(cuts[i]), yes: trees[i], no: tree } : undefined;
|
|
313
|
+
const combined = tree && (hasConditionalProof(tree) ? collectConditionalCertificate(goal, tree, Math.min(wallAt(), countedSearchNow() + Math.max(0, until - clock()) * 10)) : { tree, lemmas: undefined });
|
|
314
|
+
const result = combined && { ...activeCert, ...combined };
|
|
315
|
+
return result && (options.deferCheck || checkMC(packet.goal.hyps, packet.decls, result)) ? { instances: at, cert: result } : undefined;
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
atPoint.on = previous;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|