tla-ts 0.0.4-dev.702eb98 → 0.0.4-dev.7714e32
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 +32 -6
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/deciders.cjs +27 -27
- package/dist/deciders.js +34 -34
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -14
- package/dist/index.d.ts +12 -14
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +516 -25
- package/dist/prove.js +518 -27
- package/dist/run.cjs +45 -0
- package/dist/run.js +45 -0
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +76 -86
- package/dist/transfer.js +73 -83
- package/dist/worker.cjs +6 -6
- package/dist/worker.js +6 -6
- package/package.json +1 -1
- package/src/ast.ts +2 -2
- package/src/bags.ts +22 -23
- package/src/builtins.ts +16 -8
- package/src/check.ts +131 -1154
- package/src/{cli-options.ts → cli/options.ts} +54 -9
- package/src/cli/run.ts +63 -0
- package/src/cli/shared.ts +106 -0
- package/src/cli/tlapm.ts +374 -0
- package/src/{run-cli.ts → cli/tlc.ts} +112 -761
- package/src/cli/xml-exporter.ts +221 -0
- package/src/cli.ts +1 -1
- package/src/codegen.ts +17 -15
- package/src/config.ts +5 -5
- package/src/dependencies.ts +4 -6
- package/src/environment.ts +55 -60
- package/src/errors.ts +12 -36
- package/src/evaluate.ts +81 -101
- package/src/exit-codes.ts +1 -1
- package/src/fingerprints.ts +3 -3
- package/src/index.ts +2 -2
- package/src/instances.ts +56 -46
- package/src/java-overrides.ts +79 -41
- package/src/json.ts +31 -36
- package/src/levels.ts +10 -13
- package/src/{live-check.ts → liveness-checker.ts} +169 -142
- package/src/liveness.ts +38 -34
- package/src/obligations/action.ts +58 -105
- package/src/obligations/{anon.ts → anonymize.ts} +44 -52
- package/src/obligations/equality.ts +260 -0
- package/src/obligations/expression.ts +42 -530
- package/src/obligations/format.ts +7 -8
- package/src/obligations/generate.ts +93 -783
- package/src/obligations/index.ts +23 -23
- package/src/obligations/levels.ts +38 -44
- package/src/obligations/module.ts +106 -729
- package/src/obligations/normalize.ts +554 -0
- package/src/obligations/operators.ts +176 -0
- package/src/obligations/pragma.ts +35 -29
- package/src/obligations/printer.ts +98 -209
- package/src/obligations/proof.ts +0 -1
- package/src/obligations/regroup.ts +100 -0
- package/src/obligations/simplify.ts +668 -0
- package/src/obligations/source.ts +92 -192
- package/src/obligations/{deref.ts → subexpression.ts} +82 -113
- package/src/obligations/substitution.ts +261 -0
- package/src/obligations/temporal.ts +32 -30
- package/src/obligations/tuples.ts +37 -53
- package/src/parallel-worker.ts +37 -33
- package/src/parallel.ts +30 -24
- package/src/parser.ts +67 -74
- package/src/{pcal-ast.ts → pcal/ast.ts} +2 -17
- package/src/{pcal-parse.ts → pcal/parse.ts} +28 -64
- package/src/{pcal-tokenize.ts → pcal/tokenize.ts} +10 -39
- package/src/{pcal-translate.ts → pcal/translate.ts} +30 -109
- package/src/{pcal-validate.ts → pcal/validate.ts} +10 -20
- package/src/{prove → prover}/decide-pool.ts +14 -19
- package/src/{prove → prover}/deciders.ts +7 -1
- package/src/{obligations/pickle.ts → prover/first-order.ts} +79 -4
- package/src/{prove → prover}/isabelle/decide.ts +3 -6
- package/src/{prove → prover}/isabelle/encode.ts +106 -138
- package/src/{prove → prover}/isabelle/isar/inner-syntax.ts +1 -1
- package/src/{prove → prover}/isabelle/isar/method.ts +3 -3
- package/src/{prove → prover}/isabelle/isar/type-check.ts +1 -1
- package/src/{prove → prover}/isabelle/provers/blast/blast.ts +1 -1
- package/src/{prove → prover}/isabelle/provers/blast/branch.ts +1 -1
- package/src/{prove → prover}/isabelle/provers/blast/term.ts +3 -4
- package/src/{prove → prover}/isabelle/provers/clasimp.ts +1 -1
- package/src/{prove → prover}/isabelle/provers/classical.ts +3 -3
- package/src/{prove → prover}/isabelle/provers/hypsubst.ts +1 -9
- package/src/{prove → prover}/isabelle/pure/conv.ts +1 -1
- package/src/{prove → prover}/isabelle/pure/drule.ts +2 -2
- package/src/{prove → prover}/isabelle/pure/envir.ts +3 -35
- package/src/{prove → prover}/isabelle/pure/logic.ts +4 -76
- package/src/{prove → prover}/isabelle/pure/name.ts +1 -13
- package/src/{prove → prover}/isabelle/pure/net.ts +2 -49
- package/src/{prove → prover}/isabelle/pure/pattern.ts +3 -22
- package/src/{prove → prover}/isabelle/pure/raw-simplifier.ts +3 -18
- package/src/{prove → prover}/isabelle/pure/seq.ts +0 -23
- package/src/{prove → prover}/isabelle/pure/simplifier.ts +2 -8
- package/src/{prove → prover}/isabelle/pure/table.ts +1 -8
- package/src/{prove → prover}/isabelle/pure/tactic.ts +5 -113
- package/src/{prove → prover}/isabelle/pure/tactical.ts +1 -84
- package/src/{prove → prover}/isabelle/pure/term-ord.ts +1 -55
- package/src/{prove → prover}/isabelle/pure/term.ts +8 -128
- package/src/{prove → prover}/isabelle/pure/thm.ts +4 -27
- package/src/{prove → prover}/isabelle/pure/type.ts +0 -12
- package/src/{prove → prover}/isabelle/pure/unify.ts +1 -1
- package/src/{prove → prover}/isabelle/tla/classical-setup.ts +1 -1
- package/src/{prove → prover}/ocaml.ts +1 -1
- package/src/{prove → prover}/prep/action.ts +54 -66
- package/src/{prove → prover}/prep/enabled-axioms.ts +2 -2
- package/src/{prove → prover}/prep/fingerprint.ts +3 -3
- package/src/{prove → prover}/prep/level-comparison.ts +15 -38
- package/src/{prove → prover}/prep/md5.ts +2 -9
- package/src/{prove/prep/pragma.ts → prover/prep/methods.ts} +4 -4
- package/src/prover/prep/normalize.ts +309 -0
- package/src/{prove → prover}/prove-worker.ts +4 -11
- package/src/prover/prove.ts +492 -0
- package/src/{prove → prover}/ptl/encode.ts +19 -31
- package/src/{prove → prover}/smt/axioms.ts +78 -79
- package/src/{prove → prover}/smt/data.ts +16 -45
- package/src/{prove → prover}/smt/encode.ts +134 -28
- package/src/{prove → prover}/smt/extensionality.ts +14 -12
- package/src/{prove → prover}/smt/flatten.ts +3 -18
- package/src/{prove → prover}/smt/format.ts +14 -3
- package/src/{prove → prover}/smt/instances.ts +4 -5
- package/src/{prove → prover}/smt/rewrite.ts +41 -59
- package/src/{prove → prover}/smt/solver/ast-util.ts +0 -56
- package/src/{prove → prover}/smt/solver/case-split-queue.ts +1 -1
- package/src/{prove → prover}/smt/solver/enode.ts +1 -1
- package/src/{prove → prover}/smt/solver/lp/dep-intervals.ts +0 -14
- package/src/{prove → prover}/smt/solver/model-macro-solver.ts +1 -1
- package/src/{prove → prover}/smt/solver/nlsat/algebraic.ts +3 -3
- package/src/{prove → prover}/smt/solver/nlsat/atoms.ts +1 -1
- package/src/{prove → prover}/smt/solver/nlsat/explain.ts +1 -1
- package/src/{prove → prover}/smt/solver/nlsat/interval-set.ts +1 -1
- package/src/{prove → prover}/smt/solver/nlsat/levelwise.ts +4 -7
- package/src/{prove → prover}/smt/solver/nlsat/polynomial.ts +4 -4
- package/src/{prove → prover}/smt/solver/nlsat/upolynomial.ts +2 -2
- package/src/{prove → prover}/smt/solver/pattern-inference.ts +1 -1
- package/src/{prove → prover}/smt/solver/relevancy.ts +2 -2
- package/src/{prove → prover}/smt/solver/rewriter.ts +1 -1
- package/src/{prove → prover}/smt/solver/solver.ts +2 -2
- package/src/prover/tlapm/cache.ts +236 -0
- package/src/prover/tlapm/ocaml-marshal.ts +166 -0
- package/src/{prove → prover}/tlapm/tlapm.ts +1 -2
- package/src/prover/verdict.ts +13 -0
- package/src/{prove → prover}/zenon/decide.ts +5 -11
- package/src/{prove → prover}/zenon/encode.ts +40 -106
- package/src/{prove → prover}/zenon/eqrel.ts +1 -1
- package/src/{prove → prover}/zenon/equality-rules.ts +1 -1
- package/src/{prove → prover}/zenon/expr.ts +2 -2
- package/src/{prove → prover}/zenon/index-table.ts +1 -1
- package/src/{prove → prover}/zenon/isar.ts +1 -1
- package/src/{prove → prover}/zenon/llproof.ts +1 -1
- package/src/{prove → prover}/zenon/mltoll.ts +1 -1
- package/src/{prove → prover}/zenon/node.ts +1 -1
- package/src/{prove → prover}/zenon/search.ts +1 -1
- package/src/{prove → prover}/zenon/tla/terms.ts +1 -20
- package/src/{prove → prover}/zenon/tla/tla.ts +1 -1
- package/src/randomization.ts +19 -24
- package/src/resolve.ts +15 -22
- package/src/runtime.ts +8 -8
- package/src/{sany-builtins.ts → sany/builtins.ts} +1 -1
- package/src/{sany-generator.ts → sany/generator.ts} +38 -55
- package/src/{sany-levels.ts → sany/levels.ts} +45 -48
- package/src/{sany-lexer.ts → sany/lexer.ts} +2 -3
- package/src/{sany-linter.ts → sany/linter.ts} +1 -1
- package/src/{sany-modules.ts → sany/modules.ts} +2 -2
- package/src/{sany-nodes.ts → sany/nodes.ts} +2 -2
- package/src/{sany-parse-error.ts → sany/parse-error.ts} +2 -2
- package/src/{sany-report.ts → sany/report.ts} +16 -17
- package/src/{sany-selectors.ts → sany/selectors.ts} +3 -5
- package/src/{sany-source.ts → sany/source.ts} +6 -7
- package/src/{sany-xml.ts → sany/xml.ts} +5 -6
- package/src/search.ts +969 -0
- package/src/spec-description.ts +26 -20
- package/src/{standard-levels.ts → standard-definitions.ts} +118 -2
- package/src/standard-modules.ts +16 -20
- package/src/state-graph.ts +9 -8
- package/src/substitution-levels.ts +2 -2
- package/src/successors.ts +16 -19
- package/src/symmetry.ts +1 -1
- package/src/tableau.ts +6 -7
- package/src/tlc/fingerprint.ts +214 -0
- package/src/{tlc-messages.ts → tlc/messages.ts} +119 -7
- package/src/{tlc-order.ts → tlc/order.ts} +7 -7
- package/src/{tlc-random.ts → tlc/random.ts} +3 -213
- package/src/{tlc-replay.ts → tlc/replay.ts} +40 -36
- package/src/{tlc-module.ts → tlc/tlc-operators.ts} +9 -9
- package/src/{tlc-ext.ts → tlc/tlcext-operators.ts} +30 -25
- package/src/transfer.ts +32 -32
- package/src/values.ts +72 -67
- package/src/worker.ts +1 -4
- package/dist/run-cli.cjs +0 -38
- package/dist/run-cli.js +0 -38
- package/src/canonical.ts +0 -40
- package/src/obligations/ctx.ts +0 -64
- package/src/prove/prep/defs.ts +0 -27
- package/src/prove/prep/elab.ts +0 -156
- package/src/prove/prep/enabled.ts +0 -43
- package/src/prove/prep/flatten.ts +0 -70
- package/src/prove/prep/trivial.ts +0 -22
- package/src/prove/prove.ts +0 -417
- package/src/prove/smt/axiomatize.ts +0 -69
- package/src/prove/smt/simplify.ts +0 -57
- package/src/prove/verdict.ts +0 -13
- package/src/standard-ranges.ts +0 -116
- package/src/value-sources.ts +0 -29
- /package/src/{prove → prover}/isabelle/LICENSE +0 -0
- /package/src/{prove → prover}/isabelle/LICENSE-tlapm +0 -0
- /package/src/{prove → prover}/isabelle/isar/proof.ts +0 -0
- /package/src/{prove → prover}/isabelle/isar/statement.ts +0 -0
- /package/src/{prove → prover}/isabelle/isar/theory.ts +0 -0
- /package/src/{prove → prover}/isabelle/provers/blast/prove.ts +0 -0
- /package/src/{prove → prover}/isabelle/provers/blast/rules.ts +0 -0
- /package/src/{prove → prover}/isabelle/provers/blast/state.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/bicompose.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/consts.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/goal.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/interrupt.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/list.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/object-logic.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/rewriter.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/search.ts +0 -0
- /package/src/{prove → prover}/isabelle/pure/variable.ts +0 -0
- /package/src/{prove → prover}/isabelle/tla/context.ts +0 -0
- /package/src/{prove → prover}/isabelle/tla/logic-data.ts +0 -0
- /package/src/{prove → prover}/isabelle/tla/logic.ts +0 -0
- /package/src/{prove → prover}/isabelle/tla/simpdata.ts +0 -0
- /package/src/{prove → prover}/isabelle/tools/intuitionistic.ts +0 -0
- /package/src/{prove → prover}/ptl/decide.ts +0 -0
- /package/src/{prove → prover}/ptl/sat.ts +0 -0
- /package/src/{prove → prover}/ptl/tableau.ts +0 -0
- /package/src/{prove → prover}/smt/context.ts +0 -0
- /package/src/{prove → prover}/smt/solver/act-cache.ts +0 -0
- /package/src/{prove → prover}/smt/solver/arith-rewriter.ts +0 -0
- /package/src/{prove → prover}/smt/solver/array.ts +0 -0
- /package/src/{prove → prover}/smt/solver/asserted-formulas.ts +0 -0
- /package/src/{prove → prover}/smt/solver/ast-lt.ts +0 -0
- /package/src/{prove → prover}/smt/solver/ast.ts +0 -0
- /package/src/{prove → prover}/smt/solver/auf-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/cg-table.ts +0 -0
- /package/src/{prove → prover}/smt/solver/clause.ts +0 -0
- /package/src/{prove → prover}/smt/solver/conflict-resolution.ts +0 -0
- /package/src/{prove → prover}/smt/solver/context.ts +0 -0
- /package/src/{prove → prover}/smt/solver/ctx-simplify.ts +0 -0
- /package/src/{prove → prover}/smt/solver/der.ts +0 -0
- /package/src/{prove → prover}/smt/solver/dyn-ack.ts +0 -0
- /package/src/{prove → prover}/smt/solver/e-matching.ts +0 -0
- /package/src/{prove → prover}/smt/solver/expr-ref.ts +0 -0
- /package/src/{prove → prover}/smt/solver/expr-safe-replace.ts +0 -0
- /package/src/{prove → prover}/smt/solver/fingerprints.ts +0 -0
- /package/src/{prove → prover}/smt/solver/flat-literals.ts +0 -0
- /package/src/{prove → prover}/smt/solver/goal.ts +0 -0
- /package/src/{prove → prover}/smt/solver/hash.ts +0 -0
- /package/src/{prove → prover}/smt/solver/hashtable.ts +0 -0
- /package/src/{prove → prover}/smt/solver/internalizer.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lbool.ts +0 -0
- /package/src/{prove → prover}/smt/solver/literal.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/bound-propagator.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/constraints.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/containers.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/core-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/cross-nested.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/dependency.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/dioph-eq.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/explanation.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/gomory.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/hnf-cutter.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/hnf.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/int-cube.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/int-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/lar-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/lar-term.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/lp-settings.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/maximize-term.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nex-creator.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nex.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-backoff.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-basics.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-core.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-divisions.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-emonics.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-factorization.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-grobner.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-horner.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-intervals.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-monomial-bounds.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-monotone.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-order.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-patcher.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-tangents.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-throttle.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-types.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nla-var-eqs.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/nra-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/numeric-pair.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/pdd-interval.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/pdd-simplifier.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/pdd-solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/pdd.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/random-updater.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/static-matrix.ts +0 -0
- /package/src/{prove → prover}/smt/solver/lp/union-find.ts +0 -0
- /package/src/{prove → prover}/smt/solver/mam-compiler.ts +0 -0
- /package/src/{prove → prover}/smt/solver/mam-interpreter.ts +0 -0
- /package/src/{prove → prover}/smt/solver/maximize-ac-sharing.ts +0 -0
- /package/src/{prove → prover}/smt/solver/model-checker.ts +0 -0
- /package/src/{prove → prover}/smt/solver/model-evaluator.ts +0 -0
- /package/src/{prove → prover}/smt/solver/model-finder.ts +0 -0
- /package/src/{prove → prover}/smt/solver/model-generator.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nlsat/evaluator.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nlsat/mpbq.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nlsat/solver.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nlsat/types.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nlsat/upolynomial-factorization.ts +0 -0
- /package/src/{prove → prover}/smt/solver/nnf.ts +0 -0
- /package/src/{prove → prover}/smt/solver/poly-rewriter.ts +0 -0
- /package/src/{prove → prover}/smt/solver/propagate-values.ts +0 -0
- /package/src/{prove → prover}/smt/solver/proto-model.ts +0 -0
- /package/src/{prove → prover}/smt/solver/pull-quant.ts +0 -0
- /package/src/{prove → prover}/smt/solver/qe-lite-der.ts +0 -0
- /package/src/{prove → prover}/smt/solver/qe-lite-fm.ts +0 -0
- /package/src/{prove → prover}/smt/solver/qe-lite.ts +0 -0
- /package/src/{prove → prover}/smt/solver/qi-queue.ts +0 -0
- /package/src/{prove → prover}/smt/solver/quant-tactics.ts +0 -0
- /package/src/{prove → prover}/smt/solver/quantifier-analyzer.ts +0 -0
- /package/src/{prove → prover}/smt/solver/quantifier-manager.ts +0 -0
- /package/src/{prove → prover}/smt/solver/random-gen.ts +0 -0
- /package/src/{prove → prover}/smt/solver/rational.ts +0 -0
- /package/src/{prove → prover}/smt/solver/ref-vector.ts +0 -0
- /package/src/{prove → prover}/smt/solver/rewriter-tpl.ts +0 -0
- /package/src/{prove → prover}/smt/solver/rlimit.ts +0 -0
- /package/src/{prove → prover}/smt/solver/smtlib-parser.ts +0 -0
- /package/src/{prove → prover}/smt/solver/sort.ts +0 -0
- /package/src/{prove → prover}/smt/solver/sticky-generations.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-axioms.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-bounds.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-final-check.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-internalize.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-model.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-propagate.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra-state.ts +0 -0
- /package/src/{prove → prover}/smt/solver/theory-lra.ts +0 -0
- /package/src/{prove → prover}/smt/solver/var-subst.ts +0 -0
- /package/src/{prove → prover}/smt/solver/z3-license.txt +0 -0
- /package/src/{prove → prover}/smt/table.ts +0 -0
- /package/src/{prove → prover}/tlaps-module.ts +0 -0
- /package/src/{prove → prover}/zenon/LICENSE +0 -0
- /package/src/{prove → prover}/zenon/check/check.ts +0 -0
- /package/src/{prove → prover}/zenon/check/definitions.ts +0 -0
- /package/src/{prove → prover}/zenon/check/equality.ts +0 -0
- /package/src/{prove → prover}/zenon/check/functions.ts +0 -0
- /package/src/{prove → prover}/zenon/check/keys.ts +0 -0
- /package/src/{prove → prover}/zenon/check/propositional.ts +0 -0
- /package/src/{prove → prover}/zenon/check/records.ts +0 -0
- /package/src/{prove → prover}/zenon/check/relations.ts +0 -0
- /package/src/{prove → prover}/zenon/check/rewrites.ts +0 -0
- /package/src/{prove → prover}/zenon/check/sets.ts +0 -0
- /package/src/{prove → prover}/zenon/check/terms.ts +0 -0
- /package/src/{prove → prover}/zenon/check/tla.ts +0 -0
- /package/src/{prove → prover}/zenon/isar-case.ts +0 -0
- /package/src/{prove → prover}/zenon/limits.ts +0 -0
- /package/src/{prove → prover}/zenon/ocaml.ts +0 -0
- /package/src/{prove → prover}/zenon/parse.ts +0 -0
- /package/src/{prove → prover}/zenon/phrase.ts +0 -0
- /package/src/{prove → prover}/zenon/proof.ts +0 -0
- /package/src/{prove → prover}/zenon/propositional-rules.ts +0 -0
- /package/src/{prove → prover}/zenon/rules.ts +0 -0
- /package/src/{prove → prover}/zenon/tla/functions.ts +0 -0
- /package/src/{prove → prover}/zenon/tla/llproof.ts +0 -0
- /package/src/{prove → prover}/zenon/tla/records.ts +0 -0
- /package/src/{prove → prover}/zenon/tla/rewrites.ts +0 -0
- /package/src/{prove → prover}/zenon/tla/sets.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
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
existsSync,
|
|
3
|
-
globSync,
|
|
4
3
|
mkdirSync,
|
|
5
4
|
readFileSync,
|
|
6
5
|
readSync,
|
|
7
6
|
realpathSync,
|
|
8
7
|
writeFileSync,
|
|
9
8
|
} from "node:fs";
|
|
10
|
-
import { basename,
|
|
9
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
11
10
|
import { arch, availableParallelism, release, tmpdir, type } from "node:os";
|
|
12
11
|
import { pathToFileURL } from "node:url";
|
|
13
12
|
import { getHeapStatistics } from "node:v8";
|
|
14
|
-
import { version } from "
|
|
15
|
-
import type { Expression } from "
|
|
16
|
-
import { describeRange } from "
|
|
13
|
+
import { version } from "../../package.json";
|
|
14
|
+
import type { Expression } from "../ast";
|
|
15
|
+
import { describeRange } from "../evaluate";
|
|
17
16
|
import type {
|
|
18
17
|
CheckProgress,
|
|
19
18
|
InitialStateViolation,
|
|
@@ -24,55 +23,58 @@ import type {
|
|
|
24
23
|
SearchStatistics,
|
|
25
24
|
TraceStep,
|
|
26
25
|
Violation,
|
|
27
|
-
} from "
|
|
28
|
-
import {
|
|
29
|
-
import { parseConfig } from "./config";
|
|
26
|
+
} from "../check";
|
|
27
|
+
import { parseConfig } from "../config";
|
|
30
28
|
import {
|
|
31
29
|
getErrorExitCode,
|
|
32
30
|
TlaConfigError,
|
|
33
31
|
TlaError,
|
|
34
32
|
TlaEvaluationError,
|
|
35
|
-
TlaProofError,
|
|
36
33
|
TlaSyntaxError,
|
|
37
34
|
getUnexpectedException,
|
|
38
|
-
TlaJavaException,
|
|
39
35
|
UNEXPECTED_EXCEPTION,
|
|
40
36
|
TlaSanyFatalError,
|
|
41
|
-
|
|
42
|
-
} from "
|
|
43
|
-
import {
|
|
44
|
-
import
|
|
45
|
-
import {
|
|
46
|
-
import { formatSummary, getObligations, WHOLE_MODULE, type ModuleObligations } from "./obligations";
|
|
47
|
-
import { check } from "./parallel";
|
|
48
|
-
import { parseModule } from "./parser";
|
|
49
|
-
import { isProveBackend, prove, PROVE_BACKENDS, type ProofStatus } from "./prove/prove";
|
|
50
|
-
import type { StateDump } from "./state-graph";
|
|
37
|
+
} from "../errors";
|
|
38
|
+
import { EXIT_STATUS, setExitCode } from "../exit-codes";
|
|
39
|
+
import { check } from "../parallel";
|
|
40
|
+
import { parseModule } from "../parser";
|
|
41
|
+
import type { StateDump } from "../state-graph";
|
|
51
42
|
import {
|
|
52
43
|
formatProbability,
|
|
53
44
|
getActualProbability,
|
|
54
45
|
getOptimisticProbability,
|
|
55
46
|
getOutDegreeSummary,
|
|
56
|
-
} from "
|
|
57
|
-
import {
|
|
58
|
-
import type
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import { exportSanyXml, XML_EXPORT_EXIT_CODE, type XmlExportOptions } from "./sany-xml";
|
|
62
|
-
import { getTlcFingerprint } from "./tlc-random";
|
|
63
|
-
import { getTlcVersion, type TlcVersion } from "./tlc-version";
|
|
47
|
+
} from "../tlc/summary";
|
|
48
|
+
import { SANY_174_STANDARD_MODULES, SANY_STANDARD_MODULES } from "../sany/modules";
|
|
49
|
+
import { getSanyReport, type SanyModuleOrigin } from "../sany/report";
|
|
50
|
+
import { getTlcFingerprint } from "../tlc/fingerprint";
|
|
51
|
+
import type { TlcVersion } from "../tlc/version";
|
|
64
52
|
import {
|
|
65
53
|
createMessagePrinter,
|
|
66
54
|
formatTlcDate,
|
|
67
55
|
formatInnerMessage,
|
|
68
56
|
formatNestedMessage,
|
|
69
57
|
formatTlcDuration,
|
|
70
|
-
getCodedMessage,
|
|
71
58
|
MESSAGE_CODE,
|
|
72
59
|
MESSAGE_LEVEL,
|
|
73
60
|
type MessagePrinter,
|
|
74
|
-
} from "
|
|
75
|
-
import { formatState } from "
|
|
61
|
+
} from "../tlc/messages";
|
|
62
|
+
import { formatState } from "../values";
|
|
63
|
+
import { CHECK_COMMAND, USAGE, type ParsedArgs } from "./options";
|
|
64
|
+
import {
|
|
65
|
+
createModuleLoader,
|
|
66
|
+
findModuleFile,
|
|
67
|
+
getInputPaths,
|
|
68
|
+
getToolsJar,
|
|
69
|
+
getStandardModulesUrl,
|
|
70
|
+
printError,
|
|
71
|
+
printMissingFile,
|
|
72
|
+
printMissingFile174,
|
|
73
|
+
reportErrors,
|
|
74
|
+
reportMissingModules174,
|
|
75
|
+
toLibraryPath,
|
|
76
|
+
type JavaProperties,
|
|
77
|
+
} from "./shared";
|
|
76
78
|
|
|
77
79
|
const EXIT_CODES: Record<CheckStatus, number> = {
|
|
78
80
|
success: EXIT_STATUS.success,
|
|
@@ -85,116 +87,6 @@ const EXIT_CODES: Record<CheckStatus, number> = {
|
|
|
85
87
|
error: EXIT_STATUS.error,
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
const CHECK_COMMAND = defineCommand("tla-ts <Spec.tla|Spec.cfg|glob>... {options}", [
|
|
89
|
-
{ flag: "-config <Spec.cfg>" },
|
|
90
|
-
{ flag: "-deadlock" },
|
|
91
|
-
// Like TLC, -dump takes a format only when the next argument starts with dot and a file follows.
|
|
92
|
-
{
|
|
93
|
-
flag: "-dump [<format>] <file>",
|
|
94
|
-
getArity: (rest) => (rest.length > 1 && rest[0].startsWith("dot") ? 2 : 1),
|
|
95
|
-
},
|
|
96
|
-
{ flag: "-fp <num>" },
|
|
97
|
-
{ flag: "-lncheck <final|default>" },
|
|
98
|
-
{ flag: "-metadir <directory>" },
|
|
99
|
-
{ flag: "-nowarning" },
|
|
100
|
-
{ flag: "-seed <num>" },
|
|
101
|
-
{ flag: "-tool" },
|
|
102
|
-
{ flag: "-workers <count|auto>" },
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
const OBLIGATIONS_COMMAND = defineCommand("tla-ts prove {options} <Module.tla|glob>...", [
|
|
106
|
-
{ flag: "-N", isRequired: true },
|
|
107
|
-
{ flag: "--toolbox <start> <end>" },
|
|
108
|
-
{ flag: "--line <num>" },
|
|
109
|
-
{ flag: "--printallobs" },
|
|
110
|
-
{ flag: "--summary" },
|
|
111
|
-
{ flag: "--strict" },
|
|
112
|
-
{ flag: "-I <directory>", isRepeatable: true },
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
const PROVE_COMMAND = defineCommand("tla-ts prove {options} <Module.tla|glob>...", [
|
|
116
|
-
{ flag: `--backend <${PROVE_BACKENDS.join("|")}>` },
|
|
117
|
-
{ flag: "-I <directory>", isRepeatable: true },
|
|
118
|
-
{ flag: "-workers <count|auto>" },
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
|
-
const XML_EXPORT_FLAGS = new Set(["-o", "-t", "-r", "-u"]);
|
|
122
|
-
|
|
123
|
-
const XML_EXPORT_174_FLAGS = new Set(["-o"]);
|
|
124
|
-
|
|
125
|
-
// The usage that XMLExporter.printUsage prints with UsageGenerator.
|
|
126
|
-
const XML_EXPORT_USAGE = (() => {
|
|
127
|
-
const bold = (text: string) => `\x1b[1m${text}\x1b[0m`;
|
|
128
|
-
const options = [
|
|
129
|
-
["-I", "Include; use given directory path to resolve module dependencies."],
|
|
130
|
-
["-help", "Print this usage information."],
|
|
131
|
-
["-o", "Offline mode; skip XML schema validation step."],
|
|
132
|
-
[
|
|
133
|
-
"-r",
|
|
134
|
-
"Restrict mode; include only declarations and definitions of the specified module, excluding extended or instantiated modules.",
|
|
135
|
-
],
|
|
136
|
-
["-t", "Terse; format XML output without tabs or newlines."],
|
|
137
|
-
[
|
|
138
|
-
"-u",
|
|
139
|
-
"Uncomment; process boxed comments and single-line comments (\\*) in pre-comments to extract their content.",
|
|
140
|
-
],
|
|
141
|
-
];
|
|
142
|
-
const tips = [
|
|
143
|
-
"Only one root TLA+ file can be parsed per run.",
|
|
144
|
-
"Multiple directory search paths can be given by providing multiple -I arguments.",
|
|
145
|
-
"XML schema validation does not require network access.",
|
|
146
|
-
];
|
|
147
|
-
return [
|
|
148
|
-
"",
|
|
149
|
-
bold("NAME"),
|
|
150
|
-
"",
|
|
151
|
-
"\ttla2sany.xml.XMLExporter - Emit SANY's parse tree as XML - Version 2.2 created 08 July 2020",
|
|
152
|
-
"",
|
|
153
|
-
"",
|
|
154
|
-
bold("SYNOPSIS"),
|
|
155
|
-
"",
|
|
156
|
-
`\t${bold("tla2sany.xml.XMLExporter")} [${bold("-Iortu")}] [${bold("-help")}] FILE`,
|
|
157
|
-
"",
|
|
158
|
-
bold("DESCRIPTION"),
|
|
159
|
-
"",
|
|
160
|
-
"\tGiven a TLA+ file, parse that file with SANY then translate the module's semantic parse tree to XML, including all the modules depended on. The XML is printed to stdout and its output format is given by an XML Schema file (.xsd) found at https://proofs.tlapl.us/doc/web/sany.xsd.",
|
|
161
|
-
"",
|
|
162
|
-
bold("OPTIONS"),
|
|
163
|
-
"",
|
|
164
|
-
...options.map(([flag, description]) => `\t${bold(flag)}\n\t\t${description}`),
|
|
165
|
-
"",
|
|
166
|
-
bold("TIPS"),
|
|
167
|
-
"",
|
|
168
|
-
...tips.flatMap((tip) => [`\t${tip}`, ""]),
|
|
169
|
-
"",
|
|
170
|
-
].join("\n");
|
|
171
|
-
})();
|
|
172
|
-
|
|
173
|
-
const USAGE = [
|
|
174
|
-
`Usage: ${CHECK_COMMAND.usage}`,
|
|
175
|
-
` ${PROVE_COMMAND.usage}`,
|
|
176
|
-
` ${OBLIGATIONS_COMMAND.usage}`,
|
|
177
|
-
" tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>",
|
|
178
|
-
" (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)",
|
|
179
|
-
" tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>",
|
|
180
|
-
].join("\n");
|
|
181
|
-
|
|
182
|
-
const GLOB_CHARACTERS = /[*?[{]/;
|
|
183
|
-
|
|
184
|
-
interface InputPath {
|
|
185
|
-
path: string;
|
|
186
|
-
isGlobbed: boolean;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const getInputPaths = (paths: string[]): InputPath[] =>
|
|
190
|
-
paths.flatMap((arg): InputPath[] =>
|
|
191
|
-
GLOB_CHARACTERS.test(arg)
|
|
192
|
-
? globSync(arg)
|
|
193
|
-
.sort()
|
|
194
|
-
.map((path) => ({ path, isGlobbed: true }))
|
|
195
|
-
: [{ path: arg, isGlobbed: false }],
|
|
196
|
-
);
|
|
197
|
-
|
|
198
90
|
const isJavaLong = (text: string) =>
|
|
199
91
|
/^[+-]?\d+$/.test(text) && BigInt.asIntN(64, BigInt(text)) === BigInt(text);
|
|
200
92
|
|
|
@@ -211,7 +103,7 @@ const UNSUPPORTED_DUMP_FORMATS = ["constrained", "stuttering", "strict"];
|
|
|
211
103
|
const getDumpPath = (path: string, extension: string) =>
|
|
212
104
|
path.endsWith(extension) ? path : `${path}${extension}`;
|
|
213
105
|
|
|
214
|
-
const
|
|
106
|
+
const getStateDump = (values: string[]): StateDump => {
|
|
215
107
|
if (values.length === 1) return { path: getDumpPath(values[0], ".dump") };
|
|
216
108
|
const format = values[0].toLowerCase();
|
|
217
109
|
return {
|
|
@@ -223,7 +115,6 @@ const getDump = (values: string[]): StateDump => {
|
|
|
223
115
|
};
|
|
224
116
|
};
|
|
225
117
|
|
|
226
|
-
// What the spec prints as TLC rebuilds a trace, before it prints the states or after.
|
|
227
118
|
const printInitialStatesProgress = (printer: MessagePrinter, count: number) =>
|
|
228
119
|
printer.print(
|
|
229
120
|
MESSAGE_CODE.computingInitProgress,
|
|
@@ -245,6 +136,7 @@ const getInitialViolationHeadline = (
|
|
|
245
136
|
text: `Property ${name} is violated by the initial state:`,
|
|
246
137
|
};
|
|
247
138
|
|
|
139
|
+
// What the spec prints as TLC rebuilds a trace, before it prints the states or after.
|
|
248
140
|
const printTraceOutput = (printer: MessagePrinter, lines: OutputLine[] | undefined) =>
|
|
249
141
|
lines?.forEach((line) => {
|
|
250
142
|
if (typeof line === "string") return console.log(line);
|
|
@@ -336,35 +228,32 @@ const printInitialStates = (printer: MessagePrinter, initialStates: InitialState
|
|
|
336
228
|
};
|
|
337
229
|
|
|
338
230
|
interface Timing {
|
|
339
|
-
|
|
231
|
+
startTime: number;
|
|
340
232
|
// Whether TLC has printed that SANY finished.
|
|
341
233
|
isParsed: boolean;
|
|
342
|
-
|
|
343
|
-
liveness: number | undefined;
|
|
234
|
+
livenessStartTime: number | undefined;
|
|
344
235
|
}
|
|
345
236
|
|
|
346
|
-
// TLC reports
|
|
347
|
-
//
|
|
348
|
-
// states it generated and found a minute.
|
|
237
|
+
// TLC reports a depth of at least 1, even before it finds a state, and rates a minute only once the
|
|
238
|
+
// search has started.
|
|
349
239
|
const printProgress = (
|
|
350
240
|
printer: MessagePrinter,
|
|
351
241
|
statistics: SearchStatistics,
|
|
352
242
|
startTime?: number,
|
|
353
243
|
) => {
|
|
354
244
|
const minutes = Math.max(Date.now() - (startTime ?? 0), 1) / 60_000;
|
|
355
|
-
const
|
|
245
|
+
const formatCount = (count: number) => count.toLocaleString("en-US");
|
|
356
246
|
const getRate = (count: number, unit: string) =>
|
|
357
|
-
startTime === undefined ? "" : ` (${
|
|
247
|
+
startTime === undefined ? "" : ` (${formatCount(Math.floor(count / minutes))} ${unit}/min)`;
|
|
358
248
|
printer.print(
|
|
359
249
|
MESSAGE_CODE.progress,
|
|
360
250
|
MESSAGE_LEVEL.none,
|
|
361
|
-
`Progress(${Math.max(statistics.depth, 1)}) at ${formatTlcDate(new Date())}: ${
|
|
251
|
+
`Progress(${Math.max(statistics.depth, 1)}) at ${formatTlcDate(new Date())}: ${formatCount(statistics.generatedStates)} states generated${getRate(statistics.generatedStates, "s")}, ${formatCount(statistics.distinctStates)} distinct states found${getRate(statistics.distinctStates, "ds")}, ${formatCount(statistics.queuedStates)} states left on queue.`,
|
|
362
252
|
);
|
|
363
253
|
};
|
|
364
254
|
|
|
365
255
|
const getClassPath = (directory: string, module: string) => join(directory, `${module}.class`);
|
|
366
256
|
|
|
367
|
-
// The messages TLC prints as the search goes.
|
|
368
257
|
const printCheckProgress = (
|
|
369
258
|
printer: MessagePrinter,
|
|
370
259
|
progress: CheckProgress,
|
|
@@ -443,10 +332,10 @@ const printCheckProgress = (
|
|
|
443
332
|
printInitialStates(printer, progress.initialStates);
|
|
444
333
|
return;
|
|
445
334
|
case "progress":
|
|
446
|
-
printProgress(printer, progress.statistics, timing.
|
|
335
|
+
printProgress(printer, progress.statistics, timing.startTime);
|
|
447
336
|
return;
|
|
448
337
|
case "liveness-started": {
|
|
449
|
-
timing.
|
|
338
|
+
timing.livenessStartTime = Date.now();
|
|
450
339
|
// TLC reports how far the search got before it checks the complete state graph.
|
|
451
340
|
if (progress.isComplete) printProgress(printer, progress.statistics);
|
|
452
341
|
const branches = progress.branches > 1 ? `${progress.branches} branches of ` : "";
|
|
@@ -468,13 +357,13 @@ const printCheckProgress = (
|
|
|
468
357
|
};
|
|
469
358
|
|
|
470
359
|
const printLivenessEnd = (printer: MessagePrinter, timing: Timing) => {
|
|
471
|
-
if (timing.
|
|
360
|
+
if (timing.livenessStartTime === undefined) return;
|
|
472
361
|
printer.print(
|
|
473
362
|
MESSAGE_CODE.checkingTemporalEnd,
|
|
474
363
|
MESSAGE_LEVEL.none,
|
|
475
|
-
`Finished checking temporal properties in ${formatTlcDuration(Date.now() - timing.
|
|
364
|
+
`Finished checking temporal properties in ${formatTlcDuration(Date.now() - timing.livenessStartTime)} at ${formatTlcDate(new Date())}`,
|
|
476
365
|
);
|
|
477
|
-
timing.
|
|
366
|
+
timing.livenessStartTime = undefined;
|
|
478
367
|
};
|
|
479
368
|
|
|
480
369
|
// Prints a violation, and returns whether TLC goes on to print the statistics of the search.
|
|
@@ -645,8 +534,8 @@ const printResult = (result: CheckResult, printer: MessagePrinter, timing: Timin
|
|
|
645
534
|
if (!printViolation(result.status, result.violation, printer)) return;
|
|
646
535
|
// TLC adds a deadlocked state to the behavior graph after it reports the deadlock, which can
|
|
647
536
|
// violate a temporal property too.
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
537
|
+
const additionalViolation = result.additionalViolation;
|
|
538
|
+
if (additionalViolation) printViolation("property-violation", additionalViolation, printer);
|
|
650
539
|
if (result.liveCallStack) printNestedExpressions(printer, result.liveCallStack);
|
|
651
540
|
} else {
|
|
652
541
|
printLivenessEnd(printer, timing);
|
|
@@ -671,7 +560,7 @@ const printResult = (result: CheckResult, printer: MessagePrinter, timing: Timin
|
|
|
671
560
|
}
|
|
672
561
|
if (result.failure?.isWithoutStatistics) return;
|
|
673
562
|
if (result.status !== "success") printLivenessEnd(printer, timing);
|
|
674
|
-
if (printer.isTool) printProgress(printer, result, timing.
|
|
563
|
+
if (printer.isTool) printProgress(printer, result, timing.startTime);
|
|
675
564
|
print(
|
|
676
565
|
MESSAGE_CODE.stats,
|
|
677
566
|
MESSAGE_LEVEL.none,
|
|
@@ -692,25 +581,6 @@ const printResult = (result: CheckResult, printer: MessagePrinter, timing: Timin
|
|
|
692
581
|
if (outDegree) print(MESSAGE_CODE.stateGraphOutdegree, MESSAGE_LEVEL.none, outDegree);
|
|
693
582
|
};
|
|
694
583
|
|
|
695
|
-
// Like TLC, tla-ts finds a module in the directory of the spec, then in each library directory.
|
|
696
|
-
const findModuleFile = (directories: string[], name: string) =>
|
|
697
|
-
directories.map((directory) => join(directory, `${name}.tla`)).find(existsSync);
|
|
698
|
-
|
|
699
|
-
const createModuleLoader = (directories: string[]) => (name: string) => {
|
|
700
|
-
const path = findModuleFile(directories, name);
|
|
701
|
-
return path === undefined ? undefined : readFileSync(path, "utf8");
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
// SimpleFilenameToStream: SANY names the file of a module it can't find, and where it looked.
|
|
705
|
-
const printMissingFile = (userDirectory: string, fileName: string, directories: string[]) =>
|
|
706
|
-
console.error(
|
|
707
|
-
`File does not exist: ${userDirectory}/${fileName} while looking in these directories: ${userDirectory}, ${directories.join(", ")}, classpath:/tla2sany/StandardModules, classpath:/`,
|
|
708
|
-
);
|
|
709
|
-
|
|
710
|
-
// The URL of the directory of SANY's standard modules in a tla2tools.jar.
|
|
711
|
-
const getStandardModulesUrl = (jar: string) =>
|
|
712
|
-
`jar:file:${pathToFileURL(resolve(jar)).pathname}!/tla2sany/StandardModules/`;
|
|
713
|
-
|
|
714
584
|
// Java's Files.createTempDirectory names a directory by a random unsigned long. tla-ts derives it
|
|
715
585
|
// from TLC's fingerprint of what the directory holds, so that each run of a spec prints the same
|
|
716
586
|
// files.
|
|
@@ -729,7 +599,7 @@ const createFileDescriber = (
|
|
|
729
599
|
const temporary = java.temporaryDirectory ?? tmpdir();
|
|
730
600
|
const temporaryDirectory = existsSync(temporary) ? realpathSync(temporary) : resolve(temporary);
|
|
731
601
|
const libraryDirectory = join(temporaryDirectory, `tlc-${getTemporaryName(resolve(specPath))}`);
|
|
732
|
-
const jar =
|
|
602
|
+
const jar = getToolsJar(java);
|
|
733
603
|
return (name: string, origin: SanyModuleOrigin) => {
|
|
734
604
|
const fileName = `${name}.tla`;
|
|
735
605
|
if (origin === "file") return realpathSync(findModuleFile(directories, name) ?? specPath);
|
|
@@ -774,12 +644,12 @@ const printStartupBanner = (printer: MessagePrinter, seed: string, workers: numb
|
|
|
774
644
|
// -noGenerateSpecTEBin and -noTEBin turn off the binary trace. TLC 1.7.4 records no such trace.
|
|
775
645
|
const isTraceRecorded = (args: ParsedArgs, version: TlcVersion) => {
|
|
776
646
|
const flags = [...args.unknown, ...args.options.map((option) => option.name)];
|
|
777
|
-
const
|
|
647
|
+
const hasFlag = (name: string, alias = name) =>
|
|
778
648
|
flags.some((flag) => flag === name || flag.toLowerCase() === alias.toLowerCase());
|
|
779
649
|
const isSpecGenerated =
|
|
780
|
-
|
|
781
|
-
(!
|
|
782
|
-
return version !== "1.7.4" && isSpecGenerated && !
|
|
650
|
+
hasFlag("-generateSpecTE") ||
|
|
651
|
+
(!hasFlag("-noGenerateSpecTE", "-noTE") && !hasFlag("-tool") && !hasFlag("-continue"));
|
|
652
|
+
return version !== "1.7.4" && isSpecGenerated && !hasFlag("-noGenerateSpecTEBin", "-noTEBin");
|
|
783
653
|
};
|
|
784
654
|
|
|
785
655
|
const checkSpec = async (
|
|
@@ -815,11 +685,10 @@ const checkSpec = async (
|
|
|
815
685
|
console.error(`Error: tla-ts does not support the -dump format ${unsupportedFormat}.`);
|
|
816
686
|
return 1;
|
|
817
687
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
if (fingerprint !== undefined && Number(fingerprint) !== 0) {
|
|
688
|
+
const fingerprintIndex = args.get("-fp")?.[0];
|
|
689
|
+
if (fingerprintIndex !== undefined && Number(fingerprintIndex) !== 0) {
|
|
821
690
|
console.error(
|
|
822
|
-
`Error: tla-ts fingerprints states as TLC does with -fp 0, not -fp ${
|
|
691
|
+
`Error: tla-ts fingerprints states as TLC does with -fp 0, not -fp ${fingerprintIndex}.`,
|
|
823
692
|
);
|
|
824
693
|
return 1;
|
|
825
694
|
}
|
|
@@ -839,10 +708,10 @@ const checkSpec = async (
|
|
|
839
708
|
return EXIT_STATUS.configParseError;
|
|
840
709
|
}
|
|
841
710
|
const fileName = basename(specPath, ".tla");
|
|
842
|
-
const timing: Timing = {
|
|
711
|
+
const timing: Timing = { startTime: Date.now(), livenessStartTime: undefined, isParsed: false };
|
|
843
712
|
// Without -tool, TLC prints how long it ran for a person to read.
|
|
844
713
|
const printFinished = () => {
|
|
845
|
-
const runtime = Date.now() - timing.
|
|
714
|
+
const runtime = Date.now() - timing.startTime;
|
|
846
715
|
printer.print(
|
|
847
716
|
MESSAGE_CODE.finished,
|
|
848
717
|
MESSAGE_LEVEL.none,
|
|
@@ -891,44 +760,6 @@ const checkSpec = async (
|
|
|
891
760
|
const directories = [directory, ...java.libraries];
|
|
892
761
|
const loadModule = createModuleLoader(directories);
|
|
893
762
|
const isRecorded = isTraceRecorded(args, version);
|
|
894
|
-
const run = async () => {
|
|
895
|
-
const source = readFileSync(specPath, "utf8");
|
|
896
|
-
const moduleName = parseModule(source).name;
|
|
897
|
-
if (moduleName !== fileName) {
|
|
898
|
-
throw new TlaSanyFatalError(
|
|
899
|
-
`File name '${fileName}' does not match the name '${moduleName}' of the top level module it contains.`,
|
|
900
|
-
undefined,
|
|
901
|
-
);
|
|
902
|
-
}
|
|
903
|
-
const result = await check({
|
|
904
|
-
workers,
|
|
905
|
-
livenessCheck: ["final", "seqfinal", "off"].includes(livenessCheck) ? "final" : "default",
|
|
906
|
-
seed: BigInt(seed),
|
|
907
|
-
dump: dumpValues && getDump(dumpValues),
|
|
908
|
-
isTool: printer.isTool,
|
|
909
|
-
isTraceRecorded: isRecorded,
|
|
910
|
-
isSanyReported: true,
|
|
911
|
-
isWarningEnabled: !args.has("-nowarning"),
|
|
912
|
-
version,
|
|
913
|
-
onProgress: (progress) => printCheckProgress(printer, progress, timing, directory),
|
|
914
|
-
source,
|
|
915
|
-
config,
|
|
916
|
-
onPause: () => readSync(0, Buffer.alloc(1)),
|
|
917
|
-
loadModule,
|
|
918
|
-
loadClass: (name) => {
|
|
919
|
-
const classPath = getClassPath(directory, name);
|
|
920
|
-
return existsSync(classPath) ? readFileSync(classPath) : undefined;
|
|
921
|
-
},
|
|
922
|
-
readFile: (path) => (existsSync(path) ? readFileSync(path, "utf8") : undefined),
|
|
923
|
-
writeFile: (path, content) => {
|
|
924
|
-
mkdirSync(dirname(resolve(path)), { recursive: true });
|
|
925
|
-
writeFileSync(path, content);
|
|
926
|
-
},
|
|
927
|
-
});
|
|
928
|
-
printResult(result, printer, timing);
|
|
929
|
-
printFinished();
|
|
930
|
-
return result.failure?.exitCode ?? EXIT_CODES[result.status];
|
|
931
|
-
};
|
|
932
763
|
if (printer.isTool) {
|
|
933
764
|
printer.print(MESSAGE_CODE.startingSany, MESSAGE_LEVEL.none, "Starting SANY...");
|
|
934
765
|
}
|
|
@@ -937,7 +768,7 @@ const checkSpec = async (
|
|
|
937
768
|
// the spec's modules in the spec's directory and the TLA-Library directories.
|
|
938
769
|
const isAbsoluteSpec = isAbsolute(specPath);
|
|
939
770
|
const specName = isAbsoluteSpec ? fileName : specPath.replace(/\.tla$/, "");
|
|
940
|
-
const jar =
|
|
771
|
+
const jar = getToolsJar(java);
|
|
941
772
|
const reportMissingFile =
|
|
942
773
|
version === "1.7.4" ? createMissingFilePrinter174(specPath, java, jar) : undefined;
|
|
943
774
|
if (reportMissingFile) {
|
|
@@ -978,7 +809,42 @@ const checkSpec = async (
|
|
|
978
809
|
return EXIT_STATUS.specParseError;
|
|
979
810
|
}
|
|
980
811
|
try {
|
|
981
|
-
|
|
812
|
+
const source = readFileSync(specPath, "utf8");
|
|
813
|
+
const moduleName = parseModule(source).name;
|
|
814
|
+
if (moduleName !== fileName) {
|
|
815
|
+
throw new TlaSanyFatalError(
|
|
816
|
+
`File name '${fileName}' does not match the name '${moduleName}' of the top level module it contains.`,
|
|
817
|
+
undefined,
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
const result = await check({
|
|
821
|
+
workers,
|
|
822
|
+
livenessCheck: ["final", "seqfinal", "off"].includes(livenessCheck) ? "final" : "default",
|
|
823
|
+
seed: BigInt(seed),
|
|
824
|
+
dump: dumpValues && getStateDump(dumpValues),
|
|
825
|
+
isTool: printer.isTool,
|
|
826
|
+
isTraceRecorded: isRecorded,
|
|
827
|
+
isSanyReported: true,
|
|
828
|
+
isWarningEnabled: !args.has("-nowarning"),
|
|
829
|
+
version,
|
|
830
|
+
onProgress: (progress) => printCheckProgress(printer, progress, timing, directory),
|
|
831
|
+
source,
|
|
832
|
+
config,
|
|
833
|
+
onPause: () => readSync(0, Buffer.alloc(1)),
|
|
834
|
+
loadModule,
|
|
835
|
+
loadClass: (name) => {
|
|
836
|
+
const classPath = getClassPath(directory, name);
|
|
837
|
+
return existsSync(classPath) ? readFileSync(classPath) : undefined;
|
|
838
|
+
},
|
|
839
|
+
readFile: (path) => (existsSync(path) ? readFileSync(path, "utf8") : undefined),
|
|
840
|
+
writeFile: (path, content) => {
|
|
841
|
+
mkdirSync(dirname(resolve(path)), { recursive: true });
|
|
842
|
+
writeFileSync(path, content);
|
|
843
|
+
},
|
|
844
|
+
});
|
|
845
|
+
printResult(result, printer, timing);
|
|
846
|
+
printFinished();
|
|
847
|
+
return result.failure?.exitCode ?? EXIT_CODES[result.status];
|
|
982
848
|
} catch (error) {
|
|
983
849
|
if (!(error instanceof TlaError)) throw error;
|
|
984
850
|
if (error instanceof TlaSyntaxError) console.log(formatSanyErrors(error, fileName));
|
|
@@ -1002,261 +868,7 @@ const formatSanyErrors = (error: TlaSyntaxError, specName: string) => {
|
|
|
1002
868
|
return `${parseError}\nFatal errors while parsing TLA+ spec in file ${specName}\n\n${report}\n*** Errors: 1\n\n${report}\n\n\n`;
|
|
1003
869
|
};
|
|
1004
870
|
|
|
1005
|
-
|
|
1006
|
-
const printError = (error: TlaError, printer: MessagePrinter) => {
|
|
1007
|
-
if (error instanceof TlaConfigError || error instanceof TlaEvaluationError) {
|
|
1008
|
-
// TLC prints an error it raises with a message code, such as a configuration error, with
|
|
1009
|
-
// that code.
|
|
1010
|
-
const coded = getCodedMessage(error.message);
|
|
1011
|
-
const code = coded && !coded.isEvalException ? coded.code : MESSAGE_CODE.general;
|
|
1012
|
-
return printer.print(
|
|
1013
|
-
code,
|
|
1014
|
-
MESSAGE_LEVEL.error,
|
|
1015
|
-
formatInnerMessage(code, error.message, printer.isTool),
|
|
1016
|
-
);
|
|
1017
|
-
}
|
|
1018
|
-
console.error(`${error.name}: ${error.message}`);
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
// Prints a TlaError and returns its exit code.
|
|
1022
|
-
const reportErrors = async (
|
|
1023
|
-
run: () => number | Promise<number>,
|
|
1024
|
-
printer = createMessagePrinter(false),
|
|
1025
|
-
) => {
|
|
1026
|
-
try {
|
|
1027
|
-
return await run();
|
|
1028
|
-
} catch (error) {
|
|
1029
|
-
if (!(error instanceof TlaError)) throw error;
|
|
1030
|
-
printError(error, printer);
|
|
1031
|
-
return getErrorExitCode(error);
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
// Runs each path in turn, as TLC runs in a process of its own, so an error in one leaves the others
|
|
1036
|
-
// to report. The exit code is the first that is not success.
|
|
1037
|
-
const runEach = async (
|
|
1038
|
-
paths: string[],
|
|
1039
|
-
runPath: (path: string, printer: MessagePrinter) => number | Promise<number>,
|
|
1040
|
-
createPrinter: () => MessagePrinter,
|
|
1041
|
-
) => {
|
|
1042
|
-
const exitCodes: number[] = [];
|
|
1043
|
-
for (const [index, path] of paths.entries()) {
|
|
1044
|
-
if (index > 0) console.log("");
|
|
1045
|
-
const printer = createPrinter();
|
|
1046
|
-
exitCodes.push(await reportErrors(() => runPath(path, printer), printer));
|
|
1047
|
-
}
|
|
1048
|
-
return exitCodes.find((exitCode) => exitCode !== EXIT_STATUS.success) ?? EXIT_STATUS.success;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
// tlapm installs its standard library, with modules such as TLAPS, at lib/tlapm/stdlib beside
|
|
1052
|
-
// bin/tlapm.
|
|
1053
|
-
const getTlapmLibrary = () =>
|
|
1054
|
-
getTlapmPaths()
|
|
1055
|
-
.map((path) => join(dirname(dirname(realpathSync(path))), "lib/tlapm/stdlib"))
|
|
1056
|
-
.find((path) => existsSync(path));
|
|
1057
|
-
|
|
1058
|
-
const expandGlobs = (paths: string[]) =>
|
|
1059
|
-
paths.flatMap((path) => (GLOB_CHARACTERS.test(path) ? globSync(path).sort() : [path]));
|
|
1060
|
-
|
|
1061
|
-
const readModule = (path: string) =>
|
|
1062
|
-
existsSync(path) ? { file: path, source: readFileSync(path, "utf8") } : undefined;
|
|
1063
|
-
|
|
1064
|
-
// A message of tlapm's toolbox protocol, which it writes to stderr.
|
|
1065
|
-
const printToolboxMessage = (fields: string[]) =>
|
|
1066
|
-
console.error(`@!!BEGIN\n${fields.map((field) => `@!!${field}\n`).join("")}@!!END\n`);
|
|
1067
|
-
|
|
1068
|
-
const TLAPM_VERSION = "5f5037f";
|
|
1069
|
-
|
|
1070
|
-
const quoteArgument = (arg: string) =>
|
|
1071
|
-
/^[+,\-./0-9:=@A-Z_a-z]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
|
|
1072
|
-
|
|
1073
|
-
const printToolboxHeader = (args: string[]) =>
|
|
1074
|
-
console.log(
|
|
1075
|
-
`\n\\* TLAPM version ${TLAPM_VERSION}\n\\* launched at ${formatTlcDate(new Date())} with command line:\n\\* ${["tla-ts", "prove", ...args].map(quoteArgument).join(" ")}\n`,
|
|
1076
|
-
);
|
|
1077
|
-
|
|
1078
|
-
const STRICT_EXIT_STATUS = { incomplete: 11, emptyTarget: 12 };
|
|
1079
|
-
|
|
1080
|
-
const checkStrictly = (result: ModuleObligations, isTargeted: boolean, isSummary: boolean) => {
|
|
1081
|
-
const summary = result.summary;
|
|
1082
|
-
if (!isSummary) {
|
|
1083
|
-
summary.absent.forEach((locus) => console.error(`Missing proof at ${getLocusText(locus)}`));
|
|
1084
|
-
summary.omitted.forEach((locus) => console.error(`Omitted proof at ${getLocusText(locus)}`));
|
|
1085
|
-
}
|
|
1086
|
-
const isIncomplete = summary.absent.length + summary.omitted.length > 0;
|
|
1087
|
-
if (isIncomplete) {
|
|
1088
|
-
console.error(
|
|
1089
|
-
`${getAtPrefix(result.location)}[ERROR]: Proof incomplete in module ${JSON.stringify(result.name)}: ${summary.absent.length} missing, ${summary.omitted.length} omitted proof step(s).`,
|
|
1090
|
-
);
|
|
1091
|
-
}
|
|
1092
|
-
const isEmpty = isTargeted && result.obligations.length === 0;
|
|
1093
|
-
if (isEmpty) {
|
|
1094
|
-
console.error(
|
|
1095
|
-
`${getAtPrefix(result.location)}[ERROR]: No proof obligation found for the selected target.`,
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1098
|
-
return [
|
|
1099
|
-
...(isIncomplete ? [STRICT_EXIT_STATUS.incomplete] : []),
|
|
1100
|
-
...(isEmpty ? [STRICT_EXIT_STATUS.emptyTarget] : []),
|
|
1101
|
-
];
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
const TLAPM_FAILURE_STATUS = 3;
|
|
1105
|
-
|
|
1106
|
-
const generateObligations = (generate: () => ModuleObligations[]) => {
|
|
1107
|
-
try {
|
|
1108
|
-
return generate();
|
|
1109
|
-
} catch (error) {
|
|
1110
|
-
if (!(error instanceof TlaProofError)) throw error;
|
|
1111
|
-
console.error(` tlapm ending abnormally with ${error.exception}\n`);
|
|
1112
|
-
return undefined;
|
|
1113
|
-
}
|
|
1114
|
-
};
|
|
1115
|
-
|
|
1116
|
-
// tla-ts prove: proves each module with prove, printing each obligation as it ends.
|
|
1117
|
-
const proveModules = (args: string[]) => {
|
|
1118
|
-
const parsed = PROVE_COMMAND.parse(args);
|
|
1119
|
-
const backend = parsed.get("--backend")?.[0];
|
|
1120
|
-
if (
|
|
1121
|
-
parsed.unknown[0] !== undefined ||
|
|
1122
|
-
parsed.incomplete ||
|
|
1123
|
-
(backend !== undefined && !isProveBackend(backend))
|
|
1124
|
-
) {
|
|
1125
|
-
console.error(`Usage: ${PROVE_COMMAND.usage}`);
|
|
1126
|
-
return 1;
|
|
1127
|
-
}
|
|
1128
|
-
const modulePaths = expandGlobs(parsed.positionals).map((path) =>
|
|
1129
|
-
path.endsWith(".tla") ? path : `${path}.tla`,
|
|
1130
|
-
);
|
|
1131
|
-
if (modulePaths.length === 0) {
|
|
1132
|
-
console.error(`Usage: ${PROVE_COMMAND.usage}`);
|
|
1133
|
-
return 1;
|
|
1134
|
-
}
|
|
1135
|
-
const tlapmLibrary = getTlapmLibrary();
|
|
1136
|
-
const includes = parsed.options.flatMap((option) => (option.name === "-I" ? option.values : []));
|
|
1137
|
-
return runEach(
|
|
1138
|
-
modulePaths,
|
|
1139
|
-
async (path) => {
|
|
1140
|
-
const directories = [
|
|
1141
|
-
dirname(path),
|
|
1142
|
-
".",
|
|
1143
|
-
...(tlapmLibrary ? [tlapmLibrary] : []),
|
|
1144
|
-
...includes.toReversed(),
|
|
1145
|
-
];
|
|
1146
|
-
const result = await prove({
|
|
1147
|
-
source: readFileSync(path, "utf8"),
|
|
1148
|
-
loadModule: (name) =>
|
|
1149
|
-
directories.map((directory) => readModule(`${directory}/${name}.tla`)).find(Boolean)
|
|
1150
|
-
?.source,
|
|
1151
|
-
backend,
|
|
1152
|
-
workers: getWorkerCount(parsed.get("-workers")),
|
|
1153
|
-
onObligation: (obligation) =>
|
|
1154
|
-
console.log(
|
|
1155
|
-
`${path}:${obligation.location}: ${obligation.status}${obligation.status === "proved" ? ` by ${obligation.prover}` : ""}${obligation.status === "failed" || obligation.status === "unsupported" ? ` (${obligation.reason})` : ""}`,
|
|
1156
|
-
),
|
|
1157
|
-
});
|
|
1158
|
-
const counts = Map.groupBy(result.obligations, (obligation) => obligation.status);
|
|
1159
|
-
const getCount = (status: ProofStatus) => counts.get(status)?.length ?? 0;
|
|
1160
|
-
console.log(
|
|
1161
|
-
`${result.obligations.length} obligations: ${getCount("proved")} proved, ${getCount("trivial")} trivial, ${getCount("failed")} failed, ${getCount("unsupported")} unsupported`,
|
|
1162
|
-
);
|
|
1163
|
-
return getCount("failed") + getCount("unsupported") === 0 ? EXIT_STATUS.success : 1;
|
|
1164
|
-
},
|
|
1165
|
-
() => createMessagePrinter(false),
|
|
1166
|
-
);
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
const runProve = (args: string[]) => {
|
|
1170
|
-
if (!args.includes("-N") && !args.includes("--summary")) return proveModules(args);
|
|
1171
|
-
const parsed = OBLIGATIONS_COMMAND.parse(args);
|
|
1172
|
-
const unsupported = parsed.unknown[0];
|
|
1173
|
-
if (unsupported !== undefined) {
|
|
1174
|
-
console.error(`Error: tla-ts prove does not support the tlapm option ${unsupported}.`);
|
|
1175
|
-
return 1;
|
|
1176
|
-
}
|
|
1177
|
-
if (parsed.incomplete) {
|
|
1178
|
-
console.error(`Error: option '${parsed.incomplete.name}' needs an argument.`);
|
|
1179
|
-
return 1;
|
|
1180
|
-
}
|
|
1181
|
-
const nonInteger = parsed.options.find(
|
|
1182
|
-
(option) => option.name !== "-I" && option.values.some((value) => !/^-?\d+$/.test(value)),
|
|
1183
|
-
);
|
|
1184
|
-
if (nonInteger) {
|
|
1185
|
-
console.error(`Error: option '${nonInteger.name}' expects an integer.`);
|
|
1186
|
-
return 1;
|
|
1187
|
-
}
|
|
1188
|
-
const files = expandGlobs(parsed.positionals);
|
|
1189
|
-
const modulePaths = files.map((path) => (path.endsWith(".tla") ? path : `${path}.tla`));
|
|
1190
|
-
if (modulePaths.length === 0) {
|
|
1191
|
-
console.error(USAGE);
|
|
1192
|
-
return 1;
|
|
1193
|
-
}
|
|
1194
|
-
const isToolbox = parsed.has("--toolbox") || parsed.has("--line");
|
|
1195
|
-
if (isToolbox) printToolboxHeader(args);
|
|
1196
|
-
// Like tlapm, the last of --toolbox and --line wins, and a 0 means the whole module.
|
|
1197
|
-
const lines = parsed.options.reduce<LineRange>((range, option) => {
|
|
1198
|
-
const [start, end] = option.values.map(Number);
|
|
1199
|
-
if (option.name === "--toolbox") return { start, end: end === 0 ? Infinity : end };
|
|
1200
|
-
if (option.name === "--line") return start === 0 ? WHOLE_MODULE : { start, end: start };
|
|
1201
|
-
return range;
|
|
1202
|
-
}, WHOLE_MODULE);
|
|
1203
|
-
// tlapm searches the current directory and each module's, then its library, then each -I
|
|
1204
|
-
// directory, the last given first.
|
|
1205
|
-
const tlapmLibrary = getTlapmLibrary();
|
|
1206
|
-
const includes = parsed.options.flatMap((option) => (option.name === "-I" ? option.values : []));
|
|
1207
|
-
const directories = modulePaths.reduce(
|
|
1208
|
-
(found, path) => (found.includes(dirname(path)) ? found : [dirname(path), ...found]),
|
|
1209
|
-
[".", ...(tlapmLibrary ? [tlapmLibrary] : []), ...includes.toReversed()],
|
|
1210
|
-
);
|
|
1211
|
-
// tlapm names each file it reads by joining a search directory and the name, as in ./Module.tla.
|
|
1212
|
-
const results = generateObligations(() => {
|
|
1213
|
-
const missingIndex = modulePaths.findIndex((path) => !existsSync(path));
|
|
1214
|
-
if (missingIndex !== -1) {
|
|
1215
|
-
const missing = files[missingIndex];
|
|
1216
|
-
console.error(`File "<unknown>":\nError: File ${JSON.stringify(missing)} not found`);
|
|
1217
|
-
throw new TlaProofError(`File ${missing} not found`, { failure: "Module.Parser.parse_file" });
|
|
1218
|
-
}
|
|
1219
|
-
return getObligations(
|
|
1220
|
-
modulePaths.map((path) => ({ file: `./${path}`, source: readFileSync(path, "utf8") })),
|
|
1221
|
-
(name) =>
|
|
1222
|
-
directories.map((directory) => readModule(`${directory}/${name}.tla`)).find(Boolean),
|
|
1223
|
-
{
|
|
1224
|
-
lines,
|
|
1225
|
-
onWarning: (warning) => {
|
|
1226
|
-
if (warning.channel === "stdout") return console.log(warning.text);
|
|
1227
|
-
const isToolboxMessage =
|
|
1228
|
-
warning.channel === "toolbox" || warning.channel === "toolboxOnly";
|
|
1229
|
-
if (isToolbox && isToolboxMessage)
|
|
1230
|
-
return printToolboxMessage(["type:warning", `msg:${warning.text}`]);
|
|
1231
|
-
if (warning.channel !== "toolboxOnly") console.error(warning.text);
|
|
1232
|
-
},
|
|
1233
|
-
},
|
|
1234
|
-
);
|
|
1235
|
-
});
|
|
1236
|
-
if (!results) return TLAPM_FAILURE_STATUS;
|
|
1237
|
-
const failures = results.flatMap((result) => {
|
|
1238
|
-
if (parsed.has("--summary")) console.log(formatSummary(result));
|
|
1239
|
-
if (isToolbox) {
|
|
1240
|
-
result.obligations.forEach((obligation) =>
|
|
1241
|
-
printToolboxMessage([
|
|
1242
|
-
"type:obligation",
|
|
1243
|
-
`id:${obligation.id}`,
|
|
1244
|
-
`loc:${obligation.location}`,
|
|
1245
|
-
"status:to be proved",
|
|
1246
|
-
...(parsed.has("--printallobs") ? [`obl:${obligation.text}`] : []),
|
|
1247
|
-
]),
|
|
1248
|
-
);
|
|
1249
|
-
printToolboxMessage(["type:obligationsnumber", `count:${result.obligations.length}`]);
|
|
1250
|
-
}
|
|
1251
|
-
if (!parsed.has("--strict")) return [];
|
|
1252
|
-
return checkStrictly(result, lines.start > 0 || lines.end < Infinity, parsed.has("--summary"));
|
|
1253
|
-
});
|
|
1254
|
-
return failures.includes(STRICT_EXIT_STATUS.incomplete)
|
|
1255
|
-
? STRICT_EXIT_STATUS.incomplete
|
|
1256
|
-
: (failures[0] ?? EXIT_STATUS.success);
|
|
1257
|
-
};
|
|
1258
|
-
|
|
1259
|
-
const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
871
|
+
export const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
1260
872
|
const parsed = CHECK_COMMAND.parse(args);
|
|
1261
873
|
const inputs = getInputPaths(parsed.positionals);
|
|
1262
874
|
const isConfigured = parsed.has("-config");
|
|
@@ -1290,123 +902,24 @@ const checkSpecs = async (args: string[], java: JavaProperties) => {
|
|
|
1290
902
|
? path
|
|
1291
903
|
: (java.libraries.map((directory) => join(directory, path)).find(existsSync) ?? path);
|
|
1292
904
|
const paths = [...new Set(specPaths.map(findSpec))];
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
// XMLExporter.run prints why it cannot parse its arguments, and its usage.
|
|
1307
|
-
const printXmlExportUsageError = (message: string) => {
|
|
1308
|
-
process.stderr.write(`ERROR: ${message}\n${XML_EXPORT_USAGE}`);
|
|
1309
|
-
return XML_EXPORT_EXIT_CODE.argsParsingFailure;
|
|
1310
|
-
};
|
|
1311
|
-
|
|
1312
|
-
// XMLExporter.run writes the XML of a specification, and why it can't when it can't.
|
|
1313
|
-
const writeXml = (specification: SanySpecification, options: XmlExportOptions) => {
|
|
1314
|
-
try {
|
|
1315
|
-
process.stdout.write(exportSanyXml(specification, options));
|
|
1316
|
-
return EXIT_STATUS.success;
|
|
1317
|
-
} catch (error) {
|
|
1318
|
-
if (!(error instanceof TlaUnsupportedError)) throw error;
|
|
1319
|
-
const exitCode = getErrorExitCode(error);
|
|
1320
|
-
const unwound = error instanceof TlaJavaException ? error.unwound : "";
|
|
1321
|
-
console.error(
|
|
1322
|
-
exitCode === XML_EXPORT_EXIT_CODE.uncaughtException
|
|
1323
|
-
? `${unwound}Exception in thread "main" ${error.message}`
|
|
1324
|
-
: `ERROR: ${error.message}`,
|
|
1325
|
-
);
|
|
1326
|
-
return exitCode;
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
interface XmlExportArgs {
|
|
1331
|
-
flags: Set<string>;
|
|
1332
|
-
includes: string[];
|
|
1333
|
-
error: "missing-include" | "several-files" | undefined;
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
// XMLExporter reads the flags before the last argument, which names the module, and skips an
|
|
1337
|
-
// argument it does not know, which then counts as another module.
|
|
1338
|
-
const parseXmlExportArgs = (args: string[], flagNames: Set<string>): XmlExportArgs => {
|
|
1339
|
-
const parsed: XmlExportArgs = { flags: new Set(), includes: [], error: undefined };
|
|
1340
|
-
const last = { flag: -1 };
|
|
1341
|
-
for (let index = 0; index < args.length - 1; index++) {
|
|
1342
|
-
if (flagNames.has(args[index])) {
|
|
1343
|
-
parsed.flags.add(args[index]);
|
|
1344
|
-
last.flag = index;
|
|
1345
|
-
continue;
|
|
1346
|
-
}
|
|
1347
|
-
if (args[index] !== "-I") continue;
|
|
1348
|
-
index++;
|
|
1349
|
-
if (index > args.length - 2) return { ...parsed, error: "missing-include" };
|
|
1350
|
-
parsed.includes.push(args[index]);
|
|
1351
|
-
last.flag = index;
|
|
1352
|
-
}
|
|
1353
|
-
return last.flag === args.length - 2 ? parsed : { ...parsed, error: "several-files" };
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
|
-
const exportXml = (args: string[]) => {
|
|
1357
|
-
if (args.length === 0) return printXmlExportUsageError("at least one .tla file must be given");
|
|
1358
|
-
const parsed = parseXmlExportArgs(args, XML_EXPORT_FLAGS);
|
|
1359
|
-
if (parsed.error === "missing-include") {
|
|
1360
|
-
return printXmlExportUsageError(
|
|
1361
|
-
"the -I flag must be followed by a directory and at least one .tla file",
|
|
905
|
+
// Each spec is checked as TLC would in a process of its own, so an error in one leaves the others
|
|
906
|
+
// to report. The exit code is the first that is not success.
|
|
907
|
+
const exitCodes: number[] = [];
|
|
908
|
+
for (const [index, path] of paths.entries()) {
|
|
909
|
+
if (index > 0) console.log("");
|
|
910
|
+
// TLC checks one spec, so tla-ts names each of several it checks.
|
|
911
|
+
if (paths.length > 1)
|
|
912
|
+
console.log(`Checking ${basename(path)} with ${basename(path, ".tla")}.cfg`);
|
|
913
|
+
const printer = createMessagePrinter(
|
|
914
|
+
parsed.has("-tool"),
|
|
915
|
+
!parsed.has("-nowarning"),
|
|
916
|
+
java.tlcVersion ?? "master",
|
|
1362
917
|
);
|
|
918
|
+
exitCodes.push(await reportErrors(() => checkSpec(path, parsed, java, printer), printer));
|
|
1363
919
|
}
|
|
1364
|
-
|
|
1365
|
-
return printXmlExportUsageError("Only one TLA file to check allowed!");
|
|
1366
|
-
}
|
|
1367
|
-
const name = args[args.length - 1];
|
|
1368
|
-
if (name === "-help") {
|
|
1369
|
-
process.stdout.write(XML_EXPORT_USAGE);
|
|
1370
|
-
return EXIT_STATUS.success;
|
|
1371
|
-
}
|
|
1372
|
-
const fileName = name.endsWith(".tla") ? name : `${name}.tla`;
|
|
1373
|
-
// SANY looks for each module in the working directory, then in the -I directories, which
|
|
1374
|
-
// XMLExporter passes in place of TLA-Library, then among its standard modules.
|
|
1375
|
-
const directories = [".", ...parsed.includes];
|
|
1376
|
-
const path = directories.map((directory) => resolve(directory, fileName)).find(existsSync);
|
|
1377
|
-
if (path === undefined && !SANY_STANDARD_MODULES.has(fileName.slice(0, -".tla".length))) {
|
|
1378
|
-
printMissingFile(process.cwd(), `./${fileName}`, parsed.includes);
|
|
1379
|
-
}
|
|
1380
|
-
// XMLExporter.parseSpec prints SANY's errors, and XMLExporter.run why it fails.
|
|
1381
|
-
const sany = getSanyReport(path ?? fileName, createModuleLoader(directories), {
|
|
1382
|
-
fileName: name,
|
|
1383
|
-
isXmlExport: true,
|
|
1384
|
-
});
|
|
1385
|
-
process.stderr.write(sany.text);
|
|
1386
|
-
if (sany.isFailed || sany.specification === undefined) {
|
|
1387
|
-
console.error("ERROR: Failed to parse module.");
|
|
1388
|
-
return XML_EXPORT_EXIT_CODE.specParsingFailure;
|
|
1389
|
-
}
|
|
1390
|
-
return writeXml(sany.specification, {
|
|
1391
|
-
version: "master",
|
|
1392
|
-
isRestricted: parsed.flags.has("-r"),
|
|
1393
|
-
isUncommented: parsed.flags.has("-u"),
|
|
1394
|
-
isTerse: parsed.flags.has("-t"),
|
|
1395
|
-
});
|
|
920
|
+
return exitCodes.find((exitCode) => exitCode !== EXIT_STATUS.success) ?? EXIT_STATUS.success;
|
|
1396
921
|
};
|
|
1397
922
|
|
|
1398
|
-
// TLC 1.7.4's FileUtil.createNamedInputStream names the last file that SimpleFilenameToStream
|
|
1399
|
-
// looked for a module in, and the directories it looks in, the standard modules in the jar last,
|
|
1400
|
-
// which tla-ts leaves out without a jar.
|
|
1401
|
-
const printMissingFile174 = (path: string, libraries: string[], jar: string | undefined) =>
|
|
1402
|
-
console.error(
|
|
1403
|
-
`File does not exist: ${isAbsolute(path) ? path : `${process.cwd()}/${path}`} while looking in these directories: ${[...libraries, ...(jar === undefined ? [] : [getStandardModulesUrl(jar)])].join(", ")}`,
|
|
1404
|
-
);
|
|
1405
|
-
|
|
1406
|
-
// SimpleFilenameToStream ends a library directory with a separator.
|
|
1407
|
-
const toLibraryPath = (directory: string) =>
|
|
1408
|
-
directory.endsWith("/") ? directory : `${directory}/`;
|
|
1409
|
-
|
|
1410
923
|
// TLC 1.7.4's SimpleFilenameToStream looks for a module in the directory of a spec that TLC is
|
|
1411
924
|
// given by an absolute path, then in the directory that a relative path names, or else in the
|
|
1412
925
|
// TLA-Library directories.
|
|
@@ -1426,165 +939,3 @@ const createMissingFilePrinter174 = (
|
|
|
1426
939
|
: "";
|
|
1427
940
|
return (fileName: string) => printMissingFile174(`${lastDirectory}${fileName}`, libraries, jar);
|
|
1428
941
|
};
|
|
1429
|
-
|
|
1430
|
-
// TLC 1.7.4's SANY reports each module it can't find as it looks for it.
|
|
1431
|
-
const reportMissingModules174 =
|
|
1432
|
-
(loadModule: (name: string) => string | undefined, onMissing: (fileName: string) => void) =>
|
|
1433
|
-
(name: string) => {
|
|
1434
|
-
const text = loadModule(name);
|
|
1435
|
-
if (text === undefined && !SANY_174_STANDARD_MODULES.has(name)) onMissing(`${name}.tla`);
|
|
1436
|
-
return text;
|
|
1437
|
-
};
|
|
1438
|
-
|
|
1439
|
-
// TLC 1.7.4's XMLExporter.main throws an exception for an argument it can't take or a
|
|
1440
|
-
// specification without a root module.
|
|
1441
|
-
const printXmlExporterException = (exception: string, line: number) => {
|
|
1442
|
-
console.error(
|
|
1443
|
-
`Exception in thread "main" ${exception}\n\tat tla2sany.xml.XMLExporter.main(XMLExporter.java:${line})`,
|
|
1444
|
-
);
|
|
1445
|
-
return XML_EXPORT_EXIT_CODE.uncaughtException;
|
|
1446
|
-
};
|
|
1447
|
-
|
|
1448
|
-
// TLC 1.7.4's XMLExporter.main, which takes only -o, as it can't validate the XML without
|
|
1449
|
-
// fetching its schema, and -I, and exports a specification that SANY finds errors in.
|
|
1450
|
-
const exportXml174 = (args: string[], jar: string | undefined) => {
|
|
1451
|
-
if (args.length === 0) {
|
|
1452
|
-
return printXmlExporterException(
|
|
1453
|
-
"java.lang.IllegalArgumentException: at least one .tla file must be given",
|
|
1454
|
-
59,
|
|
1455
|
-
);
|
|
1456
|
-
}
|
|
1457
|
-
const parsed = parseXmlExportArgs(args, XML_EXPORT_174_FLAGS);
|
|
1458
|
-
if (parsed.error === "missing-include") {
|
|
1459
|
-
return printXmlExporterException(
|
|
1460
|
-
"java.lang.IllegalArgumentException: the -I flag must be followed by a directory and at least one .tla file",
|
|
1461
|
-
71,
|
|
1462
|
-
);
|
|
1463
|
-
}
|
|
1464
|
-
if (parsed.error === "several-files") {
|
|
1465
|
-
return printXmlExporterException(
|
|
1466
|
-
"java.lang.IllegalArgumentException: Only one TLA file to check allowed!",
|
|
1467
|
-
83,
|
|
1468
|
-
);
|
|
1469
|
-
}
|
|
1470
|
-
const name = args[args.length - 1];
|
|
1471
|
-
const fileName = `${name.replace(/\.tla$/i, "")}.tla`;
|
|
1472
|
-
// SimpleFilenameToStream looks for a module in the working directory, then in the -I
|
|
1473
|
-
// directories, or the root directory when there are none, then among the standard modules.
|
|
1474
|
-
const libraries = (parsed.includes.length === 0 ? ["/"] : parsed.includes).map(toLibraryPath);
|
|
1475
|
-
const directories = [".", ...libraries];
|
|
1476
|
-
const printMissingFile = (moduleFileName: string) =>
|
|
1477
|
-
printMissingFile174(`${libraries[libraries.length - 1]}${moduleFileName}`, libraries, jar);
|
|
1478
|
-
const path = directories.map((directory) => resolve(directory, fileName)).find(existsSync);
|
|
1479
|
-
if (path === undefined && !SANY_174_STANDARD_MODULES.has(basename(fileName, ".tla"))) {
|
|
1480
|
-
printMissingFile(fileName);
|
|
1481
|
-
return EXIT_STATUS.success;
|
|
1482
|
-
}
|
|
1483
|
-
const sany = getSanyReport(
|
|
1484
|
-
path ?? fileName,
|
|
1485
|
-
reportMissingModules174(createModuleLoader(directories), printMissingFile),
|
|
1486
|
-
{
|
|
1487
|
-
fileName: name,
|
|
1488
|
-
isXmlExport: true,
|
|
1489
|
-
version: "1.7.4",
|
|
1490
|
-
},
|
|
1491
|
-
);
|
|
1492
|
-
process.stderr.write(sany.text);
|
|
1493
|
-
if (sany.specification === undefined) {
|
|
1494
|
-
return printXmlExporterException(
|
|
1495
|
-
`tla2sany.xml.XMLExportingException: spec ${(path && getSanyModuleName(readFileSync(path, "utf8"), "1.7.4")) ?? "null"} is malformed - does not have a root module`,
|
|
1496
|
-
110,
|
|
1497
|
-
);
|
|
1498
|
-
}
|
|
1499
|
-
return writeXml(sany.specification, {
|
|
1500
|
-
version: "1.7.4",
|
|
1501
|
-
isRestricted: false,
|
|
1502
|
-
isUncommented: false,
|
|
1503
|
-
isTerse: true,
|
|
1504
|
-
});
|
|
1505
|
-
};
|
|
1506
|
-
|
|
1507
|
-
// Tools that run TLC with Java, such as the statechart skill of pstack, can run tla-ts in place of
|
|
1508
|
-
// java, as in `tla-ts -DTLA-Library=lib -cp tla2tools.jar tlc2.TLC Spec`. tla-ts searches the
|
|
1509
|
-
// TLA-Library directories for modules as TLC does, though not as XMLExporter, which ignores them,
|
|
1510
|
-
// names the files in java.io.tmpdir and the jar on the class path that TLC would copy and read
|
|
1511
|
-
// modules from, and ignores the other options. It reproduces the TLC of that jar, or the one that
|
|
1512
|
-
// -Dtla-ts.tlc names without a jar, as in `tla-ts -Dtla-ts.tlc=1.7.4 tlc2.TLC Spec`.
|
|
1513
|
-
const JAVA_MAIN_CLASSES = ["tlc2.TLC", "tla2sany.xml.XMLExporter"];
|
|
1514
|
-
|
|
1515
|
-
const TLA_LIBRARY_PROPERTY = "-DTLA-Library=";
|
|
1516
|
-
|
|
1517
|
-
const TEMPORARY_DIRECTORY_PROPERTY = "-Djava.io.tmpdir=";
|
|
1518
|
-
|
|
1519
|
-
const TLC_VERSION_PROPERTY = "-Dtla-ts.tlc=";
|
|
1520
|
-
|
|
1521
|
-
// What the java command sets for TLC: the TLA-Library directories it searches for modules, the
|
|
1522
|
-
// class path it finds its standard modules on, and java.io.tmpdir, where it copies them.
|
|
1523
|
-
interface JavaProperties {
|
|
1524
|
-
libraries: string[];
|
|
1525
|
-
classPath?: string;
|
|
1526
|
-
temporaryDirectory?: string;
|
|
1527
|
-
tlcVersion?: TlcVersion;
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
// The tla2tools.jar on the class path.
|
|
1531
|
-
const getJar = (java: JavaProperties) =>
|
|
1532
|
-
java.classPath?.split(delimiter).find((entry) => entry.endsWith(".jar"));
|
|
1533
|
-
|
|
1534
|
-
interface JavaLaunch {
|
|
1535
|
-
mainClass: string;
|
|
1536
|
-
args: string[];
|
|
1537
|
-
java: JavaProperties;
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
const getJavaLaunch = (args: string[]): JavaLaunch | undefined => {
|
|
1541
|
-
const java: JavaProperties = { libraries: [] };
|
|
1542
|
-
for (let index = 0; index < args.length; index++) {
|
|
1543
|
-
const arg = args[index];
|
|
1544
|
-
if (arg === "-cp" || arg === "-classpath" || arg === "--class-path") {
|
|
1545
|
-
index++;
|
|
1546
|
-
java.classPath = args[index];
|
|
1547
|
-
} else if (arg === "-jar") {
|
|
1548
|
-
java.classPath = args[index + 1];
|
|
1549
|
-
return { mainClass: "tlc2.TLC", args: args.slice(index + 2), java };
|
|
1550
|
-
} else if (arg.startsWith(TLA_LIBRARY_PROPERTY)) {
|
|
1551
|
-
java.libraries.push(...arg.slice(TLA_LIBRARY_PROPERTY.length).split(delimiter));
|
|
1552
|
-
} else if (arg.startsWith(TEMPORARY_DIRECTORY_PROPERTY)) {
|
|
1553
|
-
java.temporaryDirectory = arg.slice(TEMPORARY_DIRECTORY_PROPERTY.length);
|
|
1554
|
-
} else if (arg.startsWith(TLC_VERSION_PROPERTY)) {
|
|
1555
|
-
java.tlcVersion = arg.slice(TLC_VERSION_PROPERTY.length) === "1.7.4" ? "1.7.4" : "master";
|
|
1556
|
-
} else if (!arg.startsWith("-D") && !arg.startsWith("-X")) {
|
|
1557
|
-
const isLaunch = index > 0 || JAVA_MAIN_CLASSES.includes(arg);
|
|
1558
|
-
return isLaunch ? { mainClass: arg, args: args.slice(index + 1), java } : undefined;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
return undefined;
|
|
1562
|
-
};
|
|
1563
|
-
|
|
1564
|
-
const runJavaClass = (launch: JavaLaunch) => {
|
|
1565
|
-
if (launch.mainClass === "tlc2.TLC") return checkSpecs(launch.args, launch.java);
|
|
1566
|
-
if (launch.mainClass === "tla2sany.xml.XMLExporter") {
|
|
1567
|
-
return reportErrors(() =>
|
|
1568
|
-
launch.java.tlcVersion === "1.7.4"
|
|
1569
|
-
? exportXml174(launch.args, getJar(launch.java))
|
|
1570
|
-
: exportXml(launch.args),
|
|
1571
|
-
);
|
|
1572
|
-
}
|
|
1573
|
-
console.error(
|
|
1574
|
-
`Error: tla-ts runs the Java classes ${JAVA_MAIN_CLASSES.join(" and ")}, not ${launch.mainClass}.`,
|
|
1575
|
-
);
|
|
1576
|
-
return 1;
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
const run = async (args: string[]) => {
|
|
1580
|
-
if (args[0] === "prove") return reportErrors(() => runProve(args.slice(1)));
|
|
1581
|
-
const launch = getJavaLaunch(args);
|
|
1582
|
-
if (launch === undefined) return checkSpecs(args, { libraries: [] });
|
|
1583
|
-
// The TLC that -Dtla-ts.tlc names, or else the one of the jar on the class path.
|
|
1584
|
-
launch.java.tlcVersion ??= await getTlcVersion(getJar(launch.java));
|
|
1585
|
-
return runJavaClass(launch);
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
|
-
export const runCli = async () => {
|
|
1589
|
-
process.exitCode = await run(process.argv.slice(2));
|
|
1590
|
-
};
|