tla-ts 0.0.9 → 0.0.10-dev.28c823e4b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +28 -28
- package/dist/deciders.js +43 -43
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +106 -10
- package/dist/index.d.ts +106 -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 +129 -104
- package/dist/transfer.js +129 -104
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +4 -23
- package/src/bags.ts +99 -102
- package/src/builtins.ts +40 -78
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +599 -388
- package/src/cli/options.ts +11 -6
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +136 -0
- package/src/cli/shared.ts +18 -11
- package/src/cli/tlapm.ts +0 -12
- package/src/cli/tlc-arguments.ts +640 -0
- package/src/cli/tlc-usage.ts +361 -0
- package/src/cli/tlc.ts +538 -220
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +4 -16
- package/src/cli.ts +0 -1
- package/src/codegen.ts +191 -64
- package/src/config.ts +140 -109
- package/src/coverage.ts +837 -0
- package/src/dependencies.ts +6 -40
- package/src/dfid.ts +618 -0
- package/src/environment.ts +240 -118
- package/src/errors.ts +70 -55
- package/src/evaluate.ts +596 -339
- 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 +4 -19
- package/src/json-reader.ts +455 -0
- package/src/json.ts +255 -139
- package/src/levels.ts +8 -17
- package/src/lexer.ts +80 -100
- package/src/liveness-checker.ts +82 -119
- package/src/liveness.ts +112 -64
- package/src/obligations/action.ts +4 -28
- package/src/obligations/anonymize.ts +84 -80
- package/src/obligations/equality.ts +1 -1
- package/src/obligations/expression.ts +2 -19
- package/src/obligations/format.ts +1 -9
- package/src/obligations/generate.ts +1 -11
- package/src/obligations/index.ts +0 -11
- package/src/obligations/levels.ts +4 -8
- package/src/obligations/module.ts +1 -15
- package/src/obligations/normalize.ts +5 -24
- package/src/obligations/operators.ts +1 -2
- package/src/obligations/pragma.ts +1 -10
- package/src/obligations/printer.ts +47 -46
- package/src/obligations/proof.ts +1 -5
- package/src/obligations/regroup.ts +1 -4
- package/src/obligations/simplify.ts +3 -14
- package/src/obligations/source.ts +1 -21
- package/src/obligations/subexpression.ts +5 -11
- package/src/obligations/substitution.ts +1 -3
- package/src/obligations/temporal.ts +8 -14
- package/src/obligations/tuples.ts +3 -9
- package/src/parallel-worker.ts +29 -39
- package/src/parallel.ts +53 -44
- package/src/parser.ts +565 -282
- package/src/pcal/ast.ts +53 -86
- package/src/pcal/parse.ts +144 -219
- package/src/pcal/tokenize.ts +91 -131
- package/src/pcal/translate.ts +83 -130
- package/src/pcal/validate.ts +48 -68
- package/src/pretty-print.ts +7 -8
- 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 +81 -35
- package/src/resolve.ts +12 -112
- package/src/runtime.ts +22 -22
- package/src/sany/builtins.ts +2 -5
- package/src/sany/generator.ts +149 -252
- package/src/sany/levels.ts +6 -34
- package/src/sany/lexer.ts +41 -61
- package/src/sany/linter.ts +1 -9
- 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 +495 -155
- package/src/simulate.ts +685 -0
- package/src/spec-description.ts +176 -69
- package/src/standard-definitions.ts +0 -4
- package/src/standard-modules.ts +254 -69
- package/src/state-graph.ts +50 -24
- package/src/subexpressions.ts +69 -52
- package/src/substitution-levels.ts +2 -3
- package/src/successors.ts +263 -94
- package/src/symmetry.ts +33 -25
- package/src/tableau.ts +27 -24
- package/src/tlc/fingerprint.ts +183 -67
- package/src/tlc/jar-data.ts +112 -6
- package/src/tlc/messages.ts +110 -44
- package/src/tlc/order.ts +37 -60
- package/src/tlc/random.ts +33 -45
- package/src/tlc/replay.ts +549 -217
- package/src/tlc/summary.ts +36 -47
- package/src/tlc/tlc-operators.ts +76 -41
- package/src/tlc/tlcext-operators.ts +139 -122
- package/src/tlc/trace-spec.ts +269 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -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 +780 -337
- 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) =>
|
|
@@ -40,8 +39,6 @@ const composePermutations = (first: Images, second: Images) => {
|
|
|
40
39
|
return composed;
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
// Tool#getSymmetryPerms fails with a RuntimeException as TLC starts, which TLC reports as one it
|
|
44
|
-
// did not expect.
|
|
45
42
|
const createSymmetryError = (message: string) =>
|
|
46
43
|
setExitCode(new TlaEvaluationError(`${UNEXPECTED_EXCEPTION}${message}`), EXIT_STATUS.error);
|
|
47
44
|
|
|
@@ -58,9 +55,32 @@ const toImages = (value: Value) => {
|
|
|
58
55
|
return permutation;
|
|
59
56
|
};
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
const getBoundImage = (pattern: BoundPattern, set: Expression | undefined) => {
|
|
59
|
+
const names = pattern.kind === "Name" ? pattern.name : `<<${pattern.names.join(",")}>>`;
|
|
60
|
+
return set ? `${names}\\in${getExpressionImage(set)}` : names;
|
|
61
|
+
};
|
|
62
|
+
|
|
62
63
|
const getExpressionImage = (expression: Expression): string => {
|
|
63
64
|
if (expression.kind === "Identifier") return expression.name;
|
|
65
|
+
if (expression.kind === "Number") return expression.text ?? String(expression.value);
|
|
66
|
+
if (expression.kind === "SetEnumeration") {
|
|
67
|
+
return `{${expression.elements.map(getExpressionImage).join(",")}}`;
|
|
68
|
+
}
|
|
69
|
+
if (expression.kind === "Choose") {
|
|
70
|
+
return `CHOOSE${getBoundImage(expression.pattern, expression.set)}:${getExpressionImage(expression.body)}`;
|
|
71
|
+
}
|
|
72
|
+
if (expression.kind === "Tuple")
|
|
73
|
+
return `<<${expression.elements.map(getExpressionImage).join(",")}>>`;
|
|
74
|
+
if (expression.kind === "Record") {
|
|
75
|
+
const fields = expression.fields.map(
|
|
76
|
+
(field) => `${field.name}|->${getExpressionImage(field.value)}`,
|
|
77
|
+
);
|
|
78
|
+
return `[${fields.join(",")}]`;
|
|
79
|
+
}
|
|
80
|
+
if (expression.kind === "FunctionConstruction") {
|
|
81
|
+
const bounds = expression.bounds.map((bound) => getBoundImage(bound.pattern, bound.set));
|
|
82
|
+
return `[${bounds.join(",")}|->${getExpressionImage(expression.body)}]`;
|
|
83
|
+
}
|
|
64
84
|
if (expression.kind !== "Apply") return "";
|
|
65
85
|
const args = expression.args.map(getExpressionImage);
|
|
66
86
|
return /^[A-Za-z_]/.test(expression.operator)
|
|
@@ -99,10 +119,9 @@ export const getSymmetryGroup = (
|
|
|
99
119
|
if (!elements.every(isFunctionValue)) {
|
|
100
120
|
throw createSymmetryError("The symmetry values must be function records.");
|
|
101
121
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const permutedSets = definition.body.kind === "Apply" ? definition.body.args : [];
|
|
122
|
+
const body = definition.body;
|
|
123
|
+
const permutedSets =
|
|
124
|
+
body.kind === "Apply" ? body.args : body.kind === "SetEnumeration" ? body.elements : [];
|
|
106
125
|
const configNames = new Map(
|
|
107
126
|
substitutions
|
|
108
127
|
.filter((substitution) => substitution.module === undefined)
|
|
@@ -125,28 +144,26 @@ export const getSymmetryGroup = (
|
|
|
125
144
|
return undefined;
|
|
126
145
|
}
|
|
127
146
|
const group = new Map<string, Images>();
|
|
128
|
-
|
|
147
|
+
elements.map(toImages).forEach((permutation) => {
|
|
129
148
|
if (permutation.size > 0) group.set(getPermutationKey(permutation), permutation);
|
|
130
149
|
});
|
|
131
150
|
const generators = [...group.values()];
|
|
132
|
-
|
|
133
|
-
while (
|
|
151
|
+
let frontierStart = 0;
|
|
152
|
+
while (frontierStart < group.size) {
|
|
134
153
|
const members = [...group.values()];
|
|
135
154
|
const end = members.length;
|
|
136
155
|
generators.forEach((generator) =>
|
|
137
|
-
members.slice(
|
|
156
|
+
members.slice(frontierStart, end).forEach((member) => {
|
|
138
157
|
const composed = composePermutations(generator, member);
|
|
139
158
|
const key = getPermutationKey(composed);
|
|
140
159
|
if (composed.size > 0 && !group.has(key)) group.set(key, composed);
|
|
141
160
|
}),
|
|
142
161
|
);
|
|
143
|
-
|
|
162
|
+
frontierStart = end;
|
|
144
163
|
}
|
|
145
164
|
const movedNames = new Set(
|
|
146
165
|
[...group.values()].flatMap((images) => [...images.values()].map((image) => image.name)),
|
|
147
166
|
);
|
|
148
|
-
// Only a permutation of a constant that TLC holds as an enumerated set is checked. TLC binds a
|
|
149
|
-
// constant the config substitutes with <- to the definition, which it skips.
|
|
150
167
|
const substitutedNames = new Set(substitutions.map((substitution) => substitution.name));
|
|
151
168
|
warnSmallSets(
|
|
152
169
|
permutedSets.filter((node) => {
|
|
@@ -180,8 +197,6 @@ const permuteElements = (elements: Value[], images: Images) => {
|
|
|
180
197
|
return undefined;
|
|
181
198
|
};
|
|
182
199
|
|
|
183
|
-
// A permutation maps distinct elements to distinct elements and keeps the elements it doesn't move
|
|
184
|
-
// in order, so it sorts only the moved ones and merges them back.
|
|
185
200
|
const permuteSortedElements = (elements: Value[], images: Images) => {
|
|
186
201
|
const kept: Value[] = [];
|
|
187
202
|
const moved: Value[] = [];
|
|
@@ -207,8 +222,6 @@ const permuteSortedElements = (elements: Value[], images: Images) => {
|
|
|
207
222
|
return merged;
|
|
208
223
|
};
|
|
209
224
|
|
|
210
|
-
// Value#permute: the value with each model value replaced by its image. A value the permutation
|
|
211
|
-
// doesn't move is returned itself, so that comparing it with itself stops at identity.
|
|
212
225
|
const permuteValue = (value: Value, images: Images): Value => {
|
|
213
226
|
if (typeof value !== "object") return value;
|
|
214
227
|
const kind = value.kind;
|
|
@@ -225,8 +238,6 @@ const permuteValue = (value: Value, images: Images): Value => {
|
|
|
225
238
|
const permuted = createFunction(
|
|
226
239
|
domain.map((key, index): [Value, Value] => [key, range[index]]),
|
|
227
240
|
);
|
|
228
|
-
// A permutation often maps the domain to itself, such as a function over the symmetric set.
|
|
229
|
-
// Sharing the original domain array lets comparisons with other images skip the domain.
|
|
230
241
|
const isSameDomain = permuted.domain.every(
|
|
231
242
|
(key, index) => key === functionValue.domain[index],
|
|
232
243
|
);
|
|
@@ -242,9 +253,6 @@ const permuteValue = (value: Value, images: Images): Value => {
|
|
|
242
253
|
return elements ? createSet(elements) : set;
|
|
243
254
|
};
|
|
244
255
|
|
|
245
|
-
// TLCStateMut#fingerPrint: the smallest image of the state under the group in TLC's variable
|
|
246
|
-
// order. TLC permutes the state under each permutation, variable by variable, and moves on to the
|
|
247
|
-
// next permutation as soon as a variable's image is larger than the smallest state's.
|
|
248
256
|
export const getRepresentative = (
|
|
249
257
|
state: Value[],
|
|
250
258
|
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,199 @@ 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
|
-
|
|
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
|
+
let selectedPolynomial = 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 = () => selectedPolynomial;
|
|
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
|
+
let initialHigh = 0;
|
|
159
|
+
let initialLow = 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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
169
|
+
export const setFingerprintPolynomial = (index: number) => {
|
|
170
|
+
const polynomial = POLYNOMIALS[index];
|
|
171
|
+
selectedPolynomial = polynomial;
|
|
172
|
+
const powers: bigint[] = [];
|
|
173
|
+
for (let power = 1n << 63n; powers.length < 72;) {
|
|
174
|
+
powers.push(power);
|
|
175
|
+
power = (power >> 1n) ^ ((power & 1n) === 0n ? 0n : polynomial);
|
|
176
|
+
}
|
|
177
|
+
const bytePowers = powers.slice(64, 72).reverse();
|
|
178
|
+
for (let byte = 0; byte < 256; byte++) {
|
|
179
|
+
const entry = bytePowers.reduce(
|
|
180
|
+
(value, power, bit) => ((byte >> bit) & 1 ? value ^ power : value),
|
|
181
|
+
0n,
|
|
182
|
+
);
|
|
183
|
+
SLICE_HIGH_0[byte] = Number(BigInt.asIntN(32, entry >> 32n));
|
|
184
|
+
SLICE_LOW_0[byte] = Number(BigInt.asIntN(32, entry));
|
|
185
|
+
}
|
|
186
|
+
const highs = [SLICE_HIGH_0, SLICE_HIGH_1, SLICE_HIGH_2, SLICE_HIGH_3];
|
|
187
|
+
const lows = [SLICE_LOW_0, SLICE_LOW_1, SLICE_LOW_2, SLICE_LOW_3];
|
|
52
188
|
for (let zeros = 1; zeros < 4; zeros++) {
|
|
53
189
|
const previousHigh = highs[zeros - 1];
|
|
54
190
|
const previousLow = lows[zeros - 1];
|
|
55
|
-
const sliceHigh = new Int32Array(256);
|
|
56
|
-
const sliceLow = new Int32Array(256);
|
|
57
191
|
for (let byte = 0; byte < 256; byte++) {
|
|
58
192
|
const index = previousLow[byte] & 0xff;
|
|
59
|
-
|
|
60
|
-
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^
|
|
61
|
-
|
|
193
|
+
lows[zeros][byte] =
|
|
194
|
+
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^ SLICE_LOW_0[index];
|
|
195
|
+
highs[zeros][byte] = (previousHigh[byte] >>> 8) ^ SLICE_HIGH_0[index];
|
|
62
196
|
}
|
|
63
|
-
highs.push(sliceHigh);
|
|
64
|
-
lows.push(sliceLow);
|
|
65
197
|
}
|
|
66
|
-
|
|
198
|
+
initialHigh = Number(BigInt.asIntN(32, polynomial >> 32n));
|
|
199
|
+
initialLow = Number(BigInt.asIntN(32, polynomial));
|
|
67
200
|
};
|
|
68
201
|
|
|
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];
|
|
202
|
+
setFingerprintPolynomial(0);
|
|
78
203
|
|
|
79
|
-
// Extends the fingerprint by the four bytes of a word, lowest first.
|
|
80
204
|
const extendInt = (word: number) => {
|
|
81
205
|
const mixed = low ^ word;
|
|
82
206
|
const first = mixed & 0xff;
|
|
@@ -94,9 +218,6 @@ const SET_ENUM_VALUE = 5;
|
|
|
94
218
|
const FCN_RCD_VALUE = 9;
|
|
95
219
|
const MODEL_VALUE = 21;
|
|
96
220
|
|
|
97
|
-
// Value#fingerPrint for TLC's booleans, integers, strings, and model values, which returns how
|
|
98
|
-
// many bytes it extends the fingerprint by. A model value extends the fingerprint with its
|
|
99
|
-
// UniqueString token, and TLC numbers tokens from 1 in intern order.
|
|
100
221
|
const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
101
222
|
if (typeof value === "boolean") {
|
|
102
223
|
extendByte(BOOL_VALUE);
|
|
@@ -128,7 +249,6 @@ const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
|
128
249
|
return 5;
|
|
129
250
|
};
|
|
130
251
|
|
|
131
|
-
// Value#fingerPrint for each of TLC's value classes.
|
|
132
252
|
const extendValue = (value: Value) => {
|
|
133
253
|
if (typeof value !== "object" || isModelValue(value)) {
|
|
134
254
|
extendScalar(value);
|
|
@@ -148,30 +268,26 @@ const extendValue = (value: Value) => {
|
|
|
148
268
|
}
|
|
149
269
|
};
|
|
150
270
|
|
|
151
|
-
// TLCStateMut#fingerPrint of variable values in TLC's variable order. Evaluating a lazy value can
|
|
152
|
-
// fingerprint another, so this restores the fingerprint it interrupts.
|
|
153
271
|
export const getTlcFingerprint = (state: Value[]) => {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
272
|
+
const outerHigh = high;
|
|
273
|
+
const outerLow = low;
|
|
274
|
+
high = initialHigh;
|
|
275
|
+
low = initialLow;
|
|
157
276
|
for (const value of state) extendValue(value);
|
|
158
277
|
const fingerprint = (BigInt(high >>> 0) << 32n) | BigInt(low >>> 0);
|
|
159
|
-
high =
|
|
160
|
-
low =
|
|
278
|
+
high = outerHigh;
|
|
279
|
+
low = outerLow;
|
|
161
280
|
return fingerprint;
|
|
162
281
|
};
|
|
163
282
|
|
|
164
|
-
// TLCStateMut#fingerPrint of each state's variables in TLC's variable order, as the fingerprint
|
|
165
|
-
// store reads them.
|
|
166
283
|
export const getTlcFingerprints = (states: Value[][], order: number[]) => {
|
|
167
284
|
const fingerprints = new BigInt64Array(states.length);
|
|
168
|
-
// Each fingerprint's low and high words, as a BigInt64Array is little-endian.
|
|
169
285
|
const words = new Int32Array(fingerprints.buffer);
|
|
170
286
|
const outerHigh = high;
|
|
171
287
|
const outerLow = low;
|
|
172
288
|
states.forEach((state, position) => {
|
|
173
|
-
high =
|
|
174
|
-
low =
|
|
289
|
+
high = initialHigh;
|
|
290
|
+
low = initialLow;
|
|
175
291
|
for (const index of order) extendValue(state[index]);
|
|
176
292
|
words[2 * position] = low;
|
|
177
293
|
words[2 * position + 1] = high;
|