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,14 @@
|
|
|
1
|
+
export type CountTierBudget = Readonly<{
|
|
2
|
+
active: boolean;
|
|
3
|
+
workAllowance: number;
|
|
4
|
+
generationUntil: number;
|
|
5
|
+
strategyFloor: number;
|
|
6
|
+
ordinaryFloor: number;
|
|
7
|
+
strategyUntil: number | undefined;
|
|
8
|
+
until: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function countTierBudget(start: number, until: number, selectedStrategies: number): CountTierBudget;
|
|
11
|
+
export declare function remainingCountTierBudget(start: number, requested: number, selected: number): CountTierBudget;
|
|
12
|
+
export declare function strategyPhase<T>(budget: CountTierBudget | undefined, attemptEnd: number, run: (end: number) => T): T | undefined;
|
|
13
|
+
export declare function isLocalCountExpiration(error: unknown, enclosingEnd: number): boolean;
|
|
14
|
+
export declare function ordinaryTierShare(budget: CountTierBudget, now: number, pending: ReadonlySet<string>): number;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Counted-unit reservations, not wall-clock timers. A strategy floor is not
|
|
2
|
+
// a per-law or pool cap: the unreserved remainder and unused generation flow
|
|
3
|
+
// to strategies, while an ordinary-work floor remains protected.
|
|
4
|
+
import { attemptShare } from "./support-budget.js";
|
|
5
|
+
import { BudgetExpired, budgetEnd, clock, withDeadline } from "../kernel/prove.js";
|
|
6
|
+
import { inProxySearch } from "./search-policy.js";
|
|
7
|
+
import { workLedger } from "./work-admission.js";
|
|
8
|
+
export function countTierBudget(start, until, selectedStrategies) {
|
|
9
|
+
if (!Number.isSafeInteger(selectedStrategies) || selectedStrategies < 0)
|
|
10
|
+
throw new RangeError('invalid strategy count');
|
|
11
|
+
// No dispatcher hit: no reservation and precisely the existing split.
|
|
12
|
+
if (!selectedStrategies)
|
|
13
|
+
return Object.freeze({ active: false, workAllowance: Math.max(0, until - start), generationUntil: until, strategyFloor: 0, ordinaryFloor: 0, strategyUntil: undefined, until });
|
|
14
|
+
if (!Number.isFinite(start) || !Number.isFinite(until))
|
|
15
|
+
throw new RangeError('tiered work requires finite counted endpoints');
|
|
16
|
+
const width = Math.max(0, until - start), ordinaryFloor = width * 3 / 10;
|
|
17
|
+
return Object.freeze({ active: true, workAllowance: width, generationUntil: Math.min(until, start + width / 4), strategyFloor: width * 7 / 20, ordinaryFloor, strategyUntil: until - ordinaryFloor, until });
|
|
18
|
+
}
|
|
19
|
+
// The public caller has already spent work on normalization and preflight.
|
|
20
|
+
// Never regrant its original duration after that work.
|
|
21
|
+
export function remainingCountTierBudget(start, requested, selected) {
|
|
22
|
+
const plan = countTierBudget(start, Math.min(start + requested, budgetEnd()), selected);
|
|
23
|
+
if (!plan.active)
|
|
24
|
+
return plan;
|
|
25
|
+
// Include fixed public preflight in the original generation quarter.
|
|
26
|
+
const originalStart = plan.until - requested;
|
|
27
|
+
return Object.freeze({ ...plan, generationUntil: Math.min(plan.generationUntil, originalStart + requested / 4) });
|
|
28
|
+
}
|
|
29
|
+
// One endpoint shared by every STEP refinement and every retry. Expiration
|
|
30
|
+
// returns to ordinary INIT/STEP completion; it does not cancel that reserve.
|
|
31
|
+
export function strategyPhase(budget, attemptEnd, run) {
|
|
32
|
+
if (!budget?.active)
|
|
33
|
+
return run(attemptEnd);
|
|
34
|
+
const end = Math.min(attemptEnd, budget.strategyUntil ?? attemptEnd);
|
|
35
|
+
if (clock() >= end)
|
|
36
|
+
return undefined;
|
|
37
|
+
try {
|
|
38
|
+
const result = withDeadline(end, () => run(end)), now = clock();
|
|
39
|
+
// Equality does not throw BudgetExpired. Only a local-cap unknown hands
|
|
40
|
+
// back the ordinary reserve; proofs and genuine refutations stay results.
|
|
41
|
+
if (now >= end && now <= budgetEnd() && result !== null && typeof result === 'object' &&
|
|
42
|
+
'stuck' in result && result.stuck === 'unknown' && !('proof' in result) &&
|
|
43
|
+
!('refuted' in result && result.refuted))
|
|
44
|
+
return undefined;
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (inProxySearch() && workLedger.capacityRefusal(error))
|
|
49
|
+
throw error;
|
|
50
|
+
if (!(error instanceof BudgetExpired) || clock() < end || clock() > budgetEnd())
|
|
51
|
+
throw error;
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// A local full-work deadline throws the same exception as the public budget.
|
|
56
|
+
// Only the former is an unknown attempt: preserve the enclosing phase's end,
|
|
57
|
+
// captured before per-law/subset scopes, and never swallow outer cancellation.
|
|
58
|
+
export function isLocalCountExpiration(error, enclosingEnd) {
|
|
59
|
+
return !(inProxySearch() && workLedger.capacityRefusal(error))
|
|
60
|
+
&& error instanceof BudgetExpired && clock() < Math.min(enclosingEnd, budgetEnd());
|
|
61
|
+
}
|
|
62
|
+
export function ordinaryTierShare(budget, now, pending) {
|
|
63
|
+
return attemptShare(budget.until - now, pending);
|
|
64
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Untrusted set-cover proposals for Count.lean's existing single-witness CInst.
|
|
2
|
+
// Two positive counts may be disjoint inside one set or a union of three
|
|
3
|
+
// Venn regions. No disjointness/coverage fact is assumed here: a generated
|
|
4
|
+
// instance keeps its witness alternative, checked by the ordinary kernel.
|
|
5
|
+
import { walkOnce, x } from "./machine.js";
|
|
6
|
+
import { substE } from "../kernel/kernel.js";
|
|
7
|
+
const key = (x) => JSON.stringify(x);
|
|
8
|
+
const cond = (c, atoms) => {
|
|
9
|
+
if (c.op === 'flag' || c.op === 'all')
|
|
10
|
+
return undefined;
|
|
11
|
+
if (c.op === 'not') {
|
|
12
|
+
const b = cond(c.x, atoms);
|
|
13
|
+
return b === undefined ? undefined : { not: b };
|
|
14
|
+
}
|
|
15
|
+
if (c.op === 'and' || c.op === 'or') {
|
|
16
|
+
const bs = c.xs.map(c => cond(c, atoms));
|
|
17
|
+
return bs.some(b => b === undefined) ? undefined : { [c.op]: bs };
|
|
18
|
+
}
|
|
19
|
+
const atom = key(c);
|
|
20
|
+
atoms.add(atom);
|
|
21
|
+
return { atom };
|
|
22
|
+
};
|
|
23
|
+
const body = (e, atoms) => {
|
|
24
|
+
if (e.op === 'const')
|
|
25
|
+
return e.value === 0 ? false : e.value === 1 ? true : undefined;
|
|
26
|
+
if (e.op !== 'if')
|
|
27
|
+
return undefined;
|
|
28
|
+
const c = cond(e.c, atoms), a = body(e.then, atoms), b = body(e.else, atoms);
|
|
29
|
+
return c === undefined || a === undefined || b === undefined ? undefined : { or: [{ and: [c, a] }, { and: [{ not: c }, b] }] };
|
|
30
|
+
};
|
|
31
|
+
const evaluate = (b, at) => typeof b === 'boolean' ? b : 'atom' in b ? at.get(b.atom) : 'not' in b ? !evaluate(b.not, at) : 'and' in b ? b.and.every(c => evaluate(c, at)) : b.or.some(c => evaluate(c, at));
|
|
32
|
+
export function proposeCountUnions(counts, pairs, maxFacts = 128) {
|
|
33
|
+
const out = [], seen = new Set();
|
|
34
|
+
const add = (a, b, cover) => {
|
|
35
|
+
if (out.length >= maxFacts || cover.some(c => c.v === a.v || c.v === b.v))
|
|
36
|
+
return;
|
|
37
|
+
const terms = [[1, a.v], [1, b.v], ...cover.map(c => [-1, c.v])];
|
|
38
|
+
const signature = key(terms);
|
|
39
|
+
if (!seen.has(signature)) {
|
|
40
|
+
seen.add(signature);
|
|
41
|
+
out.push({ wit: `union$${out.length}`, below: a.below, terms, unit: 0 });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const groups = new Map();
|
|
45
|
+
for (const c of counts.slice(0, 128)) {
|
|
46
|
+
const k = key(c.below), cs = groups.get(k) ?? [];
|
|
47
|
+
cs.push(c);
|
|
48
|
+
groups.set(k, cs);
|
|
49
|
+
}
|
|
50
|
+
for (const cs of groups.values()) {
|
|
51
|
+
const byName = new Map(cs.map(c => [c.v, c])), regions = new Map();
|
|
52
|
+
for (const c of cs) {
|
|
53
|
+
const atoms = new Set(), f = body(substE(c.body, { vars: { [c.key]: x('union$key') }, maps: {}, flags: {} }), atoms);
|
|
54
|
+
if (f === undefined || atoms.size !== 2)
|
|
55
|
+
continue;
|
|
56
|
+
const ks = [...atoms].sort();
|
|
57
|
+
let mask = 0;
|
|
58
|
+
for (let bits = 0; bits < 4; bits++)
|
|
59
|
+
if (evaluate(f, new Map(ks.map((k, i) => [k, !!(bits & (1 << i))]))))
|
|
60
|
+
mask |= 1 << bits;
|
|
61
|
+
// One region of two primitive predicates; select a representative for duplicates.
|
|
62
|
+
if (![1, 2, 4, 8].includes(mask))
|
|
63
|
+
continue;
|
|
64
|
+
const id = key(ks), rs = regions.get(id) ?? new Map();
|
|
65
|
+
if (!rs.has(mask))
|
|
66
|
+
rs.set(mask, c);
|
|
67
|
+
regions.set(id, rs);
|
|
68
|
+
}
|
|
69
|
+
// An indicator is the disjoint union of the two regions where its atom
|
|
70
|
+
// holds. Raw map-valued counts are only *candidates* for indicators: the
|
|
71
|
+
// returned CInst retains its pointwise alternative, so 0/1 membership must
|
|
72
|
+
// still be established from the actual machine's hypotheses.
|
|
73
|
+
for (const c of cs) {
|
|
74
|
+
const e = substE(c.body, { vars: { [c.key]: x('union$key') }, maps: {}, flags: {} });
|
|
75
|
+
const atoms = new Set(), f = body(e, atoms);
|
|
76
|
+
const atom = e.op === 'get' ? key({ op: '=', a: e, b: { op: 'const', value: 1 } }) : atoms.size === 1 ? [...atoms][0] : undefined;
|
|
77
|
+
if (!atom)
|
|
78
|
+
continue;
|
|
79
|
+
const on = (v) => e.op === 'get' ? v : f !== undefined && evaluate(f, new Map([[atom, v]]));
|
|
80
|
+
for (const [id, rs] of regions) {
|
|
81
|
+
const ks = JSON.parse(id), i = ks.indexOf(atom);
|
|
82
|
+
if (i < 0)
|
|
83
|
+
continue;
|
|
84
|
+
const parts = [1, 2, 4, 8].filter((_, bits) => on(!!(bits & (1 << i)))).map(mask => rs.get(mask));
|
|
85
|
+
const [left, right] = parts;
|
|
86
|
+
if (parts.length !== 2 || !left || !right || out.length + 2 > maxFacts)
|
|
87
|
+
continue;
|
|
88
|
+
for (const sign of [1, -1]) {
|
|
89
|
+
const terms = [[sign, c.v], [-sign, left.v], [-sign, right.v]], signature = key(terms);
|
|
90
|
+
if (!seen.has(signature)) {
|
|
91
|
+
seen.add(signature);
|
|
92
|
+
out.push({ wit: `union$${out.length}`, below: c.below, terms, unit: 0 });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const triples = [...regions.values()].filter(rs => rs.has(2) && rs.has(4) && rs.has(8)).map(rs => [rs.get(2), rs.get(4), rs.get(8)]);
|
|
98
|
+
const positive = pairs.flatMap(([a, b]) => byName.has(a) && byName.has(b) && a !== b ? [[byName.get(a), byName.get(b)]] : []);
|
|
99
|
+
// Interleave useful singleton covers with relational unions per positive
|
|
100
|
+
// pair. A global five-term prefix can otherwise consume the whole budget
|
|
101
|
+
// before the actual carried set gets its three-term self-row cover.
|
|
102
|
+
const normalized = new Map(cs.map(c => [c.v, substE(c.body, { vars: { [c.key]: x('union$key') }, maps: {}, flags: {} })]));
|
|
103
|
+
const primitive = (e) => {
|
|
104
|
+
if (e.op === 'get')
|
|
105
|
+
return e;
|
|
106
|
+
if (e.op !== 'if' || e.then.op !== 'const' || e.then.value !== 1 || e.else.op !== 'const' || e.else.value !== 0)
|
|
107
|
+
return undefined;
|
|
108
|
+
const c = e.c;
|
|
109
|
+
if (c.op === '=' && c.a.op === 'get' && c.b.op === 'const' && c.b.value === 1)
|
|
110
|
+
return c.a;
|
|
111
|
+
if (c.op === '=' && c.b.op === 'get' && c.a.op === 'const' && c.a.value === 1)
|
|
112
|
+
return c.b;
|
|
113
|
+
if (c.op === '<=' && c.a.op === 'const' && c.a.value === 1 && c.b.op === 'get')
|
|
114
|
+
return c.b;
|
|
115
|
+
if (c.op === '<' && c.a.op === 'const' && c.a.value === 0 && c.b.op === 'get')
|
|
116
|
+
return c.b;
|
|
117
|
+
return undefined;
|
|
118
|
+
};
|
|
119
|
+
for (const [a, b] of positive) {
|
|
120
|
+
if (out.length >= maxFacts)
|
|
121
|
+
break;
|
|
122
|
+
const members = new Set();
|
|
123
|
+
for (const c of [a, b])
|
|
124
|
+
walkOnce(normalized.get(c.v), (o) => { if (o.op === 'get')
|
|
125
|
+
members.add(key(o)); });
|
|
126
|
+
for (const c of cs) {
|
|
127
|
+
const view = primitive(normalized.get(c.v));
|
|
128
|
+
if (view && members.has(key(view)))
|
|
129
|
+
add(a, b, [c]);
|
|
130
|
+
}
|
|
131
|
+
for (const cover of triples)
|
|
132
|
+
add(a, b, cover);
|
|
133
|
+
}
|
|
134
|
+
for (const [a, b] of positive)
|
|
135
|
+
for (const c of cs)
|
|
136
|
+
add(a, b, [c]);
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type C, type E } from './machine.js';
|
|
2
|
+
import { type Count, type CountDecl, type LinCut, type MapRead } from '../kernel/kernel.js';
|
|
3
|
+
export declare function checkedReversePrefix(counts: Count[], cut: LinCut): LinCut | undefined;
|
|
4
|
+
export declare function replayReversePrefix(counts: Count[], cut: LinCut, until: number): LinCut | undefined;
|
|
5
|
+
export declare class UnwrittenCountPrefix {
|
|
6
|
+
private decls;
|
|
7
|
+
private reads;
|
|
8
|
+
private guards;
|
|
9
|
+
private written;
|
|
10
|
+
private rowBound;
|
|
11
|
+
private search;
|
|
12
|
+
private options;
|
|
13
|
+
private cache;
|
|
14
|
+
readonly stats: {
|
|
15
|
+
proofs: number;
|
|
16
|
+
hits: number;
|
|
17
|
+
refusals: number;
|
|
18
|
+
};
|
|
19
|
+
constructor(decls: CountDecl[], reads: MapRead[], guards: C[], written: E, rowBound: E, search?: 'grow' | 'cdcl', options?: {
|
|
20
|
+
deferCheck?: boolean;
|
|
21
|
+
leafUnits?: number;
|
|
22
|
+
});
|
|
23
|
+
prove(post: string, pre: string, rows: E[], sign: 1 | -1, until: number): LinCut | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Untrusted shared prefix for unwritten row counts. Every reusable result is
|
|
2
|
+
// checked after alpha-renaming; no frame is inferred merely from a row label.
|
|
3
|
+
import { n, not, same, walkOnce, x } from "./machine.js";
|
|
4
|
+
import { countCertificateRenamer } from "./count-cert-rename.js";
|
|
5
|
+
import { countsForReads } from "./count-facts.js";
|
|
6
|
+
import { linOk, substE } from "../kernel/kernel.js";
|
|
7
|
+
import { clock } from "../kernel/prove.js";
|
|
8
|
+
import { countPrimitiveUnits } from "./count-primitive-budget.js";
|
|
9
|
+
import { guardLinearFact } from "./count-guard-facts.js";
|
|
10
|
+
import { replayLinearSkeleton } from "./count-replay-skeleton.js";
|
|
11
|
+
// A hint, never an equality assumption: alpha-renaming can change which
|
|
12
|
+
// orientation a stored derivation supports. Admit the reverse only by linOk.
|
|
13
|
+
export function checkedReversePrefix(counts, cut) {
|
|
14
|
+
const candidate = { ...cut, pos: cut.neg, neg: cut.pos };
|
|
15
|
+
return linOk(counts, candidate) ? candidate : undefined;
|
|
16
|
+
}
|
|
17
|
+
// Unlike swapping a proof, this rebuilds every leaf for the opposite claim.
|
|
18
|
+
// It may only return a cut that linOk accepts under the original conditions.
|
|
19
|
+
export function replayReversePrefix(counts, cut, until) {
|
|
20
|
+
if (clock() >= until)
|
|
21
|
+
return;
|
|
22
|
+
const pos = cut.neg, neg = cut.pos, first = counts.find(c => c.v === (pos[0] ?? neg[0])?.[1]);
|
|
23
|
+
if (!first || [...pos, ...neg].some(([, id]) => !counts.some(c => c.v === id)))
|
|
24
|
+
return;
|
|
25
|
+
const term = (side) => side.reduceRight((rest, [k, id]) => ({ op: 'add', a: { op: 'mul', k, a: counts.find(c => c.v === id).body }, b: rest }), n(0));
|
|
26
|
+
const goal = { name: 'replayed opposite prefix', hyps: [...cut.when, { op: '<', a: x(first.key), b: first.below }, { op: '<', a: term(neg), b: term(pos) }] };
|
|
27
|
+
const tree = replayLinearSkeleton(goal, cut.tree, new Map(), until);
|
|
28
|
+
const candidate = tree && { ...cut, pos, neg, tree };
|
|
29
|
+
return candidate && clock() < until && linOk(counts, candidate) ? candidate : undefined;
|
|
30
|
+
}
|
|
31
|
+
export class UnwrittenCountPrefix {
|
|
32
|
+
decls;
|
|
33
|
+
reads;
|
|
34
|
+
guards;
|
|
35
|
+
written;
|
|
36
|
+
rowBound;
|
|
37
|
+
search;
|
|
38
|
+
options;
|
|
39
|
+
cache = new Map();
|
|
40
|
+
stats = { proofs: 0, hits: 0, refusals: 0 };
|
|
41
|
+
constructor(decls, reads, guards, written, rowBound, search = 'grow', options = {}) {
|
|
42
|
+
this.decls = decls;
|
|
43
|
+
this.reads = reads;
|
|
44
|
+
this.guards = guards;
|
|
45
|
+
this.written = written;
|
|
46
|
+
this.rowBound = rowBound;
|
|
47
|
+
this.search = search;
|
|
48
|
+
this.options = options;
|
|
49
|
+
}
|
|
50
|
+
prove(post, pre, rows, sign, until) {
|
|
51
|
+
const p = this.reads.find(r => r[0] === post), q = this.reads.find(r => r[0] === pre);
|
|
52
|
+
if (!p || !q || p[1] !== q[1] + '#' || JSON.stringify(p[2]) !== JSON.stringify(q[2]))
|
|
53
|
+
return;
|
|
54
|
+
const names = [...new Set(rows.flatMap(r => r.op === 'var' ? [r.name] : []))];
|
|
55
|
+
if (names.length !== rows.length)
|
|
56
|
+
return;
|
|
57
|
+
const fixed = new Set();
|
|
58
|
+
for (const c of [...this.guards, this.written, this.rowBound])
|
|
59
|
+
walkOnce(c, (v) => { if (v.op === 'var')
|
|
60
|
+
fixed.add(v.name); });
|
|
61
|
+
if (names.some(n => fixed.has(n)))
|
|
62
|
+
return;
|
|
63
|
+
const scope = JSON.stringify([this.decls, this.reads, this.guards, this.written, this.rowBound]);
|
|
64
|
+
let prefix = 'unwritten$';
|
|
65
|
+
while (scope.includes(prefix))
|
|
66
|
+
prefix = '$' + prefix;
|
|
67
|
+
const vars = Object.fromEntries(names.map((name, i) => [name, x(prefix + 'r' + i)])), sub = { vars, maps: {}, flags: {} };
|
|
68
|
+
const key = substE(p[2], sub), genericRows = names.map(n => vars[n]), when = [...this.guards, ...genericRows.flatMap(row => [{ op: '<', a: row, b: this.rowBound }, not(same(row, this.written))])];
|
|
69
|
+
const generic = [[prefix + 'post', p[1], key], [prefix + 'pre', q[1], key]], terms = [[sign, generic[0][0]], [-sign, generic[1][0]]];
|
|
70
|
+
const cacheKey = JSON.stringify([generic, when, terms]);
|
|
71
|
+
let cut = this.cache.get(cacheKey);
|
|
72
|
+
if (cut)
|
|
73
|
+
this.stats.hits++;
|
|
74
|
+
else {
|
|
75
|
+
this.stats.proofs++;
|
|
76
|
+
const fact = guardLinearFact(this.decls, generic, { name: 'unwritten count prefix', kind: 'ordinary-unwritten-count', when, terms }, Math.min(until, clock() + countPrimitiveUnits(60, this.options.leafUnits)), undefined, this.search, this.options);
|
|
77
|
+
if (!fact) {
|
|
78
|
+
this.stats.refusals++;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
cut = fact.cut;
|
|
82
|
+
this.cache.set(cacheKey, cut);
|
|
83
|
+
}
|
|
84
|
+
const renames = new Map(names.map((name, i) => [prefix + 'r' + i, name]));
|
|
85
|
+
renames.set(generic[0][0], post);
|
|
86
|
+
renames.set(generic[1][0], pre);
|
|
87
|
+
if (clock() >= until)
|
|
88
|
+
return;
|
|
89
|
+
const renamed = countCertificateRenamer(renames, until).certificate({ reads: generic, insts: [], picks: [], lins: [cut], tree: { leaf: [] } }).lins[0];
|
|
90
|
+
const counts = countsForReads(this.decls, this.reads);
|
|
91
|
+
if (!counts || !this.options.deferCheck && !linOk(counts, renamed)) {
|
|
92
|
+
this.stats.refusals++;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
return renamed;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type E, type Machine } from './machine.js';
|
|
2
|
+
import { type CountCert, type CountDecl, type Instances } from '../kernel/kernel.js';
|
|
3
|
+
export declare function seedCountWitnessFlags(m: Machine, at: Instances, packets: {
|
|
4
|
+
decls: CountDecl[];
|
|
5
|
+
cert: Pick<CountCert, 'reads' | 'insts'>;
|
|
6
|
+
}[], preferCarried?: boolean, options?: {
|
|
7
|
+
dependencies?: (body: E) => Set<string>;
|
|
8
|
+
carriedOnly?: boolean;
|
|
9
|
+
}): Instances;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Untrusted instances of the machine's universal flags at selected count witnesses.
|
|
2
|
+
// Count.lean only supplies a witness; the pointwise request predicates at that
|
|
3
|
+
// witness must still be instantiated and proved useful by the ordinary kernel.
|
|
4
|
+
import { walkOnce, x } from "./machine.js";
|
|
5
|
+
const mapsIn = (value) => {
|
|
6
|
+
const maps = new Set();
|
|
7
|
+
walkOnce(value, (o) => { if (o.op === 'get')
|
|
8
|
+
maps.add(o.map); });
|
|
9
|
+
return maps;
|
|
10
|
+
};
|
|
11
|
+
export function seedCountWitnessFlags(m, at, packets, preferCarried = false, options = {}) {
|
|
12
|
+
let out = at;
|
|
13
|
+
const flags = Object.entries(m.step.flags ?? {}).filter(([, q]) => q.op === 'all' && !q.keys?.length).map(([name, q]) => ({ name: `?${name}`, maps: mapsIn(q) }))
|
|
14
|
+
// A count read at its own CInst witness is outside checkMC's read-key scope.
|
|
15
|
+
.filter(q => ![...q.maps].some(mp => mp in (m.counts ?? {})));
|
|
16
|
+
for (const { decls, cert } of packets) {
|
|
17
|
+
const bodies = new Map(cert.reads.map(([id, map]) => { const d = decls.find(d => d.map === map); return [id, d ? (options.dependencies ?? mapsIn)(d.body) : new Set()]; }));
|
|
18
|
+
for (const inst of cert.insts) {
|
|
19
|
+
let used = new Set(inst.terms.flatMap(([, id]) => [...bodies.get(id) ?? []]));
|
|
20
|
+
if (preferCarried) {
|
|
21
|
+
const carried = new Set(inst.terms.filter(([coefficient]) => coefficient > 0).flatMap(([, id]) => [...bodies.get(id) ?? []]).filter(mp => m.inputMaps?.includes(mp)));
|
|
22
|
+
if (carried.size || options.carriedOnly)
|
|
23
|
+
used = carried;
|
|
24
|
+
}
|
|
25
|
+
for (const f of flags)
|
|
26
|
+
if (!f.maps.size || [...f.maps].some(mp => used.has(mp))) {
|
|
27
|
+
const term = x(inst.wit), had = out[f.name] ?? [];
|
|
28
|
+
if (had.some(e => e.op === 'var' && e.name === inst.wit))
|
|
29
|
+
continue;
|
|
30
|
+
if (out === at)
|
|
31
|
+
out = { ...at };
|
|
32
|
+
out[f.name] = [...had, term];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Machine } from './machine.js';
|
|
2
|
+
import { type CountCert, type CountDecl, type CountInst } from '../kernel/kernel.js';
|
|
3
|
+
/** Demand IDs are certificate read variables. Inspect PRE declarations at the
|
|
4
|
+
* same keys: expanded post bodies hide the small two-membership shape. Match
|
|
5
|
+
* only incoming counts joining a written map to its actual carried value source.
|
|
6
|
+
* Difference counts deliberately offer both incoming directions: which row is
|
|
7
|
+
* written/equal is a guarded proof obligation, not a syntactic equivalence.
|
|
8
|
+
* No reads/declarations are added, no input is mutated, and at most 32 ordinary
|
|
9
|
+
* unit-zero instances are returned (two-term frames or three-term compensated
|
|
10
|
+
* single-set/difference transports, in a deterministic prefix).
|
|
11
|
+
*/
|
|
12
|
+
export declare function proposeWriteCountFrames(m: Machine, ds: CountDecl[], cert: Pick<CountCert, 'reads' | 'insts'>, demanded: ReadonlySet<string>, maxFacts?: number): CountInst[];
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// UNTRUSTED written-row count proposals. No equality or frame is assumed here:
|
|
2
|
+
// each direction keeps Count.lean's counterexample-key alternative. Only the
|
|
3
|
+
// source solver/checker, under its actual row/scalar guards, can discharge it.
|
|
4
|
+
import { n } from "./machine.js";
|
|
5
|
+
import { countsForReads } from "./count-facts.js";
|
|
6
|
+
const stable = (value) => JSON.stringify(value, (_, v) => v && typeof v === 'object' && !Array.isArray(v)
|
|
7
|
+
? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b))) : v);
|
|
8
|
+
// These are membership syntaxes, not arbitrary predicates that happen to have
|
|
9
|
+
// two atoms (e.g. older-field lexicographic comparisons).
|
|
10
|
+
function membership(c) {
|
|
11
|
+
if (c.op === '=') {
|
|
12
|
+
if (c.a.op === 'get' && c.b.op === 'const' && c.b.value === 1)
|
|
13
|
+
return c.a;
|
|
14
|
+
if (c.b.op === 'get' && c.a.op === 'const' && c.a.value === 1)
|
|
15
|
+
return c.b;
|
|
16
|
+
}
|
|
17
|
+
if ((c.op === '<=' && c.a.op === 'const' && c.a.value === 1
|
|
18
|
+
|| c.op === '<' && c.a.op === 'const' && c.a.value === 0) && c.b.op === 'get')
|
|
19
|
+
return c.b;
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function literals(c, positive = true) {
|
|
23
|
+
if (c.op === 'not')
|
|
24
|
+
return literals(c.x, !positive);
|
|
25
|
+
if (c.op === 'and' && positive) {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const child of c.xs) {
|
|
28
|
+
const part = literals(child);
|
|
29
|
+
if (!part || out.length + part.length > 2)
|
|
30
|
+
return undefined;
|
|
31
|
+
out.push(...part);
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
const cell = membership(c);
|
|
36
|
+
return cell && [{ cell, positive }];
|
|
37
|
+
}
|
|
38
|
+
function shape(body) {
|
|
39
|
+
if (body.op !== 'if' || body.then.op !== 'const' || body.then.value !== 1
|
|
40
|
+
|| body.else.op !== 'const' || body.else.value !== 0)
|
|
41
|
+
return undefined;
|
|
42
|
+
const ls = literals(body.c);
|
|
43
|
+
if (ls?.length === 1)
|
|
44
|
+
return ls[0].positive ? { kind: 'single', literals: ls } : undefined;
|
|
45
|
+
if (!ls || ls.length !== 2 || stable(ls[0].cell) === stable(ls[1].cell))
|
|
46
|
+
return undefined;
|
|
47
|
+
const positives = ls.filter(l => l.positive).length;
|
|
48
|
+
return positives ? { kind: positives === 2 ? 'intersection' : 'difference', literals: ls } : undefined;
|
|
49
|
+
}
|
|
50
|
+
// Follow value branches, never general reads in a non-Boolean write guard.
|
|
51
|
+
// A Booleanized value can be an OR of guarded membership arms after lowering.
|
|
52
|
+
function booleanSources(c, inputs, out, positive = true) {
|
|
53
|
+
if (c.op === 'not') {
|
|
54
|
+
booleanSources(c.x, inputs, out, !positive);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (c.op === 'and' || c.op === 'or') {
|
|
58
|
+
for (const child of c.xs)
|
|
59
|
+
booleanSources(child, inputs, out, positive);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const cell = positive && membership(c);
|
|
63
|
+
if (cell && inputs.has(cell.map))
|
|
64
|
+
out.add(cell.map);
|
|
65
|
+
}
|
|
66
|
+
function copySources(value, inputs, out = new Set()) {
|
|
67
|
+
if (value.op === 'get' && inputs.has(value.map))
|
|
68
|
+
out.add(value.map);
|
|
69
|
+
if (value.op === 'if') {
|
|
70
|
+
if (value.then.op === 'const' && value.then.value === 1
|
|
71
|
+
&& value.else.op === 'const' && value.else.value === 0)
|
|
72
|
+
booleanSources(value.c, inputs, out);
|
|
73
|
+
copySources(value.then, inputs, out);
|
|
74
|
+
copySources(value.else, inputs, out);
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/** Demand IDs are certificate read variables. Inspect PRE declarations at the
|
|
79
|
+
* same keys: expanded post bodies hide the small two-membership shape. Match
|
|
80
|
+
* only incoming counts joining a written map to its actual carried value source.
|
|
81
|
+
* Difference counts deliberately offer both incoming directions: which row is
|
|
82
|
+
* written/equal is a guarded proof obligation, not a syntactic equivalence.
|
|
83
|
+
* No reads/declarations are added, no input is mutated, and at most 32 ordinary
|
|
84
|
+
* unit-zero instances are returned (two-term frames or three-term compensated
|
|
85
|
+
* single-set/difference transports, in a deterministic prefix).
|
|
86
|
+
*/
|
|
87
|
+
export function proposeWriteCountFrames(m, ds, cert, demanded, maxFacts = 32) {
|
|
88
|
+
const cap = Number.isSafeInteger(maxFacts) && maxFacts >= 0 ? Math.min(maxFacts, 32) : 0;
|
|
89
|
+
if (!cap || !demanded.size)
|
|
90
|
+
return [];
|
|
91
|
+
// Include ALL names, including unrelated declarations, flags, bindings, map
|
|
92
|
+
// keys and existing witness bounds. Iterative traversal also handles sharing.
|
|
93
|
+
const used = new Set(), seenObjects = new Set(), pending = [m, ds, cert, [...demanded]];
|
|
94
|
+
while (pending.length) {
|
|
95
|
+
const value = pending.pop();
|
|
96
|
+
if (typeof value === 'string')
|
|
97
|
+
used.add(value);
|
|
98
|
+
else if (value && typeof value === 'object' && !seenObjects.has(value)) {
|
|
99
|
+
seenObjects.add(value);
|
|
100
|
+
for (const [key, child] of Object.entries(value)) {
|
|
101
|
+
used.add(key);
|
|
102
|
+
pending.push(child);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let serial = 0;
|
|
107
|
+
const fresh = () => {
|
|
108
|
+
while (used.has(`writeFrame$${serial}`))
|
|
109
|
+
serial++;
|
|
110
|
+
const name = `writeFrame$${serial++}`;
|
|
111
|
+
used.add(name);
|
|
112
|
+
return name;
|
|
113
|
+
};
|
|
114
|
+
const writers = new Map(), inputs = new Set(m.inputMaps ?? []);
|
|
115
|
+
for (const [map, write] of Object.entries(m.step.maps ?? {})) {
|
|
116
|
+
const sources = copySources(write.value, inputs);
|
|
117
|
+
if (sources.size)
|
|
118
|
+
writers.set(map, sources);
|
|
119
|
+
}
|
|
120
|
+
if (!writers.size)
|
|
121
|
+
return [];
|
|
122
|
+
const declarations = new Map();
|
|
123
|
+
for (const d of ds)
|
|
124
|
+
if (!declarations.has(d.map))
|
|
125
|
+
declarations.set(d.map, d);
|
|
126
|
+
const indexKey = (map, kind, below) => stable([map, kind, below]);
|
|
127
|
+
const incoming = new Map(), readIds = new Set();
|
|
128
|
+
for (const read of cert.reads) {
|
|
129
|
+
if (readIds.has(read[0]))
|
|
130
|
+
continue;
|
|
131
|
+
readIds.add(read[0]);
|
|
132
|
+
if (read[1].endsWith('#'))
|
|
133
|
+
continue;
|
|
134
|
+
const c = countsForReads(ds, [read])?.[0], s = c && shape(c.body);
|
|
135
|
+
if (!c || !s)
|
|
136
|
+
continue;
|
|
137
|
+
for (const [map, sources] of writers) {
|
|
138
|
+
if (!s.literals.some(l => sources.has(l.cell.map)) || s.kind !== 'single' && !s.literals.some(l => l.cell.map === map))
|
|
139
|
+
continue;
|
|
140
|
+
const key = indexKey(map, s.kind, c.below), group = incoming.get(key) ?? [];
|
|
141
|
+
group.push(c);
|
|
142
|
+
incoming.set(key, group);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Coefficient-vector dedupe ignores term order and combines repeated IDs.
|
|
146
|
+
// Each direction has its own signature; an existing reverse does not erase
|
|
147
|
+
// the still-missing forward direction.
|
|
148
|
+
const signature = (i) => {
|
|
149
|
+
const coefficients = new Map();
|
|
150
|
+
for (const [z, id] of i.terms)
|
|
151
|
+
coefficients.set(id, (coefficients.get(id) ?? 0) + z);
|
|
152
|
+
return stable([i.unit, [...coefficients].filter(([, z]) => z !== 0).sort(([a], [b]) => a.localeCompare(b))]);
|
|
153
|
+
};
|
|
154
|
+
const emitted = new Set(cert.insts.map(signature)), out = [];
|
|
155
|
+
readIds.clear();
|
|
156
|
+
for (const read of cert.reads) {
|
|
157
|
+
if (readIds.has(read[0]))
|
|
158
|
+
continue;
|
|
159
|
+
readIds.add(read[0]);
|
|
160
|
+
if (!demanded.has(read[0]) || !read[1].endsWith('#'))
|
|
161
|
+
continue;
|
|
162
|
+
const preRead = [read[0], read[1].slice(0, -1), read[2]];
|
|
163
|
+
const before = countsForReads(ds, [preRead])?.[0], s = before && shape(before.body);
|
|
164
|
+
const postDecl = declarations.get(read[1]);
|
|
165
|
+
if (!before || !s || !postDecl)
|
|
166
|
+
continue;
|
|
167
|
+
// Instantiate the real post bound without traversing the expanded body.
|
|
168
|
+
const post = countsForReads([{ ...postDecl, body: n(0) }], [read])?.[0];
|
|
169
|
+
if (!post || stable(post.below) !== stable(before.below))
|
|
170
|
+
continue;
|
|
171
|
+
for (const map of new Set(s.literals.map(l => l.cell.map))) {
|
|
172
|
+
const kinds = s.kind === 'intersection' && s.literals.every(l => l.cell.map === map) ? [s.kind, 'single'] : [s.kind];
|
|
173
|
+
for (const kind of kinds)
|
|
174
|
+
for (const c of incoming.get(indexKey(map, kind, post.below)) ?? []) {
|
|
175
|
+
if (c.v === read[0])
|
|
176
|
+
continue;
|
|
177
|
+
// Retaining the old count can compensate a changed single set or
|
|
178
|
+
// directed difference. These are only proposals: a writer may conjure
|
|
179
|
+
// members, and neither old+incoming nor either incoming orientation
|
|
180
|
+
// is trusted until checked under the actual write/row guards.
|
|
181
|
+
if (s.kind === 'difference' || s.kind === 'single') {
|
|
182
|
+
const previous = cert.reads.find(r => r[1] === preRead[1] && stable(r[2]) === stable(preRead[2]));
|
|
183
|
+
if (previous) {
|
|
184
|
+
const terms = [[1, read[0]], [-1, previous[0]], [-1, c.v]], key = signature({ terms, unit: 0 });
|
|
185
|
+
if (!emitted.has(key)) {
|
|
186
|
+
if (out.length >= cap)
|
|
187
|
+
return out;
|
|
188
|
+
emitted.add(key);
|
|
189
|
+
out.push({ wit: fresh(), below: post.below, terms, unit: 0 });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
for (const sign of [1, -1]) {
|
|
194
|
+
if (out.length >= cap)
|
|
195
|
+
return out;
|
|
196
|
+
const terms = [[sign, read[0]], [-sign, c.v]], key = signature({ terms, unit: 0 });
|
|
197
|
+
if (emitted.has(key))
|
|
198
|
+
continue;
|
|
199
|
+
emitted.add(key);
|
|
200
|
+
out.push({ wit: fresh(), below: post.below, terms, unit: 0 });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Machine } from './machine.js';
|
|
2
|
+
import { type CountGuardShape } from './count-guard-shape.js';
|
|
3
|
+
export type CountThresholdWrite = {
|
|
4
|
+
source: string;
|
|
5
|
+
guard: string;
|
|
6
|
+
increment: 0 | 1;
|
|
7
|
+
input: string;
|
|
8
|
+
inputCount: string;
|
|
9
|
+
committedInput?: string;
|
|
10
|
+
committedCount?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function discoverCountThresholdWrite(m: Machine, shape: CountGuardShape, choice: {
|
|
13
|
+
name: string;
|
|
14
|
+
value: number;
|
|
15
|
+
}): CountThresholdWrite | undefined;
|