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,59 @@
|
|
|
1
|
+
// Untrusted equality proposals for a row count and an identical existing read.
|
|
2
|
+
// Both inequalities remain ordinary CountInst witnesses checked by checkMC.
|
|
3
|
+
import { substE } from "../kernel/kernel.js";
|
|
4
|
+
import { x } from "./machine.js";
|
|
5
|
+
import { countsForReads } from "./count-facts.js";
|
|
6
|
+
export function identicalRowCountAliases(decls, reads, rowMap, prefix, more = () => true) {
|
|
7
|
+
const counts = countsForReads(decls, reads);
|
|
8
|
+
if (!counts)
|
|
9
|
+
return [];
|
|
10
|
+
const rows = new Set(reads.filter(([, map]) => map === rowMap).map(([id]) => id)), pre = new Set(reads.filter(([, map]) => !map.endsWith('#')).map(([id]) => id));
|
|
11
|
+
const body = (c) => JSON.stringify([c.below, substE(c.body, { vars: { [c.key]: x(prefix + 'bound') }, maps: {}, flags: {} })]);
|
|
12
|
+
const out = [], seen = new Set();
|
|
13
|
+
for (const row of counts.filter(c => rows.has(c.v)))
|
|
14
|
+
for (const other of counts) {
|
|
15
|
+
if (!more() || out.length >= 8)
|
|
16
|
+
return out;
|
|
17
|
+
if (row.v === other.v || !pre.has(other.v) || body(row) !== body(other))
|
|
18
|
+
continue;
|
|
19
|
+
const pair = [row.v, other.v].sort().join('\n');
|
|
20
|
+
if (seen.has(pair))
|
|
21
|
+
continue;
|
|
22
|
+
seen.add(pair);
|
|
23
|
+
for (const [a, b] of [[row.v, other.v], [other.v, row.v]])
|
|
24
|
+
out.push({ wit: prefix + out.length, below: row.below, terms: [[1, a], [-1, b]], unit: 0 });
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
// Equality is only a proposal here. A missing restriction is NOT assumed:
|
|
29
|
+
// each signed difference still needs an ordinary counting witness refutation.
|
|
30
|
+
// This includes the election's threshold/not-newer restricted count, rather
|
|
31
|
+
// than trying to repair only a plain membership-row alias. Keep the nearest
|
|
32
|
+
// predicate slice: do not drop both the threshold and a not-newer restriction.
|
|
33
|
+
export function restrictedRowCountAliases(decls, reads, voteMap, prefix, more = () => true) {
|
|
34
|
+
const counts = countsForReads(decls, reads);
|
|
35
|
+
if (!counts)
|
|
36
|
+
return [];
|
|
37
|
+
const votes = new Set(reads.filter(([, map]) => map === voteMap).map(([id]) => id)), pre = new Set(reads.filter(([, map]) => !map.endsWith('#')).map(([id]) => id));
|
|
38
|
+
const atoms = (c) => c.op === 'and' ? c.xs.flatMap(atoms) : [c];
|
|
39
|
+
const body = (e) => e.op === 'if' && e.then.op === 'const' && e.then.value === 1 && e.else.op === 'const' && e.else.value === 0 ? new Set(atoms(e.c).map(c => JSON.stringify(c))) : undefined;
|
|
40
|
+
const normalized = (c) => body(substE(c.body, { vars: { [c.key]: x(prefix + 'bound') }, maps: {}, flags: {} }));
|
|
41
|
+
const out = [], seen = new Set();
|
|
42
|
+
for (const vote of counts.filter(c => votes.has(c.v)))
|
|
43
|
+
for (const other of counts) {
|
|
44
|
+
if (!more() || out.length >= 8)
|
|
45
|
+
return out;
|
|
46
|
+
if (vote.v === other.v || !pre.has(other.v) || JSON.stringify(vote.below) !== JSON.stringify(other.below))
|
|
47
|
+
continue;
|
|
48
|
+
const a = normalized(vote), b = normalized(other);
|
|
49
|
+
if (!a || !b || !b.size || a.size > b.size + 1 || ![...b].every(atom => a.has(atom)))
|
|
50
|
+
continue;
|
|
51
|
+
const pair = [vote.v, other.v].sort().join('\n');
|
|
52
|
+
if (seen.has(pair))
|
|
53
|
+
continue;
|
|
54
|
+
seen.add(pair);
|
|
55
|
+
for (const [left, right] of [[vote.v, other.v], [other.v, vote.v]])
|
|
56
|
+
out.push({ wit: prefix + out.length, below: vote.below, terms: [[1, left], [-1, right]], unit: 0 });
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type CountRequestBuilder, type CountStrategyProof, type CountStrategyOptions } from './count-strategy.js';
|
|
3
|
+
export declare function proveCountRowComposition(m: Machine, family: Law[], law: Law, until: number, requestFor: CountRequestBuilder, observe?: (event: Record<string, unknown>) => void, options?: CountStrategyOptions & {
|
|
4
|
+
framePremisesOnly?: boolean;
|
|
5
|
+
shapeFamily?: readonly Law[];
|
|
6
|
+
}): CountStrategyProof | undefined;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Optional versioned-row portfolio. All cases share the caller's deadline.
|
|
2
|
+
// STEP cases and INIT are proposals: only the final original-goal checker accepts them.
|
|
3
|
+
import { all, n, same, x } from "./machine.js";
|
|
4
|
+
import { finiteCountChoice } from "./count-cases.js";
|
|
5
|
+
import { traceNow } from "./trace-clock.js";
|
|
6
|
+
import { traceCountStage } from "./count-stage-trace.js";
|
|
7
|
+
import { countCertificateSize } from "./count-certificate-minimize.js";
|
|
8
|
+
import { discoverCountGuardShape } from "./count-guard-shape.js";
|
|
9
|
+
import { discoverCountRowCopy } from "./count-copy-shape.js";
|
|
10
|
+
import { discoverRowAgreement } from "./row-agreement-shape.js";
|
|
11
|
+
import { proveRowAgreementCase, proposeRowAgreementInitial, rowAgreementWrittenKeys } from "./count-row-agreement.js";
|
|
12
|
+
import { classifyRowValueWrite } from "./count-row-policy.js";
|
|
13
|
+
import { rowCountSupport } from "./count-row-support.js";
|
|
14
|
+
import { composeCountOperationProofs } from "./count-case-compose.js";
|
|
15
|
+
import { clock, fullRate, fullWork, late, withDeadline } from "../kernel/prove.js";
|
|
16
|
+
export function proveCountRowComposition(m, family, law, until, requestFor, observe, options = {}) {
|
|
17
|
+
return withDeadline(until, () => {
|
|
18
|
+
if (late(until))
|
|
19
|
+
return;
|
|
20
|
+
const row = discoverRowAgreement(m, law), choice = finiteCountChoice(m);
|
|
21
|
+
if (!row || !choice)
|
|
22
|
+
return;
|
|
23
|
+
// Shape inventory is construction metadata only. All proof hypotheses, seed
|
|
24
|
+
// instances and returned citations still come from the attempted family.
|
|
25
|
+
const shapeFamily = options.shapeFamily ?? family;
|
|
26
|
+
const shapes = shapeFamily.flatMap(l => { const s = discoverCountGuardShape(m, l, shapeFamily); return s?.membershipMap === row.map ? [s] : []; });
|
|
27
|
+
if (!shapes.length)
|
|
28
|
+
return;
|
|
29
|
+
const planned = traceCountStage(observe, 'row-plan', 'untrusted-assembly', () => [...choice[1]].map(value => {
|
|
30
|
+
const machine = { ...m, assume: all(...(m.assume ? [m.assume] : []), same(x(choice[0]), n(value))) }, support = traceCountStage(observe, 'row-plan-support-' + value, 'untrusted-assembly', () => rowCountSupport(machine, family, law, row, until));
|
|
31
|
+
const kind = !rowAgreementWrittenKeys(machine, row).length ? 'frame' : support ? 'leader' : shapes.some(shape => discoverCountRowCopy(machine, shape, { name: choice[0], value })) ? 'copy' : classifyRowValueWrite(machine, row) ?? 'replacement';
|
|
32
|
+
return { value, machine, support, kind };
|
|
33
|
+
}));
|
|
34
|
+
const rank = { leader: 0, copy: 1, load: 2, replacement: 3, frame: 4 };
|
|
35
|
+
planned.sort((a, b) => rank[a.kind] - rank[b.kind] || a.value - b.value);
|
|
36
|
+
observe?.({ stage: 'plan', cases: planned.map(({ value, kind }) => ({ value, kind })) });
|
|
37
|
+
const cases = [];
|
|
38
|
+
for (const { value, machine, support, kind } of planned) {
|
|
39
|
+
if (late(until))
|
|
40
|
+
return;
|
|
41
|
+
const start = fullWork(), wall = traceNow();
|
|
42
|
+
const proof = proveRowAgreementCase(machine, family, law, row, until, support?.request ?? requestFor, { ...support?.options, leafUnits: options.leafUnits, sparseOwn: true, symmetryReuse: true, premiseScoped: kind === 'copy', operationPath: kind === 'frame' || kind === 'load' || kind === 'leader' || kind === 'copy', diagonalAlias: kind === 'copy' || kind === 'leader', framePremisesOnly: options.framePremisesOnly && kind === 'frame', deferToComposition: true, deferRowChecks: options.deferRowChecks, tailTrace: observe ? event => observe({ operation: value, kind, ...event }) : undefined, trace: observe ? event => observe({ stage: 'query', operation: value, kind, ...event }) : undefined, observe: leaf => observe?.({ stage: 'leaf', outcome: leaf.outcome, hyps: leaf.goal.hyps.length, units: leaf.units, wallMs: leaf.wallMs, operation: value, kind, method: leaf.method, ...(!['proved', 'unchecked-proposal'].includes(leaf.outcome) ? { goal: leaf.goal, path: [...leaf.path.values()] } : {}) }) });
|
|
43
|
+
observe?.({ stage: 'operation', value, kind, proposed: !!proof, checked: false, ...(proof?.status ? { status: proof.status } : {}), units: (fullWork() - start) / fullRate, wallMs: traceNow() - wall, remaining: until - clock(), ...(proof ? { size: countCertificateSize(proof.certs[law.name + ' @step']) } : {}) });
|
|
44
|
+
if (!proof)
|
|
45
|
+
return;
|
|
46
|
+
cases.push({ value, proof });
|
|
47
|
+
}
|
|
48
|
+
if (late(until))
|
|
49
|
+
return;
|
|
50
|
+
const initial = traceCountStage(observe, 'initial-proposal', 'untrusted-search', () => proposeRowAgreementInitial(m, family, law, until, requestFor));
|
|
51
|
+
if (!initial)
|
|
52
|
+
return;
|
|
53
|
+
return composeCountOperationProofs({ original: m, machine: m, shape: shapes[0], restrictions: [], inputCounts: {} }, family, law, cases, until, requestFor, (stage, value) => observe?.({ stage, value }), { initial, trace: observe, minimize: options.minimize, reindexFactsOnly: options.reindexFactsOnly, familyProposal: options.familyProposal });
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type CountRequestBuilder, type CountStrategyProof, type CountStrategyOptions } from './count-strategy.js';
|
|
3
|
+
import { type Instances } from '../kernel/kernel.js';
|
|
4
|
+
export declare function proveCountRowCopyLinear(m: Machine, family: Law[], law: Law, seed: Instances, until: number, requestFor: CountRequestBuilder, observe?: (stage: string, checked: boolean) => void, options?: CountStrategyOptions): CountStrategyProof | undefined;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Pointwise, ordinary checked alternative to the global row-copy witnesses.
|
|
2
|
+
// A failed auxiliary proof declines; neither discovery nor a candidate is trusted.
|
|
3
|
+
import { all, n, not, same, x } from "./machine.js";
|
|
4
|
+
import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
|
|
5
|
+
import { discoverCountGuardShape } from "./count-guard-shape.js";
|
|
6
|
+
import { discoverCountRowCopy } from "./count-copy-shape.js";
|
|
7
|
+
import { countsForReads } from "./count-facts.js";
|
|
8
|
+
import { countPrimitiveUnits } from "./count-primitive-budget.js";
|
|
9
|
+
import { guardLinearFact } from "./count-guard-facts.js";
|
|
10
|
+
import { countGuardTree } from "./count-guard-tree.js";
|
|
11
|
+
import { finishCountStrategy } from "./count-strategy.js";
|
|
12
|
+
import { add, k, scale, solve } from "./solver.js";
|
|
13
|
+
import { countedObligations, frameOk, framePath, mcGoal, truth } from "../kernel/kernel.js";
|
|
14
|
+
import { clock, late, rowsAt, withDeadline } from "../kernel/prove.js";
|
|
15
|
+
export function proveCountRowCopyLinear(m, family, law, seed, until, requestFor, observe, options = {}) {
|
|
16
|
+
return withDeadline(until, () => {
|
|
17
|
+
if (late(until) || !family.includes(law))
|
|
18
|
+
return;
|
|
19
|
+
const shape = discoverCountGuardShape(m, law, family), choice = fixedCountFrameCase(m);
|
|
20
|
+
if (!shape || !choice)
|
|
21
|
+
return;
|
|
22
|
+
const copy = discoverCountRowCopy(m, shape, choice), active = copy && m.step.flags?.[copy.guard];
|
|
23
|
+
if (!copy || !active || active.op === 'all')
|
|
24
|
+
return;
|
|
25
|
+
const from = x(copy.from), to = x(copy.to), a = x(law.forall + '#'), b = x(law.keys[0]), pairs = [[a, b], [a, from], [from, b], [from, from]], instances = { ...ownCountLawInstance(law, seed) };
|
|
26
|
+
const unique = new Map(), old = instances[law.name] ?? [];
|
|
27
|
+
for (let i = 0; i < old.length; i += 2)
|
|
28
|
+
unique.set(JSON.stringify(old.slice(i, i + 2)), old.slice(i, i + 2));
|
|
29
|
+
for (const pair of pairs)
|
|
30
|
+
unique.set(JSON.stringify(pair), pair);
|
|
31
|
+
instances[law.name] = [...unique.values()].flat();
|
|
32
|
+
const step = countedObligations(m, family, { [law.name]: instances }, family.indexOf(law)).at(-1);
|
|
33
|
+
if (!step)
|
|
34
|
+
return;
|
|
35
|
+
const base = requestFor(step.goal, step.decls), reads = base.reads, counts = countsForReads(step.decls, reads);
|
|
36
|
+
if (!counts)
|
|
37
|
+
return;
|
|
38
|
+
const key = (p, q) => q ? { op: 'add', a: { op: 'mul', k: shape.width, a: p }, b: q } : p;
|
|
39
|
+
const read = (map, key) => reads.find(r => r[1] === map && JSON.stringify(r[2]) === JSON.stringify(key))?.[0];
|
|
40
|
+
const postVote = read(shape.voteMap + '#', key(a, b)), postRow = read(shape.rowMap + '#', a), bound = counts.find(c => c.v === postVote)?.below;
|
|
41
|
+
const votes = pairs.map(([p, q]) => read(shape.voteMap, key(p, q))), rows = [a, from].map(p => read(shape.rowMap, p));
|
|
42
|
+
if (!postVote || !postRow || !bound || votes.some(r => !r) || rows.some(r => !r))
|
|
43
|
+
return;
|
|
44
|
+
const operation = same(x(choice.name), n(choice.value)), domain = all(...[a, b, from, to].flatMap(t => [{ op: '<', a: t, b: bound }, { op: '<', a: t, b: n(shape.width) }])), regions = [[not(same(a, to)), not(same(b, to))], [not(same(a, to)), same(b, to)], [same(a, to), not(same(b, to))], [same(a, to), same(b, to)]];
|
|
45
|
+
const when = [...(m.pre ? [m.pre] : []), operation, domain, active], proposals = votes.map((pre, i) => ({ name: 'copy voter inclusion ' + i, kind: 'pointwise-copy', when: [...when, ...regions[i]], terms: [[1, postVote], [-1, pre]] }));
|
|
46
|
+
rows.forEach((pre, i) => proposals.push({ name: 'copy row lower bound ' + i, kind: 'pointwise-copy', when: [...when, i ? same(a, to) : not(same(a, to))], terms: [[1, pre], [-1, postRow]] }));
|
|
47
|
+
const lins = [];
|
|
48
|
+
for (const proposal of proposals) {
|
|
49
|
+
if (late(until))
|
|
50
|
+
return;
|
|
51
|
+
const fact = guardLinearFact(step.decls, reads, proposal, Math.min(until, clock() + countPrimitiveUnits(Infinity, options.leafUnits)));
|
|
52
|
+
observe?.(proposal.name, !!fact);
|
|
53
|
+
if (!fact)
|
|
54
|
+
return;
|
|
55
|
+
lins.push(fact.cut);
|
|
56
|
+
}
|
|
57
|
+
const request = { reads, insts: [], picks: [], lins }, goal = mcGoal(step.goal.hyps, step.decls, request);
|
|
58
|
+
if (!goal)
|
|
59
|
+
return;
|
|
60
|
+
const frames = [], ask = (path, frame = false, stage = 'active-region') => {
|
|
61
|
+
if (late(until))
|
|
62
|
+
return;
|
|
63
|
+
if (frame)
|
|
64
|
+
for (const map of [shape.voteMap, shape.rowMap]) {
|
|
65
|
+
const post = read(map + '#', map === shape.rowMap ? a : key(a, b)), pre = read(map, map === shape.rowMap ? a : key(a, b));
|
|
66
|
+
if (!post || !pre)
|
|
67
|
+
return;
|
|
68
|
+
const cut = { post, pre, when: [...path.values()].map(t => t.holds ? t.lin : add(scale(t.lin, -1), k(1))) };
|
|
69
|
+
if (frameOk(counts, cut))
|
|
70
|
+
frames.push(cut);
|
|
71
|
+
}
|
|
72
|
+
const result = solve(rowsAt(goal, framePath(frames, [], path, [], lins)), 2000);
|
|
73
|
+
if (result.kind !== 'refuted')
|
|
74
|
+
observe?.('close:' + stage + ':' + result.kind + ':' + JSON.stringify({ frames: frames.length, activeCuts: lins.map(l => l.when.map(c => truth(c, path))), path: [...path.values()] }), false);
|
|
75
|
+
return result.kind === 'refuted' ? { leaf: result.steps } : undefined;
|
|
76
|
+
};
|
|
77
|
+
const split = countGuardTree(until), region = (path) => split.condition(same(a, to), path, p => split.condition(same(b, to), p, q => ask(q), q => ask(q)), p => split.condition(same(b, to), p, q => ask(q), q => ask(q)));
|
|
78
|
+
const body = (path) => split.rows(countFrameConditions(choice), path, p => split.condition(domain, p, q => split.condition(active, q, region, q => ask(q, true, 'inactive')), q => ask(q, false, 'outside-domain')), q => ask(q, false, 'outside-operation'));
|
|
79
|
+
const tree = m.pre ? split.condition(m.pre, new Map(), body, p => ask(p, false, 'outside-precondition')) : body(new Map());
|
|
80
|
+
observe?.('whole-step-tree', !!tree);
|
|
81
|
+
return tree ? finishCountStrategy(m, family, law, instances, shape.voteMap, { ...request, frames, tree }, until, requestFor, undefined, options) : undefined;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type CountRequestBuilder, type CountStrategyProof, type CountStrategyOptions } from './count-strategy.js';
|
|
3
|
+
import { type Instances } from '../kernel/kernel.js';
|
|
4
|
+
export declare function proveCountRowCopy(m: Machine, family: Law[], law: Law, seed: Instances, until: number, requestFor: CountRequestBuilder, options?: CountStrategyOptions): CountStrategyProof | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Optional structural row-copy proof. Selection and slicing are untrusted;
|
|
2
|
+
// every leaf is transported back and checked on the complete count goal.
|
|
3
|
+
import { x, n, same, atMost, walkOnce } from "./machine.js";
|
|
4
|
+
import { countsForReads } from "./count-facts.js";
|
|
5
|
+
import { countPrimitiveUnits } from "./count-primitive-budget.js";
|
|
6
|
+
import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
|
|
7
|
+
import { discoverCountGuardShape } from "./count-guard-shape.js";
|
|
8
|
+
import { discoverCountRowCopy } from "./count-copy-shape.js";
|
|
9
|
+
import { countGuardTree } from "./count-guard-tree.js";
|
|
10
|
+
import { finishCountStrategy, strategyLeafUntil } from "./count-strategy.js";
|
|
11
|
+
import { add, k, scale, solve } from "./solver.js";
|
|
12
|
+
import { countedObligations, frameOk, framePath, mcGoal } from "../kernel/kernel.js";
|
|
13
|
+
import { growCdcl } from "../kernel/cdcl.js";
|
|
14
|
+
import { clock, pastWall, rowsAt, withDeadline } from "../kernel/prove.js";
|
|
15
|
+
import { rebasePath } from "./count-recovery/rebase-path.js";
|
|
16
|
+
export function proveCountRowCopy(m, family, law, seed, until, requestFor, options = {}) {
|
|
17
|
+
return withDeadline(until, () => {
|
|
18
|
+
if (clock() >= until || pastWall() || !family.includes(law))
|
|
19
|
+
return;
|
|
20
|
+
const shape = discoverCountGuardShape(m, law, family), choice = fixedCountFrameCase(m);
|
|
21
|
+
if (!shape || !choice)
|
|
22
|
+
return;
|
|
23
|
+
const copy = discoverCountRowCopy(m, shape, choice);
|
|
24
|
+
if (!copy)
|
|
25
|
+
return;
|
|
26
|
+
const from = x(copy.from), to = x(copy.to), a = x(law.forall + '#'), b = x(law.keys[0]);
|
|
27
|
+
const pairs = [[a, b], [a, from], [from, b], [from, from]], instances = { ...ownCountLawInstance(law, seed) };
|
|
28
|
+
const old = instances[law.name] ?? [], unique = new Map();
|
|
29
|
+
for (let i = 0; i < old.length; i += 2)
|
|
30
|
+
unique.set(JSON.stringify(old.slice(i, i + 2)), old.slice(i, i + 2));
|
|
31
|
+
for (const pair of pairs)
|
|
32
|
+
unique.set(JSON.stringify(pair), pair);
|
|
33
|
+
instances[law.name] = [...unique.values()].flat();
|
|
34
|
+
const step = countedObligations(m, family, { [law.name]: instances }, family.indexOf(law)).at(-1);
|
|
35
|
+
if (!step)
|
|
36
|
+
return;
|
|
37
|
+
const base = requestFor(step.goal, step.decls), reads = base.reads, counts = countsForReads(step.decls, reads);
|
|
38
|
+
if (!counts)
|
|
39
|
+
return;
|
|
40
|
+
const { voteMap, rowMap, width } = shape, key = (p, q) => q ? { op: 'add', a: { op: 'mul', k: width, a: p }, b: q } : p;
|
|
41
|
+
const read = (map, key) => reads.find(r => r[1] === map && JSON.stringify(r[2]) === JSON.stringify(key))?.[0];
|
|
42
|
+
const postVote = read(voteMap + '#', key(a, b)), postRow = read(rowMap + '#', a), bound = counts.find(c => c.v === postVote)?.below;
|
|
43
|
+
const voteReads = pairs.map(([p, q]) => read(voteMap, key(p, q))), rowReads = [a, from].map(p => read(rowMap, p));
|
|
44
|
+
if (!postVote || !postRow || !bound || voteReads.some(r => !r) || rowReads.some(r => !r))
|
|
45
|
+
return;
|
|
46
|
+
const scope = JSON.stringify([m, family, seed, reads]), names = [];
|
|
47
|
+
for (let i = 0; names.length < 6; i++) {
|
|
48
|
+
const name = `rowCopy$${i}`;
|
|
49
|
+
if (!scope.includes(JSON.stringify(name)))
|
|
50
|
+
names.push(name);
|
|
51
|
+
}
|
|
52
|
+
const voters = voteReads.map((r, i) => ({ wit: names[i], below: bound, terms: [[1, postVote], [-1, r]], unit: 0 }));
|
|
53
|
+
const rows = rowReads.map((r, i) => ({ wit: names[4 + i], below: bound, terms: [[1, r], [-1, postRow]], unit: 0 }));
|
|
54
|
+
const request = { reads, insts: [...voters, ...rows], picks: [] }, goal = mcGoal(step.goal.hyps, step.decls, request);
|
|
55
|
+
if (!goal)
|
|
56
|
+
return;
|
|
57
|
+
const frames = [], active = m.step.flags?.[copy.guard];
|
|
58
|
+
if (!active || active.op === 'all')
|
|
59
|
+
return;
|
|
60
|
+
const ask = (path, index, frame = false) => {
|
|
61
|
+
if (clock() >= until || pastWall())
|
|
62
|
+
return;
|
|
63
|
+
if (frame)
|
|
64
|
+
for (const map of [voteMap, rowMap]) {
|
|
65
|
+
const post = read(map + '#', map === rowMap ? a : key(a, b)), pre = read(map, map === rowMap ? a : key(a, b));
|
|
66
|
+
if (!post || !pre)
|
|
67
|
+
return;
|
|
68
|
+
const cut = { post, pre, when: [...path.values()].map(t => t.holds ? t.lin : add(scale(t.lin, -1), k(1))) };
|
|
69
|
+
if (frameOk(counts, cut))
|
|
70
|
+
frames.push(cut);
|
|
71
|
+
}
|
|
72
|
+
const p = framePath(frames, [], path), selected = reads.find(r => r[0] === voters[index].terms[1][1]);
|
|
73
|
+
const hyps = step.goal.hyps.filter(h => { let unrelated = false; walkOnce(h, (z) => { if (z.op === 'get' && z.map === voteMap && JSON.stringify(z.key) !== JSON.stringify(selected[2]))
|
|
74
|
+
unrelated = true; }); return !unrelated; });
|
|
75
|
+
const view = mcGoal(hyps, step.decls, { ...request, insts: [voters[index], rows[index >= 2 ? 1 : 0]] });
|
|
76
|
+
if (!view)
|
|
77
|
+
return;
|
|
78
|
+
const direct = solve(rowsAt(goal, p), 1000);
|
|
79
|
+
// Intermediate trees are proposals. finishCountStrategy checks the whole
|
|
80
|
+
// original-goal certificate once; do not repeat that work at every leaf.
|
|
81
|
+
if (direct.kind === 'refuted')
|
|
82
|
+
return { leaf: direct.steps };
|
|
83
|
+
const result = growCdcl(view, p, { nodes: 0, until: Math.min(strategyLeafUntil(until, options), clock() + countPrimitiveUnits(1000, options.leafUnits)) });
|
|
84
|
+
const lifted = 'tree' in result ? rebasePath(view, result.tree, p, p, Math.min(strategyLeafUntil(until, options), clock() + countPrimitiveUnits(500, options.leafUnits)), goal) : undefined;
|
|
85
|
+
return lifted;
|
|
86
|
+
};
|
|
87
|
+
const split = countGuardTree(until);
|
|
88
|
+
const domain = { op: 'and', xs: [a, b, from, to].flatMap(t => [{ op: '<', a: t, b: bound }, { op: '<', a: t, b: n(width) }]) };
|
|
89
|
+
const regions = (p) => split.condition(same(a, to), p, q => split.condition(same(b, to), q, r => ask(r, 3), r => ask(r, 2)), q => split.condition(same(b, to), q, r => ask(r, 1), r => ask(r, 0)));
|
|
90
|
+
const copies = (p) => split.condition(atMost(to, from), p, regions, regions);
|
|
91
|
+
const tree = split.rows(countFrameConditions(choice), new Map(), p => split.condition(domain, p, q => split.condition(active, q, copies, q => ask(q, 0, true)), q => ask(q, 0)), p => ask(p, 0));
|
|
92
|
+
return tree ? finishCountStrategy(m, family, law, instances, voteMap, { ...request, frames, tree }, until, requestFor, undefined, options) : undefined;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Scheduling hints only. Every selected strategy must still prove its result.
|
|
2
|
+
import { n, same, walkOnce, x } from "./machine.js";
|
|
3
|
+
import { countFrameConditions, fixedCountFrameCase } from "./count-frames.js";
|
|
4
|
+
import { canon, cellParts, isCell, linear, substC, truth } from "../kernel/kernel.js";
|
|
5
|
+
export function classifyRowValueWrite(m, row) {
|
|
6
|
+
const choice = fixedCountFrameCase(m);
|
|
7
|
+
if (!choice)
|
|
8
|
+
return;
|
|
9
|
+
const path = new Map(countFrameConditions(choice).map(lin => [canon(lin), { lin, holds: true }]));
|
|
10
|
+
// A scheduling-only evaluation: the checked proof still receives the original machine.
|
|
11
|
+
const vars = { [choice.name]: n(choice.value) }, flags = Object.create(null);
|
|
12
|
+
for (const [name, c] of Object.entries(m.step.flags ?? {}))
|
|
13
|
+
flags[name] = c.op === 'all' ? same(x('?' + name), n(1)) : substC(c, { vars, maps: {}, flags });
|
|
14
|
+
const foreignRead = (value) => {
|
|
15
|
+
let loaded = false;
|
|
16
|
+
walkOnce(value, (node) => { if (node.op === 'get' && node.map !== row.map && Object.hasOwn(m.maps ?? {}, node.map))
|
|
17
|
+
loaded = true; });
|
|
18
|
+
return loaded;
|
|
19
|
+
};
|
|
20
|
+
// Boolean maps compile data selection into the condition of a 1/0 indicator.
|
|
21
|
+
// Ignore decided Boolean branches before looking for a data-source read.
|
|
22
|
+
const unresolvedRead = (c, match) => {
|
|
23
|
+
if (truth(c, path) !== undefined)
|
|
24
|
+
return false;
|
|
25
|
+
if (c.op === 'and' || c.op === 'or')
|
|
26
|
+
return c.xs.some(child => unresolvedRead(child, match));
|
|
27
|
+
if (c.op === 'not')
|
|
28
|
+
return unresolvedRead(c.x, match);
|
|
29
|
+
return match(c);
|
|
30
|
+
};
|
|
31
|
+
const active = (e, predicate, indicatorReads = false, indicatorMatch = foreignRead) => {
|
|
32
|
+
if (e.op !== 'if')
|
|
33
|
+
return predicate(e);
|
|
34
|
+
const condition = substC(e.c, { vars, maps: {}, flags }), known = truth(condition, path);
|
|
35
|
+
const indicator = e.then.op === 'const' && e.else.op === 'const' && e.then.value !== e.else.value && [0, 1].includes(e.then.value) && [0, 1].includes(e.else.value);
|
|
36
|
+
return indicatorReads && indicator && unresolvedRead(condition, indicatorMatch) || known !== false && active(e.then, predicate, indicatorReads, indicatorMatch) || known !== true && active(e.else, predicate, indicatorReads, indicatorMatch);
|
|
37
|
+
};
|
|
38
|
+
for (const field of row.fields) {
|
|
39
|
+
const write = m.step.maps?.[field];
|
|
40
|
+
if (!write || !('each' in write))
|
|
41
|
+
continue;
|
|
42
|
+
if (active(write.value, e => {
|
|
43
|
+
const value = linear(e, path), terms = value && Object.entries(value).filter(([name, k]) => name !== '1' && k !== 0);
|
|
44
|
+
return !!value && value['1'] === 1 && terms?.length === 1 && terms[0][1] === 1 && isCell(terms[0][0]) && cellParts(terms[0][0]).map === field;
|
|
45
|
+
}))
|
|
46
|
+
return 'replacement';
|
|
47
|
+
}
|
|
48
|
+
const write = m.step.maps?.[row.map];
|
|
49
|
+
if (!write)
|
|
50
|
+
return;
|
|
51
|
+
const carriedRead = (value) => { let carried = false; walkOnce(value, (node) => { if (node.op === 'get' && m.inputMaps?.includes(node.map))
|
|
52
|
+
carried = true; }); return carried; };
|
|
53
|
+
if (active(write.value, carriedRead, true, carriedRead))
|
|
54
|
+
return 'replacement';
|
|
55
|
+
return active(write.value, foreignRead, true) ? 'load' : undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Goal, type Tree } from '../kernel/kernel.js';
|
|
2
|
+
import { type Constraint } from './solver.js';
|
|
3
|
+
export type CountReindexStats = {
|
|
4
|
+
hits: number;
|
|
5
|
+
layouts: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function countRowReindexer(target: Goal, options?: {
|
|
8
|
+
offsets?: boolean;
|
|
9
|
+
stats?: CountReindexStats;
|
|
10
|
+
}): (source: Goal, before: Constraint[], after: Constraint[]) => (i: number) => number | undefined;
|
|
11
|
+
export declare function operationRefutation(rows: Constraint[], operation: string): Tree | undefined;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Untrusted row transport. Exact mode checks every chosen linear form. Offset
|
|
2
|
+
// mode lazily caches demanded indices per source/layout and verifies each reused
|
|
3
|
+
// row against its current form. The enclosing complete checker still owns acceptance.
|
|
4
|
+
import { canon } from "../kernel/kernel.js";
|
|
5
|
+
export function countRowReindexer(target, options = {}) {
|
|
6
|
+
const layouts = new WeakMap();
|
|
7
|
+
const ids = new WeakMap(), hypotheses = new Map(), sources = new WeakMap();
|
|
8
|
+
const groups = new WeakMap(), all = new WeakMap();
|
|
9
|
+
const id = (row) => { let key = ids.get(row); if (key === undefined) {
|
|
10
|
+
key = canon(row);
|
|
11
|
+
ids.set(row, key);
|
|
12
|
+
} return key; };
|
|
13
|
+
for (const [i, h] of target.hyps.entries()) {
|
|
14
|
+
const key = JSON.stringify(h);
|
|
15
|
+
if (!hypotheses.has(key))
|
|
16
|
+
hypotheses.set(key, i);
|
|
17
|
+
}
|
|
18
|
+
const tag = (row, remap) => {
|
|
19
|
+
const source = row.src;
|
|
20
|
+
if (!source)
|
|
21
|
+
return;
|
|
22
|
+
if ('fact' in source) {
|
|
23
|
+
const i = remap ? remap.get(source.fact) : source.fact;
|
|
24
|
+
return i === undefined ? undefined : 'f:' + i;
|
|
25
|
+
}
|
|
26
|
+
if ('atom' in source)
|
|
27
|
+
return 'a';
|
|
28
|
+
if ('nat' in source)
|
|
29
|
+
return 'n:' + source.nat;
|
|
30
|
+
if ('term' in source)
|
|
31
|
+
return 't:' + source.term;
|
|
32
|
+
return 'p:' + JSON.stringify(source.pair);
|
|
33
|
+
};
|
|
34
|
+
return (source, before, after) => {
|
|
35
|
+
let remap = sources.get(source);
|
|
36
|
+
if (!remap) {
|
|
37
|
+
remap = new Map();
|
|
38
|
+
for (const [i, h] of source.hyps.entries()) {
|
|
39
|
+
const found = hypotheses.get(JSON.stringify(h));
|
|
40
|
+
if (found !== undefined)
|
|
41
|
+
remap.set(i, found);
|
|
42
|
+
}
|
|
43
|
+
sources.set(source, remap);
|
|
44
|
+
}
|
|
45
|
+
const key = options.offsets ? JSON.stringify([before.map(r => tag(r, remap) ?? null), after.map(r => tag(r) ?? null)]) : undefined;
|
|
46
|
+
let cache = layouts.get(source);
|
|
47
|
+
const cached = key === undefined ? undefined : cache?.get(key);
|
|
48
|
+
if (cached && options.stats)
|
|
49
|
+
options.stats.hits++;
|
|
50
|
+
const exact = (i) => {
|
|
51
|
+
if (!Number.isSafeInteger(i) || i < 0)
|
|
52
|
+
return;
|
|
53
|
+
if (i >= before.length)
|
|
54
|
+
return i - before.length + after.length; // appended product rows
|
|
55
|
+
let byTag = groups.get(after);
|
|
56
|
+
if (!byTag) {
|
|
57
|
+
byTag = new Map();
|
|
58
|
+
after.forEach((row, index) => { const name = tag(row); if (name !== undefined) {
|
|
59
|
+
const list = byTag.get(name) ?? [];
|
|
60
|
+
list.push(index);
|
|
61
|
+
byTag.set(name, list);
|
|
62
|
+
} });
|
|
63
|
+
groups.set(after, byTag);
|
|
64
|
+
}
|
|
65
|
+
const row = before[i], key = id(row.lin), origin = tag(row, remap);
|
|
66
|
+
for (const j of origin === undefined ? [] : byTag.get(origin) ?? [])
|
|
67
|
+
if (id(after[j].lin) === key)
|
|
68
|
+
return j;
|
|
69
|
+
// A changed assumption can yield the same row through a path atom or a
|
|
70
|
+
// different hypothesis. This fallback is still exact, with no solver.
|
|
71
|
+
let fallback = all.get(after);
|
|
72
|
+
if (!fallback) {
|
|
73
|
+
fallback = new Map();
|
|
74
|
+
after.forEach((r, j) => { const k = id(r.lin); if (!fallback.has(k))
|
|
75
|
+
fallback.set(k, j); });
|
|
76
|
+
all.set(after, fallback);
|
|
77
|
+
}
|
|
78
|
+
return fallback.get(key);
|
|
79
|
+
};
|
|
80
|
+
if (key === undefined)
|
|
81
|
+
return exact;
|
|
82
|
+
const indices = cached ?? [];
|
|
83
|
+
if (!cached) {
|
|
84
|
+
if (!cache) {
|
|
85
|
+
cache = new Map();
|
|
86
|
+
layouts.set(source, cache);
|
|
87
|
+
}
|
|
88
|
+
if (cache.size >= 64)
|
|
89
|
+
cache.delete(cache.keys().next().value);
|
|
90
|
+
cache.set(key, indices);
|
|
91
|
+
if (options.stats)
|
|
92
|
+
options.stats.layouts++;
|
|
93
|
+
}
|
|
94
|
+
return (i) => {
|
|
95
|
+
if (!Number.isSafeInteger(i) || i < 0)
|
|
96
|
+
return;
|
|
97
|
+
if (i >= before.length)
|
|
98
|
+
return i - before.length + after.length;
|
|
99
|
+
const previous = indices[i];
|
|
100
|
+
if (previous !== undefined && after[previous] && id(before[i].lin) === id(after[previous].lin))
|
|
101
|
+
return previous;
|
|
102
|
+
return indices[i] = exact(i);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// The missing operation branches are contradictory interval bounds. Emit
|
|
107
|
+
// their two-input linear derivation directly; decline any other shape.
|
|
108
|
+
export function operationRefutation(rows, operation) {
|
|
109
|
+
let upper, lower;
|
|
110
|
+
for (const [index, row] of rows.entries()) {
|
|
111
|
+
const names = Object.keys(row.lin).filter(name => name !== '1' && row.lin[name] !== 0), constant = row.lin['1'] ?? 0;
|
|
112
|
+
if (!Number.isSafeInteger(constant))
|
|
113
|
+
continue;
|
|
114
|
+
if (!names.length && constant > 0)
|
|
115
|
+
return { leaf: [{ kind: 'input', index }] };
|
|
116
|
+
if (names.length !== 1 || names[0] !== operation)
|
|
117
|
+
continue;
|
|
118
|
+
if (row.lin[operation] === 1 && (!upper || constant > upper.constant))
|
|
119
|
+
upper = { index, constant };
|
|
120
|
+
if (row.lin[operation] === -1 && (!lower || constant > lower.constant))
|
|
121
|
+
lower = { index, constant };
|
|
122
|
+
}
|
|
123
|
+
if (upper && lower && upper.constant + lower.constant > 0)
|
|
124
|
+
return { leaf: [{ kind: 'input', index: upper.index }, { kind: 'input', index: lower.index }, { kind: 'combine', a: 0, b: 1, ma: 1, mb: 1 }] };
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type RowAgreementShape } from './row-agreement-shape.js';
|
|
3
|
+
import { type RowAgreementOptions } from './count-row-agreement.js';
|
|
4
|
+
import { type CountRequestBuilder } from './count-strategy.js';
|
|
5
|
+
export declare function rowCountSupport(m: Machine, family: Law[], target: Law, row: RowAgreementShape, until: number): {
|
|
6
|
+
options: RowAgreementOptions;
|
|
7
|
+
request: CountRequestBuilder;
|
|
8
|
+
report: unknown;
|
|
9
|
+
} | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// An untrusted strategy request: instantiate an existing PRE count law,
|
|
2
|
+
// then propose ordinary inclusion witnesses. No scalar guard is asserted.
|
|
3
|
+
import { x } from "./machine.js";
|
|
4
|
+
import { fixedCountFrameCase } from "./count-frames.js";
|
|
5
|
+
import { discoverCountGuardShape } from "./count-guard-shape.js";
|
|
6
|
+
import { discoverCountThresholdWrite } from "./count-write-shape.js";
|
|
7
|
+
import { memberInclusions } from "./count-recovery/member-inclusions.js";
|
|
8
|
+
import { certFor } from "./counts.js";
|
|
9
|
+
import { clock } from "../kernel/prove.js";
|
|
10
|
+
import { identicalRowCountAliases, restrictedRowCountAliases } from "./count-row-aliases.js";
|
|
11
|
+
export function rowCountSupport(m, family, target, row, until) {
|
|
12
|
+
const choice = fixedCountFrameCase(m);
|
|
13
|
+
if (!choice || !target.forall || target.keys?.length !== 2)
|
|
14
|
+
return;
|
|
15
|
+
const matches = family.flatMap(law => {
|
|
16
|
+
const shape = discoverCountGuardShape(m, law, family);
|
|
17
|
+
if (!shape || shape.membershipMap !== row.map || !row.fields.includes(shape.thresholdField))
|
|
18
|
+
return [];
|
|
19
|
+
const write = discoverCountThresholdWrite(m, shape, choice);
|
|
20
|
+
return write?.increment === 1 ? [{ law, shape, write }] : [];
|
|
21
|
+
});
|
|
22
|
+
// Prefer the most restricted vote predicate, never its weaker base law.
|
|
23
|
+
// The election witness must prove every restriction; unrelated roots decline.
|
|
24
|
+
const roots = matches.filter(match => !matches.some(other => other.shape.weakerLaw === match.law));
|
|
25
|
+
if (roots.length !== 1)
|
|
26
|
+
return;
|
|
27
|
+
const { law, shape, write } = roots[0], report = { law: law.name, shape, write, inclusionCounts: [], aliasCounts: [] };
|
|
28
|
+
const seedInstances = { [law.name]: [x(write.source), x(target.forall + '#'), x(write.source), x(target.keys[0])] };
|
|
29
|
+
const scope = JSON.stringify([m, family]);
|
|
30
|
+
let prefix = 'rowCountWitness$';
|
|
31
|
+
while (scope.includes(prefix))
|
|
32
|
+
prefix += '$';
|
|
33
|
+
const request = (goal, decls) => {
|
|
34
|
+
const base = certFor(goal, decls, false, 0, () => clock() < until);
|
|
35
|
+
const inclusions = memberInclusions(m, decls, base.reads, () => clock() < until).filter(p => p.carried === write.input && base.reads.some(r => r[0] === p.negative && r[1] === shape.voteMap)).slice(0, 8);
|
|
36
|
+
const aliases = [...restrictedRowCountAliases(decls, base.reads, shape.voteMap, prefix + 'voteAlias$', () => clock() < until), ...identicalRowCountAliases(decls, base.reads, shape.rowMap, prefix + 'alias$', () => clock() < until)];
|
|
37
|
+
report.inclusionCounts.push(inclusions.length);
|
|
38
|
+
report.aliasCounts.push(aliases.length);
|
|
39
|
+
return { ...base, insts: [...inclusions.map((p, i) => ({ wit: prefix + i, below: p.below, terms: [[1, p.positive], [-1, p.negative]], unit: 0 })), ...aliases] };
|
|
40
|
+
};
|
|
41
|
+
return { options: { seedInstances, witnessFlags: true }, request, report };
|
|
42
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CountCert, type Goal, type Path, type Tree } from '../kernel/kernel.js';
|
|
2
|
+
import { type CountStageObserver } from './count-stage-trace.js';
|
|
3
|
+
export declare function rowSymmetryNames(request: Pick<CountCert, 'reads' | 'insts'>, a: string, b: string, until: number): Map<string, string> | undefined;
|
|
4
|
+
export declare function rowSymmetryCache(goal: Goal, request: Pick<CountCert, 'reads' | 'insts'>, a: string, b: string, until: number, observe?: CountStageObserver, deferCheck?: boolean): {
|
|
5
|
+
put(path: Path, tree: Tree): void;
|
|
6
|
+
get(path: Path): Tree | undefined;
|
|
7
|
+
} | undefined;
|