tla-ts 0.0.4-dev.4c0ab96 → 0.0.4-dev.55f2117
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 +37 -126
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -4
- package/dist/parallel-worker.js +1 -4
- package/dist/prove-worker.cjs +9 -0
- package/dist/prove-worker.d.cts +9 -0
- package/dist/prove-worker.d.ts +9 -0
- package/dist/prove-worker.js +9 -0
- package/dist/prove.cjs +996 -0
- package/dist/prove.js +996 -0
- package/dist/run.cjs +45 -0
- package/dist/run.js +45 -0
- package/dist/tlapm.cjs +10 -0
- package/dist/tlapm.js +10 -0
- package/dist/transfer.cjs +38 -44
- package/dist/transfer.js +38 -44
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +21 -12
- package/src/ast.ts +2 -2
- package/src/check.ts +7 -7
- package/src/{cli-options.ts → cli/options.ts} +1 -1
- package/src/{run-cli.ts → cli/run.ts} +293 -91
- package/src/cli.ts +1 -1
- package/src/config.ts +2 -2
- package/src/environment.ts +9 -9
- package/src/errors.ts +89 -30
- package/src/evaluate.ts +32 -11
- package/src/index.ts +10 -0
- package/src/levels.ts +1 -1
- package/src/live-check.ts +1 -1
- package/src/liveness.ts +1 -1
- package/src/{obligation-action.ts → obligations/action.ts} +247 -69
- package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
- package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
- package/src/{obligations.ts → obligations/index.ts} +32 -16
- package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
- package/src/{obligation-module.ts → obligations/module.ts} +113 -121
- package/src/obligations/pickle.ts +98 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
- package/src/{obligation-source.ts → obligations/source.ts} +154 -99
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/parallel-worker.ts +4 -20
- package/src/parallel.ts +13 -46
- package/src/parser.ts +1 -1
- package/src/{pcal-ast.ts → pcal/ast.ts} +2 -2
- package/src/{pcal-parse.ts → pcal/parse.ts} +3 -3
- package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +2 -2
- package/src/{pcal-translate.ts → pcal/translate.ts} +2 -2
- package/src/{pcal-validate.ts → pcal/validate.ts} +6 -6
- package/src/prove/decide-pool.ts +95 -0
- package/src/prove/deciders.ts +33 -0
- package/src/prove/first-order.ts +78 -0
- package/src/prove/isabelle/LICENSE +36 -0
- package/src/prove/isabelle/LICENSE-tlapm +26 -0
- package/src/prove/isabelle/decide.ts +47 -0
- package/src/prove/isabelle/encode.ts +446 -0
- package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prove/isabelle/isar/method.ts +367 -0
- package/src/prove/isabelle/isar/proof.ts +28 -0
- package/src/prove/isabelle/isar/statement.ts +57 -0
- package/src/prove/isabelle/isar/theory.ts +192 -0
- package/src/prove/isabelle/isar/type-check.ts +278 -0
- package/src/prove/isabelle/provers/blast/blast.ts +258 -0
- package/src/prove/isabelle/provers/blast/branch.ts +322 -0
- package/src/prove/isabelle/provers/blast/prove.ts +347 -0
- package/src/prove/isabelle/provers/blast/rules.ts +330 -0
- package/src/prove/isabelle/provers/blast/state.ts +180 -0
- package/src/prove/isabelle/provers/blast/term.ts +546 -0
- package/src/prove/isabelle/provers/clasimp.ts +150 -0
- package/src/prove/isabelle/provers/classical.ts +389 -0
- package/src/prove/isabelle/provers/hypsubst.ts +433 -0
- package/src/prove/isabelle/pure/bicompose.ts +174 -0
- package/src/prove/isabelle/pure/consts.ts +32 -0
- package/src/prove/isabelle/pure/conv.ts +79 -0
- package/src/prove/isabelle/pure/drule.ts +264 -0
- package/src/prove/isabelle/pure/envir.ts +331 -0
- package/src/prove/isabelle/pure/goal.ts +53 -0
- package/src/prove/isabelle/pure/interrupt.ts +16 -0
- package/src/prove/isabelle/pure/list.ts +12 -0
- package/src/prove/isabelle/pure/logic.ts +330 -0
- package/src/prove/isabelle/pure/name.ts +98 -0
- package/src/prove/isabelle/pure/net.ts +215 -0
- package/src/prove/isabelle/pure/object-logic.ts +41 -0
- package/src/prove/isabelle/pure/pattern.ts +631 -0
- package/src/prove/isabelle/pure/raw-simplifier.ts +338 -0
- package/src/prove/isabelle/pure/rewriter.ts +602 -0
- package/src/prove/isabelle/pure/search.ts +68 -0
- package/src/prove/isabelle/pure/seq.ts +133 -0
- package/src/prove/isabelle/pure/simplifier.ts +106 -0
- package/src/prove/isabelle/pure/table.ts +201 -0
- package/src/prove/isabelle/pure/tactic.ts +168 -0
- package/src/prove/isabelle/pure/tactical.ts +264 -0
- package/src/prove/isabelle/pure/term-ord.ts +105 -0
- package/src/prove/isabelle/pure/term.ts +688 -0
- package/src/prove/isabelle/pure/thm.ts +783 -0
- package/src/prove/isabelle/pure/type.ts +121 -0
- package/src/prove/isabelle/pure/unify.ts +753 -0
- package/src/prove/isabelle/pure/variable.ts +25 -0
- package/src/prove/isabelle/tla/classical-setup.ts +101 -0
- package/src/prove/isabelle/tla/context.ts +74 -0
- package/src/prove/isabelle/tla/logic-data.ts +5 -0
- package/src/prove/isabelle/tla/logic.ts +215 -0
- package/src/prove/isabelle/tla/simpdata.ts +241 -0
- package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prove/ocaml.ts +22 -0
- package/src/prove/prep/action.ts +508 -0
- package/src/prove/prep/defs.ts +33 -0
- package/src/prove/prep/elab.ts +156 -0
- package/src/prove/prep/enabled-axioms.ts +189 -0
- package/src/prove/prep/enabled.ts +43 -0
- package/src/prove/prep/fingerprint.ts +388 -0
- package/src/prove/prep/flatten.ts +70 -0
- package/src/prove/prep/level-comparison.ts +529 -0
- package/src/prove/prep/md5.ts +67 -0
- package/src/prove/prep/pragma.ts +221 -0
- package/src/prove/prep/trivial.ts +22 -0
- package/src/prove/prove-worker.ts +22 -0
- package/src/prove/prove.ts +498 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +255 -0
- package/src/prove/ptl/sat.ts +151 -0
- package/src/prove/ptl/tableau.ts +276 -0
- package/src/prove/smt/axiomatize.ts +69 -0
- package/src/prove/smt/axioms.ts +209 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +636 -0
- package/src/prove/smt/encode.ts +164 -0
- package/src/prove/smt/extensionality.ts +65 -0
- package/src/prove/smt/flatten.ts +112 -0
- package/src/prove/smt/format.ts +154 -0
- package/src/prove/smt/instances.ts +181 -0
- package/src/prove/smt/rewrite.ts +772 -0
- package/src/prove/smt/simplify.ts +57 -0
- package/src/prove/smt/solver/act-cache.ts +265 -0
- package/src/prove/smt/solver/arith-rewriter.ts +962 -0
- package/src/prove/smt/solver/array.ts +22 -0
- package/src/prove/smt/solver/asserted-formulas.ts +469 -0
- package/src/prove/smt/solver/ast-lt.ts +157 -0
- package/src/prove/smt/solver/ast-util.ts +91 -0
- package/src/prove/smt/solver/ast.ts +1315 -0
- package/src/prove/smt/solver/auf-solver.ts +572 -0
- package/src/prove/smt/solver/case-split-queue.ts +178 -0
- package/src/prove/smt/solver/cg-table.ts +175 -0
- package/src/prove/smt/solver/clause.ts +276 -0
- package/src/prove/smt/solver/conflict-resolution.ts +343 -0
- package/src/prove/smt/solver/context.ts +1292 -0
- package/src/prove/smt/solver/ctx-simplify.ts +334 -0
- package/src/prove/smt/solver/der.ts +224 -0
- package/src/prove/smt/solver/dyn-ack.ts +141 -0
- package/src/prove/smt/solver/e-matching.ts +659 -0
- package/src/prove/smt/solver/enode.ts +259 -0
- package/src/prove/smt/solver/expr-ref.ts +21 -0
- package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prove/smt/solver/fingerprints.ts +92 -0
- package/src/prove/smt/solver/flat-literals.ts +51 -0
- package/src/prove/smt/solver/goal.ts +138 -0
- package/src/prove/smt/solver/hash.ts +173 -0
- package/src/prove/smt/solver/hashtable.ts +166 -0
- package/src/prove/smt/solver/internalizer.ts +1381 -0
- package/src/prove/smt/solver/lbool.ts +5 -0
- package/src/prove/smt/solver/literal.ts +24 -0
- package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prove/smt/solver/lp/constraints.ts +78 -0
- package/src/prove/smt/solver/lp/containers.ts +296 -0
- package/src/prove/smt/solver/lp/core-solver.ts +504 -0
- package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prove/smt/solver/lp/dep-intervals.ts +642 -0
- package/src/prove/smt/solver/lp/dependency.ts +51 -0
- package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prove/smt/solver/lp/explanation.ts +46 -0
- package/src/prove/smt/solver/lp/gomory.ts +255 -0
- package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prove/smt/solver/lp/hnf.ts +281 -0
- package/src/prove/smt/solver/lp/int-cube.ts +295 -0
- package/src/prove/smt/solver/lp/int-solver.ts +514 -0
- package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prove/smt/solver/lp/lar-term.ts +62 -0
- package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prove/smt/solver/lp/nex.ts +120 -0
- package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prove/smt/solver/lp/nla-core.ts +968 -0
- package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prove/smt/solver/lp/nla-order.ts +307 -0
- package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prove/smt/solver/lp/nla-types.ts +124 -0
- package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prove/smt/solver/lp/pdd.ts +971 -0
- package/src/prove/smt/solver/lp/random-updater.ts +138 -0
- package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prove/smt/solver/lp/union-find.ts +96 -0
- package/src/prove/smt/solver/mam-compiler.ts +847 -0
- package/src/prove/smt/solver/mam-interpreter.ts +400 -0
- package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prove/smt/solver/model-checker.ts +347 -0
- package/src/prove/smt/solver/model-evaluator.ts +262 -0
- package/src/prove/smt/solver/model-finder.ts +155 -0
- package/src/prove/smt/solver/model-generator.ts +97 -0
- package/src/prove/smt/solver/model-macro-solver.ts +728 -0
- package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prove/smt/solver/nlsat/explain.ts +607 -0
- package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prove/smt/solver/nlsat/levelwise.ts +737 -0
- package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prove/smt/solver/nlsat/solver.ts +911 -0
- package/src/prove/smt/solver/nlsat/types.ts +43 -0
- package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prove/smt/solver/nnf.ts +469 -0
- package/src/prove/smt/solver/pattern-inference.ts +351 -0
- package/src/prove/smt/solver/poly-rewriter.ts +477 -0
- package/src/prove/smt/solver/propagate-values.ts +83 -0
- package/src/prove/smt/solver/proto-model.ts +551 -0
- package/src/prove/smt/solver/pull-quant.ts +139 -0
- package/src/prove/smt/solver/qe-lite-der.ts +526 -0
- package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prove/smt/solver/qe-lite.ts +381 -0
- package/src/prove/smt/solver/qi-queue.ts +362 -0
- package/src/prove/smt/solver/quant-tactics.ts +117 -0
- package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prove/smt/solver/quantifier-manager.ts +186 -0
- package/src/prove/smt/solver/random-gen.ts +10 -0
- package/src/prove/smt/solver/rational.ts +165 -0
- package/src/prove/smt/solver/ref-vector.ts +62 -0
- package/src/prove/smt/solver/relevancy.ts +247 -0
- package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prove/smt/solver/rewriter.ts +843 -0
- package/src/prove/smt/solver/rlimit.ts +79 -0
- package/src/prove/smt/solver/smtlib-parser.ts +526 -0
- package/src/prove/smt/solver/solver.ts +71 -0
- package/src/prove/smt/solver/sort.ts +35 -0
- package/src/prove/smt/solver/sticky-generations.ts +69 -0
- package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prove/smt/solver/theory-lra-model.ts +243 -0
- package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prove/smt/solver/theory-lra-state.ts +43 -0
- package/src/prove/smt/solver/theory-lra.ts +56 -0
- package/src/prove/smt/solver/var-subst.ts +258 -0
- package/src/prove/smt/solver/z3-license.txt +10 -0
- package/src/prove/smt/table.ts +170 -0
- package/src/prove/tlapm/cache.ts +236 -0
- package/src/prove/tlapm/ocaml-marshal.ts +166 -0
- package/src/prove/tlapm/tlapm.ts +96 -0
- package/src/prove/tlaps-module.ts +510 -0
- package/src/prove/verdict.ts +18 -0
- package/src/prove/zenon/LICENSE +32 -0
- package/src/prove/zenon/check/check.ts +105 -0
- package/src/prove/zenon/check/definitions.ts +144 -0
- package/src/prove/zenon/check/equality.ts +182 -0
- package/src/prove/zenon/check/functions.ts +62 -0
- package/src/prove/zenon/check/keys.ts +125 -0
- package/src/prove/zenon/check/propositional.ts +104 -0
- package/src/prove/zenon/check/records.ts +188 -0
- package/src/prove/zenon/check/relations.ts +121 -0
- package/src/prove/zenon/check/rewrites.ts +224 -0
- package/src/prove/zenon/check/sets.ts +302 -0
- package/src/prove/zenon/check/terms.ts +127 -0
- package/src/prove/zenon/check/tla.ts +126 -0
- package/src/prove/zenon/decide.ts +113 -0
- package/src/prove/zenon/encode.ts +379 -0
- package/src/prove/zenon/eqrel.ts +300 -0
- package/src/prove/zenon/equality-rules.ts +435 -0
- package/src/prove/zenon/expr.ts +551 -0
- package/src/prove/zenon/index-table.ts +350 -0
- package/src/prove/zenon/isar-case.ts +513 -0
- package/src/prove/zenon/isar.ts +1249 -0
- package/src/prove/zenon/limits.ts +15 -0
- package/src/prove/zenon/llproof.ts +173 -0
- package/src/prove/zenon/mltoll.ts +1566 -0
- package/src/prove/zenon/node.ts +297 -0
- package/src/prove/zenon/ocaml.ts +169 -0
- package/src/prove/zenon/parse.ts +247 -0
- package/src/prove/zenon/phrase.ts +191 -0
- package/src/prove/zenon/proof.ts +198 -0
- package/src/prove/zenon/propositional-rules.ts +387 -0
- package/src/prove/zenon/rules.ts +94 -0
- package/src/prove/zenon/search.ts +288 -0
- package/src/prove/zenon/tla/functions.ts +151 -0
- package/src/prove/zenon/tla/llproof.ts +480 -0
- package/src/prove/zenon/tla/records.ts +225 -0
- package/src/prove/zenon/tla/rewrites.ts +447 -0
- package/src/prove/zenon/tla/sets.ts +304 -0
- package/src/prove/zenon/tla/terms.ts +162 -0
- package/src/prove/zenon/tla/tla.ts +506 -0
- package/src/randomization.ts +1 -1
- package/src/resolve.ts +1 -1
- package/src/runtime.ts +2 -2
- package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
- package/src/{sany-generator.ts → sany/generator.ts} +14 -14
- package/src/{sany-levels.ts → sany/levels.ts} +2 -2
- package/src/{sany-lexer.ts → sany/lexer.ts} +1 -1
- package/src/{sany-linter.ts → sany/linter.ts} +1 -1
- package/src/{sany-modules.ts → sany/modules.ts} +2 -2
- package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
- package/src/{sany-report.ts → sany/report.ts} +15 -15
- package/src/{sany-selectors.ts → sany/selectors.ts} +3 -3
- package/src/{sany-source.ts → sany/source.ts} +6 -6
- package/src/{sany-xml.ts → sany/xml.ts} +5 -5
- package/src/spec-description.ts +1 -1
- package/src/{standard-levels.ts → standard/levels.ts} +1 -1
- package/src/{standard-modules.ts → standard/modules.ts} +12 -12
- package/src/{standard-ranges.ts → standard/ranges.ts} +1 -1
- package/src/state-graph.ts +1 -1
- package/src/successors.ts +1 -1
- package/src/symmetry.ts +1 -1
- package/src/{tlc-messages.ts → tlc/messages.ts} +2 -2
- package/src/{tlc-order.ts → tlc/order.ts} +7 -7
- package/src/{tlc-random.ts → tlc/random.ts} +3 -3
- package/src/{tlc-replay.ts → tlc/replay.ts} +5 -5
- package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
- package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +14 -8
- package/src/values.ts +1 -1
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
- package/dist/run-cli.cjs +0 -55
- package/dist/run-cli.js +0 -55
- package/src/value-sources.ts +0 -29
- /package/src/{sany-nodes.ts → sany/nodes.ts} +0 -0
- /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
- /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
- /package/src/{tlc-version.ts → tlc/version.ts} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Worker threads that decide the obligations prove sends them, the earliest obligation first.
|
|
2
|
+
|
|
3
|
+
import { TlaProverError } from "../errors";
|
|
4
|
+
import { spawnWorker, type WorkerHandle } from "../worker";
|
|
5
|
+
import type { DecideOptions, Decision } from "./verdict";
|
|
6
|
+
|
|
7
|
+
export interface DecideRequest {
|
|
8
|
+
prover: string;
|
|
9
|
+
text: string;
|
|
10
|
+
timeLimitMs: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// A backend's decision, or the message of the TlaProverError it threw, which prove turns into a
|
|
14
|
+
// result.
|
|
15
|
+
export type DecideResponse = Decision | { error: string };
|
|
16
|
+
|
|
17
|
+
interface PendingDecision {
|
|
18
|
+
request: DecideRequest;
|
|
19
|
+
priority: number;
|
|
20
|
+
resolve: (decision: Decision) => void;
|
|
21
|
+
reject: (error: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DecidePool {
|
|
25
|
+
decide: (
|
|
26
|
+
prover: string,
|
|
27
|
+
text: string,
|
|
28
|
+
options: DecideOptions,
|
|
29
|
+
priority: number,
|
|
30
|
+
) => Promise<Decision>;
|
|
31
|
+
// Rejects every decision not yet made with reason, and stops the workers.
|
|
32
|
+
terminate: (reason: unknown) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createDecidePool = async (count: number): Promise<DecidePool> => {
|
|
36
|
+
const workers: WorkerHandle[] = [];
|
|
37
|
+
const queue: PendingDecision[] = [];
|
|
38
|
+
const running = new Map<number, PendingDecision>();
|
|
39
|
+
const idle: number[] = [];
|
|
40
|
+
const state: { failure: { reason: unknown } | undefined } = { failure: undefined };
|
|
41
|
+
const dispatch = () => {
|
|
42
|
+
while (idle.length > 0 && queue.length > 0) {
|
|
43
|
+
const earliest = queue.reduce(
|
|
44
|
+
(best, decision, position) => (decision.priority < queue[best].priority ? position : best),
|
|
45
|
+
0,
|
|
46
|
+
);
|
|
47
|
+
const [decision] = queue.splice(earliest, 1);
|
|
48
|
+
const index = idle.pop() ?? 0;
|
|
49
|
+
running.set(index, decision);
|
|
50
|
+
workers[index].postMessage(decision.request);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const onResponse = (index: number, message: unknown) => {
|
|
54
|
+
const response = message as DecideResponse;
|
|
55
|
+
const decision = running.get(index);
|
|
56
|
+
running.delete(index);
|
|
57
|
+
idle.push(index);
|
|
58
|
+
if ("verdict" in response) decision?.resolve(response);
|
|
59
|
+
if ("error" in response) decision?.reject(new TlaProverError(response.error));
|
|
60
|
+
dispatch();
|
|
61
|
+
};
|
|
62
|
+
const terminate = (reason: unknown) => {
|
|
63
|
+
if (state.failure) return;
|
|
64
|
+
state.failure = { reason };
|
|
65
|
+
[...queue.splice(0), ...running.values()].forEach((decision) => decision.reject(reason));
|
|
66
|
+
running.clear();
|
|
67
|
+
workers.forEach((worker) => worker.terminate());
|
|
68
|
+
};
|
|
69
|
+
workers.push(
|
|
70
|
+
...(await Promise.all(
|
|
71
|
+
Array.from({ length: count }, (_, index) =>
|
|
72
|
+
spawnWorker(
|
|
73
|
+
new URL("./prove-worker.js", import.meta.url),
|
|
74
|
+
(message) => onResponse(index, message),
|
|
75
|
+
terminate,
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
)),
|
|
79
|
+
);
|
|
80
|
+
idle.push(...workers.keys());
|
|
81
|
+
return {
|
|
82
|
+
decide: (prover, text, options, priority) =>
|
|
83
|
+
new Promise((resolve, reject) => {
|
|
84
|
+
if (state.failure) return reject(state.failure.reason);
|
|
85
|
+
queue.push({
|
|
86
|
+
request: { prover, text, timeLimitMs: options.timeLimitMs },
|
|
87
|
+
priority,
|
|
88
|
+
resolve,
|
|
89
|
+
reject,
|
|
90
|
+
});
|
|
91
|
+
dispatch();
|
|
92
|
+
}),
|
|
93
|
+
terminate,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// How each of tla-ts's backends decides the text tlapm would send its prover, by the prover of the
|
|
2
|
+
// method that selects it.
|
|
3
|
+
|
|
4
|
+
import { SmtParseError, TlaProverError } from "../errors";
|
|
5
|
+
import { decideIsabelle } from "./isabelle/decide";
|
|
6
|
+
import { decidePtl } from "./ptl/decide";
|
|
7
|
+
import { decideSmt } from "./smt/solver/solver";
|
|
8
|
+
import type { DecideOptions, Decision, Verdict } from "./verdict";
|
|
9
|
+
import { decideZenon } from "./zenon/decide";
|
|
10
|
+
|
|
11
|
+
// Z3 rejects malformed input with an error, and tlapm counts that as a failure.
|
|
12
|
+
const decideZ3 = (text: string, options: DecideOptions) => {
|
|
13
|
+
try {
|
|
14
|
+
return decideSmt(text, options);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (error instanceof SmtParseError) throw new TlaProverError(error.message, error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DECIDERS: Record<string, (text: string, options: DecideOptions) => Verdict> = {
|
|
22
|
+
smt: decideZ3,
|
|
23
|
+
z3: decideZ3,
|
|
24
|
+
zenon: (text, options) => decideZenon(text, options).verdict,
|
|
25
|
+
isabelle: decideIsabelle,
|
|
26
|
+
ls4: decidePtl,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const decide = (prover: string, text: string, options: DecideOptions): Decision => {
|
|
30
|
+
const start = performance.now();
|
|
31
|
+
const verdict = DECIDERS[prover](text, options);
|
|
32
|
+
return { verdict, timeUsedMs: performance.now() - start };
|
|
33
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// What backend/zenon.ml and backend/isabelle.ml share in printing an obligation that Backend.Prep
|
|
2
|
+
// has shipped.
|
|
3
|
+
|
|
4
|
+
import { TlapmBugError, TlaProverError, TlaUnsupportedError } from "../errors";
|
|
5
|
+
import { popNames, type Context } from "../obligations/ctx";
|
|
6
|
+
import { shiftExpr, type Bound, type Builtin, type Expr } from "../obligations/expression";
|
|
7
|
+
|
|
8
|
+
// The temporal operators neither backend has a counterpart for, by the name tlapm reports.
|
|
9
|
+
const TEMPORAL_OPERATORS: Partial<Record<Builtin, [string, number]>> = {
|
|
10
|
+
Leadsto: ["Leadsto", 2],
|
|
11
|
+
ENABLED: ["ENABLED", 1],
|
|
12
|
+
Cdot: ["\\cdot", 2],
|
|
13
|
+
Actplus: ["-+->", 2],
|
|
14
|
+
BoxTrue: ["[]", 1],
|
|
15
|
+
BoxFalse: ["[]", 1],
|
|
16
|
+
Diamond: ["<>", 1],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Why a backend can't print an application of builtin, which it reports as where.
|
|
20
|
+
export const getUnprintableError = (builtin: Builtin, arity: number, where: string) => {
|
|
21
|
+
const isFrontend = builtin === "Prime" || builtin === "StrongPrime" || builtin === "UNCHANGED";
|
|
22
|
+
if (isFrontend && arity === 1) return new TlapmBugError();
|
|
23
|
+
const temporal = TEMPORAL_OPERATORS[builtin];
|
|
24
|
+
return temporal && temporal[1] === arity
|
|
25
|
+
? new TlaProverError(`Unsupported operator \`${temporal[0]}\`.\n`)
|
|
26
|
+
: new TlaProverError(where);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface SplitQuantifier {
|
|
30
|
+
first: Bound;
|
|
31
|
+
inner: Expr;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A quantifier's first bound binds around a quantifier over the others, which move under it. A
|
|
35
|
+
// ditto after the first bound copies its domain.
|
|
36
|
+
export const splitFirstBound = (
|
|
37
|
+
quantifier: "Forall" | "Exists",
|
|
38
|
+
bounds: Bound[],
|
|
39
|
+
body: Expr,
|
|
40
|
+
): SplitQuantifier => {
|
|
41
|
+
const first = bounds[0];
|
|
42
|
+
const rest = bounds.slice(1);
|
|
43
|
+
const undittoed =
|
|
44
|
+
rest[0]?.domain.kind === "Ditto"
|
|
45
|
+
? [{ ...rest[0], domain: first.domain }, ...rest.slice(1)]
|
|
46
|
+
: rest;
|
|
47
|
+
if (undittoed.length === 0) return { first, inner: body };
|
|
48
|
+
return {
|
|
49
|
+
first,
|
|
50
|
+
inner: {
|
|
51
|
+
kind: "Quant",
|
|
52
|
+
quantifier,
|
|
53
|
+
bounds: undittoed.map((other) =>
|
|
54
|
+
other.domain.kind === "Domain"
|
|
55
|
+
? {
|
|
56
|
+
...other,
|
|
57
|
+
domain: { kind: "Domain", expression: shiftExpr(1, other.domain.expression) },
|
|
58
|
+
}
|
|
59
|
+
: other,
|
|
60
|
+
),
|
|
61
|
+
body,
|
|
62
|
+
location: body.location,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// tlapm prints a fact to a formatter that drops its output first, to omit an unsupported one: the
|
|
68
|
+
// fact's print, or the error that omits it once the names it bound are out of scope.
|
|
69
|
+
export const printFact = <Printed>(context: Context, print: () => Printed) => {
|
|
70
|
+
const depth = context.stack.length;
|
|
71
|
+
try {
|
|
72
|
+
return print();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (!(error instanceof TlaUnsupportedError)) throw error;
|
|
75
|
+
popNames(context, context.stack.length - depth);
|
|
76
|
+
return error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
ISABELLE COPYRIGHT NOTICE, LICENCE AND DISCLAIMER.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 1986-2025,
|
|
4
|
+
University of Cambridge,
|
|
5
|
+
Technische Universitaet Muenchen,
|
|
6
|
+
and contributors.
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted provided that the following conditions are
|
|
12
|
+
met:
|
|
13
|
+
|
|
14
|
+
* Redistributions of source code must retain the above copyright
|
|
15
|
+
notice, this list of conditions and the following disclaimer.
|
|
16
|
+
|
|
17
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
18
|
+
notice, this list of conditions and the following disclaimer in the
|
|
19
|
+
documentation and/or other materials provided with the distribution.
|
|
20
|
+
|
|
21
|
+
* Neither the name of the University of Cambridge or the Technische
|
|
22
|
+
Universitaet Muenchen nor the names of their contributors may be used
|
|
23
|
+
to endorse or promote products derived from this software without
|
|
24
|
+
specific prior written permission.
|
|
25
|
+
|
|
26
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
27
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
28
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
29
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2008 INRIA and Microsoft Corporation
|
|
2
|
+
Copyright (c) 2023 Linux Foundation
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are
|
|
6
|
+
met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in
|
|
13
|
+
the documentation and/or other materials provided with the
|
|
14
|
+
distribution.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
20
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
21
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
22
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Decides a theory tlapm writes for Isabelle, as tlapm's Isabelle backend runs it: use_thy on the
|
|
2
|
+
// heap of Isabelle/TLA+ succeeds or fails.
|
|
3
|
+
|
|
4
|
+
import { TlaIsabelleError } from "../../errors";
|
|
5
|
+
import type { DecideOptions, Verdict } from "../verdict";
|
|
6
|
+
import { parseProofText, terminalProof } from "./isar/method";
|
|
7
|
+
import { getFacts, initGoal } from "./isar/proof";
|
|
8
|
+
import { readStatement } from "./isar/statement";
|
|
9
|
+
import { parseTheory } from "./isar/theory";
|
|
10
|
+
import { protect } from "./pure/logic";
|
|
11
|
+
import { seqHead } from "./pure/seq";
|
|
12
|
+
import { aconv } from "./pure/term";
|
|
13
|
+
import { getProofContext } from "./tla/context";
|
|
14
|
+
import { loadLogic } from "./tla/logic";
|
|
15
|
+
|
|
16
|
+
// V8's error when a recursion runs out of stack. Poly/ML grows its stack instead, until the
|
|
17
|
+
// recursion ends or Isabelle breaks down for lack of memory, which tlapm counts as a failure.
|
|
18
|
+
const isStackOverflow = (error: unknown) =>
|
|
19
|
+
error instanceof RangeError && error.message === "Maximum call stack size exceeded";
|
|
20
|
+
|
|
21
|
+
export const decideIsabelle = (text: string, options: DecideOptions): Exclude<Verdict, "sat"> => {
|
|
22
|
+
const limits = { deadline: Date.now() + options.timeLimitMs, signal: options.signal };
|
|
23
|
+
try {
|
|
24
|
+
const theory = parseTheory(text);
|
|
25
|
+
const logic = loadLogic();
|
|
26
|
+
const statement = readStatement(logic, theory);
|
|
27
|
+
const facts = theory.isUsingAssms ? getFacts(limits, statement) : [];
|
|
28
|
+
const result = seqHead(
|
|
29
|
+
terminalProof(
|
|
30
|
+
getProofContext(logic, limits),
|
|
31
|
+
parseProofText(theory.method),
|
|
32
|
+
facts,
|
|
33
|
+
initGoal(statement),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
// Proof.conclude_goal: the theorem must be the statement, from its assumptions only.
|
|
37
|
+
return result !== undefined &&
|
|
38
|
+
result.tpairs.length === 0 &&
|
|
39
|
+
aconv(result.prop, protect(statement.conclusion)) &&
|
|
40
|
+
result.hyps.every((hyp) => statement.assumptions.some((assumption) => aconv(hyp, assumption)))
|
|
41
|
+
? "unsat"
|
|
42
|
+
: "unknown";
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error instanceof TlaIsabelleError || isStackOverflow(error)) return "unknown";
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|