tla-ts 0.0.8-dev.d9bffda → 0.0.9-dev.0493be549
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 +30 -0
- 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 +80 -10
- package/dist/index.d.ts +80 -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 +605 -311
- package/src/cli/options.ts +12 -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 +545 -218
- 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 +632 -298
- 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 +31 -38
- package/src/parallel.ts +41 -17
- 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 +128 -176
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +31 -29
- 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 +533 -174
- 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 +832 -255
- package/src/worker.ts +7 -8
package/src/symmetry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Expression } from "./ast";
|
|
1
|
+
import type { BoundPattern, Expression } from "./ast";
|
|
2
2
|
import type { Substitution } from "./config";
|
|
3
3
|
import { TlaConfigError, TlaEvaluationError, UNEXPECTED_EXCEPTION } from "./errors";
|
|
4
4
|
import { EXIT_STATUS, setExitCode } from "./exit-codes";
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
type Value,
|
|
21
21
|
} from "./values";
|
|
22
22
|
|
|
23
|
-
// The image of each model value a permutation moves, by name.
|
|
24
23
|
type Images = Map<string, ModelValue>;
|
|
25
24
|
|
|
26
25
|
const getPermutationKey = (permutation: Images) =>
|
|
@@ -59,8 +58,32 @@ const toImages = (value: Value) => {
|
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
// SyntaxTreeNode.getHumanReadableImage, which joins the tokens of an expression without spaces.
|
|
61
|
+
const getBoundImage = (pattern: BoundPattern, set: Expression | undefined) => {
|
|
62
|
+
const names = pattern.kind === "Name" ? pattern.name : `<<${pattern.names.join(",")}>>`;
|
|
63
|
+
return set ? `${names}\\in${getExpressionImage(set)}` : names;
|
|
64
|
+
};
|
|
65
|
+
|
|
62
66
|
const getExpressionImage = (expression: Expression): string => {
|
|
63
67
|
if (expression.kind === "Identifier") return expression.name;
|
|
68
|
+
if (expression.kind === "Number") return expression.text ?? String(expression.value);
|
|
69
|
+
if (expression.kind === "SetEnumeration") {
|
|
70
|
+
return `{${expression.elements.map(getExpressionImage).join(",")}}`;
|
|
71
|
+
}
|
|
72
|
+
if (expression.kind === "Choose") {
|
|
73
|
+
return `CHOOSE${getBoundImage(expression.pattern, expression.set)}:${getExpressionImage(expression.body)}`;
|
|
74
|
+
}
|
|
75
|
+
if (expression.kind === "Tuple")
|
|
76
|
+
return `<<${expression.elements.map(getExpressionImage).join(",")}>>`;
|
|
77
|
+
if (expression.kind === "Record") {
|
|
78
|
+
const fields = expression.fields.map(
|
|
79
|
+
(field) => `${field.name}|->${getExpressionImage(field.value)}`,
|
|
80
|
+
);
|
|
81
|
+
return `[${fields.join(",")}]`;
|
|
82
|
+
}
|
|
83
|
+
if (expression.kind === "FunctionConstruction") {
|
|
84
|
+
const bounds = expression.bounds.map((bound) => getBoundImage(bound.pattern, bound.set));
|
|
85
|
+
return `[${bounds.join(",")}|->${getExpressionImage(expression.body)}]`;
|
|
86
|
+
}
|
|
64
87
|
if (expression.kind !== "Apply") return "";
|
|
65
88
|
const args = expression.args.map(getExpressionImage);
|
|
66
89
|
return /^[A-Za-z_]/.test(expression.operator)
|
|
@@ -99,10 +122,11 @@ export const getSymmetryGroup = (
|
|
|
99
122
|
if (!elements.every(isFunctionValue)) {
|
|
100
123
|
throw createSymmetryError("The symmetry values must be function records.");
|
|
101
124
|
}
|
|
102
|
-
const permutations = elements.map(toImages);
|
|
103
125
|
// Tool#getSymmetryPerms warns about each permuted set with fewer than two elements, by the name
|
|
104
126
|
// the config substitutes for it. As many permuted sets as permutations means none has two.
|
|
105
|
-
const
|
|
127
|
+
const body = definition.body;
|
|
128
|
+
const permutedSets =
|
|
129
|
+
body.kind === "Apply" ? body.args : body.kind === "SetEnumeration" ? body.elements : [];
|
|
106
130
|
const configNames = new Map(
|
|
107
131
|
substitutions
|
|
108
132
|
.filter((substitution) => substitution.module === undefined)
|
|
@@ -125,7 +149,7 @@ export const getSymmetryGroup = (
|
|
|
125
149
|
return undefined;
|
|
126
150
|
}
|
|
127
151
|
const group = new Map<string, Images>();
|
|
128
|
-
|
|
152
|
+
elements.map(toImages).forEach((permutation) => {
|
|
129
153
|
if (permutation.size > 0) group.set(getPermutationKey(permutation), permutation);
|
|
130
154
|
});
|
|
131
155
|
const generators = [...group.values()];
|
|
@@ -242,9 +266,8 @@ const permuteValue = (value: Value, images: Images): Value => {
|
|
|
242
266
|
return elements ? createSet(elements) : set;
|
|
243
267
|
};
|
|
244
268
|
|
|
245
|
-
//
|
|
246
|
-
//
|
|
247
|
-
// next permutation as soon as a variable's image is larger than the smallest state's.
|
|
269
|
+
// TLC permutes the state under each permutation, variable by variable, and moves on to the next
|
|
270
|
+
// permutation as soon as a variable's image is larger than the smallest state's.
|
|
248
271
|
export const getRepresentative = (
|
|
249
272
|
state: Value[],
|
|
250
273
|
permutations: Images[],
|
package/src/tableau.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface LiveEnabled {
|
|
|
23
23
|
interface LiveAction {
|
|
24
24
|
kind: "Action";
|
|
25
25
|
expression: Expression;
|
|
26
|
-
|
|
26
|
+
subscript: Expression | undefined;
|
|
27
27
|
scope: Scope | undefined;
|
|
28
28
|
enabled?: LiveEnabled;
|
|
29
29
|
}
|
|
@@ -78,6 +78,11 @@ interface Classification {
|
|
|
78
78
|
formulas: LiveExpression[];
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
interface SolutionGroup {
|
|
82
|
+
formula: LiveExpression | undefined;
|
|
83
|
+
classifications: Classification[];
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
interface Triple {
|
|
82
87
|
whole: LiveExpression;
|
|
83
88
|
first: LiveExpression;
|
|
@@ -162,9 +167,8 @@ const containsAction = (expression: LiveExpression): boolean => {
|
|
|
162
167
|
};
|
|
163
168
|
|
|
164
169
|
const termKeys = new WeakMap<LiveExpression, string>();
|
|
165
|
-
|
|
170
|
+
let atomCount = 0;
|
|
166
171
|
|
|
167
|
-
// A term's structure as a string in which each atom stands for itself, so equal terms share a key.
|
|
168
172
|
export const getTermKey = (expression: LiveExpression): string => {
|
|
169
173
|
const cached = termKeys.get(expression);
|
|
170
174
|
if (cached !== undefined) return cached;
|
|
@@ -175,7 +179,7 @@ export const getTermKey = (expression: LiveExpression): string => {
|
|
|
175
179
|
case "State":
|
|
176
180
|
case "Enabled":
|
|
177
181
|
case "Action":
|
|
178
|
-
return `#${
|
|
182
|
+
return `#${atomCount++}`;
|
|
179
183
|
case "And":
|
|
180
184
|
case "Or":
|
|
181
185
|
return `${expression.kind}(${expression.operands.map(getTermKey).join(",")})`;
|
|
@@ -277,7 +281,7 @@ const toDisjunctiveNormalForm = (expression: LiveExpression): LiveExpression =>
|
|
|
277
281
|
switch (expression.kind) {
|
|
278
282
|
case "And": {
|
|
279
283
|
const items: LiveExpression[] = [];
|
|
280
|
-
|
|
284
|
+
let total = 1;
|
|
281
285
|
for (const operand of expression.operands) {
|
|
282
286
|
const normal = toDisjunctiveNormalForm(operand);
|
|
283
287
|
if (normal.kind === "And") {
|
|
@@ -285,8 +289,8 @@ const toDisjunctiveNormalForm = (expression: LiveExpression): LiveExpression =>
|
|
|
285
289
|
continue;
|
|
286
290
|
}
|
|
287
291
|
if (normal.kind === "Or") {
|
|
288
|
-
total
|
|
289
|
-
if (total
|
|
292
|
+
total *= normal.operands.length;
|
|
293
|
+
if (total > MAXIMUM_DISJUNCTS) {
|
|
290
294
|
throw new TlaEvaluationError(
|
|
291
295
|
"TLC cannot handle the temporal formula because it exceeds the maximum supported size in disjunctive normal form.",
|
|
292
296
|
);
|
|
@@ -294,24 +298,25 @@ const toDisjunctiveNormalForm = (expression: LiveExpression): LiveExpression =>
|
|
|
294
298
|
}
|
|
295
299
|
items.push(normal);
|
|
296
300
|
}
|
|
297
|
-
if (total
|
|
298
|
-
const conjunctions = Array.from({ length: total
|
|
299
|
-
|
|
301
|
+
if (total === 1) return { kind: "And", operands: items };
|
|
302
|
+
const conjunctions = Array.from({ length: total }, (): LiveExpression[] => []);
|
|
303
|
+
let groups = 1;
|
|
304
|
+
let repeat = total;
|
|
300
305
|
for (const item of items) {
|
|
301
306
|
if (item.kind !== "Or") {
|
|
302
307
|
conjunctions.forEach((conjunction) => conjunction.push(item));
|
|
303
308
|
continue;
|
|
304
309
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
for (let group = 0; group <
|
|
310
|
+
repeat /= item.operands.length;
|
|
311
|
+
let position = 0;
|
|
312
|
+
for (let group = 0; group < groups; group++) {
|
|
308
313
|
for (const operand of item.operands) {
|
|
309
|
-
for (let copy = 0; copy <
|
|
310
|
-
conjunctions[position
|
|
314
|
+
for (let copy = 0; copy < repeat; copy++) {
|
|
315
|
+
conjunctions[position++].push(operand);
|
|
311
316
|
}
|
|
312
317
|
}
|
|
313
318
|
}
|
|
314
|
-
|
|
319
|
+
groups *= item.operands.length;
|
|
315
320
|
}
|
|
316
321
|
return {
|
|
317
322
|
kind: "Or",
|
|
@@ -462,7 +467,6 @@ const getTriples = (
|
|
|
462
467
|
return parts ? [{ whole: term, first: parts.first, second: parts.second }] : [];
|
|
463
468
|
});
|
|
464
469
|
|
|
465
|
-
// A particle is a set of terms, so its key ignores order and repeats.
|
|
466
470
|
const getParticleKey = (particle: LiveExpression[]) =>
|
|
467
471
|
[...new Set(particle.map(getTermKey))].sort().join("|");
|
|
468
472
|
|
|
@@ -503,9 +507,9 @@ const getParticleClosure = (terms: LiveExpression[]) => {
|
|
|
503
507
|
if (!isMember(expanded, parts.first)) expanded.push(parts.first);
|
|
504
508
|
if (!isMember(expanded, parts.second)) expanded.push(parts.second);
|
|
505
509
|
}
|
|
506
|
-
|
|
507
|
-
while (
|
|
508
|
-
|
|
510
|
+
let isChanged = true;
|
|
511
|
+
while (isChanged) {
|
|
512
|
+
isChanged = false;
|
|
509
513
|
for (const alpha of alphas) {
|
|
510
514
|
const isImplied =
|
|
511
515
|
isMember(expanded, alpha.first) &&
|
|
@@ -513,7 +517,7 @@ const getParticleClosure = (terms: LiveExpression[]) => {
|
|
|
513
517
|
!isMember(expanded, alpha.whole);
|
|
514
518
|
if (isImplied) {
|
|
515
519
|
expanded.push(alpha.whole);
|
|
516
|
-
|
|
520
|
+
isChanged = true;
|
|
517
521
|
}
|
|
518
522
|
}
|
|
519
523
|
}
|
|
@@ -527,8 +531,7 @@ const getParticleClosure = (terms: LiveExpression[]) => {
|
|
|
527
531
|
const createTableauNode = (particle: LiveExpression[]): TableauNode => ({
|
|
528
532
|
particle,
|
|
529
533
|
successors: [],
|
|
530
|
-
// Constant terms count
|
|
531
|
-
// FALSE term stays in the graph and yields a bogus counterexample (tlaplus#604).
|
|
534
|
+
// Constant terms count even for TLC 1.7.4, whose FALSE terms yield a bogus counterexample (tlaplus#604).
|
|
532
535
|
statePredicates: particle.filter((term) => getLiveLevel(term) <= VARIABLE_LEVEL),
|
|
533
536
|
});
|
|
534
537
|
|
|
@@ -599,7 +602,7 @@ const addToBin = (bin: LiveExpression[], expression: LiveExpression) => {
|
|
|
599
602
|
export const getSolutions = (formula: LiveExpression): Solution[] => {
|
|
600
603
|
const normal = toDisjunctiveNormalForm(simplify(pushNegation(formula, false)));
|
|
601
604
|
if (normal.kind === "Boolean" && !normal.value) return [];
|
|
602
|
-
const groups:
|
|
605
|
+
const groups: SolutionGroup[] = [];
|
|
603
606
|
for (const disjunct of normal.kind === "Or" ? normal.operands : [normal]) {
|
|
604
607
|
const flattened = flattenSingleJunctions(disjunct);
|
|
605
608
|
const classification: Classification = {
|
package/src/tlc/fingerprint.ts
CHANGED
|
@@ -8,75 +8,202 @@ import {
|
|
|
8
8
|
type Value,
|
|
9
9
|
} from "../values";
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
const
|
|
11
|
+
// TLC's FP64.Polys, the irreducible polynomials that -fp picks from.
|
|
12
|
+
const POLYNOMIALS = [
|
|
13
|
+
0x911498ae0e66bad6n,
|
|
14
|
+
0xda8a0ba66dae0181n,
|
|
15
|
+
0xc02f176b8f268d9fn,
|
|
16
|
+
0xd617bb1220fc7812n,
|
|
17
|
+
0xc6fd951ad34f9f74n,
|
|
18
|
+
0xdd1897bd991704d4n,
|
|
19
|
+
0xf5394c541cbfd343n,
|
|
20
|
+
0xb1dded37b5c7b8f7n,
|
|
21
|
+
0xb713ff61039dc632n,
|
|
22
|
+
0xdfb340cb2fb03d43n,
|
|
23
|
+
0xbc3e7e4c5ecb76a3n,
|
|
24
|
+
0xdbb4b1349cd7058an,
|
|
25
|
+
0xf53e9dcb9e915cdfn,
|
|
26
|
+
0xca5f58e90dd01848n,
|
|
27
|
+
0x80e7ff4406891aa1n,
|
|
28
|
+
0xab541bf881fa8571n,
|
|
29
|
+
0xbf274e07ac5499d5n,
|
|
30
|
+
0x939b1ea933040a4en,
|
|
31
|
+
0xb791a595448d75b1n,
|
|
32
|
+
0x8bf88d6ef85563a2n,
|
|
33
|
+
0xecb33ec339513a53n,
|
|
34
|
+
0xfa2d3e722db5208an,
|
|
35
|
+
0xb4e2058aac479d24n,
|
|
36
|
+
0xafbd6474e7213b82n,
|
|
37
|
+
0x98c1694d14ffaeefn,
|
|
38
|
+
0xe188fb5c0a125e24n,
|
|
39
|
+
0xfa71cc3865487d80n,
|
|
40
|
+
0x891135f7c1c94569n,
|
|
41
|
+
0xcf77cdd16d22e3e6n,
|
|
42
|
+
0xeb5e3a1d2e2bb4b5n,
|
|
43
|
+
0x92f7f5b69cd00c55n,
|
|
44
|
+
0xa9fbbe40ca3b9ae9n,
|
|
45
|
+
0x84a7b33d85295bden,
|
|
46
|
+
0xebd4680dbb6fdee2n,
|
|
47
|
+
0xa31fc46a0583b4d0n,
|
|
48
|
+
0xa792c94f15de3e49n,
|
|
49
|
+
0xd9d60a9feff4521an,
|
|
50
|
+
0x9227ba31dfdda04bn,
|
|
51
|
+
0xfb4c89c607ce162dn,
|
|
52
|
+
0xa89b3b2e01479cc0n,
|
|
53
|
+
0xb35a0c2a28b89f7dn,
|
|
54
|
+
0x91d0b700b99d9ec2n,
|
|
55
|
+
0xf0646bbda05020b0n,
|
|
56
|
+
0xcb5d5f63ce043056n,
|
|
57
|
+
0xd276b6a04f42a1b8n,
|
|
58
|
+
0xbc1a7a7dbfeb47a3n,
|
|
59
|
+
0xe138acff7a963036n,
|
|
60
|
+
0xed860223c1557ee7n,
|
|
61
|
+
0x9b2491e980150ab6n,
|
|
62
|
+
0xe7e03dd8a5b4e59en,
|
|
63
|
+
0xaaa3f5eac516783cn,
|
|
64
|
+
0xfe78cc267a724180n,
|
|
65
|
+
0xc22519a21edfac64n,
|
|
66
|
+
0xcdb2941933fec60fn,
|
|
67
|
+
0xc5f485551ef38aa1n,
|
|
68
|
+
0xa19293d250bd3335n,
|
|
69
|
+
0xa4d4c215a50b7afen,
|
|
70
|
+
0xc1155176406a5070n,
|
|
71
|
+
0xecadaa8200e123ecn,
|
|
72
|
+
0xbacfe629d58b2f08n,
|
|
73
|
+
0xded991082148cb42n,
|
|
74
|
+
0x9a0ccbe5deaa88dbn,
|
|
75
|
+
0x9a83246f342061bbn,
|
|
76
|
+
0xb71482842297ab05n,
|
|
77
|
+
0xf2407eeb997592bdn,
|
|
78
|
+
0xb7b43d4b5c4c4bccn,
|
|
79
|
+
0xb339a2568221ffe7n,
|
|
80
|
+
0xdb4b6b379446ef9en,
|
|
81
|
+
0xe43c205bb5c0b2b6n,
|
|
82
|
+
0xe8e1d141f19d6db0n,
|
|
83
|
+
0xd19e8710a4ea1c86n,
|
|
84
|
+
0x9704cecfa8d6d07bn,
|
|
85
|
+
0xb0a35716162c3f26n,
|
|
86
|
+
0xa2a68c0cf56390acn,
|
|
87
|
+
0xe4a74bc601c95b46n,
|
|
88
|
+
0xe668fff675595e56n,
|
|
89
|
+
0xe0ea77ebe06fabbbn,
|
|
90
|
+
0xa8bb94f585279523n,
|
|
91
|
+
0xbeb667b42b684f21n,
|
|
92
|
+
0xd7b65410189e28afn,
|
|
93
|
+
0x85722037beffc5b9n,
|
|
94
|
+
0xe7e7c5f773426204n,
|
|
95
|
+
0xa5fd0cc8e060c6f4n,
|
|
96
|
+
0xb8f91ee9065dcf95n,
|
|
97
|
+
0xb4047008040f8b50n,
|
|
98
|
+
0xecb9ab6291c8cfccn,
|
|
99
|
+
0xe08bb9b70caad6dfn,
|
|
100
|
+
0xd6e086a301d95d56n,
|
|
101
|
+
0xf6a808f5f3fb9da3n,
|
|
102
|
+
0xfa74b8a8ef86fbc5n,
|
|
103
|
+
0xa0b6b33ba9e6381cn,
|
|
104
|
+
0x8c78703427873dbbn,
|
|
105
|
+
0xc5516ea423011021n,
|
|
106
|
+
0xb075cce8528ae7e2n,
|
|
107
|
+
0x92e4a37979e2b13bn,
|
|
108
|
+
0xafc9ab000ed81026n,
|
|
109
|
+
0xf1873f2a861a518an,
|
|
110
|
+
0xf885d6b35770192cn,
|
|
111
|
+
0xd2a82f27f71f5f7en,
|
|
112
|
+
0xd5e7a4dd8beb2d9fn,
|
|
113
|
+
0xbab9e7e65dc23e0fn,
|
|
114
|
+
0xd5fc877c0bdf5b85n,
|
|
115
|
+
0xab428169b9f31c02n,
|
|
116
|
+
0xb7b1351f9266d3ean,
|
|
117
|
+
0xfad564914328f635n,
|
|
118
|
+
0x9623ecb1000db9bdn,
|
|
119
|
+
0x88d371ec6644c892n,
|
|
120
|
+
0xd0a71270573e271cn,
|
|
121
|
+
0xbd200d763f9d81b4n,
|
|
122
|
+
0x8484fd96374bf2ean,
|
|
123
|
+
0xe0d0810749432294n,
|
|
124
|
+
0x8ebe9dadc88658ban,
|
|
125
|
+
0xf6268c58993ae542n,
|
|
126
|
+
0xd6cc88fed0d359c9n,
|
|
127
|
+
0xbcaddb8d40a16690n,
|
|
128
|
+
0x92817c6db421cbf6n,
|
|
129
|
+
0xac63721120a371b5n,
|
|
130
|
+
0xd6cc137fdced0820n,
|
|
131
|
+
0xf1c5fbaebb617bd7n,
|
|
132
|
+
0xac35d78c765237a5n,
|
|
133
|
+
0xbd0a471fa9a23116n,
|
|
134
|
+
0x943a7031b946a5aen,
|
|
135
|
+
0xe4e83520cb1aaebbn,
|
|
136
|
+
0xe92a4b73246dd124n,
|
|
137
|
+
0xafc1e070787c4c86n,
|
|
138
|
+
0xdfe84d42cf06286bn,
|
|
139
|
+
0x8b29ec962e4b964bn,
|
|
140
|
+
0x807eb5de812ede0fn,
|
|
141
|
+
0xa3cd71299c8b3bfdn,
|
|
142
|
+
0x845b8031ef886f35n,
|
|
143
|
+
0x91f5a5fa9c5515a5n,
|
|
144
|
+
];
|
|
13
145
|
|
|
14
|
-
const
|
|
15
|
-
const powers: bigint[] = [];
|
|
16
|
-
for (let power = 1n << 63n; powers.length < 72;) {
|
|
17
|
-
powers.push(power);
|
|
18
|
-
power = (power >> 1n) ^ ((power & 1n) === 0n ? 0n : IRREDUCIBLE_POLYNOMIAL);
|
|
19
|
-
}
|
|
20
|
-
return Array.from({ length: 256 }, (_, byte) =>
|
|
21
|
-
powers
|
|
22
|
-
.slice(64, 72)
|
|
23
|
-
.reverse()
|
|
24
|
-
.reduce((value, power, bit) => ((byte >> bit) & 1 ? value ^ power : value), 0n),
|
|
25
|
-
);
|
|
26
|
-
})();
|
|
146
|
+
const selected = { polynomial: POLYNOMIALS[0] };
|
|
27
147
|
|
|
28
|
-
const
|
|
29
|
-
Number(BigInt.asIntN(32, entry >> 32n)),
|
|
30
|
-
);
|
|
31
|
-
const BYTE_MOD_LOW = Int32Array.from(BYTE_MOD_TABLE, (entry) => Number(BigInt.asIntN(32, entry)));
|
|
148
|
+
export const getFingerprintPolynomial = () => selected.polynomial;
|
|
32
149
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
150
|
+
const SLICE_HIGH_0 = new Int32Array(256);
|
|
151
|
+
const SLICE_HIGH_1 = new Int32Array(256);
|
|
152
|
+
const SLICE_HIGH_2 = new Int32Array(256);
|
|
153
|
+
const SLICE_HIGH_3 = new Int32Array(256);
|
|
154
|
+
const SLICE_LOW_0 = new Int32Array(256);
|
|
155
|
+
const SLICE_LOW_1 = new Int32Array(256);
|
|
156
|
+
const SLICE_LOW_2 = new Int32Array(256);
|
|
157
|
+
const SLICE_LOW_3 = new Int32Array(256);
|
|
158
|
+
// The polynomial's high and low 32 bits, which avoid a BigInt operation for every byte.
|
|
159
|
+
const initial = { high: 0, low: 0 };
|
|
160
|
+
let high = 0;
|
|
161
|
+
let low = 0;
|
|
39
162
|
|
|
40
163
|
const extendByte = (byte: number) => {
|
|
41
164
|
const index = (byte ^ low) & 0xff;
|
|
42
|
-
low = ((low >>> 8) | (high << 24)) ^
|
|
43
|
-
high = (high >>> 8) ^
|
|
165
|
+
low = ((low >>> 8) | (high << 24)) ^ SLICE_LOW_0[index];
|
|
166
|
+
high = (high >>> 8) ^ SLICE_HIGH_0[index];
|
|
44
167
|
};
|
|
45
168
|
|
|
46
169
|
// Extending is linear over GF(2), so extending by four bytes at once shifts the fingerprint by a
|
|
47
170
|
// word and adds, for each of the four, the fingerprint from zero of that byte followed by the zero
|
|
48
|
-
// bytes that come after it:
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
171
|
+
// bytes that come after it: SLICE_HIGH_k and SLICE_LOW_k hold them for k zero bytes after.
|
|
172
|
+
export const setFingerprintPolynomial = (index: number) => {
|
|
173
|
+
const polynomial = POLYNOMIALS[index];
|
|
174
|
+
selected.polynomial = polynomial;
|
|
175
|
+
const powers: bigint[] = [];
|
|
176
|
+
for (let power = 1n << 63n; powers.length < 72;) {
|
|
177
|
+
powers.push(power);
|
|
178
|
+
power = (power >> 1n) ^ ((power & 1n) === 0n ? 0n : polynomial);
|
|
179
|
+
}
|
|
180
|
+
const bytePowers = powers.slice(64, 72).reverse();
|
|
181
|
+
for (let byte = 0; byte < 256; byte++) {
|
|
182
|
+
const entry = bytePowers.reduce(
|
|
183
|
+
(value, power, bit) => ((byte >> bit) & 1 ? value ^ power : value),
|
|
184
|
+
0n,
|
|
185
|
+
);
|
|
186
|
+
SLICE_HIGH_0[byte] = Number(BigInt.asIntN(32, entry >> 32n));
|
|
187
|
+
SLICE_LOW_0[byte] = Number(BigInt.asIntN(32, entry));
|
|
188
|
+
}
|
|
189
|
+
const highs = [SLICE_HIGH_0, SLICE_HIGH_1, SLICE_HIGH_2, SLICE_HIGH_3];
|
|
190
|
+
const lows = [SLICE_LOW_0, SLICE_LOW_1, SLICE_LOW_2, SLICE_LOW_3];
|
|
52
191
|
for (let zeros = 1; zeros < 4; zeros++) {
|
|
53
192
|
const previousHigh = highs[zeros - 1];
|
|
54
193
|
const previousLow = lows[zeros - 1];
|
|
55
|
-
const sliceHigh = new Int32Array(256);
|
|
56
|
-
const sliceLow = new Int32Array(256);
|
|
57
194
|
for (let byte = 0; byte < 256; byte++) {
|
|
58
195
|
const index = previousLow[byte] & 0xff;
|
|
59
|
-
|
|
60
|
-
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^
|
|
61
|
-
|
|
196
|
+
lows[zeros][byte] =
|
|
197
|
+
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^ SLICE_LOW_0[index];
|
|
198
|
+
highs[zeros][byte] = (previousHigh[byte] >>> 8) ^ SLICE_HIGH_0[index];
|
|
62
199
|
}
|
|
63
|
-
highs.push(sliceHigh);
|
|
64
|
-
lows.push(sliceLow);
|
|
65
200
|
}
|
|
66
|
-
|
|
201
|
+
initial.high = Number(BigInt.asIntN(32, polynomial >> 32n));
|
|
202
|
+
initial.low = Number(BigInt.asIntN(32, polynomial));
|
|
67
203
|
};
|
|
68
204
|
|
|
69
|
-
|
|
70
|
-
const SLICE_HIGH_0 = SLICES.highs[0];
|
|
71
|
-
const SLICE_HIGH_1 = SLICES.highs[1];
|
|
72
|
-
const SLICE_HIGH_2 = SLICES.highs[2];
|
|
73
|
-
const SLICE_HIGH_3 = SLICES.highs[3];
|
|
74
|
-
const SLICE_LOW_0 = SLICES.lows[0];
|
|
75
|
-
const SLICE_LOW_1 = SLICES.lows[1];
|
|
76
|
-
const SLICE_LOW_2 = SLICES.lows[2];
|
|
77
|
-
const SLICE_LOW_3 = SLICES.lows[3];
|
|
205
|
+
setFingerprintPolynomial(0);
|
|
78
206
|
|
|
79
|
-
// Extends the fingerprint by the four bytes of a word, lowest first.
|
|
80
207
|
const extendInt = (word: number) => {
|
|
81
208
|
const mixed = low ^ word;
|
|
82
209
|
const first = mixed & 0xff;
|
|
@@ -94,9 +221,8 @@ const SET_ENUM_VALUE = 5;
|
|
|
94
221
|
const FCN_RCD_VALUE = 9;
|
|
95
222
|
const MODEL_VALUE = 21;
|
|
96
223
|
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// UniqueString token, and TLC numbers tokens from 1 in intern order.
|
|
224
|
+
// Returns how many bytes it extends the fingerprint by. A model value extends it with its
|
|
225
|
+
// UniqueString token, which TLC numbers from 1 in intern order.
|
|
100
226
|
const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
101
227
|
if (typeof value === "boolean") {
|
|
102
228
|
extendByte(BOOL_VALUE);
|
|
@@ -128,7 +254,6 @@ const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
|
128
254
|
return 5;
|
|
129
255
|
};
|
|
130
256
|
|
|
131
|
-
// Value#fingerPrint for each of TLC's value classes.
|
|
132
257
|
const extendValue = (value: Value) => {
|
|
133
258
|
if (typeof value !== "object" || isModelValue(value)) {
|
|
134
259
|
extendScalar(value);
|
|
@@ -148,12 +273,11 @@ const extendValue = (value: Value) => {
|
|
|
148
273
|
}
|
|
149
274
|
};
|
|
150
275
|
|
|
151
|
-
//
|
|
152
|
-
// fingerprint another, so this restores the fingerprint it interrupts.
|
|
276
|
+
// Evaluating a lazy value can fingerprint another, so this restores the fingerprint it interrupts.
|
|
153
277
|
export const getTlcFingerprint = (state: Value[]) => {
|
|
154
278
|
const outer = { high, low };
|
|
155
|
-
high =
|
|
156
|
-
low =
|
|
279
|
+
high = initial.high;
|
|
280
|
+
low = initial.low;
|
|
157
281
|
for (const value of state) extendValue(value);
|
|
158
282
|
const fingerprint = (BigInt(high >>> 0) << 32n) | BigInt(low >>> 0);
|
|
159
283
|
high = outer.high;
|
|
@@ -161,8 +285,6 @@ export const getTlcFingerprint = (state: Value[]) => {
|
|
|
161
285
|
return fingerprint;
|
|
162
286
|
};
|
|
163
287
|
|
|
164
|
-
// TLCStateMut#fingerPrint of each state's variables in TLC's variable order, as the fingerprint
|
|
165
|
-
// store reads them.
|
|
166
288
|
export const getTlcFingerprints = (states: Value[][], order: number[]) => {
|
|
167
289
|
const fingerprints = new BigInt64Array(states.length);
|
|
168
290
|
// Each fingerprint's low and high words, as a BigInt64Array is little-endian.
|
|
@@ -170,8 +292,8 @@ export const getTlcFingerprints = (states: Value[][], order: number[]) => {
|
|
|
170
292
|
const outerHigh = high;
|
|
171
293
|
const outerLow = low;
|
|
172
294
|
states.forEach((state, position) => {
|
|
173
|
-
high =
|
|
174
|
-
low =
|
|
295
|
+
high = initial.high;
|
|
296
|
+
low = initial.low;
|
|
175
297
|
for (const index of order) extendValue(state[index]);
|
|
176
298
|
words[2 * position] = low;
|
|
177
299
|
words[2 * position + 1] = high;
|
package/src/tlc/jar-data.ts
CHANGED
|
@@ -430,6 +430,16 @@ export const TLC_RUNTIME_STRINGS = [
|
|
|
430
430
|
"levelmean",
|
|
431
431
|
"levelvariance",
|
|
432
432
|
"bfs",
|
|
433
|
+
"beginLine",
|
|
434
|
+
"beginColumn",
|
|
435
|
+
"endLine",
|
|
436
|
+
"endColumn",
|
|
437
|
+
"module",
|
|
438
|
+
"name",
|
|
439
|
+
"location",
|
|
440
|
+
"context",
|
|
441
|
+
"parameters",
|
|
442
|
+
"_action",
|
|
433
443
|
];
|
|
434
444
|
|
|
435
445
|
export const SANY_NODE_NAMES = [
|
|
@@ -550,10 +560,6 @@ export const SANY_NODE_NAMES = [
|
|
|
550
560
|
"N_AssertStep",
|
|
551
561
|
];
|
|
552
562
|
|
|
553
|
-
// The standard modules that a spec may ship its own file of, such as CommunityModules' Json.tla,
|
|
554
|
-
// which SANY reads in place of its own.
|
|
555
|
-
export const USER_STANDARD_MODULES = new Set(["Bags", "Json", "Randomization", "TLCExt"]);
|
|
556
|
-
|
|
557
563
|
export const TLC_MODULE_SOURCES = new Map([
|
|
558
564
|
[
|
|
559
565
|
"Naturals",
|
|
@@ -925,9 +931,57 @@ _PrintCounts == PrintT(_Counts)
|
|
|
925
931
|
],
|
|
926
932
|
]);
|
|
927
933
|
|
|
928
|
-
//
|
|
929
|
-
// them in TLC's errors.
|
|
934
|
+
// As java.lang.reflect.Method prints them in TLC's errors.
|
|
930
935
|
export const TLC_JAVA_METHODS = new Map([
|
|
936
|
+
[
|
|
937
|
+
"Bags",
|
|
938
|
+
new Map([
|
|
939
|
+
[
|
|
940
|
+
"IsABag",
|
|
941
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.IsABag(tlc2.value.impl.Value)",
|
|
942
|
+
],
|
|
943
|
+
[
|
|
944
|
+
"BagCardinality",
|
|
945
|
+
"public static tlc2.value.impl.IntValue tlc2.module.Bags.BagCardinality(tlc2.value.impl.Value)",
|
|
946
|
+
],
|
|
947
|
+
[
|
|
948
|
+
"BagIn",
|
|
949
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.BagIn(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
950
|
+
],
|
|
951
|
+
[
|
|
952
|
+
"CopiesIn",
|
|
953
|
+
"public static tlc2.value.impl.IntValue tlc2.module.Bags.CopiesIn(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
954
|
+
],
|
|
955
|
+
[
|
|
956
|
+
"\\oplus",
|
|
957
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagCup(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
958
|
+
],
|
|
959
|
+
[
|
|
960
|
+
"\\ominus",
|
|
961
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagDiff(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
962
|
+
],
|
|
963
|
+
[
|
|
964
|
+
"BagUnion",
|
|
965
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagUnion(tlc2.value.impl.Value)",
|
|
966
|
+
],
|
|
967
|
+
[
|
|
968
|
+
"\\sqsubseteq",
|
|
969
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.SqSubseteq(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
970
|
+
],
|
|
971
|
+
[
|
|
972
|
+
"BagOfAll",
|
|
973
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagOfAll(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
974
|
+
],
|
|
975
|
+
[
|
|
976
|
+
"BagToSet",
|
|
977
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagToSet(tlc2.value.impl.Value)",
|
|
978
|
+
],
|
|
979
|
+
[
|
|
980
|
+
"SetToBag",
|
|
981
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.SetToBag(tlc2.value.impl.Value)",
|
|
982
|
+
],
|
|
983
|
+
]),
|
|
984
|
+
],
|
|
931
985
|
[
|
|
932
986
|
"FiniteSets",
|
|
933
987
|
new Map([
|
|
@@ -1023,4 +1077,57 @@ export const TLC_JAVA_METHODS = new Map([
|
|
|
1023
1077
|
],
|
|
1024
1078
|
]),
|
|
1025
1079
|
],
|
|
1080
|
+
[
|
|
1081
|
+
"TLCExt",
|
|
1082
|
+
new Map([
|
|
1083
|
+
[
|
|
1084
|
+
"AssertError",
|
|
1085
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.assertError(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1086
|
+
],
|
|
1087
|
+
[
|
|
1088
|
+
"PickSuccessor",
|
|
1089
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.pickSuccessor(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1090
|
+
],
|
|
1091
|
+
[
|
|
1092
|
+
"ToTrace",
|
|
1093
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.lassoOrdinal(tlc2.value.impl.Value)",
|
|
1094
|
+
],
|
|
1095
|
+
[
|
|
1096
|
+
"CounterExample",
|
|
1097
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.error(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel) throws java.io.IOException",
|
|
1098
|
+
],
|
|
1099
|
+
[
|
|
1100
|
+
"Trace",
|
|
1101
|
+
"public static tlc2.value.impl.TupleValue tlc2.module.TLCExt.getTrace(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel) throws java.io.IOException",
|
|
1102
|
+
],
|
|
1103
|
+
[
|
|
1104
|
+
"TLCDefer",
|
|
1105
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcDefer(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1106
|
+
],
|
|
1107
|
+
[
|
|
1108
|
+
"TLCNoOp",
|
|
1109
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcNoOp(tlc2.value.impl.Value)",
|
|
1110
|
+
],
|
|
1111
|
+
[
|
|
1112
|
+
"TLCModelValue",
|
|
1113
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.tlcModelValue(tlc2.value.impl.Value)",
|
|
1114
|
+
],
|
|
1115
|
+
[
|
|
1116
|
+
"TLCCache",
|
|
1117
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcEval2(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1118
|
+
],
|
|
1119
|
+
[
|
|
1120
|
+
"TLCFP",
|
|
1121
|
+
"public static synchronized tlc2.value.impl.IntValue tlc2.module.TLCExt.tlcFingerprint(tlc2.value.impl.Value)",
|
|
1122
|
+
],
|
|
1123
|
+
[
|
|
1124
|
+
"TLCEvalDefinition",
|
|
1125
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcDefByName(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1126
|
+
],
|
|
1127
|
+
[
|
|
1128
|
+
"TLCGetOrDefault",
|
|
1129
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcGetOrDefault(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
1130
|
+
],
|
|
1131
|
+
]),
|
|
1132
|
+
],
|
|
1026
1133
|
]);
|