tla-ts 0.0.4-dev.fa107ef → 0.0.5-dev.cc59f31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -126
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +44 -12
- package/dist/index.d.ts +44 -12
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -4
- package/dist/parallel-worker.js +1 -4
- package/dist/prove-worker.cjs +9 -0
- package/dist/prove-worker.d.cts +9 -0
- package/dist/prove-worker.d.ts +9 -0
- package/dist/prove-worker.js +9 -0
- package/dist/prove.cjs +1006 -0
- package/dist/prove.js +1006 -0
- package/dist/run.cjs +45 -0
- package/dist/run.js +45 -0
- package/dist/tlapm.cjs +10 -0
- package/dist/tlapm.js +10 -0
- package/dist/transfer.cjs +76 -92
- package/dist/transfer.js +76 -92
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +21 -12
- package/src/ast.ts +2 -2
- package/src/bags.ts +22 -23
- package/src/builtins.ts +16 -8
- package/src/check.ts +131 -1153
- 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} +115 -721
- package/src/cli/xml-exporter.ts +221 -0
- package/src/cli.ts +1 -1
- package/src/codegen.ts +43 -22
- package/src/config.ts +5 -5
- package/src/dependencies.ts +4 -6
- package/src/environment.ts +55 -60
- package/src/errors.ts +97 -35
- package/src/evaluate.ts +135 -120
- package/src/exit-codes.ts +1 -1
- package/src/fingerprints.ts +3 -3
- package/src/index.ts +10 -0
- 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/{obligation-action.ts → obligations/action.ts} +248 -74
- package/src/{obligation-anon.ts → obligations/anonymize.ts} +55 -57
- package/src/obligations/equality.ts +260 -0
- package/src/obligations/expression.ts +618 -0
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/obligations/generate.ts +457 -0
- package/src/{obligations.ts → obligations/index.ts} +46 -32
- package/src/{obligation-levels.ts → obligations/levels.ts} +44 -40
- package/src/obligations/module.ts +445 -0
- package/src/obligations/normalize.ts +554 -0
- package/src/obligations/operators.ts +176 -0
- package/src/obligations/pragma.ts +195 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +65 -230
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
- package/src/obligations/regroup.ts +100 -0
- package/src/{obligation-generate.ts → obligations/simplify.ts} +130 -536
- package/src/{obligation-source.ts → obligations/source.ts} +172 -216
- package/src/{obligation-deref.ts → obligations/subexpression.ts} +84 -115
- package/src/obligations/substitution.ts +261 -0
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/parallel-worker.ts +39 -51
- package/src/parallel.ts +39 -66
- 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/prover/decide-pool.ts +95 -0
- package/src/prover/deciders.ts +33 -0
- package/src/prover/first-order.ts +175 -0
- package/src/prover/isabelle/LICENSE +36 -0
- package/src/prover/isabelle/LICENSE-tlapm +26 -0
- package/src/prover/isabelle/decide.ts +44 -0
- package/src/prover/isabelle/encode.ts +445 -0
- package/src/prover/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prover/isabelle/isar/method.ts +367 -0
- package/src/prover/isabelle/isar/proof.ts +28 -0
- package/src/prover/isabelle/isar/statement.ts +57 -0
- package/src/prover/isabelle/isar/theory.ts +192 -0
- package/src/prover/isabelle/isar/type-check.ts +278 -0
- package/src/prover/isabelle/provers/blast/blast.ts +258 -0
- package/src/prover/isabelle/provers/blast/branch.ts +322 -0
- package/src/prover/isabelle/provers/blast/prove.ts +347 -0
- package/src/prover/isabelle/provers/blast/rules.ts +330 -0
- package/src/prover/isabelle/provers/blast/state.ts +180 -0
- package/src/prover/isabelle/provers/blast/term.ts +546 -0
- package/src/prover/isabelle/provers/clasimp.ts +150 -0
- package/src/prover/isabelle/provers/classical.ts +389 -0
- package/src/prover/isabelle/provers/hypsubst.ts +433 -0
- package/src/prover/isabelle/pure/bicompose.ts +174 -0
- package/src/prover/isabelle/pure/consts.ts +32 -0
- package/src/prover/isabelle/pure/conv.ts +79 -0
- package/src/prover/isabelle/pure/drule.ts +264 -0
- package/src/prover/isabelle/pure/envir.ts +331 -0
- package/src/prover/isabelle/pure/goal.ts +53 -0
- package/src/prover/isabelle/pure/interrupt.ts +16 -0
- package/src/prover/isabelle/pure/list.ts +12 -0
- package/src/prover/isabelle/pure/logic.ts +330 -0
- package/src/prover/isabelle/pure/name.ts +98 -0
- package/src/prover/isabelle/pure/net.ts +215 -0
- package/src/prover/isabelle/pure/object-logic.ts +41 -0
- package/src/prover/isabelle/pure/pattern.ts +631 -0
- package/src/prover/isabelle/pure/raw-simplifier.ts +338 -0
- package/src/prover/isabelle/pure/rewriter.ts +602 -0
- package/src/prover/isabelle/pure/search.ts +68 -0
- package/src/prover/isabelle/pure/seq.ts +133 -0
- package/src/prover/isabelle/pure/simplifier.ts +106 -0
- package/src/prover/isabelle/pure/table.ts +201 -0
- package/src/prover/isabelle/pure/tactic.ts +168 -0
- package/src/prover/isabelle/pure/tactical.ts +264 -0
- package/src/prover/isabelle/pure/term-ord.ts +105 -0
- package/src/prover/isabelle/pure/term.ts +688 -0
- package/src/prover/isabelle/pure/thm.ts +783 -0
- package/src/prover/isabelle/pure/type.ts +121 -0
- package/src/prover/isabelle/pure/unify.ts +753 -0
- package/src/prover/isabelle/pure/variable.ts +25 -0
- package/src/prover/isabelle/tla/classical-setup.ts +101 -0
- package/src/prover/isabelle/tla/context.ts +74 -0
- package/src/prover/isabelle/tla/logic-data.ts +5 -0
- package/src/prover/isabelle/tla/logic.ts +215 -0
- package/src/prover/isabelle/tla/simpdata.ts +241 -0
- package/src/prover/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prover/ocaml.ts +22 -0
- package/src/prover/prep/action.ts +508 -0
- package/src/prover/prep/enabled-axioms.ts +189 -0
- package/src/prover/prep/fingerprint.ts +388 -0
- package/src/prover/prep/level-comparison.ts +529 -0
- package/src/prover/prep/md5.ts +60 -0
- package/src/prover/prep/methods.ts +221 -0
- package/src/prover/prep/normalize.ts +309 -0
- package/src/prover/prove-worker.ts +22 -0
- package/src/prover/prove.ts +492 -0
- package/src/prover/ptl/decide.ts +68 -0
- package/src/prover/ptl/encode.ts +244 -0
- package/src/prover/ptl/sat.ts +151 -0
- package/src/prover/ptl/tableau.ts +276 -0
- package/src/prover/smt/axioms.ts +209 -0
- package/src/prover/smt/context.ts +108 -0
- package/src/prover/smt/data.ts +636 -0
- package/src/prover/smt/encode.ts +275 -0
- package/src/prover/smt/extensionality.ts +65 -0
- package/src/prover/smt/flatten.ts +112 -0
- package/src/prover/smt/format.ts +154 -0
- package/src/prover/smt/instances.ts +181 -0
- package/src/prover/smt/rewrite.ts +766 -0
- package/src/prover/smt/solver/act-cache.ts +265 -0
- package/src/prover/smt/solver/arith-rewriter.ts +962 -0
- package/src/prover/smt/solver/array.ts +22 -0
- package/src/prover/smt/solver/asserted-formulas.ts +469 -0
- package/src/prover/smt/solver/ast-lt.ts +157 -0
- package/src/prover/smt/solver/ast-util.ts +91 -0
- package/src/prover/smt/solver/ast.ts +1315 -0
- package/src/prover/smt/solver/auf-solver.ts +572 -0
- package/src/prover/smt/solver/case-split-queue.ts +178 -0
- package/src/prover/smt/solver/cg-table.ts +175 -0
- package/src/prover/smt/solver/clause.ts +276 -0
- package/src/prover/smt/solver/conflict-resolution.ts +343 -0
- package/src/prover/smt/solver/context.ts +1292 -0
- package/src/prover/smt/solver/ctx-simplify.ts +334 -0
- package/src/prover/smt/solver/der.ts +224 -0
- package/src/prover/smt/solver/dyn-ack.ts +141 -0
- package/src/prover/smt/solver/e-matching.ts +659 -0
- package/src/prover/smt/solver/enode.ts +259 -0
- package/src/prover/smt/solver/expr-ref.ts +21 -0
- package/src/prover/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prover/smt/solver/fingerprints.ts +92 -0
- package/src/prover/smt/solver/flat-literals.ts +51 -0
- package/src/prover/smt/solver/goal.ts +138 -0
- package/src/prover/smt/solver/hash.ts +173 -0
- package/src/prover/smt/solver/hashtable.ts +166 -0
- package/src/prover/smt/solver/internalizer.ts +1381 -0
- package/src/prover/smt/solver/lbool.ts +5 -0
- package/src/prover/smt/solver/literal.ts +24 -0
- package/src/prover/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prover/smt/solver/lp/constraints.ts +78 -0
- package/src/prover/smt/solver/lp/containers.ts +296 -0
- package/src/prover/smt/solver/lp/core-solver.ts +504 -0
- package/src/prover/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prover/smt/solver/lp/dep-intervals.ts +642 -0
- package/src/prover/smt/solver/lp/dependency.ts +51 -0
- package/src/prover/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prover/smt/solver/lp/explanation.ts +46 -0
- package/src/prover/smt/solver/lp/gomory.ts +255 -0
- package/src/prover/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prover/smt/solver/lp/hnf.ts +281 -0
- package/src/prover/smt/solver/lp/int-cube.ts +295 -0
- package/src/prover/smt/solver/lp/int-solver.ts +514 -0
- package/src/prover/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prover/smt/solver/lp/lar-term.ts +62 -0
- package/src/prover/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prover/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prover/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prover/smt/solver/lp/nex.ts +120 -0
- package/src/prover/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prover/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prover/smt/solver/lp/nla-core.ts +968 -0
- package/src/prover/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prover/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prover/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prover/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prover/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prover/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prover/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prover/smt/solver/lp/nla-order.ts +307 -0
- package/src/prover/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prover/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prover/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prover/smt/solver/lp/nla-types.ts +124 -0
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prover/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prover/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prover/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prover/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prover/smt/solver/lp/pdd.ts +971 -0
- package/src/prover/smt/solver/lp/random-updater.ts +138 -0
- package/src/prover/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prover/smt/solver/lp/union-find.ts +96 -0
- package/src/prover/smt/solver/mam-compiler.ts +847 -0
- package/src/prover/smt/solver/mam-interpreter.ts +400 -0
- package/src/prover/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prover/smt/solver/model-checker.ts +347 -0
- package/src/prover/smt/solver/model-evaluator.ts +262 -0
- package/src/prover/smt/solver/model-finder.ts +155 -0
- package/src/prover/smt/solver/model-generator.ts +97 -0
- package/src/prover/smt/solver/model-macro-solver.ts +728 -0
- package/src/prover/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prover/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prover/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prover/smt/solver/nlsat/explain.ts +607 -0
- package/src/prover/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prover/smt/solver/nlsat/levelwise.ts +737 -0
- package/src/prover/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prover/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prover/smt/solver/nlsat/solver.ts +911 -0
- package/src/prover/smt/solver/nlsat/types.ts +43 -0
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prover/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prover/smt/solver/nnf.ts +469 -0
- package/src/prover/smt/solver/pattern-inference.ts +351 -0
- package/src/prover/smt/solver/poly-rewriter.ts +477 -0
- package/src/prover/smt/solver/propagate-values.ts +83 -0
- package/src/prover/smt/solver/proto-model.ts +551 -0
- package/src/prover/smt/solver/pull-quant.ts +139 -0
- package/src/prover/smt/solver/qe-lite-der.ts +526 -0
- package/src/prover/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prover/smt/solver/qe-lite.ts +381 -0
- package/src/prover/smt/solver/qi-queue.ts +362 -0
- package/src/prover/smt/solver/quant-tactics.ts +117 -0
- package/src/prover/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prover/smt/solver/quantifier-manager.ts +186 -0
- package/src/prover/smt/solver/random-gen.ts +10 -0
- package/src/prover/smt/solver/rational.ts +165 -0
- package/src/prover/smt/solver/ref-vector.ts +62 -0
- package/src/prover/smt/solver/relevancy.ts +247 -0
- package/src/prover/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prover/smt/solver/rewriter.ts +843 -0
- package/src/prover/smt/solver/rlimit.ts +79 -0
- package/src/prover/smt/solver/smtlib-parser.ts +526 -0
- package/src/prover/smt/solver/solver.ts +71 -0
- package/src/prover/smt/solver/sort.ts +35 -0
- package/src/prover/smt/solver/sticky-generations.ts +69 -0
- package/src/prover/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prover/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prover/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prover/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prover/smt/solver/theory-lra-model.ts +243 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prover/smt/solver/theory-lra-state.ts +43 -0
- package/src/prover/smt/solver/theory-lra.ts +56 -0
- package/src/prover/smt/solver/var-subst.ts +258 -0
- package/src/prover/smt/solver/z3-license.txt +10 -0
- package/src/prover/smt/table.ts +170 -0
- package/src/prover/tlapm/cache.ts +236 -0
- package/src/prover/tlapm/ocaml-marshal.ts +166 -0
- package/src/prover/tlapm/tlapm.ts +96 -0
- package/src/prover/tlaps-module.ts +510 -0
- package/src/prover/verdict.ts +13 -0
- package/src/prover/zenon/LICENSE +32 -0
- package/src/prover/zenon/check/check.ts +105 -0
- package/src/prover/zenon/check/definitions.ts +144 -0
- package/src/prover/zenon/check/equality.ts +182 -0
- package/src/prover/zenon/check/functions.ts +62 -0
- package/src/prover/zenon/check/keys.ts +125 -0
- package/src/prover/zenon/check/propositional.ts +104 -0
- package/src/prover/zenon/check/records.ts +188 -0
- package/src/prover/zenon/check/relations.ts +121 -0
- package/src/prover/zenon/check/rewrites.ts +224 -0
- package/src/prover/zenon/check/sets.ts +302 -0
- package/src/prover/zenon/check/terms.ts +127 -0
- package/src/prover/zenon/check/tla.ts +126 -0
- package/src/prover/zenon/decide.ts +107 -0
- package/src/prover/zenon/encode.ts +378 -0
- package/src/prover/zenon/eqrel.ts +300 -0
- package/src/prover/zenon/equality-rules.ts +435 -0
- package/src/prover/zenon/expr.ts +551 -0
- package/src/prover/zenon/index-table.ts +350 -0
- package/src/prover/zenon/isar-case.ts +513 -0
- package/src/prover/zenon/isar.ts +1249 -0
- package/src/prover/zenon/limits.ts +15 -0
- package/src/prover/zenon/llproof.ts +173 -0
- package/src/prover/zenon/mltoll.ts +1566 -0
- package/src/prover/zenon/node.ts +297 -0
- package/src/prover/zenon/ocaml.ts +169 -0
- package/src/prover/zenon/parse.ts +247 -0
- package/src/prover/zenon/phrase.ts +191 -0
- package/src/prover/zenon/proof.ts +198 -0
- package/src/prover/zenon/propositional-rules.ts +387 -0
- package/src/prover/zenon/rules.ts +94 -0
- package/src/prover/zenon/search.ts +288 -0
- package/src/prover/zenon/tla/functions.ts +151 -0
- package/src/prover/zenon/tla/llproof.ts +480 -0
- package/src/prover/zenon/tla/records.ts +225 -0
- package/src/prover/zenon/tla/rewrites.ts +447 -0
- package/src/prover/zenon/tla/sets.ts +304 -0
- package/src/prover/zenon/tla/terms.ts +162 -0
- package/src/prover/zenon/tla/tla.ts +506 -0
- package/src/randomization.ts +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 +21 -22
- package/src/state-graph.ts +9 -8
- package/src/substitution-levels.ts +2 -2
- package/src/successors.ts +38 -22
- 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 -190
- 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/{tlc-version.ts → tlc/version.ts} +8 -7
- package/src/transfer.ts +32 -32
- package/src/values.ts +154 -105
- package/src/worker.ts +62 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
- package/dist/run-cli.cjs +0 -55
- package/dist/run-cli.js +0 -55
- package/src/canonical.ts +0 -40
- package/src/obligation-expression.ts +0 -1060
- package/src/obligation-module.ts +0 -1042
- package/src/standard-ranges.ts +0 -116
- package/src/value-sources.ts +0 -29
- /package/src/{tlc-modules.ts → tlc/jar-data.ts} +0 -0
- /package/src/{tlc-summary.ts → tlc/summary.ts} +0 -0
package/src/resolve.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type SymbolKind =
|
|
|
36
36
|
|
|
37
37
|
// range is where SANY reports the symbol, and two symbols at one range are one node to SANY. params
|
|
38
38
|
// holds the arity of each parameter of a defined operator.
|
|
39
|
-
|
|
39
|
+
interface Binding {
|
|
40
40
|
kind: SymbolKind;
|
|
41
41
|
arity: number;
|
|
42
42
|
params?: number[];
|
|
@@ -74,14 +74,7 @@ interface ModuleBinding extends Binding {
|
|
|
74
74
|
isPending?: boolean;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
//
|
|
78
|
-
// holds the names the module binds. A label may appear where hasLabelScope holds, in a definition, a
|
|
79
|
-
// named theorem, or a numbered step, except where isLabelForbidden holds, in the scope of a NEW in a
|
|
80
|
-
// nested ASSUME, or where isInExcept holds, in the new value of an EXCEPT. labelParams holds the
|
|
81
|
-
// names bound since the innermost definition, label, or step, which a label must take as parameters,
|
|
82
|
-
// and labels the labels there. isGenerated holds in a definition tla-ts generates for a LET INSTANCE,
|
|
83
|
-
// and in a subexpression that a name selects, which SANY analyzes where it is defined.
|
|
84
|
-
// getInstance gives what an INSTANCE in a LET or a proof instantiates.
|
|
77
|
+
// What SANY reports while it goes on analyzing a unit of a module, and the scope it analyzes it in.
|
|
85
78
|
interface Unit {
|
|
86
79
|
imported: Symbols;
|
|
87
80
|
getInstance: (instance: Instance) => InstancedModule;
|
|
@@ -94,11 +87,15 @@ interface Unit {
|
|
|
94
87
|
bindings: Map<string, ModuleBinding>;
|
|
95
88
|
errors: SanyError[];
|
|
96
89
|
warnings: SanyError[];
|
|
90
|
+
// In a definition, a named theorem, or a numbered step.
|
|
97
91
|
hasLabelScope: boolean;
|
|
92
|
+
// In the scope of a NEW in a nested ASSUME.
|
|
98
93
|
isLabelForbidden: boolean;
|
|
99
94
|
isInExcept: boolean;
|
|
95
|
+
// The names bound since the innermost definition, label, or step, which a label must take.
|
|
100
96
|
labelParams: string[];
|
|
101
97
|
labels: Set<string>;
|
|
98
|
+
// In a definition generated for a LET INSTANCE, or a subexpression analyzed where it is defined.
|
|
102
99
|
isGenerated: boolean;
|
|
103
100
|
}
|
|
104
101
|
|
|
@@ -168,10 +165,8 @@ const getModuleBinding = (name: string, unit: Unit, range: SourceRange | undefin
|
|
|
168
165
|
const isSameRange = (left: SourceRange | undefined, right: SourceRange | undefined) =>
|
|
169
166
|
left !== undefined && right !== undefined && formatRange(left) === formatRange(right);
|
|
170
167
|
|
|
171
|
-
// SymbolTable.addSymbol
|
|
172
|
-
// or
|
|
173
|
-
// of any other duplicate. tla-ts binds a symbol SANY never sees, such as one it generates. Tells
|
|
174
|
-
// whether to bind the added symbol.
|
|
168
|
+
// SymbolTable.addSymbol: rejects redefining a built-in, a bound name, or a symbol of another kind
|
|
169
|
+
// or arity, and warns of any other duplicate. A symbol SANY never sees, such as a generated one, binds.
|
|
175
170
|
const isBindable = (name: string, current: Binding | undefined, added: Binding, unit: Unit) => {
|
|
176
171
|
if (current === undefined) return true;
|
|
177
172
|
if (isSameRange(current.range, added.range)) return false;
|
|
@@ -1447,7 +1442,7 @@ const resolveTheorem = (theorem: Theorem, unit: Unit) => {
|
|
|
1447
1442
|
|
|
1448
1443
|
// The declarations of the module an INSTANCE instantiates, the names the INSTANCE adds, and the
|
|
1449
1444
|
// module that instantiates it.
|
|
1450
|
-
|
|
1445
|
+
interface InstancedModule {
|
|
1451
1446
|
declarations: Declaration[];
|
|
1452
1447
|
symbols: Symbols;
|
|
1453
1448
|
instancer: string;
|
|
@@ -1461,18 +1456,16 @@ export interface ModuleReport {
|
|
|
1461
1456
|
warnings: SanyError[];
|
|
1462
1457
|
}
|
|
1463
1458
|
|
|
1464
|
-
// bound holds the names in scope where the module starts: the built-in operators, the names of the
|
|
1465
|
-
// module that encloses it, and those of the modules it extends. instanced holds the names each
|
|
1466
|
-
// INSTANCE adds, getInstance what an INSTANCE in a LET or a proof instantiates, facts the theorems
|
|
1467
|
-
// and assumptions the modules it extends or instantiates export, and warnings the warnings SANY
|
|
1468
|
-
// reports for the spec.
|
|
1469
1459
|
export interface ModuleUnit {
|
|
1470
1460
|
imported: Symbols;
|
|
1471
1461
|
getInstance: (instance: Instance) => InstancedModule;
|
|
1462
|
+
// The built-in operators and the names of the enclosing and extended modules.
|
|
1472
1463
|
bound: Symbols;
|
|
1473
1464
|
definitions: Map<string, Definition>;
|
|
1474
1465
|
getKey: (definition: Definition) => string;
|
|
1466
|
+
// The names each INSTANCE adds.
|
|
1475
1467
|
instanced: Map<Instance, Symbols>;
|
|
1468
|
+
// The theorems and assumptions the extended and instantiated modules export.
|
|
1476
1469
|
facts: Set<string>;
|
|
1477
1470
|
reports: ModuleReport[];
|
|
1478
1471
|
warnings: SanyError[];
|
|
@@ -1631,7 +1624,7 @@ export const collectSemanticErrors = (
|
|
|
1631
1624
|
warnings: SanyError[],
|
|
1632
1625
|
) => {
|
|
1633
1626
|
const errors: SanyError[] = [];
|
|
1634
|
-
const
|
|
1627
|
+
const addUnique = (list: SanyError[], item: SanyError) => {
|
|
1635
1628
|
if (
|
|
1636
1629
|
list.every(
|
|
1637
1630
|
(existing) => existing.location !== item.location || existing.message !== item.message,
|
|
@@ -1659,8 +1652,8 @@ export const collectSemanticErrors = (
|
|
|
1659
1652
|
}
|
|
1660
1653
|
reported.push(...(error.sany?.errors ?? []));
|
|
1661
1654
|
}
|
|
1662
|
-
reported.forEach((item) =>
|
|
1663
|
-
warned.forEach((item) =>
|
|
1655
|
+
reported.forEach((item) => addUnique(errors, item));
|
|
1656
|
+
warned.forEach((item) => addUnique(warnings, item));
|
|
1664
1657
|
});
|
|
1665
1658
|
return errors;
|
|
1666
1659
|
};
|
package/src/runtime.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getTlcFingerprint } from "./tlc/fingerprint";
|
|
2
|
+
import { createJavaRandom, type JavaRandom } from "./tlc/random";
|
|
2
3
|
import { createFunction, createRecord, type Value } from "./values";
|
|
3
|
-
import type { TlcVersion } from "./tlc
|
|
4
|
+
import type { TlcVersion } from "./tlc/version";
|
|
4
5
|
|
|
5
6
|
export interface CheckerRuntime {
|
|
6
7
|
getLevel: (state: (Value | undefined)[]) => number;
|
|
@@ -22,7 +23,6 @@ export interface CheckerRuntime {
|
|
|
22
23
|
// TLC's -tool, under which the message of an error that TLC raises with a code holds the
|
|
23
24
|
// code's markers, which AssertError compares with.
|
|
24
25
|
isTool: boolean;
|
|
25
|
-
// The TLC whose messages tla-ts reproduces.
|
|
26
26
|
version: TlcVersion;
|
|
27
27
|
seed: bigint;
|
|
28
28
|
isSeen: (state: Value[]) => boolean;
|
|
@@ -46,8 +46,8 @@ export interface CheckerRuntime {
|
|
|
46
46
|
// its Random with the fingerprint of each state it expands, XORed with the seed, so a state's
|
|
47
47
|
// successors are the same whatever order the workers expand states in.
|
|
48
48
|
export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime => {
|
|
49
|
-
const
|
|
50
|
-
const worker = { random: createJavaRandom(seed),
|
|
49
|
+
const startupRandom = createJavaRandom(seed);
|
|
50
|
+
const worker = { random: createJavaRandom(seed), seededState: undefined as Value[] | undefined };
|
|
51
51
|
const phase = { isStartup: false };
|
|
52
52
|
const runtime: CheckerRuntime = {
|
|
53
53
|
getLevel: () => 0,
|
|
@@ -60,10 +60,10 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
|
|
|
60
60
|
getFingerprint: getTlcFingerprint,
|
|
61
61
|
getRandom: () => {
|
|
62
62
|
const state = phase.isStartup ? undefined : runtime.getCurrentState();
|
|
63
|
-
if (state === undefined) return
|
|
64
|
-
if (state !== worker.
|
|
63
|
+
if (state === undefined) return startupRandom;
|
|
64
|
+
if (state !== worker.seededState) {
|
|
65
65
|
worker.random.setSeed(runtime.getFingerprint(state) ^ BigInt.asUintN(64, seed));
|
|
66
|
-
worker.
|
|
66
|
+
worker.seededState = state;
|
|
67
67
|
}
|
|
68
68
|
return worker.random;
|
|
69
69
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./
|
|
1
|
+
import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./nodes";
|
|
2
2
|
|
|
3
3
|
// tla2sany.semantic.BuiltInOperators: name, arity, level, maximum argument levels and argument
|
|
4
4
|
// weights. SANY leaves the levels of "." and \neg unset.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TEMPORAL_LEVEL } from "
|
|
2
|
-
import type { TlcVersion } from "
|
|
1
|
+
import { TEMPORAL_LEVEL } from "../levels";
|
|
2
|
+
import type { TlcVersion } from "../tlc/version";
|
|
3
3
|
import type {
|
|
4
4
|
AssumeProve,
|
|
5
5
|
Assumption,
|
|
@@ -18,18 +18,18 @@ import type {
|
|
|
18
18
|
SourceLocation,
|
|
19
19
|
Theorem,
|
|
20
20
|
UseOrHide,
|
|
21
|
-
} from "
|
|
22
|
-
import { getChildren } from "
|
|
21
|
+
} from "../ast";
|
|
22
|
+
import { getChildren } from "../ast";
|
|
23
23
|
import {
|
|
24
24
|
TlaMissingModuleError,
|
|
25
25
|
TlaSanyFatalError,
|
|
26
26
|
TlaSyntaxError,
|
|
27
27
|
TlaUnsupportedError,
|
|
28
|
-
} from "
|
|
29
|
-
import { parseSanyModule } from "
|
|
30
|
-
import { BUILTIN_LOCATION, createBuiltins, createLevelFields } from "./
|
|
31
|
-
import { getSany174LexicalError } from "./
|
|
32
|
-
import { getSanyParseError } from "./
|
|
28
|
+
} from "../errors";
|
|
29
|
+
import { parseSanyModule } from "../parser";
|
|
30
|
+
import { BUILTIN_LOCATION, createBuiltins, createLevelFields } from "./builtins";
|
|
31
|
+
import { getSany174LexicalError } from "./lexer";
|
|
32
|
+
import { getSanyParseError } from "./parse-error";
|
|
33
33
|
import {
|
|
34
34
|
addSanyMessage,
|
|
35
35
|
CONSTANT_DECL_KIND,
|
|
@@ -73,13 +73,13 @@ import {
|
|
|
73
73
|
type TheoremNode,
|
|
74
74
|
type ThmOrAssumpDefNode,
|
|
75
75
|
type UseOrHideNode,
|
|
76
|
-
} from "./
|
|
76
|
+
} from "./nodes";
|
|
77
77
|
import {
|
|
78
78
|
createSelectorResolver,
|
|
79
79
|
getSelectorItems,
|
|
80
80
|
isGeneralId,
|
|
81
81
|
type SelectorItem,
|
|
82
|
-
} from "./
|
|
82
|
+
} from "./selectors";
|
|
83
83
|
import {
|
|
84
84
|
createSourceFile,
|
|
85
85
|
findNameTokens,
|
|
@@ -99,8 +99,8 @@ import {
|
|
|
99
99
|
isToken,
|
|
100
100
|
type SourceFile,
|
|
101
101
|
type TokenSpan,
|
|
102
|
-
} from "./
|
|
103
|
-
import { SANY_OPERATOR_SYNONYMS } from "
|
|
102
|
+
} from "./source";
|
|
103
|
+
import { SANY_OPERATOR_SYNONYMS } from "../tlc/jar-data";
|
|
104
104
|
|
|
105
105
|
const SYNONYMS = new Map(
|
|
106
106
|
SANY_OPERATOR_SYNONYMS.flatMap(([canonical, ...synonyms]) =>
|
|
@@ -161,7 +161,7 @@ export interface SanySpecification {
|
|
|
161
161
|
messages: SanyMessage[];
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
interface SanyGenerationOptions {
|
|
165
165
|
// The name of the root module's file, which SANY requires to match the module's name.
|
|
166
166
|
rootFileName?: string;
|
|
167
167
|
// The path of the root module's file as SANY's caller gives it, which SANY names when it cannot
|
|
@@ -271,6 +271,15 @@ const isInternalInstance = (module: Module, name: string) => {
|
|
|
271
271
|
return false;
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
+
type LetUnit =
|
|
275
|
+
| { kind: "Recursive"; declarations: Declaration[] }
|
|
276
|
+
| { kind: "Instance"; instance: Instance }
|
|
277
|
+
| { kind: "Definition"; definition: Definition };
|
|
278
|
+
|
|
279
|
+
// The decimal digits of a numeral such as \hFF, which SANY keeps at any size.
|
|
280
|
+
const getNumeralDigits = (text: string) =>
|
|
281
|
+
BigInt(text.startsWith("\\") ? `0${text.slice(1).replace(/^h/i, "x")}` : text).toString();
|
|
282
|
+
|
|
274
283
|
// An entry of SANY's LS stack: the labels of a definition, theorem or label and the parameters
|
|
275
284
|
// bound within it around the expression being generated.
|
|
276
285
|
interface LabelScope {
|
|
@@ -542,11 +551,8 @@ export const generateSanySpecification = (
|
|
|
542
551
|
path.pop();
|
|
543
552
|
order.push(name);
|
|
544
553
|
};
|
|
545
|
-
// SpecObj.loadSpec: SANY resolves the first name it finds
|
|
546
|
-
//
|
|
547
|
-
// only once it has resolved every extended module. SANY resolves a name in the context of the
|
|
548
|
-
// module that names it, so a module another module loaded is unresolved until SANY reaches it
|
|
549
|
-
// from this one.
|
|
554
|
+
// SpecObj.loadSpec: SANY resolves the first unresolved name it finds from the root, every
|
|
555
|
+
// extended module before any instantiated one, each in the context of the module that names it.
|
|
550
556
|
const resolutions = new Set<string>();
|
|
551
557
|
const isResolved = (importer: string, name: string) => resolutions.has(`${importer} ${name}`);
|
|
552
558
|
const findUnresolved = (
|
|
@@ -1402,7 +1408,7 @@ export const generateSanySpecification = (
|
|
|
1402
1408
|
return {
|
|
1403
1409
|
...createLevelFields(getId()),
|
|
1404
1410
|
kind: "Numeral",
|
|
1405
|
-
value:
|
|
1411
|
+
value: getNumeralDigits(expression.text ?? String(expression.value)),
|
|
1406
1412
|
location,
|
|
1407
1413
|
};
|
|
1408
1414
|
case "Decimal": {
|
|
@@ -1913,7 +1919,6 @@ export const generateSanySpecification = (
|
|
|
1913
1919
|
if (node.operator.name === "$NonRecursiveFcnSpec") node.unbounded = undefined;
|
|
1914
1920
|
};
|
|
1915
1921
|
|
|
1916
|
-
// The module's operators declared in RECURSIVE statements.
|
|
1917
1922
|
const recursiveDeclarations: OpDefNode[] = [];
|
|
1918
1923
|
const processRecursive = (declarations: Declaration[]) => {
|
|
1919
1924
|
if (state.unresolvedSum === 0) state.recursiveSectionCount++;
|
|
@@ -1985,12 +1990,13 @@ export const generateSanySpecification = (
|
|
|
1985
1990
|
});
|
|
1986
1991
|
// Generator.checkSubstitutionForCorrectArity, which SANY locates in its builtins for the
|
|
1987
1992
|
// nullOpArg it substitutes after an error.
|
|
1988
|
-
const checkArity = (target: OpDeclNode,
|
|
1989
|
-
const arity =
|
|
1990
|
-
const isNullOpArg =
|
|
1993
|
+
const checkArity = (target: OpDeclNode, substitute: ExprOrOpArgNode) => {
|
|
1994
|
+
const arity = substitute.kind === "OpArg" ? getSymbolArity(substitute.op) : 0;
|
|
1995
|
+
const isNullOpArg =
|
|
1996
|
+
target.arity > 0 && substitute.kind === "OpAppl" && substitute.isNull === true;
|
|
1991
1997
|
if (arity !== target.arity && !isNullOpArg) {
|
|
1992
1998
|
addError(
|
|
1993
|
-
|
|
1999
|
+
substitute.location,
|
|
1994
2000
|
`An operator must be substituted for symbol '${target.name}', and it must have arity ${target.arity}.`,
|
|
1995
2001
|
);
|
|
1996
2002
|
}
|
|
@@ -2012,11 +2018,11 @@ export const generateSanySpecification = (
|
|
|
2012
2018
|
);
|
|
2013
2019
|
return;
|
|
2014
2020
|
}
|
|
2015
|
-
const
|
|
2021
|
+
const substitute =
|
|
2016
2022
|
target.arity === 0
|
|
2017
2023
|
? generateExpression(substitution.expression)
|
|
2018
2024
|
: generateOperatorArgument(substitution.expression, target);
|
|
2019
|
-
checkArity(target,
|
|
2025
|
+
checkArity(target, substitute);
|
|
2020
2026
|
const existing = substs.find((subst) => subst.op.name === target.name);
|
|
2021
2027
|
if (existing && !existing.isImplicit) {
|
|
2022
2028
|
addError(
|
|
@@ -2024,9 +2030,9 @@ export const generateSanySpecification = (
|
|
|
2024
2030
|
`Multiple substitutions for symbol '${target.name}' in substitution.`,
|
|
2025
2031
|
);
|
|
2026
2032
|
} else if (existing) {
|
|
2027
|
-
existing.expr =
|
|
2033
|
+
existing.expr = substitute;
|
|
2028
2034
|
existing.isImplicit = false;
|
|
2029
|
-
} else substs.push({ op: target, expr, isImplicit: false });
|
|
2035
|
+
} else substs.push({ op: target, expr: substitute, isImplicit: false });
|
|
2030
2036
|
});
|
|
2031
2037
|
// TLC 1.7.4's SANY checks the arity of only the substitutions that the INSTANCE writes.
|
|
2032
2038
|
substs
|
|
@@ -2215,8 +2221,8 @@ export const generateSanySpecification = (
|
|
|
2215
2221
|
return symbol;
|
|
2216
2222
|
};
|
|
2217
2223
|
const isOriginParameterFree = symbol.module === undefined || isParameterFree(symbol.module);
|
|
2218
|
-
const node =
|
|
2219
|
-
|
|
2224
|
+
const node =
|
|
2225
|
+
isInstanceeParameterFree || isOriginParameterFree
|
|
2220
2226
|
? isLocal
|
|
2221
2227
|
? copyFrom(symbol.module, symbol.body)
|
|
2222
2228
|
: reuse()
|
|
@@ -2224,10 +2230,7 @@ export const generateSanySpecification = (
|
|
|
2224
2230
|
currentModule,
|
|
2225
2231
|
symbol.body &&
|
|
2226
2232
|
createSubstIn("SubstIn", substs, symbol.body, instanceeModule, location),
|
|
2227
|
-
)
|
|
2228
|
-
: isLocal
|
|
2229
|
-
? copyFrom(symbol.module, symbol.body)
|
|
2230
|
-
: reuse();
|
|
2233
|
+
);
|
|
2231
2234
|
currentModule.definitions.push(node);
|
|
2232
2235
|
setRecursionFields(node);
|
|
2233
2236
|
});
|
|
@@ -3106,23 +3109,3 @@ export const generateSanySpecification = (
|
|
|
3106
3109
|
});
|
|
3107
3110
|
return { root: modules[modules.length - 1], modules, messages };
|
|
3108
3111
|
};
|
|
3109
|
-
|
|
3110
|
-
type LetUnit =
|
|
3111
|
-
| { kind: "Recursive"; declarations: Declaration[] }
|
|
3112
|
-
| { kind: "Instance"; instance: Instance }
|
|
3113
|
-
| { kind: "Definition"; definition: Definition };
|
|
3114
|
-
|
|
3115
|
-
const getNumeralValue = (text: string) => {
|
|
3116
|
-
const lower = text.toLowerCase();
|
|
3117
|
-
const radix = lower.startsWith("\\b")
|
|
3118
|
-
? 2
|
|
3119
|
-
: lower.startsWith("\\o")
|
|
3120
|
-
? 8
|
|
3121
|
-
: lower.startsWith("\\h")
|
|
3122
|
-
? 16
|
|
3123
|
-
: 10;
|
|
3124
|
-
const digits = radix === 10 ? lower : lower.slice(2);
|
|
3125
|
-
return [...digits]
|
|
3126
|
-
.reduce((value, digit) => value * BigInt(radix) + BigInt(parseInt(digit, radix)), 0n)
|
|
3127
|
-
.toString();
|
|
3128
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION_LEVEL, CONSTANT_LEVEL, TEMPORAL_LEVEL, VARIABLE_LEVEL } from "
|
|
1
|
+
import { ACTION_LEVEL, CONSTANT_LEVEL, TEMPORAL_LEVEL, VARIABLE_LEVEL } from "../levels";
|
|
2
2
|
import {
|
|
3
3
|
addSanyMessage,
|
|
4
4
|
CONSTANT_DECL_KIND,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
type Subst,
|
|
26
26
|
type SymbolNode,
|
|
27
27
|
type ThmOrAssumpDefNode,
|
|
28
|
-
} from "./
|
|
28
|
+
} from "./nodes";
|
|
29
29
|
|
|
30
30
|
// A port of the levelCheck methods of SANY's semantic nodes: the levels, weights and Leibniz flags
|
|
31
31
|
// its XMLExporter writes, and the level errors it reports. Each check returns what SANY's returns,
|
|
@@ -50,16 +50,16 @@ const addAll = <Item>(target: Set<Item>, source: Iterable<Item>) => {
|
|
|
50
50
|
for (const item of source) target.add(item);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
const getArgLevelKey = (
|
|
54
|
-
`${
|
|
53
|
+
const getArgLevelKey = (operator: SymbolNode, index: number, param: SymbolNode) =>
|
|
54
|
+
`${operator.id}:${index}:${param.id}`;
|
|
55
55
|
|
|
56
56
|
const addArgLevelParam = (
|
|
57
57
|
target: Map<string, ArgLevelParam>,
|
|
58
|
-
|
|
58
|
+
operator: SymbolNode,
|
|
59
59
|
index: number,
|
|
60
60
|
param: SymbolNode,
|
|
61
61
|
) => {
|
|
62
|
-
target.set(getArgLevelKey(
|
|
62
|
+
target.set(getArgLevelKey(operator, index, param), { op: operator, index, param });
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const addArgLevelParams = (
|
|
@@ -172,22 +172,22 @@ const getSubstitute = (symbol: SymbolNode, substs: Subst[]) =>
|
|
|
172
172
|
|
|
173
173
|
// Subst.paramSet and Subst.allParamSet.
|
|
174
174
|
const getSubstitutedParams = (param: SymbolNode, substs: Subst[], isAll: boolean) => {
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
return isAll ?
|
|
175
|
+
const substitute = getSubstitute(param, substs);
|
|
176
|
+
if (substitute === undefined) return new Set([param]);
|
|
177
|
+
return isAll ? substitute.allParams : substitute.levelParams;
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
// Subst.getSubALPSet.
|
|
181
181
|
const getSubstitutedArgLevelParams = (source: Map<string, ArgLevelParam>, substs: Subst[]) => {
|
|
182
182
|
const result = new Map<string, ArgLevelParam>();
|
|
183
183
|
source.forEach((argLevelParam, key) => {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
184
|
+
const substitute = getSubstitute(argLevelParam.op, substs);
|
|
185
|
+
if (substitute === undefined) {
|
|
186
186
|
result.set(key, argLevelParam);
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
if (
|
|
190
|
-
const operator =
|
|
189
|
+
if (substitute.kind !== "OpArg" || !isParam(substitute.op)) return;
|
|
190
|
+
const operator = substitute.op;
|
|
191
191
|
getSubstitutedParams(argLevelParam.param, substs, false).forEach((param) =>
|
|
192
192
|
addArgLevelParam(result, operator, argLevelParam.index, param),
|
|
193
193
|
);
|
|
@@ -224,10 +224,10 @@ const getSubstitutedLevelConstraints = (
|
|
|
224
224
|
);
|
|
225
225
|
});
|
|
226
226
|
body.argLevelParams.forEach((argLevelParam) => {
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
checkLevel(
|
|
230
|
-
const level = getMaxLevel(
|
|
227
|
+
const substitute = getSubstitute(argLevelParam.op, substs);
|
|
228
|
+
if (substitute?.kind !== "OpArg" || substitute.op.kind !== "OpDef") return;
|
|
229
|
+
checkLevel(substitute.op, iteration, check);
|
|
230
|
+
const level = getMaxLevel(substitute.op, argLevelParam.index);
|
|
231
231
|
getSubstitutedParams(argLevelParam.param, substs, false).forEach((substituted) =>
|
|
232
232
|
putLevelConstraint(result, substituted, level),
|
|
233
233
|
);
|
|
@@ -244,22 +244,26 @@ const getSubstitutedArgLevelConstraints = (
|
|
|
244
244
|
) => {
|
|
245
245
|
const result = new Map<string, ArgLevelConstraint>();
|
|
246
246
|
body.argLevelConstraints.forEach((constraint) => {
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
247
|
+
const substitute = getSubstitute(constraint.param, substs);
|
|
248
|
+
if (substitute === undefined) {
|
|
249
249
|
putArgLevelConstraint(result, constraint.param, constraint.position, constraint.level);
|
|
250
|
-
} else if (
|
|
251
|
-
putArgLevelConstraint(result,
|
|
250
|
+
} else if (substitute.kind === "OpArg" && isParam(substitute.op)) {
|
|
251
|
+
putArgLevelConstraint(result, substitute.op, constraint.position, constraint.level);
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
body.argLevelParams.forEach((argLevelParam) => {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
255
|
+
const paramSubstitute = getSubstitute(argLevelParam.param, substs);
|
|
256
|
+
if (paramSubstitute === undefined) return;
|
|
257
|
+
const operatorSubstitute = getSubstitute(argLevelParam.op, substs);
|
|
258
258
|
const operator =
|
|
259
|
-
|
|
259
|
+
operatorSubstitute === undefined
|
|
260
|
+
? argLevelParam.op
|
|
261
|
+
: operatorSubstitute.kind === "OpArg"
|
|
262
|
+
? operatorSubstitute.op
|
|
263
|
+
: undefined;
|
|
260
264
|
if (operator === undefined || !isParam(operator)) return;
|
|
261
|
-
checkLevel(
|
|
262
|
-
putArgLevelConstraint(result, operator, argLevelParam.index,
|
|
265
|
+
checkLevel(paramSubstitute, iteration, check);
|
|
266
|
+
putArgLevelConstraint(result, operator, argLevelParam.index, paramSubstitute.level);
|
|
263
267
|
});
|
|
264
268
|
return result;
|
|
265
269
|
};
|
|
@@ -836,26 +840,6 @@ const checkTemporalProof = (proof: ProofNode | undefined, check: LevelCheck) =>
|
|
|
836
840
|
});
|
|
837
841
|
};
|
|
838
842
|
|
|
839
|
-
// Subst.getSubLCSet, getSubALCSet and getSubALPSet for the body of an instantiation.
|
|
840
|
-
const constrainSubstitution = (
|
|
841
|
-
node: LevelFields,
|
|
842
|
-
body: ConstraintSource,
|
|
843
|
-
substs: Subst[],
|
|
844
|
-
isConstant: boolean,
|
|
845
|
-
iteration: number,
|
|
846
|
-
check: LevelCheck,
|
|
847
|
-
) => {
|
|
848
|
-
node.levelConstraints = getSubstitutedLevelConstraints(
|
|
849
|
-
body,
|
|
850
|
-
substs,
|
|
851
|
-
isConstant,
|
|
852
|
-
iteration,
|
|
853
|
-
check,
|
|
854
|
-
);
|
|
855
|
-
node.argLevelConstraints = getSubstitutedArgLevelConstraints(body, substs, iteration, check);
|
|
856
|
-
node.argLevelParams = getSubstitutedArgLevelParams(body.argLevelParams, substs);
|
|
857
|
-
};
|
|
858
|
-
|
|
859
843
|
// InstanceNode.levelCheck.
|
|
860
844
|
const checkInstance = (node: InstanceNode, iteration: number, check: LevelCheck) => {
|
|
861
845
|
if (node.levelChecked >= iteration) return node.levelCorrect;
|
|
@@ -1114,7 +1098,20 @@ const checkLevel = (node: SemanticNode, iteration: number, check: LevelCheck): b
|
|
|
1114
1098
|
});
|
|
1115
1099
|
}
|
|
1116
1100
|
const isConstant = isConstantModule(node.instantiatedModule, check);
|
|
1117
|
-
|
|
1101
|
+
node.levelConstraints = getSubstitutedLevelConstraints(
|
|
1102
|
+
body,
|
|
1103
|
+
node.substs,
|
|
1104
|
+
isConstant,
|
|
1105
|
+
iteration,
|
|
1106
|
+
check,
|
|
1107
|
+
);
|
|
1108
|
+
node.argLevelConstraints = getSubstitutedArgLevelConstraints(
|
|
1109
|
+
body,
|
|
1110
|
+
node.substs,
|
|
1111
|
+
iteration,
|
|
1112
|
+
check,
|
|
1113
|
+
);
|
|
1114
|
+
node.argLevelParams = getSubstitutedArgLevelParams(body.argLevelParams, node.substs);
|
|
1118
1115
|
return node.levelCorrect;
|
|
1119
1116
|
}
|
|
1120
1117
|
case "Instance":
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TlaError } from "
|
|
1
|
+
import { TlaError } from "../errors";
|
|
2
2
|
|
|
3
3
|
// An emulation of the token manager that JavaCC generates for SANY's grammar, javacc/tla+.jj: the
|
|
4
4
|
// tokens it produces, their kinds in TLAplusParserConstants order, and their positions.
|
|
@@ -228,8 +228,7 @@ const KIND_INDEXES = new Map(
|
|
|
228
228
|
KIND_NAMES.map((name, kind): [string, number] => [name, kind]).reverse(),
|
|
229
229
|
);
|
|
230
230
|
|
|
231
|
-
// The
|
|
232
|
-
// looks up.
|
|
231
|
+
// The anonymous infix operators share the name "infix", which no caller looks up.
|
|
233
232
|
export const getKind = (name: string) => {
|
|
234
233
|
const kind = KIND_INDEXES.get(name);
|
|
235
234
|
if (kind === undefined) throw new TlaError(`Unknown SANY token kind ${name}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TlcVersion } from "
|
|
2
|
-
import { REAL_TIME, REALS, TOOLBOX } from "
|
|
1
|
+
import type { TlcVersion } from "../tlc/version";
|
|
2
|
+
import { REAL_TIME, REALS, TOOLBOX } from "../bundled-modules";
|
|
3
3
|
|
|
4
4
|
const BAGS = `----------------------------- MODULE Bags --------------------------------
|
|
5
5
|
(**************************************************************************)
|
|
@@ -344,7 +344,7 @@ export type LevelNode = ExprOrOpArgNode | AssumeProveNode | NewSymbNode;
|
|
|
344
344
|
|
|
345
345
|
export type ProofPartNode = ProofNode | DefStepNode;
|
|
346
346
|
|
|
347
|
-
|
|
347
|
+
type TopLevelNode = InstanceNode | AssumeNode | TheoremNode | UseOrHideNode;
|
|
348
348
|
|
|
349
349
|
export type SemanticNode = SymbolNode | LevelNode | TopLevelNode | ProofPartNode;
|
|
350
350
|
|
|
@@ -362,7 +362,7 @@ interface HashtableEntry {
|
|
|
362
362
|
value: SymbolNode;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
|
|
365
|
+
interface JavaHashtable {
|
|
366
366
|
buckets: HashtableEntry[][];
|
|
367
367
|
count: number;
|
|
368
368
|
threshold: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createSanyLexer, escapeLexeme, getKind, type SanyToken } from "./
|
|
2
|
-
import { SANY_OPERATOR_SYNONYMS } from "
|
|
1
|
+
import { createSanyLexer, escapeLexeme, getKind, type SanyToken } from "./lexer";
|
|
2
|
+
import { SANY_OPERATOR_SYNONYMS } from "../tlc/jar-data";
|
|
3
3
|
|
|
4
4
|
// The report SANY's parser, TLAplusParser, gives for a module it fails to parse. This interprets
|
|
5
5
|
// the grammar of javacc/tla+.jj the way the code JavaCC generates from it runs: the productions,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
|
-
import type { Module } from "
|
|
4
|
-
import { TlaSyntaxError, PcalRuntimeError, TlaSanyFatalError } from "
|
|
5
|
-
import { extractModule, parseSanyModule } from "
|
|
6
|
-
import { createPcalParams } from "
|
|
7
|
-
import { createPcalSession } from "
|
|
8
|
-
import { validatePcalModule } from "
|
|
9
|
-
import { generateSanySpecification, type SanySpecification } from "./
|
|
10
|
-
import { checkModuleLevels } from "./
|
|
11
|
-
import { getSany174LexicalError } from "./
|
|
12
|
-
import { lintSanyModule } from "./
|
|
13
|
-
import { getSanyStandardModules } from "./
|
|
14
|
-
import { formatSanyLocation, type SanyMessage } from "./
|
|
15
|
-
import { getUnboxedSource } from "./
|
|
16
|
-
import type { TlcVersion } from "
|
|
3
|
+
import type { Module } from "../ast";
|
|
4
|
+
import { TlaSyntaxError, PcalRuntimeError, TlaSanyFatalError } from "../errors";
|
|
5
|
+
import { extractModule, parseSanyModule } from "../parser";
|
|
6
|
+
import { createPcalParams } from "../pcal/ast";
|
|
7
|
+
import { createPcalSession } from "../pcal/parse";
|
|
8
|
+
import { validatePcalModule } from "../pcal/validate";
|
|
9
|
+
import { generateSanySpecification, type SanySpecification } from "./generator";
|
|
10
|
+
import { checkModuleLevels } from "./levels";
|
|
11
|
+
import { getSany174LexicalError } from "./lexer";
|
|
12
|
+
import { lintSanyModule } from "./linter";
|
|
13
|
+
import { getSanyStandardModules } from "./modules";
|
|
14
|
+
import { formatSanyLocation, type SanyMessage } from "./nodes";
|
|
15
|
+
import { getUnboxedSource } from "./source";
|
|
16
|
+
import type { TlcVersion } from "../tlc/version";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
interface SanyReport {
|
|
19
19
|
text: string;
|
|
20
20
|
isFailed: boolean;
|
|
21
21
|
// The specification SANY analyzes, which has errors when SANY rejects it.
|
|
@@ -35,7 +35,6 @@ export interface SanyReportOptions {
|
|
|
35
35
|
// tla2sany.xml.XMLExporter runs SANY with its validAstSettings, which neither lint the modules
|
|
36
36
|
// nor validate their PlusCal, and prints only SANY's errors.
|
|
37
37
|
isXmlExport?: boolean;
|
|
38
|
-
// The TLC whose SANY to reproduce.
|
|
39
38
|
version?: TlcVersion;
|
|
40
39
|
// The modules TLC adds to the root module's EXTENDS for its post conditions.
|
|
41
40
|
rootExtendees?: string[];
|
|
@@ -119,7 +118,7 @@ export const getSanyModuleName = (text: string, version?: TlcVersion) =>
|
|
|
119
118
|
// in the rest.
|
|
120
119
|
export const getSanyReport = (
|
|
121
120
|
rootPath: string,
|
|
122
|
-
loadModule: (name: string) => string | undefined
|
|
121
|
+
loadModule: (name: string) => string | undefined,
|
|
123
122
|
options: SanyReportOptions = {},
|
|
124
123
|
): SanyReport => {
|
|
125
124
|
const rootName = basename(rootPath, ".tla");
|