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
package/dist/core/kind.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "./wall.js";
|
|
1
2
|
import { checkKInduction, historyMachine, kInductionStart, kInductionSteps, stepLawObligations } from "../kernel/kernel.js";
|
|
2
3
|
import { clock, counted, grow, proveLaws } from "../kernel/prove.js";
|
|
3
4
|
import { REFUTED, growCdcl } from "../kernel/cdcl.js";
|
|
@@ -14,7 +15,7 @@ export function proveKInduction(m, laws, law, opts) {
|
|
|
14
15
|
if (!kindFits(m, laws, law))
|
|
15
16
|
return { proven: false, checked: false, depths, why: 'a law or fact about every key, a flag at every key, or a carried map' };
|
|
16
17
|
return counted(opts.rate ?? 200, () => {
|
|
17
|
-
const until = clock() + opts.ms, over = () => clock() > until || (opts.wall !== undefined &&
|
|
18
|
+
const until = clock() + opts.ms, over = () => clock() > until || (opts.wall !== undefined && countedSearchNow() > opts.wall);
|
|
18
19
|
// A goal's tree: CDCL's, unfolded (prove.ts's grow keeps CDCL off a goal over k steps, for the size of the tree its
|
|
19
20
|
// cuts would make smaller; but here the plain search's cases multiply with every step), else the plain search's.
|
|
20
21
|
const treeOf = (g) => {
|
package/dist/core/laws.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ type Seg = {
|
|
|
25
25
|
call: true;
|
|
26
26
|
args?: string;
|
|
27
27
|
};
|
|
28
|
-
type X = {
|
|
28
|
+
export type X = {
|
|
29
29
|
k: 'num';
|
|
30
30
|
v: number;
|
|
31
31
|
} | {
|
|
@@ -38,6 +38,7 @@ type X = {
|
|
|
38
38
|
v: boolean;
|
|
39
39
|
} | {
|
|
40
40
|
k: 'null';
|
|
41
|
+
absence?: 'null' | 'undefined';
|
|
41
42
|
} | {
|
|
42
43
|
k: 'path';
|
|
43
44
|
head: string;
|
package/dist/core/laws.js
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
// in it, the same item, not an equal one), at every two (or three) at once
|
|
29
29
|
// mode == "closed", outcome == SLOW_ERROR, mode == :closed a choice by its value
|
|
30
30
|
import { Choice, Int, Str, Term, all, any, forall, no, not, yes } from "./dsl.js";
|
|
31
|
+
import { attachNativeLaw } from "./source-check.js";
|
|
32
|
+
import { nativeLaw } from "./native-law.js";
|
|
31
33
|
import { agreement, isolation, noninterference } from "./relational.js";
|
|
32
34
|
import { CalendarError, businessDays } from "./calendar.js";
|
|
33
35
|
export { businessDays } from "./calendar.js";
|
|
@@ -178,7 +180,7 @@ export function parse(s) {
|
|
|
178
180
|
if (['false', 'False'].includes(x))
|
|
179
181
|
return { k: 'bool', v: false };
|
|
180
182
|
if (['None', 'nil', 'null', 'undefined', 'NULL', 'nullptr'].includes(x))
|
|
181
|
-
return { k: 'null' };
|
|
183
|
+
return { k: 'null', ...(x === 'null' || x === 'undefined' ? { absence: x } : {}) };
|
|
182
184
|
if (!/^@?[A-Za-z_]/.test(x))
|
|
183
185
|
throw new LawError(`unexpected ${JSON.stringify(x)}`);
|
|
184
186
|
if (x === 'old' && peek() === '(') {
|
|
@@ -264,6 +266,10 @@ const calendarOf = (opts) => {
|
|
|
264
266
|
};
|
|
265
267
|
export function buildLaw(x, l, opts = {}) {
|
|
266
268
|
const strictOptional = x.model?.standalone === true;
|
|
269
|
+
const absence = {};
|
|
270
|
+
for (const r of Object.values(x.model?.results ?? {}))
|
|
271
|
+
if (r.k === 'maybe')
|
|
272
|
+
absence[r.missing] = r.null ? 'null' : 'undefined';
|
|
267
273
|
const names = namesWithClock(x), r = x.rule;
|
|
268
274
|
if (!r)
|
|
269
275
|
throw new LawError('the extraction has no rule');
|
|
@@ -272,15 +278,18 @@ export function buildLaw(x, l, opts = {}) {
|
|
|
272
278
|
const e = parse(l.expr);
|
|
273
279
|
// A first reading finds what the law reads: a request, a result, the failure or the state before make it a step law.
|
|
274
280
|
const cal = opts.clock === undefined ? undefined : calendarOf(opts);
|
|
275
|
-
const probe = { strictOptional, consts: x.consts, b: {}, a: {}, step: true, method: l.method, keys: new Map(), roles: new Set(), methods: new Set(), clock: opts.clock, cal };
|
|
281
|
+
const probe = { strictOptional, absence, consts: x.consts, b: {}, a: {}, step: true, method: l.method, keys: new Map(), roles: new Set(), methods: new Set(), clock: opts.clock, cal };
|
|
276
282
|
read(e, probe, names, true);
|
|
277
283
|
// (a law on a method, the line above it, is a law of its step: the state after it, old(x) before)
|
|
278
284
|
const step = !!l.method || ['input', 'answer', 'result', 'failed', 'clock', 'method', 'old'].some(k => probe.roles.has(k));
|
|
279
|
-
|
|
285
|
+
// An explicit binding is authoritative even when a name has only one owner.
|
|
286
|
+
if (l.method && [...probe.methods].some(method => method !== l.method))
|
|
287
|
+
throw new LawError(`the law is bound to ${l.method}, but reads a value belonging to ${[...probe.methods].join(', ')}`);
|
|
288
|
+
const method = l.method ?? (probe.methods.size === 1 ? [...probe.methods][0] : undefined);
|
|
280
289
|
if (probe.methods.size > 1)
|
|
281
290
|
throw new LawError(`it reads the arguments of ${[...probe.methods].join(' and ')}: a law of one step is about one method`);
|
|
282
291
|
const gate = step && method && names.some(n => n.role === 'method') ? method : undefined;
|
|
283
|
-
const body0 = (b, a, pins, bits) => read(e, { strictOptional, consts: x.consts, b, a, step, method, keys: new Map(), roles: new Set(), methods: new Set(), clock: opts.clock, cal, pins, ...(bits ? { bits } : {}) }, names, false);
|
|
292
|
+
const body0 = (b, a, pins, bits) => read(e, { strictOptional, absence, consts: x.consts, b, a, step, method, keys: new Map(), roles: new Set(), methods: new Set(), clock: opts.clock, cal, pins, ...(bits ? { bits } : {}) }, names, false);
|
|
284
293
|
// (a step law's bit tests: read once to count the keys they take, then at every value of them, the facts implying it)
|
|
285
294
|
const bitBody = (b, a) => {
|
|
286
295
|
const count = { ks: [], used: 0, hyps: [] };
|
|
@@ -295,10 +304,11 @@ export function buildLaw(x, l, opts = {}) {
|
|
|
295
304
|
};
|
|
296
305
|
// (a law of one step reads no function, so business days there pin each time's week to a key, ∀w. guard → law)
|
|
297
306
|
const body = (b, a) => (step && probe.roles.has('bdays') ? pinned(b, a, (bb, aa, p) => body0(bb, aa, p)) : bitBody(b, a));
|
|
307
|
+
const bind = (built) => { attachNativeLaw(x.rule, built.law, l.name, built.kind === 'step' ? gate ?? method : undefined, nativeLaw(e, opts, parse, { ...Object.fromEntries(names.filter(n => n.role === 'const' && n.value !== undefined).map(n => [n.code, n.value])), ...x.consts }, new Set(names.map(n => n.code.split('.')[0])))); return built; };
|
|
298
308
|
if (!step)
|
|
299
|
-
return { kind: 'law', law: r.law(l.name, (env) => (x.quiet ? env[x.quiet].eq(0).implies(body0(env, env)) : body0(env, env))) };
|
|
309
|
+
return bind({ kind: 'law', law: r.law(l.name, (env) => (x.quiet ? env[x.quiet].eq(0).implies(body0(env, env)) : body0(env, env))) });
|
|
300
310
|
const mname = names.find(n => n.role === 'method')?.rule;
|
|
301
|
-
return { kind: 'step', ...(gate ? { method: gate } : {}), law: r.stepLaw(l.name, (b, a) => body(b, a), gate ? (b) => b[mname].is(gate) : undefined) };
|
|
311
|
+
return bind({ kind: 'step', ...(gate ? { method: gate } : {}), law: r.stepLaw(l.name, (b, a) => body(b, a), gate ? (b) => b[mname].is(gate) : undefined) });
|
|
302
312
|
}
|
|
303
313
|
// A law of one step over business days: read once to find its times, then held at every week of each (a key, two for
|
|
304
314
|
// a time that may be below 0), under the guards that only each time's own week meets.
|
|
@@ -393,7 +403,7 @@ function val(e, c, names, dry) {
|
|
|
393
403
|
throw new LawError(`${e.text}: not a whole number of the clock's units`);
|
|
394
404
|
return { t: 'num', v: Int.of(e.v * c.clock) };
|
|
395
405
|
case 'bool': return { t: 'cond', v: e.v ? yes : no };
|
|
396
|
-
case 'null': return { t: 'null' };
|
|
406
|
+
case 'null': return { t: 'null', absence: e.absence };
|
|
397
407
|
case 'str':
|
|
398
408
|
if (e.holes)
|
|
399
409
|
throw new LawError('a string template outside a store\'s key');
|
|
@@ -454,8 +464,9 @@ function val(e, c, names, dry) {
|
|
|
454
464
|
// over the integers (a <= x // k is k·a <= x; a < x // k is k·(a + 1) <= x), so it needs no function, which a law
|
|
455
465
|
// of one step can't read)
|
|
456
466
|
const flip = { '<': '>', '<=': '>=', '>': '<', '>=': '<=', '==': '==', '!=': '!=' };
|
|
467
|
+
// Calendar operands retain strict optional checks throughout nested arithmetic.
|
|
457
468
|
if (flip[e.op] && (e.a.k === 'bdur' || e.b.k === 'bdur'))
|
|
458
|
-
return { t: 'cond', v: businessCompare(e, flip, c,
|
|
469
|
+
return { t: 'cond', v: businessCompare(e, flip, c, operand => val(operand, { ...c, strictOptional: true }, names, dry), dry) };
|
|
459
470
|
const divk = (x) => (x.k === 'bin' && x.op === '//' && (constOf(x.b) ?? 0) >= 1 ? x : undefined);
|
|
460
471
|
if (flip[e.op] && (divk(e.b) || divk(e.a))) {
|
|
461
472
|
// Inspect the original numerator before rewriting division into comparisons.
|
|
@@ -573,6 +584,8 @@ function businessCompare(e, flip, c, go, dry) {
|
|
|
573
584
|
throw new LawError(`${n.text}: business days need a calendar ([calendar] in gdp.toml: weekend = ["sat", "sun"], holidays = ["2026-12-25", ...], utc_offset = "-05:00")`);
|
|
574
585
|
c.roles.add('bdays');
|
|
575
586
|
const later = go(diff.a), earlier = go(diff.b);
|
|
587
|
+
if ([later, earlier].some(v => v.t === 'opt'))
|
|
588
|
+
throw new LawError(c.strictOptional ? 'arithmetic on an optional standalone value is not supported' : 'arithmetic on an optional value is not supported in calendar comparisons');
|
|
576
589
|
if (dry)
|
|
577
590
|
return yes;
|
|
578
591
|
const cal = c.cal, at = (x, v) => {
|
|
@@ -596,9 +609,13 @@ function businessCompare(e, flip, c, go, dry) {
|
|
|
596
609
|
// (a path's last name: a choice's value written as one, Outcome.SLOW_ERROR)
|
|
597
610
|
const lastName = (x) => (x.segs.length ? x.segs.at(-1).f : x.head);
|
|
598
611
|
const constOf = (x) => (x.k === 'num' ? x.v : x.k === 'un' && x.op === '-' && x.x.k === 'num' ? -x.x.v : undefined);
|
|
599
|
-
|
|
612
|
+
// Require the caller to choose source semantics, including on recursive unwrapping.
|
|
613
|
+
function compare(op, a, b, e, strictOptional) {
|
|
600
614
|
if (b.t === 'null' || a.t === 'null') {
|
|
615
|
+
const literal = a.t === 'null' ? a : b;
|
|
601
616
|
const o = a.t === 'null' ? b : a, none = o.t === 'opt' ? o.none : o.t === 'cell' ? not(o.rec.has) : undefined;
|
|
617
|
+
if (strictOptional && o.t === 'opt' && literal.absence && o.absence && literal.absence !== o.absence)
|
|
618
|
+
return op === '==' ? no : op === '!=' ? yes : fail(`${op} with None`);
|
|
602
619
|
if (!none)
|
|
603
620
|
throw new LawError(`${show(a.t === 'null' ? e.b : e.a)} is never None here (the rule holds no None for it)`);
|
|
604
621
|
return op === '==' ? none : op === '!=' ? not(none) : fail(`${op} with None`);
|
|
@@ -609,11 +626,11 @@ function compare(op, a, b, e, strictOptional = false) {
|
|
|
609
626
|
const av = a.t === 'opt' ? a.v : a, bv = b.t === 'opt' ? b.v : b;
|
|
610
627
|
const present = all(a.t === 'opt' ? not(a.none) : yes, b.t === 'opt' ? not(b.none) : yes);
|
|
611
628
|
if (op === '==' || op === '!=') {
|
|
612
|
-
const absent = a.t === 'opt' && b.t === 'opt' ? all(a.none, b.none) : no;
|
|
613
|
-
const equal = any(absent, av && bv ? all(present, compare('==', av, bv, e)) : no);
|
|
629
|
+
const absent = a.t === 'opt' && b.t === 'opt' && (!a.absence || !b.absence || a.absence === b.absence) ? all(a.none, b.none) : no;
|
|
630
|
+
const equal = any(absent, av && bv ? all(present, compare('==', av, bv, e, strictOptional)) : no);
|
|
614
631
|
return op === '==' ? equal : not(equal);
|
|
615
632
|
}
|
|
616
|
-
return av && bv ? all(present, compare(op, av, bv, e)) : no;
|
|
633
|
+
return av && bv ? all(present, compare(op, av, bv, e, strictOptional)) : no;
|
|
617
634
|
}
|
|
618
635
|
const un = (v) => (v.t === 'opt' && v.v ? v.v : v);
|
|
619
636
|
a = un(a);
|
|
@@ -625,8 +642,12 @@ function compare(op, a, b, e, strictOptional = false) {
|
|
|
625
642
|
const eq = (c) => (op === '==' ? c : op === '!=' ? not(c) : fail(`${op} of values that aren't numbers`));
|
|
626
643
|
if (a.t === 'choice' || b.t === 'choice') {
|
|
627
644
|
const [ch, o, ox] = a.t === 'choice' ? [a.v, b, e.b] : [b.v, a, e.a];
|
|
645
|
+
// Choice encodings are local to each domain: the same index can name
|
|
646
|
+
// different strings. In standalone laws compare common names, not indices.
|
|
628
647
|
if (o.t === 'choice')
|
|
629
|
-
return eq(
|
|
648
|
+
return eq(strictOptional
|
|
649
|
+
? any(...ch.values.filter(v => o.v.values.includes(v)).map(v => all(ch.is(v), o.v.is(v))))
|
|
650
|
+
: ch.eq(o.v));
|
|
630
651
|
const lit = o.t === 'lit' ? o.v : ox.k === 'path' ? lastName(ox) : undefined;
|
|
631
652
|
if (lit === undefined || !ch.values.includes(lit))
|
|
632
653
|
throw new LawError(`${show(ox)} isn't one of ${ch.values.join(', ')}`);
|
|
@@ -666,6 +687,18 @@ function path(e, c, names, dry) {
|
|
|
666
687
|
return DRY;
|
|
667
688
|
// (result and failed are the step's, unless the code has a name of its own so: a field named failed, read bare, is
|
|
668
689
|
// that field, as self.failed always is)
|
|
690
|
+
if (e.head === 'result' && e.segs[0] && 'f' in e.segs[0]) {
|
|
691
|
+
const field = `result.${e.segs[0].f}`, rs = names.filter(n => n.role === 'result' && n.code === field);
|
|
692
|
+
const hit = rs.find(n => n.method === c.method) ?? (rs.length === 1 ? rs[0] : undefined);
|
|
693
|
+
if (hit) {
|
|
694
|
+
c.roles.add('result');
|
|
695
|
+
if (hit.method)
|
|
696
|
+
c.methods.add(hit.method);
|
|
697
|
+
return rest(e.segs.slice(1), leaf(hit, c, dry), c, names, dry, e);
|
|
698
|
+
}
|
|
699
|
+
if (rs.length > 1)
|
|
700
|
+
throw new LawError(`${field}: name the method it belongs to`);
|
|
701
|
+
}
|
|
669
702
|
if ((e.head === 'result' || e.head === 'failed') && !names.some(n => n.code === e.head && n.role !== 'failed' && n.role !== 'result')) {
|
|
670
703
|
const n = e.head === 'failed' ? names.find(x => x.role === 'failed') : results(names, c);
|
|
671
704
|
if (!n)
|
|
@@ -781,7 +814,7 @@ function leaf(n, c, dry) {
|
|
|
781
814
|
const get = (r) => { if (!(r in env) && !(r in c.b))
|
|
782
815
|
throw new LawError(`${n.code}: ${r} isn't in the rule's environment here`); return r in env ? env[r] : c.b[r]; };
|
|
783
816
|
const v = n.rule ? wrap(get(n.rule)) : undefined;
|
|
784
|
-
return n.none ? { t: 'opt', none: get(n.none), ...(v ? { v } : {}) } : v;
|
|
817
|
+
return n.none ? { t: 'opt', none: get(n.none), absence: c.strictOptional ? c.absence?.[n.none] ?? 'undefined' : undefined, ...(v ? { v } : {}) } : v;
|
|
785
818
|
}
|
|
786
819
|
// The rest of a path: a map at a key (m[k], m.get(k)), a cell's field, has/contains/key? of a map.
|
|
787
820
|
function rest(segs, v, c, names, dry, e) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Goal, type LemmaCut, type Path, type Tree, leafConstraintsReusing as leafConstraints } from '../kernel/kernel.js';
|
|
2
|
+
export type ProofOrigin = {
|
|
3
|
+
goal: Goal;
|
|
4
|
+
tree: Tree;
|
|
5
|
+
path: Path;
|
|
6
|
+
};
|
|
7
|
+
export declare const proofOrigins: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const proofOrigin: (tree: Tree) => ProofOrigin | undefined;
|
|
11
|
+
export declare const setProofOrigin: (tree: Tree, origin: ProofOrigin) => void;
|
|
12
|
+
export declare function rememberProofOrigin(out: Tree | undefined, part: Goal, tree: Tree, path: Path, whole: Goal): void;
|
|
13
|
+
type ProofRows = ReturnType<typeof leafConstraints>;
|
|
14
|
+
export declare function rememberProofRows(tree: Tree, goal: Goal, path: Path, rows: ProofRows): void;
|
|
15
|
+
export type SharedCuts = {
|
|
16
|
+
goal: Goal;
|
|
17
|
+
tree: Tree;
|
|
18
|
+
lemmas: LemmaCut[];
|
|
19
|
+
stats: {
|
|
20
|
+
before: number;
|
|
21
|
+
after: number;
|
|
22
|
+
cuts: number;
|
|
23
|
+
sourceHyps: number;
|
|
24
|
+
lemmaHyps: number;
|
|
25
|
+
mainNodes: number;
|
|
26
|
+
checkMs: number;
|
|
27
|
+
buildMs: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function proposeLemmaCuts(goal: Goal, tree: Tree, options?: {
|
|
31
|
+
path?: Path;
|
|
32
|
+
until?: number;
|
|
33
|
+
minNodes?: number;
|
|
34
|
+
minimizeConditions?: boolean;
|
|
35
|
+
trace?: (event: Record<string, string | number | boolean>) => void;
|
|
36
|
+
}): SharedCuts | undefined;
|
|
37
|
+
export declare function shareLemmaCuts(goal: Goal, tree: Tree, options?: Parameters<typeof proposeLemmaCuts>[2]): SharedCuts | undefined;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { searchNow as countedSearchNow } from "./wall.js";
|
|
2
|
+
// Untrusted proof compression. Turn repeated forced splits into independently checked conditional cuts.
|
|
3
|
+
// No search, protocol vocabulary, new facts or proof-budget changes: failed transport/check returns no proposal.
|
|
4
|
+
import { n, plus, times, x } from "./machine.js";
|
|
5
|
+
import { add, k, scale } from "./solver.js";
|
|
6
|
+
import { canon, canonFlip, checkGoalLemmas, isCell, isMonomial, leafConstraintsReusing as leafConstraints, lemmaPath } from "../kernel/kernel.js";
|
|
7
|
+
const originOf = new WeakMap();
|
|
8
|
+
// Search provenance is only an optional proposer hint. The trusted checker never reads this cache.
|
|
9
|
+
export const proofOrigins = { enabled: false };
|
|
10
|
+
export const proofOrigin = (tree) => originOf.get(tree);
|
|
11
|
+
export const setProofOrigin = (tree, origin) => { originOf.set(tree, origin); };
|
|
12
|
+
export function rememberProofOrigin(out, part, tree, path, whole) {
|
|
13
|
+
if (!out)
|
|
14
|
+
return;
|
|
15
|
+
const earlier = originOf.get(tree);
|
|
16
|
+
if (earlier && earlier.goal.hyps.length <= part.hyps.length)
|
|
17
|
+
originOf.set(out, earlier);
|
|
18
|
+
else if (part.hyps.length < whole.hyps.length)
|
|
19
|
+
originOf.set(out, { goal: part, tree, path: new Map(path) });
|
|
20
|
+
}
|
|
21
|
+
const rowIds = new WeakMap(), rowIndexes = new WeakMap();
|
|
22
|
+
const rowId = (lin) => {
|
|
23
|
+
let id = rowIds.get(lin);
|
|
24
|
+
if (id === undefined) {
|
|
25
|
+
id = canon(lin);
|
|
26
|
+
rowIds.set(lin, id);
|
|
27
|
+
}
|
|
28
|
+
return id;
|
|
29
|
+
};
|
|
30
|
+
const rowIndex = (rows) => {
|
|
31
|
+
let at = rowIndexes.get(rows);
|
|
32
|
+
if (!at) {
|
|
33
|
+
at = new Map();
|
|
34
|
+
rows.forEach((r, i) => { const id = rowId(r.lin); if (!at.has(id))
|
|
35
|
+
at.set(id, i); });
|
|
36
|
+
rowIndexes.set(rows, at);
|
|
37
|
+
}
|
|
38
|
+
return at;
|
|
39
|
+
};
|
|
40
|
+
const rowsOf = new WeakMap();
|
|
41
|
+
const pathKey = (p) => JSON.stringify([...p].map(([id, a]) => [id, canon(a.lin), a.holds]));
|
|
42
|
+
const savedProofRows = (tree, goal, path) => {
|
|
43
|
+
const old = rowsOf.get(tree);
|
|
44
|
+
return old?.goal === goal && old.path === pathKey(path) ? old : undefined;
|
|
45
|
+
};
|
|
46
|
+
const saveProofRows = (tree, goal, path, rows, atoms) => {
|
|
47
|
+
rowsOf.set(tree, { goal, path: pathKey(path), rows, atoms });
|
|
48
|
+
};
|
|
49
|
+
// Hints only: the trusted checker always rebuilds its own rows. Capturing reuses work already done by widen.
|
|
50
|
+
export function rememberProofRows(tree, goal, path, rows) {
|
|
51
|
+
if (proofOrigins.enabled && 'leaf' in tree)
|
|
52
|
+
saveProofRows(tree, goal, path, rows);
|
|
53
|
+
}
|
|
54
|
+
const decide = (lin, path) => {
|
|
55
|
+
if (!Object.values(lin).every(Number.isSafeInteger))
|
|
56
|
+
return undefined;
|
|
57
|
+
if (Object.keys(lin).every(k => k === '1'))
|
|
58
|
+
return (lin['1'] ?? 0) <= 0;
|
|
59
|
+
const direct = path.get(canon(lin))?.holds;
|
|
60
|
+
if (direct !== undefined)
|
|
61
|
+
return direct;
|
|
62
|
+
const opposite = path.get(canonFlip(lin))?.holds;
|
|
63
|
+
return opposite === undefined ? undefined : !opposite;
|
|
64
|
+
};
|
|
65
|
+
const flip = (r) => add(k(1), scale(r, -1));
|
|
66
|
+
const put = (p, lin, holds) => new Map(p).set(canon(lin), { lin, holds });
|
|
67
|
+
const proofPath = (when, cut) => {
|
|
68
|
+
const p = new Map();
|
|
69
|
+
let duplicate = 0;
|
|
70
|
+
for (const atom of [{ lin: cut, holds: false }, ...when.map(lin => ({ lin, holds: true }))]) {
|
|
71
|
+
const key = canon(atom.lin);
|
|
72
|
+
p.set(p.has(key) ? `@${duplicate++}` : key, atom);
|
|
73
|
+
}
|
|
74
|
+
return p;
|
|
75
|
+
};
|
|
76
|
+
// Unlike widen, transport never calls a solver when a row is missing.
|
|
77
|
+
function transport(from, to, tree, before, after, until, missing) {
|
|
78
|
+
if (countedSearchNow() >= until)
|
|
79
|
+
return undefined;
|
|
80
|
+
if ('split' in tree) {
|
|
81
|
+
const known = decide(tree.split, after);
|
|
82
|
+
if (known !== undefined)
|
|
83
|
+
return transport(from, to, known ? tree.yes : tree.no, put(before, tree.split, known), after, until, missing);
|
|
84
|
+
const yes = transport(from, to, tree.yes, put(before, tree.split, true), put(after, tree.split, true), until, missing);
|
|
85
|
+
const no = yes && transport(from, to, tree.no, put(before, tree.split, false), put(after, tree.split, false), until, missing);
|
|
86
|
+
return yes && no ? { split: tree.split, yes, no } : undefined;
|
|
87
|
+
}
|
|
88
|
+
const atoms = new Set();
|
|
89
|
+
const old = savedProofRows(tree, from, before)?.rows ?? leafConstraints(from, before);
|
|
90
|
+
const rows = leafConstraints(to, new ObservedPath(after, atoms)), at = rowIndex(rows);
|
|
91
|
+
const index = (i) => {
|
|
92
|
+
if (i >= old.length)
|
|
93
|
+
return i - old.length + rows.length;
|
|
94
|
+
const row = old[i], found = row && at.get(rowId(row.lin));
|
|
95
|
+
if (row && found === undefined)
|
|
96
|
+
missing?.(row.lin);
|
|
97
|
+
return found;
|
|
98
|
+
};
|
|
99
|
+
const leaf = [], products = [];
|
|
100
|
+
for (const s of tree.leaf) {
|
|
101
|
+
if (s.kind !== 'input')
|
|
102
|
+
leaf.push(s);
|
|
103
|
+
else {
|
|
104
|
+
const i = index(s.index);
|
|
105
|
+
if (i === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
leaf.push({ ...s, index: i });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const [a, b] of tree.products ?? []) {
|
|
111
|
+
const i = index(a), j = index(b);
|
|
112
|
+
if (i === undefined || j === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
products.push([i, j]);
|
|
115
|
+
}
|
|
116
|
+
const out = { leaf, ...(tree.products ? { products } : {}), ...(tree.squares ? { squares: tree.squares } : {}) };
|
|
117
|
+
saveProofRows(out, to, after, rows, atoms);
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
// Observe only lookups; enumerating path rows is not itself a dependence on every path assumption.
|
|
121
|
+
class ObservedPath extends Map {
|
|
122
|
+
observed;
|
|
123
|
+
constructor(path, observed) {
|
|
124
|
+
super(path);
|
|
125
|
+
this.observed = observed;
|
|
126
|
+
}
|
|
127
|
+
get(key) { this.observed.add(key); return super.get(key); }
|
|
128
|
+
has(key) { this.observed.add(key); return super.has(key); }
|
|
129
|
+
}
|
|
130
|
+
function dependencies(g, t, path, facts, atoms, until) {
|
|
131
|
+
if (countedSearchNow() >= until)
|
|
132
|
+
return false;
|
|
133
|
+
if ('split' in t)
|
|
134
|
+
return dependencies(g, t.yes, put(path, t.split, true), facts, atoms, until)
|
|
135
|
+
&& dependencies(g, t.no, put(path, t.split, false), facts, atoms, until);
|
|
136
|
+
const observed = new ObservedPath(path, atoms), cached = savedProofRows(t, g, path);
|
|
137
|
+
const rows = cached?.rows ?? leafConstraints(g, observed), values = [...path.values()];
|
|
138
|
+
if (cached?.atoms)
|
|
139
|
+
for (const key of cached.atoms)
|
|
140
|
+
atoms.add(key);
|
|
141
|
+
// Prover-captured tables have no new lookup trace. Conservatively retain their source conditions.
|
|
142
|
+
else if (cached)
|
|
143
|
+
for (const a of values) {
|
|
144
|
+
atoms.add(canon(a.lin));
|
|
145
|
+
atoms.add(canonFlip(a.lin));
|
|
146
|
+
}
|
|
147
|
+
for (const i of [...t.leaf.flatMap(s => s.kind === 'input' ? [s.index] : []), ...(t.products ?? []).flat()]) {
|
|
148
|
+
const src = rows[i]?.src;
|
|
149
|
+
if (src && 'fact' in src)
|
|
150
|
+
facts.add(src.fact);
|
|
151
|
+
if (src && 'atom' in src) {
|
|
152
|
+
const a = values[src.atom];
|
|
153
|
+
if (a) {
|
|
154
|
+
atoms.add(canon(a.lin));
|
|
155
|
+
atoms.add(canonFlip(a.lin));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
// Conditional replay scopes are explicit hypotheses, never silently assumed. Root scopes currently reify scalar
|
|
162
|
+
// rows; rootless production certificates also support all the original cell/term/monomial columns.
|
|
163
|
+
function scopeCondition(lin) {
|
|
164
|
+
let a = n(0), b = n(0);
|
|
165
|
+
for (const [name, z] of Object.entries(lin)) {
|
|
166
|
+
if (!Number.isSafeInteger(z))
|
|
167
|
+
return undefined;
|
|
168
|
+
if (name !== '1' && (isCell(name) || isMonomial(name) || name.startsWith('⟦')))
|
|
169
|
+
return undefined;
|
|
170
|
+
const term = name === '1' ? n(Math.abs(z)) : times(Math.abs(z), x(name));
|
|
171
|
+
if (z > 0)
|
|
172
|
+
a = plus(a, term);
|
|
173
|
+
else if (z < 0)
|
|
174
|
+
b = plus(b, term);
|
|
175
|
+
}
|
|
176
|
+
return { op: '<=', a, b };
|
|
177
|
+
}
|
|
178
|
+
// Candidate construction only. Call shareLemmaCuts or the containing machine checker before admission.
|
|
179
|
+
export function proposeLemmaCuts(goal, tree, options = {}) {
|
|
180
|
+
const started = countedSearchNow(), root = options.path ?? new Map(), until = options.until ?? Infinity;
|
|
181
|
+
const sizes = new WeakMap(), repeats = new Map();
|
|
182
|
+
const measure = (t) => {
|
|
183
|
+
if ('leaf' in t) {
|
|
184
|
+
sizes.set(t, 1);
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
const id = canon(t.split);
|
|
188
|
+
repeats.set(id, (repeats.get(id) ?? 0) + 1);
|
|
189
|
+
const size = 1 + measure(t.yes) + measure(t.no);
|
|
190
|
+
sizes.set(t, size);
|
|
191
|
+
return size;
|
|
192
|
+
};
|
|
193
|
+
const before = measure(tree);
|
|
194
|
+
if (before < (options.minNodes ?? 64))
|
|
195
|
+
return undefined;
|
|
196
|
+
const roots = [...root.values()], conditions = roots.map(a => scopeCondition(a.holds ? a.lin : flip(a.lin)));
|
|
197
|
+
if (conditions.some(c => !c))
|
|
198
|
+
return undefined;
|
|
199
|
+
const scoped = root.size ? { ...goal, hyps: [...goal.hyps, ...conditions] } : goal;
|
|
200
|
+
const lemmas = [], shared = new Map(), origins = new WeakMap();
|
|
201
|
+
const keyOf = (when, cut) => when.map(canon).sort().join(';') + '=>' + canon(cut);
|
|
202
|
+
const makeLemma = (t, original, real) => {
|
|
203
|
+
let when = [...real.values()].map(a => a.holds ? a.lin : flip(a.lin));
|
|
204
|
+
let base = proofPath(when, t.split);
|
|
205
|
+
const available = lemmas.filter(l => l.when.every(w => decide(w, real) === true));
|
|
206
|
+
const from = (g, body, path) => {
|
|
207
|
+
const required = [];
|
|
208
|
+
let proof;
|
|
209
|
+
for (;;) {
|
|
210
|
+
let absent;
|
|
211
|
+
const target = required.reduce((p, l) => put(p, l.cut, true), base);
|
|
212
|
+
proof = transport(g, goal, body, path, target, until, row => { absent = canon(row); });
|
|
213
|
+
if (proof)
|
|
214
|
+
break;
|
|
215
|
+
const dependency = available.find(l => canon(l.cut) === absent && !required.includes(l));
|
|
216
|
+
if (!dependency)
|
|
217
|
+
return undefined;
|
|
218
|
+
required.push(dependency);
|
|
219
|
+
}
|
|
220
|
+
// Inline only prerequisites whose exact rows were needed. Each is an already independent proof;
|
|
221
|
+
// no certificate lemma is permitted to cite another lemma, and there is no circular trust.
|
|
222
|
+
for (let i = required.length - 1; i >= 0; i--) {
|
|
223
|
+
const l = required[i], local = l.slice ? { ...goal, hyps: l.slice.map(j => goal.hyps[j]) } : goal;
|
|
224
|
+
const prefix = required.slice(0, i).reduce((p, prev) => put(p, prev.cut, true), base);
|
|
225
|
+
const no = transport(local, goal, l.tree, proofPath(l.when, l.cut), put(prefix, l.cut, false), until);
|
|
226
|
+
if (!no)
|
|
227
|
+
return undefined;
|
|
228
|
+
proof = { split: l.cut, yes: proof, no };
|
|
229
|
+
}
|
|
230
|
+
return proof;
|
|
231
|
+
};
|
|
232
|
+
const origin = proofOrigin(t.no);
|
|
233
|
+
let proof = origin && from(origin.goal, origin.tree, origin.path);
|
|
234
|
+
proof ??= from(goal, t.no, put(original, t.split, false));
|
|
235
|
+
if (!proof)
|
|
236
|
+
return undefined;
|
|
237
|
+
const used = new Set(), seen = new Set();
|
|
238
|
+
if (!dependencies(goal, proof, base, used, seen, until))
|
|
239
|
+
return undefined;
|
|
240
|
+
let slice = [...used].sort((a, b) => a - b), small = { ...goal, hyps: slice.map(i => goal.hyps[i]) };
|
|
241
|
+
const narrowed = transport(goal, small, proof, base, base, until);
|
|
242
|
+
if (narrowed)
|
|
243
|
+
proof = narrowed;
|
|
244
|
+
else {
|
|
245
|
+
slice = goal.hyps.map((_, i) => i);
|
|
246
|
+
small = goal;
|
|
247
|
+
}
|
|
248
|
+
// A failed dependency minimization is just a missed optimization. The old proof and full conditions remain.
|
|
249
|
+
const needed = new Set();
|
|
250
|
+
if (!dependencies(small, proof, base, new Set(), needed, until))
|
|
251
|
+
return undefined;
|
|
252
|
+
const less = when.filter(w => needed.has(canon(w)) || needed.has(canonFlip(w)));
|
|
253
|
+
if (less.length < when.length) {
|
|
254
|
+
const next = proofPath(less, t.split), reduced = transport(small, small, proof, base, next, until);
|
|
255
|
+
if (reduced) {
|
|
256
|
+
when = less;
|
|
257
|
+
base = next;
|
|
258
|
+
proof = reduced;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// Lookup traces are conservative (a discarded alternative may read a condition). Remove each remaining
|
|
262
|
+
// unnecessary condition by exact row transport, never by asserting that an unknown condition holds.
|
|
263
|
+
for (let i = options.minimizeConditions ? when.length - 1 : -1; i >= 0; i--) {
|
|
264
|
+
const less = when.filter((_, j) => i !== j), next = proofPath(less, t.split);
|
|
265
|
+
const reduced = transport(small, small, proof, base, next, until);
|
|
266
|
+
if (reduced) {
|
|
267
|
+
when = less;
|
|
268
|
+
base = next;
|
|
269
|
+
proof = reduced;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return { when, cut: t.split, tree: proof, slice };
|
|
273
|
+
};
|
|
274
|
+
const visit = (t, original, real) => {
|
|
275
|
+
if (countedSearchNow() >= until)
|
|
276
|
+
return undefined;
|
|
277
|
+
if ('leaf' in t) {
|
|
278
|
+
const copy = { ...t };
|
|
279
|
+
origins.set(copy, { tree: t, path: original });
|
|
280
|
+
return copy;
|
|
281
|
+
}
|
|
282
|
+
const id = canon(t.split);
|
|
283
|
+
// Prefer compact repeated derivations. Larger enclosing candidates are left as ordinary tree nodes;
|
|
284
|
+
// the final comparison still weighs each proposed proof by its actual hypothesis context.
|
|
285
|
+
if ((repeats.get(id) ?? 0) >= 2 && (sizes.get(t.no) ?? 0) >= 3 && (sizes.get(t.no) ?? 0) <= 128) {
|
|
286
|
+
const fullKey = keyOf([...real.values()].map(a => a.holds ? a.lin : flip(a.lin)), t.split);
|
|
287
|
+
let found = shared.get(fullKey);
|
|
288
|
+
if (found === undefined) {
|
|
289
|
+
const usable = lemmas.findIndex(l => canon(l.cut) === id && l.when.every(w => decide(w, real) === true));
|
|
290
|
+
if (usable >= 0)
|
|
291
|
+
found = usable;
|
|
292
|
+
}
|
|
293
|
+
if (found === undefined) {
|
|
294
|
+
const begun = countedSearchNow(), lemma = makeLemma(t, original, real);
|
|
295
|
+
options.trace?.({ stage: 'lemma', produced: !!lemma, nodes: sizes.get(t.no) ?? 0, ms: countedSearchNow() - begun, when: lemma?.when.length ?? -1, hyps: lemma?.slice?.length ?? -1 });
|
|
296
|
+
if (lemma) {
|
|
297
|
+
const key = keyOf(lemma.when, lemma.cut);
|
|
298
|
+
found = shared.get(key);
|
|
299
|
+
if (found === undefined) {
|
|
300
|
+
found = lemmas.length;
|
|
301
|
+
lemmas.push(lemma);
|
|
302
|
+
shared.set(key, found);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (found !== undefined) {
|
|
307
|
+
shared.set(fullKey, found);
|
|
308
|
+
return visit(t.yes, put(original, t.split, true), real);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const yes = visit(t.yes, put(original, t.split, true), put(real, t.split, true));
|
|
312
|
+
const no = yes && visit(t.no, put(original, t.split, false), put(real, t.split, false));
|
|
313
|
+
return yes && no ? { split: t.split, yes, no } : undefined;
|
|
314
|
+
};
|
|
315
|
+
const skeleton = visit(tree, root, root);
|
|
316
|
+
if (!skeleton || !lemmas.length) {
|
|
317
|
+
options.trace?.({ stage: 'no-skeleton', lemmas: lemmas.length });
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
const finish = (t, path) => {
|
|
321
|
+
if ('leaf' in t) {
|
|
322
|
+
const src = origins.get(t);
|
|
323
|
+
return transport(goal, scoped, src.tree, src.path, lemmaPath(lemmas, path), until);
|
|
324
|
+
}
|
|
325
|
+
const yes = finish(t.yes, put(path, t.split, true)), no = yes && finish(t.no, put(path, t.split, false));
|
|
326
|
+
return yes && no ? { split: t.split, yes, no } : undefined;
|
|
327
|
+
};
|
|
328
|
+
let out = finish(skeleton, root);
|
|
329
|
+
if (!out)
|
|
330
|
+
return undefined;
|
|
331
|
+
// Prove the other side of each explicit scope condition by its contradictory hypothesis.
|
|
332
|
+
for (let i = roots.length - 1; i >= 0; i--) {
|
|
333
|
+
const a = roots[i], prefix = new Map([...root].slice(0, i)), bad = put(prefix, a.lin, !a.holds);
|
|
334
|
+
const rows = leafConstraints(scoped, bad), absurd = rows.findIndex(r => Object.keys(r.lin).every(k => k === '1') && (r.lin['1'] ?? 0) > 0);
|
|
335
|
+
let opposite;
|
|
336
|
+
if (absurd >= 0)
|
|
337
|
+
opposite = { leaf: [{ kind: 'input', index: absurd }] };
|
|
338
|
+
else {
|
|
339
|
+
const left = rows.findIndex(r => canon(r.lin) === canon(a.lin)), right = rows.findIndex(r => canon(r.lin) === canon(flip(a.lin)));
|
|
340
|
+
if (left < 0 || right < 0)
|
|
341
|
+
return undefined;
|
|
342
|
+
opposite = { leaf: [{ kind: 'input', index: left }, { kind: 'input', index: right }, { kind: 'combine', a: 0, b: 1, ma: 1, mb: 1 }] };
|
|
343
|
+
}
|
|
344
|
+
out = a.holds ? { split: a.lin, yes: out, no: opposite } : { split: a.lin, yes: opposite, no: out };
|
|
345
|
+
}
|
|
346
|
+
const count = (t) => 'leaf' in t ? 1 : 1 + count(t.yes) + count(t.no);
|
|
347
|
+
const after = count(out) + lemmas.reduce((n, l) => n + count(l.tree), 0);
|
|
348
|
+
const workBefore = before * Math.max(1, goal.hyps.length), workAfter = count(out) * Math.max(1, scoped.hyps.length) + lemmas.reduce((n, l) => n + count(l.tree) * Math.max(1, l.slice?.length ?? scoped.hyps.length), 0);
|
|
349
|
+
if (workAfter >= workBefore || countedSearchNow() >= until) {
|
|
350
|
+
options.trace?.({ stage: 'not-cheaper-or-expired', before, after, workBefore, workAfter });
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
return { goal: scoped, tree: out, lemmas, stats: { before, after, cuts: lemmas.length, sourceHyps: goal.hyps.length, lemmaHyps: lemmas.reduce((n, l) => n + (l.slice?.length ?? scoped.hyps.length), 0), mainNodes: count(out), checkMs: 0, buildMs: countedSearchNow() - started } };
|
|
354
|
+
}
|
|
355
|
+
export function shareLemmaCuts(goal, tree, options = {}) {
|
|
356
|
+
const proposed = proposeLemmaCuts(goal, tree, options);
|
|
357
|
+
if (!proposed)
|
|
358
|
+
return undefined;
|
|
359
|
+
const start = countedSearchNow(), checked = checkGoalLemmas(proposed.goal, proposed.tree, proposed.lemmas);
|
|
360
|
+
if (!checked) {
|
|
361
|
+
options?.trace?.({ stage: 'kernel-rejected' });
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
proposed.stats.checkMs = countedSearchNow() - start;
|
|
365
|
+
return proposed;
|
|
366
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Lin } from './solver.js';
|
|
2
|
+
export declare function fundedAdd(...inputs: Lin[]): Lin;
|
|
3
|
+
export declare const fundedSub: (a: Lin, b: Lin) => Lin;
|
|
4
|
+
export declare const fundedScale: (a: Lin, factor: number) => Lin;
|
|
5
|
+
export declare const fundedVariable: (name: string) => Lin;
|
|
6
|
+
export declare function fundedConstant(value: number): Lin;
|
|
7
|
+
export declare function admittedLinearProduct(a: Lin, b: Lin, keyOf: (p: string, q: string) => string | undefined, site: string, safeIntegers: boolean): Lin | undefined;
|
|
8
|
+
export declare function everyLinearCell(lin: Lin, test: (key: string, value: number) => boolean, site: string): boolean;
|
|
9
|
+
export declare function visitLinearCells(lin: Lin, visit: (key: string, value: number) => void, site: string): void;
|
|
10
|
+
export declare function admittedLinearSub(a: Lin, b: Lin, site: string): Lin;
|
|
11
|
+
export declare function admittedLinearAdd(a: Lin, b: Lin, site: string): Lin;
|
|
12
|
+
export declare function admittedLinearScale(a: Lin, factor: number, site: string): Lin;
|
|
13
|
+
export declare function admittedLinearCopy(a: Lin, site: string): Lin;
|
|
14
|
+
export declare function admittedLinearVariable(name: string, coefficient: number, site: string): Lin;
|