tla-ts 0.0.3 → 0.0.4-dev.1a3acf6
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 +46 -115
- 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 +194 -8
- package/dist/index.d.ts +194 -8
- 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 +1006 -0
- package/dist/prove.js +1006 -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 +1377 -18
- package/dist/transfer.js +1377 -18
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +24 -11
- package/src/ast.ts +149 -8
- package/src/bags.ts +26 -30
- package/src/builtins.ts +45 -19
- package/src/bundled-modules.ts +3 -3
- package/src/check.ts +1182 -900
- package/src/cli/options.ts +109 -0
- package/src/cli/run.ts +63 -0
- package/src/cli/shared.ts +106 -0
- package/src/cli/tlapm.ts +374 -0
- package/src/cli/tlc.ts +941 -0
- package/src/cli/xml-exporter.ts +221 -0
- package/src/cli.ts +9 -2
- package/src/codegen.ts +112 -51
- package/src/config.ts +254 -181
- package/src/dependencies.ts +5 -7
- package/src/environment.ts +579 -184
- package/src/errors.ts +287 -4
- package/src/evaluate.ts +1095 -365
- package/src/exit-codes.ts +22 -43
- package/src/fingerprints.ts +49 -14
- package/src/index.ts +11 -0
- package/src/instances.ts +73 -60
- package/src/java-overrides.ts +183 -66
- package/src/json.ts +31 -36
- package/src/levels.ts +197 -54
- package/src/lexer.ts +127 -30
- package/src/liveness-checker.ts +894 -0
- package/src/liveness.ts +246 -596
- package/src/{obligation-action.ts → obligations/action.ts} +248 -74
- package/src/{obligation-anon.ts → obligations/anonymize.ts} +55 -57
- package/src/obligations/equality.ts +260 -0
- package/src/obligations/expression.ts +618 -0
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/obligations/generate.ts +457 -0
- package/src/{obligations.ts → obligations/index.ts} +46 -32
- package/src/{obligation-levels.ts → obligations/levels.ts} +44 -40
- package/src/obligations/module.ts +445 -0
- package/src/obligations/normalize.ts +554 -0
- package/src/obligations/operators.ts +176 -0
- package/src/obligations/pragma.ts +195 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +65 -230
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
- package/src/obligations/regroup.ts +100 -0
- package/src/{obligation-generate.ts → obligations/simplify.ts} +130 -536
- package/src/{obligation-source.ts → obligations/source.ts} +174 -216
- package/src/{obligation-deref.ts → obligations/subexpression.ts} +84 -115
- package/src/obligations/substitution.ts +261 -0
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/parallel-worker.ts +184 -235
- package/src/parallel.ts +156 -91
- package/src/parser.ts +490 -188
- package/src/pcal/ast.ts +755 -0
- package/src/pcal/parse.ts +1487 -0
- package/src/pcal/tokenize.ts +487 -0
- package/src/pcal/translate.ts +1151 -0
- package/src/pcal/validate.ts +444 -0
- package/src/prover/decide-pool.ts +95 -0
- package/src/prover/deciders.ts +33 -0
- package/src/prover/first-order.ts +175 -0
- package/src/prover/isabelle/LICENSE +36 -0
- package/src/prover/isabelle/LICENSE-tlapm +26 -0
- package/src/prover/isabelle/decide.ts +44 -0
- package/src/prover/isabelle/encode.ts +445 -0
- package/src/prover/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prover/isabelle/isar/method.ts +367 -0
- package/src/prover/isabelle/isar/proof.ts +28 -0
- package/src/prover/isabelle/isar/statement.ts +57 -0
- package/src/prover/isabelle/isar/theory.ts +192 -0
- package/src/prover/isabelle/isar/type-check.ts +278 -0
- package/src/prover/isabelle/provers/blast/blast.ts +258 -0
- package/src/prover/isabelle/provers/blast/branch.ts +322 -0
- package/src/prover/isabelle/provers/blast/prove.ts +347 -0
- package/src/prover/isabelle/provers/blast/rules.ts +330 -0
- package/src/prover/isabelle/provers/blast/state.ts +180 -0
- package/src/prover/isabelle/provers/blast/term.ts +546 -0
- package/src/prover/isabelle/provers/clasimp.ts +150 -0
- package/src/prover/isabelle/provers/classical.ts +389 -0
- package/src/prover/isabelle/provers/hypsubst.ts +433 -0
- package/src/prover/isabelle/pure/bicompose.ts +174 -0
- package/src/prover/isabelle/pure/consts.ts +32 -0
- package/src/prover/isabelle/pure/conv.ts +79 -0
- package/src/prover/isabelle/pure/drule.ts +264 -0
- package/src/prover/isabelle/pure/envir.ts +331 -0
- package/src/prover/isabelle/pure/goal.ts +53 -0
- package/src/prover/isabelle/pure/interrupt.ts +16 -0
- package/src/prover/isabelle/pure/list.ts +12 -0
- package/src/prover/isabelle/pure/logic.ts +330 -0
- package/src/prover/isabelle/pure/name.ts +98 -0
- package/src/prover/isabelle/pure/net.ts +215 -0
- package/src/prover/isabelle/pure/object-logic.ts +41 -0
- package/src/prover/isabelle/pure/pattern.ts +631 -0
- package/src/prover/isabelle/pure/raw-simplifier.ts +338 -0
- package/src/prover/isabelle/pure/rewriter.ts +602 -0
- package/src/prover/isabelle/pure/search.ts +68 -0
- package/src/prover/isabelle/pure/seq.ts +133 -0
- package/src/prover/isabelle/pure/simplifier.ts +106 -0
- package/src/prover/isabelle/pure/table.ts +201 -0
- package/src/prover/isabelle/pure/tactic.ts +168 -0
- package/src/prover/isabelle/pure/tactical.ts +264 -0
- package/src/prover/isabelle/pure/term-ord.ts +105 -0
- package/src/prover/isabelle/pure/term.ts +688 -0
- package/src/prover/isabelle/pure/thm.ts +783 -0
- package/src/prover/isabelle/pure/type.ts +121 -0
- package/src/prover/isabelle/pure/unify.ts +753 -0
- package/src/prover/isabelle/pure/variable.ts +25 -0
- package/src/prover/isabelle/tla/classical-setup.ts +101 -0
- package/src/prover/isabelle/tla/context.ts +74 -0
- package/src/prover/isabelle/tla/logic-data.ts +5 -0
- package/src/prover/isabelle/tla/logic.ts +215 -0
- package/src/prover/isabelle/tla/simpdata.ts +241 -0
- package/src/prover/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prover/ocaml.ts +22 -0
- package/src/prover/prep/action.ts +508 -0
- package/src/prover/prep/enabled-axioms.ts +189 -0
- package/src/prover/prep/fingerprint.ts +388 -0
- package/src/prover/prep/level-comparison.ts +529 -0
- package/src/prover/prep/md5.ts +60 -0
- package/src/prover/prep/methods.ts +221 -0
- package/src/prover/prep/normalize.ts +309 -0
- package/src/prover/prove-worker.ts +22 -0
- package/src/prover/prove.ts +492 -0
- package/src/prover/ptl/decide.ts +68 -0
- package/src/prover/ptl/encode.ts +244 -0
- package/src/prover/ptl/sat.ts +151 -0
- package/src/prover/ptl/tableau.ts +276 -0
- package/src/prover/smt/axioms.ts +209 -0
- package/src/prover/smt/context.ts +108 -0
- package/src/prover/smt/data.ts +636 -0
- package/src/prover/smt/encode.ts +275 -0
- package/src/prover/smt/extensionality.ts +65 -0
- package/src/prover/smt/flatten.ts +112 -0
- package/src/prover/smt/format.ts +154 -0
- package/src/prover/smt/instances.ts +181 -0
- package/src/prover/smt/rewrite.ts +766 -0
- package/src/prover/smt/solver/act-cache.ts +265 -0
- package/src/prover/smt/solver/arith-rewriter.ts +962 -0
- package/src/prover/smt/solver/array.ts +22 -0
- package/src/prover/smt/solver/asserted-formulas.ts +469 -0
- package/src/prover/smt/solver/ast-lt.ts +157 -0
- package/src/prover/smt/solver/ast-util.ts +91 -0
- package/src/prover/smt/solver/ast.ts +1315 -0
- package/src/prover/smt/solver/auf-solver.ts +572 -0
- package/src/prover/smt/solver/case-split-queue.ts +178 -0
- package/src/prover/smt/solver/cg-table.ts +175 -0
- package/src/prover/smt/solver/clause.ts +276 -0
- package/src/prover/smt/solver/conflict-resolution.ts +343 -0
- package/src/prover/smt/solver/context.ts +1292 -0
- package/src/prover/smt/solver/ctx-simplify.ts +334 -0
- package/src/prover/smt/solver/der.ts +224 -0
- package/src/prover/smt/solver/dyn-ack.ts +141 -0
- package/src/prover/smt/solver/e-matching.ts +659 -0
- package/src/prover/smt/solver/enode.ts +259 -0
- package/src/prover/smt/solver/expr-ref.ts +21 -0
- package/src/prover/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prover/smt/solver/fingerprints.ts +92 -0
- package/src/prover/smt/solver/flat-literals.ts +51 -0
- package/src/prover/smt/solver/goal.ts +138 -0
- package/src/prover/smt/solver/hash.ts +173 -0
- package/src/prover/smt/solver/hashtable.ts +166 -0
- package/src/prover/smt/solver/internalizer.ts +1381 -0
- package/src/prover/smt/solver/lbool.ts +5 -0
- package/src/prover/smt/solver/literal.ts +24 -0
- package/src/prover/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prover/smt/solver/lp/constraints.ts +78 -0
- package/src/prover/smt/solver/lp/containers.ts +296 -0
- package/src/prover/smt/solver/lp/core-solver.ts +504 -0
- package/src/prover/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prover/smt/solver/lp/dep-intervals.ts +642 -0
- package/src/prover/smt/solver/lp/dependency.ts +51 -0
- package/src/prover/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prover/smt/solver/lp/explanation.ts +46 -0
- package/src/prover/smt/solver/lp/gomory.ts +255 -0
- package/src/prover/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prover/smt/solver/lp/hnf.ts +281 -0
- package/src/prover/smt/solver/lp/int-cube.ts +295 -0
- package/src/prover/smt/solver/lp/int-solver.ts +514 -0
- package/src/prover/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prover/smt/solver/lp/lar-term.ts +62 -0
- package/src/prover/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prover/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prover/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prover/smt/solver/lp/nex.ts +120 -0
- package/src/prover/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prover/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prover/smt/solver/lp/nla-core.ts +968 -0
- package/src/prover/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prover/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prover/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prover/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prover/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prover/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prover/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prover/smt/solver/lp/nla-order.ts +307 -0
- package/src/prover/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prover/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prover/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prover/smt/solver/lp/nla-types.ts +124 -0
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prover/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prover/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prover/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prover/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prover/smt/solver/lp/pdd.ts +971 -0
- package/src/prover/smt/solver/lp/random-updater.ts +138 -0
- package/src/prover/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prover/smt/solver/lp/union-find.ts +96 -0
- package/src/prover/smt/solver/mam-compiler.ts +847 -0
- package/src/prover/smt/solver/mam-interpreter.ts +400 -0
- package/src/prover/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prover/smt/solver/model-checker.ts +347 -0
- package/src/prover/smt/solver/model-evaluator.ts +262 -0
- package/src/prover/smt/solver/model-finder.ts +155 -0
- package/src/prover/smt/solver/model-generator.ts +97 -0
- package/src/prover/smt/solver/model-macro-solver.ts +728 -0
- package/src/prover/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prover/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prover/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prover/smt/solver/nlsat/explain.ts +607 -0
- package/src/prover/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prover/smt/solver/nlsat/levelwise.ts +737 -0
- package/src/prover/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prover/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prover/smt/solver/nlsat/solver.ts +911 -0
- package/src/prover/smt/solver/nlsat/types.ts +43 -0
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prover/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prover/smt/solver/nnf.ts +469 -0
- package/src/prover/smt/solver/pattern-inference.ts +351 -0
- package/src/prover/smt/solver/poly-rewriter.ts +477 -0
- package/src/prover/smt/solver/propagate-values.ts +83 -0
- package/src/prover/smt/solver/proto-model.ts +551 -0
- package/src/prover/smt/solver/pull-quant.ts +139 -0
- package/src/prover/smt/solver/qe-lite-der.ts +526 -0
- package/src/prover/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prover/smt/solver/qe-lite.ts +381 -0
- package/src/prover/smt/solver/qi-queue.ts +362 -0
- package/src/prover/smt/solver/quant-tactics.ts +117 -0
- package/src/prover/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prover/smt/solver/quantifier-manager.ts +186 -0
- package/src/prover/smt/solver/random-gen.ts +10 -0
- package/src/prover/smt/solver/rational.ts +165 -0
- package/src/prover/smt/solver/ref-vector.ts +62 -0
- package/src/prover/smt/solver/relevancy.ts +247 -0
- package/src/prover/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prover/smt/solver/rewriter.ts +843 -0
- package/src/prover/smt/solver/rlimit.ts +79 -0
- package/src/prover/smt/solver/smtlib-parser.ts +526 -0
- package/src/prover/smt/solver/solver.ts +71 -0
- package/src/prover/smt/solver/sort.ts +35 -0
- package/src/prover/smt/solver/sticky-generations.ts +69 -0
- package/src/prover/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prover/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prover/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prover/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prover/smt/solver/theory-lra-model.ts +243 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prover/smt/solver/theory-lra-state.ts +43 -0
- package/src/prover/smt/solver/theory-lra.ts +56 -0
- package/src/prover/smt/solver/var-subst.ts +258 -0
- package/src/prover/smt/solver/z3-license.txt +10 -0
- package/src/prover/smt/table.ts +170 -0
- package/src/prover/tlapm/cache.ts +236 -0
- package/src/prover/tlapm/ocaml-marshal.ts +166 -0
- package/src/prover/tlapm/tlapm.ts +96 -0
- package/src/prover/tlaps-module.ts +510 -0
- package/src/prover/verdict.ts +13 -0
- package/src/prover/zenon/LICENSE +32 -0
- package/src/prover/zenon/check/check.ts +105 -0
- package/src/prover/zenon/check/definitions.ts +144 -0
- package/src/prover/zenon/check/equality.ts +182 -0
- package/src/prover/zenon/check/functions.ts +62 -0
- package/src/prover/zenon/check/keys.ts +125 -0
- package/src/prover/zenon/check/propositional.ts +104 -0
- package/src/prover/zenon/check/records.ts +188 -0
- package/src/prover/zenon/check/relations.ts +121 -0
- package/src/prover/zenon/check/rewrites.ts +224 -0
- package/src/prover/zenon/check/sets.ts +302 -0
- package/src/prover/zenon/check/terms.ts +127 -0
- package/src/prover/zenon/check/tla.ts +126 -0
- package/src/prover/zenon/decide.ts +107 -0
- package/src/prover/zenon/encode.ts +378 -0
- package/src/prover/zenon/eqrel.ts +300 -0
- package/src/prover/zenon/equality-rules.ts +435 -0
- package/src/prover/zenon/expr.ts +551 -0
- package/src/prover/zenon/index-table.ts +350 -0
- package/src/prover/zenon/isar-case.ts +513 -0
- package/src/prover/zenon/isar.ts +1249 -0
- package/src/prover/zenon/limits.ts +15 -0
- package/src/prover/zenon/llproof.ts +173 -0
- package/src/prover/zenon/mltoll.ts +1566 -0
- package/src/prover/zenon/node.ts +297 -0
- package/src/prover/zenon/ocaml.ts +169 -0
- package/src/prover/zenon/parse.ts +247 -0
- package/src/prover/zenon/phrase.ts +191 -0
- package/src/prover/zenon/proof.ts +198 -0
- package/src/prover/zenon/propositional-rules.ts +387 -0
- package/src/prover/zenon/rules.ts +94 -0
- package/src/prover/zenon/search.ts +288 -0
- package/src/prover/zenon/tla/functions.ts +151 -0
- package/src/prover/zenon/tla/llproof.ts +480 -0
- package/src/prover/zenon/tla/records.ts +225 -0
- package/src/prover/zenon/tla/rewrites.ts +447 -0
- package/src/prover/zenon/tla/sets.ts +304 -0
- package/src/prover/zenon/tla/terms.ts +162 -0
- package/src/prover/zenon/tla/tla.ts +506 -0
- package/src/randomization.ts +39 -27
- package/src/resolve.ts +1474 -426
- package/src/runtime.ts +25 -7
- package/src/sany/builtins.ts +147 -0
- package/src/sany/generator.ts +3111 -0
- package/src/sany/levels.ts +1205 -0
- package/src/sany/lexer.ts +544 -0
- package/src/sany/linter.ts +122 -0
- package/src/sany/modules.ts +1398 -0
- package/src/sany/nodes.ts +463 -0
- package/src/sany/parse-error.ts +2161 -0
- package/src/sany/report.ts +355 -0
- package/src/sany/selectors.ts +736 -0
- package/src/sany/source.ts +247 -0
- package/src/sany/xml.ts +1016 -0
- package/src/search.ts +969 -0
- package/src/spec-description.ts +66 -29
- package/src/{standard-levels.ts → standard-definitions.ts} +118 -2
- package/src/standard-modules.ts +215 -164
- package/src/state-graph.ts +181 -0
- package/src/subexpressions.ts +231 -171
- package/src/substitution-levels.ts +40 -19
- package/src/successors.ts +253 -125
- package/src/symmetry.ts +194 -54
- package/src/tableau.ts +60 -32
- package/src/tlc/fingerprint.ts +214 -0
- package/src/{tlc-modules.ts → tlc/jar-data.ts} +4 -0
- package/src/tlc/messages.ts +441 -0
- package/src/{tlc-order.ts → tlc/order.ts} +84 -16
- package/src/{tlc-random.ts → tlc/random.ts} +30 -189
- package/src/tlc/replay.ts +659 -0
- package/src/{tlc-summary.ts → tlc/summary.ts} +20 -5
- package/src/{tlc-module.ts → tlc/tlc-operators.ts} +59 -50
- package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +63 -45
- package/src/tlc/version.ts +19 -0
- package/src/transfer.ts +44 -32
- package/src/values.ts +843 -241
- package/src/worker.ts +62 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
- package/dist/run-cli.cjs +0 -28
- package/dist/run-cli.js +0 -28
- package/src/canonical.ts +0 -39
- package/src/cli-options.ts +0 -58
- package/src/obligation-expression.ts +0 -1060
- package/src/obligation-module.ts +0 -1042
- package/src/run-cli.ts +0 -478
package/dist/worker.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license tla-ts
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=/* @__PURE__ */ new WeakMap,n=(e,n)=>(e instanceof Error&&!t.has(e)&&t.set(e,n),e),r=e=>t.get(e),i=t=>{try{return t()}catch(t){throw n(t,e.error)}},a=e=>{let t=i(e);return t&&{branches:t.branches,addInitialState:(e,n,r)=>i(()=>t.addInitialState(e,n,r)),addState:(e,n,r,a)=>i(()=>t.addState(e,n,r,a)),findViolation:()=>i(()=>t.findViolation()),getViolatedProperties:(e,n)=>i(()=>t.getViolatedProperties(e,n))}},o=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,s=o(`java.lang.RuntimeException`),c=o(`tlc2.tool.EvalException`),l=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`;var u=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},d=class extends u{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},f=class extends d{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},p=class extends f{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const m=(e,t=!1,n,r=[])=>new d(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
|
+
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),h=(e,t)=>m([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),g=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,_=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,v=(e,t)=>m([{location:_(t),message:e}]);var y=class extends u{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},b=class extends u{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const x=`This was a Java StackOverflowError. It was probably the result
|
|
13
|
+
of an incorrect recursive function definition that caused TLC to enter
|
|
14
|
+
an infinite loop when trying to compute the function or its application
|
|
15
|
+
to an element in its putative domain.`;var S=class extends b{constructor(){super(x)}};const C=()=>n(new S,e.error);var w=class extends b{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},T=class extends b{variable;constructor(e,t){super(e),this.variable=t}},E=class extends b{exitCode;constructor(t,n=e.error){super(t),this.name=`TlaEvaluationError`,this.exitCode=n}},D=class extends b{state;constructor(e){super(`current state is not a legal state`),this.name=`TlaEvaluationError`,this.state=e}},O=class extends u{failure;exception;constructor(e,t={}){super(e),this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},k=class extends O{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e}),this.name=`TlaProofError`}},A=class extends u{constructor(e,t){super(e,t),this.name=`TlaProverError`}},j=class extends u{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},M=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}},N=class extends u{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},P=class extends u{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},F=class extends u{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},I=class extends u{constructor(e){super(e),this.name=`SmtInvariantError`}},L=class extends u{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},R=class extends u{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},z=class extends u{constructor(e,t){super(e,t),this.name=`SmtParseError`}},B=class extends N{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const V=t=>r(t)??(t instanceof d?e.specParseError:t instanceof y?e.configParseError:t instanceof b?e.specEvaluationFailure:e.error);var H=class extends u{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},U=class extends u{constructor(e){super(e),this.name=`PcalRuntimeError`}},W=class extends u{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}};const G=`node:worker_threads`,K=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,q=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
|
+
/* @vite-ignore */
|
|
17
|
+
/* webpackIgnore: true */
|
|
18
|
+
G))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},J=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
|
+
/* @vite-ignore */
|
|
20
|
+
/* webpackIgnore: true */
|
|
21
|
+
G)).parentPort;Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return g}});
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license tla-ts
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=/* @__PURE__ */ new WeakMap,n=(e,n)=>(e instanceof Error&&!t.has(e)&&t.set(e,n),e),r=e=>t.get(e),i=t=>{try{return t()}catch(t){throw n(t,e.error)}},a=e=>{let t=i(e);return t&&{branches:t.branches,addInitialState:(e,n,r)=>i(()=>t.addInitialState(e,n,r)),addState:(e,n,r,a)=>i(()=>t.addState(e,n,r,a)),findViolation:()=>i(()=>t.findViolation()),getViolatedProperties:(e,n)=>i(()=>t.getViolatedProperties(e,n))}},o=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,s=o(`java.lang.RuntimeException`),c=o(`tlc2.tool.EvalException`),l=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`;var u=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},d=class extends u{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},f=class extends d{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},p=class extends f{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const m=(e,t=!1,n,r=[])=>new d(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
|
+
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),h=(e,t)=>m([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),g=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,_=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,v=(e,t)=>m([{location:_(t),message:e}]);var y=class extends u{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},b=class extends u{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const x=`This was a Java StackOverflowError. It was probably the result
|
|
13
|
+
of an incorrect recursive function definition that caused TLC to enter
|
|
14
|
+
an infinite loop when trying to compute the function or its application
|
|
15
|
+
to an element in its putative domain.`;var S=class extends b{constructor(){super(x)}};const C=()=>n(new S,e.error);var w=class extends b{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},T=class extends b{variable;constructor(e,t){super(e),this.variable=t}},E=class extends b{exitCode;constructor(t,n=e.error){super(t),this.name=`TlaEvaluationError`,this.exitCode=n}},D=class extends b{state;constructor(e){super(`current state is not a legal state`),this.name=`TlaEvaluationError`,this.state=e}},O=class extends u{failure;exception;constructor(e,t={}){super(e),this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},k=class extends O{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e}),this.name=`TlaProofError`}},A=class extends u{constructor(e,t){super(e,t),this.name=`TlaProverError`}},j=class extends u{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},M=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}},N=class extends u{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},P=class extends u{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},F=class extends u{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},I=class extends u{constructor(e){super(e),this.name=`SmtInvariantError`}},L=class extends u{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},R=class extends u{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},z=class extends u{constructor(e,t){super(e,t),this.name=`SmtParseError`}},B=class extends N{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const V=t=>r(t)??(t instanceof d?e.specParseError:t instanceof y?e.configParseError:t instanceof b?e.specEvaluationFailure:e.error);var H=class extends u{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},U=class extends u{constructor(e){super(e),this.name=`PcalRuntimeError`}},W=class extends u{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}};const G=`node:worker_threads`,K=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,q=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
|
+
/* @vite-ignore */
|
|
17
|
+
/* webpackIgnore: true */
|
|
18
|
+
G))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},J=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
|
+
/* @vite-ignore */
|
|
20
|
+
/* webpackIgnore: true */
|
|
21
|
+
G)).parentPort;export{j as A,V as B,O as C,d as D,S as E,m as F,n as G,l as H,v as I,a as K,C as L,c as M,s as N,T as O,h as P,_ as R,E as S,f as T,e as U,o as V,r as W,D as _,W as a,B as b,R as c,I as d,z as f,b as g,u as h,L as i,k as j,N as k,x as l,y as m,K as n,H as o,P as p,q as r,U as s,J as t,F as u,w as v,A as w,p as x,M as y,g as z};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tla-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-dev.1a3acf6",
|
|
4
4
|
"description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formal verification",
|
|
@@ -54,25 +54,38 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"fflate": "^0.8.3"
|
|
59
|
+
},
|
|
57
60
|
"devDependencies": {
|
|
58
61
|
"@types/node": "^22",
|
|
59
62
|
"publint": "^0.3.0",
|
|
60
|
-
"tsx": "^4.21.0",
|
|
61
63
|
"typescript": "^7.0.2",
|
|
62
64
|
"vite-plus": "latest"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"build": "NODE_ENV=production vp pack",
|
|
66
68
|
"dev": "NODE_ENV=development vp pack --watch",
|
|
67
|
-
"bench": "pnpm build &&
|
|
68
|
-
"bench:corpus": "pnpm build &&
|
|
69
|
-
"
|
|
70
|
-
"conformance
|
|
71
|
-
"conformance:
|
|
72
|
-
"conformance:
|
|
73
|
-
"conformance:
|
|
74
|
-
"conformance:
|
|
75
|
-
"conformance:
|
|
69
|
+
"bench": "pnpm build && bun scripts/run.ts benchmark",
|
|
70
|
+
"bench:corpus": "pnpm build && bun scripts/run.ts benchmark-corpus",
|
|
71
|
+
"bench:prove": "pnpm build && bun scripts/run.ts prove-benchmark",
|
|
72
|
+
"conformance": "bun scripts/run.ts conformance",
|
|
73
|
+
"conformance:fetch": "bun scripts/run.ts fetch-corpora",
|
|
74
|
+
"conformance:fingerprint": "bun scripts/run.ts fingerprint-conformance",
|
|
75
|
+
"conformance:isabelle": "bun scripts/run.ts isabelle-conformance",
|
|
76
|
+
"conformance:isabelle-encode": "bun scripts/run.ts isabelle-encode-conformance",
|
|
77
|
+
"conformance:sany": "bun scripts/run.ts proof-conformance",
|
|
78
|
+
"conformance:ptl": "bun scripts/run.ts ptl-conformance",
|
|
79
|
+
"conformance:smt": "bun scripts/run.ts smt-conformance",
|
|
80
|
+
"conformance:record": "bun scripts/run.ts record-tlc",
|
|
81
|
+
"conformance:record-sany": "bun scripts/run.ts record-sany",
|
|
82
|
+
"conformance:record-statechart": "bun scripts/run.ts record-statechart",
|
|
83
|
+
"conformance:record-proofs": "bun scripts/run.ts record-proofs",
|
|
84
|
+
"conformance:record-tlapm": "bun scripts/run.ts record-tlapm",
|
|
85
|
+
"conformance:smt-encode": "bun scripts/run.ts smt-encode-conformance",
|
|
86
|
+
"conformance:prove": "pnpm build && bun scripts/run.ts prove-conformance",
|
|
87
|
+
"conformance:tlapm": "bun scripts/run.ts tlapm-conformance",
|
|
88
|
+
"conformance:zenon": "bun scripts/run.ts zenon-conformance",
|
|
76
89
|
"publint": "publint",
|
|
77
90
|
"test": "vp test",
|
|
78
91
|
"typecheck": "tsc --noEmit"
|
package/src/ast.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface LocalResolution {
|
|
2
2
|
kind: "Local";
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -33,20 +33,33 @@ export interface StringExpression {
|
|
|
33
33
|
location: SourceLocation;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// selectorRanges holds the range of each part of a name such as foo!lab, where SANY reports an
|
|
37
|
+
// error in selecting that part. spelling holds the text of an operator written as a synonym.
|
|
36
38
|
export interface IdentifierExpression {
|
|
37
39
|
kind: "Identifier";
|
|
38
40
|
name: string;
|
|
41
|
+
spelling?: string;
|
|
42
|
+
selectorRanges?: SourceRange[];
|
|
39
43
|
location: SourceLocation;
|
|
40
44
|
resolution?: LocalResolution;
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
// spelling holds the text of an operator written as a synonym, such as (+) for \oplus, which SANY
|
|
48
|
+
// reports as written.
|
|
43
49
|
export interface ApplyExpression {
|
|
44
50
|
kind: "Apply";
|
|
45
51
|
operator: string;
|
|
52
|
+
spelling?: string;
|
|
46
53
|
args: Expression[];
|
|
47
54
|
// The number of args each part of a name like F(x)!l(y) takes, when a part before the last takes
|
|
48
55
|
// some.
|
|
49
56
|
argumentCounts?: number[];
|
|
57
|
+
// The range of the parenthesized arguments of a named operator, or of the whole name when its
|
|
58
|
+
// last part takes none, where SANY reports their count.
|
|
59
|
+
argumentsRange?: SourceRange;
|
|
60
|
+
selectorRanges?: SourceRange[];
|
|
61
|
+
// The range of the arguments of each part of a name like F(x)!l(y), for a part that takes some.
|
|
62
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
50
63
|
location: SourceLocation;
|
|
51
64
|
resolution?: LocalResolution;
|
|
52
65
|
}
|
|
@@ -54,13 +67,18 @@ export interface ApplyExpression {
|
|
|
54
67
|
export interface OperatorReferenceExpression {
|
|
55
68
|
kind: "OperatorReference";
|
|
56
69
|
operator: string;
|
|
70
|
+
spelling?: string;
|
|
57
71
|
location: SourceLocation;
|
|
58
72
|
}
|
|
59
73
|
|
|
74
|
+
// operator holds the operator, such as SUBSET, that an argument names, which tla-ts reads as a
|
|
75
|
+
// LAMBDA.
|
|
60
76
|
export interface LambdaExpression {
|
|
61
77
|
kind: "Lambda";
|
|
62
78
|
params: string[];
|
|
79
|
+
paramRanges?: SourceRange[];
|
|
63
80
|
body: Expression;
|
|
81
|
+
operator?: string;
|
|
64
82
|
location: SourceLocation;
|
|
65
83
|
}
|
|
66
84
|
|
|
@@ -68,6 +86,9 @@ export interface JunctionExpression {
|
|
|
68
86
|
kind: "And" | "Or";
|
|
69
87
|
operands: Expression[];
|
|
70
88
|
isBulleted?: boolean;
|
|
89
|
+
// SANY parses an infix chain such as A /\ B /\ C as (A /\ B) /\ C, whose node of each prefix of
|
|
90
|
+
// two or more operands ends after the parentheses of its last operand.
|
|
91
|
+
prefixEnds?: SourceLocation[];
|
|
71
92
|
location: SourceLocation;
|
|
72
93
|
}
|
|
73
94
|
|
|
@@ -117,7 +138,10 @@ export interface LetExpression {
|
|
|
117
138
|
location: SourceLocation;
|
|
118
139
|
}
|
|
119
140
|
|
|
120
|
-
|
|
141
|
+
// ranges holds the range of each name the pattern binds.
|
|
142
|
+
export type BoundPattern =
|
|
143
|
+
| { kind: "Name"; name: string; ranges?: SourceRange[] }
|
|
144
|
+
| { kind: "Tuple"; names: string[]; ranges?: SourceRange[] };
|
|
121
145
|
|
|
122
146
|
export interface Bound {
|
|
123
147
|
pattern: BoundPattern;
|
|
@@ -135,6 +159,7 @@ export interface UnboundedQuantifierExpression {
|
|
|
135
159
|
kind: "UnboundedQuantifier";
|
|
136
160
|
quantifier: "Forall" | "Exists";
|
|
137
161
|
names: string[];
|
|
162
|
+
nameRanges?: SourceRange[];
|
|
138
163
|
isTemporal?: boolean;
|
|
139
164
|
body: Expression;
|
|
140
165
|
location: SourceLocation;
|
|
@@ -192,6 +217,7 @@ export interface FunctionSetExpression {
|
|
|
192
217
|
export interface RecordField {
|
|
193
218
|
name: string;
|
|
194
219
|
value: Expression;
|
|
220
|
+
location: SourceLocation;
|
|
195
221
|
}
|
|
196
222
|
|
|
197
223
|
export interface RecordExpression {
|
|
@@ -204,7 +230,7 @@ export type ExceptPathStep =
|
|
|
204
230
|
| { kind: "Field"; name: string }
|
|
205
231
|
| { kind: "Index"; args: Expression[] };
|
|
206
232
|
|
|
207
|
-
|
|
233
|
+
interface ExceptUpdate {
|
|
208
234
|
path: ExceptPathStep[];
|
|
209
235
|
value: Expression;
|
|
210
236
|
}
|
|
@@ -228,6 +254,14 @@ export interface FunctionApplicationExpression {
|
|
|
228
254
|
location: SourceLocation;
|
|
229
255
|
}
|
|
230
256
|
|
|
257
|
+
// SANY parses [e1, ..., en] as a function application without the function, and its semantic
|
|
258
|
+
// checker rejects it.
|
|
259
|
+
export interface BracketExpression {
|
|
260
|
+
kind: "Bracket";
|
|
261
|
+
args: Expression[];
|
|
262
|
+
location: SourceLocation;
|
|
263
|
+
}
|
|
264
|
+
|
|
231
265
|
export interface FieldAccessExpression {
|
|
232
266
|
kind: "FieldAccess";
|
|
233
267
|
record: Expression;
|
|
@@ -266,6 +300,7 @@ export interface LabelExpression {
|
|
|
266
300
|
kind: "Label";
|
|
267
301
|
name: string;
|
|
268
302
|
params: string[];
|
|
303
|
+
paramRanges?: SourceRange[];
|
|
269
304
|
body: Expression;
|
|
270
305
|
location: SourceLocation;
|
|
271
306
|
}
|
|
@@ -280,6 +315,8 @@ export type Selector =
|
|
|
280
315
|
export interface SubexpressionExpression {
|
|
281
316
|
kind: "Subexpression";
|
|
282
317
|
selectors: Selector[];
|
|
318
|
+
selectorRanges?: SourceRange[];
|
|
319
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
283
320
|
location: SourceLocation;
|
|
284
321
|
}
|
|
285
322
|
|
|
@@ -311,6 +348,7 @@ export type Expression =
|
|
|
311
348
|
| ExceptExpression
|
|
312
349
|
| ExceptAtExpression
|
|
313
350
|
| FunctionApplicationExpression
|
|
351
|
+
| BracketExpression
|
|
314
352
|
| FieldAccessExpression
|
|
315
353
|
| ProductExpression
|
|
316
354
|
| TemporalExpression
|
|
@@ -343,6 +381,8 @@ export interface FunctionDefinition {
|
|
|
343
381
|
body: Expression;
|
|
344
382
|
isLocal: boolean;
|
|
345
383
|
isRecursive: boolean;
|
|
384
|
+
// Whether the body applies the function, which SANY makes a recursive function definition.
|
|
385
|
+
isSelfReferential?: boolean;
|
|
346
386
|
location: SourceLocation;
|
|
347
387
|
}
|
|
348
388
|
|
|
@@ -363,6 +403,7 @@ export interface Assumption {
|
|
|
363
403
|
|
|
364
404
|
export interface InstanceSubstitution {
|
|
365
405
|
name: string;
|
|
406
|
+
nameRange: SourceRange;
|
|
366
407
|
expression: Expression;
|
|
367
408
|
}
|
|
368
409
|
|
|
@@ -384,6 +425,7 @@ export interface NewSymbol {
|
|
|
384
425
|
arity: number;
|
|
385
426
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
386
427
|
set: Expression | undefined;
|
|
428
|
+
nameRange?: SourceRange;
|
|
387
429
|
location: SourceLocation;
|
|
388
430
|
}
|
|
389
431
|
|
|
@@ -435,19 +477,27 @@ export type StepBody =
|
|
|
435
477
|
| Instance
|
|
436
478
|
| DefineStep
|
|
437
479
|
| { kind: "Have"; expression: Expression }
|
|
438
|
-
| { kind: "Take"; names: string[]; bounds: Bound[] }
|
|
480
|
+
| { kind: "Take"; names: string[]; nameRanges?: SourceRange[]; bounds: Bound[] }
|
|
439
481
|
| { kind: "Witness"; expressions: Expression[] }
|
|
440
|
-
| {
|
|
482
|
+
| {
|
|
483
|
+
kind: "Pick";
|
|
484
|
+
names: string[];
|
|
485
|
+
nameRanges?: SourceRange[];
|
|
486
|
+
bounds: Bound[];
|
|
487
|
+
body: Expression;
|
|
488
|
+
}
|
|
441
489
|
| { kind: "Case"; expression: Expression }
|
|
442
490
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
443
491
|
| { kind: "Qed" };
|
|
444
492
|
|
|
445
|
-
// head is the range of the step number and its statement, without the proof
|
|
493
|
+
// head is the range of the step number and its statement, without the proof, and statement is the
|
|
494
|
+
// range of the statement alone.
|
|
446
495
|
export interface ProofStep {
|
|
447
496
|
name: string | undefined;
|
|
448
497
|
token: string;
|
|
449
498
|
body: StepBody;
|
|
450
499
|
head: SourceRange;
|
|
500
|
+
statement: SourceRange;
|
|
451
501
|
proof: Proof | undefined;
|
|
452
502
|
location: SourceLocation;
|
|
453
503
|
}
|
|
@@ -461,8 +511,7 @@ export interface Theorem {
|
|
|
461
511
|
|
|
462
512
|
// The units of a module in source order, for consumers that need the order across kinds.
|
|
463
513
|
export type ModuleUnit =
|
|
464
|
-
| { kind: "Constants"; declarations: Declaration[] }
|
|
465
|
-
| { kind: "Variables"; declarations: Declaration[] }
|
|
514
|
+
| { kind: "Constants" | "Variables"; declarations: Declaration[]; location: SourceLocation }
|
|
466
515
|
| { kind: "Recursive"; declarations: Declaration[] }
|
|
467
516
|
| { kind: "Definition"; definition: Definition }
|
|
468
517
|
| { kind: "Instance"; instance: Instance }
|
|
@@ -486,3 +535,95 @@ export interface Module {
|
|
|
486
535
|
uses: UseOrHide[];
|
|
487
536
|
units: ModuleUnit[];
|
|
488
537
|
}
|
|
538
|
+
|
|
539
|
+
export const getChildren = (expression: Expression): Expression[] => {
|
|
540
|
+
switch (expression.kind) {
|
|
541
|
+
case "Number":
|
|
542
|
+
case "Decimal":
|
|
543
|
+
case "String":
|
|
544
|
+
case "Identifier":
|
|
545
|
+
case "OperatorReference":
|
|
546
|
+
case "ExceptAt":
|
|
547
|
+
return [];
|
|
548
|
+
case "Apply":
|
|
549
|
+
return expression.args;
|
|
550
|
+
case "Lambda":
|
|
551
|
+
return [expression.body];
|
|
552
|
+
case "And":
|
|
553
|
+
case "Or":
|
|
554
|
+
return expression.operands;
|
|
555
|
+
case "Prime":
|
|
556
|
+
case "Unchanged":
|
|
557
|
+
case "Enabled":
|
|
558
|
+
case "Always":
|
|
559
|
+
case "Eventually":
|
|
560
|
+
return [expression.expression];
|
|
561
|
+
case "If":
|
|
562
|
+
return [expression.condition, expression.consequent, expression.alternative];
|
|
563
|
+
case "Case":
|
|
564
|
+
return [
|
|
565
|
+
...expression.arms.flatMap((arm) => [arm.condition, arm.body]),
|
|
566
|
+
...(expression.other ? [expression.other] : []),
|
|
567
|
+
];
|
|
568
|
+
case "Let":
|
|
569
|
+
return [
|
|
570
|
+
...expression.definitions.flatMap((definition) =>
|
|
571
|
+
definition.kind === "Function"
|
|
572
|
+
? [...definition.bounds.map((bound) => bound.set), definition.body]
|
|
573
|
+
: [definition.body],
|
|
574
|
+
),
|
|
575
|
+
expression.body,
|
|
576
|
+
];
|
|
577
|
+
case "Forall":
|
|
578
|
+
case "Exists":
|
|
579
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
580
|
+
case "UnboundedQuantifier":
|
|
581
|
+
return [expression.body];
|
|
582
|
+
case "Choose":
|
|
583
|
+
return [...(expression.set ? [expression.set] : []), expression.body];
|
|
584
|
+
case "SetEnumeration":
|
|
585
|
+
case "Tuple":
|
|
586
|
+
return expression.elements;
|
|
587
|
+
case "SetFilter":
|
|
588
|
+
return [expression.bound.set, expression.predicate];
|
|
589
|
+
case "SetMap":
|
|
590
|
+
return [expression.expression, ...expression.bounds.map((bound) => bound.set)];
|
|
591
|
+
case "FunctionConstruction":
|
|
592
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
593
|
+
case "FunctionSet":
|
|
594
|
+
return [expression.domain, expression.range];
|
|
595
|
+
case "Record":
|
|
596
|
+
case "RecordSet":
|
|
597
|
+
return expression.fields.map((field) => field.value);
|
|
598
|
+
case "Except":
|
|
599
|
+
return [
|
|
600
|
+
expression.function,
|
|
601
|
+
...expression.updates.flatMap((update) => [
|
|
602
|
+
...update.path.flatMap((step) => (step.kind === "Index" ? step.args : [])),
|
|
603
|
+
update.value,
|
|
604
|
+
]),
|
|
605
|
+
];
|
|
606
|
+
case "FunctionApplication":
|
|
607
|
+
return [expression.function, ...expression.args];
|
|
608
|
+
case "Bracket":
|
|
609
|
+
return expression.args;
|
|
610
|
+
case "FieldAccess":
|
|
611
|
+
return [expression.record];
|
|
612
|
+
case "Product":
|
|
613
|
+
return expression.factors;
|
|
614
|
+
case "BoxAction":
|
|
615
|
+
case "AngleAction":
|
|
616
|
+
return [expression.action, expression.subscript];
|
|
617
|
+
case "WeakFairness":
|
|
618
|
+
case "StrongFairness":
|
|
619
|
+
return [expression.subscript, expression.action];
|
|
620
|
+
case "Label":
|
|
621
|
+
return [expression.body];
|
|
622
|
+
case "Subexpression":
|
|
623
|
+
return expression.selectors.flatMap((selector) => ("args" in selector ? selector.args : []));
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
export const isLocallyResolved = (expression: Expression) =>
|
|
628
|
+
(expression.kind === "Identifier" || expression.kind === "Apply") &&
|
|
629
|
+
expression.resolution?.kind === "Local";
|
package/src/bags.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createJavaOverrideError,
|
|
3
|
+
createModuleArgumentError,
|
|
3
4
|
createOverflowError,
|
|
4
5
|
defineConstant,
|
|
5
6
|
defineHigherOrderOperator,
|
|
@@ -32,11 +33,6 @@ const createWrongValueError = (name: string, expected: string, value: Value) =>
|
|
|
32
33
|
`Applying ${name} to the following value,\nwhich is not ${expected}:\n${formatValue(value)}`,
|
|
33
34
|
);
|
|
34
35
|
|
|
35
|
-
const createWrongArgumentError = (position: string, name: string, expected: string, value: Value) =>
|
|
36
|
-
new TlaModuleError(
|
|
37
|
-
`The ${position} argument of ${name} should be a ${expected}, but instead it is:\n${formatValue(value)}`,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
36
|
const toFunction = (value: Value) => (isFunctionValue(value) ? toFiniteFunction(value) : undefined);
|
|
41
37
|
|
|
42
38
|
const getFunction = (args: BuiltinArgument[], index: number, name: string) => {
|
|
@@ -50,7 +46,7 @@ const getBagArgument = (args: BuiltinArgument[], index: number, name: string) =>
|
|
|
50
46
|
const value = getValue(args, index, name);
|
|
51
47
|
const functionValue = toFunction(value);
|
|
52
48
|
if (!functionValue)
|
|
53
|
-
throw
|
|
49
|
+
throw createModuleArgumentError(index === 0 ? "first" : "second", name, "bag", value);
|
|
54
50
|
return functionValue;
|
|
55
51
|
};
|
|
56
52
|
|
|
@@ -67,15 +63,15 @@ const findCount = (functionValue: FunctionValue, element: Value) => {
|
|
|
67
63
|
return position === -1 ? undefined : functionValue.range[position];
|
|
68
64
|
};
|
|
69
65
|
|
|
70
|
-
const
|
|
66
|
+
const getBagsSignature = (name: string, result: string, arity: number) =>
|
|
71
67
|
`public static ${result} tlc2.module.Bags.${name}(${Array.from({ length: arity }, () => "tlc2.value.impl.Value").join(",")})`;
|
|
72
68
|
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
69
|
+
const BAG_DIFF_SIGNATURE = getBagsSignature("BagDiff", "tlc2.value.impl.Value", 2);
|
|
70
|
+
const SQ_SUBSETEQ_SIGNATURE = getBagsSignature("SqSubseteq", "tlc2.value.IBoolValue", 2);
|
|
71
|
+
const BAG_UNION_SIGNATURE = getBagsSignature("BagUnion", "tlc2.value.impl.Value", 1);
|
|
72
|
+
const BAG_OF_ALL_SIGNATURE = getBagsSignature("BagOfAll", "tlc2.value.impl.Value", 2);
|
|
73
|
+
const BAG_CUP_SIGNATURE = getBagsSignature("BagCup", "tlc2.value.impl.Value", 2);
|
|
74
|
+
const BAG_CARDINALITY_SIGNATURE = getBagsSignature("BagCardinality", "tlc2.value.impl.IntValue", 1);
|
|
79
75
|
|
|
80
76
|
// Bags.java casts each count to IntValue, so a count that isn't an integer fails with Java's
|
|
81
77
|
// ClassCastException.
|
|
@@ -123,7 +119,8 @@ const mergeBags = (bags: FunctionValue[], method: string) =>
|
|
|
123
119
|
|
|
124
120
|
const EMPTY_BAG = createSortedFunction([], []);
|
|
125
121
|
|
|
126
|
-
|
|
122
|
+
// SubBag compares the counts with the >= of Naturals, which Integers replaces when TLC loads it.
|
|
123
|
+
export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Builtin[] => [
|
|
127
124
|
defineConstant("EmptyBag", EMPTY_BAG),
|
|
128
125
|
defineOperator("IsABag", 1, (args) => {
|
|
129
126
|
const functionValue = toFunction(getValue(args, 0, "IsABag"));
|
|
@@ -136,28 +133,29 @@ export const BAGS_OPERATORS: Builtin[] = [
|
|
|
136
133
|
if (typeof count !== "number" || count <= 0) {
|
|
137
134
|
throw createWrongValueError("BagCardinality", "a bag", bag);
|
|
138
135
|
}
|
|
139
|
-
return addCounts(total, count,
|
|
136
|
+
return addCounts(total, count, BAG_CARDINALITY_SIGNATURE);
|
|
140
137
|
}, 0);
|
|
141
138
|
}),
|
|
142
139
|
defineOperator("BagIn", 2, (args) => {
|
|
143
140
|
const bag = getValue(args, 1, "BagIn");
|
|
144
141
|
const count = findCount(getFunction(args, 1, "BagIn"), getValue(args, 0, "BagIn"));
|
|
145
142
|
if (count === undefined) return false;
|
|
146
|
-
if (typeof count !== "number") throw
|
|
143
|
+
if (typeof count !== "number") throw createModuleArgumentError("second", "BagIn", "bag", bag);
|
|
147
144
|
return count > 0;
|
|
148
145
|
}),
|
|
149
146
|
defineOperator("CopiesIn", 2, (args) => {
|
|
150
147
|
const bag = getValue(args, 1, "CopiesIn");
|
|
151
148
|
const count = findCount(getFunction(args, 1, "CopiesIn"), getValue(args, 0, "CopiesIn"));
|
|
152
149
|
if (count === undefined) return 0;
|
|
153
|
-
if (typeof count !== "number")
|
|
150
|
+
if (typeof count !== "number")
|
|
151
|
+
throw createModuleArgumentError("second", "CopiesIn", "bag", bag);
|
|
154
152
|
return count;
|
|
155
153
|
}),
|
|
156
154
|
defineOperator("\\oplus", 2, (args) => {
|
|
157
155
|
const bags = [0, 1].map((index) => {
|
|
158
156
|
const functionValue = getBagArgument(args, index, "(+)");
|
|
159
157
|
if (!isBag(functionValue)) {
|
|
160
|
-
throw
|
|
158
|
+
throw createModuleArgumentError(
|
|
161
159
|
index === 0 ? "first" : "second",
|
|
162
160
|
"(+)",
|
|
163
161
|
"bag",
|
|
@@ -166,14 +164,14 @@ export const BAGS_OPERATORS: Builtin[] = [
|
|
|
166
164
|
}
|
|
167
165
|
return functionValue;
|
|
168
166
|
});
|
|
169
|
-
return mergeBags(bags,
|
|
167
|
+
return mergeBags(bags, BAG_CUP_SIGNATURE);
|
|
170
168
|
}),
|
|
171
169
|
defineOperator("\\ominus", 2, (args) => {
|
|
172
170
|
const left = getBagArgument(args, 0, "(-)");
|
|
173
171
|
const right = getBagArgument(args, 1, "(-)");
|
|
174
172
|
return createFunction(
|
|
175
173
|
left.domain.flatMap((key, index): [Value, Value][] => {
|
|
176
|
-
const count = subtractCounts(left, index, right,
|
|
174
|
+
const count = subtractCounts(left, index, right, BAG_DIFF_SIGNATURE);
|
|
177
175
|
return count > 0 ? [[key, count]] : [];
|
|
178
176
|
}),
|
|
179
177
|
);
|
|
@@ -193,12 +191,14 @@ export const BAGS_OPERATORS: Builtin[] = [
|
|
|
193
191
|
}
|
|
194
192
|
return functionValue;
|
|
195
193
|
});
|
|
196
|
-
return mergeBags(bags,
|
|
194
|
+
return mergeBags(bags, BAG_UNION_SIGNATURE);
|
|
197
195
|
}),
|
|
198
196
|
defineOperator("\\sqsubseteq", 2, (args) => {
|
|
199
197
|
const left = getFunction(args, 0, "\\sqsubseteq");
|
|
200
198
|
const right = getFunction(args, 1, "\\sqsubseteq");
|
|
201
|
-
return left.domain.every(
|
|
199
|
+
return left.domain.every(
|
|
200
|
+
(_, index) => subtractCounts(left, index, right, SQ_SUBSETEQ_SIGNATURE) <= 0,
|
|
201
|
+
);
|
|
202
202
|
}),
|
|
203
203
|
defineHigherOrderOperator("BagOfAll", 2, (args) => {
|
|
204
204
|
const operator = getOperator(args, 0, "BagOfAll");
|
|
@@ -211,13 +211,13 @@ export const BAGS_OPERATORS: Builtin[] = [
|
|
|
211
211
|
const value = getValue(args, 1, "BagOfAll");
|
|
212
212
|
const functionValue = toFunction(value);
|
|
213
213
|
if (!functionValue) {
|
|
214
|
-
throw
|
|
214
|
+
throw createModuleArgumentError("second", "BagOfAll", "function with a finite domain", value);
|
|
215
215
|
}
|
|
216
216
|
return mergeBags(
|
|
217
217
|
functionValue.domain.map((key, index) =>
|
|
218
218
|
createSortedFunction([operator.call([key])], [functionValue.range[index]]),
|
|
219
219
|
),
|
|
220
|
-
|
|
220
|
+
BAG_OF_ALL_SIGNATURE,
|
|
221
221
|
);
|
|
222
222
|
}),
|
|
223
223
|
defineOperator("SubBag", 1, (args) => {
|
|
@@ -228,12 +228,8 @@ export const BAGS_OPERATORS: Builtin[] = [
|
|
|
228
228
|
const functionValue = toFiniteFunction(value);
|
|
229
229
|
const range = createSet(functionValue.range).elements;
|
|
230
230
|
const invalid = range.find((count) => typeof count !== "number");
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
throw new TlaEvaluationError(
|
|
234
|
-
`The ${isFirst ? "first" : "second"} argument of >= should be an integer, but instead it is:\n${formatValue(isFirst ? range[0] : invalid)}`,
|
|
235
|
-
);
|
|
236
|
-
}
|
|
231
|
+
// A count that isn't an integer fails the comparison.
|
|
232
|
+
if (invalid !== undefined) builtins.get(">=")?.evaluateBinary?.(range[0], invalid);
|
|
237
233
|
const counts = functionValue.range.filter((count) => typeof count === "number");
|
|
238
234
|
if (counts.some((count) => count < 1)) {
|
|
239
235
|
throw new TlaEvaluationError(
|