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,651 @@
|
|
|
1
|
+
// Syntax-derived proposals only. Neither a copied guard nor a co-write is a trusted
|
|
2
|
+
// transition fact: counts.ts applies its ordinary scope/sample filter and kernel proof.
|
|
3
|
+
import { all, any, not, same, less, n, x, walk } from "./machine.js";
|
|
4
|
+
import { scope, substC, substE } from "../kernel/kernel.js";
|
|
5
|
+
// Shared with comparisons(): keep its existing IF-leaf / truncated-subtraction behavior.
|
|
6
|
+
export function storedInputs(m) {
|
|
7
|
+
const out = new Map();
|
|
8
|
+
const leaves = (e, to) => { if (e.op === 'var') {
|
|
9
|
+
if (m.inputs.includes(e.name) && !out.has(e.name))
|
|
10
|
+
out.set(e.name, to);
|
|
11
|
+
}
|
|
12
|
+
else if (e.op === 'if') {
|
|
13
|
+
leaves(e.then, to);
|
|
14
|
+
leaves(e.else, to);
|
|
15
|
+
} };
|
|
16
|
+
for (const [v, e] of Object.entries(m.step.state ?? {}))
|
|
17
|
+
leaves(e.op === 'sub' ? e.a : e, v);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
const json = (v) => JSON.stringify(v);
|
|
21
|
+
const eq = (a, b) => json(a) === json(b);
|
|
22
|
+
const yes = same(n(0), n(0)), no = not(yes);
|
|
23
|
+
const vars = (t) => { const out = new Set(); walk(t, o => { if (o.op === 'var' && typeof o.name === 'string')
|
|
24
|
+
out.add(o.name); }); return [...out]; };
|
|
25
|
+
const flat = (c, op) => c.op === op ? c.xs.flatMap(q => flat(q, op)) : [c];
|
|
26
|
+
// Partial evaluation at an entry guard also recognizes the DSL's Boolean-map encoding.
|
|
27
|
+
function simplify(c, at = yes, value = true) {
|
|
28
|
+
if (eq(c, at))
|
|
29
|
+
return value ? yes : no;
|
|
30
|
+
if (c.op === 'not') {
|
|
31
|
+
const q = simplify(c.x, at, value);
|
|
32
|
+
return eq(q, yes) ? no : eq(q, no) ? yes : q.op === 'not' ? q.x : not(q);
|
|
33
|
+
}
|
|
34
|
+
if (c.op === 'and' || c.op === 'or') {
|
|
35
|
+
const unit = c.op === 'and' ? yes : no, zero = c.op === 'and' ? no : yes;
|
|
36
|
+
const qs = flat(c, c.op).map(q => simplify(q, at, value));
|
|
37
|
+
if (qs.some(q => eq(q, zero)) || qs.some(q => qs.some(r => eq(q, not(r)))))
|
|
38
|
+
return zero;
|
|
39
|
+
const xs = [...new Map(qs.filter(q => !eq(q, unit)).map(q => [json(q), q])).values()];
|
|
40
|
+
return xs.length === 0 ? unit : xs.length === 1 ? xs[0] : { op: c.op, xs };
|
|
41
|
+
}
|
|
42
|
+
if ((c.op === '=' || c.op === '<' || c.op === '<=') && c.a.op === 'const' && c.b.op === 'const')
|
|
43
|
+
return (c.op === '=' ? c.a.value === c.b.value : c.op === '<' ? c.a.value < c.b.value : c.a.value <= c.b.value) ? yes : no;
|
|
44
|
+
return c;
|
|
45
|
+
}
|
|
46
|
+
function atGuard(e, guard) {
|
|
47
|
+
if (e.op !== 'if')
|
|
48
|
+
return e;
|
|
49
|
+
const c = simplify(e.c, guard), a = atGuard(e.then, guard), b = atGuard(e.else, guard);
|
|
50
|
+
return eq(c, yes) ? a : eq(c, no) ? b : { op: 'if', c, then: a, else: b };
|
|
51
|
+
}
|
|
52
|
+
function positive(c) {
|
|
53
|
+
// The cube engine writes 0 + 1 <= 0 + cell; compare that same atom, not its spelling.
|
|
54
|
+
const bare = (e) => e.op === 'add' && eq(e.a, n(0)) ? bare(e.b) : e.op === 'add' && eq(e.b, n(0)) ? bare(e.a) : e;
|
|
55
|
+
if (c.op === '<=') {
|
|
56
|
+
const a = bare(c.a), b = bare(c.b);
|
|
57
|
+
if (eq(a, n(1)) && b.op === 'get')
|
|
58
|
+
return b;
|
|
59
|
+
}
|
|
60
|
+
if (c.op === '=') {
|
|
61
|
+
const a = bare(c.a), b = bare(c.b);
|
|
62
|
+
if (eq(b, n(1)) && a.op === 'get')
|
|
63
|
+
return a;
|
|
64
|
+
}
|
|
65
|
+
if (c.op === 'not' && c.x.op === '=') {
|
|
66
|
+
const a = bare(c.x.a), b = bare(c.x.b);
|
|
67
|
+
if (eq(b, n(0)) && a.op === 'get')
|
|
68
|
+
return a;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
// Small CNF expansion, bounded independently of proof/search budgets; incomplete is fine.
|
|
73
|
+
function clauses(c, flags, bound, depth = 0, fuel = { left: 4096 }) {
|
|
74
|
+
if (depth > 24 || --fuel.left < 0)
|
|
75
|
+
return [];
|
|
76
|
+
if (c.op === 'flag') {
|
|
77
|
+
const q = flags[c.name];
|
|
78
|
+
return q ? clauses(q, flags, bound, depth + 1, fuel) : [[c]];
|
|
79
|
+
}
|
|
80
|
+
if (c.op === 'all') {
|
|
81
|
+
for (const k of [c.key, ...(c.keys ?? [])])
|
|
82
|
+
bound.add(k);
|
|
83
|
+
return clauses(c.c, flags, bound, depth + 1, fuel);
|
|
84
|
+
}
|
|
85
|
+
if (c.op === 'not' && c.x.op === 'flag') {
|
|
86
|
+
const q = flags[c.x.name];
|
|
87
|
+
return q && q.op !== 'all' ? clauses(not(q), flags, bound, depth + 1, fuel) : [[c]];
|
|
88
|
+
}
|
|
89
|
+
if (c.op === 'not' && c.x.op === 'not')
|
|
90
|
+
return clauses(c.x.x, flags, bound, depth + 1, fuel);
|
|
91
|
+
if (c.op === 'not' && (c.x.op === 'and' || c.x.op === 'or'))
|
|
92
|
+
return clauses({ op: c.x.op === 'and' ? 'or' : 'and', xs: c.x.xs.map(not) }, flags, bound, depth + 1, fuel);
|
|
93
|
+
if (c.op === 'and') {
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const q of c.xs) {
|
|
96
|
+
if (out.length >= 64 || fuel.left <= 0)
|
|
97
|
+
break;
|
|
98
|
+
out.push(...clauses(q, flags, bound, depth + 1, fuel).slice(0, 64 - out.length));
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
if (c.op === 'or') {
|
|
103
|
+
let out = [[]];
|
|
104
|
+
for (const q of c.xs) {
|
|
105
|
+
const cs = clauses(q, flags, bound, depth + 1, fuel);
|
|
106
|
+
if (!cs.length || out.length * cs.length > 64)
|
|
107
|
+
return [];
|
|
108
|
+
out = out.flatMap(a => cs.map(b => [...a, ...b]));
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
return [[c]];
|
|
113
|
+
}
|
|
114
|
+
// Linear packed-key matching: match by coefficient, not association or variable names.
|
|
115
|
+
function linear(e, k = 1, out = new Map()) {
|
|
116
|
+
if (e.op === 'var') {
|
|
117
|
+
out.set(e.name, (out.get(e.name) ?? 0) + k);
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
if (e.op === 'const')
|
|
121
|
+
return e.value === 0 ? out : undefined;
|
|
122
|
+
if (e.op === 'mul')
|
|
123
|
+
return linear(e.a, k * e.k, out);
|
|
124
|
+
return e.op === 'add' && linear(e.a, k, out) ? linear(e.b, k, out) : undefined;
|
|
125
|
+
}
|
|
126
|
+
function match(pattern, actual) {
|
|
127
|
+
const p = linear(pattern), a = linear(actual);
|
|
128
|
+
if (!p || !a || p.size !== a.size || new Set(p.values()).size !== p.size || new Set(a.values()).size !== a.size)
|
|
129
|
+
return;
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const [v, k] of p) {
|
|
132
|
+
const w = [...a].find(([, j]) => j === k);
|
|
133
|
+
if (!w)
|
|
134
|
+
return;
|
|
135
|
+
out[v] = x(w[0]);
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
export function carryCandidates(m, occupied = [], audit = { rows: [], work: 0, exhausted: false }) {
|
|
140
|
+
const flags = m.step.flags ?? {}, copies = storedInputs(m), out = new Map();
|
|
141
|
+
// Bound unsuccessful generation as well as output; local to this invocation.
|
|
142
|
+
let work = 0;
|
|
143
|
+
const more = () => { if (work >= 8192) {
|
|
144
|
+
audit.exhausted = true;
|
|
145
|
+
return false;
|
|
146
|
+
} audit.work = ++work; return out.size < 128; };
|
|
147
|
+
const taken = new Set([...m.params, ...m.inputs, ...Object.keys(m.state), ...Object.keys(m.maps ?? {}), ...(m.inputMaps ?? [])]);
|
|
148
|
+
walk(m, o => { if (typeof o.name === 'string')
|
|
149
|
+
taken.add(o.name); if (typeof o.key === 'string')
|
|
150
|
+
taken.add(o.key); });
|
|
151
|
+
const fresh = () => { let s = 'carryKey'; while (taken.has(s))
|
|
152
|
+
s += 'X'; taken.add(s); return s; };
|
|
153
|
+
const add = (holds, bound, family) => {
|
|
154
|
+
if (out.size >= 128)
|
|
155
|
+
return; // proposal cap only; never a proof/search budget
|
|
156
|
+
const ks = vars(holds).filter(v => bound.has(v)), signature = json([ks, holds]);
|
|
157
|
+
let h = 14695981039346656037n;
|
|
158
|
+
for (let i = 0; i < signature.length; i++)
|
|
159
|
+
h = BigInt.asUintN(64, (h ^ BigInt(signature.charCodeAt(i))) * 1099511628211n);
|
|
160
|
+
const name = `carry:${family}:${h.toString(16)}`;
|
|
161
|
+
const l = { name, holds, ...(ks.length ? { forall: ks[0], ...(ks.length > 1 ? { keys: ks.slice(1) } : {}) } : {}) };
|
|
162
|
+
if (occupied.some(l => l.name === name))
|
|
163
|
+
return;
|
|
164
|
+
try {
|
|
165
|
+
scope(m, [l]);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const prev = out.get(name);
|
|
171
|
+
if (prev && !eq(prev, l)) {
|
|
172
|
+
out.delete(name);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
out.set(name, l);
|
|
176
|
+
};
|
|
177
|
+
const bridges = [];
|
|
178
|
+
bridges: for (const law of occupied)
|
|
179
|
+
for (const row of clauses(law.holds, {}, new Set())) {
|
|
180
|
+
if (!more())
|
|
181
|
+
return [...out.values()];
|
|
182
|
+
for (const a of row)
|
|
183
|
+
if (a.op === 'not') {
|
|
184
|
+
const from = positive(a.x);
|
|
185
|
+
if (from)
|
|
186
|
+
for (const b of row) {
|
|
187
|
+
const to = positive(b);
|
|
188
|
+
if (to && to.map !== from.map && bridges.length < 64) {
|
|
189
|
+
bridges.push({ from, to });
|
|
190
|
+
if (bridges.length === 64)
|
|
191
|
+
break bridges;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
for (const [mode, w] of Object.entries(m.step.state ?? {})) {
|
|
197
|
+
if (!more())
|
|
198
|
+
return [...out.values()];
|
|
199
|
+
if (w.op !== 'if' || w.then.op !== 'const')
|
|
200
|
+
continue;
|
|
201
|
+
const sub = { vars: {}, maps: {}, flags: {} };
|
|
202
|
+
for (const [input, target] of copies) {
|
|
203
|
+
const e = m.step.state?.[target];
|
|
204
|
+
if (e?.op === 'if' && eq(e.c, w.c) && eq(e.then, x(input)))
|
|
205
|
+
sub.vars[input] = x(target);
|
|
206
|
+
}
|
|
207
|
+
if (!Object.keys(sub.vars).length)
|
|
208
|
+
continue;
|
|
209
|
+
for (const [target, update] of Object.entries(m.step.maps ?? {}))
|
|
210
|
+
if ('each' in update) {
|
|
211
|
+
const e = atGuard(update.value, w.c), cell = e.op === 'get' ? e : e.op === 'if' && eq(e.then, n(1)) && eq(e.else, n(0)) ? positive(e.c) : undefined;
|
|
212
|
+
if (cell && m.inputMaps?.includes(cell.map) && eq(cell.key, x(update.each)))
|
|
213
|
+
sub.maps[cell.map] = key => ({ op: 'get', map: target, key });
|
|
214
|
+
}
|
|
215
|
+
const bound = new Set(), active = same(x(mode), w.then);
|
|
216
|
+
const source = clauses(all(w.c, ...(m.assume ? [m.assume] : [])), flags, bound);
|
|
217
|
+
for (const row of source) {
|
|
218
|
+
if (!more())
|
|
219
|
+
return [...out.values()];
|
|
220
|
+
const variants = [row];
|
|
221
|
+
for (let i = 0; i < row.length; i++) {
|
|
222
|
+
const c = positive(row[i]);
|
|
223
|
+
if (!c)
|
|
224
|
+
continue;
|
|
225
|
+
for (const b of bridges)
|
|
226
|
+
if (c.map === b.from.map) {
|
|
227
|
+
if (!more())
|
|
228
|
+
return [...out.values()];
|
|
229
|
+
const vs = match(b.from.key, c.key);
|
|
230
|
+
if (vs)
|
|
231
|
+
variants.push(row.map((q, j) => j === i ? { op: '<=', a: n(1), b: substE(b.to, { vars: vs, maps: {}, flags: {} }) } : q));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const rs of variants) {
|
|
235
|
+
if (!more())
|
|
236
|
+
return [...out.values()];
|
|
237
|
+
const raw = any(...rs), names = vars(raw);
|
|
238
|
+
// The entry's old control state is not the new stored state. Unretained inputs
|
|
239
|
+
// make this whole CNF clause unavailable; never erase a disjunct to strengthen it.
|
|
240
|
+
if (names.some(v => v in m.state) || !names.some(v => v in sub.vars) && !Object.keys(sub.maps).some(mp => json(raw).includes(`"map":${json(mp)}`)))
|
|
241
|
+
continue;
|
|
242
|
+
if (rs.some(q => q.op === 'flag' || q.op === 'not' && q.x.op === 'flag'))
|
|
243
|
+
continue;
|
|
244
|
+
const c = substC(raw, sub);
|
|
245
|
+
add(any(not(active), c), bound, 'guard');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Co-written monotone point and interval maps. Keep the source interval and input
|
|
250
|
+
// bounds; no protocol names, guessed domain constants, or invariant seeds.
|
|
251
|
+
const inserts = (map, key, value) => {
|
|
252
|
+
if (value.op !== 'if' || !eq(value.then, n(1)) || !eq(value.else, n(0)))
|
|
253
|
+
return [];
|
|
254
|
+
const c = simplify(value.c), branches = clauses(not(c), {}, new Set()).map(row => row.map(q => simplify(not(q))));
|
|
255
|
+
return branches.filter(row => !row.some(q => json(q).includes(json({ op: 'get', map, key }))));
|
|
256
|
+
};
|
|
257
|
+
for (const [mp, point] of Object.entries(m.step.maps ?? {})) {
|
|
258
|
+
if (!more())
|
|
259
|
+
return [...out.values()];
|
|
260
|
+
if ('each' in point)
|
|
261
|
+
continue;
|
|
262
|
+
const ps = vars(point.key);
|
|
263
|
+
if (!ps.length || ps.some(v => !m.inputs.includes(v)))
|
|
264
|
+
continue;
|
|
265
|
+
for (const g of inserts(mp, point.key, point.value))
|
|
266
|
+
for (const [other, interval] of Object.entries(m.step.maps ?? {})) {
|
|
267
|
+
if (!more())
|
|
268
|
+
return [...out.values()];
|
|
269
|
+
if (!('each' in interval))
|
|
270
|
+
continue;
|
|
271
|
+
for (const row of inserts(other, x(interval.each), interval.value)) {
|
|
272
|
+
if (!more())
|
|
273
|
+
return [...out.values()];
|
|
274
|
+
if (!g.every(q => row.some(r => eq(q, r))))
|
|
275
|
+
continue;
|
|
276
|
+
const rest = row.filter(q => !g.some(r => eq(q, r)));
|
|
277
|
+
const lo = rest.find((q) => q.op === '<=' && eq(q.b, x(interval.each)));
|
|
278
|
+
const hi = rest.find((q) => q.op === '<' && eq(q.a, x(interval.each)));
|
|
279
|
+
if (!lo || !hi || rest.length !== 2 || hi.b.op !== 'add' || !eq(hi.b.a, lo.a))
|
|
280
|
+
continue;
|
|
281
|
+
const z = fresh(), names = ps.map(() => fresh()), vs = Object.fromEntries(ps.map((p, i) => [p, x(names[i])])), bound = new Set([...names, z]);
|
|
282
|
+
const s = { vars: { ...vs, [interval.each]: { op: 'add', a: lo.a, b: x(z) } }, maps: {}, flags: {} };
|
|
283
|
+
const domains = m.assume ? clauses(m.assume, {}, new Set()).filter(r => vars(r).every(v => ps.includes(v) || m.params.includes(v))).map(r => any(...r)) : [];
|
|
284
|
+
const hyp = all(...domains, { op: '<', a: x(z), b: hi.b.b }, { op: '<=', a: n(1), b: { op: 'get', map: mp, key: point.key } });
|
|
285
|
+
// Substitute the interval key before the point variables (substitution is simultaneous).
|
|
286
|
+
const cell = substE(substE({ op: 'get', map: other, key: x(interval.each) }, s), { vars: vs, maps: {}, flags: {} });
|
|
287
|
+
add(any(not(substC(hyp, { vars: vs, maps: {}, flags: {} })), { op: '<=', a: n(1), b: cell }), bound, 'co-write');
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// New rules are appended; existing guarded/co-write candidates and their order survive.
|
|
292
|
+
// Only unconditional transition input bounds are used. m.pre is param-only by scope.
|
|
293
|
+
const pre = flat(m.pre ?? yes, 'and'), transition = flat(m.assume ?? yes, 'and');
|
|
294
|
+
const paramOnly = (e) => vars(e).every(v => m.params.includes(v)) && !json(e).includes('"op":"get"') && !json(e).includes('"op":"flag"');
|
|
295
|
+
const bounds = transition.filter((c) => c.op === '<' && c.a.op === 'var' && m.inputs.includes(c.a.name) && paramOnly(c.b));
|
|
296
|
+
for (const [target, update] of Object.entries(m.step.state ?? {}))
|
|
297
|
+
for (const b of bounds) {
|
|
298
|
+
if (!more())
|
|
299
|
+
return [...out.values()];
|
|
300
|
+
const input = b.a.name, bound = b.b, allowedInputs = new Set(bounds.filter(q => eq(q.b, bound)).map(q => q.a.name));
|
|
301
|
+
const safe = (e) => boundKnown(e, bound, pre);
|
|
302
|
+
let copied = false;
|
|
303
|
+
const leaves = (e, depth = 0) => { if (!more() || depth > 48)
|
|
304
|
+
return false; if (e.op === 'if')
|
|
305
|
+
return leaves(e.then, depth + 1) && leaves(e.else, depth + 1); if (e.op === 'var' && e.name === target)
|
|
306
|
+
return true; if (e.op === 'var' && allowedInputs.has(e.name)) {
|
|
307
|
+
copied = true;
|
|
308
|
+
return true;
|
|
309
|
+
} return safe(e); };
|
|
310
|
+
if (!safe(m.state[target])) {
|
|
311
|
+
audit.rows.push({ rule: 'range', target, input, accepted: false, reason: 'initial bound not established' });
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const accepted = leaves(update) && copied;
|
|
315
|
+
audit.rows.push({ rule: 'range', target, input, accepted, reason: accepted ? 'all leaves preserve exact source bound' : 'unsafe or unbounded update leaf' });
|
|
316
|
+
if (accepted)
|
|
317
|
+
add({ op: '<', a: x(target), b: bound }, new Set(), 'global-range');
|
|
318
|
+
}
|
|
319
|
+
const guarded = [...out.values()];
|
|
320
|
+
for (const l of guarded) {
|
|
321
|
+
if (!more())
|
|
322
|
+
return [...out.values()];
|
|
323
|
+
if (l.holds.op !== 'or' || l.holds.xs.length !== 2)
|
|
324
|
+
continue;
|
|
325
|
+
const [g, body] = l.holds.xs;
|
|
326
|
+
if (g?.op !== 'not' || g.x.op !== '=' || g.x.a.op !== 'var' || g.x.b.op !== 'const' || !body)
|
|
327
|
+
continue;
|
|
328
|
+
const mode = g.x.a.name, entry = m.step.state?.[mode];
|
|
329
|
+
if (entry?.op !== 'if' || !eq(entry.then, g.x.b))
|
|
330
|
+
continue;
|
|
331
|
+
const qs = flat(body, 'or'), negative = qs.flatMap(q => { const atom = q.op === 'not' ? q.x : not(q), cell = positiveExact(atom); return cell ? [{ atom, cell, clause: q }] : []; }), positive = qs.flatMap(q => positiveExact(q) ? [{ atom: q, cell: positiveExact(q) }] : []);
|
|
332
|
+
if (negative.length !== 1 || positive.length !== 1)
|
|
333
|
+
continue;
|
|
334
|
+
const domain = negative[0], range = positive[0];
|
|
335
|
+
if (domain.cell.map === range.cell.map || qs.some(q => q !== domain.clause && q !== range.atom && json(q).includes('"op":"get"')))
|
|
336
|
+
continue;
|
|
337
|
+
const update = m.step.maps?.[domain.cell.map], persistent = m.step.maps?.[range.cell.map];
|
|
338
|
+
if (!update || !('each' in update) || !persistent || m.maps?.[domain.cell.map] !== 0 || domain.cell.key.op !== 'var')
|
|
339
|
+
continue;
|
|
340
|
+
const entryFacts = factsWith(new Map(), entry.c, true), entryValue = foldE(update.value, entryFacts, more);
|
|
341
|
+
let sourceCell;
|
|
342
|
+
if (entryValue?.op === 'get' && m.inputMaps?.includes(entryValue.map) && eq(entryValue.key, x(update.each)))
|
|
343
|
+
sourceCell = entryValue;
|
|
344
|
+
else if (entryValue?.op === 'if' && eq(entryValue.then, n(1)) && eq(entryValue.else, n(0))) {
|
|
345
|
+
const p = positiveExact(entryValue.c);
|
|
346
|
+
if (p && m.inputMaps?.includes(p.map) && eq(p.key, x(update.each))) {
|
|
347
|
+
const inverse = substC(domain.atom, { vars: { [domain.cell.key.name]: x(update.each) }, maps: { [domain.cell.map]: key => ({ op: 'get', map: p.map, key }) }, flags: {} });
|
|
348
|
+
// No Eq1/>=1/nonzero normalization is permitted across the copy.
|
|
349
|
+
if (eq(inverse, entryValue.c))
|
|
350
|
+
sourceCell = p;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (!sourceCell) {
|
|
354
|
+
audit.rows.push({ rule: 'frame', target: l.name, accepted: false, reason: 'copy predicate is not exact' });
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const oldCell = { op: 'get', map: range.cell.map, key: 'each' in persistent ? x(persistent.each) : persistent.key }, atOld = replaceCell(range.atom, range.cell, oldCell), post = replaceCell(range.atom, range.cell, persistent.value);
|
|
358
|
+
const retained = foldC(post, factsWith(new Map(), atOld, true), more);
|
|
359
|
+
if (!retained || !eq(retained, yes)) {
|
|
360
|
+
audit.rows.push({ rule: 'frame', target: l.name, accepted: false, reason: 'consequent positivity not preserved' });
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const fields = vars(body).filter(v => v in m.state), oldDomain = { op: 'get', map: domain.cell.map, key: x(update.each) }, oldAtom = substC(domain.atom, { vars: { [domain.cell.key.name]: x(update.each) }, maps: {}, flags: {} });
|
|
364
|
+
const outside = factsWith(new Map(), entry.c, false);
|
|
365
|
+
const framed = (e, fs, depth = 0) => {
|
|
366
|
+
if (!more() || depth > 48)
|
|
367
|
+
return false;
|
|
368
|
+
const value = foldE(e, fs, more);
|
|
369
|
+
if (!value)
|
|
370
|
+
return false;
|
|
371
|
+
if (value.op === 'if')
|
|
372
|
+
return framed(value.then, factsWith(fs, value.c, true), depth + 1) && framed(value.else, factsWith(fs, value.c, false), depth + 1);
|
|
373
|
+
const after = foldC(replaceCell(oldAtom, oldDomain, value), fs, more);
|
|
374
|
+
if (after && eq(after, no))
|
|
375
|
+
return true;
|
|
376
|
+
const prior = foldC(oldAtom, fs, more);
|
|
377
|
+
if (!eq(value, oldDomain) && (!prior || !eq(prior, yes)))
|
|
378
|
+
return false;
|
|
379
|
+
return fields.every(v => { const post = foldE(m.step.state?.[v] ?? x(v), fs, more); return !!post && eq(post, x(v)); });
|
|
380
|
+
};
|
|
381
|
+
const accepted = framed(update.value, outside);
|
|
382
|
+
audit.rows.push({ rule: 'frame', target: l.name, accepted, reason: accepted ? 'empty init, exact entry copy, clear-or-frame, persistent positive target' : 'outside-entry path unframed' });
|
|
383
|
+
if (accepted)
|
|
384
|
+
add(body, new Set([l.forall, ...(l.keys ?? [])].filter((v) => !!v)), 'global-frame');
|
|
385
|
+
}
|
|
386
|
+
// Appended point/point proposals: syntax is eligibility, never a transition fact.
|
|
387
|
+
// Accept only the two exact Boolean retention shapes; no arbitrary self read.
|
|
388
|
+
const insertion = (map, key, value) => {
|
|
389
|
+
if (!more() || value.op !== 'if' || !eq(value.then, n(1)) || !eq(value.else, n(0)))
|
|
390
|
+
return;
|
|
391
|
+
const branches = flat(simplify(value.c), 'or'), prior = same({ op: 'get', map, key }, n(1));
|
|
392
|
+
if (branches.length !== 2)
|
|
393
|
+
return;
|
|
394
|
+
for (let i = 0; i < 2; i++) {
|
|
395
|
+
const guard = branches[i], retained = branches[1 - i];
|
|
396
|
+
if (eq(retained, prior) || eq(retained, simplify(all(not(guard), prior))))
|
|
397
|
+
return guard;
|
|
398
|
+
}
|
|
399
|
+
return;
|
|
400
|
+
};
|
|
401
|
+
// Complete, bounded expansion of plain flags only. In particular an OR keeps
|
|
402
|
+
// every arm, and quantified/opaque/cyclic flags cannot supply a free binder.
|
|
403
|
+
const plain = (c, depth = 0) => {
|
|
404
|
+
if (!more() || depth > 24 || c.op === 'all')
|
|
405
|
+
return;
|
|
406
|
+
if (c.op === 'flag') {
|
|
407
|
+
const q = flags[c.name];
|
|
408
|
+
return q ? plain(q, depth + 1) : undefined;
|
|
409
|
+
}
|
|
410
|
+
if (c.op === 'not') {
|
|
411
|
+
const q = plain(c.x, depth + 1);
|
|
412
|
+
return q ? not(q) : undefined;
|
|
413
|
+
}
|
|
414
|
+
if (c.op === 'and' || c.op === 'or') {
|
|
415
|
+
const xs = [];
|
|
416
|
+
for (const x of c.xs) {
|
|
417
|
+
const q = plain(x, depth + 1);
|
|
418
|
+
if (!q)
|
|
419
|
+
return;
|
|
420
|
+
xs.push(q);
|
|
421
|
+
}
|
|
422
|
+
return { op: c.op, xs };
|
|
423
|
+
}
|
|
424
|
+
return c;
|
|
425
|
+
};
|
|
426
|
+
for (const [source, point] of Object.entries(m.step.maps ?? {})) {
|
|
427
|
+
if (!more())
|
|
428
|
+
return [...out.values()];
|
|
429
|
+
if ('each' in point || m.maps?.[source] !== 0)
|
|
430
|
+
continue;
|
|
431
|
+
const ps = vars(point.key), affine = linear(point.key);
|
|
432
|
+
if (!ps.length || !affine || [...affine.values()].some(k => !Number.isSafeInteger(k) || k <= 0) || ps.some(p => !m.inputs.includes(p)))
|
|
433
|
+
continue;
|
|
434
|
+
const domains = bounds.filter(b => ps.includes(b.a.name));
|
|
435
|
+
if (ps.some(p => !domains.some(b => eq(b.a, x(p)))))
|
|
436
|
+
continue;
|
|
437
|
+
const guard = insertion(source, point.key, point.value), expanded = guard && plain(guard);
|
|
438
|
+
if (!expanded)
|
|
439
|
+
continue;
|
|
440
|
+
const names = ps.map(() => fresh()), at = { vars: Object.fromEntries(ps.map((p, i) => [p, x(names[i])])), maps: {}, flags: {} }, bound = new Set(names);
|
|
441
|
+
// Only necessary unit conjuncts are eligible, never one selected OR arm.
|
|
442
|
+
for (const atom of flat(expanded, 'and')) {
|
|
443
|
+
if (!more())
|
|
444
|
+
return [...out.values()];
|
|
445
|
+
if (atom.op !== '=')
|
|
446
|
+
continue;
|
|
447
|
+
const dest = eq(atom.b, n(1)) && atom.a.op === 'get' ? atom.a : eq(atom.a, n(1)) && atom.b.op === 'get' ? atom.b : undefined;
|
|
448
|
+
if (!dest || dest.map === source || !Object.hasOwn(m.maps ?? {}, dest.map) || !linear(dest.key) || vars(dest.key).some(p => !ps.includes(p) && !m.params.includes(p)))
|
|
449
|
+
continue;
|
|
450
|
+
const update = m.step.maps?.[dest.map];
|
|
451
|
+
if (!update || 'each' in update || !insertion(dest.map, update.key, update.value))
|
|
452
|
+
continue;
|
|
453
|
+
const hyp = all(...domains, { op: '<=', a: n(1), b: { op: 'get', map: source, key: point.key } }), size = out.size;
|
|
454
|
+
add(substC(any(not(hyp), same(dest, n(1))), at), bound, 'point-guard');
|
|
455
|
+
if (out.size > size)
|
|
456
|
+
audit.rows.push({ rule: 'point-guard', target: source, accepted: true, reason: 'exact insertion guard, persistent-one destination, source bounds; proposal only' });
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return [...out.values()];
|
|
460
|
+
}
|
|
461
|
+
function factsWith(fs, c, value) {
|
|
462
|
+
const out = new Map(fs);
|
|
463
|
+
const add = (q, v, depth = 0) => { if (depth > 48)
|
|
464
|
+
return; out.set(json(q), { c: q, value: v }); if (q.op === 'not')
|
|
465
|
+
add(q.x, !v, depth + 1);
|
|
466
|
+
else if (q.op === 'and' && v || q.op === 'or' && !v)
|
|
467
|
+
for (const x of q.xs)
|
|
468
|
+
add(x, v, depth + 1); };
|
|
469
|
+
add(c, value);
|
|
470
|
+
return out;
|
|
471
|
+
}
|
|
472
|
+
function positiveExact(c) {
|
|
473
|
+
if (c.op === '=' && eq(c.b, n(1)) && c.a.op === 'get')
|
|
474
|
+
return c.a;
|
|
475
|
+
if (c.op === '=' && eq(c.a, n(1)) && c.b.op === 'get')
|
|
476
|
+
return c.b;
|
|
477
|
+
if (c.op === '<=' && eq(c.a, n(1)) && c.b.op === 'get')
|
|
478
|
+
return c.b;
|
|
479
|
+
if (c.op === 'not' && c.x.op === '=' && eq(c.x.b, n(0)) && c.x.a.op === 'get')
|
|
480
|
+
return c.x.a;
|
|
481
|
+
if (c.op === 'not' && c.x.op === '=' && eq(c.x.a, n(0)) && c.x.b.op === 'get')
|
|
482
|
+
return c.x.b;
|
|
483
|
+
return undefined;
|
|
484
|
+
}
|
|
485
|
+
function replaceCell(c, old, value) { return substC(c, { vars: {}, maps: { [old.map]: key => eq(key, old.key) ? value : { op: 'get', map: old.map, key } }, flags: {} }); }
|
|
486
|
+
function boundKnown(e, b, pre) {
|
|
487
|
+
if (pre.some(c => c.op === '<' && eq(c.a, e) && eq(c.b, b)))
|
|
488
|
+
return true;
|
|
489
|
+
if (e.op !== 'const' || e.value < 0)
|
|
490
|
+
return false;
|
|
491
|
+
if (b.op === 'const')
|
|
492
|
+
return e.value < b.value;
|
|
493
|
+
return pre.some(c => (c.op === '<' || c.op === '<=') && c.a.op === 'const' && eq(c.b, b) && e.value < (c.op === '<' ? c.a.value + 1 : c.a.value));
|
|
494
|
+
}
|
|
495
|
+
function foldE(e, fs, tick, depth = 0) {
|
|
496
|
+
if (!tick() || depth > 48)
|
|
497
|
+
return;
|
|
498
|
+
for (const { c, value } of fs.values())
|
|
499
|
+
if (value && c.op === '=') {
|
|
500
|
+
if (eq(c.a, e) && c.b.op === 'const')
|
|
501
|
+
return c.b;
|
|
502
|
+
if (eq(c.b, e) && c.a.op === 'const')
|
|
503
|
+
return c.a;
|
|
504
|
+
}
|
|
505
|
+
if (e.op === 'if') {
|
|
506
|
+
const c = foldC(e.c, fs, tick, depth + 1);
|
|
507
|
+
if (!c)
|
|
508
|
+
return;
|
|
509
|
+
if (eq(c, yes))
|
|
510
|
+
return foldE(e.then, fs, tick, depth + 1);
|
|
511
|
+
if (eq(c, no))
|
|
512
|
+
return foldE(e.else, fs, tick, depth + 1);
|
|
513
|
+
const a = foldE(e.then, fs, tick, depth + 1), b = foldE(e.else, fs, tick, depth + 1);
|
|
514
|
+
if (!a || !b)
|
|
515
|
+
return;
|
|
516
|
+
return eq(a, b) ? a : { op: 'if', c, then: a, else: b };
|
|
517
|
+
}
|
|
518
|
+
if (e.op === 'get') {
|
|
519
|
+
const key = foldE(e.key, fs, tick, depth + 1);
|
|
520
|
+
return key ? { ...e, key } : undefined;
|
|
521
|
+
}
|
|
522
|
+
if (e.op === 'add' || e.op === 'sub' || e.op === 'min' || e.op === 'max' || e.op === 'prod') {
|
|
523
|
+
const a = foldE(e.a, fs, tick, depth + 1), b = foldE(e.b, fs, tick, depth + 1);
|
|
524
|
+
if (!a || !b)
|
|
525
|
+
return;
|
|
526
|
+
if (a.op === 'const' && b.op === 'const')
|
|
527
|
+
return n(e.op === 'add' ? a.value + b.value : e.op === 'sub' ? Math.max(0, a.value - b.value) : e.op === 'min' ? Math.min(a.value, b.value) : e.op === 'max' ? Math.max(a.value, b.value) : a.value * b.value);
|
|
528
|
+
return { ...e, a, b };
|
|
529
|
+
}
|
|
530
|
+
if (e.op === 'mul') {
|
|
531
|
+
const a = foldE(e.a, fs, tick, depth + 1);
|
|
532
|
+
return a ? (a.op === 'const' ? n(e.k * a.value) : { ...e, a }) : undefined;
|
|
533
|
+
}
|
|
534
|
+
return e;
|
|
535
|
+
}
|
|
536
|
+
function foldC(c, fs, tick, depth = 0) {
|
|
537
|
+
if (!tick() || depth > 48)
|
|
538
|
+
return;
|
|
539
|
+
const f = fs.get(json(c));
|
|
540
|
+
if (f)
|
|
541
|
+
return f.value ? yes : no;
|
|
542
|
+
if (c.op === 'not') {
|
|
543
|
+
const q = foldC(c.x, fs, tick, depth + 1);
|
|
544
|
+
return q ? (eq(q, yes) ? no : eq(q, no) ? yes : q.op === 'not' ? q.x : not(q)) : undefined;
|
|
545
|
+
}
|
|
546
|
+
if (c.op === 'and' || c.op === 'or') {
|
|
547
|
+
const unit = c.op === 'and' ? yes : no, zero = c.op === 'and' ? no : yes, qs = [];
|
|
548
|
+
for (const x of flat(c, c.op)) {
|
|
549
|
+
const q = foldC(x, fs, tick, depth + 1);
|
|
550
|
+
if (!q)
|
|
551
|
+
return;
|
|
552
|
+
if (eq(q, zero))
|
|
553
|
+
return zero;
|
|
554
|
+
if (!eq(q, unit))
|
|
555
|
+
qs.push(q);
|
|
556
|
+
}
|
|
557
|
+
if (qs.some(q => qs.some(r => eq(q, not(r)) || eq(r, not(q)))))
|
|
558
|
+
return zero;
|
|
559
|
+
const unique = [...new Map(qs.map(q => [json(q), q])).values()];
|
|
560
|
+
return !unique.length ? unit : unique.length === 1 ? unique[0] : { op: c.op, xs: unique };
|
|
561
|
+
}
|
|
562
|
+
if (c.op === '=' || c.op === '<' || c.op === '<=') {
|
|
563
|
+
const a = foldE(c.a, fs, tick, depth + 1), b = foldE(c.b, fs, tick, depth + 1);
|
|
564
|
+
if (!a || !b)
|
|
565
|
+
return;
|
|
566
|
+
if (eq(a, b))
|
|
567
|
+
return c.op === '<' ? no : yes;
|
|
568
|
+
if (a.op === 'const' && b.op === 'const')
|
|
569
|
+
return (c.op === '=' ? a.value === b.value : c.op === '<' ? a.value < b.value : a.value <= b.value) ? yes : no;
|
|
570
|
+
return { ...c, a, b };
|
|
571
|
+
}
|
|
572
|
+
return c;
|
|
573
|
+
}
|
|
574
|
+
export function scanPrefixes(m, occupied = []) {
|
|
575
|
+
const flags = m.step.flags ?? {}, packets = [];
|
|
576
|
+
let work = 0;
|
|
577
|
+
const more = () => ++work <= 8192 && packets.length < 64;
|
|
578
|
+
const eq = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
579
|
+
const sub = (c, from, to) => substC(c, { vars: { [from]: to }, maps: {}, flags: {} });
|
|
580
|
+
const parts = (c) => c.op === 'and' ? c.xs.flatMap(parts) : [c];
|
|
581
|
+
const closure = (c, seen = new Set()) => {
|
|
582
|
+
const rs = [c];
|
|
583
|
+
walk(c, o => {
|
|
584
|
+
if (o.op === 'flag' && typeof o.name === 'string' && !seen.has(o.name)) {
|
|
585
|
+
seen.add(o.name);
|
|
586
|
+
const f = flags[o.name];
|
|
587
|
+
if (f && f.op !== 'all')
|
|
588
|
+
rs.push(...closure(f, seen));
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
return rs;
|
|
592
|
+
};
|
|
593
|
+
// Stable structural discriminator; collisions are detected below, not trusted away.
|
|
594
|
+
const tag = (s) => {
|
|
595
|
+
let h = 14695981039346656037n;
|
|
596
|
+
for (let i = 0; i < s.length; i++)
|
|
597
|
+
h = BigInt.asUintN(64, (h ^ BigInt(s.charCodeAt(i))) * 1099511628211n);
|
|
598
|
+
return h.toString(16);
|
|
599
|
+
};
|
|
600
|
+
scan: for (const [counter, w] of Object.entries(m.step.state ?? {})) {
|
|
601
|
+
if (!more())
|
|
602
|
+
break;
|
|
603
|
+
if (w.op !== 'if' || !eq(w.then, { op: 'add', a: x(counter), b: n(1) }) || w.else.op !== 'if' || !eq(w.else.then, n(0)) || !eq(w.else.else, x(counter)))
|
|
604
|
+
continue;
|
|
605
|
+
const related = closure(w.c), atoms = related.flatMap(parts);
|
|
606
|
+
const activities = atoms.filter((c) => c.op === '=' && c.a.op === 'var' && c.a.name !== counter && c.a.name in m.state && eq(m.state[c.a.name], n(0)) && eq(c.b, n(1)));
|
|
607
|
+
for (const c of related)
|
|
608
|
+
for (const node of parts(c)) {
|
|
609
|
+
if (node.op !== 'not' || node.x.op !== 'flag')
|
|
610
|
+
continue;
|
|
611
|
+
const rowName = node.x.name, row = flags[rowName];
|
|
612
|
+
if (row?.op !== 'all' || row.keys?.length)
|
|
613
|
+
continue;
|
|
614
|
+
const members = parts(c).filter(q => q.op === '=' && q.a.op === 'get' && eq(q.a.key, x(counter)) && q.a.map in (m.maps ?? {}) && eq(q.b, n(1)));
|
|
615
|
+
for (const member of members)
|
|
616
|
+
for (const activity of activities) {
|
|
617
|
+
if (!more())
|
|
618
|
+
break scan;
|
|
619
|
+
const taken = new Set([...m.params, ...m.inputs, ...Object.keys(m.state), ...Object.keys(m.maps ?? {}), ...Object.keys(flags)]);
|
|
620
|
+
walk([m], o => { if (typeof o.name === 'string')
|
|
621
|
+
taken.add(o.name); if (typeof o.key === 'string')
|
|
622
|
+
taken.add(o.key); });
|
|
623
|
+
let fresh = 'scanKey';
|
|
624
|
+
while (taken.has(fresh) || fresh === row.key)
|
|
625
|
+
fresh += 'X';
|
|
626
|
+
const base = `scan-prefix:${counter}:${rowName}:${tag(JSON.stringify({ member, activity, row }))}`;
|
|
627
|
+
packets.push([
|
|
628
|
+
{ name: base + ':entry', holds: any(not(same(activity.a, n(0))), same(x(counter), n(0))) },
|
|
629
|
+
{ name: base, forall: fresh, keys: [row.key], holds: any(not(all(activity, less(x(fresh), x(counter)), sub(member, counter, x(fresh)))), sub(row.c, counter, x(fresh))) },
|
|
630
|
+
]);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
const blocked = new Set(occupied.map(l => l.name)), byName = new Map();
|
|
635
|
+
for (const packet of packets)
|
|
636
|
+
for (const l of packet) {
|
|
637
|
+
const signature = JSON.stringify(l), previous = byName.get(l.name);
|
|
638
|
+
if (previous !== undefined && previous !== signature)
|
|
639
|
+
blocked.add(l.name);
|
|
640
|
+
byName.set(l.name, signature);
|
|
641
|
+
}
|
|
642
|
+
const unique = new Map();
|
|
643
|
+
for (const packet of packets) {
|
|
644
|
+
// Skip the whole family if either name conflicts, including with a caller.
|
|
645
|
+
if (packet.some(l => blocked.has(l.name)))
|
|
646
|
+
continue;
|
|
647
|
+
for (const l of packet)
|
|
648
|
+
unique.set(l.name, l);
|
|
649
|
+
}
|
|
650
|
+
return [...unique.values()];
|
|
651
|
+
}
|