gdp-wired 0.48.0 → 0.50.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 +6 -2
- package/dist/core/bmc.js +10 -7
- package/dist/core/candidate-seeds.d.ts +25 -0
- package/dist/core/candidate-seeds.js +90 -0
- package/dist/core/check.js +7 -2
- package/dist/core/cli.js +3 -0
- 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.js +3 -2
- 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 +10 -2
- package/dist/core/count-cert-transport.js +60 -9
- 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-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-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-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-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-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/conditional-check-cache.js +3 -2
- package/dist/core/count-recovery/conditional-cuts.js +5 -4
- package/dist/core/count-recovery/conditional-proof.d.ts +37 -3
- package/dist/core/count-recovery/conditional-proof.js +72 -30
- package/dist/core/count-recovery/derivability-closure.js +2 -1
- package/dist/core/count-recovery/guard-cases.js +2 -1
- 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/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.js +2 -1
- 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-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 +1 -0
- package/dist/core/count-support.js +26 -4
- package/dist/core/count-tier-budget.d.ts +14 -0
- package/dist/core/count-tier-budget.js +64 -0
- package/dist/core/count-unwritten-prefix.d.ts +24 -0
- package/dist/core/count-unwritten-prefix.js +97 -0
- package/dist/core/count-write-shape.d.ts +15 -0
- package/dist/core/count-write-shape.js +73 -0
- package/dist/core/counted-candidate-seeds.d.ts +12 -0
- package/dist/core/counted-candidate-seeds.js +31 -0
- package/dist/core/counts.d.ts +37 -13
- package/dist/core/counts.js +999 -129
- 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 +32 -2
- package/dist/core/dsl.js +202 -64
- package/dist/core/evaluation-admission.d.ts +1 -0
- package/dist/core/evaluation-admission.js +3 -0
- package/dist/core/exists.d.ts +6 -1
- package/dist/core/exists.js +53 -10
- package/dist/core/field-laws.d.ts +3 -1
- package/dist/core/field-laws.js +159 -3
- package/dist/core/finite-houdini.d.ts +6 -0
- package/dist/core/finite-houdini.js +63 -21
- package/dist/core/finite-tiny.js +95 -67
- package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
- package/dist/core/fresh.js +5 -1
- package/dist/core/infer.js +49 -33
- package/dist/core/kind.js +2 -1
- package/dist/core/lemma-cuts.js +11 -10
- package/dist/core/lift-cli.d.ts +11 -0
- package/dist/core/lift-cli.js +113 -0
- package/dist/core/linear-admission.d.ts +14 -0
- package/dist/core/linear-admission.js +151 -0
- package/dist/core/machine.d.ts +5 -2
- package/dist/core/machine.js +105 -31
- package/dist/core/meter.d.ts +22 -0
- package/dist/core/meter.js +34 -0
- package/dist/core/nonterm.js +4 -3
- package/dist/core/proof-output.d.ts +53 -0
- package/dist/core/proof-output.js +38 -0
- 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 +21 -1
- package/dist/core/quorum-laws.js +80 -17
- 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/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 +2 -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/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/system.js +4 -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 +6 -1
- package/dist/core/wall.js +23 -9
- package/dist/core/watch.d.ts +1 -1
- package/dist/core/watch.js +13 -4
- 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.js +93 -40
- package/dist/kernel/epr.js +23 -8
- package/dist/kernel/function-instances.d.ts +45 -0
- package/dist/kernel/function-instances.js +460 -0
- package/dist/kernel/kernel.d.ts +47 -1
- package/dist/kernel/kernel.js +417 -68
- package/dist/kernel/prove.d.ts +61 -6
- package/dist/kernel/prove.js +625 -205
- package/dist/kernel/prover-rows.d.ts +1 -0
- package/dist/kernel/prover-rows.js +12 -1
- 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/axiom-audit.d.ts +11 -0
- package/dist/lean-kernel/axiom-audit.js +50 -0
- package/dist/lean-kernel/emit.d.ts +34 -3
- package/dist/lean-kernel/emit.js +215 -28
- 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/legacy-family-order.d.ts +1 -0
- package/dist/lean-kernel/legacy-family-order.js +26 -0
- package/dist/lean-kernel/library.js +25 -3
- package/dist/lean-kernel/lift/counted-source-data.d.ts +7 -0
- package/dist/lean-kernel/lift/counted-source-data.js +78 -0
- package/dist/lean-kernel/lift/index.d.ts +82 -0
- package/dist/lean-kernel/lift/index.js +116 -0
- package/dist/lean-kernel/lift/project.d.ts +4 -0
- package/dist/lean-kernel/lift/project.js +15 -0
- package/dist/lean-kernel/lift/proof-capture.d.ts +104 -0
- package/dist/lean-kernel/lift/proof-capture.js +216 -0
- package/dist/lean-kernel/lift/proof-codec.d.ts +28 -0
- package/dist/lean-kernel/lift/proof-codec.js +299 -0
- package/dist/lean-kernel/lift/proof-counted-source.d.ts +16 -0
- package/dist/lean-kernel/lift/proof-counted-source.js +68 -0
- package/dist/lean-kernel/lift/proof-frontier.d.ts +19 -0
- package/dist/lean-kernel/lift/proof-frontier.js +153 -0
- package/dist/lean-kernel/lift/proof-graph.d.ts +17 -0
- package/dist/lean-kernel/lift/proof-graph.js +130 -0
- package/dist/lean-kernel/lift/proof-parts.d.ts +29 -0
- package/dist/lean-kernel/lift/proof-parts.js +131 -0
- package/dist/lean-kernel/lift/proof-prelude.d.ts +2 -0
- package/dist/lean-kernel/lift/proof-prelude.js +38 -0
- package/dist/lean-kernel/lift/proof-witness.d.ts +30 -0
- package/dist/lean-kernel/lift/proof-witness.js +283 -0
- package/dist/lean-kernel/lift/shape.d.ts +5 -0
- package/dist/lean-kernel/lift/shape.js +57 -0
- package/dist/lean-kernel/lift/source-projection.d.ts +16 -0
- package/dist/lean-kernel/lift/source-projection.js +81 -0
- package/dist/lean-kernel/lift/source.d.ts +23 -0
- package/dist/lean-kernel/lift/source.js +111 -0
- package/dist/lean-kernel/lift/witness-alpha.d.ts +9 -0
- package/dist/lean-kernel/lift/witness-alpha.js +31 -0
- package/dist/lean-kernel/lift-legacy.d.ts +58 -0
- package/dist/lean-kernel/lift-legacy.js +84 -0
- package/dist/lean-kernel/lift-names.d.ts +22 -0
- package/dist/lean-kernel/lift-names.js +36 -0
- package/dist/lean-kernel/lift-simulation/index.d.ts +29 -0
- package/dist/lean-kernel/lift-simulation/index.js +352 -0
- package/dist/lean-kernel/lift-simulation/shape.d.ts +41 -0
- package/dist/lean-kernel/lift-simulation/shape.js +173 -0
- package/dist/lean-kernel/lift-special/index.d.ts +36 -0
- package/dist/lean-kernel/lift-special/index.js +241 -0
- package/dist/lean-kernel/lift-special/structural.d.ts +25 -0
- package/dist/lean-kernel/lift-special/structural.js +126 -0
- package/dist/lean-kernel/lift-typed/index.d.ts +35 -0
- package/dist/lean-kernel/lift-typed/index.js +256 -0
- package/dist/lean-kernel/lift-typed/roles.d.ts +17 -0
- package/dist/lean-kernel/lift-typed/roles.js +170 -0
- package/dist/lean-kernel/lift-typed/shape.d.ts +1 -0
- package/dist/lean-kernel/lift-typed/shape.js +12 -0
- package/dist/lean-kernel/lift.d.ts +30 -0
- package/dist/lean-kernel/lift.js +97 -0
- package/package.json +5 -1
package/dist/core/dsl.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { retainFrom, retainCounted, publishProof, withPublicRule } from "./proof-output.js";
|
|
2
|
+
import { searchNow as countedSearchNow } from "./wall.js";
|
|
1
3
|
// Typed builders for machines, decisions and loops: names are declared once and come back as typed values, so a
|
|
2
4
|
// misspelled name, a law that reads a request, or a step that sets an undeclared variable is a TypeScript error, and
|
|
3
5
|
// the input kinds the kernel would otherwise see as hand encodings (a flag, an optional fact, a choice among values)
|
|
@@ -16,14 +18,22 @@
|
|
|
16
18
|
// A step returns its updates as one object: every right-hand side reads the state before the step, as the kernel and
|
|
17
19
|
// both runtimes do.
|
|
18
20
|
import { candidates, cone, searchCounted } from "./counts.js";
|
|
21
|
+
import { proveCandidateSeeds } from "./candidate-seeds.js";
|
|
22
|
+
import { proveCountedCandidateSeeds } from "./counted-candidate-seeds.js";
|
|
19
23
|
import { inheritSource, translationVerdict } from "./source-check.js";
|
|
20
24
|
import { env as knobs } from "./solver.js";
|
|
21
|
-
import { argsKey, bindDirect, directOf, machineTerms, part, tuple, carriedView, compileFunction, divName, divisor, divisorsIn, evalC, evalE, fnCall, interpret, isArithmetic, loadJs, modName, numbersOf, pairedArgs, seeded, sourceFreeFn, withArithmetic } from "./machine.js";
|
|
25
|
+
import { argsKey, bindDirect, directOf, machineTerms, part, tuple, carriedView, compileFunction, divName, divisor, divisorsIn, evalC, evalE, fnCall, hasFinite, interpret, isArithmetic, loadJs, modName, numbersOf, pairedArgs, seeded, sourceFreeFn, withArithmetic } from "./machine.js";
|
|
22
26
|
import { allowed, keysOf, requestEnv, watch, watchWork } from "./watch.js";
|
|
23
27
|
import { ghostOf, proveSome, skolemOf, someHolds, substVars, substVarsE, witnessSupport } from "./exists.js";
|
|
24
28
|
import { check, mapArities, checkRecur, foldObligations, ghostedMachine, loopObligations, someOfGhostsOk, substC, sumMachine } from "../kernel/kernel.js";
|
|
25
|
-
import { certLoop, clock, counted, factsFor, fullRate, grow, pastWall, proveLaw, proveLaws, proveLiveness, proveSetFast, proveStepLaws, usualProof,
|
|
26
|
-
import { WallExpired, checkWall, searchWall } from "./wall.js";
|
|
29
|
+
import { certLoop, clock, counted, factsFor, fullRate, grow, pastWall, proveLaw, proveLaws, proveLiveness, proveSetFast, proveStepLaws, usualProof, withModelRounds, withWall } from "../kernel/prove.js";
|
|
30
|
+
import { WallExpired, checkWall, checkWorkEndpoint, searchWall, withBudget, BudgetExpired } from "./wall.js";
|
|
31
|
+
import { completeWorkProfile } from "./work-profile.js";
|
|
32
|
+
import { workLedger } from "./work-admission.js";
|
|
33
|
+
import { withStageAllowance, withStageDeadline, withStageWall } from "./dsl-deadline.js";
|
|
34
|
+
import { withPublicSearchPolicy } from "./search-policy.js";
|
|
35
|
+
import { workRefusalWhy } from "./work-refusal.js";
|
|
36
|
+
import { workDivide, workFromNumber, workToNumber } from "./work-amount.js";
|
|
27
37
|
import { certCyclic, certOn, crossCyclic, cyclicOn, foldNodes, proveCyclic, quietly, recurNodes, translatedProof, uncovered } from "./cyclic.js";
|
|
28
38
|
import { discover } from "./discover.js";
|
|
29
39
|
import { inferLaws, inferRates } from "./infer.js";
|
|
@@ -1059,6 +1069,41 @@ export class SeqTable {
|
|
|
1059
1069
|
}
|
|
1060
1070
|
// f at every key below n: what bookkeeping a request carries meets, row by row (where each grant went, say).
|
|
1061
1071
|
export const everyBelow = (n, f) => everyKey(k => k.lt(n).implies(f(k)));
|
|
1072
|
+
// Explicit finite-domain opt-in. The guard, not the label, carries its semantics.
|
|
1073
|
+
// A size is over immutable params; the kernel validates that when it scopes the rule.
|
|
1074
|
+
// Unlike everyBelow's legacy breakpoint route, every/some enumerate every element.
|
|
1075
|
+
export function sizedSort(name, size) {
|
|
1076
|
+
if (!name)
|
|
1077
|
+
throw new Error('a sized sort needs a name');
|
|
1078
|
+
const below = termOf(size);
|
|
1079
|
+
const every = (f) => {
|
|
1080
|
+
const key = `k$${++boundCounter}`;
|
|
1081
|
+
const body = f(v(key));
|
|
1082
|
+
if (body.ex?.length || hasAll(body.c))
|
|
1083
|
+
throw new Error('a finite sort body must be unquantified in this slice');
|
|
1084
|
+
const c = { op: 'all', key, finite: name, c: { op: 'or', xs: [{ op: 'not', x: { op: '<', a: v(key).e, b: below } }, body.c] } };
|
|
1085
|
+
const n = valOf(size);
|
|
1086
|
+
if (n !== undefined)
|
|
1087
|
+
naturalConst(n);
|
|
1088
|
+
checkWall('finite sort enumeration');
|
|
1089
|
+
let ok = n === undefined ? undefined : true;
|
|
1090
|
+
if (n !== undefined)
|
|
1091
|
+
for (let k = 0; k < n; k++) {
|
|
1092
|
+
if ((k & 255) === 0)
|
|
1093
|
+
checkWall('finite sort enumeration');
|
|
1094
|
+
const holds = f(keyTerm(k)).ok;
|
|
1095
|
+
if (holds === false) {
|
|
1096
|
+
ok = false;
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
if (holds === undefined)
|
|
1100
|
+
ok = undefined;
|
|
1101
|
+
}
|
|
1102
|
+
return new Cond(c, ok);
|
|
1103
|
+
};
|
|
1104
|
+
return { name, size: new Term(below, valOf(size)), has: (key) => new Term(termOf(key), valOf(key)).lt(size),
|
|
1105
|
+
every, some: (f) => every(k => f(k).not()).not() };
|
|
1106
|
+
}
|
|
1062
1107
|
const when_ = (c, then, otherwise) => new Term({ op: 'if', c: c.c, then: termOf(then), else: termOf(otherwise) }, c.ok === undefined ? undefined : valOf(c.ok ? then : otherwise));
|
|
1063
1108
|
const isPartsWrite = (u) => typeof u === 'object' && u !== null && 'parts' in u;
|
|
1064
1109
|
// The parts of a value written at a cell, by the names of the maps they go to.
|
|
@@ -1437,7 +1482,7 @@ class Hoister {
|
|
|
1437
1482
|
const outer = bound.filter(key => namesIn(q).includes(key));
|
|
1438
1483
|
if (outer.length)
|
|
1439
1484
|
throw new Error(`a condition at every key reads ${outer[0]}, a key bound outside it: two keys at once are named together (everyKey((i, j) => ...))`);
|
|
1440
|
-
const inner = perStep(q.c), keys = q.keys?.length ? { keys: q.keys } : {};
|
|
1485
|
+
const inner = perStep(q.c), keys = { ...(q.keys?.length ? { keys: q.keys } : {}), ...(q.finite === undefined ? {} : { finite: q.finite }) };
|
|
1441
1486
|
if (!inner) {
|
|
1442
1487
|
const f = name ?? `${this.prefix}${++this.n}`;
|
|
1443
1488
|
this.flags[f] = { op: 'all', key: q.key, ...keys, c: q.c };
|
|
@@ -1473,6 +1518,8 @@ export function nameQuantifiers(m) {
|
|
|
1473
1518
|
const hasForall = (c, positive = true) => c.op === 'all' ? positive || hasForall(c.c, positive) : c.op === 'not' ? hasForall(c.x, !positive) : c.op === 'and' || c.op === 'or' ? c.xs.some(y => hasForall(y, positive)) : false;
|
|
1474
1519
|
const hasAll = (c) => JSON.stringify(c).includes('"op":"all"');
|
|
1475
1520
|
function prenex(c, what, key) {
|
|
1521
|
+
if (hasFinite(c) && (what.startsWith('step law') || (c.op !== 'all' && hasForall(c))))
|
|
1522
|
+
throw new Error(`${what}: a finite universal is one whole law in this slice (not nested or a step law)`);
|
|
1476
1523
|
let found = false;
|
|
1477
1524
|
const walk = (d, positive) => {
|
|
1478
1525
|
switch (d.op) {
|
|
@@ -1598,15 +1645,15 @@ export const recur = (name, def, lemmas = {}, between = {}) => {
|
|
|
1598
1645
|
.step((env) => ({ x: env.x.plus(1), fx: def.next(env.x, env.fx, envAt(args.map(a => env[a]))) }));
|
|
1599
1646
|
const laws = Object.entries(lemmas).map(([n, f]) => r.law(n, (env) => f(env.x, env.fx, envAt(args.map(a => env[a])))));
|
|
1600
1647
|
// (Its machine's proof timed alone: the recurrence is compared below as its own instance.)
|
|
1601
|
-
const t0 =
|
|
1648
|
+
const t0 = countedSearchNow();
|
|
1602
1649
|
usualProof.last = undefined;
|
|
1603
1650
|
verdict = quietly(() => proveRule(r, laws, { search: false }));
|
|
1604
1651
|
lemmaProof = usualProof.last;
|
|
1605
1652
|
if (cyclicOn())
|
|
1606
|
-
crossCyclic('recurrence', name, verdict.proven && verdict.checked, () => { const { facts, specs } = recurNodes(recurCase([])); return proveCyclic(facts, specs); },
|
|
1653
|
+
crossCyclic('recurrence', name, verdict.proven && verdict.checked, () => { const { facts, specs } = recurNodes(recurCase([])); return proveCyclic(facts, specs); }, countedSearchNow() - t0, translatedRecur({ lemmas: lemmaProof }));
|
|
1607
1654
|
// (the usual trees checked already, inside quietly: where no cyclic proof is made they are the certificate)
|
|
1608
1655
|
if (certOn() && verdict.proven && verdict.checked) {
|
|
1609
|
-
const c = certCyclic('recurrence', name, translatedRecur({ lemmas: lemmaProof }), () => { const { facts, specs } = recurNodes(recurCase([])); return proveCyclic(facts, specs); },
|
|
1656
|
+
const c = certCyclic('recurrence', name, translatedRecur({ lemmas: lemmaProof }), () => { const { facts, specs } = recurNodes(recurCase([])); return proveCyclic(facts, specs); }, countedSearchNow() - t0);
|
|
1610
1657
|
if (!c.checked)
|
|
1611
1658
|
uncovered('recurrence', name, c.why);
|
|
1612
1659
|
}
|
|
@@ -1648,7 +1695,7 @@ export const recur = (name, def, lemmas = {}, between = {}) => {
|
|
|
1648
1695
|
const laws = [...Object.entries(lemmas).map(([n, l]) => r.law(`${n} at y`, (env) => l(env.y, env.fy, envAt(at(env))))),
|
|
1649
1696
|
...Object.entries(between).map(([n, l]) => r.law(n, (env) => l(env.x, env.fx, env.y, env.fy, envAt(at(env)))))];
|
|
1650
1697
|
usualProof.last = undefined;
|
|
1651
|
-
const t0 =
|
|
1698
|
+
const t0 = countedSearchNow(), v = quietly(() => proveRule(r, laws, { search: false })), usualMs = countedSearchNow() - t0, betweenProof = usualProof.last;
|
|
1652
1699
|
if (cyclicOn())
|
|
1653
1700
|
crossCyclic('recurrence, between', name, v.proven && v.checked, () => { const { facts, specs } = recurNodes(recurCase(pairs)); return proveCyclic(facts, specs); }, usualMs, betweenProof && translatedRecur({ lemmas: lemmaProof, between: betweenProof }));
|
|
1654
1701
|
if (certOn() && v.proven && v.checked) {
|
|
@@ -2018,9 +2065,11 @@ export class Rule {
|
|
|
2018
2065
|
const key = `key$${++keyCounter}`;
|
|
2019
2066
|
if (out instanceof Cond) {
|
|
2020
2067
|
const p = prenex(out.c, `law ${name}`, key);
|
|
2021
|
-
return this.divides(this.someOf(name, out, p ? { name, forall: key, holds: p } : { name, holds: out.c }));
|
|
2068
|
+
return this.divides(this.someOf(name, out, p ? { name, forall: key, holds: p, ...(out.c.op === 'all' && out.c.finite !== undefined ? { finite: out.c.finite } : {}) } : { name, holds: out.c }));
|
|
2022
2069
|
}
|
|
2023
2070
|
const [k1, more] = keysFor(out), inner = out.forall(v(k1), ...more.map(v)), holds = inner.c;
|
|
2071
|
+
if (hasFinite(holds))
|
|
2072
|
+
throw new Error(`law ${name}: a finite universal is one whole law, not inside forall`);
|
|
2024
2073
|
return this.divides(this.someOf(name, inner, more.length ? { name, forall: k1, keys: more, holds } : { name, forall: k1, holds: prenex(holds, `law ${name}`, k1) ?? holds }));
|
|
2025
2074
|
}
|
|
2026
2075
|
// A law's existentials (exists), pulled out before it: `some` its naturals, `witness` the ones given (a ghost's step
|
|
@@ -3124,12 +3173,19 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
3124
3173
|
const facts = (m.facts ?? []).filter(f => !isArithmetic(f.name.slice(0, f.name.indexOf(':'))));
|
|
3125
3174
|
const holds = (f, params) => {
|
|
3126
3175
|
const names = f.forall ? [f.forall, ...(f.keys ?? [])] : [], top = names.length > 1 ? bound : 2 * bound;
|
|
3127
|
-
const at = (env, i) =>
|
|
3128
|
-
|
|
3176
|
+
const at = (env, i) => {
|
|
3177
|
+
checkWorkEndpoint('refutation fact bindings');
|
|
3178
|
+
return i === names.length ? evalC(f.holds, env, { scalars: {}, maps: {} }, m)
|
|
3179
|
+
: Array.from({ length: top + 1 }, (_, key) => key).every(key => at({ ...env, [names[i]]: key }, i + 1));
|
|
3180
|
+
};
|
|
3129
3181
|
try {
|
|
3130
3182
|
return at(params, 0);
|
|
3131
3183
|
}
|
|
3132
|
-
catch {
|
|
3184
|
+
catch (e) {
|
|
3185
|
+
if (e instanceof WallExpired)
|
|
3186
|
+
throw e;
|
|
3187
|
+
if (e instanceof BudgetExpired)
|
|
3188
|
+
checkWorkEndpoint(e.phase);
|
|
3133
3189
|
return false;
|
|
3134
3190
|
}
|
|
3135
3191
|
};
|
|
@@ -3140,7 +3196,7 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
3140
3196
|
&& facts.filter(readsParams).every(f => holds(f, params));
|
|
3141
3197
|
const cap = watchWork.n + perTrial * budget.trials;
|
|
3142
3198
|
try {
|
|
3143
|
-
const late = () => pastWall() || budget.until !== undefined &&
|
|
3199
|
+
const late = () => { checkWorkEndpoint('refutation poll'); return pastWall() || budget.until !== undefined && countedSearchNow() > budget.until; };
|
|
3144
3200
|
for (let trial = 0; trial < budget.trials && watchWork.n <= cap && !late(); trial++) {
|
|
3145
3201
|
// (`mixed`: the trials in turn at bounds 1 to 4, every fourth near)
|
|
3146
3202
|
const bound = budget.mixed ? 1 + trial % 4 : budget.bound, guided = guides, near = budget.mixed && trial % 4 ? undefined : budget.near;
|
|
@@ -3217,18 +3273,63 @@ function refuteByRuns(r, laws, stepLaws = [], budget = refuteBudget) {
|
|
|
3217
3273
|
catch (e) {
|
|
3218
3274
|
if (e instanceof WallExpired)
|
|
3219
3275
|
throw e;
|
|
3276
|
+
if (e instanceof BudgetExpired)
|
|
3277
|
+
checkWorkEndpoint(e.phase);
|
|
3220
3278
|
return undefined;
|
|
3221
3279
|
}
|
|
3222
3280
|
return undefined;
|
|
3223
3281
|
}
|
|
3224
3282
|
// The kernel's report as a verdict: its first goal left unproven, with its counterexample and why.
|
|
3225
|
-
export const verdictOf = (out) => ({ proven: out.proven, checked: out.checked, ...(out.failed ? { goal: out.failed.goal, stuck: out.failed.stuck, ...(out.failed.witness ? { witness: out.failed.witness } : {}), ...(out.failed.why ? { why: out.failed.why } : {}) } : {}) });
|
|
3283
|
+
export const verdictOf = (out) => retainFrom(({ proven: out.proven, checked: out.checked, ...(out.failed ? { goal: out.failed.goal, stuck: out.failed.stuck, ...(out.failed.witness ? { witness: out.failed.witness } : {}), ...(out.failed.why ? { why: out.failed.why } : {}) } : {}) }), [out]);
|
|
3226
3284
|
const refutedVerdict = (out) => ({ proven: false, checked: false, goal: out.goal, stuck: 'sat', witness: out.witness, ...(out.run ? { run: out.run } : {}) });
|
|
3227
3285
|
// The divisors some laws read (modBy, divBy), noted on the rule so its machine declares them: a law may come from
|
|
3228
3286
|
// another instance of the same rule (a factory called twice).
|
|
3229
3287
|
const noting = (r, ...xs) => { const ks = divisorsIn(xs); if (ks.size)
|
|
3230
3288
|
r.dividesBy(...ks); return r; };
|
|
3289
|
+
function workPlan(opts) {
|
|
3290
|
+
const explicit = typeof opts.search === 'object' ? opts.search.work : undefined;
|
|
3291
|
+
const ms = typeof opts.search === 'object' ? opts.search.ms : undefined;
|
|
3292
|
+
if (explicit !== undefined && ms !== undefined)
|
|
3293
|
+
throw new RangeError('choose a work budget or a legacy ms budget, not both');
|
|
3294
|
+
const work = explicit ?? (completeWorkProfile.enabled ? ms === undefined ? completeWorkProfile.defaultUnits : ms * fullRate : undefined);
|
|
3295
|
+
if (work === undefined || opts.search === false)
|
|
3296
|
+
return { work, opts };
|
|
3297
|
+
const search = typeof opts.search === 'object' ? { ...opts.search } : {};
|
|
3298
|
+
delete search.work;
|
|
3299
|
+
// Compatibility scheduling hint only; withBudget below receives the exact
|
|
3300
|
+
// original amount. This display must never become the root's authority.
|
|
3301
|
+
search.ms = typeof work === 'number' ? work / fullRate : workToNumber(workDivide(work, workFromNumber(fullRate)));
|
|
3302
|
+
return { work, opts: { ...opts, search } };
|
|
3303
|
+
}
|
|
3304
|
+
function workVerdict(opts, supported, run) {
|
|
3305
|
+
const plan = workPlan(opts);
|
|
3306
|
+
// An implicit child inherits the owner's hard allowance, not a fresh default.
|
|
3307
|
+
// Keep workPlan's validation and scheduling hint; let the owner's refusal
|
|
3308
|
+
// propagate to its handler rather than becoming this child's unknown verdict.
|
|
3309
|
+
const implicit = typeof opts.search !== 'object' || (opts.search.work === undefined && opts.search.ms === undefined);
|
|
3310
|
+
if (completeWorkProfile.enabled && workLedger.inBudget() && implicit)
|
|
3311
|
+
return run(plan.opts);
|
|
3312
|
+
if (plan.work === undefined)
|
|
3313
|
+
return run(plan.opts);
|
|
3314
|
+
if (!completeWorkProfile.enabled && !supported)
|
|
3315
|
+
return { proven: false, checked: false, stuck: 'unknown', why: 'work mode: plain-path migration pending' };
|
|
3316
|
+
try {
|
|
3317
|
+
return withBudget(plan.work, () => run(plan.opts));
|
|
3318
|
+
}
|
|
3319
|
+
catch (error) {
|
|
3320
|
+
if (!(error instanceof BudgetExpired))
|
|
3321
|
+
throw error;
|
|
3322
|
+
return { proven: false, checked: false, stuck: 'unknown', why: workRefusalWhy(error) };
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3231
3325
|
export function proveRule(r, laws, opts = {}) {
|
|
3326
|
+
return withModelRounds(opts.modelRounds, () => withPublicRule(outermost => {
|
|
3327
|
+
const captureMachine = r.machine, hasCounts = !!Object.keys(captureMachine.counts ?? {}).length;
|
|
3328
|
+
const result = workVerdict(opts, hasCounts, plan => withPublicSearchPolicy(hasCounts, () => proveRuleWall(r, laws, plan)));
|
|
3329
|
+
return outermost ? publishProof(result, captureMachine, laws) : result;
|
|
3330
|
+
}));
|
|
3331
|
+
}
|
|
3332
|
+
function proveRuleWall(r, laws, opts) {
|
|
3232
3333
|
const ms = typeof opts.search === 'object' ? opts.search.ms : undefined;
|
|
3233
3334
|
const run = () => {
|
|
3234
3335
|
try {
|
|
@@ -3245,12 +3346,38 @@ export function proveRule(r, laws, opts = {}) {
|
|
|
3245
3346
|
};
|
|
3246
3347
|
// One absolute wall for setup, sampling, generation and proof, not a fresh
|
|
3247
3348
|
// allowance for each phase. Nested callers can only shorten it.
|
|
3248
|
-
|
|
3349
|
+
const result = ms === undefined ? run() : withWall(searchWall(ms), run);
|
|
3350
|
+
return retainFrom(translationVerdict(r, laws, result), [result]);
|
|
3249
3351
|
}
|
|
3250
3352
|
function proveRuleIn(r, laws, opts) {
|
|
3251
|
-
r = r.withSumsOf(laws);
|
|
3353
|
+
r = r.withSumsOf(laws, opts.candidateSeeds?.laws ?? []);
|
|
3252
3354
|
noting(r, laws);
|
|
3355
|
+
if (opts.candidateSeeds) {
|
|
3356
|
+
if (opts.search === false || opts.from === 'any')
|
|
3357
|
+
throw Error('candidate seeds require reachable-state search');
|
|
3358
|
+
const machine = r.machine, extraCounts = opts.candidateSeeds.counts ?? {};
|
|
3359
|
+
if (opts.candidateSeeds.kind === 'counted' || Object.keys(machine.counts ?? {}).length || Object.keys(extraCounts).length) {
|
|
3360
|
+
const reserved = new Set([...Object.keys(machine.maps ?? {}), ...Object.keys(machine.counts ?? {}), ...Object.keys(machine.state), ...Object.keys(machine.fns ?? {}), ...(machine.inputMaps ?? []), ...machine.params, ...machine.inputs]);
|
|
3361
|
+
if (Object.keys(extraCounts).some(n => reserved.has(n)))
|
|
3362
|
+
throw Error('candidate count declaration must not override the source');
|
|
3363
|
+
const producer = { ...machine, counts: { ...machine.counts, ...extraCounts } };
|
|
3364
|
+
const seeded = proveCountedCandidateSeeds(producer, withKinds(r, laws), opts.candidateSeeds.laws, typeof opts.search === 'object' ? opts.search.ms ?? 60_000 : 60_000);
|
|
3365
|
+
opts.candidateSeeds.report?.({ status: seeded.status, kind: 'counted', kept: seeded.status === 'checked' ? seeded.kept.map(l => l.name) : [],
|
|
3366
|
+
dropped: seeded.status === 'checked' ? seeded.dropped.map(l => ({ name: l.name, reason: 'not retained by counted admission' })) : [],
|
|
3367
|
+
...(seeded.status === 'inconclusive' ? { reason: seeded.reason } : {}) });
|
|
3368
|
+
if (seeded.status === 'checked')
|
|
3369
|
+
return retainCounted({ proven: true, checked: true, found: { laws: seeded.closure.laws.map(l => ({ text: l.name })) } }, seeded.closure);
|
|
3370
|
+
}
|
|
3371
|
+
else {
|
|
3372
|
+
const seeded = proveCandidateSeeds(machine, withKinds(r, laws), opts.candidateSeeds.laws, opts.candidateSeeds.witnesses, opts.candidateSeeds.ghosts);
|
|
3373
|
+
opts.candidateSeeds.report?.({ status: seeded.status, kept: seeded.kept.map(l => l.name), dropped: seeded.dropped,
|
|
3374
|
+
...(seeded.status === 'inconclusive' ? { reason: seeded.reason } : {}) });
|
|
3375
|
+
if (seeded.status === 'checked')
|
|
3376
|
+
return retainFrom(verdictOf(seeded.closure), [seeded.closure], { kind: 'inference', original: machine, laws });
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3253
3379
|
const refuted = refuteByRuns(r, laws);
|
|
3380
|
+
checkWorkEndpoint('refutation result');
|
|
3254
3381
|
// A state the laws allow whose step breaks one, with no run to it (a wide rule's: what the kernel's step goal would end
|
|
3255
3382
|
// at), is a counterexample to induction: the laws may still hold, so the search goes on from it, as from the kernel's.
|
|
3256
3383
|
// (A step law broken so is refused, proveSteps below: it holds from every state the laws allow, reached or not.)
|
|
@@ -3259,7 +3386,7 @@ function proveRuleIn(r, laws, opts) {
|
|
|
3259
3386
|
// A rule with counts: its goals are the counted ones (core/counts.ts searches them; the kernel checks the set).
|
|
3260
3387
|
if (r.machine.counts && Object.keys(r.machine.counts).length) {
|
|
3261
3388
|
const c = searchCounted(r.machine, withKinds(r, laws), typeof opts.search === 'object' ? opts.search.ms ?? 60_000 : 60_000);
|
|
3262
|
-
return { proven: c.proven, checked: c.proven, ...(c.why ? { why: c.why } : {}), found: { laws: c.laws.map(l => ({ text: l.name })) } };
|
|
3389
|
+
return retainCounted({ proven: c.proven, checked: c.proven, ...(c.why ? { why: c.why } : {}), found: { laws: c.laws.map(l => ({ text: l.name })) } }, c);
|
|
3263
3390
|
}
|
|
3264
3391
|
// (with a search budget, the laws as given within it on the wall: a step goal of hundreds of hypotheses has a second
|
|
3265
3392
|
// each by its own budget, so the search would never start)
|
|
@@ -3271,11 +3398,17 @@ function proveRuleIn(r, laws, opts) {
|
|
|
3271
3398
|
// Quantified witness preflight needs a counted allocation: a slow attempt must
|
|
3272
3399
|
// not seed different memoized decisions. Other laws keep their existing budget;
|
|
3273
3400
|
// inference's query rate is not calibrated for their whole-set preflight.
|
|
3274
|
-
const out = ms === undefined ? given() :
|
|
3275
|
-
const v = { ...verdictOf(out), ...(out.witnesses && out.proven ? { witnesses: out.witnesses } : {}) }
|
|
3401
|
+
const out = ms === undefined ? given() : withStageWall(countedSearchNow() + ms / share, () => share === 1 ? given() : counted(inferRates.work, () => withStageDeadline(clock() + ms / share, given, () => undefined)), () => undefined);
|
|
3402
|
+
const v = out ? { ...verdictOf(out), ...(out.witnesses && out.proven ? { witnesses: out.witnesses } : {}) }
|
|
3403
|
+
: { proven: false, checked: false, stuck: 'unknown' };
|
|
3404
|
+
if (out)
|
|
3405
|
+
retainFrom(v, [out]);
|
|
3276
3406
|
return searched(r, laws, [], v, opts);
|
|
3277
3407
|
}
|
|
3278
3408
|
export function proveSteps(r, laws, stepLaws, opts = {}) {
|
|
3409
|
+
return workVerdict(opts, false, plan => proveStepsWall(r, laws, stepLaws, plan));
|
|
3410
|
+
}
|
|
3411
|
+
function proveStepsWall(r, laws, stepLaws, opts) {
|
|
3279
3412
|
const ms = typeof opts.search === 'object' ? opts.search.ms : undefined;
|
|
3280
3413
|
// From any state, the caller's budget includes preflight runs and all initial
|
|
3281
3414
|
// goals, not a fresh budget per goal. Keep reachable-state search unchanged.
|
|
@@ -3290,13 +3423,14 @@ export function proveSteps(r, laws, stepLaws, opts = {}) {
|
|
|
3290
3423
|
}
|
|
3291
3424
|
};
|
|
3292
3425
|
const verdict = opts.from !== 'any' || ms === undefined ? run()
|
|
3293
|
-
: withWall(
|
|
3426
|
+
: withWall(countedSearchNow() + ms, run);
|
|
3294
3427
|
return translationVerdict(r, [...laws, ...stepLaws], verdict);
|
|
3295
3428
|
}
|
|
3296
3429
|
function proveStepsIn(r, laws, stepLaws, opts) {
|
|
3297
3430
|
r = r.withSumsOf(laws, stepLaws);
|
|
3298
3431
|
noting(r, laws, stepLaws);
|
|
3299
3432
|
const refuted = refuteByRuns(r, laws, stepLaws);
|
|
3433
|
+
checkWorkEndpoint('refutation result');
|
|
3300
3434
|
// (a step law broken from a state the laws allow, with no run to it: the laws may need an invariant there, or the run
|
|
3301
3435
|
// be further than these runs go; the search goes on from it, as from the kernel's)
|
|
3302
3436
|
if (refuted)
|
|
@@ -3340,7 +3474,7 @@ function searched(r, laws, stepLaws, v, opts) {
|
|
|
3340
3474
|
// The deeper runs; then runs over small values (keys that meet, small params), whose requests meet their
|
|
3341
3475
|
// assumption's equalities and clocks, or near the counterexample the verdict ends at.
|
|
3342
3476
|
// (the three within the search's budget again, on the wall: past it they stop, and the search starts as it would)
|
|
3343
|
-
const ms = typeof opts.search === 'object' && opts.search.ms !== undefined ? opts.search.ms : 10_000, runsUntil =
|
|
3477
|
+
const ms = typeof opts.search === 'object' && opts.search.ms !== undefined ? opts.search.ms : 10_000, runsUntil = countedSearchNow() + ms;
|
|
3344
3478
|
for (const b of [deeperBudget, { ...deeperBudget, bound: 1, seed: 31, states: false }, { ...deeperBudget, trials: 1200, seed: 41, states: false, mixed: true, ...(v.witness ? { near: v.witness } : {}) }]) {
|
|
3345
3479
|
const deeper = refuteByRuns(r, laws, stepLaws, { ...b, until: runsUntil });
|
|
3346
3480
|
if (deeper?.run)
|
|
@@ -3357,7 +3491,7 @@ function searched(r, laws, stepLaws, v, opts) {
|
|
|
3357
3491
|
}
|
|
3358
3492
|
const until = clock() + (typeof opts.search === 'object' && opts.search.ms !== undefined ? opts.search.ms : 10_000);
|
|
3359
3493
|
// (the search's end on the wall too: kernel/prove.ts's withWall, past which every goal is unknown)
|
|
3360
|
-
return
|
|
3494
|
+
return withStageWall(countedSearchNow() + Math.max(0, until - clock()), () => searchedUntil(r, laws, stepLaws, v, opts, until), () => v);
|
|
3361
3495
|
}
|
|
3362
3496
|
// Two machines alike up to the names of the keys their quantified flags and writes at every key bind (the rule builds
|
|
3363
3497
|
// fresh ones each time it is read): each bound name by its place of first binding.
|
|
@@ -3381,7 +3515,7 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3381
3515
|
const ghosted = stepGhosts(r.machine, stepLaws);
|
|
3382
3516
|
// (with the step laws' ghosts, a wall stop too, at the budget: their goals cost the cost model more than its clock
|
|
3383
3517
|
// counts, a wide rule's past twice its wall time; and the last runs always, the search's tail on the wall too)
|
|
3384
|
-
const bounded = (ms, from, wall = !!ghosted) => counted(fullRate, () => findBoundedRun(ghosted?.machine ?? r.machine, [...laws, ...(ghosted?.laws ?? [])], { ms, from, steps: true, ...(wall ? { wall:
|
|
3518
|
+
const bounded = (ms, from, wall = !!ghosted) => counted(fullRate, () => withStageAllowance(ms, () => findBoundedRun(ghosted?.machine ?? r.machine, [...laws, ...(ghosted?.laws ?? [])], { ms, from, steps: true, ...(wall ? { wall: countedSearchNow() + ms } : {}), progress: k => { reached = k; } }), () => undefined), true);
|
|
3385
3519
|
const refutedBy = (b) => refutedVerdict({ goal: `${b.law} @step (a run of ${b.depth} steps from the start)`, witness: b.witness, run: { params: b.params, trace: b.trace.map(shownRequest) } });
|
|
3386
3520
|
const shallow = bounded(Math.min(250, total / 40), 1);
|
|
3387
3521
|
if (shallow)
|
|
@@ -3390,24 +3524,24 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3390
3524
|
// within a twentieth of the budget (at most 500 ms, counted so too).
|
|
3391
3525
|
if (!any && !stepLaws.length && laws.every(l => !l.forall && !l.keys?.length && !l.some?.length)) {
|
|
3392
3526
|
const ms = Math.min(500, total / 20), kinds = withKinds(r, []).filter(k => !laws.some(l => l.name === k.name));
|
|
3393
|
-
const kd = counted(fullRate, () => proveKInduction(r.machine, kinds, conjunction(laws), { ms }), true);
|
|
3394
|
-
if (kd
|
|
3527
|
+
const kd = counted(fullRate, () => withStageAllowance(ms, () => proveKInduction(r.machine, kinds, conjunction(laws), { ms }), () => undefined), true);
|
|
3528
|
+
if (kd?.proven && kd.checked)
|
|
3395
3529
|
return { proven: true, checked: true, k: kd.k, assumes: { states: 'reachable', laws: [] } };
|
|
3396
3530
|
}
|
|
3397
3531
|
let rule = r, lemmas;
|
|
3398
3532
|
const { fns, lists } = r.parts;
|
|
3399
3533
|
if (lists.length || fns.some(([, d]) => recurOf(d))) {
|
|
3400
|
-
const d =
|
|
3401
|
-
if (d
|
|
3402
|
-
return { ...d.verdict, found: { lemmas: d.found } };
|
|
3403
|
-
if (Object.keys(d.found).length)
|
|
3534
|
+
const d = withStageDeadline(until, () => discover(r, laws, stepLaws, v), () => undefined);
|
|
3535
|
+
if (d?.verdict.proven && d.verdict.checked)
|
|
3536
|
+
return retainFrom({ ...d.verdict, found: { lemmas: d.found } }, [d.verdict]);
|
|
3537
|
+
if (d && Object.keys(d.found).length)
|
|
3404
3538
|
(rule = d.rule, lemmas = d.found);
|
|
3405
3539
|
}
|
|
3406
3540
|
// Functions known by their facts alone (not a recurrence): lemmas about them, fitted to their values and proven from
|
|
3407
3541
|
// the facts as cyclic claims, the laws proven with them as facts.
|
|
3408
3542
|
if ((typeof opts.search !== 'object' || opts.search.cycles !== false) && fns.some(([, d]) => !recurOf(d)) && rule.machine.facts?.length && until - clock() > 500) {
|
|
3409
|
-
const c =
|
|
3410
|
-
if (c
|
|
3543
|
+
const c = withStageDeadline(until, () => cycleLemmas(rule.machine, withKinds(rule, laws), stepLaws, { ms: (until - clock()) / 2 }), () => undefined);
|
|
3544
|
+
if (c?.proven && c.checked)
|
|
3411
3545
|
return { proven: true, checked: true, found: { ...(lemmas ? { lemmas } : {}), facts: c.found.map(f => f.text) } };
|
|
3412
3546
|
}
|
|
3413
3547
|
// Laws about the ids a counter hands out (core/fresh.ts), within a tenth of what is left: the laws with them, then
|
|
@@ -3418,12 +3552,12 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3418
3552
|
let fresh = [];
|
|
3419
3553
|
if (Object.keys(rule.machine.maps ?? {}).length && until - clock() - tail > 1000) {
|
|
3420
3554
|
const fm = rule.machine, share = (until - clock() - tail) / 10;
|
|
3421
|
-
fresh =
|
|
3555
|
+
fresh = withStageDeadline(clock() + share, () => freshLaws(fm, rule.kindLaws(), { params: (rand, bound) => rule.randomParams(rand, bound), input: (rand, bound, ps) => rule.randomInput(rand, bound, ps) }, { ms: share }), () => []);
|
|
3422
3556
|
if (fresh.length) {
|
|
3423
3557
|
// (counted, as the laws' own search: the same verdict on any machine)
|
|
3424
|
-
const given = [...withKinds(rule, laws), ...fresh.map(f => f.law)], out = counted(fullRate, () =>
|
|
3425
|
-
if (out
|
|
3426
|
-
return { proven: true, checked: true, found: { laws: fresh, ...(lemmas ? { lemmas } : {}) }, assumes: reachableBy(fresh) };
|
|
3558
|
+
const given = [...withKinds(rule, laws), ...fresh.map(f => f.law)], out = counted(fullRate, () => withStageDeadline(clock() + share, () => (stepLaws.length ? proveStepLaws(fm, given, stepLaws) : proveLaws(fm, given)), () => undefined), true);
|
|
3559
|
+
if (out?.proven && out.checked)
|
|
3560
|
+
return retainFrom({ proven: true, checked: true, found: { laws: fresh, ...(lemmas ? { lemmas } : {}) }, assumes: reachableBy(fresh) }, [out]);
|
|
3427
3561
|
}
|
|
3428
3562
|
}
|
|
3429
3563
|
let ms = until - clock() - tail;
|
|
@@ -3433,19 +3567,21 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3433
3567
|
if (!stepLaws.length && laws.some(l => l.some?.length) && laws.every(l => !l.some?.length || !l.forall)) {
|
|
3434
3568
|
let c;
|
|
3435
3569
|
try {
|
|
3436
|
-
c =
|
|
3570
|
+
c = withStageWall(countedSearchNow() + ms / 2, () => withStageDeadline(clock() + ms / 2, () => someCone(rule, laws, ms / 2), () => undefined), () => undefined);
|
|
3437
3571
|
}
|
|
3438
3572
|
catch (e) {
|
|
3573
|
+
if (e instanceof BudgetExpired)
|
|
3574
|
+
throw e;
|
|
3439
3575
|
if (knobs.GDP_EXISTS_LOG === '1')
|
|
3440
3576
|
console.error(`exists: cone failed: ${String(e.stack ?? e).slice(0, 600)}`);
|
|
3441
3577
|
}
|
|
3442
3578
|
if (c)
|
|
3443
|
-
return { ...c, found: { ...c.found, ...(lemmas ? { lemmas } : {}) } };
|
|
3579
|
+
return retainFrom({ ...c, found: { ...c.found, ...(lemmas ? { lemmas } : {}) } }, [c]);
|
|
3444
3580
|
if ((ms = until - clock() - tail) < 500)
|
|
3445
3581
|
return v;
|
|
3446
3582
|
}
|
|
3447
3583
|
// (the search's own wall ends where the tail begins: the last bounded runs keep it)
|
|
3448
|
-
const tailAt = () =>
|
|
3584
|
+
const tailAt = () => countedSearchNow() + Math.max(0, until - tail - clock());
|
|
3449
3585
|
// (a law about every key with "there exists": the search over its plain form, the value at its ghost map's cell, the
|
|
3450
3586
|
// ghosts' own laws beside it, on the rule with the ghosts (exists.ts's skolemOf), its verdict `back`'s; no join, whose
|
|
3451
3587
|
// convex forms can't state a cell read at a key a ghost holds: the engine alone (the join's first whole-set query on
|
|
@@ -3470,11 +3606,11 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3470
3606
|
console.error(`exists: back: plain ${plain ? `${plain.proven} ${plain.checked}` : 'none'}, machine ${sameMachine(over.machine, ghostedMachine(G))}`);
|
|
3471
3607
|
if (plain?.proven && plain.checked && sameMachine(over.machine, ghostedMachine(G))
|
|
3472
3608
|
&& laws.filter(l => l.some?.length).every(l => { const q = sk.plains[l.name]; return !!q && ls.includes(q.plain) && someOfGhostsOk(G, l, q.plain, q.sub); }))
|
|
3473
|
-
return { proven: true, checked: true, witnesses: sk.witnesses };
|
|
3609
|
+
return retainFrom({ proven: true, checked: true, witnesses: sk.witnesses }, [plain], { kind: 'skolem', original: G.orig, laws, G, plains: sk.plains, family: ls });
|
|
3474
3610
|
// (proveSome over the original: the found laws that read no ghost map)
|
|
3475
3611
|
const own = found.filter(f => Object.keys(sk.maps).every(mp => !JSON.stringify(f.law.holds).includes(`"map":${JSON.stringify(mp)}`)));
|
|
3476
3612
|
const out = proveSome(rule.machine, [...withKinds(rule, laws), ...fresh.map(f => f.law), ...own.map(f => f.law)], { mapMs: Math.max(5_000, (until - clock()) / 2) });
|
|
3477
|
-
return { ...verdictOf(out), ...(out.witnesses && out.proven ? { witnesses: out.witnesses } : {}) };
|
|
3613
|
+
return retainFrom({ ...verdictOf(out), ...(out.witnesses && out.proven ? { witnesses: out.witnesses } : {}) }, [out]);
|
|
3478
3614
|
};
|
|
3479
3615
|
// (the plain law's candidate supports, exists.ts's ghostSupports: Houdini within half of what is left, each with the
|
|
3480
3616
|
// rest assumed, the failing dropped, until none fails; then the set through `back`, the ∃ verdict as the search's)
|
|
@@ -3494,15 +3630,15 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3494
3630
|
return counted(fullRate, () => {
|
|
3495
3631
|
const end = clock() + budget;
|
|
3496
3632
|
if (!native)
|
|
3497
|
-
return !
|
|
3633
|
+
return !withStageDeadline(end, () => proveLaw(tm, ls, ls.indexOf(c)), () => undefined)?.proven;
|
|
3498
3634
|
// Try local provenance before instantiating every witness. All three
|
|
3499
3635
|
// attempts share the same existing support-query allocation.
|
|
3500
|
-
if (round === 0 &&
|
|
3636
|
+
if (round === 0 && withStageDeadline(Math.min(end, clock() + 500), () => proveSetFast(tm, [c]), () => undefined)?.proven)
|
|
3501
3637
|
return false;
|
|
3502
3638
|
const local = witnessSupport(tm, helpers, c, Object.keys(sk.maps));
|
|
3503
|
-
if (
|
|
3639
|
+
if (withStageDeadline(Math.min(end, clock() + 1_000), () => proveLaw(tm, local, local.indexOf(c)), () => undefined)?.proven)
|
|
3504
3640
|
return false;
|
|
3505
|
-
return !
|
|
3641
|
+
return !withStageDeadline(end, () => proveLaw(tm, ls, ls.indexOf(c)), () => undefined)?.proven;
|
|
3506
3642
|
}, true);
|
|
3507
3643
|
});
|
|
3508
3644
|
if (clock() >= hUntil)
|
|
@@ -3513,47 +3649,47 @@ function searchedUntil(r, laws, stepLaws, v, opts, until) {
|
|
|
3513
3649
|
for (const l of native ? sought : []) {
|
|
3514
3650
|
const local = witnessSupport(tm, ls, l);
|
|
3515
3651
|
if (local.length < ls.length)
|
|
3516
|
-
|
|
3652
|
+
withStageDeadline(Math.min(hUntil, clock() + 3_000), () => proveLaw(tm, local, local.indexOf(l)), () => undefined);
|
|
3517
3653
|
}
|
|
3518
3654
|
const b = back(target, keep.map(law => ({ law })), native);
|
|
3519
3655
|
if (knobs.GDP_EXISTS_LOG === '1')
|
|
3520
3656
|
console.error(`exists: ghost supports set: ${b.proven ? 'proven' : `${b.goal} ${b.stuck} ${b.why ?? ''}`}`);
|
|
3521
3657
|
if (b.proven && b.checked) {
|
|
3522
3658
|
const found = keep.map(law => ({ law, text: law.name }));
|
|
3523
|
-
return { ...b, proven: true, checked: true, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) };
|
|
3659
|
+
return retainFrom({ ...b, proven: true, checked: true, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) }, [b]);
|
|
3524
3660
|
}
|
|
3525
3661
|
break;
|
|
3526
3662
|
}
|
|
3527
3663
|
keep = keep.filter(c => !drop.includes(c));
|
|
3528
3664
|
}
|
|
3529
3665
|
}
|
|
3530
|
-
const inf =
|
|
3531
|
-
if (!(inf
|
|
3666
|
+
const inf = withStageWall(tailAt(), () => inferLaws(target, [...fresh.map(f => f.law), ...sought], stepLaws, { ms, ...((rule === r && !fresh.length) || sk ? { first: v } : {}), ...(sk ? { join: 0 } : {}) }), () => undefined);
|
|
3667
|
+
if (!(inf?.proven && inf.checked)) {
|
|
3532
3668
|
// The sum of each map the step writes (withMapSums): the search again over the rule with them, within half of what
|
|
3533
3669
|
// is left (at most 20 s), where a law of cells against a total needs one (no ERC20 balance past the supply).
|
|
3534
3670
|
const summed = target.withMapSums();
|
|
3535
3671
|
if (summed && until - clock() - tail > 1000) {
|
|
3536
|
-
const inf2 =
|
|
3537
|
-
if (inf2
|
|
3672
|
+
const inf2 = withStageWall(tailAt(), () => inferLaws(summed, [...fresh.map(f => f.law), ...sought], stepLaws, { ms: Math.min(20_000, (until - clock() - tail) / 2) }), () => undefined);
|
|
3673
|
+
if (inf2?.proven && inf2.checked) {
|
|
3538
3674
|
const { found, stats: _s2, ...verdict } = inf2;
|
|
3539
3675
|
void _s2;
|
|
3540
3676
|
const b = back(summed, found);
|
|
3541
3677
|
if (!sk || (b.proven && b.checked))
|
|
3542
|
-
return { ...(sk ? {} : verdict), ...b, proven: true, checked: true, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) };
|
|
3678
|
+
return retainFrom({ ...(sk ? {} : verdict), ...b, proven: true, checked: true, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) }, sk ? [inf2, b] : [inf2]);
|
|
3543
3679
|
}
|
|
3544
3680
|
}
|
|
3545
3681
|
// (a step law's ghost: at most 10 s of it, as its goals cost more than the laws')
|
|
3546
3682
|
const deep = bounded(Math.max(0, Math.min(until - clock(), ghosted && !laws.length ? 10_000 : Infinity)), Math.max(1, reached), true);
|
|
3547
3683
|
if (deep)
|
|
3548
3684
|
return refutedBy(deep);
|
|
3549
|
-
return { ...v, why: [v.why, `the search found nothing that proves it in ${Math.round(inf.stats.ms)} ms`].filter(Boolean).join('; ') };
|
|
3685
|
+
return { ...v, why: [v.why, inf ? `the search found nothing that proves it in ${Math.round(inf.stats.ms)} ms` : 'the search reached its stage deadline'].filter(Boolean).join('; ') };
|
|
3550
3686
|
}
|
|
3551
3687
|
const { found, stats: _stats, ...verdict } = inf;
|
|
3552
3688
|
void _stats;
|
|
3553
3689
|
const b = back(target, found);
|
|
3554
3690
|
if (sk && !(b.proven && b.checked))
|
|
3555
3691
|
return { ...v, ...b, why: [v.why, 'the set found over the ghost maps is not proven with the laws as stated'].filter(Boolean).join('; ') };
|
|
3556
|
-
return { ...(sk ? { proven: true, checked: true } : verdict), ...b, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) };
|
|
3692
|
+
return retainFrom({ ...(sk ? { proven: true, checked: true } : verdict), ...b, found: { laws: [...fresh, ...found], ...(lemmas ? { lemmas } : {}) }, ...withAssumes([...fresh, ...found]) }, sk ? [inf, b] : [inf]);
|
|
3557
3693
|
}
|
|
3558
3694
|
// A law with "there exists" about no key, which the join can't take as its goal: its witness core/exists.ts's ghostOf;
|
|
3559
3695
|
// then core/counts.ts's pipeline: the candidates, the engine's template two keys at the bound value's places, framed by
|
|
@@ -3577,10 +3713,12 @@ function someCone(r, laws0, ms) {
|
|
|
3577
3713
|
// (a cube the kernel refuses to state, one past its key rules, is never kept)
|
|
3578
3714
|
const plain = (law, ls, ms2) => {
|
|
3579
3715
|
try {
|
|
3580
|
-
const o =
|
|
3581
|
-
return o.proven ? { proof: true } : { stuck: o.stuck };
|
|
3716
|
+
const o = withStageDeadline(Math.min(until, clock() + ms2), () => proveLaw(m, ls, ls.indexOf(law)), () => undefined);
|
|
3717
|
+
return o ? o.proven ? { proof: true } : { stuck: o.stuck } : { stuck: 'unknown' };
|
|
3582
3718
|
}
|
|
3583
|
-
catch {
|
|
3719
|
+
catch (e) {
|
|
3720
|
+
if (e instanceof BudgetExpired)
|
|
3721
|
+
throw e;
|
|
3584
3722
|
return { stuck: '' };
|
|
3585
3723
|
}
|
|
3586
3724
|
};
|
|
@@ -3590,7 +3728,7 @@ function someCone(r, laws0, ms) {
|
|
|
3590
3728
|
if (clock() > until)
|
|
3591
3729
|
return undefined;
|
|
3592
3730
|
const v = verdictOf(proveSome(m, [...laws, ...kept.filter(c => !laws.some(l => l.name === c.name))]));
|
|
3593
|
-
return v.proven && v.checked ? { ...v, found: { laws: kept.map(l => ({ law: l, text: l.name })) }, ...withAssumes(kept.map(l => ({ text: l.name }))) } : undefined;
|
|
3731
|
+
return v.proven && v.checked ? retainFrom({ ...v, found: { laws: kept.map(l => ({ law: l, text: l.name })) }, ...withAssumes(kept.map(l => ({ text: l.name }))) }, [v]) : undefined;
|
|
3594
3732
|
}
|
|
3595
3733
|
// What a verdict proven with these found laws rests on: the states reachable from init (each found law is proven so).
|
|
3596
3734
|
const reachableBy = (found) => ({ states: 'reachable', laws: found.map(f => f.text) });
|
|
@@ -3609,7 +3747,7 @@ function proveLeadsToIn(r, laws, l, opts) {
|
|
|
3609
3747
|
const until = clock() + (opts.ms ?? 10_000), draws = { params: (rand, bound) => r.randomParams(rand, bound), input: (rand, bound, ps) => r.randomInput(rand, bound, ps) };
|
|
3610
3748
|
// (the laws about the keys a counter hands out or a high-water mark bounds, core/fresh.ts, within a twentieth: given
|
|
3611
3749
|
// to both searches, each proven again with the rank)
|
|
3612
|
-
const share = (until - clock()) / 20, fresh = Object.keys(r.machine.maps ?? {}).length ?
|
|
3750
|
+
const share = (until - clock()) / 20, fresh = Object.keys(r.machine.maps ?? {}).length ? withStageDeadline(clock() + share, () => freshLaws(r.machine, r.kindLaws(), draws, { ms: share }), () => []) : [];
|
|
3613
3751
|
laws = [...laws, ...fresh.map(x => x.law)];
|
|
3614
3752
|
let f = findLeadsTo(r.machine, withKinds(r, laws), l, { ...draws, rule: r }, { ms: until - clock() });
|
|
3615
3753
|
// Where the rank fitted to the runs isn't the one: a rank of the rule's own terms (core/live.ts), in the time left.
|
|
@@ -3650,7 +3788,7 @@ export function refuteLeadsTo(r, laws, l, opts = {}) {
|
|
|
3650
3788
|
// prover reads (the counted one inside a counted search): past it the verdict is unknown.
|
|
3651
3789
|
export const proveDecision = (d, opts = {}) => {
|
|
3652
3790
|
const go = () => (d.steps ? proveSteps(d.steps.rule, [], [d.steps.law], { search: false }) : goalsVerdict([d.goal]));
|
|
3653
|
-
return translationVerdict(d.rule, [d.goal], opts.ms === undefined ? go() :
|
|
3791
|
+
return translationVerdict(d.rule, [d.goal], opts.ms === undefined ? go() : withStageDeadline(clock() + opts.ms, go, () => ({ proven: false, checked: false, stuck: 'unknown' })));
|
|
3654
3792
|
};
|
|
3655
3793
|
// A decision's callbacks against its condition, on random params and requests: `given` and `then` each run with every
|
|
3656
3794
|
// value known, against what the interpreter evaluates of the decision built from them.
|
|
@@ -3685,15 +3823,15 @@ export function crossCheckDecision(d, opts = {}) {
|
|
|
3685
3823
|
// usual trees, which are then its input and not checked again); where none is made, the usual trees, checked.
|
|
3686
3824
|
export const proveLoop = (l, laws, opts = {}) => {
|
|
3687
3825
|
if (l.hasRank) {
|
|
3688
|
-
const t0 =
|
|
3826
|
+
const t0 = countedSearchNow(), goals = loopObligations(l.loop, laws, l.rankTerms), v = goalsVerdict(goals, !certOn());
|
|
3689
3827
|
if (!v.proven)
|
|
3690
3828
|
return v;
|
|
3691
|
-
const c = certLoop(l.loop, laws, l.rankTerms, v.trees,
|
|
3829
|
+
const c = certLoop(l.loop, laws, l.rankTerms, v.trees, countedSearchNow() - t0);
|
|
3692
3830
|
return c && !c.checked && certOn() ? { ...v, checked: goals.every(g => check(g, v.trees[g.name])) } : v;
|
|
3693
3831
|
}
|
|
3694
|
-
const t0 =
|
|
3832
|
+
const t0 = countedSearchNow(), out = findRank(l.loop, laws, opts);
|
|
3695
3833
|
if (out.proven && out.checked && out.rank && out.trees)
|
|
3696
|
-
certLoop(l.loop, [...laws, ...(out.laws ?? [])], out.rank, out.trees,
|
|
3834
|
+
certLoop(l.loop, [...laws, ...(out.laws ?? [])], out.rank, out.trees, countedSearchNow() - t0);
|
|
3697
3835
|
return { proven: out.proven, checked: out.checked, ...(out.trees ? { trees: out.trees } : {}), ...(out.goal ? { goal: out.goal, stuck: out.stuck } : {}), ...(out.witness ? { witness: out.witness } : {}), ...(out.why ? { why: out.why } : {}),
|
|
3698
3836
|
...(out.found ? { found: { rank: out.found.rank, ...(out.laws?.length ? { laws: out.laws.map((law, i) => ({ law, text: out.found.laws[i] ?? law.name })) } : {}) } } : {}) };
|
|
3699
3837
|
};
|
|
@@ -3821,7 +3959,7 @@ export const fold = (name) => new FoldRule({ name, params: [], inputs: [], pre:
|
|
|
3821
3959
|
export const proveFold = (f, laws) => {
|
|
3822
3960
|
// (by default the certificate a cyclic proof, core/cyclic.ts's certCyclic, the usual trees its input; where none is
|
|
3823
3961
|
// made, the usual trees checked)
|
|
3824
|
-
const all = [...(f.lemmas ?? []), ...laws], t0 =
|
|
3962
|
+
const all = [...(f.lemmas ?? []), ...laws], t0 = countedSearchNow(), v = goalsVerdict(foldObligations(f.fold, all), !certOn()), usualMs = countedSearchNow() - t0;
|
|
3825
3963
|
if (cyclicOn())
|
|
3826
3964
|
crossCyclic('fold', f.fold.name, v.proven && v.checked, () => { const { facts, specs } = foldNodes(f.fold, all); return proveCyclic(facts, specs); }, usualMs, v.trees && (st => translatedProof(() => JSON.stringify(['fold', f.fold, all]), () => foldNodes(f.fold, all, v.trees, st), st)));
|
|
3827
3965
|
if (certOn() && v.proven) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withEvaluationAdmission } from './work-observe.js';
|
package/dist/core/exists.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type C, type E, type Law, type Machine, type SomeWitness, type State } from './machine.js';
|
|
1
|
+
import { type C, type E, type Law, type Machine, type Request, type SomeWitness, type State } from './machine.js';
|
|
2
2
|
import { type Report } from '../kernel/prove.js';
|
|
3
3
|
import { type Ghosted } from '../kernel/kernel.js';
|
|
4
4
|
type Env = Record<string, number>;
|
|
@@ -7,6 +7,11 @@ export declare const namesOf: (t: E | C) => string[];
|
|
|
7
7
|
export declare function groupsOf(vars: string[]): Group[];
|
|
8
8
|
export declare function substVarsE(e: E, s: Record<string, E>): E;
|
|
9
9
|
export declare function substVars(c: C, s: Record<string, E>): C;
|
|
10
|
+
export declare function retainedSamplePath(state: State, visit: () => void): Request[] | undefined;
|
|
11
|
+
export declare function retainedSamples(m: Machine): readonly {
|
|
12
|
+
p: Env;
|
|
13
|
+
sts: readonly State[];
|
|
14
|
+
}[];
|
|
10
15
|
export declare function small(m: Machine, p: Env, b: number, cap?: number, work?: number, walks?: number): State[];
|
|
11
16
|
export declare function ghostOf(m: Machine, law: Law): SomeWitness | undefined;
|
|
12
17
|
export declare function smallOf(m: Machine, source?: Machine): {
|