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,293 @@
|
|
|
1
|
+
// Untrusted transport matching. Images describe the discovered write and a
|
|
2
|
+
// region's existing row-agreement premise; no image or relation is an axiom.
|
|
3
|
+
// Emitters must prove every selected relation on the unchanged machine.
|
|
4
|
+
import { all, get, n, not, plus, same, times, walkOnce, x } from "./machine.js";
|
|
5
|
+
import { countsForReads } from "./count-facts.js";
|
|
6
|
+
import { discoverLiftedCountGuard, discoverLiftedCountOperation } from "./count-lifted-shape.js";
|
|
7
|
+
import { substE } from "../kernel/kernel.js";
|
|
8
|
+
import { discoverCountRowLoad } from "./count-load-shape.js";
|
|
9
|
+
import { inlineFrozenGuard } from "./count-frozen-guard.js";
|
|
10
|
+
const json = (value) => JSON.stringify(value);
|
|
11
|
+
const neg = (f) => typeof f === 'boolean' ? !f : 'not' in f ? f.not : { not: f };
|
|
12
|
+
const join = (op, items) => {
|
|
13
|
+
const xs = items.flatMap(f => typeof f !== 'boolean' && 'op' in f && f.op === op ? f.xs : [f]);
|
|
14
|
+
if (xs.includes(op === 'or'))
|
|
15
|
+
return op === 'or';
|
|
16
|
+
const terms = new Set(xs.map(json));
|
|
17
|
+
if (xs.some(f => terms.has(json(neg(f)))))
|
|
18
|
+
return op === 'or';
|
|
19
|
+
const unique = [...new Map(xs.filter(f => f !== (op === 'and')).map(f => [json(f), f])).entries()].sort(([a], [b]) => a.localeCompare(b)).map(([, f]) => f);
|
|
20
|
+
return !unique.length ? op === 'and' : unique.length === 1 ? unique[0] : { op, xs: unique };
|
|
21
|
+
};
|
|
22
|
+
const normalize = (value) => {
|
|
23
|
+
if (value.op === 'const')
|
|
24
|
+
return String(value.value);
|
|
25
|
+
if (value.op === 'var')
|
|
26
|
+
return '$' + value.name;
|
|
27
|
+
if (value.op === 'get')
|
|
28
|
+
return value.map + '[' + normalize(value.key) + ']';
|
|
29
|
+
if (value.op === 'add')
|
|
30
|
+
return [normalize(value.a), normalize(value.b)].sort().join('+');
|
|
31
|
+
if (value.op === 'mul')
|
|
32
|
+
return value.k + '*' + normalize(value.a);
|
|
33
|
+
return json(value);
|
|
34
|
+
};
|
|
35
|
+
function formula(c) {
|
|
36
|
+
if (c.op === 'and' || c.op === 'or')
|
|
37
|
+
return join(c.op, c.xs.map(formula));
|
|
38
|
+
if (c.op === 'not')
|
|
39
|
+
return neg(formula(c.x));
|
|
40
|
+
if (c.op === '=' || c.op === '<=' || c.op === '<') {
|
|
41
|
+
const a = c.a, b = c.b;
|
|
42
|
+
if (a.op === 'const' && b.op === 'const')
|
|
43
|
+
return c.op === '=' ? a.value === b.value : c.op === '<=' ? a.value <= b.value : a.value < b.value;
|
|
44
|
+
if (c.op === '=' && b.op === 'const' && (b.value === 0 || b.value === 1))
|
|
45
|
+
return b.value === 1 ? body(a) : neg(body(a));
|
|
46
|
+
if (c.op === '=' && a.op === 'const' && (a.value === 0 || a.value === 1))
|
|
47
|
+
return a.value === 1 ? body(b) : neg(body(b));
|
|
48
|
+
if (c.op === '<=' && a.op === 'const' && a.value === 1)
|
|
49
|
+
return body(b);
|
|
50
|
+
const pair = [normalize(a), normalize(b)];
|
|
51
|
+
if (c.op === '=')
|
|
52
|
+
pair.sort();
|
|
53
|
+
return { atom: c.op + json(pair) };
|
|
54
|
+
}
|
|
55
|
+
return { atom: json(c) };
|
|
56
|
+
}
|
|
57
|
+
function body(e) {
|
|
58
|
+
if (e.op === 'const' && (e.value === 0 || e.value === 1))
|
|
59
|
+
return !!e.value;
|
|
60
|
+
if (e.op === 'if')
|
|
61
|
+
return join('or', [join('and', [formula(e.c), body(e.then)]), join('and', [neg(formula(e.c)), body(e.else)])]);
|
|
62
|
+
return { atom: 'present:' + normalize(e) };
|
|
63
|
+
}
|
|
64
|
+
function images(value, shape, rows, fields) {
|
|
65
|
+
const visit = (node) => {
|
|
66
|
+
if (!node || typeof node !== 'object')
|
|
67
|
+
return node;
|
|
68
|
+
if (Array.isArray(node))
|
|
69
|
+
return node.map(visit);
|
|
70
|
+
const e = node;
|
|
71
|
+
if (e.op === 'get' && fields.has(e.map)) {
|
|
72
|
+
const image = rows.get(json(e.key));
|
|
73
|
+
if (image?.kind === 'row')
|
|
74
|
+
return get(e.map, image.row);
|
|
75
|
+
}
|
|
76
|
+
if (e.op === 'get' && e.map === shape.origin.membershipMap && e.key.op === 'add') {
|
|
77
|
+
const [base, column] = e.key.a.op === 'mul' ? [e.key.a, e.key.b] : [e.key.b, e.key.a];
|
|
78
|
+
if (base.op === 'mul' && base.k === shape.origin.width) {
|
|
79
|
+
const image = rows.get(json(base.a));
|
|
80
|
+
if (image?.kind === 'empty')
|
|
81
|
+
return n(0);
|
|
82
|
+
if (image?.kind === 'source')
|
|
83
|
+
return get(image.map, column);
|
|
84
|
+
if (image?.kind === 'row')
|
|
85
|
+
return get(e.map, plus(times(shape.origin.width, image.row), column));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return Object.fromEntries(Object.entries(node).map(([key, child]) => [key, visit(child)]));
|
|
89
|
+
};
|
|
90
|
+
return visit(value);
|
|
91
|
+
}
|
|
92
|
+
// A syntactic Boolean-body match is only a transport proposal. Its witness
|
|
93
|
+
// obligation still passes through the unchanged native checker.
|
|
94
|
+
export function matchLiftedCountBodies(left, right) {
|
|
95
|
+
if (json(left.below) !== json(right.below))
|
|
96
|
+
return false;
|
|
97
|
+
let member = 'match$member';
|
|
98
|
+
const scope = json([left, right]);
|
|
99
|
+
while (scope.includes(member))
|
|
100
|
+
member = '$' + member;
|
|
101
|
+
const canonical = (count) => body(substE(count.body, { vars: { [count.key]: x(member) }, maps: {}, flags: {} }));
|
|
102
|
+
return json(canonical(left)) === json(canonical(right));
|
|
103
|
+
}
|
|
104
|
+
// These are identities in the matcher's Boolean abstraction, not CountInsts.
|
|
105
|
+
// Raw comparisons may have different but equivalent spellings in the two
|
|
106
|
+
// generator paths. Only a later native proof can validate their use on counts.
|
|
107
|
+
export function proposeTransportPartitions(counts) {
|
|
108
|
+
const result = [], groups = new Map();
|
|
109
|
+
for (const count of counts) {
|
|
110
|
+
const key = json(count.below), group = groups.get(key) ?? [];
|
|
111
|
+
group.push(count);
|
|
112
|
+
groups.set(key, group);
|
|
113
|
+
}
|
|
114
|
+
for (const group of groups.values()) {
|
|
115
|
+
if (group.length > 32)
|
|
116
|
+
continue;
|
|
117
|
+
const fs = group.map(count => body(count.body)), atoms = new Set();
|
|
118
|
+
const gather = (f) => { if (typeof f === 'boolean')
|
|
119
|
+
return; if ('atom' in f)
|
|
120
|
+
atoms.add(f.atom);
|
|
121
|
+
else if ('not' in f)
|
|
122
|
+
gather(f.not);
|
|
123
|
+
else
|
|
124
|
+
f.xs.forEach(gather); };
|
|
125
|
+
fs.forEach(gather);
|
|
126
|
+
if (atoms.size > 8)
|
|
127
|
+
continue;
|
|
128
|
+
const keys = [...atoms].sort(), positions = new Map(keys.map((key, index) => [key, index]));
|
|
129
|
+
const evaluate = (f, bits) => typeof f === 'boolean' ? f : 'atom' in f ? !!(bits & (1 << positions.get(f.atom))) : 'not' in f ? !evaluate(f.not, bits) : f.op === 'and' ? f.xs.every(child => evaluate(child, bits)) : f.xs.some(child => evaluate(child, bits));
|
|
130
|
+
const masks = fs.map(f => { let mask = 0n; for (let bits = 0; bits < 2 ** keys.length; bits++)
|
|
131
|
+
if (evaluate(f, bits))
|
|
132
|
+
mask |= 1n << BigInt(bits); return mask; });
|
|
133
|
+
for (let b = 0; b < group.length; b++)
|
|
134
|
+
for (let c = b + 1; c < group.length; c++) {
|
|
135
|
+
if (!masks[b] || !masks[c] || (masks[b] & masks[c]) !== 0n)
|
|
136
|
+
continue;
|
|
137
|
+
for (let a = 0; a < group.length; a++)
|
|
138
|
+
if (masks[a] === (masks[b] | masks[c]))
|
|
139
|
+
result.push({ terms: [[1, group[a].v], [-1, group[b].v], [-1, group[c].v]] });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
export function liftedCopyTuples(law, source) {
|
|
145
|
+
if (!law.forall || law.keys?.length !== 3)
|
|
146
|
+
return [];
|
|
147
|
+
const a = x(law.forall + '#'), b = x(law.keys[0]), rest = law.keys.slice(1).map(x);
|
|
148
|
+
return [[a, b, ...rest], [a, source, ...rest], [source, b, ...rest], [source, source, ...rest]];
|
|
149
|
+
}
|
|
150
|
+
// Integer row reduction is only scheduling metadata. A derived mark still
|
|
151
|
+
// requires the emitter's checked base relations and final arithmetic proof.
|
|
152
|
+
function spanned(target, rows) {
|
|
153
|
+
const names = [...new Set([...target.keys(), ...rows.flatMap(row => [...row.keys()])])].sort(), basis = new Map();
|
|
154
|
+
const reduce = (input) => {
|
|
155
|
+
let a = names.map(name => input.get(name) ?? 0n);
|
|
156
|
+
for (let i = 0; i < a.length; i++)
|
|
157
|
+
if (a[i]) {
|
|
158
|
+
const b = basis.get(i);
|
|
159
|
+
if (!b)
|
|
160
|
+
return { a, pivot: i };
|
|
161
|
+
const q = a[i], p = b[i];
|
|
162
|
+
a = a.map((value, j) => p * value - q * b[j]);
|
|
163
|
+
const abs = (value) => value < 0n ? -value : value, gcd = (left, right) => right ? gcd(right, left % right) : abs(left), divisor = a.reduce(gcd, 0n);
|
|
164
|
+
if (divisor > 1n)
|
|
165
|
+
a = a.map(value => value / divisor);
|
|
166
|
+
}
|
|
167
|
+
return { a, pivot: -1 };
|
|
168
|
+
};
|
|
169
|
+
for (const row of rows) {
|
|
170
|
+
const { a, pivot } = reduce(row);
|
|
171
|
+
if (pivot >= 0)
|
|
172
|
+
basis.set(pivot, a);
|
|
173
|
+
}
|
|
174
|
+
return reduce(target).pivot < 0;
|
|
175
|
+
}
|
|
176
|
+
export function proposeLiftedTransports(m, family, law, value) {
|
|
177
|
+
const shape = discoverLiftedCountGuard(m, law, family), operation = shape && discoverLiftedCountOperation(m, shape, value);
|
|
178
|
+
if (!shape || !operation || !law.forall || law.keys?.length !== 3)
|
|
179
|
+
return;
|
|
180
|
+
const a = x(law.forall + '#'), b = x(law.keys[0]), copy = 'copy' in operation ? operation.copy : undefined, write = 'write' in operation ? operation.write : undefined;
|
|
181
|
+
const load = operation.kind === 'load' ? discoverCountRowLoad(m, shape, family, operation) : undefined;
|
|
182
|
+
const writer = copy ? x(copy.to) : write ? x(write.source) : operation.kind === 'threshold-replace' ? x(shape.origin.rowInput) : load ? x(load.written) : undefined;
|
|
183
|
+
if (!writer)
|
|
184
|
+
return [];
|
|
185
|
+
const guard = copy?.guard ?? write?.guard ?? load?.guard ?? shape.origin.guard, active = inlineFrozenGuard(m.step.flags ?? {}, guard);
|
|
186
|
+
let keyName = 'transport$member';
|
|
187
|
+
const scope = json([m, law]);
|
|
188
|
+
while (scope.includes(keyName))
|
|
189
|
+
keyName = '$' + keyName;
|
|
190
|
+
const declarations = Object.entries(m.counts ?? {}).map(([map, definition]) => ({ ...definition, map })), post = [];
|
|
191
|
+
walkOnce(law.holds, (node) => { if (node.op === 'get' && shape.countMaps.includes(node.map)) {
|
|
192
|
+
const key = substE(node.key, { vars: { [law.forall]: a }, maps: {}, flags: {} }), read = ['post$' + post.length, node.map + '#', key];
|
|
193
|
+
if (!post.some(r => r[1] === read[1] && json(r[2]) === json(key)))
|
|
194
|
+
post.push(read);
|
|
195
|
+
} });
|
|
196
|
+
const regions = [];
|
|
197
|
+
const add = (name, when, premises, tuples, postImages, preImages = new Map(), upper = false, activeTuple = tuples[0]) => regions.push({ name, when: [...(m.pre ? [m.pre] : []), active, ...when], premises, tuples, activeTuple, postImages, preImages, upper });
|
|
198
|
+
if (copy) {
|
|
199
|
+
const from = x(copy.from), tuples = liftedCopyTuples(law, from);
|
|
200
|
+
for (let bits = 0; bits < 4; bits++) {
|
|
201
|
+
const left = !!(bits & 2), right = !!(bits & 1), map = new Map([[json(a), { kind: 'row', row: left ? from : a }], [json(b), { kind: 'row', row: right ? from : b }]]);
|
|
202
|
+
add('copy-' + bits, [left ? same(a, writer) : not(same(a, writer)), right ? same(b, writer) : not(same(b, writer))], [], tuples, map, new Map(), true, tuples[bits]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (operation.kind === 'threshold-replace') {
|
|
206
|
+
const agreement = shape.rowAgreements[0];
|
|
207
|
+
if (!agreement)
|
|
208
|
+
return;
|
|
209
|
+
for (const left of [true, false]) {
|
|
210
|
+
const actor = left ? a : b, other = left ? b : a, preImages = new Map([[json(other), { kind: 'row', row: writer }]]), postImages = new Map(preImages);
|
|
211
|
+
postImages.set(json(actor), { kind: 'source', map: shape.origin.requestSet });
|
|
212
|
+
const rowGuard = substE({ op: 'if', c: agreement.shape.guard, then: n(1), else: n(0) }, { vars: { [agreement.shape.left]: writer, [agreement.shape.right]: other }, maps: {}, flags: {} });
|
|
213
|
+
add(left ? 'replacement-left-equal' : 'replacement-right-equal', [same(actor, writer), not(same(other, writer)), rowGuard.op === 'if' ? rowGuard.c : all()], [agreement.law], [[a, b, ...law.keys.slice(1).map(x)]], postImages, preImages);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else if (load) {
|
|
217
|
+
for (const both of [true, false]) {
|
|
218
|
+
const postImages = new Map([[json(a), both ? { kind: 'source', map: load.source } : { kind: 'row', row: a }], [json(b), both ? { kind: 'source', map: load.source } : { kind: 'row', row: b }]]);
|
|
219
|
+
add(both ? 'load-both' : 'load-neither', [both ? same(a, writer) : not(same(a, writer)), both ? same(b, writer) : not(same(b, writer))], [load.law, ...load.phaseLaws], [[a, b, ...law.keys.slice(1).map(x)]], postImages);
|
|
220
|
+
}
|
|
221
|
+
for (const left of [true, false])
|
|
222
|
+
for (const marked of [true, false]) {
|
|
223
|
+
const actor = left ? a : b, other = left ? b : a, map = new Map([[json(actor), { kind: 'source', map: load.source }], [json(other), marked ? { kind: 'source', map: load.source } : { kind: 'empty' }]]);
|
|
224
|
+
add('load-' + (left ? 'left' : 'right') + '-' + (marked ? 'marked' : 'empty'), [same(actor, writer), not(same(other, writer)), marked ? same(get(load.marker.map, other), n(load.marker.value)) : same(get(load.marker.map, other), n(0))], [load.law, ...load.phaseLaws], [[a, b, ...law.keys.slice(1).map(x)]], map, new Map([[json(other), marked ? { kind: 'source', map: load.source } : { kind: 'empty' }]]));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else
|
|
228
|
+
return [];
|
|
229
|
+
return regions.map(region => {
|
|
230
|
+
const candidates = [];
|
|
231
|
+
const put = (map, key) => { if (!candidates.some(read => read[1] === map && json(read[2]) === json(key)))
|
|
232
|
+
candidates.push(['pre$' + candidates.length, map, key]); };
|
|
233
|
+
for (const tuple of region.tuples)
|
|
234
|
+
for (const read of post)
|
|
235
|
+
put(read[1].slice(0, -1), substE(read[2], { vars: { [a.op === 'var' ? a.name : '']: tuple[0], [b.op === 'var' ? b.name : '']: tuple[1] }, maps: {}, flags: {} }));
|
|
236
|
+
for (const endpoint of [a, b, writer])
|
|
237
|
+
put(shape.origin.rowCount, endpoint);
|
|
238
|
+
for (const [map, definition] of Object.entries(m.counts ?? {})) {
|
|
239
|
+
if (definition.base)
|
|
240
|
+
continue;
|
|
241
|
+
const fields = new Set(), variables = new Set();
|
|
242
|
+
walkOnce(definition.body, (node) => { if (node.op === 'get')
|
|
243
|
+
fields.add(node.map); if (node.op === 'var')
|
|
244
|
+
variables.add(node.name); });
|
|
245
|
+
if (!variables.has(definition.j) && fields.size && [...fields].every(field => field === shape.origin.requestSet || field === shape.origin.membershipMap))
|
|
246
|
+
put(map, n(0));
|
|
247
|
+
}
|
|
248
|
+
const records = [];
|
|
249
|
+
for (const [isPost, reads, selectedImages] of [[true, post, region.postImages], [false, candidates, region.preImages]])
|
|
250
|
+
for (const read of reads) {
|
|
251
|
+
const raw = [read[0], read[1].replace(/#$/, ''), read[2]], count = countsForReads(declarations, [raw])?.[0];
|
|
252
|
+
if (!count)
|
|
253
|
+
continue;
|
|
254
|
+
records.push({ read, count: { ...count, key: keyName, body: images(substE(count.body, { vars: { [count.key]: x(keyName) }, maps: {}, flags: {} }), shape, selectedImages, copy ? new Set([shape.countShape.memberField, shape.countShape.thresholdField, ...shape.rowAgreement?.fields ?? []]) : new Set()) }, isPost });
|
|
255
|
+
}
|
|
256
|
+
const relations = [], unmatched = [];
|
|
257
|
+
for (const record of records.filter(record => record.isPost)) {
|
|
258
|
+
const key = json(body(record.count.body)), matches = records.filter(other => other.read[0] !== record.read[0] && json(body(other.count.body)) === key);
|
|
259
|
+
if (key === 'false')
|
|
260
|
+
relations.push({ post: record.read, kind: 'zero', postBody: record.count.body, targetBody: n(0), derived: false });
|
|
261
|
+
for (const match of matches)
|
|
262
|
+
relations.push({ post: record.read, target: match.read, kind: region.upper && !shape.origin.twins.some(twin => twin.row === record.read[1].slice(0, -1)) && record.read[1] !== shape.origin.rowCount + '#' ? 'upper' : 'equality', postBody: record.count.body, targetBody: match.count.body, derived: false });
|
|
263
|
+
for (const target of records.filter(other => other.isPost && other.read[1] === shape.origin.rowCount + '#' && other.read[0] !== record.read[0] && (key === 'false' || json(body(other.count.body)) !== key)))
|
|
264
|
+
if (join('and', [body(record.count.body), neg(body(target.count.body))]) === false)
|
|
265
|
+
relations.push({ post: record.read, target: target.read, kind: 'upper', postBody: record.count.body, targetBody: target.count.body, derived: false });
|
|
266
|
+
if (!relations.some(relation => relation.post[0] === record.read[0]))
|
|
267
|
+
unmatched.push({ read: record.read, body: record.count.body });
|
|
268
|
+
}
|
|
269
|
+
const membershipMaps = new Set([shape.origin.membershipMap, shape.origin.requestSet, ...load ? [load.source] : []]);
|
|
270
|
+
const partitionCounts = records.map(record => record.count).filter(count => { const fields = []; walkOnce(count.body, (node) => { if (node.op === 'get')
|
|
271
|
+
fields.push(node.map); }); return fields.every(field => membershipMaps.has(field)); });
|
|
272
|
+
const partitions = proposeTransportPartitions(partitionCounts);
|
|
273
|
+
const vector = (terms) => new Map(terms.map(([coefficient, id]) => [id, BigInt(coefficient)]));
|
|
274
|
+
const relationVector = (relation) => vector([[1, relation.post[0]], ...(relation.target ? [[-1, relation.target[0]]] : [])]);
|
|
275
|
+
const accepted = [], basis = partitions.map(partition => vector(partition.terms));
|
|
276
|
+
const cost = (relation) => { const f = json(body(relation.postBody)), atoms = [...f.matchAll(/"atom":/g)].length; return atoms * 2 + (f.includes('"not":') ? 0 : 1); };
|
|
277
|
+
for (const index of relations.map((_, index) => index).sort((a, b) => cost(relations[a]) - cost(relations[b]))) {
|
|
278
|
+
const relation = relations[index];
|
|
279
|
+
if (relation.kind !== 'equality')
|
|
280
|
+
continue;
|
|
281
|
+
const row = relationVector(relation);
|
|
282
|
+
if (spanned(row, basis)) {
|
|
283
|
+
relation.derived = true;
|
|
284
|
+
relation.derivedFrom = [...accepted];
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
basis.push(row);
|
|
288
|
+
accepted.push(index);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { name: region.name, when: region.when, premises: region.premises, tuples: region.tuples, activeTuple: region.activeTuple, relations, partitions, unmatched };
|
|
292
|
+
});
|
|
293
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type LiftedCountGuardShape } from './count-lifted-shape.js';
|
|
3
|
+
export type CountRowLoad = {
|
|
4
|
+
law: Law;
|
|
5
|
+
source: string;
|
|
6
|
+
written: string;
|
|
7
|
+
guard: string;
|
|
8
|
+
marker: {
|
|
9
|
+
map: string;
|
|
10
|
+
value: number;
|
|
11
|
+
};
|
|
12
|
+
phaseLaws: Law[];
|
|
13
|
+
};
|
|
14
|
+
export declare function discoverCountRowLoad(m: Machine, shape: LiftedCountGuardShape, family: readonly Law[], choice: {
|
|
15
|
+
name: string;
|
|
16
|
+
value: number;
|
|
17
|
+
}): CountRowLoad | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Untrusted discovery of a marked row loaded from a plain-key map.
|
|
2
|
+
// The existing family supplies every premise; names never select a law.
|
|
3
|
+
import { n, walkOnce, x } from "./machine.js";
|
|
4
|
+
const json = (v) => JSON.stringify(v);
|
|
5
|
+
const atoms = (c) => c.op === 'and' ? c.xs.flatMap(atoms) : [c];
|
|
6
|
+
const variable = (e, name) => e.op === 'var' && e.name === name;
|
|
7
|
+
const has = (root, predicate) => { let found = false; walkOnce(root, (node) => { if (predicate(node))
|
|
8
|
+
found = true; }); return found; };
|
|
9
|
+
export function discoverCountRowLoad(m, shape, family, choice) {
|
|
10
|
+
const results = [];
|
|
11
|
+
for (const law of family) {
|
|
12
|
+
if (!law.forall || law.keys?.length !== 1 || law.holds.op !== 'or')
|
|
13
|
+
continue;
|
|
14
|
+
const equality = law.holds.xs.find(c => c.op === '='), negated = law.holds.xs.find(c => c.op === 'not');
|
|
15
|
+
if (equality?.op !== '=' || negated?.op !== 'not')
|
|
16
|
+
continue;
|
|
17
|
+
const [row, source] = equality.a.op === 'get' && equality.a.map === shape.origin.membershipMap ? [equality.a, equality.b] : [equality.b, equality.a];
|
|
18
|
+
if (row.op !== 'get' || source.op !== 'get' || row.map !== shape.origin.membershipMap || source.map === row.map || !Object.hasOwn(m.maps ?? {}, source.map) || !variable(source.key, law.keys[0]))
|
|
19
|
+
continue;
|
|
20
|
+
const key = row.key;
|
|
21
|
+
if (key.op !== 'add' || key.a.op !== 'mul' || key.a.k !== shape.origin.width || !variable(key.a.a, law.forall) || !variable(key.b, law.keys[0]))
|
|
22
|
+
continue;
|
|
23
|
+
const conditions = atoms(negated.x), markers = conditions.flatMap(c => {
|
|
24
|
+
if (c.op !== '=')
|
|
25
|
+
return [];
|
|
26
|
+
const [cell, value] = c.a.op === 'get' ? [c.a, c.b] : [c.b, c.a];
|
|
27
|
+
return cell.op === 'get' && variable(cell.key, law.forall) && value.op === 'const' && value.value >= 1 && Object.hasOwn(m.maps ?? {}, cell.map) ? [{ map: cell.map, value: value.value }] : [];
|
|
28
|
+
});
|
|
29
|
+
for (const marker of markers) {
|
|
30
|
+
const write = m.step.maps?.[marker.map], rowWrite = m.step.maps?.[row.map];
|
|
31
|
+
if (!write || 'each' in write || write.key.op !== 'var' || !m.inputs.includes(write.key.name) || write.value.op !== 'if' || json(write.value.then) !== json(n(marker.value)) || !rowWrite || !('each' in rowWrite))
|
|
32
|
+
continue;
|
|
33
|
+
const written = write.key.name, flags = [];
|
|
34
|
+
walkOnce(write.value.c, (node) => { if (node.op === 'flag')
|
|
35
|
+
flags.push(node.name); });
|
|
36
|
+
for (const guard of flags) {
|
|
37
|
+
const definition = m.step.flags?.[guard];
|
|
38
|
+
if (!definition || !has(definition, node => node.op === '=' && (json(node.a) === json(x(choice.name)) && json(node.b) === json(n(choice.value)) || json(node.b) === json(x(choice.name)) && json(node.a) === json(n(choice.value)))))
|
|
39
|
+
continue;
|
|
40
|
+
if (!has(rowWrite.value, node => node.op === 'flag' && node.name === guard) || !has(rowWrite.value, node => node.op === 'get' && node.map === source.map && node.key.op === 'sub' && variable(node.key.a, rowWrite.each) && node.key.b.op === 'mul' && node.key.b.k === shape.origin.width && variable(node.key.b.a, written)))
|
|
41
|
+
continue;
|
|
42
|
+
const phaseLaws = family.filter(candidate => {
|
|
43
|
+
if (!candidate.forall || candidate.keys?.length)
|
|
44
|
+
return false;
|
|
45
|
+
const maps = new Set();
|
|
46
|
+
walkOnce(candidate.holds, (node) => { if (node.op === 'get')
|
|
47
|
+
maps.add(node.map); });
|
|
48
|
+
if (maps.size === 1 && maps.has(marker.map))
|
|
49
|
+
return has(candidate.holds, node => (node.op === '<=' || node.op === '<') && node.a.op === 'get' && node.a.map === marker.map && node.b.op === 'const' && node.b.value <= (node.op === '<' ? marker.value + 1 : marker.value));
|
|
50
|
+
return maps.size === 2 && maps.has(marker.map) && maps.has(shape.origin.rowCount) && has(candidate.holds, node => node.op === '=' && ((node.a.op === 'get' && node.a.map === marker.map && json(node.b) === json(n(0))) || (node.b.op === 'get' && node.b.map === marker.map && json(node.a) === json(n(0)))));
|
|
51
|
+
});
|
|
52
|
+
if (!phaseLaws.some(candidate => has(candidate.holds, node => node.op === 'get' && node.map === shape.origin.rowCount)))
|
|
53
|
+
continue;
|
|
54
|
+
results.push({ law, source: source.map, written, guard, marker, phaseLaws });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Prefer the unphased load law; an extra scalar guard is not silently dropped.
|
|
59
|
+
const size = (value) => { let count = 0; walkOnce(value, () => { count++; }); return count; };
|
|
60
|
+
results.sort((a, b) => size(a.law.holds) - size(b.law.holds));
|
|
61
|
+
if (!results.length)
|
|
62
|
+
return;
|
|
63
|
+
const first = results[0];
|
|
64
|
+
if (results.some(result => json([result.source, result.written, result.guard, result.marker]) !== json([first.source, first.written, first.guard, first.marker])))
|
|
65
|
+
return;
|
|
66
|
+
return first;
|
|
67
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type C } from './machine.js';
|
|
2
|
+
import { type CountDecl, type CountInst, type Goal, type MapRead, type Path, type Tree } from '../kernel/kernel.js';
|
|
3
|
+
import { type Outcome } from '../kernel/prove.js';
|
|
4
|
+
export declare function minimalTransportView(hyps: C[], decls: CountDecl[], reads: MapRead[], all: CountInst[], selected: CountInst[], path: Path): {
|
|
5
|
+
goal: Goal;
|
|
6
|
+
reads: MapRead[];
|
|
7
|
+
path: Path;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export type MinimalResult = {
|
|
10
|
+
kind: 'proof' | 'sat' | 'unknown' | 'rejected';
|
|
11
|
+
minimalKind: 'proof' | 'sat' | 'unknown' | 'rejected';
|
|
12
|
+
fallback: boolean;
|
|
13
|
+
minimalUnits: number;
|
|
14
|
+
fallbackUnits: number;
|
|
15
|
+
tree?: Tree;
|
|
16
|
+
witness?: Record<string, number>;
|
|
17
|
+
};
|
|
18
|
+
type Search = (goal: Goal, path: Path, budget: {
|
|
19
|
+
nodes: number;
|
|
20
|
+
until: number;
|
|
21
|
+
}) => Outcome;
|
|
22
|
+
export declare function minimalViewFirst(full: Goal, minimal: Goal, path: Path, until: number, fallbackSearch?: Search, minimalPath?: Path, options?: {
|
|
23
|
+
deferCheck?: boolean;
|
|
24
|
+
deferReplayCheck?: boolean;
|
|
25
|
+
}): MinimalResult;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { countsForReads } from "./count-facts.js";
|
|
2
|
+
import { env, solve } from "./solver.js";
|
|
3
|
+
import { check, mcGoal } from "../kernel/kernel.js";
|
|
4
|
+
import { growCdcl } from "../kernel/cdcl.js";
|
|
5
|
+
import { brokenOf, clock, fullRate, fullWork, rowsAt } from "../kernel/prove.js";
|
|
6
|
+
import { projectCountFree } from "./count-project-free.js";
|
|
7
|
+
import { projectCountWitness, projectCountWitnessRoot } from "./count-project-witness.js";
|
|
8
|
+
import { rebasePath } from "./count-rebase-path.js";
|
|
9
|
+
import { replayLinearSkeleton } from "./count-replay-skeleton.js";
|
|
10
|
+
export function minimalTransportView(hyps, decls, reads, all, selected, path) {
|
|
11
|
+
if (!selected.length)
|
|
12
|
+
return;
|
|
13
|
+
const counts = countsForReads(decls, reads);
|
|
14
|
+
if (!counts)
|
|
15
|
+
return;
|
|
16
|
+
const own = new Set(selected.map(inst => inst.wit)), other = new Set(all.filter(inst => !own.has(inst.wit)).map(inst => inst.wit));
|
|
17
|
+
const scalar = projectCountFree(hyps, path, new Set(decls.map(decl => decl.map)), other, true);
|
|
18
|
+
const premises = projectCountWitness(scalar, counts, selected), ids = new Set(selected.flatMap(inst => inst.terms.map(([, id]) => id)));
|
|
19
|
+
const minimal = reads.filter(([id]) => ids.has(id)), goal = mcGoal(premises, decls, { reads: minimal, insts: selected, picks: [] });
|
|
20
|
+
return goal ? { goal, reads: minimal, path: projectCountWitnessRoot(path, counts, selected) } : undefined;
|
|
21
|
+
}
|
|
22
|
+
export function minimalViewFirst(full, minimal, path, until, fallbackSearch = growCdcl, minimalPath = path, options = {}) {
|
|
23
|
+
const began = fullWork(), units = () => (fullWork() - began) / fullRate;
|
|
24
|
+
const search = (goal, solver, root) => {
|
|
25
|
+
if (clock() >= until)
|
|
26
|
+
return { stuck: 'unknown', path: root, why: 'minimal-view deadline' };
|
|
27
|
+
const direct = solve(rowsAt(goal, root), 2000);
|
|
28
|
+
return direct.kind === 'refuted' ? { tree: { leaf: direct.steps }, nodes: 0 } : solver(goal, root, { nodes: 0, until });
|
|
29
|
+
};
|
|
30
|
+
const small = search(minimal, growCdcl, minimalPath);
|
|
31
|
+
if ('tree' in small) {
|
|
32
|
+
// C2 ownership does not activate forwarding without its independent opt-in.
|
|
33
|
+
const tree = minimal === full && minimalPath === path ? small.tree : (rebasePath(minimal, small.tree, minimalPath, path, until, full) ?? (env.GDP_COUNT_REPLAY_FORWARD === '1'
|
|
34
|
+
? replayLinearSkeleton(full, small.tree, path, until, { deferCheck: options.deferCheck === true && options.deferReplayCheck === true })
|
|
35
|
+
: replayLinearSkeleton(full, small.tree, path, until)));
|
|
36
|
+
const checked = !!tree && (options.deferCheck || check(full, tree, path)) && clock() < until;
|
|
37
|
+
return { kind: checked ? 'proof' : 'rejected', minimalKind: checked ? 'proof' : 'rejected', fallback: false, minimalUnits: units(), fallbackUnits: 0, ...(checked ? { tree } : {}) };
|
|
38
|
+
}
|
|
39
|
+
const minimalUnits = units();
|
|
40
|
+
if (small.stuck !== 'sat')
|
|
41
|
+
return { kind: 'unknown', minimalKind: 'unknown', fallback: false, minimalUnits, fallbackUnits: 0 };
|
|
42
|
+
if (small.witness && brokenOf(minimal)(small.witness).length)
|
|
43
|
+
throw Error('invalid minimal transport model');
|
|
44
|
+
const result = search(full, fallbackSearch, path), checked = 'tree' in result && (options.deferCheck || check(full, result.tree, path)) && clock() < until;
|
|
45
|
+
return { kind: checked ? 'proof' : 'tree' in result ? 'rejected' : result.stuck, minimalKind: 'sat', fallback: true, minimalUnits, fallbackUnits: units() - minimalUnits, witness: small.witness, ...(checked && 'tree' in result ? { tree: result.tree } : {}) };
|
|
46
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type CountOperationEvent = Readonly<{
|
|
2
|
+
phase: 'begin' | 'end';
|
|
3
|
+
owner: string;
|
|
4
|
+
value: number;
|
|
5
|
+
kind: string;
|
|
6
|
+
returned?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function withCountOperationObservation<T>(next: (event: CountOperationEvent) => void, run: () => T): T;
|
|
9
|
+
export declare function observeCountOperation<T>(identity: Omit<CountOperationEvent, 'phase' | 'returned'>, run: () => T): T;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
let observe;
|
|
2
|
+
export function withCountOperationObservation(next, run) { const prior = observe; observe = next; try {
|
|
3
|
+
return run();
|
|
4
|
+
}
|
|
5
|
+
finally {
|
|
6
|
+
observe = prior;
|
|
7
|
+
} }
|
|
8
|
+
export function observeCountOperation(identity, run) {
|
|
9
|
+
if (!observe)
|
|
10
|
+
return run();
|
|
11
|
+
const notify = observe;
|
|
12
|
+
notify({ ...identity, phase: 'begin' });
|
|
13
|
+
let returned = false;
|
|
14
|
+
try {
|
|
15
|
+
const result = run();
|
|
16
|
+
returned = result !== undefined;
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
notify({ ...identity, phase: 'end', returned });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type CountStrategyOptions } from './count-strategy.js';
|
|
3
|
+
import { type CountCert, type CountDecl, type Goal, type Instances } from '../kernel/kernel.js';
|
|
4
|
+
export type PhaseCountProof = {
|
|
5
|
+
instances: Instances;
|
|
6
|
+
certs: Record<string, CountCert>;
|
|
7
|
+
};
|
|
8
|
+
export type CountRequestBuilder = (goal: Goal, declarations: CountDecl[]) => Pick<CountCert, 'reads' | 'insts' | 'picks'>;
|
|
9
|
+
export declare function proveFixedCountPhase(m: Machine, family: Law[], law: Law, seed: Instances, until: number, requestFor: CountRequestBuilder, observe?: (stage: string) => void, options?: CountStrategyOptions): PhaseCountProof | undefined;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Optional fixed-operation phase strategy. Discovery is untrusted; all leaves,
|
|
2
|
+
// INIT and STEP are checked against the caller's ordinary count obligations.
|
|
3
|
+
import { x } from "./machine.js";
|
|
4
|
+
import { strategyLeafUntil } from "./count-strategy.js";
|
|
5
|
+
import { countsForReads } from "./count-facts.js";
|
|
6
|
+
import { countFrameConditions, fixedCountFrameCase, ownCountLawInstance } from "./count-frames.js";
|
|
7
|
+
import { discoverCountGuardShape } from "./count-guard-shape.js";
|
|
8
|
+
import { add, k, scale } from "./solver.js";
|
|
9
|
+
import { canon, checkMC, countedObligations, frameOk, framePath, mcGoal } from "../kernel/kernel.js";
|
|
10
|
+
import { clock, grow, pastWall } from "../kernel/prove.js";
|
|
11
|
+
import { growCdcl } from "../kernel/cdcl.js";
|
|
12
|
+
import { countSearchView, proveCountQuery } from "./count-query.js";
|
|
13
|
+
export function proveFixedCountPhase(m, family, law, seed, until, requestFor, observe, options = {}) {
|
|
14
|
+
if (clock() >= until || pastWall() || !family.includes(law))
|
|
15
|
+
return;
|
|
16
|
+
const shape = discoverCountGuardShape(m, law, family), choice = fixedCountFrameCase(m);
|
|
17
|
+
if (!shape?.phase || !choice)
|
|
18
|
+
return;
|
|
19
|
+
observe?.('shape');
|
|
20
|
+
const instances = { ...ownCountLawInstance(law, seed) };
|
|
21
|
+
for (const premise of shape.phase.laws)
|
|
22
|
+
instances[premise.name] = [x(law.keys[0])];
|
|
23
|
+
const packets = countedObligations(m, family, { [law.name]: instances }, family.indexOf(law)), step = packets.at(-1);
|
|
24
|
+
if (!step)
|
|
25
|
+
return;
|
|
26
|
+
const base = requestFor(step.goal, step.decls), counts = countsForReads(step.decls, base.reads);
|
|
27
|
+
if (!counts)
|
|
28
|
+
return;
|
|
29
|
+
const targets = [shape.voteMap, shape.rowMap];
|
|
30
|
+
const post = base.reads.filter(r => r[1].endsWith('#') && targets.includes(r[1].slice(0, -1)));
|
|
31
|
+
const voted = post.find(r => r[1] === shape.voteMap + '#'), row = post.find(r => r[1] === shape.rowMap + '#');
|
|
32
|
+
if (!voted || !row)
|
|
33
|
+
return;
|
|
34
|
+
const before = (read) => base.reads.find(r => r[1] === read[1].slice(0, -1) && JSON.stringify(r[2]) === JSON.stringify(read[2]));
|
|
35
|
+
const preVote = before(voted), preRow = before(row), bound = counts.find(c => c.v === voted[0]).below;
|
|
36
|
+
if (!preVote || !preRow)
|
|
37
|
+
return;
|
|
38
|
+
const scope = JSON.stringify([m, family, seed, base.reads]), names = [];
|
|
39
|
+
for (let i = 0; names.length < 3; i++) {
|
|
40
|
+
const name = `phase$count${i}`;
|
|
41
|
+
if (!scope.includes(JSON.stringify(name)))
|
|
42
|
+
names.push(name);
|
|
43
|
+
}
|
|
44
|
+
const request = { reads: base.reads, insts: [
|
|
45
|
+
{ wit: names[0], below: bound, terms: [[1, voted[0]]], unit: 0 },
|
|
46
|
+
{ wit: names[1], below: bound, terms: [[1, voted[0]], [-1, preVote[0]]], unit: 0 },
|
|
47
|
+
{ wit: names[2], below: bound, terms: [[1, preRow[0]], [-1, row[0]]], unit: 0 }
|
|
48
|
+
], picks: [] };
|
|
49
|
+
const goal = mcGoal(step.goal.hyps, step.decls, request);
|
|
50
|
+
if (!goal)
|
|
51
|
+
return;
|
|
52
|
+
observe?.('encoded-step');
|
|
53
|
+
const frames = [], conditions = countFrameConditions(choice), minimal = options.minimalView ? countSearchView(step.goal, step.decls, request) : undefined;
|
|
54
|
+
// A genuinely unchanged count has one unconditional frame, not an expanding
|
|
55
|
+
// list of duplicate conditional frames whose row positions vary by leaf.
|
|
56
|
+
for (const read of post) {
|
|
57
|
+
const pre = before(read);
|
|
58
|
+
if (!pre)
|
|
59
|
+
continue;
|
|
60
|
+
const cut = { post: read[0], pre: pre[0], when: [] };
|
|
61
|
+
if (frameOk(counts, cut))
|
|
62
|
+
frames.push(cut);
|
|
63
|
+
}
|
|
64
|
+
const ask = (path) => {
|
|
65
|
+
if (clock() >= until || pastWall())
|
|
66
|
+
return;
|
|
67
|
+
for (const read of post) {
|
|
68
|
+
const pre = before(read);
|
|
69
|
+
if (!pre || frames.some(f => f.post === read[0] && f.pre === pre[0] && !f.when.length))
|
|
70
|
+
continue;
|
|
71
|
+
const cut = { post: read[0], pre: pre[0], when: [...path.values()].map(t => t.holds ? t.lin : add(scale(t.lin, -1), k(1))) };
|
|
72
|
+
if (!frames.some(f => JSON.stringify(f) === JSON.stringify(cut)) && frameOk(counts, cut))
|
|
73
|
+
frames.push(cut);
|
|
74
|
+
}
|
|
75
|
+
if (minimal)
|
|
76
|
+
return proveCountQuery(goal, framePath(frames, [], path), until, { query: 'phase-leaf', minimal, leafUnits: options.leafUnits, trace: options.trace, deferCheck: !!options.deferToComposition });
|
|
77
|
+
const result = growCdcl(goal, framePath(frames, [], path), { nodes: 0, until: strategyLeafUntil(until, options) });
|
|
78
|
+
return 'tree' in result ? result.tree : undefined;
|
|
79
|
+
};
|
|
80
|
+
const solve = (i, path) => {
|
|
81
|
+
if (clock() >= until || pastWall())
|
|
82
|
+
return;
|
|
83
|
+
if (i === conditions.length)
|
|
84
|
+
return ask(path);
|
|
85
|
+
const split = conditions[i], id = canon(split), known = path.get(id)?.holds;
|
|
86
|
+
if (known !== undefined)
|
|
87
|
+
return known ? solve(i + 1, path) : ask(path);
|
|
88
|
+
const yes = solve(i + 1, new Map(path).set(id, { lin: split, holds: true }));
|
|
89
|
+
const no = yes && ask(new Map(path).set(id, { lin: split, holds: false }));
|
|
90
|
+
return yes && no ? { split, yes, no } : undefined;
|
|
91
|
+
};
|
|
92
|
+
const split = { [shape.phase.name]: 1 }, id = canon(split), yes = solve(0, new Map([[id, { lin: split, holds: true }]]));
|
|
93
|
+
const no = yes && solve(0, new Map([[id, { lin: split, holds: false }]]));
|
|
94
|
+
if (!yes || !no) {
|
|
95
|
+
observe?.('step-search-failed');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const cert = { ...request, frames, tree: { split, yes, no } };
|
|
99
|
+
if (options.deferToComposition) {
|
|
100
|
+
observe?.('proposed-step');
|
|
101
|
+
return clock() < until && !pastWall() ? { instances, certs: { [step.goal.name]: cert } } : undefined;
|
|
102
|
+
}
|
|
103
|
+
if (!checkMC(step.goal.hyps, step.decls, cert)) {
|
|
104
|
+
observe?.('rejected-step');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
observe?.('checked-step');
|
|
108
|
+
const certs = { [step.goal.name]: cert };
|
|
109
|
+
for (const initial of packets.slice(0, -1)) {
|
|
110
|
+
if (clock() >= until || pastWall())
|
|
111
|
+
return;
|
|
112
|
+
const base = requestFor(initial.goal, initial.decls), counts = countsForReads(initial.decls, base.reads), target = base.reads.find(r => r[1].replace(/#$/, '') === shape.voteMap);
|
|
113
|
+
if (!counts || !target)
|
|
114
|
+
return;
|
|
115
|
+
const request = { reads: base.reads, insts: [{ wit: names[0], below: counts.find(c => c.v === target[0]).below, terms: [[1, target[0]]], unit: 0 }], picks: [] };
|
|
116
|
+
const goal = mcGoal(initial.goal.hyps, initial.decls, request), result = goal && grow(goal, new Map(), { nodes: 0, until: strategyLeafUntil(until, options) });
|
|
117
|
+
if (!result || !('tree' in result)) {
|
|
118
|
+
observe?.('initial-search-failed');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const cert = { ...request, tree: result.tree };
|
|
122
|
+
if (!checkMC(initial.goal.hyps, initial.decls, cert))
|
|
123
|
+
return;
|
|
124
|
+
certs[initial.goal.name] = cert;
|
|
125
|
+
}
|
|
126
|
+
return clock() < until && !pastWall() ? { instances, certs } : undefined;
|
|
127
|
+
}
|