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/dist/worker.cjs
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=/* @__PURE__ */ new WeakMap,
|
|
9
|
+
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>{let t=o(e);return t&&{branches:t.branches,addInitialState:(e,n,r)=>o(()=>t.addInitialState(e,n,r)),addState:(e,n,r,i)=>o(()=>t.addState(e,n,r,i)),findViolation:()=>o(()=>t.findViolation()),getViolatedProperties:(e,n)=>o(()=>t.getViolatedProperties(e,n))}},c=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,l=c(`java.lang.RuntimeException`),ee=c(`tlc2.tool.EvalException`),u=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var d=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},f=class extends d{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},p=class extends f{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},m=class extends p{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const h=(e,t=!1,n,r=[])=>new f(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
|
-
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),
|
|
12
|
-
`)}`,
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),g=(e,t)=>h([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),_=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,v=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,y=(e,t)=>h([{location:v(t),message:e}]);var b=class extends d{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},x=class extends d{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const S=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var C=class extends x{constructor(){super(S)}};const w=()=>i(new C,e.error);var T=class extends x{},E=class extends x{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},D=class extends x{variable;constructor(e,t){super(e),this.variable=t}},O=class extends x{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},k=class extends x{constructor(t){super(t),i(this,e.error)}},A=class extends T{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},j=class extends x{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},M=class extends x{},N=class extends x{};const P=`Too many possible next states for the last state in the trace.`;var F=class extends x{constructor(){super(P)}},I=class extends x{code;constructor(e,t){super(t),this.code=e}},L=class extends x{},R=class extends x{state;constructor(e){super(`current state is not a legal state`),this.state=e}},z=class extends d{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},B=class extends z{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},V=class extends d{constructor(e,t){super(e,t),this.name=`TlaProverError`}},te=class extends d{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},H=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}},U=class extends d{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},W=class extends d{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},G=class extends d{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},K=class extends d{constructor(e){super(e),this.name=`SmtInvariantError`}},q=class extends d{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},J=class extends d{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},Y=class extends d{constructor(e,t){super(e,t),this.name=`SmtParseError`}},X=class extends U{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const Z=t=>a(t)??(t instanceof f?e.specParseError:t instanceof b?e.configParseError:t instanceof x?e.specEvaluationFailure:e.error);var Q=class extends d{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},ne=class extends d{constructor(e){super(e),this.name=`PcalRuntimeError`}},re=class extends d{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ie=class extends d{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,ae=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,oe=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
|
-
|
|
18
|
+
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},se=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
19
|
/* @vite-ignore */
|
|
20
20
|
/* webpackIgnore: true */
|
|
21
|
-
|
|
21
|
+
$)).parentPort,ce=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return T}});
|
package/dist/worker.js
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=/* @__PURE__ */ new WeakMap,
|
|
9
|
+
const e={success:0,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>{let t=o(e);return t&&{branches:t.branches,addInitialState:(e,n,r)=>o(()=>t.addInitialState(e,n,r)),addState:(e,n,r,i)=>o(()=>t.addState(e,n,r,i)),findViolation:()=>o(()=>t.findViolation()),getViolatedProperties:(e,n)=>o(()=>t.getViolatedProperties(e,n))}},c=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,l=c(`java.lang.RuntimeException`),ee=c(`tlc2.tool.EvalException`),u=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var d=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},f=class extends d{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},p=class extends f{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},m=class extends p{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const h=(e,t=!1,n,r=[])=>new f(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
|
-
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),
|
|
12
|
-
`)}`,
|
|
11
|
+
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),g=(e,t)=>h([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),_=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
+
`)}`,v=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,y=(e,t)=>h([{location:v(t),message:e}]);var b=class extends d{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},x=class extends d{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const S=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var C=class extends x{constructor(){super(S)}};const w=()=>i(new C,e.error);var T=class extends x{},E=class extends x{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},D=class extends x{variable;constructor(e,t){super(e),this.variable=t}},O=class extends x{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},k=class extends x{constructor(t){super(t),i(this,e.error)}},A=class extends T{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},j=class extends x{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},M=class extends x{},N=class extends x{};const P=`Too many possible next states for the last state in the trace.`;var F=class extends x{constructor(){super(P)}},I=class extends x{code;constructor(e,t){super(t),this.code=e}},L=class extends x{},R=class extends x{state;constructor(e){super(`current state is not a legal state`),this.state=e}},z=class extends d{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},B=class extends z{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},V=class extends d{constructor(e,t){super(e,t),this.name=`TlaProverError`}},te=class extends d{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},H=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}},U=class extends d{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},W=class extends d{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},G=class extends d{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},K=class extends d{constructor(e){super(e),this.name=`SmtInvariantError`}},q=class extends d{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},J=class extends d{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},Y=class extends d{constructor(e,t){super(e,t),this.name=`SmtParseError`}},X=class extends U{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const Z=t=>a(t)??(t instanceof f?e.specParseError:t instanceof b?e.configParseError:t instanceof x?e.specEvaluationFailure:e.error);var Q=class extends d{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},ne=class extends d{constructor(e){super(e),this.name=`PcalRuntimeError`}},re=class extends d{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ie=class extends d{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,ae=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,oe=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
|
-
|
|
18
|
+
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},se=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
19
19
|
/* @vite-ignore */
|
|
20
20
|
/* webpackIgnore: true */
|
|
21
|
-
|
|
21
|
+
$)).parentPort,ce=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{c as $,z as A,U as B,E as C,m as D,j as E,f as F,l as G,te as H,F as I,y as J,g as K,ie as L,p as M,N,O,C as P,Z as Q,D as R,R as S,X as T,B as U,I as V,ee as W,v as X,w as Y,_ as Z,b as _,q as a,s as at,x as b,ne as c,G as d,u as et,K as f,M as g,P as h,oe as i,i as it,V as j,L as k,J as l,W as m,se as n,a as nt,re as o,Y as p,h as q,ae as r,n as rt,Q as s,ce as t,e as tt,S as u,A as v,H as w,k as x,d as y,T as z};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tla-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9-dev.0493be549",
|
|
4
4
|
"description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formal verification",
|
|
@@ -55,9 +55,11 @@
|
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@typescript/typescript6": "6.0.2",
|
|
58
59
|
"fflate": "^0.8.3"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
62
|
+
"@engine262/engine262": "0.0.1-d553e7b52501fbc47eae981c8d0fa7a5c26d0171",
|
|
61
63
|
"@types/node": "^22",
|
|
62
64
|
"publint": "^0.3.0",
|
|
63
65
|
"typescript": "^7.0.2",
|
package/src/ast.ts
CHANGED
|
@@ -33,8 +33,6 @@ export interface StringExpression {
|
|
|
33
33
|
location: SourceLocation;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// selectorRanges holds the range of each part of a name such as foo!lab, where SANY reports an
|
|
37
|
-
// error in selecting that part. spelling holds the text of an operator written as a synonym.
|
|
38
36
|
export interface IdentifierExpression {
|
|
39
37
|
kind: "Identifier";
|
|
40
38
|
name: string;
|
|
@@ -51,14 +49,9 @@ export interface ApplyExpression {
|
|
|
51
49
|
operator: string;
|
|
52
50
|
spelling?: string;
|
|
53
51
|
args: Expression[];
|
|
54
|
-
// The number of args each part of a name like F(x)!l(y) takes, when a part before the last takes
|
|
55
|
-
// some.
|
|
56
52
|
argumentCounts?: number[];
|
|
57
|
-
// The range of the parenthesized arguments of a named operator, or of the whole name when its
|
|
58
|
-
// last part takes none, where SANY reports their count.
|
|
59
53
|
argumentsRange?: SourceRange;
|
|
60
54
|
selectorRanges?: SourceRange[];
|
|
61
|
-
// The range of the arguments of each part of a name like F(x)!l(y), for a part that takes some.
|
|
62
55
|
argumentRanges?: (SourceRange | undefined)[];
|
|
63
56
|
location: SourceLocation;
|
|
64
57
|
resolution?: LocalResolution;
|
|
@@ -71,8 +64,6 @@ export interface OperatorReferenceExpression {
|
|
|
71
64
|
location: SourceLocation;
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
// operator holds the operator, such as SUBSET, that an argument names, which tla-ts reads as a
|
|
75
|
-
// LAMBDA.
|
|
76
67
|
export interface LambdaExpression {
|
|
77
68
|
kind: "Lambda";
|
|
78
69
|
params: string[];
|
|
@@ -86,8 +77,8 @@ export interface JunctionExpression {
|
|
|
86
77
|
kind: "And" | "Or";
|
|
87
78
|
operands: Expression[];
|
|
88
79
|
isBulleted?: boolean;
|
|
89
|
-
// SANY parses
|
|
90
|
-
//
|
|
80
|
+
// SANY parses A /\ B /\ C as (A /\ B) /\ C, whose node of each prefix of two or more operands ends
|
|
81
|
+
// after the parentheses of its last operand.
|
|
91
82
|
prefixEnds?: SourceLocation[];
|
|
92
83
|
location: SourceLocation;
|
|
93
84
|
}
|
|
@@ -127,6 +118,7 @@ export interface CaseExpression {
|
|
|
127
118
|
kind: "Case";
|
|
128
119
|
arms: CaseArm[];
|
|
129
120
|
other: Expression | undefined;
|
|
121
|
+
otherRange?: SourceRange;
|
|
130
122
|
location: SourceLocation;
|
|
131
123
|
}
|
|
132
124
|
|
|
@@ -138,7 +130,6 @@ export interface LetExpression {
|
|
|
138
130
|
location: SourceLocation;
|
|
139
131
|
}
|
|
140
132
|
|
|
141
|
-
// ranges holds the range of each name the pattern binds.
|
|
142
133
|
export type BoundPattern =
|
|
143
134
|
| { kind: "Name"; name: string; ranges?: SourceRange[] }
|
|
144
135
|
| { kind: "Tuple"; names: string[]; ranges?: SourceRange[] };
|
|
@@ -254,8 +245,7 @@ export interface FunctionApplicationExpression {
|
|
|
254
245
|
location: SourceLocation;
|
|
255
246
|
}
|
|
256
247
|
|
|
257
|
-
// SANY parses [e1, ..., en] as a function application without the function, and
|
|
258
|
-
// checker rejects it.
|
|
248
|
+
// SANY parses [e1, ..., en] as a function application without the function, and rejects it.
|
|
259
249
|
export interface BracketExpression {
|
|
260
250
|
kind: "Bracket";
|
|
261
251
|
args: Expression[];
|
|
@@ -301,6 +291,7 @@ export interface LabelExpression {
|
|
|
301
291
|
name: string;
|
|
302
292
|
params: string[];
|
|
303
293
|
paramRanges?: SourceRange[];
|
|
294
|
+
head?: SourceRange;
|
|
304
295
|
body: Expression;
|
|
305
296
|
location: SourceLocation;
|
|
306
297
|
}
|
|
@@ -369,6 +360,7 @@ export interface OperatorDefinition {
|
|
|
369
360
|
params: OperatorParam[];
|
|
370
361
|
body: Expression;
|
|
371
362
|
bodyRange?: SourceRange;
|
|
363
|
+
head?: SourceRange;
|
|
372
364
|
isLocal: boolean;
|
|
373
365
|
isRecursive: boolean;
|
|
374
366
|
location: SourceLocation;
|
|
@@ -381,7 +373,6 @@ export interface FunctionDefinition {
|
|
|
381
373
|
body: Expression;
|
|
382
374
|
isLocal: boolean;
|
|
383
375
|
isRecursive: boolean;
|
|
384
|
-
// Whether the body applies the function, which SANY makes a recursive function definition.
|
|
385
376
|
isSelfReferential?: boolean;
|
|
386
377
|
location: SourceLocation;
|
|
387
378
|
}
|
|
@@ -438,7 +429,6 @@ export interface AssumeProve {
|
|
|
438
429
|
|
|
439
430
|
export type Fact = Expression | { kind: "ModuleFact"; name: string; location: SourceLocation };
|
|
440
431
|
|
|
441
|
-
// keyword is the range of the USE or HIDE token and any ONLY after it.
|
|
442
432
|
export interface UseOrHide {
|
|
443
433
|
kind: "Use" | "Hide";
|
|
444
434
|
isOnly: boolean;
|
|
@@ -448,7 +438,6 @@ export interface UseOrHide {
|
|
|
448
438
|
location: SourceLocation;
|
|
449
439
|
}
|
|
450
440
|
|
|
451
|
-
// keyword is the range of the BY, OBVIOUS, or OMITTED token.
|
|
452
441
|
export type Proof =
|
|
453
442
|
| { kind: "Obvious" | "Omitted"; keyword: SourceRange; location: SourceLocation }
|
|
454
443
|
| {
|
|
@@ -490,8 +479,6 @@ export type StepBody =
|
|
|
490
479
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
491
480
|
| { kind: "Qed" };
|
|
492
481
|
|
|
493
|
-
// head is the range of the step number and its statement, without the proof, and statement is the
|
|
494
|
-
// range of the statement alone.
|
|
495
482
|
export interface ProofStep {
|
|
496
483
|
name: string | undefined;
|
|
497
484
|
token: string;
|
|
@@ -509,10 +496,9 @@ export interface Theorem {
|
|
|
509
496
|
location: SourceLocation;
|
|
510
497
|
}
|
|
511
498
|
|
|
512
|
-
// The units of a module in source order, for consumers that need the order across kinds.
|
|
513
499
|
export type ModuleUnit =
|
|
514
500
|
| { kind: "Constants" | "Variables"; declarations: Declaration[]; location: SourceLocation }
|
|
515
|
-
| { kind: "Recursive"; declarations: Declaration[] }
|
|
501
|
+
| { kind: "Recursive"; declarations: Declaration[]; location: SourceLocation }
|
|
516
502
|
| { kind: "Definition"; definition: Definition }
|
|
517
503
|
| { kind: "Instance"; instance: Instance }
|
|
518
504
|
| { kind: "Assumption"; assumption: Assumption }
|
package/src/bags.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createJavaOverrideError,
|
|
3
2
|
createModuleArgumentError,
|
|
4
3
|
createOverflowError,
|
|
5
4
|
defineConstant,
|
|
6
5
|
defineHigherOrderOperator,
|
|
7
6
|
defineOperator,
|
|
8
7
|
getJavaClassName,
|
|
8
|
+
getKindString,
|
|
9
9
|
getOperator,
|
|
10
10
|
getValue,
|
|
11
11
|
isOutOfRange,
|
|
@@ -13,17 +13,18 @@ import {
|
|
|
13
13
|
import { TlaEvaluationError, TlaModuleError } from "./errors";
|
|
14
14
|
import type { Builtin, BuiltinArgument } from "./evaluate";
|
|
15
15
|
import {
|
|
16
|
+
createEnumeratedSet,
|
|
16
17
|
createFunction,
|
|
17
18
|
createSet,
|
|
18
19
|
createSortedFunction,
|
|
19
20
|
formatValue,
|
|
20
21
|
getDomain,
|
|
21
22
|
isEnumerable,
|
|
23
|
+
isEqualLikeTlc,
|
|
22
24
|
isFunctionValue,
|
|
23
25
|
isSetValue,
|
|
24
26
|
toFiniteFunction,
|
|
25
27
|
toFiniteSet,
|
|
26
|
-
valuesEqual,
|
|
27
28
|
type FunctionValue,
|
|
28
29
|
type Value,
|
|
29
30
|
} from "./values";
|
|
@@ -35,18 +36,39 @@ const createWrongValueError = (name: string, expected: string, value: Value) =>
|
|
|
35
36
|
|
|
36
37
|
const toFunction = (value: Value) => (isFunctionValue(value) ? toFiniteFunction(value) : undefined);
|
|
37
38
|
|
|
39
|
+
const FINITE_FUNCTION = "a function with a finite domain";
|
|
40
|
+
|
|
38
41
|
const getFunction = (args: BuiltinArgument[], index: number, name: string) => {
|
|
39
42
|
const value = getValue(args, index, name);
|
|
40
43
|
const functionValue = toFunction(value);
|
|
41
|
-
if (!functionValue) throw createWrongValueError(name,
|
|
44
|
+
if (!functionValue) throw createWrongValueError(name, FINITE_FUNCTION, value);
|
|
42
45
|
return functionValue;
|
|
43
46
|
};
|
|
44
47
|
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const functionValue = toFunction(
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const getCount = (args: BuiltinArgument[], name: string) => {
|
|
49
|
+
const bag = getValue(args, 1, name);
|
|
50
|
+
const functionValue = toFunction(bag);
|
|
51
|
+
const count = functionValue && findCount(functionValue, getValue(args, 0, name));
|
|
52
|
+
if (!functionValue || (count !== undefined && typeof count !== "number")) {
|
|
53
|
+
throw createModuleArgumentError("second", name, "bag", bag);
|
|
54
|
+
}
|
|
55
|
+
return count;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getAddedBag = (
|
|
59
|
+
args: BuiltinArgument[],
|
|
60
|
+
functions: (FunctionValue | undefined)[],
|
|
61
|
+
index: number,
|
|
62
|
+
) => {
|
|
63
|
+
const functionValue = functions[index];
|
|
64
|
+
if (!functionValue || !isBag(functionValue)) {
|
|
65
|
+
throw createModuleArgumentError(
|
|
66
|
+
index === 0 ? "first" : "second",
|
|
67
|
+
"(+)",
|
|
68
|
+
"bag",
|
|
69
|
+
getValue(args, index, "(+)"),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
50
72
|
return functionValue;
|
|
51
73
|
};
|
|
52
74
|
|
|
@@ -59,63 +81,45 @@ const isBag = (functionValue: FunctionValue) =>
|
|
|
59
81
|
functionValue.range.every((count) => typeof count === "number" && count > 0);
|
|
60
82
|
|
|
61
83
|
const findCount = (functionValue: FunctionValue, element: Value) => {
|
|
62
|
-
const position = functionValue.domain.findIndex((key) =>
|
|
84
|
+
const position = functionValue.domain.findIndex((key) => isEqualLikeTlc(element, key));
|
|
63
85
|
return position === -1 ? undefined : functionValue.range[position];
|
|
64
86
|
};
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
`public static ${result} tlc2.module.Bags.${name}(${Array.from({ length: arity }, () => "tlc2.value.impl.Value").join(",")})`;
|
|
68
|
-
|
|
69
|
-
const BAG_DIFF_SIGNATURE = getBagsSignature("BagDiff", "tlc2.value.impl.Value", 2);
|
|
70
|
-
const SQ_SUBSETEQ_SIGNATURE = getBagsSignature("SqSubseteq", "tlc2.value.IBoolValue", 2);
|
|
71
|
-
const BAG_UNION_SIGNATURE = getBagsSignature("BagUnion", "tlc2.value.impl.Value", 1);
|
|
72
|
-
const BAG_OF_ALL_SIGNATURE = getBagsSignature("BagOfAll", "tlc2.value.impl.Value", 2);
|
|
73
|
-
const BAG_CUP_SIGNATURE = getBagsSignature("BagCup", "tlc2.value.impl.Value", 2);
|
|
74
|
-
const BAG_CARDINALITY_SIGNATURE = getBagsSignature("BagCardinality", "tlc2.value.impl.IntValue", 1);
|
|
75
|
-
|
|
76
|
-
// Bags.java casts each count to IntValue, so a count that isn't an integer fails with Java's
|
|
88
|
+
// Bags.java casts each count to IntValue, so a count that isn't an integer fails with a
|
|
77
89
|
// ClassCastException.
|
|
78
|
-
const toCount = (value: Value
|
|
90
|
+
const toCount = (value: Value) => {
|
|
79
91
|
if (typeof value === "number") return value;
|
|
80
92
|
const javaClass = `tlc2.value.impl.${getJavaClassName(value)}`;
|
|
81
|
-
throw
|
|
82
|
-
method,
|
|
93
|
+
throw new TlaEvaluationError(
|
|
83
94
|
`class ${javaClass} cannot be cast to class tlc2.value.impl.IntValue (${javaClass} and tlc2.value.impl.IntValue are in unnamed module of loader 'app')`,
|
|
84
95
|
);
|
|
85
96
|
};
|
|
86
97
|
|
|
87
|
-
const addCounts = (left: Value, right: Value
|
|
88
|
-
const sum = toCount(left
|
|
98
|
+
const addCounts = (left: Value, right: Value) => {
|
|
99
|
+
const sum = toCount(left) + toCount(right);
|
|
89
100
|
if (isOutOfRange(sum)) throw createOverflowError(`${left}+${right}`);
|
|
90
101
|
return sum;
|
|
91
102
|
};
|
|
92
103
|
|
|
93
|
-
//
|
|
94
|
-
const subtractCounts = (
|
|
95
|
-
functionValue
|
|
96
|
-
index: number,
|
|
97
|
-
other: FunctionValue,
|
|
98
|
-
method: string,
|
|
99
|
-
) => {
|
|
104
|
+
// Bags.java subtracts counts as Java ints, which wrap, where the - of the TLA+ definition overflows.
|
|
105
|
+
const subtractCounts = (functionValue: FunctionValue, index: number, other: FunctionValue) => {
|
|
106
|
+
const count = toCount(functionValue.range[index]);
|
|
100
107
|
const removed = findCount(other, functionValue.domain[index]);
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
if (removed === undefined) return count;
|
|
109
|
+
const difference = count - toCount(removed);
|
|
110
|
+
if (isOutOfRange(difference)) throw createOverflowError(`${count}-${removed}`);
|
|
111
|
+
return difference;
|
|
103
112
|
};
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
pairs.push([key, bag.range[index]]);
|
|
115
|
-
});
|
|
116
|
-
return pairs;
|
|
117
|
-
}, []),
|
|
118
|
-
);
|
|
114
|
+
// BagCup looks up a key of its second bag only among the keys of its first.
|
|
115
|
+
const addToBag = (pairs: [Value, Value][], key: Value, count: Value, end = pairs.length) => {
|
|
116
|
+
const existing = pairs.slice(0, end).find((pair) => isEqualLikeTlc(key, pair[0]));
|
|
117
|
+
if (existing) existing[1] = addCounts(existing[1], count);
|
|
118
|
+
else pairs.push([key, count]);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const getPairs = (functionValue: FunctionValue) =>
|
|
122
|
+
functionValue.domain.map((key, index): [Value, Value] => [key, functionValue.range[index]]);
|
|
119
123
|
|
|
120
124
|
const EMPTY_BAG = createSortedFunction([], []);
|
|
121
125
|
|
|
@@ -133,45 +137,34 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
|
|
|
133
137
|
if (typeof count !== "number" || count <= 0) {
|
|
134
138
|
throw createWrongValueError("BagCardinality", "a bag", bag);
|
|
135
139
|
}
|
|
136
|
-
return addCounts(total, count
|
|
140
|
+
return addCounts(total, count);
|
|
137
141
|
}, 0);
|
|
138
142
|
}),
|
|
139
143
|
defineOperator("BagIn", 2, (args) => {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
if (count === undefined) return false;
|
|
143
|
-
if (typeof count !== "number") throw createModuleArgumentError("second", "BagIn", "bag", bag);
|
|
144
|
-
return count > 0;
|
|
145
|
-
}),
|
|
146
|
-
defineOperator("CopiesIn", 2, (args) => {
|
|
147
|
-
const bag = getValue(args, 1, "CopiesIn");
|
|
148
|
-
const count = findCount(getFunction(args, 1, "CopiesIn"), getValue(args, 0, "CopiesIn"));
|
|
149
|
-
if (count === undefined) return 0;
|
|
150
|
-
if (typeof count !== "number")
|
|
151
|
-
throw createModuleArgumentError("second", "CopiesIn", "bag", bag);
|
|
152
|
-
return count;
|
|
144
|
+
const count = getCount(args, "BagIn");
|
|
145
|
+
return count !== undefined && count > 0;
|
|
153
146
|
}),
|
|
147
|
+
defineOperator("CopiesIn", 2, (args) => getCount(args, "CopiesIn") ?? 0),
|
|
154
148
|
defineOperator("\\oplus", 2, (args) => {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
return functionValue;
|
|
166
|
-
});
|
|
167
|
-
return mergeBags(bags, BAG_CUP_SIGNATURE);
|
|
149
|
+
const functions = [0, 1].map((index) => toFunction(getValue(args, index, "(+)")));
|
|
150
|
+
const left = getAddedBag(args, functions, 0);
|
|
151
|
+
const right = getAddedBag(args, functions, 1);
|
|
152
|
+
const pairs = getPairs(left);
|
|
153
|
+
right.domain.forEach((key, index) =>
|
|
154
|
+
addToBag(pairs, key, right.range[index], left.domain.length),
|
|
155
|
+
);
|
|
156
|
+
return createFunction(pairs);
|
|
168
157
|
}),
|
|
169
158
|
defineOperator("\\ominus", 2, (args) => {
|
|
170
|
-
const
|
|
171
|
-
const
|
|
159
|
+
const leftValue = getValue(args, 0, "(-)");
|
|
160
|
+
const rightValue = getValue(args, 1, "(-)");
|
|
161
|
+
const left = toFunction(leftValue);
|
|
162
|
+
const right = toFunction(rightValue);
|
|
163
|
+
if (!left) throw createModuleArgumentError("first", "(-)", "bag", leftValue);
|
|
164
|
+
if (!right) throw createModuleArgumentError("second", "(-)", "bag", rightValue);
|
|
172
165
|
return createFunction(
|
|
173
166
|
left.domain.flatMap((key, index): [Value, Value][] => {
|
|
174
|
-
const count = subtractCounts(left, index, right
|
|
167
|
+
const count = subtractCounts(left, index, right);
|
|
175
168
|
return count > 0 ? [[key, count]] : [];
|
|
176
169
|
}),
|
|
177
170
|
);
|
|
@@ -182,7 +175,7 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
|
|
|
182
175
|
createWrongValueError("BagUnion", "a finite enumerable set", set),
|
|
183
176
|
);
|
|
184
177
|
if (elements.length < 2) return elements[0] ?? EMPTY_BAG;
|
|
185
|
-
const
|
|
178
|
+
const getBag = (element: Value) => {
|
|
186
179
|
const functionValue = toFunction(element);
|
|
187
180
|
if (!functionValue) {
|
|
188
181
|
throw new TlaModuleError(
|
|
@@ -190,43 +183,50 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
|
|
|
190
183
|
);
|
|
191
184
|
}
|
|
192
185
|
return functionValue;
|
|
186
|
+
};
|
|
187
|
+
const pairs = getPairs(getBag(elements[0]));
|
|
188
|
+
elements.slice(1).forEach((element) => {
|
|
189
|
+
const functionValue = getBag(element);
|
|
190
|
+
functionValue.domain.forEach((key, index) =>
|
|
191
|
+
addToBag(pairs, key, functionValue.range[index]),
|
|
192
|
+
);
|
|
193
193
|
});
|
|
194
|
-
return
|
|
194
|
+
return createFunction(pairs);
|
|
195
195
|
}),
|
|
196
196
|
defineOperator("\\sqsubseteq", 2, (args) => {
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
);
|
|
197
|
+
const leftValue = getValue(args, 0, "\\sqsubseteq");
|
|
198
|
+
const rightValue = getValue(args, 1, "\\sqsubseteq");
|
|
199
|
+
const left = toFunction(leftValue);
|
|
200
|
+
const right = toFunction(rightValue);
|
|
201
|
+
if (!left) throw createWrongValueError("\\sqsubseteq", FINITE_FUNCTION, leftValue);
|
|
202
|
+
if (!right) throw createWrongValueError("\\sqsubseteq", FINITE_FUNCTION, rightValue);
|
|
203
|
+
return left.domain.every((key, index) => {
|
|
204
|
+
const count = findCount(right, key);
|
|
205
|
+
return toCount(left.range[index]) <= (count === undefined ? 0 : toCount(count));
|
|
206
|
+
});
|
|
202
207
|
}),
|
|
203
208
|
defineHigherOrderOperator("BagOfAll", 2, (args) => {
|
|
204
209
|
const operator = getOperator(args, 0, "BagOfAll");
|
|
205
|
-
// TLC passes an operator whose body is a number or string literal to Bags.java as that literal.
|
|
206
|
-
if (operator.literalBody !== undefined) {
|
|
207
|
-
throw new TlaModuleError(
|
|
208
|
-
`The first argument of BagOfAll should be an operator, but instead it is:\n${formatValue(operator.literalBody)}`,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
210
|
const value = getValue(args, 1, "BagOfAll");
|
|
212
211
|
const functionValue = toFunction(value);
|
|
213
212
|
if (!functionValue) {
|
|
214
213
|
throw createModuleArgumentError("second", "BagOfAll", "function with a finite domain", value);
|
|
215
214
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
),
|
|
220
|
-
BAG_OF_ALL_SIGNATURE,
|
|
215
|
+
const pairs: [Value, Value][] = [];
|
|
216
|
+
functionValue.domain.forEach((key, index) =>
|
|
217
|
+
addToBag(pairs, operator.call([key]), functionValue.range[index]),
|
|
221
218
|
);
|
|
219
|
+
return createFunction(pairs);
|
|
222
220
|
}),
|
|
223
221
|
defineOperator("SubBag", 1, (args) => {
|
|
224
222
|
const value = getValue(args, 0, "SubBag");
|
|
225
223
|
if (!isFunctionValue(value)) {
|
|
226
|
-
throw new TlaEvaluationError(
|
|
224
|
+
throw new TlaEvaluationError(
|
|
225
|
+
`Attempted to apply the operator DOMAIN to a non-function\n(${getKindString(value)})\nline 106, col 58 to line 106, col 65 of module Bags`,
|
|
226
|
+
);
|
|
227
227
|
}
|
|
228
228
|
const functionValue = toFiniteFunction(value);
|
|
229
|
-
const range =
|
|
229
|
+
const range = toFiniteSet(createEnumeratedSet(functionValue.range)).elements;
|
|
230
230
|
const invalid = range.find((count) => typeof count !== "number");
|
|
231
231
|
// A count that isn't an integer fails the comparison.
|
|
232
232
|
if (invalid !== undefined) builtins.get(">=")?.evaluateBinary?.(range[0], invalid);
|
|
@@ -261,7 +261,7 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
|
|
|
261
261
|
defineOperator("SetToBag", 1, (args) => {
|
|
262
262
|
const set = getValue(args, 0, "SetToBag");
|
|
263
263
|
const elements = getFiniteElements(set, () =>
|
|
264
|
-
createWrongValueError("BagToSet",
|
|
264
|
+
createWrongValueError("BagToSet", FINITE_FUNCTION, set),
|
|
265
265
|
);
|
|
266
266
|
return createSortedFunction(
|
|
267
267
|
[...elements],
|