tla-ts 0.0.9 → 0.0.10-dev.b4a856304
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 +29 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +28 -28
- package/dist/deciders.js +43 -43
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +72 -10
- package/dist/index.d.ts +72 -10
- 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 +116 -36
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +128 -103
- package/dist/transfer.js +128 -103
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +7 -21
- package/src/bags.ts +99 -99
- package/src/builtins.ts +44 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +576 -300
- package/src/cli/options.ts +11 -6
- package/src/cli/run.ts +2 -2
- package/src/cli/runtime-invariants.ts +135 -0
- package/src/cli/shared.ts +20 -9
- package/src/cli/tlapm.ts +0 -12
- package/src/cli/tlc-arguments.ts +646 -0
- package/src/cli/tlc-usage.ts +362 -0
- package/src/cli/tlc.ts +538 -220
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +4 -16
- package/src/cli.ts +0 -1
- package/src/codegen.ts +191 -64
- package/src/config.ts +140 -109
- package/src/coverage.ts +837 -0
- package/src/dependencies.ts +6 -40
- package/src/dfid.ts +618 -0
- package/src/environment.ts +240 -118
- package/src/errors.ts +70 -55
- package/src/evaluate.ts +630 -297
- package/src/exit-codes.ts +37 -3
- package/src/fingerprints.ts +10 -10
- package/src/index.ts +3 -0
- package/src/instances.ts +79 -11
- package/src/java-overrides.ts +2 -12
- package/src/json-reader.ts +456 -0
- package/src/json.ts +262 -139
- package/src/levels.ts +2 -3
- package/src/lexer.ts +17 -26
- package/src/liveness-checker.ts +10 -18
- package/src/liveness.ts +121 -49
- package/src/obligations/action.ts +4 -28
- package/src/obligations/anonymize.ts +84 -80
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +2 -19
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +1 -11
- package/src/obligations/index.ts +0 -11
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +1 -15
- package/src/obligations/normalize.ts +5 -24
- package/src/obligations/operators.ts +1 -2
- package/src/obligations/pragma.ts +1 -10
- package/src/obligations/printer.ts +47 -46
- package/src/obligations/proof.ts +1 -5
- package/src/obligations/regroup.ts +1 -4
- package/src/obligations/simplify.ts +3 -14
- package/src/obligations/source.ts +1 -21
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +8 -14
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +29 -39
- package/src/parallel.ts +29 -13
- package/src/parser.ts +436 -90
- package/src/pcal/ast.ts +7 -28
- package/src/pcal/parse.ts +11 -39
- package/src/pcal/tokenize.ts +4 -20
- package/src/pcal/translate.ts +10 -42
- package/src/pcal/validate.ts +3 -21
- package/src/pretty-print.ts +1 -2
- package/src/prover/decide-pool.ts +5 -10
- package/src/prover/deciders.ts +0 -4
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +0 -6
- package/src/prover/isabelle/encode.ts +11 -23
- package/src/prover/isabelle/isar/inner-syntax.ts +108 -114
- package/src/prover/isabelle/isar/method.ts +25 -38
- package/src/prover/isabelle/isar/proof.ts +1 -10
- package/src/prover/isabelle/isar/statement.ts +1 -6
- package/src/prover/isabelle/isar/theory.ts +15 -26
- package/src/prover/isabelle/isar/type-check.ts +11 -25
- package/src/prover/isabelle/provers/blast/blast.ts +10 -41
- package/src/prover/isabelle/provers/blast/branch.ts +1 -32
- package/src/prover/isabelle/provers/blast/prove.ts +1 -35
- package/src/prover/isabelle/provers/blast/rules.ts +6 -44
- package/src/prover/isabelle/provers/blast/state.ts +2 -28
- package/src/prover/isabelle/provers/blast/term.ts +9 -36
- package/src/prover/isabelle/provers/clasimp.ts +1 -13
- package/src/prover/isabelle/provers/classical.ts +14 -42
- package/src/prover/isabelle/provers/hypsubst.ts +11 -25
- package/src/prover/isabelle/pure/bicompose.ts +16 -13
- package/src/prover/isabelle/pure/consts.ts +1 -7
- package/src/prover/isabelle/pure/conv.ts +1 -9
- package/src/prover/isabelle/pure/drule.ts +24 -40
- package/src/prover/isabelle/pure/envir.ts +3 -52
- package/src/prover/isabelle/pure/goal.ts +1 -7
- package/src/prover/isabelle/pure/interrupt.ts +0 -5
- package/src/prover/isabelle/pure/list.ts +0 -3
- package/src/prover/isabelle/pure/logic.ts +1 -14
- package/src/prover/isabelle/pure/name.ts +2 -9
- package/src/prover/isabelle/pure/net.ts +3 -59
- package/src/prover/isabelle/pure/object-logic.ts +3 -10
- package/src/prover/isabelle/pure/pattern.ts +2 -19
- package/src/prover/isabelle/pure/raw-simplifier.ts +13 -49
- package/src/prover/isabelle/pure/rewriter.ts +26 -58
- package/src/prover/isabelle/pure/search.ts +3 -10
- package/src/prover/isabelle/pure/seq.ts +1 -10
- package/src/prover/isabelle/pure/simplifier.ts +4 -12
- package/src/prover/isabelle/pure/table.ts +1 -31
- package/src/prover/isabelle/pure/tactic.ts +12 -22
- package/src/prover/isabelle/pure/tactical.ts +6 -12
- package/src/prover/isabelle/pure/term-ord.ts +2 -6
- package/src/prover/isabelle/pure/term.ts +2 -43
- package/src/prover/isabelle/pure/thm.ts +13 -36
- package/src/prover/isabelle/pure/type.ts +2 -15
- package/src/prover/isabelle/pure/unify.ts +20 -30
- package/src/prover/isabelle/pure/variable.ts +3 -7
- package/src/prover/isabelle/tla/classical-setup.ts +9 -19
- package/src/prover/isabelle/tla/context.ts +8 -16
- package/src/prover/isabelle/tla/logic.ts +4 -11
- package/src/prover/isabelle/tla/simpdata.ts +46 -34
- package/src/prover/isabelle/tools/intuitionistic.ts +1 -10
- package/src/prover/ocaml.ts +0 -6
- package/src/prover/prep/action.ts +4 -36
- package/src/prover/prep/enabled-axioms.ts +12 -19
- package/src/prover/prep/fingerprint.ts +0 -16
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +9 -36
- package/src/prover/prep/normalize.ts +4 -28
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +0 -36
- package/src/prover/ptl/decide.ts +7 -12
- package/src/prover/ptl/encode.ts +14 -36
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +12 -26
- package/src/prover/smt/axioms.ts +0 -7
- package/src/prover/smt/context.ts +19 -26
- package/src/prover/smt/data.ts +51 -54
- package/src/prover/smt/encode.ts +14 -35
- package/src/prover/smt/extensionality.ts +0 -10
- package/src/prover/smt/flatten.ts +3 -22
- package/src/prover/smt/format.ts +5 -10
- package/src/prover/smt/instances.ts +0 -10
- package/src/prover/smt/rewrite.ts +66 -101
- package/src/prover/smt/solver/act-cache.ts +0 -15
- package/src/prover/smt/solver/arith-rewriter.ts +3 -48
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +1 -43
- package/src/prover/smt/solver/ast-lt.ts +1 -11
- package/src/prover/smt/solver/ast-util.ts +1 -6
- package/src/prover/smt/solver/ast.ts +1 -143
- package/src/prover/smt/solver/auf-solver.ts +6 -39
- package/src/prover/smt/solver/case-split-queue.ts +1 -9
- package/src/prover/smt/solver/cg-table.ts +1 -18
- package/src/prover/smt/solver/clause.ts +1 -27
- package/src/prover/smt/solver/conflict-resolution.ts +0 -9
- package/src/prover/smt/solver/context.ts +4 -61
- package/src/prover/smt/solver/ctx-simplify.ts +14 -41
- package/src/prover/smt/solver/der.ts +2 -21
- package/src/prover/smt/solver/dyn-ack.ts +1 -11
- package/src/prover/smt/solver/e-matching.ts +3 -34
- package/src/prover/smt/solver/enode.ts +1 -21
- package/src/prover/smt/solver/expr-ref.ts +1 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +0 -5
- package/src/prover/smt/solver/fingerprints.ts +1 -12
- package/src/prover/smt/solver/flat-literals.ts +1 -9
- package/src/prover/smt/solver/goal.ts +2 -14
- package/src/prover/smt/solver/hash.ts +0 -8
- package/src/prover/smt/solver/hashtable.ts +1 -12
- package/src/prover/smt/solver/internalizer.ts +6 -98
- package/src/prover/smt/solver/lbool.ts +1 -2
- package/src/prover/smt/solver/literal.ts +0 -3
- package/src/prover/smt/solver/lp/bound-propagator.ts +8 -26
- package/src/prover/smt/solver/lp/constraints.ts +2 -8
- package/src/prover/smt/solver/lp/containers.ts +12 -30
- package/src/prover/smt/solver/lp/core-solver.ts +10 -31
- package/src/prover/smt/solver/lp/cross-nested.ts +6 -20
- package/src/prover/smt/solver/lp/dep-intervals.ts +7 -22
- package/src/prover/smt/solver/lp/dependency.ts +1 -4
- package/src/prover/smt/solver/lp/dioph-eq.ts +12 -98
- package/src/prover/smt/solver/lp/explanation.ts +1 -6
- package/src/prover/smt/solver/lp/gomory.ts +9 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +17 -23
- package/src/prover/smt/solver/lp/hnf.ts +11 -26
- package/src/prover/smt/solver/lp/int-cube.ts +15 -36
- package/src/prover/smt/solver/lp/int-solver.ts +4 -34
- package/src/prover/smt/solver/lp/lar-solver.ts +32 -81
- package/src/prover/smt/solver/lp/lar-term.ts +1 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +1 -14
- package/src/prover/smt/solver/lp/maximize-term.ts +20 -45
- package/src/prover/smt/solver/lp/nex-creator.ts +5 -28
- package/src/prover/smt/solver/lp/nex.ts +1 -6
- package/src/prover/smt/solver/lp/nla-backoff.ts +1 -4
- package/src/prover/smt/solver/lp/nla-basics.ts +5 -30
- package/src/prover/smt/solver/lp/nla-core.ts +35 -130
- package/src/prover/smt/solver/lp/nla-divisions.ts +32 -42
- package/src/prover/smt/solver/lp/nla-emonics.ts +4 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +1 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +15 -69
- package/src/prover/smt/solver/lp/nla-horner.ts +3 -11
- package/src/prover/smt/solver/lp/nla-intervals.ts +2 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +16 -41
- package/src/prover/smt/solver/lp/nla-monotone.ts +2 -6
- package/src/prover/smt/solver/lp/nla-order.ts +2 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +4 -7
- package/src/prover/smt/solver/lp/nla-tangents.ts +1 -9
- package/src/prover/smt/solver/lp/nla-throttle.ts +1 -6
- package/src/prover/smt/solver/lp/nla-types.ts +1 -11
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -25
- package/src/prover/smt/solver/lp/nra-solver.ts +5 -52
- package/src/prover/smt/solver/lp/numeric-pair.ts +1 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +1 -3
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +2 -14
- package/src/prover/smt/solver/lp/pdd-solver.ts +4 -33
- package/src/prover/smt/solver/lp/pdd.ts +7 -70
- package/src/prover/smt/solver/lp/random-updater.ts +1 -8
- package/src/prover/smt/solver/lp/static-matrix.ts +9 -19
- package/src/prover/smt/solver/lp/union-find.ts +1 -6
- package/src/prover/smt/solver/mam-compiler.ts +14 -56
- package/src/prover/smt/solver/mam-interpreter.ts +1 -21
- package/src/prover/smt/solver/maximize-ac-sharing.ts +2 -17
- package/src/prover/smt/solver/model-checker.ts +2 -36
- package/src/prover/smt/solver/model-evaluator.ts +3 -29
- package/src/prover/smt/solver/model-finder.ts +3 -15
- package/src/prover/smt/solver/model-generator.ts +1 -12
- package/src/prover/smt/solver/model-macro-solver.ts +12 -69
- package/src/prover/smt/solver/nlsat/algebraic.ts +55 -151
- package/src/prover/smt/solver/nlsat/atoms.ts +5 -19
- package/src/prover/smt/solver/nlsat/evaluator.ts +17 -22
- package/src/prover/smt/solver/nlsat/explain.ts +3 -47
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -50
- package/src/prover/smt/solver/nlsat/levelwise.ts +48 -129
- package/src/prover/smt/solver/nlsat/mpbq.ts +3 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +17 -156
- package/src/prover/smt/solver/nlsat/solver.ts +7 -67
- package/src/prover/smt/solver/nlsat/types.ts +1 -8
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -44
- package/src/prover/smt/solver/nlsat/upolynomial.ts +11 -92
- package/src/prover/smt/solver/nnf.ts +3 -38
- package/src/prover/smt/solver/pattern-inference.ts +2 -15
- package/src/prover/smt/solver/poly-rewriter.ts +3 -23
- package/src/prover/smt/solver/propagate-values.ts +1 -10
- package/src/prover/smt/solver/proto-model.ts +3 -48
- package/src/prover/smt/solver/pull-quant.ts +1 -12
- package/src/prover/smt/solver/qe-lite-der.ts +1 -29
- package/src/prover/smt/solver/qe-lite-fm.ts +2 -25
- package/src/prover/smt/solver/qe-lite.ts +3 -33
- package/src/prover/smt/solver/qi-queue.ts +1 -16
- package/src/prover/smt/solver/quant-tactics.ts +5 -22
- package/src/prover/smt/solver/quantifier-analyzer.ts +17 -37
- package/src/prover/smt/solver/quantifier-manager.ts +1 -8
- package/src/prover/smt/solver/random-gen.ts +1 -2
- package/src/prover/smt/solver/rational.ts +1 -8
- package/src/prover/smt/solver/ref-vector.ts +1 -6
- package/src/prover/smt/solver/relevancy.ts +2 -15
- package/src/prover/smt/solver/rewriter-tpl.ts +3 -147
- package/src/prover/smt/solver/rewriter.ts +3 -85
- package/src/prover/smt/solver/rlimit.ts +2 -20
- package/src/prover/smt/solver/smtlib-parser.ts +2 -37
- package/src/prover/smt/solver/solver.ts +23 -34
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/sticky-generations.ts +0 -5
- package/src/prover/smt/solver/theory-lra-axioms.ts +3 -24
- package/src/prover/smt/solver/theory-lra-bounds.ts +0 -5
- package/src/prover/smt/solver/theory-lra-final-check.ts +4 -22
- package/src/prover/smt/solver/theory-lra-internalize.ts +1 -27
- package/src/prover/smt/solver/theory-lra-model.ts +4 -19
- package/src/prover/smt/solver/theory-lra-propagate.ts +1 -15
- package/src/prover/smt/solver/theory-lra-state.ts +3 -8
- package/src/prover/smt/solver/theory-lra.ts +1 -8
- package/src/prover/smt/solver/var-subst.ts +2 -26
- package/src/prover/smt/table.ts +0 -8
- package/src/prover/tlapm/cache.ts +20 -25
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +12 -17
- package/src/prover/verdict.ts +0 -2
- package/src/prover/zenon/check/check.ts +0 -9
- package/src/prover/zenon/check/definitions.ts +5 -15
- package/src/prover/zenon/check/equality.ts +0 -8
- package/src/prover/zenon/check/functions.ts +0 -4
- package/src/prover/zenon/check/keys.ts +0 -7
- package/src/prover/zenon/check/propositional.ts +0 -3
- package/src/prover/zenon/check/records.ts +0 -5
- package/src/prover/zenon/check/relations.ts +0 -13
- package/src/prover/zenon/check/rewrites.ts +0 -6
- package/src/prover/zenon/check/sets.ts +0 -3
- package/src/prover/zenon/check/terms.ts +0 -17
- package/src/prover/zenon/check/tla.ts +0 -6
- package/src/prover/zenon/decide.ts +0 -12
- package/src/prover/zenon/encode.ts +1 -8
- package/src/prover/zenon/eqrel.ts +0 -13
- package/src/prover/zenon/equality-rules.ts +0 -4
- package/src/prover/zenon/expr.ts +1 -26
- package/src/prover/zenon/index-table.ts +17 -38
- package/src/prover/zenon/isar-case.ts +9 -19
- package/src/prover/zenon/isar.ts +1 -29
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +0 -9
- package/src/prover/zenon/mltoll.ts +54 -76
- package/src/prover/zenon/node.ts +1 -11
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +2 -7
- package/src/prover/zenon/phrase.ts +1 -11
- package/src/prover/zenon/proof.ts +0 -9
- package/src/prover/zenon/propositional-rules.ts +0 -5
- package/src/prover/zenon/rules.ts +2 -6
- package/src/prover/zenon/search.ts +1 -17
- package/src/prover/zenon/tla/functions.ts +57 -29
- package/src/prover/zenon/tla/llproof.ts +63 -70
- package/src/prover/zenon/tla/records.ts +56 -27
- package/src/prover/zenon/tla/rewrites.ts +12 -19
- package/src/prover/zenon/tla/sets.ts +68 -39
- package/src/prover/zenon/tla/terms.ts +0 -6
- package/src/prover/zenon/tla/tla.ts +59 -58
- package/src/randomization.ts +84 -35
- package/src/resolve.ts +18 -60
- package/src/runtime.ts +11 -4
- package/src/sany/builtins.ts +3 -4
- package/src/sany/generator.ts +119 -169
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +1 -8
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +0 -31
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +29 -63
- package/src/sany/selectors.ts +15 -39
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +13 -63
- package/src/search.ts +494 -154
- package/src/simulate.ts +694 -0
- package/src/spec-description.ts +166 -48
- package/src/standard-definitions.ts +2 -3
- package/src/standard-modules.ts +264 -68
- package/src/state-graph.ts +51 -18
- package/src/subexpressions.ts +31 -5
- package/src/substitution-levels.ts +2 -3
- package/src/successors.ts +267 -77
- package/src/symmetry.ts +31 -8
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -61
- package/src/tlc/jar-data.ts +113 -6
- package/src/tlc/messages.ts +122 -37
- package/src/tlc/order.ts +33 -38
- package/src/tlc/random.ts +16 -16
- package/src/tlc/replay.ts +563 -211
- package/src/tlc/summary.ts +2 -4
- package/src/tlc/tlc-operators.ts +81 -36
- package/src/tlc/tlcext-operators.ts +138 -117
- package/src/tlc/trace-spec.ts +273 -0
- package/src/tlc/value-stream.ts +143 -0
- package/src/tlc/version.ts +2 -4
- package/src/transfer.ts +22 -25
- package/src/typescript/actions.ts +481 -0
- package/src/typescript/collections.ts +600 -0
- package/src/typescript/compile.ts +65 -0
- package/src/typescript/context.ts +94 -0
- package/src/typescript/emit.ts +121 -0
- package/src/typescript/expressions.ts +496 -0
- package/src/typescript/formula.ts +152 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +163 -0
- package/src/typescript/names.ts +114 -0
- package/src/typescript/program.ts +48 -0
- package/src/typescript/properties.ts +139 -0
- package/src/typescript/scope.ts +112 -0
- package/src/typescript/steps.ts +165 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +826 -276
- package/src/worker.ts +7 -8
package/src/sany/levels.ts
CHANGED
|
@@ -27,9 +27,7 @@ import {
|
|
|
27
27
|
type ThmOrAssumpDefNode,
|
|
28
28
|
} from "./nodes";
|
|
29
29
|
|
|
30
|
-
// A port of the levelCheck methods of SANY's semantic nodes
|
|
31
|
-
// its XMLExporter writes, and the level errors it reports. Each check returns what SANY's returns,
|
|
32
|
-
// which is whether the node is free of level errors, or true for the nodes that ignore that.
|
|
30
|
+
// A port of the levelCheck methods of SANY's semantic nodes.
|
|
33
31
|
|
|
34
32
|
type AnyDefNode = OpDefNode | ThmOrAssumpDefNode;
|
|
35
33
|
|
|
@@ -72,7 +70,6 @@ const addArgLevelParams = (
|
|
|
72
70
|
});
|
|
73
71
|
};
|
|
74
72
|
|
|
75
|
-
// SetOfLevelConstraints.put keeps the lowest bound.
|
|
76
73
|
const putLevelConstraint = (target: Map<SymbolNode, number>, param: SymbolNode, level: number) => {
|
|
77
74
|
target.set(param, Math.min(level, target.get(param) ?? TEMPORAL_LEVEL));
|
|
78
75
|
};
|
|
@@ -89,7 +86,6 @@ const putLevelConstraints = (
|
|
|
89
86
|
|
|
90
87
|
const getArgLevelConstraintKey = (param: SymbolNode, position: number) => `${param.id}:${position}`;
|
|
91
88
|
|
|
92
|
-
// SetOfArgLevelConstraints.put keeps the highest bound.
|
|
93
89
|
const putArgLevelConstraint = (
|
|
94
90
|
target: Map<string, ArgLevelConstraint>,
|
|
95
91
|
param: SymbolNode,
|
|
@@ -129,7 +125,6 @@ const mergeLevels = (node: LevelFields, part: LevelFields) => {
|
|
|
129
125
|
addArgLevelParams(node.argLevelParams, part.argLevelParams);
|
|
130
126
|
};
|
|
131
127
|
|
|
132
|
-
// ArgLevelParam.occur.
|
|
133
128
|
const isOccurring = (argLevelParam: ArgLevelParam, symbols: SymbolNode[]) =>
|
|
134
129
|
symbols.includes(argLevelParam.op) || symbols.includes(argLevelParam.param);
|
|
135
130
|
|
|
@@ -170,14 +165,12 @@ const getBoundSymbols = (node: OpApplNode) => [
|
|
|
170
165
|
const getSubstitute = (symbol: SymbolNode, substs: Subst[]) =>
|
|
171
166
|
substs.find((subst) => subst.op === symbol)?.expr;
|
|
172
167
|
|
|
173
|
-
// Subst.paramSet and Subst.allParamSet.
|
|
174
168
|
const getSubstitutedParams = (param: SymbolNode, substs: Subst[], isAll: boolean) => {
|
|
175
169
|
const substitute = getSubstitute(param, substs);
|
|
176
170
|
if (substitute === undefined) return new Set([param]);
|
|
177
171
|
return isAll ? substitute.allParams : substitute.levelParams;
|
|
178
172
|
};
|
|
179
173
|
|
|
180
|
-
// Subst.getSubALPSet.
|
|
181
174
|
const getSubstitutedArgLevelParams = (source: Map<string, ArgLevelParam>, substs: Subst[]) => {
|
|
182
175
|
const result = new Map<string, ArgLevelParam>();
|
|
183
176
|
source.forEach((argLevelParam, key) => {
|
|
@@ -201,7 +194,6 @@ interface ConstraintSource {
|
|
|
201
194
|
argLevelParams: Map<string, ArgLevelParam>;
|
|
202
195
|
}
|
|
203
196
|
|
|
204
|
-
// Subst.getSubLCSet.
|
|
205
197
|
const getSubstitutedLevelConstraints = (
|
|
206
198
|
body: ConstraintSource,
|
|
207
199
|
substs: Subst[],
|
|
@@ -235,7 +227,6 @@ const getSubstitutedLevelConstraints = (
|
|
|
235
227
|
return result;
|
|
236
228
|
};
|
|
237
229
|
|
|
238
|
-
// Subst.getSubALCSet.
|
|
239
230
|
const getSubstitutedArgLevelConstraints = (
|
|
240
231
|
body: ConstraintSource,
|
|
241
232
|
substs: Subst[],
|
|
@@ -268,7 +259,6 @@ const getSubstitutedArgLevelConstraints = (
|
|
|
268
259
|
return result;
|
|
269
260
|
};
|
|
270
261
|
|
|
271
|
-
// ModuleNode.isConstant.
|
|
272
262
|
const isConstantModule = (module: ModuleNode, check: LevelCheck) => {
|
|
273
263
|
if (getDeclarations(module, VARIABLE_DECL_KIND).length > 0) return false;
|
|
274
264
|
checkModuleLevels(module, check);
|
|
@@ -278,7 +268,6 @@ const isConstantModule = (module: ModuleNode, check: LevelCheck) => {
|
|
|
278
268
|
return module.topLevel.every((node) => node.kind !== "Theorem" || node.level === CONSTANT_LEVEL);
|
|
279
269
|
};
|
|
280
270
|
|
|
281
|
-
// The parts of OpDefNode.levelCheck and ThmOrAssumpDefNode.levelCheck that follow the body's.
|
|
282
271
|
const checkDefinitionBody = (node: AnyDefNode, params: FormalParamNode[], body: LevelFields) => {
|
|
283
272
|
node.minMaxLevel = params.map((param) =>
|
|
284
273
|
Array.from(
|
|
@@ -323,8 +312,6 @@ const checkDefinitionBody = (node: AnyDefNode, params: FormalParamNode[], body:
|
|
|
323
312
|
);
|
|
324
313
|
};
|
|
325
314
|
|
|
326
|
-
// The checks of OpApplNode.levelCheck that compare the levels of the arguments of a defined
|
|
327
|
-
// operator with the levels it allows.
|
|
328
315
|
const checkArguments = (
|
|
329
316
|
node: OpApplNode,
|
|
330
317
|
operator: AnyDefNode,
|
|
@@ -395,7 +382,6 @@ const checkArguments = (
|
|
|
395
382
|
});
|
|
396
383
|
};
|
|
397
384
|
|
|
398
|
-
// The level constraints OpApplNode.levelCheck derives for an application of a defined operator.
|
|
399
385
|
const constrainArguments = (
|
|
400
386
|
node: OpApplNode,
|
|
401
387
|
operator: AnyDefNode,
|
|
@@ -532,8 +518,6 @@ const constrainArguments = (
|
|
|
532
518
|
});
|
|
533
519
|
};
|
|
534
520
|
|
|
535
|
-
// The operators OpApplNode.levelCheck rejects with both temporal and action arguments, and how its
|
|
536
|
-
// message names them.
|
|
537
521
|
const LOGICAL_OPERATOR_NAMES = new Map([
|
|
538
522
|
["\\land", "\\land"],
|
|
539
523
|
["\\lor", "\\lor"],
|
|
@@ -543,9 +527,7 @@ const LOGICAL_OPERATOR_NAMES = new Map([
|
|
|
543
527
|
["$DisjList", "Disjunction list"],
|
|
544
528
|
]);
|
|
545
529
|
|
|
546
|
-
//
|
|
547
|
-
// 1.7.4's SANY reports these errors but leaves the node level-correct, so an operator applied to it
|
|
548
|
-
// still checks its level.
|
|
530
|
+
// TLC 1.7.4's SANY reports these errors but leaves the node level-correct.
|
|
549
531
|
const checkTemporalApplication = (node: OpApplNode, check: LevelCheck) => {
|
|
550
532
|
const addTemporalError = (location: SanyLocation, text: string) => {
|
|
551
533
|
addError(check, location, text);
|
|
@@ -710,8 +692,8 @@ const checkTheoremDefinition = (node: ThmOrAssumpDefNode, iteration: number, che
|
|
|
710
692
|
return node.levelCorrect;
|
|
711
693
|
};
|
|
712
694
|
|
|
713
|
-
//
|
|
714
|
-
//
|
|
695
|
+
// SANY checks the definitions of each recursive section twice, the second time with the highest
|
|
696
|
+
// level and the parameters of the section's recursive operators.
|
|
715
697
|
export const checkModuleLevels = (module: ModuleNode, check: LevelCheck) => {
|
|
716
698
|
if (module.isLevelChecked) return module.levelCorrect;
|
|
717
699
|
module.isLevelChecked = true;
|
|
@@ -796,7 +778,6 @@ export const checkModuleLevels = (module: ModuleNode, check: LevelCheck) => {
|
|
|
796
778
|
return module.levelCorrect;
|
|
797
779
|
};
|
|
798
780
|
|
|
799
|
-
// LevelNode.levelCheckSubnodes, which skips modules.
|
|
800
781
|
const checkSubnodes = (
|
|
801
782
|
node: LevelFields,
|
|
802
783
|
subnodes: SemanticNode[],
|
|
@@ -816,8 +797,6 @@ const checkSubnodes = (
|
|
|
816
797
|
return node.levelCorrect;
|
|
817
798
|
};
|
|
818
799
|
|
|
819
|
-
// TheoremNode.LevelCheckTemporal: the steps of the proof of a temporal theorem that must be
|
|
820
|
-
// constant.
|
|
821
800
|
const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) => {
|
|
822
801
|
if (proof?.kind !== "NonLeafProof") return;
|
|
823
802
|
proof.steps.forEach((step) => {
|
|
@@ -840,7 +819,6 @@ const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) =>
|
|
|
840
819
|
});
|
|
841
820
|
};
|
|
842
821
|
|
|
843
|
-
// InstanceNode.levelCheck.
|
|
844
822
|
const checkInstance = (node: InstanceNode, iteration: number, check: LevelCheck) => {
|
|
845
823
|
if (node.levelChecked >= iteration) return node.levelCorrect;
|
|
846
824
|
node.levelChecked = iteration;
|
|
@@ -1121,7 +1099,6 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
|
|
|
1121
1099
|
node.levelChecked = iteration;
|
|
1122
1100
|
const isBodyCorrect = checkLevel(node.body, iteration, check);
|
|
1123
1101
|
const isDefinitionCorrect = !node.definition || checkLevel(node.definition, iteration, check);
|
|
1124
|
-
// AssumeNode's getters return its expression's levels.
|
|
1125
1102
|
node.level = node.body.level;
|
|
1126
1103
|
shareLevels(node, node.body);
|
|
1127
1104
|
if (node.level !== CONSTANT_LEVEL) {
|
|
@@ -1134,8 +1111,8 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
|
|
|
1134
1111
|
return isBodyCorrect && isDefinitionCorrect;
|
|
1135
1112
|
}
|
|
1136
1113
|
case "Theorem": {
|
|
1137
|
-
// TheoremNode declares its own levelChecked, so levelCheckSubnodes still runs on
|
|
1138
|
-
//
|
|
1114
|
+
// TheoremNode declares its own levelChecked, so levelCheckSubnodes still runs on its definition,
|
|
1115
|
+
// or its statement when it has none, and its proof.
|
|
1139
1116
|
if (node.levelChecked >= iteration) return true;
|
|
1140
1117
|
const isCorrect = checkSubnodes(
|
|
1141
1118
|
node,
|
|
@@ -1191,7 +1168,6 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
|
|
|
1191
1168
|
node.goal.level,
|
|
1192
1169
|
);
|
|
1193
1170
|
[node.goal, ...node.assumptions].forEach((part) => mergeLevels(node, part));
|
|
1194
|
-
// LevelNode.addTemporalLevelConstraintToConstants.
|
|
1195
1171
|
if (node.levelCorrect) {
|
|
1196
1172
|
node.levelParams.forEach((param) => {
|
|
1197
1173
|
if (param.kind === "OpDecl" && param.declKind === CONSTANT_DECL_KIND) {
|
package/src/sany/lexer.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TlaError } from "../errors";
|
|
2
2
|
|
|
3
|
-
// An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj
|
|
4
|
-
// tokens it produces, their kinds in TLAplusParserConstants order, and their positions.
|
|
3
|
+
// An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj.
|
|
5
4
|
|
|
6
5
|
export interface SanyToken {
|
|
7
6
|
kind: number;
|
|
@@ -11,8 +10,7 @@ export interface SanyToken {
|
|
|
11
10
|
next: SanyToken | undefined;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
//
|
|
15
|
-
// produce it. JavaCC breaks a tie between matches of the same length by this order.
|
|
13
|
+
// In TLAplusParserConstants order, by which JavaCC breaks a tie between matches of one length.
|
|
16
14
|
const KINDS: [string, ...string[]][] = [
|
|
17
15
|
["EOF"],
|
|
18
16
|
["BEGIN_PRAGMA", "--->"],
|
|
@@ -261,7 +259,6 @@ const BAND_PATTERNS = getJunctionPatterns(String.raw`\.\/\\`);
|
|
|
261
259
|
const BOR_PATTERNS = getJunctionPatterns(String.raw`\.\\\/`);
|
|
262
260
|
const STEP = String.raw`<(?:[0-9]+|\+|\*)>`;
|
|
263
261
|
|
|
264
|
-
// The tokens of the SPEC lexical state that are not literals, with their kinds.
|
|
265
262
|
const SPEC_PATTERNS: [string, RegExp[]][] = [
|
|
266
263
|
["_BM0", [BEGIN_MODULE]],
|
|
267
264
|
["SEPARATOR", [/----+/y]],
|
|
@@ -278,7 +275,6 @@ const SPEC_PATTERNS: [string, RegExp[]][] = [
|
|
|
278
275
|
["UnnumberedStepLexeme", [new RegExp(String.raw`${STEP}(?:\*\.*|-\.*|\.+)`, "y")]],
|
|
279
276
|
];
|
|
280
277
|
|
|
281
|
-
// The tokens of the DEFAULT and PRAGMA lexical states, which skip every other character.
|
|
282
278
|
const DEFAULT_PATTERNS: [string, RegExp[]][] = [
|
|
283
279
|
["BEGIN_PRAGMA", [/--->/y]],
|
|
284
280
|
["_BM1", [BEGIN_MODULE]],
|
|
@@ -296,7 +292,6 @@ const getMatchLength = (pattern: RegExp, source: string, offset: number) => {
|
|
|
296
292
|
return pattern.exec(source)?.[0].length ?? 0;
|
|
297
293
|
};
|
|
298
294
|
|
|
299
|
-
// The longest match at offset, the earliest kind among matches of that length.
|
|
300
295
|
const matchPatterns = (patterns: [string, RegExp[]][], source: string, offset: number) =>
|
|
301
296
|
patterns
|
|
302
297
|
.map(([name, regexes]) => ({
|
|
@@ -329,8 +324,6 @@ const matchSpecToken = (source: string, offset: number) => {
|
|
|
329
324
|
|
|
330
325
|
export const getTabStop = (column: number) => column + 8 - (column % 8);
|
|
331
326
|
|
|
332
|
-
// SimpleCharStream.UpdateLineColumn: the line and column of each character, with tabs stopping
|
|
333
|
-
// at multiples of 8.
|
|
334
327
|
const getPositions = (source: string) => {
|
|
335
328
|
const lines: number[] = [];
|
|
336
329
|
const columns: number[] = [];
|
|
@@ -360,7 +353,6 @@ const getPositions = (source: string) => {
|
|
|
360
353
|
return { lines, columns };
|
|
361
354
|
};
|
|
362
355
|
|
|
363
|
-
// The characters of a string literal that a string literal could still continue.
|
|
364
356
|
const STRING_PREFIX = /"(?:[^"\n\r\\]|\\[ntrf\\"])*\\?/y;
|
|
365
357
|
const LITERAL_PREFIXES = new Set(
|
|
366
358
|
[...LITERALS.keys()].flatMap((image) =>
|
|
@@ -368,7 +360,6 @@ const LITERAL_PREFIXES = new Set(
|
|
|
368
360
|
),
|
|
369
361
|
);
|
|
370
362
|
|
|
371
|
-
// The characters JavaCC's token manager reads at offset while some token could still continue.
|
|
372
363
|
const getTokenPrefix = (source: string, offset: number) => {
|
|
373
364
|
let length = 0;
|
|
374
365
|
while (LITERAL_PREFIXES.has(source.slice(offset, offset + length + 1))) length++;
|
|
@@ -378,9 +369,6 @@ const getTokenPrefix = (source: string, offset: number) => {
|
|
|
378
369
|
);
|
|
379
370
|
};
|
|
380
371
|
|
|
381
|
-
// A lazy token stream over source, which returns SANY's message for the TokenMgrError JavaCC's
|
|
382
|
-
// token manager throws at a character no token continues with, or at the end of the file in a
|
|
383
|
-
// comment.
|
|
384
372
|
export const createSanyLexer = (source: string) => {
|
|
385
373
|
const positions = getPositions(source);
|
|
386
374
|
const state = { offset: 0, mode: "DEFAULT" };
|
|
@@ -393,8 +381,8 @@ export const createSanyLexer = (source: string) => {
|
|
|
393
381
|
});
|
|
394
382
|
// JavaCC places the end of the file at the file's last character.
|
|
395
383
|
const getEndOfFile = () => createToken(getKind("EOF"), source.length - 1, 0);
|
|
396
|
-
//
|
|
397
|
-
//
|
|
384
|
+
// TLAplusParser.parse reports the end of the file in a token that starts on an earlier line as an
|
|
385
|
+
// open comment.
|
|
398
386
|
const getLexicalError = (start: number, end: number, after: string) => {
|
|
399
387
|
const index = end - 1;
|
|
400
388
|
const line = positions.lines[index];
|
|
@@ -407,8 +395,7 @@ export const createSanyLexer = (source: string) => {
|
|
|
407
395
|
? formatLexicalError(line + 1, 0, undefined, after)
|
|
408
396
|
: formatLexicalError(line, column + 1, undefined, after);
|
|
409
397
|
};
|
|
410
|
-
//
|
|
411
|
-
// end of the file right after a bracket ends the token stream.
|
|
398
|
+
// The end of the file right after a nested comment bracket ends the token stream.
|
|
412
399
|
const skipComment = () => {
|
|
413
400
|
const start = state.offset;
|
|
414
401
|
if (source.startsWith("\\*", start)) {
|
|
@@ -481,7 +468,6 @@ export const createSanyLexer = (source: string) => {
|
|
|
481
468
|
return getNextToken;
|
|
482
469
|
};
|
|
483
470
|
|
|
484
|
-
// JavaCC's TokenMgrError.addEscapes, which escapes the characters of a lexical error's message.
|
|
485
471
|
const LEXEME_ESCAPES = new Map([
|
|
486
472
|
["\b", "\\b"],
|
|
487
473
|
["\t", "\\t"],
|
|
@@ -502,8 +488,6 @@ export const escapeLexeme = (text: string) =>
|
|
|
502
488
|
(character === "\0" ? "" : `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`),
|
|
503
489
|
);
|
|
504
490
|
|
|
505
|
-
// TokenMgrError.LexicalError: the character the lexer stopped at, or the end of the file, and the
|
|
506
|
-
// characters of the token it had read.
|
|
507
491
|
export const formatLexicalError = (
|
|
508
492
|
line: number,
|
|
509
493
|
column: number,
|
|
@@ -512,8 +496,8 @@ export const formatLexicalError = (
|
|
|
512
496
|
) =>
|
|
513
497
|
`Lexical error at line ${line}, column ${column}. Encountered: ${character === undefined ? "<EOF> " : `"${escapeLexeme(character)}" (${character.charCodeAt(0)}), `}after : "${escapeLexeme(after)}"`;
|
|
514
498
|
|
|
515
|
-
// TLC 1.7.4's lexer,
|
|
516
|
-
//
|
|
499
|
+
// TLC 1.7.4's lexer, generated without UNICODE_INPUT, reads a character past U+00FF outside a
|
|
500
|
+
// comment by its low byte, and stops at one whose low byte is below 0x80.
|
|
517
501
|
export const getSany174LexicalError = (source: string) => {
|
|
518
502
|
const readToken = createSanyLexer(source);
|
|
519
503
|
for (
|
package/src/sany/linter.ts
CHANGED
|
@@ -7,10 +7,8 @@ import {
|
|
|
7
7
|
type SemanticNode,
|
|
8
8
|
} from "./nodes";
|
|
9
9
|
|
|
10
|
-
// A port of SANY's tla2sany.linter.Linter
|
|
11
|
-
// definition or declaration of the module.
|
|
10
|
+
// A port of SANY's tla2sany.linter.Linter.
|
|
12
11
|
|
|
13
|
-
// SemanticNode.getChildren.
|
|
14
12
|
const getChildren = (node: SemanticNode): (SemanticNode | undefined)[] => {
|
|
15
13
|
switch (node.kind) {
|
|
16
14
|
case "OpAppl":
|
|
@@ -35,7 +33,6 @@ const getChildren = (node: SemanticNode): (SemanticNode | undefined)[] => {
|
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
35
|
|
|
38
|
-
// Operators whose values are sets of values that a record field may range over.
|
|
39
36
|
const SET_OPERATORS = new Map([
|
|
40
37
|
["Integers", "Int"],
|
|
41
38
|
["Naturals", "Nat"],
|
|
@@ -43,8 +40,6 @@ const SET_OPERATORS = new Map([
|
|
|
43
40
|
["Reals", "Reals"],
|
|
44
41
|
]);
|
|
45
42
|
|
|
46
|
-
// Linter.isBuiltFromDeclarations: whether an expression applies a declared or bound symbol, BOOLEAN
|
|
47
|
-
// or a standard set of numbers, directly or through the definitions it applies.
|
|
48
43
|
const isBuiltFromDeclarations = (node: SemanticNode | undefined) => {
|
|
49
44
|
const visited = new Set<SemanticNode>();
|
|
50
45
|
const visit = (current: SemanticNode | undefined): boolean => {
|
|
@@ -83,7 +78,6 @@ const getDomain = (record: OpApplNode) =>
|
|
|
83
78
|
.sort(),
|
|
84
79
|
]);
|
|
85
80
|
|
|
86
|
-
// ModuleNode.getExtendedModuleSet(true).
|
|
87
81
|
const getExtendedModules = (module: ModuleNode, found = new Set<ModuleNode>()) => {
|
|
88
82
|
module.extendees.forEach((extendee) => {
|
|
89
83
|
if (found.has(extendee)) return;
|
|
@@ -93,7 +87,6 @@ const getExtendedModules = (module: ModuleNode, found = new Set<ModuleNode>()) =
|
|
|
93
87
|
return found;
|
|
94
88
|
};
|
|
95
89
|
|
|
96
|
-
// Linter.lintRecords: the warnings for the records of a module.
|
|
97
90
|
export const lintSanyModule = (module: ModuleNode): SanyMessage[] => {
|
|
98
91
|
const linted = module.records.map((record) => ({
|
|
99
92
|
domain: getDomain(record),
|
package/src/sany/modules.ts
CHANGED
|
@@ -156,8 +156,7 @@ CopiesIn(e, B) ==
|
|
|
156
156
|
5 Dec 98 : Initial version.
|
|
157
157
|
`;
|
|
158
158
|
|
|
159
|
-
//
|
|
160
|
-
// since the XML that SANY exports locates every node of them and keeps their comments.
|
|
159
|
+
// Verbatim from tla2tools.jar 2026.10.28, since SANY's XML locates every node and keeps comments.
|
|
161
160
|
export const SANY_STANDARD_MODULES = new Map([
|
|
162
161
|
["Bags", BAGS],
|
|
163
162
|
[
|
|
@@ -1289,8 +1288,6 @@ _TLCTrace ==
|
|
|
1289
1288
|
],
|
|
1290
1289
|
]);
|
|
1291
1290
|
|
|
1292
|
-
// The standard modules of TLC 1.7.4's tla2tools.jar, which has none of the later ones and older
|
|
1293
|
-
// Bags, Randomization and Toolbox modules.
|
|
1294
1291
|
export const SANY_174_STANDARD_MODULES = new Map([
|
|
1295
1292
|
...[...SANY_STANDARD_MODULES].filter(([name]) =>
|
|
1296
1293
|
["FiniteSets", "Integers", "Naturals", "RealTime", "Reals", "Sequences", "TLC"].includes(name),
|
|
@@ -1393,6 +1390,5 @@ _TEPosition ==
|
|
|
1393
1390
|
],
|
|
1394
1391
|
]);
|
|
1395
1392
|
|
|
1396
|
-
// The standard modules of the SANY of a TLC.
|
|
1397
1393
|
export const getSanyStandardModules = (version: TlcVersion = "master") =>
|
|
1398
1394
|
version === "1.7.4" ? SANY_174_STANDARD_MODULES : SANY_STANDARD_MODULES;
|
package/src/sany/nodes.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The semantic nodes of SANY's tla2sany.semantic package that its XMLExporter writes out, with the
|
|
2
|
-
// fields that the export and SANY's level checking read.
|
|
3
|
-
|
|
4
1
|
export interface SanyLocation {
|
|
5
2
|
file: string;
|
|
6
3
|
beginLine: number;
|
|
@@ -9,27 +6,21 @@ export interface SanyLocation {
|
|
|
9
6
|
endColumn: number;
|
|
10
7
|
}
|
|
11
8
|
|
|
12
|
-
// An error or warning SANY reports, with the location its message names. A location of undefined
|
|
13
|
-
// is SANY's unknown location, and one that is just a module name stands for the whole module.
|
|
14
9
|
export interface SanyMessage {
|
|
15
10
|
location: SanyLocation | string | undefined;
|
|
16
11
|
text: string;
|
|
17
12
|
isWarning: boolean;
|
|
18
|
-
// The ErrorCode SANY files a message under, where another check files the same text.
|
|
19
13
|
code?: string;
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
// Errors.addMessage: SANY keeps one copy of each message, and after TLC 1.7.4 one for each code.
|
|
23
16
|
export const addSanyMessage = (messages: SanyMessage[], message: SanyMessage) => {
|
|
24
17
|
const key = JSON.stringify(message);
|
|
25
18
|
if (!messages.some((candidate) => JSON.stringify(candidate) === key)) messages.push(message);
|
|
26
19
|
};
|
|
27
20
|
|
|
28
|
-
// Location.toString.
|
|
29
21
|
export const formatSanyLocation = (location: SanyMessage["location"]) => {
|
|
30
22
|
if (location === undefined) return "Unknown location";
|
|
31
23
|
if (typeof location === "string") return `In module ${location}`;
|
|
32
|
-
// Location.toString names only the module of a location at line 0, column 0.
|
|
33
24
|
if (
|
|
34
25
|
location.beginLine === 0 &&
|
|
35
26
|
location.beginColumn === 0 &&
|
|
@@ -41,23 +32,18 @@ export const formatSanyLocation = (location: SanyMessage["location"]) => {
|
|
|
41
32
|
return `line ${location.beginLine}, col ${location.beginColumn} to line ${location.endLine}, col ${location.endColumn} of module ${location.file}`;
|
|
42
33
|
};
|
|
43
34
|
|
|
44
|
-
// SANY's ArgLevelParam: the level of argument index of operator op depends on param.
|
|
45
35
|
export interface ArgLevelParam {
|
|
46
36
|
op: SymbolNode;
|
|
47
37
|
index: number;
|
|
48
38
|
param: SymbolNode;
|
|
49
39
|
}
|
|
50
40
|
|
|
51
|
-
// SANY's ParamAndPosition with its level in a SetOfArgLevelConstraints: the argument at position of
|
|
52
|
-
// operator param must be allowed a level of at least level.
|
|
53
41
|
export interface ArgLevelConstraint {
|
|
54
42
|
param: SymbolNode;
|
|
55
43
|
position: number;
|
|
56
44
|
level: number;
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
// The fields of SANY's LevelNode. levelChecked is 0 until levelCheck runs, and SANY exports a level
|
|
60
|
-
// only for the nodes it has level-checked.
|
|
61
47
|
export interface LevelFields {
|
|
62
48
|
id: number;
|
|
63
49
|
levelChecked: number;
|
|
@@ -67,12 +53,10 @@ export interface LevelFields {
|
|
|
67
53
|
nonLeibnizParams: Set<SymbolNode>;
|
|
68
54
|
argLevelParams: Map<string, ArgLevelParam>;
|
|
69
55
|
levelCorrect: boolean;
|
|
70
|
-
// SetOfLevelConstraints: the highest level each parameter may have.
|
|
71
56
|
levelConstraints: Map<SymbolNode, number>;
|
|
72
57
|
argLevelConstraints: Map<string, ArgLevelConstraint>;
|
|
73
58
|
}
|
|
74
59
|
|
|
75
|
-
// SANY's kinds of declared symbols, from tla2sany.semantic.ASTConstants.
|
|
76
60
|
export const CONSTANT_DECL_KIND = 2;
|
|
77
61
|
export const VARIABLE_DECL_KIND = 3;
|
|
78
62
|
export const NEW_CONSTANT_KIND = 24;
|
|
@@ -117,7 +101,6 @@ export interface OpDefNode extends LevelFields {
|
|
|
117
101
|
maxLevels: number[];
|
|
118
102
|
minMaxLevel: number[][] | undefined;
|
|
119
103
|
labels: Map<string, LabelNode>;
|
|
120
|
-
// The DEFINE, USE, HIDE or INSTANCE step that a NumberedProofStep definition names.
|
|
121
104
|
step: ProofStepNode | undefined;
|
|
122
105
|
}
|
|
123
106
|
|
|
@@ -154,7 +137,6 @@ export interface ModuleNode {
|
|
|
154
137
|
argLevelParams: Map<string, ArgLevelParam>;
|
|
155
138
|
levelConstraints: Map<SymbolNode, number>;
|
|
156
139
|
argLevelConstraints: Map<string, ArgLevelConstraint>;
|
|
157
|
-
// ModuleNode.getRecords: the record constructors and sets of records generated for the module.
|
|
158
140
|
records: OpApplNode[];
|
|
159
141
|
}
|
|
160
142
|
|
|
@@ -169,9 +151,7 @@ export interface OpApplNode extends LevelFields {
|
|
|
169
151
|
tupleOrs: boolean[] | undefined;
|
|
170
152
|
ranges: ExprNode[];
|
|
171
153
|
location: SanyLocation;
|
|
172
|
-
// Generator.nullOAN, whose operator, nullODN, has no kind that the XMLExporter can export.
|
|
173
154
|
isNull?: boolean;
|
|
174
|
-
// The null that SANY generates for an operator it cannot resolve.
|
|
175
155
|
isAbsent?: boolean;
|
|
176
156
|
}
|
|
177
157
|
|
|
@@ -272,8 +252,6 @@ export interface TheoremNode extends LevelFields {
|
|
|
272
252
|
location: SanyLocation;
|
|
273
253
|
}
|
|
274
254
|
|
|
275
|
-
// A fact of a BY, USE or HIDE: an expression, an ASSUME/PROVE or NEW clause, a module, or the
|
|
276
|
-
// definition of a module instance.
|
|
277
255
|
export type FactNode = LevelNode | ModuleNode | OpDefNode;
|
|
278
256
|
|
|
279
257
|
export interface LeafProofNode extends LevelFields {
|
|
@@ -348,9 +326,6 @@ type TopLevelNode = InstanceNode | AssumeNode | TheoremNode | UseOrHideNode;
|
|
|
348
326
|
|
|
349
327
|
export type SemanticNode = SymbolNode | LevelNode | TopLevelNode | ProofPartNode;
|
|
350
328
|
|
|
351
|
-
// SANY's Context: a java.util.Hashtable from names to symbols, whose iteration order SANY's lists
|
|
352
|
-
// of constants, variables and instantiated definitions follow, and the symbols in the order they
|
|
353
|
-
// were added.
|
|
354
329
|
export interface Context {
|
|
355
330
|
table: JavaHashtable;
|
|
356
331
|
symbols: SymbolNode[];
|
|
@@ -368,7 +343,6 @@ interface JavaHashtable {
|
|
|
368
343
|
threshold: number;
|
|
369
344
|
}
|
|
370
345
|
|
|
371
|
-
// java.lang.String.hashCode, over UTF-16 code units.
|
|
372
346
|
const getJavaHash = (text: string) => {
|
|
373
347
|
let hash = 0;
|
|
374
348
|
for (let index = 0; index < text.length; index++) {
|
|
@@ -377,7 +351,6 @@ const getJavaHash = (text: string) => {
|
|
|
377
351
|
return hash;
|
|
378
352
|
};
|
|
379
353
|
|
|
380
|
-
// A java.util.Hashtable with its default capacity of 11 and load factor of 0.75.
|
|
381
354
|
const createJavaHashtable = (): JavaHashtable => ({
|
|
382
355
|
buckets: Array.from({ length: 11 }, () => []),
|
|
383
356
|
count: 0,
|
|
@@ -417,7 +390,6 @@ const putHashtableValue = (table: JavaHashtable, key: string, value: SymbolNode,
|
|
|
417
390
|
table.count++;
|
|
418
391
|
};
|
|
419
392
|
|
|
420
|
-
// The values in the order of Hashtable.elements(), from the last bucket to the first.
|
|
421
393
|
export const getHashtableValues = (table: JavaHashtable) =>
|
|
422
394
|
table.buckets.toReversed().flatMap((bucket) => bucket.map((entry) => entry.value));
|
|
423
395
|
|
|
@@ -442,14 +414,11 @@ export const getContextSymbol = (context: Context, name: string) =>
|
|
|
442
414
|
export const getContextModule = (context: Context, name: string) =>
|
|
443
415
|
getHashtableValue(context.table, MODULE_KEY_PREFIX + name, name);
|
|
444
416
|
|
|
445
|
-
// ModuleNode.getOpDefs: the definitions in the order they joined the context, without builtins
|
|
446
|
-
// and module instances.
|
|
447
417
|
export const getOpDefs = (module: ModuleNode) =>
|
|
448
418
|
module.context.symbols.filter(
|
|
449
419
|
(symbol): symbol is OpDefNode => symbol.kind === "OpDef" && symbol.defKind === "UserDefined",
|
|
450
420
|
);
|
|
451
421
|
|
|
452
|
-
// ModuleNode.getConstantDecls and getVariableDecls reverse the Hashtable's order.
|
|
453
422
|
export const getDeclarations = (module: ModuleNode, declKind: number) =>
|
|
454
423
|
getHashtableValues(module.context.table)
|
|
455
424
|
.filter(
|