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,205 @@
|
|
|
1
|
+
// Untrusted candidate policy. Only original-interpreter replay justifies a drop;
|
|
2
|
+
// none of this ledger is proof admission.
|
|
3
|
+
import { interpret } from "./machine.js";
|
|
4
|
+
import { finiteEvaluator } from "./finite-houdini.js";
|
|
5
|
+
import { finiteModelChecker } from "./finite-model.js";
|
|
6
|
+
import { BudgetExpired, budgetEnd, checkBudget, fullRate, fullWork, remainingWork, withBudget } from "../kernel/prove.js";
|
|
7
|
+
import { WallExpired } from "./wall.js";
|
|
8
|
+
const none = () => ({ status: 'ignored', rejected: [], safety: [] });
|
|
9
|
+
const declarations = (m) => [...(m.pre ? [{ name: 'rejection parameter precondition', holds: m.pre }] : []), ...m.facts ?? []];
|
|
10
|
+
export function createRejectionStage(source, m, caller, candidates, allowance) {
|
|
11
|
+
if (!Number.isFinite(allowance) || allowance < 0 || !Number.isFinite(allowance * fullRate))
|
|
12
|
+
throw new RangeError('rejection allowance must be finite and nonnegative');
|
|
13
|
+
const all = [...new Set([...caller, ...candidates])], protectedLaws = new Set(caller), records = new Map(), restored = new Set(), start = fullWork(), limit = allowance * fullRate;
|
|
14
|
+
let safetyStatus;
|
|
15
|
+
const evaluate = finiteEvaluator(m), sourceEvaluate = finiteEvaluator(source), facts = declarations(m), sourceFacts = declarations(source), run = interpret(source), complete = finiteModelChecker(m);
|
|
16
|
+
let charged = fullWork() - start, activeAt, exhausted = false, revision = 0;
|
|
17
|
+
let commits = [];
|
|
18
|
+
const active = () => all.filter(l => !records.has(l)), spent = () => charged + (activeAt === undefined ? 0 : fullWork() - activeAt);
|
|
19
|
+
function bounded(fallback, body) {
|
|
20
|
+
// Even an exhausted local stage must not hide cancellation of its parent.
|
|
21
|
+
checkBudget('rejection parent');
|
|
22
|
+
if (exhausted || spent() >= limit)
|
|
23
|
+
return fallback;
|
|
24
|
+
if (activeAt !== undefined) {
|
|
25
|
+
checkBudget('nested rejection entry');
|
|
26
|
+
const out = body();
|
|
27
|
+
checkBudget('nested rejection completion');
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
// A nonrestricting scope exposes the effective inherited endpoint, including
|
|
31
|
+
// withWork's otherwise private cap. This also disambiguates an exact tie:
|
|
32
|
+
// a refusal shared with the parent must propagate, not become local expiry.
|
|
33
|
+
const parentEnd = withBudget(Number.MAX_VALUE, () => budgetEnd());
|
|
34
|
+
const before = fullWork(), localEnd = (before + Math.max(0, limit - charged)) / fullRate;
|
|
35
|
+
let localRefusal = false, installedEnd;
|
|
36
|
+
activeAt = before;
|
|
37
|
+
commits = [];
|
|
38
|
+
try {
|
|
39
|
+
const out = withBudget(Math.max(0, limit - charged), () => {
|
|
40
|
+
installedEnd = budgetEnd();
|
|
41
|
+
try {
|
|
42
|
+
checkBudget('rejection evidence');
|
|
43
|
+
return body();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// Admission can refuse an expensive primitive BEFORE charging it. Read
|
|
47
|
+
// the actual installed endpoint and refusal marker while still inside I.
|
|
48
|
+
if (error instanceof BudgetExpired && budgetEnd() === localEnd && localEnd < parentEnd && remainingWork() === 0)
|
|
49
|
+
localRefusal = true;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// withBudget's completion check has succeeded. Publication itself cannot
|
|
54
|
+
// evaluate a law, replay a step, clone user data, or incur a budget charge.
|
|
55
|
+
for (const commit of commits)
|
|
56
|
+
commit();
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
checkBudget('rejection parent completion');
|
|
61
|
+
if (error instanceof BudgetExpired && (localRefusal || (installedEnd === localEnd && localEnd < parentEnd && spent() >= limit))) {
|
|
62
|
+
exhausted = true;
|
|
63
|
+
return fallback;
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
commits = [];
|
|
69
|
+
charged += fullWork() - before;
|
|
70
|
+
activeAt = undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function enabled(params, pre, request) {
|
|
74
|
+
try {
|
|
75
|
+
return run.step(params, pre, request);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof BudgetExpired || error instanceof WallExpired)
|
|
79
|
+
throw error;
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const declared = (params, pre) => sourceFacts.every(l => sourceEvaluate(l, params, pre) === true) && facts.every(l => evaluate(l, params, pre) === true);
|
|
84
|
+
function publish(out, evidence, version) {
|
|
85
|
+
const status = out.status;
|
|
86
|
+
commits.push(() => {
|
|
87
|
+
if (status === 'broken')
|
|
88
|
+
safetyStatus = 'broken';
|
|
89
|
+
else if (status === 'weak')
|
|
90
|
+
safetyStatus ??= 'weak';
|
|
91
|
+
// An enclosing callback may expand the family before it returns. Never
|
|
92
|
+
// publish a relative witness validated against that obsolete family.
|
|
93
|
+
for (const [law, witness] of evidence)
|
|
94
|
+
if (witness.kind === 'reachable' || version === revision)
|
|
95
|
+
records.set(law, witness);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function reachable(params0, requests0) {
|
|
99
|
+
return bounded(none(), () => {
|
|
100
|
+
const out = none(), evidence = new Map(), params = structuredClone(params0), requests = structuredClone([...requests0]);
|
|
101
|
+
let post;
|
|
102
|
+
try {
|
|
103
|
+
post = run.init(params);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof BudgetExpired || error instanceof WallExpired)
|
|
107
|
+
throw error;
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
if (!declared(params, post))
|
|
111
|
+
return out;
|
|
112
|
+
for (const request of requests) {
|
|
113
|
+
const next = enabled(params, post, request);
|
|
114
|
+
if (!next || !declared(params, next))
|
|
115
|
+
return out;
|
|
116
|
+
post = next;
|
|
117
|
+
}
|
|
118
|
+
out.safety = caller.filter(l => evaluate(l, params, post) === false);
|
|
119
|
+
if (out.safety.length)
|
|
120
|
+
out.status = 'broken';
|
|
121
|
+
else
|
|
122
|
+
for (const law of all) {
|
|
123
|
+
if (protectedLaws.has(law) || evaluate(law, params, post) !== false)
|
|
124
|
+
continue;
|
|
125
|
+
evidence.set(law, structuredClone({ kind: 'reachable', law, params, requests, post }));
|
|
126
|
+
out.rejected.push(law);
|
|
127
|
+
out.status = 'rejected';
|
|
128
|
+
}
|
|
129
|
+
publish(out, evidence, revision);
|
|
130
|
+
return out;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function relative(params0, pre0, request0) {
|
|
134
|
+
return bounded(none(), () => {
|
|
135
|
+
const out = none(), evidence = new Map(), params = structuredClone(params0), pre = structuredClone(pre0), request = structuredClone(request0), family = active(), version = revision;
|
|
136
|
+
if (!declared(params, pre) || !family.every(l => evaluate(l, params, pre) === true))
|
|
137
|
+
return out;
|
|
138
|
+
const post = enabled(params, pre, request);
|
|
139
|
+
if (!post)
|
|
140
|
+
return out;
|
|
141
|
+
out.safety = caller.filter(l => evaluate(l, params, post) === false);
|
|
142
|
+
if (out.safety.length)
|
|
143
|
+
out.status = 'weak';
|
|
144
|
+
else
|
|
145
|
+
for (const law of family) {
|
|
146
|
+
if (protectedLaws.has(law) || evaluate(law, params, post) !== false)
|
|
147
|
+
continue;
|
|
148
|
+
evidence.set(law, structuredClone({ kind: 'relative', law, params, pre, request, post }));
|
|
149
|
+
out.rejected.push(law);
|
|
150
|
+
out.status = 'rejected';
|
|
151
|
+
}
|
|
152
|
+
publish(out, evidence, version);
|
|
153
|
+
return out;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function addCandidates(laws) {
|
|
157
|
+
const added = [...new Set(laws)].filter(law => !all.includes(law));
|
|
158
|
+
if (!added.length)
|
|
159
|
+
return [];
|
|
160
|
+
all.push(...added);
|
|
161
|
+
revision++;
|
|
162
|
+
const revived = [];
|
|
163
|
+
// Restoration is monotone, not a publication transaction. On local expiry
|
|
164
|
+
// every unvalidated relative witness is removed, including cascades. Outer
|
|
165
|
+
// cancellation also restores conservatively before propagating; never roll
|
|
166
|
+
// back to evidence for a smaller, stale family.
|
|
167
|
+
try {
|
|
168
|
+
for (let changed = true; changed;) {
|
|
169
|
+
changed = false;
|
|
170
|
+
const family = active();
|
|
171
|
+
for (const [law, witness] of records) {
|
|
172
|
+
if (witness.kind === 'reachable')
|
|
173
|
+
continue;
|
|
174
|
+
const valid = bounded(false, () => declared(witness.params, witness.pre) && family.every(l => evaluate(l, witness.params, witness.pre) === true));
|
|
175
|
+
if (!valid) {
|
|
176
|
+
records.delete(law);
|
|
177
|
+
restored.add(law);
|
|
178
|
+
revived.push(law);
|
|
179
|
+
changed = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
for (const [law, witness] of records)
|
|
186
|
+
if (witness.kind === 'relative') {
|
|
187
|
+
records.delete(law);
|
|
188
|
+
restored.add(law);
|
|
189
|
+
}
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
return revived;
|
|
193
|
+
}
|
|
194
|
+
function model(law, witness) {
|
|
195
|
+
return bounded(none(), () => { const candidate = complete(active(), law, witness); return candidate.genuine ? relative(candidate.params, candidate.pre, candidate.request) : none(); });
|
|
196
|
+
}
|
|
197
|
+
return { active, addCandidates, reachable, relative, model, restored: () => active().filter(law => restored.has(law)), safety: () => safetyStatus, within: (body) => bounded(undefined, body), work: () => ({ used: spent() / fullRate, limit: allowance }), evidence: () => [...records.values()].map(record => structuredClone(record)) };
|
|
198
|
+
}
|
|
199
|
+
// A restored helper belongs to EVERY later proof context, not only the call
|
|
200
|
+
// which enlarged the ledger. A subsequent validated rejection may omit it.
|
|
201
|
+
export function rejectionFamily(stage, initial) {
|
|
202
|
+
stage.addCandidates(initial);
|
|
203
|
+
const requested = new Set([...initial, ...stage.restored()]);
|
|
204
|
+
return stage.active().filter(law => requested.has(law));
|
|
205
|
+
}
|
package/dist/core/relational.js
CHANGED
|
@@ -26,6 +26,7 @@ import { Rule, Term, all, any, forall, nat, no, not, proveSteps, same, when, yes
|
|
|
26
26
|
import { proveLaws, proveStepLaws } from "../kernel/prove.js";
|
|
27
27
|
import { fromInterchange, toInterchange } from "../interchange/format.js";
|
|
28
28
|
import { checkCertificate } from "../interchange/check.js";
|
|
29
|
+
import { inheritSource, translationVerdict } from "./source-check.js";
|
|
29
30
|
const specOf = (r) => r.spec;
|
|
30
31
|
const v = (name) => new Term({ op: 'var', name });
|
|
31
32
|
// The names a side declares that are its own in the rule built (renamed): state and its parts, maps, lists, cells,
|
|
@@ -152,7 +153,10 @@ export function twoRuns(a, b = a, opts = {}) {
|
|
|
152
153
|
return out;
|
|
153
154
|
},
|
|
154
155
|
};
|
|
155
|
-
|
|
156
|
+
const out = new Rule(spec);
|
|
157
|
+
inheritSource(a, out);
|
|
158
|
+
inheritSource(b, out);
|
|
159
|
+
return out;
|
|
156
160
|
}
|
|
157
161
|
// A run's write kept only where it takes the request (else the value before it).
|
|
158
162
|
function guarded(sd, key, w, go) {
|
|
@@ -231,6 +235,7 @@ export function isolation(r, o) {
|
|
|
231
235
|
if ([...s.params, ...s.inputs].some(([n]) => n === tenant))
|
|
232
236
|
throw new Error(`isolation: ${tenant} is a name of ${s.name} already (name the tenant's param: tenant)`);
|
|
233
237
|
const base = new Rule({ ...s, params: [...s.params, [tenant, nat]] });
|
|
238
|
+
inheritSource(r, base);
|
|
234
239
|
const all2 = [...s.params, ...s.inputs].map(([n]) => n);
|
|
235
240
|
const p = twoRuns(base, base, { name: `${s.name}: isolation of ${typeof o.owner === 'string' ? o.owner : 'the owner'}`, shared: [...all2, tenant], stays: env => not(mine(env)), refusals: o.refusals });
|
|
236
241
|
const maps = new Set(vw.maps), name = o.name ?? `what ${typeof o.owner === 'string' ? o.owner : 'a tenant'} B sees is the same whatever the others do`;
|
|
@@ -300,7 +305,7 @@ export function proveTwoRuns(l, opts = {}) {
|
|
|
300
305
|
let helpers = [...l.helpers];
|
|
301
306
|
for (let round = 0; helpers.length && round <= l.helpers.length; round++) {
|
|
302
307
|
const v = proveSteps(l.rule, [...lifted, ...helpers, ...l.laws], l.stepLaws, { search: false });
|
|
303
|
-
if (v.proven && v.checked)
|
|
308
|
+
if ((v.proven && v.checked) || v.kernelProven === true)
|
|
304
309
|
return { ...v, found: { ...v.found, laws: [...v.found?.laws ?? [], ...helpers.map(h => ({ law: h, text: h.name }))] }, given: lifted };
|
|
305
310
|
const drop = helpers.find(h => v.goal?.startsWith(h.name));
|
|
306
311
|
if (!drop)
|
|
@@ -335,6 +340,9 @@ export function certify(r, laws, stepLaws = [], meta = {}) {
|
|
|
335
340
|
return undefined;
|
|
336
341
|
c = { kind: 'laws', machine: p.machine ?? m, laws: p.laws ?? given, proof: { instances: p.proof.instances, trees: p.proof.trees } };
|
|
337
342
|
}
|
|
343
|
+
const validation = translationVerdict(r, [...laws, ...stepLaws], { proven: true, checked: true });
|
|
344
|
+
if (!validation.proven || !validation.checked)
|
|
345
|
+
return undefined;
|
|
338
346
|
const doc = toInterchange(c, meta);
|
|
339
347
|
return checkCertificate(fromInterchange(JSON.parse(JSON.stringify(doc)))).every(x => x.accepted) ? doc : undefined;
|
|
340
348
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Law, type Machine } from './machine.js';
|
|
2
|
+
import { type Goal } from '../kernel/kernel.js';
|
|
3
|
+
export declare function relevantLaws(m: Machine, laws: Law[], target: Law, structural?: ReadonlySet<Law>): Law[][];
|
|
4
|
+
export declare function relevantGoals(goal: Goal): Goal[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Untrusted search ordering only: a smaller context cannot authorize a result.
|
|
2
|
+
// Trees found here are lifted to the original goal before the kernel sees them.
|
|
3
|
+
import { walkOnce } from "./machine.js";
|
|
4
|
+
import { canon, linOfE } from "./solver.js";
|
|
5
|
+
function footprint(value) {
|
|
6
|
+
const out = { vars: new Set(), maps: new Set(), cells: new Set() };
|
|
7
|
+
walkOnce(value, node => {
|
|
8
|
+
const o = node;
|
|
9
|
+
if (o.op === 'var')
|
|
10
|
+
out.vars.add(String(o.name));
|
|
11
|
+
if (o.op === 'get') {
|
|
12
|
+
out.maps.add(String(o.map));
|
|
13
|
+
const key = linOfE(o.key);
|
|
14
|
+
out.cells.add(JSON.stringify([o.map, key ? canon(key) : o.key]));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
const overlap = (a, b) => [...a].filter(x => b.has(x)).length;
|
|
20
|
+
// Count definitions participate through their actual read maps. Binder names
|
|
21
|
+
// never create relevance merely because two independent laws spell them alike.
|
|
22
|
+
export function relevantLaws(m, laws, target, structural = new Set()) {
|
|
23
|
+
if (laws.length <= 12)
|
|
24
|
+
return [];
|
|
25
|
+
const ofLaw = (law) => {
|
|
26
|
+
const f = footprint(law.holds), bound = new Set([law.forall, ...(law.keys ?? []), ...(law.some ?? [])]);
|
|
27
|
+
for (const v of f.vars)
|
|
28
|
+
if (bound.has(v) || !Object.hasOwn(m.state, v))
|
|
29
|
+
f.vars.delete(v);
|
|
30
|
+
for (const mp of f.maps) {
|
|
31
|
+
const d = m.counts?.[mp];
|
|
32
|
+
if (d)
|
|
33
|
+
for (const read of footprint(d.body).maps)
|
|
34
|
+
f.maps.add(read);
|
|
35
|
+
}
|
|
36
|
+
return f;
|
|
37
|
+
};
|
|
38
|
+
const own = ofLaw(target);
|
|
39
|
+
const ranked = laws.map((law, i) => {
|
|
40
|
+
const f = ofLaw(law), shared = overlap(f.maps, own.maps), fresh = f.maps.size - shared;
|
|
41
|
+
const states = overlap(f.vars, own.vars);
|
|
42
|
+
const scalar = !f.maps.size && (states > 0 || !f.vars.size);
|
|
43
|
+
const simple = shared > 0 && !fresh && !law.keys?.length && !law.some?.length;
|
|
44
|
+
const score = law === target ? -10000 : (simple ? -200 : scalar ? -150 : structural.has(law) && (shared || states) ? -100 : shared ? -20 : 100) + fresh * 20 + (f.vars.size - states) * 2 + (law.keys?.length ?? 0);
|
|
45
|
+
return { law, i, score };
|
|
46
|
+
}).sort((a, b) => a.score - b.score || a.i - b.i);
|
|
47
|
+
return [12, 24].filter(cap => cap < laws.length).map(cap => {
|
|
48
|
+
const chosen = new Set(ranked.slice(0, cap).map(r => r.law));
|
|
49
|
+
chosen.add(target);
|
|
50
|
+
return laws.filter(l => chosen.has(l));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Keep exact source hypotheses, in their original order, and the conclusion last.
|
|
54
|
+
// Scalar premises for any newly introduced witness accompany its selected cells.
|
|
55
|
+
export function relevantGoals(goal) {
|
|
56
|
+
if (goal.hyps.length < 24)
|
|
57
|
+
return [];
|
|
58
|
+
const fs = goal.hyps.map(footprint), root = fs.at(-1);
|
|
59
|
+
const ranked = fs.slice(0, -1).map((f, i) => {
|
|
60
|
+
const cells = overlap(f.cells, root.cells), maps = overlap(f.maps, root.maps), vars = overlap(f.vars, root.vars);
|
|
61
|
+
const fresh = f.vars.size - vars;
|
|
62
|
+
const score = i < 2 ? -10000 : cells ? -1000 - 10 * cells + fresh : maps ? -100 - maps + 4 * fresh : f.maps.size ? 100 + fresh : fresh ? 200 + fresh : -500;
|
|
63
|
+
return { i, score };
|
|
64
|
+
}).sort((a, b) => a.score - b.score || a.i - b.i);
|
|
65
|
+
const out = [], seen = new Set();
|
|
66
|
+
for (const cap of [16, 32, 64]) {
|
|
67
|
+
const selected = new Set(ranked.slice(0, cap).map(r => r.i));
|
|
68
|
+
const vars = new Set([...root.vars, ...[...selected].flatMap(i => [...fs[i].vars])]);
|
|
69
|
+
fs.slice(0, -1).forEach((f, i) => { if (!f.maps.size && [...f.vars].every(v => vars.has(v)))
|
|
70
|
+
selected.add(i); });
|
|
71
|
+
selected.add(goal.hyps.length - 1);
|
|
72
|
+
const ids = [...selected].sort((a, b) => a - b), key = ids.join(',');
|
|
73
|
+
if (ids.length >= goal.hyps.length || seen.has(key))
|
|
74
|
+
continue;
|
|
75
|
+
seen.add(key);
|
|
76
|
+
out.push({ name: goal.name, hyps: ids.map(i => goal.hyps[i]) });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Machine, type Request } from './machine.js';
|
|
2
|
+
export type RequestQuotient = {
|
|
3
|
+
classes: Uint32Array;
|
|
4
|
+
count: number;
|
|
5
|
+
selector?: string;
|
|
6
|
+
reads: ReadonlyMap<number | undefined, readonly string[]>;
|
|
7
|
+
};
|
|
8
|
+
export declare function requestQuotient(m: Machine, requests: readonly Request[]): RequestQuotient | undefined;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// Untrusted sampling optimization. A class is used only AFTER one member has
|
|
2
|
+
// produced a state. Refusals are never generalized; the original request order,
|
|
3
|
+
// logical trial allowance and first successful witness remain unchanged.
|
|
4
|
+
import { hasFinite, walk } from "./machine.js";
|
|
5
|
+
import { startWork } from "./work-admission.js";
|
|
6
|
+
import { completeWorkProfile } from "./work-profile.js";
|
|
7
|
+
import { checkWall } from "./wall.js";
|
|
8
|
+
class UnsupportedQuotient extends Error {
|
|
9
|
+
}
|
|
10
|
+
export function requestQuotient(m, requests) {
|
|
11
|
+
if (hasFinite(m))
|
|
12
|
+
return undefined; // arbitrary finite-body reads need an exact quotient proof
|
|
13
|
+
if (requests.length < 2 || Object.keys(m.fns ?? {}).length || m.history || m.leasts || Object.keys(m.sums ?? {}).length)
|
|
14
|
+
return undefined;
|
|
15
|
+
const names = [...m.inputs, ...m.inputMaps ?? []], inputs = new Set(m.inputs), maps = new Set(m.inputMaps ?? []);
|
|
16
|
+
// Ambiguous namespaces and non-topological flags use the unmodified sampler.
|
|
17
|
+
if (new Set(names).size !== names.length || names.some(n => n.startsWith('?') || m.params.includes(n) || Object.hasOwn(m.state, n)) || [...maps].some(n => Object.hasOwn(m.maps ?? {}, n) || Object.hasOwn(m.counts ?? {}, n)))
|
|
18
|
+
return undefined;
|
|
19
|
+
let work = 0;
|
|
20
|
+
const tick = () => {
|
|
21
|
+
if (completeWorkProfile.enabled) {
|
|
22
|
+
// Polling every 256 visits remains a wall-cancellation optimization, not
|
|
23
|
+
// permission to debit past an inherited raw-work endpoint.
|
|
24
|
+
startWork('ticks', 1, 'request quotient');
|
|
25
|
+
}
|
|
26
|
+
if ((++work & 255) === 0)
|
|
27
|
+
checkWall('request quotient');
|
|
28
|
+
};
|
|
29
|
+
const flags = m.step.flags ?? {}, known = new Set(), tags = new Map();
|
|
30
|
+
let supported = true;
|
|
31
|
+
walk([m.step, m.counts], o => {
|
|
32
|
+
tick();
|
|
33
|
+
if (o.op === 'var' && String(o.name).startsWith('?'))
|
|
34
|
+
supported = false;
|
|
35
|
+
if (o.op === 'all' && [o.key, ...o.keys ?? []].some(name => String(name).startsWith('?')))
|
|
36
|
+
supported = false;
|
|
37
|
+
});
|
|
38
|
+
for (const count of Object.values(m.counts ?? {}))
|
|
39
|
+
walk(count, o => { tick(); if (o.op === 'flag')
|
|
40
|
+
supported = false; });
|
|
41
|
+
if (Object.values(m.step.maps ?? {}).some(w => 'each' in w && w.each.startsWith('?')))
|
|
42
|
+
supported = false;
|
|
43
|
+
for (const [name, c] of Object.entries(flags)) {
|
|
44
|
+
walk(c, o => { tick(); if (o.op === 'flag' && !known.has(String(o.name)))
|
|
45
|
+
supported = false; });
|
|
46
|
+
known.add(name);
|
|
47
|
+
}
|
|
48
|
+
if (!supported)
|
|
49
|
+
return undefined;
|
|
50
|
+
walk(m.step, o => {
|
|
51
|
+
tick();
|
|
52
|
+
if (o.op !== '=')
|
|
53
|
+
return;
|
|
54
|
+
const a = o.a, b = o.b, v = a.op === 'var' ? a : b, k = a.op === 'var' ? b : a;
|
|
55
|
+
if (v.op === 'var' && k.op === 'const' && inputs.has(v.name) && Number.isSafeInteger(k.value)) {
|
|
56
|
+
let values = tags.get(v.name);
|
|
57
|
+
if (!values)
|
|
58
|
+
tags.set(v.name, (values = new Set()));
|
|
59
|
+
values.add(k.value);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const selector = [...tags].filter(([, values]) => values.size > 1).sort((a, b) => b[1].size - a[1].size || m.inputs.indexOf(a[0]) - m.inputs.indexOf(b[0]))[0]?.[0];
|
|
63
|
+
const empty = new Set(), reads = new Map();
|
|
64
|
+
const number = (e, fixed, bound) => {
|
|
65
|
+
tick();
|
|
66
|
+
let out;
|
|
67
|
+
switch (e.op) {
|
|
68
|
+
case 'const':
|
|
69
|
+
out = e.value;
|
|
70
|
+
break;
|
|
71
|
+
case 'var':
|
|
72
|
+
out = bound.has(e.name) ? undefined : fixed[e.name];
|
|
73
|
+
break;
|
|
74
|
+
case 'if': {
|
|
75
|
+
const c = boolean(e.c, fixed, bound, new Set());
|
|
76
|
+
return c === undefined ? undefined : number(c ? e.then : e.else, fixed, bound);
|
|
77
|
+
}
|
|
78
|
+
case 'get':
|
|
79
|
+
case 'tup':
|
|
80
|
+
case 'proj': return undefined;
|
|
81
|
+
case 'mul': {
|
|
82
|
+
const a = number(e.a, fixed, bound);
|
|
83
|
+
out = a === undefined ? undefined : e.k * a;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'add':
|
|
87
|
+
case 'sub':
|
|
88
|
+
case 'min':
|
|
89
|
+
case 'max':
|
|
90
|
+
case 'prod': {
|
|
91
|
+
const a = number(e.a, fixed, bound), b = number(e.b, fixed, bound);
|
|
92
|
+
if (a === undefined || b === undefined)
|
|
93
|
+
return undefined;
|
|
94
|
+
out = e.op === 'add' ? a + b : e.op === 'sub' ? Math.max(0, a - b) : e.op === 'min' ? Math.min(a, b) : e.op === 'max' ? Math.max(a, b) : a * b;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return out !== undefined && Number.isSafeInteger(out) && out >= 0 ? out : undefined;
|
|
98
|
+
};
|
|
99
|
+
const boolean = (c, fixed, bound, visiting) => {
|
|
100
|
+
tick();
|
|
101
|
+
switch (c.op) {
|
|
102
|
+
case 'flag': {
|
|
103
|
+
if (visiting.has(c.name) || !flags[c.name])
|
|
104
|
+
throw new UnsupportedQuotient('flag');
|
|
105
|
+
const next = new Set(visiting);
|
|
106
|
+
next.add(c.name);
|
|
107
|
+
return boolean(flags[c.name], fixed, empty, next);
|
|
108
|
+
}
|
|
109
|
+
case 'all': return undefined;
|
|
110
|
+
case 'not': {
|
|
111
|
+
const a = boolean(c.x, fixed, bound, visiting);
|
|
112
|
+
return a === undefined ? undefined : !a;
|
|
113
|
+
}
|
|
114
|
+
case 'and':
|
|
115
|
+
case 'or': {
|
|
116
|
+
let unknown = false;
|
|
117
|
+
for (const x of c.xs) {
|
|
118
|
+
const a = boolean(x, fixed, bound, visiting);
|
|
119
|
+
if (a === (c.op === 'or'))
|
|
120
|
+
return a;
|
|
121
|
+
if (a === undefined)
|
|
122
|
+
unknown = true;
|
|
123
|
+
}
|
|
124
|
+
return unknown ? undefined : c.op === 'and';
|
|
125
|
+
}
|
|
126
|
+
case '=':
|
|
127
|
+
case '<':
|
|
128
|
+
case '<=': {
|
|
129
|
+
const a = number(c.a, fixed, bound), b = number(c.b, fixed, bound);
|
|
130
|
+
return a === undefined || b === undefined ? undefined : c.op === '=' ? a === b : c.op === '<' ? a < b : a <= b;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const projection = (value) => {
|
|
135
|
+
const cached = reads.get(value);
|
|
136
|
+
if (cached)
|
|
137
|
+
return cached;
|
|
138
|
+
const fixed = selector ? { [selector]: value } : {}, out = new Set(), visiting = new Set();
|
|
139
|
+
const expr = (e, bound) => {
|
|
140
|
+
tick();
|
|
141
|
+
switch (e.op) {
|
|
142
|
+
case 'const': return;
|
|
143
|
+
case 'var':
|
|
144
|
+
if (!bound.has(e.name) && inputs.has(e.name) && !Object.hasOwn(fixed, e.name))
|
|
145
|
+
out.add(e.name);
|
|
146
|
+
return;
|
|
147
|
+
case 'if': {
|
|
148
|
+
const c = boolean(e.c, fixed, bound, new Set());
|
|
149
|
+
if (c !== undefined) {
|
|
150
|
+
expr(c ? e.then : e.else, bound);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
cond(e.c, bound);
|
|
154
|
+
expr(e.then, bound);
|
|
155
|
+
expr(e.else, bound);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
case 'get': {
|
|
159
|
+
expr(e.key, bound);
|
|
160
|
+
if (maps.has(e.map))
|
|
161
|
+
out.add(e.map);
|
|
162
|
+
const count = m.counts?.[e.map];
|
|
163
|
+
// A derived count has memoized, not complete, enumerable support in
|
|
164
|
+
// the runtime. Never quotient its reads under a quantified/bulk binder.
|
|
165
|
+
if (count && bound.size)
|
|
166
|
+
throw new UnsupportedQuotient('count under binder');
|
|
167
|
+
if (count) {
|
|
168
|
+
const tag = 'count:' + e.map;
|
|
169
|
+
if (visiting.has(tag))
|
|
170
|
+
throw new UnsupportedQuotient('count cycle');
|
|
171
|
+
visiting.add(tag);
|
|
172
|
+
const inner = new Set([count.j, count.key, ...count.lo ? [count.lo] : []]);
|
|
173
|
+
expr(count.below, new Set([count.j, ...count.lo ? [count.lo] : []]));
|
|
174
|
+
expr(count.body, inner);
|
|
175
|
+
visiting.delete(tag);
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
case 'mul':
|
|
180
|
+
case 'proj':
|
|
181
|
+
expr(e.a, bound);
|
|
182
|
+
return;
|
|
183
|
+
case 'add':
|
|
184
|
+
case 'sub':
|
|
185
|
+
case 'min':
|
|
186
|
+
case 'max':
|
|
187
|
+
case 'prod':
|
|
188
|
+
case 'tup':
|
|
189
|
+
expr(e.a, bound);
|
|
190
|
+
expr(e.b, bound);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const cond = (c, bound) => {
|
|
194
|
+
tick();
|
|
195
|
+
if (boolean(c, fixed, bound, new Set()) !== undefined)
|
|
196
|
+
return;
|
|
197
|
+
switch (c.op) {
|
|
198
|
+
case 'flag': {
|
|
199
|
+
const tag = 'flag:' + c.name;
|
|
200
|
+
if (visiting.has(tag) || !flags[c.name])
|
|
201
|
+
throw new UnsupportedQuotient('flag');
|
|
202
|
+
visiting.add(tag);
|
|
203
|
+
cond(flags[c.name], empty);
|
|
204
|
+
visiting.delete(tag);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
case 'all':
|
|
208
|
+
// For one plain key, any past-the-support key has the same observations:
|
|
209
|
+
// every bound-key read is a map's default (opaque/count maps are excluded).
|
|
210
|
+
// Keep the conservative full support for cross-key quantifiers.
|
|
211
|
+
if (c.keys?.length)
|
|
212
|
+
for (const name of maps)
|
|
213
|
+
out.add(name);
|
|
214
|
+
cond(c.c, new Set([...bound, c.key, ...c.keys ?? []]));
|
|
215
|
+
return;
|
|
216
|
+
case 'not':
|
|
217
|
+
cond(c.x, bound);
|
|
218
|
+
return;
|
|
219
|
+
case 'and':
|
|
220
|
+
case 'or':
|
|
221
|
+
for (const x of c.xs)
|
|
222
|
+
cond(x, bound);
|
|
223
|
+
return;
|
|
224
|
+
case '=':
|
|
225
|
+
case '<':
|
|
226
|
+
case '<=':
|
|
227
|
+
expr(c.a, bound);
|
|
228
|
+
expr(c.b, bound);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
for (const e of Object.values(m.step.state ?? {}))
|
|
232
|
+
expr(e, empty);
|
|
233
|
+
for (const w of Object.values(m.step.maps ?? {})) {
|
|
234
|
+
if ('each' in w)
|
|
235
|
+
expr(w.value, new Set([w.each]));
|
|
236
|
+
else {
|
|
237
|
+
expr(w.key, empty);
|
|
238
|
+
expr(w.value, empty);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// The slice tag is part of the class even if the selected arm is a no-op.
|
|
242
|
+
const ordered = names.filter(name => out.has(name));
|
|
243
|
+
reads.set(value, ordered);
|
|
244
|
+
return ordered;
|
|
245
|
+
};
|
|
246
|
+
const tokens = new WeakMap();
|
|
247
|
+
const mapToken = (value) => {
|
|
248
|
+
if (!(value instanceof Map))
|
|
249
|
+
throw new UnsupportedQuotient('non-map request');
|
|
250
|
+
const cached = tokens.get(value);
|
|
251
|
+
if (cached !== undefined)
|
|
252
|
+
return cached;
|
|
253
|
+
const entries = [...value];
|
|
254
|
+
for (const [k, v] of entries) {
|
|
255
|
+
tick();
|
|
256
|
+
if (!Number.isSafeInteger(k) || k < 0 || !Number.isSafeInteger(v) || v < 0)
|
|
257
|
+
throw new UnsupportedQuotient('non-natural request map');
|
|
258
|
+
}
|
|
259
|
+
entries.sort((a, b) => a[0] - b[0]);
|
|
260
|
+
const token = JSON.stringify(entries);
|
|
261
|
+
tokens.set(value, token);
|
|
262
|
+
return token;
|
|
263
|
+
};
|
|
264
|
+
try {
|
|
265
|
+
const ids = new Map(), classes = new Uint32Array(requests.length);
|
|
266
|
+
for (let i = 0; i < requests.length; i++) {
|
|
267
|
+
tick();
|
|
268
|
+
const request = requests[i], value = selector ? request[selector] : undefined;
|
|
269
|
+
if (selector && (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0))
|
|
270
|
+
return undefined;
|
|
271
|
+
const fields = projection(value), parts = [value];
|
|
272
|
+
for (const name of fields) {
|
|
273
|
+
tick();
|
|
274
|
+
const v = request[name];
|
|
275
|
+
if (maps.has(name))
|
|
276
|
+
parts.push(mapToken(v));
|
|
277
|
+
else {
|
|
278
|
+
if (typeof v !== 'number' || !Number.isSafeInteger(v) || v < 0)
|
|
279
|
+
return undefined;
|
|
280
|
+
parts.push(v);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const key = JSON.stringify(parts);
|
|
284
|
+
let id = ids.get(key);
|
|
285
|
+
if (id === undefined) {
|
|
286
|
+
id = ids.size;
|
|
287
|
+
ids.set(key, id);
|
|
288
|
+
}
|
|
289
|
+
classes[i] = id;
|
|
290
|
+
}
|
|
291
|
+
checkWall('request quotient complete');
|
|
292
|
+
return ids.size < requests.length ? { classes, count: ids.size, selector, reads } : undefined;
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (error instanceof UnsupportedQuotient)
|
|
296
|
+
return undefined;
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type C, type Law, type Machine } from './machine.js';
|
|
2
|
+
export type RowAgreementShape = {
|
|
3
|
+
map: string;
|
|
4
|
+
width: number;
|
|
5
|
+
left: string;
|
|
6
|
+
right: string;
|
|
7
|
+
column: string;
|
|
8
|
+
fields: string[];
|
|
9
|
+
markers: {
|
|
10
|
+
map: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}[];
|
|
13
|
+
guard: C;
|
|
14
|
+
};
|
|
15
|
+
export declare function discoverRowAgreement(m: Machine, law: Law): RowAgreementShape | undefined;
|