tla-ts 0.0.9 → 0.0.10-dev.09e53c2a6
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 -1
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +41 -37
- package/dist/deciders.js +57 -53
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +109 -10
- package/dist/index.d.ts +109 -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 +2746 -410
- package/dist/prove.js +2745 -409
- package/dist/run.cjs +146 -31
- package/dist/run.js +146 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +132 -104
- package/dist/transfer.js +132 -104
- package/dist/worker.cjs +6 -6
- package/dist/worker.js +6 -6
- package/package.json +3 -1
- package/src/ast.ts +45 -59
- package/src/bags.ts +99 -102
- package/src/builtins.ts +28 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check-failure.ts +116 -0
- package/src/check-trace.ts +282 -0
- package/src/check.ts +797 -782
- package/src/cli/options.ts +12 -32
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +136 -0
- package/src/cli/shared.ts +19 -12
- package/src/cli/tlapm.ts +433 -82
- package/src/cli/tlc-arguments.ts +652 -0
- package/src/cli/tlc-output.ts +687 -0
- package/src/cli/tlc-usage.ts +360 -0
- package/src/cli/tlc.ts +323 -658
- package/src/cli/typescript.ts +23 -0
- package/src/cli/xml-exporter.ts +27 -49
- package/src/cli.ts +0 -1
- package/src/codegen.ts +196 -74
- package/src/config.ts +140 -109
- package/src/coverage.ts +830 -0
- package/src/dependencies.ts +36 -54
- package/src/dfid.ts +618 -0
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +178 -339
- package/src/errors.ts +100 -57
- package/src/evaluate.ts +598 -340
- package/src/exit-codes.ts +38 -3
- package/src/fingerprints.ts +75 -11
- package/src/index.ts +3 -0
- package/src/instances.ts +126 -21
- package/src/java-hash.ts +7 -0
- package/src/java-overrides.ts +4 -19
- package/src/json-reader.ts +455 -0
- package/src/json.ts +252 -139
- package/src/levels.ts +46 -58
- package/src/lexer.ts +83 -101
- package/src/liveness-checker.ts +590 -311
- package/src/liveness.ts +180 -124
- package/src/obligations/action.ts +17 -44
- package/src/obligations/anonymize.ts +120 -95
- package/src/obligations/enabled-axioms.ts +218 -0
- package/src/obligations/equality.ts +1 -3
- package/src/obligations/expression.ts +37 -26
- package/src/obligations/format.ts +0 -10
- package/src/obligations/generate.ts +66 -64
- package/src/obligations/index.ts +38 -19
- package/src/obligations/levels.ts +27 -18
- package/src/obligations/module.ts +28 -55
- package/src/obligations/normalize.ts +30 -37
- package/src/obligations/operators.ts +0 -3
- package/src/obligations/pragma.ts +52 -24
- package/src/obligations/printer.ts +89 -58
- package/src/obligations/proof.ts +3 -6
- package/src/obligations/regroup.ts +0 -5
- package/src/obligations/simplify.ts +57 -63
- package/src/obligations/source.ts +119 -95
- package/src/obligations/subexpression.ts +49 -28
- package/src/obligations/substitution.ts +1 -5
- package/src/obligations/temporal.ts +12 -20
- package/src/obligations/tuples.ts +2 -10
- package/src/parallel-worker.ts +30 -60
- package/src/parallel.ts +59 -73
- package/src/parser.ts +1082 -399
- 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 +8 -13
- package/src/prover/deciders.ts +12 -13
- package/src/prover/first-order.ts +0 -11
- package/src/prover/isabelle/decide.ts +3 -31
- package/src/prover/isabelle/encode.ts +82 -64
- package/src/prover/isabelle/isar/attrib.ts +250 -0
- package/src/prover/isabelle/isar/context.ts +335 -0
- package/src/prover/isabelle/isar/induct.ts +382 -0
- package/src/prover/isabelle/isar/inner-syntax.ts +262 -117
- package/src/prover/isabelle/isar/method.ts +510 -226
- package/src/prover/isabelle/isar/proof.ts +570 -23
- package/src/prover/isabelle/isar/rule-cases.ts +224 -0
- package/src/prover/isabelle/isar/theory.ts +488 -88
- package/src/prover/isabelle/isar/toplevel.ts +331 -0
- package/src/prover/isabelle/isar/type-check.ts +99 -38
- package/src/prover/isabelle/provers/blast/blast.ts +16 -105
- package/src/prover/isabelle/provers/blast/branch.ts +0 -33
- package/src/prover/isabelle/provers/blast/prove.ts +0 -36
- package/src/prover/isabelle/provers/blast/rules.ts +5 -45
- package/src/prover/isabelle/provers/blast/state.ts +1 -29
- package/src/prover/isabelle/provers/blast/term.ts +8 -37
- package/src/prover/isabelle/provers/clasimp.ts +0 -14
- package/src/prover/isabelle/provers/classical.ts +58 -61
- package/src/prover/isabelle/provers/hypsubst.ts +27 -52
- package/src/prover/isabelle/pure/bicompose.ts +24 -39
- package/src/prover/isabelle/pure/consts.ts +0 -8
- package/src/prover/isabelle/pure/conv.ts +2 -18
- package/src/prover/isabelle/pure/drule.ts +95 -45
- package/src/prover/isabelle/pure/envir.ts +2 -53
- package/src/prover/isabelle/pure/goal.ts +1 -9
- 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 -16
- package/src/prover/isabelle/pure/name.ts +1 -10
- package/src/prover/isabelle/pure/net.ts +2 -60
- package/src/prover/isabelle/pure/object-logic.ts +15 -16
- package/src/prover/isabelle/pure/pattern.ts +1 -20
- package/src/prover/isabelle/pure/raw-simplifier.ts +16 -63
- package/src/prover/isabelle/pure/rewriter.ts +31 -74
- package/src/prover/isabelle/pure/search.ts +2 -11
- package/src/prover/isabelle/pure/seq.ts +0 -11
- package/src/prover/isabelle/pure/simplifier.ts +27 -16
- package/src/prover/isabelle/pure/table.ts +2 -33
- package/src/prover/isabelle/pure/tactic.ts +11 -23
- package/src/prover/isabelle/pure/tactical.ts +47 -48
- package/src/prover/isabelle/pure/term-ord.ts +1 -7
- package/src/prover/isabelle/pure/term.ts +1 -44
- package/src/prover/isabelle/pure/thm.ts +26 -48
- package/src/prover/isabelle/pure/type.ts +1 -16
- package/src/prover/isabelle/pure/unify.ts +19 -31
- package/src/prover/isabelle/pure/variable.ts +2 -8
- package/src/prover/isabelle/tla/classical-setup.ts +17 -25
- package/src/prover/isabelle/tla/context.ts +65 -26
- package/src/prover/isabelle/tla/logic-data.ts +1 -1
- package/src/prover/isabelle/tla/logic.ts +53 -32
- package/src/prover/isabelle/tla/simpdata.ts +45 -44
- package/src/prover/isabelle/tools/intuitionistic.ts +28 -21
- package/src/prover/ocaml.ts +4 -7
- package/src/prover/prep/action.ts +33 -66
- package/src/prover/prep/enabled-axioms.ts +22 -20
- package/src/prover/prep/fingerprint.ts +2 -21
- package/src/prover/prep/level-comparison.ts +8 -12
- package/src/prover/prep/md5.ts +0 -2
- package/src/prover/prep/methods.ts +189 -86
- package/src/prover/prep/normalize.ts +42 -37
- package/src/prover/prove-worker.ts +0 -2
- package/src/prover/prove.ts +398 -133
- package/src/prover/ptl/decide.ts +96 -56
- package/src/prover/ptl/encode.ts +15 -38
- package/src/prover/ptl/sat.ts +24 -32
- package/src/prover/ptl/tableau.ts +40 -28
- package/src/prover/smt/arithmetic.ts +310 -0
- package/src/prover/smt/axioms.ts +12 -15
- package/src/prover/smt/context.ts +60 -32
- package/src/prover/smt/data.ts +517 -401
- package/src/prover/smt/encode.ts +155 -85
- package/src/prover/smt/extensionality.ts +5 -13
- package/src/prover/smt/flatten.ts +7 -28
- package/src/prover/smt/format.ts +33 -14
- package/src/prover/smt/instances.ts +7 -11
- package/src/prover/smt/layout.ts +91 -0
- package/src/prover/smt/rewrite.ts +1026 -658
- package/src/prover/smt/simplify.ts +441 -0
- package/src/prover/smt/solver/ackermannize-bv-tactic.ts +61 -0
- package/src/prover/smt/solver/ackr-helper.ts +179 -0
- package/src/prover/smt/solver/ackr-model-converter.ts +105 -0
- package/src/prover/smt/solver/act-cache.ts +0 -16
- package/src/prover/smt/solver/add-bounds-tactic.ts +59 -0
- package/src/prover/smt/solver/aig-tactic.ts +52 -0
- package/src/prover/smt/solver/aig.ts +889 -0
- package/src/prover/smt/solver/arith-rewriter.ts +615 -53
- package/src/prover/smt/solver/arith-terms.ts +121 -0
- package/src/prover/smt/solver/array-decl-plugin.ts +175 -0
- package/src/prover/smt/solver/array-rewriter.ts +309 -0
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +87 -58
- package/src/prover/smt/solver/ast-lt.ts +166 -22
- package/src/prover/smt/solver/ast-util.ts +160 -7
- package/src/prover/smt/solver/ast.ts +1424 -180
- package/src/prover/smt/solver/auf-solver.ts +7 -44
- package/src/prover/smt/solver/bit-blast-tactic.ts +582 -0
- package/src/prover/smt/solver/bit-blaster.ts +871 -0
- package/src/prover/smt/solver/bound-manager.ts +196 -0
- package/src/prover/smt/solver/bound-simplifier.ts +600 -0
- package/src/prover/smt/solver/bv-bound-chk.ts +492 -0
- package/src/prover/smt/solver/bv-decl-plugin.ts +338 -0
- package/src/prover/smt/solver/bv-divrem-bounds.ts +95 -0
- package/src/prover/smt/solver/bv-rewriter.ts +1901 -0
- package/src/prover/smt/solver/bv1-blast.ts +214 -0
- package/src/prover/smt/solver/bv2fpa-converter.ts +174 -0
- package/src/prover/smt/solver/bv2int-rewriter.ts +544 -0
- package/src/prover/smt/solver/bv2real-rewriter.ts +533 -0
- package/src/prover/smt/solver/card2bv.ts +110 -0
- package/src/prover/smt/solver/case-split-queue.ts +0 -10
- package/src/prover/smt/solver/cg-table.ts +39 -42
- package/src/prover/smt/solver/check-logic.ts +330 -0
- package/src/prover/smt/solver/clause.ts +0 -27
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +278 -0
- package/src/prover/smt/solver/conflict-resolution.ts +78 -11
- package/src/prover/smt/solver/context.ts +519 -175
- package/src/prover/smt/solver/ctx-simplify.ts +33 -50
- package/src/prover/smt/solver/ctx-solver-simplify.ts +122 -0
- package/src/prover/smt/solver/datatype-decl-plugin.ts +572 -0
- package/src/prover/smt/solver/datatype-rewriter.ts +82 -0
- package/src/prover/smt/solver/demodulator.ts +786 -0
- package/src/prover/smt/solver/dependent-expr-state.ts +81 -0
- package/src/prover/smt/solver/der.ts +39 -30
- package/src/prover/smt/solver/diff-neq.ts +206 -0
- package/src/prover/smt/solver/distribute-forall.ts +57 -0
- package/src/prover/smt/solver/dom-simplify.ts +511 -0
- package/src/prover/smt/solver/dt2bv-tactic.ts +260 -0
- package/src/prover/smt/solver/dyn-ack.ts +0 -11
- package/src/prover/smt/solver/e-matching.ts +9 -41
- package/src/prover/smt/solver/elim-small-bv-tactic.ts +129 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +545 -0
- package/src/prover/smt/solver/enode.ts +100 -23
- package/src/prover/smt/solver/eq2bv-tactic.ts +218 -0
- package/src/prover/smt/solver/euf/arith-axioms.ts +403 -0
- package/src/prover/smt/solver/euf/arith-internalize.ts +653 -0
- package/src/prover/smt/solver/euf/arith-solver.ts +889 -0
- package/src/prover/smt/solver/euf/array-axioms.ts +527 -0
- package/src/prover/smt/solver/euf/array-internalize.ts +428 -0
- package/src/prover/smt/solver/euf/array-solver.ts +306 -0
- package/src/prover/smt/solver/euf/bv-ackerman.ts +162 -0
- package/src/prover/smt/solver/euf/bv-internalize.ts +748 -0
- package/src/prover/smt/solver/euf/bv-solver.ts +449 -0
- package/src/prover/smt/solver/euf/dt-solver.ts +618 -0
- package/src/prover/smt/solver/euf/egraph.ts +907 -0
- package/src/prover/smt/solver/euf/euf-solver.ts +1205 -0
- package/src/prover/smt/solver/euf/fpa-solver.ts +317 -0
- package/src/prover/smt/solver/euf/mam.ts +1050 -0
- package/src/prover/smt/solver/euf/q-ematch.ts +830 -0
- package/src/prover/smt/solver/euf/q-mbi.ts +587 -0
- package/src/prover/smt/solver/euf/q-model-fixer.ts +296 -0
- package/src/prover/smt/solver/euf/q-solver.ts +361 -0
- package/src/prover/smt/solver/euf/th-solver.ts +335 -0
- package/src/prover/smt/solver/euf/th-solvers.ts +30 -0
- package/src/prover/smt/solver/expr-ref.ts +0 -5
- package/src/prover/smt/solver/expr-safe-replace.ts +26 -7
- package/src/prover/smt/solver/expr2polynomial.ts +146 -0
- package/src/prover/smt/solver/factor.ts +141 -0
- package/src/prover/smt/solver/fd-solver.ts +265 -0
- package/src/prover/smt/solver/fingerprints.ts +15 -26
- package/src/prover/smt/solver/fix-dl-var.ts +148 -0
- package/src/prover/smt/solver/flat-literals.ts +0 -9
- package/src/prover/smt/solver/fm-tactic.ts +884 -0
- package/src/prover/smt/solver/fpa-decl-plugin.ts +618 -0
- package/src/prover/smt/solver/fpa-rewriter.ts +640 -0
- package/src/prover/smt/solver/fpa2bv-converter.ts +2249 -0
- package/src/prover/smt/solver/fpa2bv-rewriter.ts +348 -0
- package/src/prover/smt/solver/fpa2bv-tactic.ts +73 -0
- package/src/prover/smt/solver/goal.ts +176 -28
- package/src/prover/smt/solver/goal2nlsat.ts +189 -0
- package/src/prover/smt/solver/guard-set.ts +219 -0
- package/src/prover/smt/solver/hash.ts +0 -9
- package/src/prover/smt/solver/hashtable.ts +26 -23
- package/src/prover/smt/solver/inf-eps.ts +63 -0
- package/src/prover/smt/solver/inj-axiom.ts +101 -0
- package/src/prover/smt/solver/internalizer.ts +112 -132
- package/src/prover/smt/solver/lackr.ts +381 -0
- package/src/prover/smt/solver/lbool.ts +0 -2
- package/src/prover/smt/solver/lia2card.ts +268 -0
- package/src/prover/smt/solver/lia2pb.ts +154 -0
- package/src/prover/smt/solver/literal.ts +0 -4
- package/src/prover/smt/solver/logic-tactics.ts +345 -0
- package/src/prover/smt/solver/lp/bound-propagator.ts +7 -26
- package/src/prover/smt/solver/lp/constraints.ts +1 -8
- package/src/prover/smt/solver/lp/containers.ts +11 -30
- package/src/prover/smt/solver/lp/core-solver.ts +23 -29
- package/src/prover/smt/solver/lp/cross-nested.ts +5 -20
- package/src/prover/smt/solver/lp/dep-intervals.ts +6 -24
- package/src/prover/smt/solver/lp/dependency.ts +0 -5
- package/src/prover/smt/solver/lp/dioph-eq.ts +8 -103
- package/src/prover/smt/solver/lp/explanation.ts +0 -6
- package/src/prover/smt/solver/lp/gomory.ts +8 -22
- package/src/prover/smt/solver/lp/hnf-cutter.ts +16 -23
- package/src/prover/smt/solver/lp/hnf.ts +10 -28
- package/src/prover/smt/solver/lp/int-cube.ts +17 -39
- package/src/prover/smt/solver/lp/int-solver.ts +3 -35
- package/src/prover/smt/solver/lp/lar-solver.ts +69 -82
- package/src/prover/smt/solver/lp/lar-term.ts +0 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +0 -14
- package/src/prover/smt/solver/lp/maximize-term.ts +76 -52
- package/src/prover/smt/solver/lp/nex-creator.ts +4 -28
- package/src/prover/smt/solver/lp/nex.ts +0 -6
- package/src/prover/smt/solver/lp/nla-backoff.ts +0 -5
- package/src/prover/smt/solver/lp/nla-basics.ts +48 -30
- package/src/prover/smt/solver/lp/nla-core.ts +91 -135
- package/src/prover/smt/solver/lp/nla-divisions.ts +31 -43
- package/src/prover/smt/solver/lp/nla-emonics.ts +3 -21
- package/src/prover/smt/solver/lp/nla-factorization.ts +0 -4
- package/src/prover/smt/solver/lp/nla-grobner.ts +22 -72
- package/src/prover/smt/solver/lp/nla-horner.ts +2 -12
- package/src/prover/smt/solver/lp/nla-intervals.ts +1 -12
- package/src/prover/smt/solver/lp/nla-monomial-bounds.ts +15 -42
- package/src/prover/smt/solver/lp/nla-monotone.ts +1 -6
- package/src/prover/smt/solver/lp/nla-order.ts +0 -13
- package/src/prover/smt/solver/lp/nla-patcher.ts +3 -7
- package/src/prover/smt/solver/lp/nla-powers.ts +220 -0
- package/src/prover/smt/solver/lp/nla-tangents.ts +0 -10
- package/src/prover/smt/solver/lp/nla-throttle.ts +0 -6
- package/src/prover/smt/solver/lp/nla-transcendentals.ts +324 -0
- package/src/prover/smt/solver/lp/nla-types.ts +0 -12
- package/src/prover/smt/solver/lp/nla-var-eqs.ts +4 -26
- package/src/prover/smt/solver/lp/nra-solver.ts +123 -112
- package/src/prover/smt/solver/lp/numeric-pair.ts +0 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +0 -3
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +1 -14
- package/src/prover/smt/solver/lp/pdd-solver.ts +2 -33
- package/src/prover/smt/solver/lp/pdd.ts +7 -70
- package/src/prover/smt/solver/lp/random-updater.ts +0 -9
- package/src/prover/smt/solver/lp/static-matrix.ts +8 -19
- package/src/prover/smt/solver/lp/union-find.ts +5 -5
- package/src/prover/smt/solver/macro-finder.ts +530 -0
- package/src/prover/smt/solver/mam-compiler.ts +129 -139
- package/src/prover/smt/solver/mam-interpreter.ts +0 -21
- package/src/prover/smt/solver/max-bv-sharing-tactic.ts +17 -0
- package/src/prover/smt/solver/max-cliques.ts +105 -0
- package/src/prover/smt/solver/maxcore.ts +309 -0
- package/src/prover/smt/solver/maximize-ac-sharing.ts +8 -21
- package/src/prover/smt/solver/maxlex.ts +115 -0
- package/src/prover/smt/solver/maxsmt-base.ts +105 -0
- package/src/prover/smt/solver/maxsmt.ts +92 -0
- package/src/prover/smt/solver/mbp/mbp-arith.ts +467 -0
- package/src/prover/smt/solver/mbp/mbp-basic-tg.ts +101 -0
- package/src/prover/smt/solver/mbp/mbp-plugin.ts +287 -0
- package/src/prover/smt/solver/mbp/mbp-qel.ts +48 -0
- package/src/prover/smt/solver/mbp/mbp-solve-plugin.ts +271 -0
- package/src/prover/smt/solver/mbp/mbp-term-graph.ts +606 -0
- package/src/prover/smt/solver/model-based-opt.ts +844 -0
- package/src/prover/smt/solver/model-checker.ts +19 -62
- package/src/prover/smt/solver/model-evaluator.ts +190 -40
- package/src/prover/smt/solver/model-finder.ts +14 -32
- package/src/prover/smt/solver/model-generator.ts +56 -40
- package/src/prover/smt/solver/model-macro-solver.ts +60 -114
- package/src/prover/smt/solver/model-printer.ts +214 -0
- package/src/prover/smt/solver/mpf.ts +711 -0
- package/src/prover/smt/solver/mus.ts +51 -0
- package/src/prover/smt/solver/muz/dl-context.ts +404 -0
- package/src/prover/smt/solver/muz/dl-mk-bit-blast.ts +97 -0
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +167 -0
- package/src/prover/smt/solver/muz/dl-mk-elim-term-ite.ts +125 -0
- package/src/prover/smt/solver/muz/dl-mk-interp-tail-simplifier.ts +299 -0
- package/src/prover/smt/solver/muz/dl-mk-rule-inliner.ts +455 -0
- package/src/prover/smt/solver/muz/dl-mk-slice.ts +340 -0
- package/src/prover/smt/solver/muz/dl-mk-subsumption-checker.ts +163 -0
- package/src/prover/smt/solver/muz/dl-rule-set.ts +273 -0
- package/src/prover/smt/solver/muz/dl-rule-transformer.ts +123 -0
- package/src/prover/smt/solver/muz/dl-rule.ts +496 -0
- package/src/prover/smt/solver/muz/hnf.ts +201 -0
- package/src/prover/smt/solver/muz/horn-subsume-model-converter.ts +176 -0
- package/src/prover/smt/solver/muz/horn-tactic.ts +201 -0
- package/src/prover/smt/solver/muz/rule-properties.ts +337 -0
- package/src/prover/smt/solver/muz/spacer-context.ts +1406 -0
- package/src/prover/smt/solver/muz/spacer-dl-interface.ts +52 -0
- package/src/prover/smt/solver/muz/spacer-generalizers.ts +241 -0
- package/src/prover/smt/solver/muz/spacer-manager.ts +127 -0
- package/src/prover/smt/solver/muz/spacer-pdr.ts +218 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +333 -0
- package/src/prover/smt/solver/muz/spacer-util.ts +282 -0
- package/src/prover/smt/solver/muz/substitution.ts +203 -0
- package/src/prover/smt/solver/nla2bv-tactic.ts +285 -0
- package/src/prover/smt/solver/nlqsat.ts +484 -0
- package/src/prover/smt/solver/nlsat/algebraic.ts +177 -160
- package/src/prover/smt/solver/nlsat/atoms.ts +24 -24
- package/src/prover/smt/solver/nlsat/evaluator.ts +16 -22
- package/src/prover/smt/solver/nlsat/explain.ts +65 -69
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -51
- package/src/prover/smt/solver/nlsat/levelwise.ts +48 -135
- package/src/prover/smt/solver/nlsat/mpbq.ts +47 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +29 -161
- package/src/prover/smt/solver/nlsat/solver.ts +241 -110
- package/src/prover/smt/solver/nlsat/transcendental-eval.ts +310 -0
- package/src/prover/smt/solver/nlsat/transcendentals.ts +367 -0
- package/src/prover/smt/solver/nlsat/types.ts +0 -9
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +1 -47
- package/src/prover/smt/solver/nlsat/upolynomial.ts +10 -93
- package/src/prover/smt/solver/nlsat-tactic.ts +82 -0
- package/src/prover/smt/solver/nnf.ts +107 -60
- package/src/prover/smt/solver/normalize-bounds.ts +53 -0
- package/src/prover/smt/solver/occf.ts +97 -0
- package/src/prover/smt/solver/opt-context.ts +787 -0
- package/src/prover/smt/solver/opt-nlsat.ts +375 -0
- package/src/prover/smt/solver/opt-pareto.ts +282 -0
- package/src/prover/smt/solver/opt-preprocess.ts +101 -0
- package/src/prover/smt/solver/opt-solver.ts +308 -0
- package/src/prover/smt/solver/opt-value.ts +55 -0
- package/src/prover/smt/solver/optsmt.ts +692 -0
- package/src/prover/smt/solver/parallel-tactic.ts +299 -0
- package/src/prover/smt/solver/pattern-inference.ts +21 -26
- package/src/prover/smt/solver/pb-rewriter.ts +284 -0
- package/src/prover/smt/solver/pb2bv-tactic.ts +540 -0
- package/src/prover/smt/solver/poly-rewriter.ts +204 -79
- package/src/prover/smt/solver/probes.ts +512 -0
- package/src/prover/smt/solver/propagate-values.ts +37 -30
- package/src/prover/smt/solver/proto-model.ts +650 -66
- package/src/prover/smt/solver/pull-quant.ts +28 -23
- package/src/prover/smt/solver/purify-arith.ts +632 -0
- package/src/prover/smt/solver/qe-arith-plugin.ts +1098 -0
- package/src/prover/smt/solver/qe-lite-der.ts +2 -31
- package/src/prover/smt/solver/qe-lite-fm.ts +4 -28
- package/src/prover/smt/solver/qe-lite.ts +39 -49
- package/src/prover/smt/solver/qe-mbp.ts +270 -0
- package/src/prover/smt/solver/qe.ts +1498 -0
- package/src/prover/smt/solver/qel.ts +25 -0
- package/src/prover/smt/solver/qi-queue.ts +0 -16
- package/src/prover/smt/solver/qsat.ts +814 -0
- package/src/prover/smt/solver/quant-hoist.ts +196 -0
- package/src/prover/smt/solver/quant-tactics.ts +17 -74
- package/src/prover/smt/solver/quantifier-analyzer.ts +26 -47
- package/src/prover/smt/solver/quantifier-manager.ts +8 -23
- package/src/prover/smt/solver/quasi-macros.ts +243 -0
- package/src/prover/smt/solver/random-gen.ts +0 -2
- package/src/prover/smt/solver/rational.ts +45 -8
- package/src/prover/smt/solver/recfun-decl-plugin.ts +261 -0
- package/src/prover/smt/solver/recfun-rewriter.ts +107 -0
- package/src/prover/smt/solver/reduce-args.ts +225 -0
- package/src/prover/smt/solver/reduce-bv-size.ts +119 -0
- package/src/prover/smt/solver/ref-vector.ts +0 -6
- package/src/prover/smt/solver/relevancy.ts +2 -16
- package/src/prover/smt/solver/rewriter-tpl.ts +52 -129
- package/src/prover/smt/solver/rewriter.ts +477 -120
- package/src/prover/smt/solver/rlimit.ts +39 -21
- package/src/prover/smt/solver/sat/asymm-branch.ts +325 -0
- package/src/prover/smt/solver/sat/big.ts +177 -0
- package/src/prover/smt/solver/sat/clause-use-list.ts +71 -0
- package/src/prover/smt/solver/sat/clause.ts +203 -0
- package/src/prover/smt/solver/sat/cleaner.ts +94 -0
- package/src/prover/smt/solver/sat/config.ts +122 -0
- package/src/prover/smt/solver/sat/consequences.ts +203 -0
- package/src/prover/smt/solver/sat/elim-eqs.ts +142 -0
- package/src/prover/smt/solver/sat/goal2sat.ts +526 -0
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +378 -0
- package/src/prover/smt/solver/sat/model-converter.ts +136 -0
- package/src/prover/smt/solver/sat/pb-constraint.ts +261 -0
- package/src/prover/smt/solver/sat/pb-solver.ts +1577 -0
- package/src/prover/smt/solver/sat/probing.ts +170 -0
- package/src/prover/smt/solver/sat/sat-tactic.ts +43 -0
- package/src/prover/smt/solver/sat/sat2goal.ts +165 -0
- package/src/prover/smt/solver/sat/scc.ts +142 -0
- package/src/prover/smt/solver/sat/simplifier.ts +1618 -0
- package/src/prover/smt/solver/sat/solver.ts +2127 -0
- package/src/prover/smt/solver/sat/var-queue.ts +117 -0
- package/src/prover/smt/solver/sat/watch-list.ts +140 -0
- package/src/prover/smt/solver/search-tree.ts +284 -0
- package/src/prover/smt/solver/seq-axioms.ts +1010 -0
- package/src/prover/smt/solver/seq-decl-plugin.ts +819 -0
- package/src/prover/smt/solver/seq-derive.ts +1301 -0
- package/src/prover/smt/solver/seq-eq-approx.ts +236 -0
- package/src/prover/smt/solver/seq-eq-solver.ts +439 -0
- package/src/prover/smt/solver/seq-factory.ts +89 -0
- package/src/prover/smt/solver/seq-monadic.ts +728 -0
- package/src/prover/smt/solver/seq-range-predicate.ts +235 -0
- package/src/prover/smt/solver/seq-re-rewriter.ts +1170 -0
- package/src/prover/smt/solver/seq-re-util.ts +758 -0
- package/src/prover/smt/solver/seq-regex-bisim.ts +144 -0
- package/src/prover/smt/solver/seq-regex-live.ts +200 -0
- package/src/prover/smt/solver/seq-rewriter.ts +2402 -0
- package/src/prover/smt/solver/seq-skolem.ts +317 -0
- package/src/prover/smt/solver/seq-subset.ts +165 -0
- package/src/prover/smt/solver/seq-view-witness.ts +353 -0
- package/src/prover/smt/solver/smt-consequences.ts +297 -0
- package/src/prover/smt/solver/smt-kernel.ts +83 -0
- package/src/prover/smt/solver/smt-logics.ts +66 -0
- package/src/prover/smt/solver/smt-setup.ts +496 -0
- package/src/prover/smt/solver/smt2-printer.ts +765 -0
- package/src/prover/smt/solver/smtlib-parser.ts +3140 -365
- package/src/prover/smt/solver/smtlib-script.ts +1631 -0
- package/src/prover/smt/solver/solve-eqs.ts +929 -0
- package/src/prover/smt/solver/solver.ts +119 -39
- package/src/prover/smt/solver/sort.ts +1 -5
- package/src/prover/smt/solver/static-features.ts +314 -0
- package/src/prover/smt/solver/sticky-generations.ts +0 -6
- package/src/prover/smt/solver/tactic.ts +1986 -0
- package/src/prover/smt/solver/term-enumeration.ts +205 -0
- package/src/prover/smt/solver/theory-array.ts +1240 -0
- package/src/prover/smt/solver/theory-bv.ts +1200 -0
- package/src/prover/smt/solver/theory-char.ts +355 -0
- package/src/prover/smt/solver/theory-datatype.ts +598 -0
- package/src/prover/smt/solver/theory-finite-set.ts +30 -0
- package/src/prover/smt/solver/theory-fpa.ts +389 -0
- package/src/prover/smt/solver/theory-lra-axioms.ts +55 -25
- package/src/prover/smt/solver/theory-lra-bounds.ts +31 -11
- package/src/prover/smt/solver/theory-lra-final-check.ts +59 -91
- package/src/prover/smt/solver/theory-lra-internalize.ts +94 -53
- package/src/prover/smt/solver/theory-lra-model.ts +23 -53
- package/src/prover/smt/solver/theory-lra-propagate.ts +24 -40
- package/src/prover/smt/solver/theory-lra-state.ts +6 -27
- package/src/prover/smt/solver/theory-lra.ts +188 -8
- package/src/prover/smt/solver/theory-pb.ts +934 -0
- package/src/prover/smt/solver/theory-polymorphism.ts +58 -0
- package/src/prover/smt/solver/theory-recfun.ts +307 -0
- package/src/prover/smt/solver/theory-seq-regex.ts +867 -0
- package/src/prover/smt/solver/theory-seq-solve.ts +1373 -0
- package/src/prover/smt/solver/theory-seq-state.ts +871 -0
- package/src/prover/smt/solver/theory-seq.ts +961 -0
- package/src/prover/smt/solver/theory.ts +189 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +485 -0
- package/src/prover/smt/solver/var-subst.ts +37 -39
- package/src/prover/smt/table.ts +3 -10
- package/src/prover/smt/types.ts +146 -0
- package/src/prover/tlapm/cache.ts +67 -41
- package/src/prover/tlapm/ocaml-marshal.ts +19 -21
- package/src/prover/tlapm/tlapm.ts +21 -20
- package/src/prover/tlapm-library.ts +3208 -0
- package/src/prover/verdict.ts +9 -2
- package/src/prover/zenon/check/check.ts +1 -11
- 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 +1 -6
- package/src/prover/zenon/check/relations.ts +2 -14
- package/src/prover/zenon/check/rewrites.ts +2 -21
- package/src/prover/zenon/check/sets.ts +40 -61
- package/src/prover/zenon/check/terms.ts +1 -19
- package/src/prover/zenon/check/tla.ts +0 -6
- package/src/prover/zenon/decide.ts +10 -19
- package/src/prover/zenon/encode.ts +0 -9
- package/src/prover/zenon/eqrel.ts +2 -15
- package/src/prover/zenon/equality-rules.ts +0 -6
- package/src/prover/zenon/expr.ts +8 -28
- package/src/prover/zenon/index-table.ts +26 -59
- package/src/prover/zenon/isar-case.ts +8 -20
- package/src/prover/zenon/isar.ts +35 -65
- package/src/prover/zenon/limits.ts +0 -4
- package/src/prover/zenon/llproof.ts +2 -22
- package/src/prover/zenon/mltoll.ts +66 -106
- package/src/prover/zenon/node.ts +20 -15
- package/src/prover/zenon/ocaml.ts +1 -17
- package/src/prover/zenon/parse.ts +9 -13
- package/src/prover/zenon/phrase.ts +1 -13
- package/src/prover/zenon/proof.ts +0 -11
- package/src/prover/zenon/propositional-rules.ts +0 -7
- package/src/prover/zenon/rules.ts +2 -8
- package/src/prover/zenon/search.ts +11 -35
- package/src/prover/zenon/tla/functions.ts +59 -33
- package/src/prover/zenon/tla/llproof.ts +67 -78
- package/src/prover/zenon/tla/records.ts +57 -35
- package/src/prover/zenon/tla/rewrites.ts +12 -21
- package/src/prover/zenon/tla/sets.ts +88 -59
- package/src/prover/zenon/tla/terms.ts +0 -8
- package/src/prover/zenon/tla/tla.ts +66 -66
- package/src/randomization.ts +81 -35
- package/src/resolve.ts +67 -185
- package/src/runtime.ts +26 -22
- package/src/sany/builtins.ts +2 -5
- package/src/sany/generation.ts +394 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +686 -0
- package/src/sany/generator-expressions.ts +1100 -0
- package/src/sany/generator-proofs.ts +662 -0
- package/src/sany/generator.ts +191 -2764
- package/src/sany/levels.ts +5 -35
- package/src/sany/lexer.ts +58 -77
- package/src/sany/linter.ts +0 -10
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +5 -43
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +32 -69
- package/src/sany/selectors.ts +49 -76
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +35 -117
- package/src/search.ts +671 -169
- package/src/simulate.ts +712 -0
- package/src/spec-description.ts +192 -100
- package/src/standard-definitions.ts +4 -4
- package/src/standard-modules.ts +264 -95
- package/src/state-graph.ts +52 -33
- package/src/subexpressions.ts +69 -52
- package/src/substitution-levels.ts +7 -7
- package/src/successors.ts +267 -100
- package/src/symmetry.ts +35 -27
- package/src/tableau.ts +29 -26
- package/src/tlc/fingerprint.ts +267 -79
- package/src/tlc/jar-data.ts +112 -6
- package/src/tlc/messages.ts +125 -54
- package/src/tlc/order.ts +39 -69
- package/src/tlc/random.ts +37 -49
- package/src/tlc/replay.ts +553 -228
- package/src/tlc/summary.ts +64 -60
- package/src/tlc/tlc-operators.ts +78 -44
- package/src/tlc/tlcext-operators.ts +171 -122
- package/src/tlc/trace-spec.ts +249 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -4
- package/src/transfer.ts +22 -25
- package/src/typed-tier.ts +6535 -0
- package/src/typescript/actions.ts +479 -0
- package/src/typescript/collections.ts +614 -0
- package/src/typescript/compile.ts +63 -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 +154 -0
- package/src/typescript/functions.ts +284 -0
- package/src/typescript/model.ts +162 -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 +167 -0
- package/src/typescript/types.ts +171 -0
- package/src/values.ts +832 -484
- package/src/worker.ts +7 -8
- package/src/prover/isabelle/isar/statement.ts +0 -57
- package/src/prover/smt/solver/z3-license.txt +0 -10
- package/src/prover/tlaps-module.ts +0 -510
- package/src/prover/zenon/LICENSE +0 -32
package/src/check.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { Expression } from "./ast";
|
|
2
2
|
import { parseConfig, type ModelConfig } from "./config";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
addCoverageRelation,
|
|
5
|
+
buildCoverage,
|
|
6
|
+
countCoverageVariables,
|
|
7
|
+
createCoverage,
|
|
8
|
+
getCoverageLabel,
|
|
9
|
+
getCoverageReport,
|
|
10
|
+
type CoverageReport,
|
|
11
|
+
} from "./coverage";
|
|
4
12
|
import {
|
|
5
13
|
createStackOverflowError,
|
|
6
|
-
getErrorExitCode,
|
|
7
14
|
isStackOverflow,
|
|
8
|
-
TlaConfigError,
|
|
9
15
|
TlaEvaluationError,
|
|
10
16
|
TlaIllegalStateError,
|
|
11
17
|
TlaIncompleteSuccessorError,
|
|
@@ -13,18 +19,35 @@ import {
|
|
|
13
19
|
TlaStackOverflowError,
|
|
14
20
|
UNEXPECTED_EVAL_EXCEPTION,
|
|
15
21
|
UNEXPECTED_EXCEPTION,
|
|
22
|
+
formatRange,
|
|
16
23
|
} from "./errors";
|
|
17
24
|
import {
|
|
18
|
-
|
|
19
|
-
evaluate,
|
|
20
|
-
formatRange,
|
|
25
|
+
describeRange,
|
|
21
26
|
getDefinition,
|
|
22
|
-
isImpure,
|
|
23
27
|
type CallStack,
|
|
24
28
|
type Environment,
|
|
25
29
|
type FingerprintFailure,
|
|
26
30
|
} from "./evaluate";
|
|
27
|
-
import { EXIT_STATUS,
|
|
31
|
+
import { EXIT_STATUS, setExitCode, withLivenessExitCode } from "./exit-codes";
|
|
32
|
+
import {
|
|
33
|
+
fingerprintReplayed,
|
|
34
|
+
getFailureExitCode,
|
|
35
|
+
getReplayFailure,
|
|
36
|
+
type FailureOptions,
|
|
37
|
+
} from "./check-failure";
|
|
38
|
+
import {
|
|
39
|
+
createTraceBuilder,
|
|
40
|
+
type Behavior,
|
|
41
|
+
type SearchPosition,
|
|
42
|
+
type TracedStep,
|
|
43
|
+
} from "./check-trace";
|
|
44
|
+
import {
|
|
45
|
+
createStateTable,
|
|
46
|
+
findStateIndex,
|
|
47
|
+
getStateHash,
|
|
48
|
+
isSameState,
|
|
49
|
+
markSeenState,
|
|
50
|
+
} from "./fingerprints";
|
|
28
51
|
import type { JavaOverride } from "./java-overrides";
|
|
29
52
|
import {
|
|
30
53
|
createLivenessChecker,
|
|
@@ -33,11 +56,11 @@ import {
|
|
|
33
56
|
type LiveSuccessor,
|
|
34
57
|
} from "./liveness-checker";
|
|
35
58
|
import {
|
|
36
|
-
|
|
59
|
+
createCheckEnvironment,
|
|
60
|
+
createMissingOperatorError,
|
|
37
61
|
createSearch,
|
|
62
|
+
getIncompleteSuccessorMessage,
|
|
38
63
|
findAssumptionViolation,
|
|
39
|
-
getConfigDefinition,
|
|
40
|
-
getContext,
|
|
41
64
|
reportInitialStatesProgress,
|
|
42
65
|
reportStartup,
|
|
43
66
|
withNextStateExitCode,
|
|
@@ -45,11 +68,11 @@ import {
|
|
|
45
68
|
import {
|
|
46
69
|
getActionLabel,
|
|
47
70
|
getActionSignature,
|
|
48
|
-
|
|
49
|
-
getNextActions,
|
|
71
|
+
getSpecDescription,
|
|
50
72
|
getSpecificationValue,
|
|
51
73
|
toActionValue,
|
|
52
74
|
type SpecAction,
|
|
75
|
+
type SpecDescription,
|
|
53
76
|
} from "./spec-description";
|
|
54
77
|
import {
|
|
55
78
|
createStateWriter,
|
|
@@ -62,11 +85,10 @@ import {
|
|
|
62
85
|
forEachSuccessor,
|
|
63
86
|
getInitialStates,
|
|
64
87
|
getSuccessors,
|
|
88
|
+
hasIncompleteSuccessor,
|
|
65
89
|
type Successor,
|
|
66
90
|
} from "./successors";
|
|
67
91
|
import {
|
|
68
|
-
formatNestedMessage,
|
|
69
|
-
getCodedMessage,
|
|
70
92
|
getFailureMessage,
|
|
71
93
|
getWrappedException,
|
|
72
94
|
isEvalException,
|
|
@@ -75,25 +97,27 @@ import {
|
|
|
75
97
|
withUnexpectedException,
|
|
76
98
|
type FailureMessage,
|
|
77
99
|
} from "./tlc/messages";
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
100
|
+
import { createTautologyError } from "./liveness";
|
|
101
|
+
import { KEY_SEPARATOR } from "./resolve";
|
|
102
|
+
import { writeTraceSpec } from "./tlc/trace-spec";
|
|
103
|
+
import {
|
|
104
|
+
getPrimedRanges,
|
|
105
|
+
replayInitialStates,
|
|
106
|
+
replaySuccessors,
|
|
107
|
+
walkSuccessors,
|
|
108
|
+
} from "./tlc/replay";
|
|
80
109
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
81
110
|
import { createActionRecord, createCounterExample } from "./tlc/tlcext-operators";
|
|
82
111
|
import type { TlcVersion } from "./tlc/version";
|
|
112
|
+
import { runTypedSearch, type TypedResult } from "./typed-tier";
|
|
83
113
|
import {
|
|
84
|
-
combineHash,
|
|
85
114
|
createCanonicalizer,
|
|
86
115
|
createModelValue,
|
|
87
116
|
formatState,
|
|
88
117
|
getFingerprintError,
|
|
89
|
-
|
|
90
|
-
getValueHash,
|
|
91
|
-
isFunctionValue,
|
|
118
|
+
getModelValues,
|
|
92
119
|
isSameValue,
|
|
93
120
|
markFingerprinted,
|
|
94
|
-
setStringOrder,
|
|
95
|
-
setValueVersion,
|
|
96
|
-
toFiniteFunction,
|
|
97
121
|
type Value,
|
|
98
122
|
} from "./values";
|
|
99
123
|
|
|
@@ -105,37 +129,58 @@ export interface CheckOptions {
|
|
|
105
129
|
onPrint?: (text: string) => void;
|
|
106
130
|
onPause?: () => void;
|
|
107
131
|
readFile?: (path: string) => string | undefined;
|
|
108
|
-
writeFile?: (path: string, content: string) => void;
|
|
132
|
+
writeFile?: (path: string, content: string | Uint8Array) => void;
|
|
133
|
+
makeDirectory?: (path: string) => void;
|
|
109
134
|
seed?: bigint;
|
|
110
135
|
workers?: number;
|
|
111
|
-
|
|
112
|
-
livenessCheck?: "default" | "final";
|
|
113
|
-
|
|
136
|
+
/** TLC's -lncheck: "final" checks liveness only on the complete graph, "off" never looks for a cycle. */
|
|
137
|
+
livenessCheck?: "default" | "final" | "off";
|
|
138
|
+
/** TLC's -fp: the index of the polynomial in TLC's FP64.Polys that fingerprints states. */
|
|
139
|
+
fingerprintPolynomial?: number;
|
|
140
|
+
/** False for TLC's -terse, which prints a lazy value, such as SUBSET S, without enumerating it. */
|
|
141
|
+
isLazyValueExpanded?: boolean;
|
|
142
|
+
/** TLC's -view: prints each state as the value of the configuration's VIEW. */
|
|
143
|
+
isViewPrinted?: boolean;
|
|
144
|
+
/** TLC's -maxSetSize: the most elements TLC enumerates into a set, or states into a list of them. */
|
|
145
|
+
maxSetSize?: number;
|
|
146
|
+
/** TLC's -dump: writes the reachable states, or with `dot` the state graph, through writeFile. */
|
|
114
147
|
dump?: StateDump;
|
|
115
|
-
|
|
148
|
+
/** TLC's -tool, which changes the messages of TLC's errors. */
|
|
116
149
|
isTool?: boolean;
|
|
117
|
-
|
|
118
|
-
// onProgress and goes on.
|
|
150
|
+
/** TLC's -continue: reports each violation through onProgress and goes on. */
|
|
119
151
|
isContinued?: boolean;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
152
|
+
/** Skips fingerprintDistance, which takes fingerprinting every state again after the search. */
|
|
153
|
+
isFingerprintDistanceSkipped?: boolean;
|
|
154
|
+
moduleOperators?: ModuleOperator[];
|
|
155
|
+
/** TLC's trace exploration spec, and the binary trace TLC records for it unless -noTEBin. */
|
|
156
|
+
traceSpec?: TraceSpecOptions;
|
|
157
|
+
/** Whether the caller printed SANY's report, its warnings included, before the check. */
|
|
123
158
|
isSanyReported?: boolean;
|
|
124
|
-
|
|
159
|
+
/** False for TLC's -nowarning, which changes how TLC computes some successors. */
|
|
125
160
|
isWarningEnabled?: boolean;
|
|
126
|
-
|
|
161
|
+
/** TLC's -coverage, in minutes. */
|
|
162
|
+
coverage?: number;
|
|
127
163
|
version?: TlcVersion;
|
|
128
|
-
// Reports the points of the search at which TLC prints a message.
|
|
129
164
|
onProgress?: (progress: CheckProgress) => void;
|
|
130
165
|
}
|
|
131
166
|
|
|
167
|
+
export interface TraceSpecOptions {
|
|
168
|
+
module: string;
|
|
169
|
+
traceFile?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface ModuleOperator {
|
|
173
|
+
kind: "postcondition" | "constraint" | "view";
|
|
174
|
+
module: string;
|
|
175
|
+
operator: string;
|
|
176
|
+
constants?: Record<string, string>;
|
|
177
|
+
}
|
|
178
|
+
|
|
132
179
|
export interface InitialStatesProgress {
|
|
133
180
|
kind: "initial-states-progress";
|
|
134
181
|
count: number;
|
|
135
182
|
}
|
|
136
183
|
|
|
137
|
-
// A check that TLC's DoInitFunctor reports as violated before it stops its replay of the initial
|
|
138
|
-
// states.
|
|
139
184
|
export interface InitialStateViolation {
|
|
140
185
|
kind: "initial-state-violation";
|
|
141
186
|
status: "invariant-violation" | "liveness-violation";
|
|
@@ -143,10 +188,8 @@ export interface InitialStateViolation {
|
|
|
143
188
|
state: Record<string, Value>;
|
|
144
189
|
}
|
|
145
190
|
|
|
146
|
-
// A line the spec prints, or what TLC reports as it replays the initial states.
|
|
147
191
|
export type OutputLine = string | InitialStatesProgress | InitialStateViolation;
|
|
148
192
|
|
|
149
|
-
// The points of the search at which TLC prints a message.
|
|
150
193
|
export type CheckProgress =
|
|
151
194
|
| { kind: "parsed" }
|
|
152
195
|
| { kind: "constant-level-invariant"; name: string }
|
|
@@ -160,23 +203,21 @@ export type CheckProgress =
|
|
|
160
203
|
| {
|
|
161
204
|
kind: "liveness-started";
|
|
162
205
|
branches: number;
|
|
163
|
-
|
|
206
|
+
/** Whether TLC checks the complete state graph. */
|
|
164
207
|
isComplete: boolean;
|
|
208
|
+
/** How many states of the graph each branch has. */
|
|
165
209
|
states: number;
|
|
166
210
|
statistics: SearchStatistics;
|
|
167
211
|
}
|
|
168
212
|
| { kind: "liveness-finished" }
|
|
169
213
|
| { kind: "sequential-fallback"; string: string }
|
|
170
|
-
// A warning TLC prints as it evaluates the spec, with its message code.
|
|
171
214
|
| { kind: "warning"; code: number; text: string }
|
|
172
|
-
// A violation that the search goes on past with -continue.
|
|
173
215
|
| { kind: "violation"; status: CheckStatus; violation: Violation }
|
|
174
|
-
// A method of the class named after a module, which TLC reports as it loads the class.
|
|
175
216
|
| ({ kind: "java-override" } & JavaOverride);
|
|
176
217
|
|
|
177
218
|
export interface SearchStatistics extends Pick<
|
|
178
219
|
CheckResult,
|
|
179
|
-
"generatedStates" | "distinctStates" | "queuedStates" | "depth"
|
|
220
|
+
"generatedStates" | "distinctStates" | "queuedStates" | "depth" | "coverage"
|
|
180
221
|
> {}
|
|
181
222
|
|
|
182
223
|
export type CheckStatus =
|
|
@@ -191,45 +232,42 @@ export type CheckStatus =
|
|
|
191
232
|
|
|
192
233
|
export interface TraceStep {
|
|
193
234
|
action: string | undefined;
|
|
194
|
-
|
|
235
|
+
/** TLC's name, parameters and location for the action that took this step. */
|
|
195
236
|
label: string | undefined;
|
|
196
237
|
state: Record<string, Value>;
|
|
197
|
-
|
|
198
|
-
// trace. The first step has what TLC prints before the trace.
|
|
238
|
+
/** What the spec prints before this step as TLC rebuilds the trace, and before it for the first. */
|
|
199
239
|
output?: OutputLine[];
|
|
200
240
|
}
|
|
201
241
|
|
|
202
242
|
export interface Violation {
|
|
203
243
|
name: string;
|
|
204
|
-
|
|
244
|
+
/** Every temporal property that a liveness counterexample violates, in the configuration's order. */
|
|
205
245
|
properties?: string[];
|
|
206
246
|
trace: TraceStep[];
|
|
207
|
-
|
|
208
|
-
// the cycle of a lasso or rebuilds the trace once more.
|
|
247
|
+
/** What the spec prints after the trace, as TLC finds the lasso's step back or rebuilds the trace. */
|
|
209
248
|
traceOutput?: OutputLine[];
|
|
249
|
+
/** What the postconditions print, which TLC checks after the lasso's step back. */
|
|
250
|
+
postconditionOutput?: OutputLine[];
|
|
210
251
|
loopStart: number | undefined;
|
|
211
252
|
loopLabel?: string;
|
|
212
253
|
message?: string;
|
|
213
254
|
counts?: string;
|
|
214
255
|
unwitnessed?: Postcondition;
|
|
215
|
-
|
|
216
|
-
// prints one.
|
|
256
|
+
/** A POSTCONDITION that is false or fails, which TLC checks as it prints the counterexample. */
|
|
217
257
|
postcondition?: Postcondition;
|
|
218
|
-
|
|
258
|
+
/** What TLC warns about after a counterexample, with its code. */
|
|
219
259
|
warning?: { code: number; text: string };
|
|
220
260
|
}
|
|
221
261
|
|
|
222
262
|
export interface Postcondition {
|
|
223
263
|
name: string;
|
|
224
|
-
// TLC's message code.
|
|
225
264
|
code: number;
|
|
226
265
|
message: string;
|
|
227
266
|
counts?: string;
|
|
228
267
|
}
|
|
229
268
|
|
|
230
|
-
|
|
269
|
+
/** An evaluation that failed during the search, with the behavior up to the state TLC was working on. */
|
|
231
270
|
export interface EvaluationFailure {
|
|
232
|
-
// TLC's code for the message, and its text with and without -tool.
|
|
233
271
|
code: number;
|
|
234
272
|
message: string;
|
|
235
273
|
toolMessage: string;
|
|
@@ -237,28 +275,20 @@ export interface EvaluationFailure {
|
|
|
237
275
|
traceOutput?: OutputLine[];
|
|
238
276
|
initialState: Record<string, Value> | undefined;
|
|
239
277
|
exitCode: number;
|
|
240
|
-
|
|
241
|
-
// them by replaying the failure.
|
|
278
|
+
/** The expressions TLC was evaluating, outermost first, when its replay finds them. */
|
|
242
279
|
callStack: Expression[] | undefined;
|
|
243
|
-
|
|
280
|
+
/** Whether TLC prints the call stack before the error, as it does for a failed liveness check. */
|
|
244
281
|
isCallStackFirst?: boolean;
|
|
245
|
-
|
|
282
|
+
/** The FingerprintException the replay raises, which TLC reports in place of the call stack. */
|
|
246
283
|
fingerprint?: FingerprintFailure;
|
|
247
|
-
|
|
248
|
-
// failure occurred in.
|
|
284
|
+
/** How TLC reports failing again as it prints the trace, since it can't fingerprint the state. */
|
|
249
285
|
traceFailure?: FailureMessage;
|
|
250
|
-
|
|
286
|
+
/** A POSTCONDITION that is false or fails after the trace, which TLC checks as it prints one. */
|
|
251
287
|
postcondition?: Postcondition;
|
|
252
|
-
|
|
288
|
+
/** Whether TLC stops before it prints the statistics, as it does for an illegal initial state. */
|
|
253
289
|
isWithoutStatistics?: boolean;
|
|
254
290
|
}
|
|
255
291
|
|
|
256
|
-
// Where TLC's replay of a failure fails.
|
|
257
|
-
interface ReplayFailure {
|
|
258
|
-
callStack: Expression[];
|
|
259
|
-
fingerprint: FingerprintFailure | undefined;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
292
|
export interface InitialStates {
|
|
263
293
|
generated: number;
|
|
264
294
|
distinct: number;
|
|
@@ -272,104 +302,38 @@ export interface CheckResult {
|
|
|
272
302
|
distinctStates: number;
|
|
273
303
|
queuedStates: number;
|
|
274
304
|
depth: number;
|
|
275
|
-
|
|
276
|
-
// them all without a violation or an error.
|
|
305
|
+
/** Once TLC computed all the initial states without a violation or an error. */
|
|
277
306
|
initialStates: InitialStates | undefined;
|
|
278
|
-
|
|
279
|
-
// the outdegree of the state graph.
|
|
307
|
+
/** How many expanded states found each number of new states, when TLC prints the outdegree. */
|
|
280
308
|
outDegrees: number[] | undefined;
|
|
281
|
-
|
|
282
|
-
// collision from the actual fingerprints.
|
|
309
|
+
/** The smallest distance between two fingerprints, when TLC estimates a collision from them. */
|
|
283
310
|
fingerprintDistance: bigint | undefined;
|
|
284
|
-
|
|
285
|
-
// which it reports after the deadlock.
|
|
311
|
+
/** A temporal property TLC finds violated as it adds a deadlocked state, reported after. */
|
|
286
312
|
additionalViolation?: Violation;
|
|
287
|
-
|
|
313
|
+
/** Where TLC's worker fails to add the state to the behavior graph after it reports a violation. */
|
|
288
314
|
liveCallStack?: Expression[];
|
|
289
|
-
|
|
290
|
-
// stop on a violation without an error code, which TLC 1.7.4 reports as a successful search.
|
|
315
|
+
/** The outdegrees when TLC's workers stop on a violation that TLC 1.7.4 reports as a success. */
|
|
291
316
|
violationOutDegrees?: number[];
|
|
317
|
+
traceSpec?: string;
|
|
318
|
+
coverage?: CoverageReport;
|
|
292
319
|
}
|
|
293
320
|
|
|
294
|
-
interface
|
|
295
|
-
|
|
296
|
-
traceOutput?: OutputLine[];
|
|
321
|
+
interface CoveredAction extends SpecAction {
|
|
322
|
+
node: number;
|
|
297
323
|
}
|
|
298
324
|
|
|
299
|
-
interface
|
|
325
|
+
interface ReportedViolation extends Omit<Violation, "loopStart"> {
|
|
300
326
|
loopStart?: number;
|
|
301
|
-
known?: number;
|
|
302
327
|
}
|
|
303
328
|
|
|
304
|
-
interface FailureOptions {
|
|
305
|
-
initialState?: Value[];
|
|
306
|
-
isInitial?: boolean;
|
|
307
|
-
outDegrees?: number[];
|
|
308
|
-
callStack?: Expression[];
|
|
309
|
-
fingerprint?: FingerprintFailure;
|
|
310
|
-
isNextState?: boolean;
|
|
311
|
-
isCallStackFirst?: boolean;
|
|
312
|
-
traceFailure?: FailureMessage;
|
|
313
|
-
// Whether the call stack is of adding the state to the behavior graph, which TLC prints instead
|
|
314
|
-
// of replaying the error.
|
|
315
|
-
isLiveCallStack?: boolean;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// TLC prints what the spec prints as it replays a failure after the trace.
|
|
319
329
|
const appendTraceOutput = <Traced extends Behavior>(behavior: Traced, lines: OutputLine[]) => ({
|
|
320
330
|
...behavior,
|
|
321
331
|
traceOutput: [...(behavior.traceOutput ?? []), ...lines],
|
|
322
332
|
});
|
|
323
333
|
|
|
324
|
-
const INITIAL_RECOVERY_FAILURE = "Failed to recover the initial state from its fingerprint.";
|
|
325
|
-
const NEXT_RECOVERY_FAILURE = "Failed to recover the next state from its fingerprint.";
|
|
326
|
-
|
|
327
|
-
const toAliasRecord = (value: Value, fieldOrder: string[]) => {
|
|
328
|
-
if (!isFunctionValue(value)) return undefined;
|
|
329
|
-
const record = toFiniteFunction(value);
|
|
330
|
-
if (!record.domain.every((key) => typeof key === "string")) return undefined;
|
|
331
|
-
const entries = record.domain.map((key, index): [string, Value] => [
|
|
332
|
-
String(key),
|
|
333
|
-
record.range[index],
|
|
334
|
-
]);
|
|
335
|
-
return Object.fromEntries(
|
|
336
|
-
entries.sort((left, right) => fieldOrder.indexOf(left[0]) - fieldOrder.indexOf(right[0])),
|
|
337
|
-
);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// Stops a replay where TLC stops it without a failure, as at a violated invariant.
|
|
341
334
|
const STOP_REPLAY = new Error("The replay stopped");
|
|
335
|
+
const STOP_WALK = new Error("The walk stopped");
|
|
342
336
|
|
|
343
|
-
// The codes of the errors in the configuration and the spec that TLC's EC.ExitStatus maps to a
|
|
344
|
-
// configuration error.
|
|
345
|
-
const CONFIG_ERROR_CODES = new Set([
|
|
346
|
-
...Array.from({ length: 24 }, (_, index) => 2222 + index),
|
|
347
|
-
2272,
|
|
348
|
-
2273,
|
|
349
|
-
2274,
|
|
350
|
-
2280,
|
|
351
|
-
2281,
|
|
352
|
-
]);
|
|
353
|
-
|
|
354
|
-
// When TLC's replay of the initial states doesn't fail again, it exits with the code of the
|
|
355
|
-
// TLCRuntimeException it reported.
|
|
356
|
-
const getInitialExitCode = (error: TlaEvaluationError) => {
|
|
357
|
-
const coded = getCodedMessage(error.message);
|
|
358
|
-
return coded && !coded.isEvalException && CONFIG_ERROR_CODES.has(coded.code)
|
|
359
|
-
? EXIT_STATUS.configParseError
|
|
360
|
-
: getErrorExitCode(error);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
// When TLC's replay of an error fails again, an EvalException from a standard module's Java code
|
|
364
|
-
// decides the exit status, and any other failure exits as a nested expression failure. An error
|
|
365
|
-
// that heads or wraps another exits as the other.
|
|
366
|
-
const getReplayExitCode = (error: TlaEvaluationError): number => {
|
|
367
|
-
const inner = error.cause;
|
|
368
|
-
if (inner instanceof TlaEvaluationError) return getReplayExitCode(inner);
|
|
369
|
-
return error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.specEvaluationFailure;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
// TLC finishes the -dump file whether or not the search finds a violation.
|
|
373
337
|
export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
374
338
|
const stateWriter =
|
|
375
339
|
options.dump && createStateWriter(options.dump, options.writeFile, options.version);
|
|
@@ -382,8 +346,6 @@ export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
|
382
346
|
}
|
|
383
347
|
};
|
|
384
348
|
|
|
385
|
-
// TLC checks liveness on the graph so far 3 seconds into the search and then every minute, once
|
|
386
|
-
// the graph has grown by a tenth and liveness checking has taken at most a fifth of the time.
|
|
387
349
|
const PERIODIC_START = 3000;
|
|
388
350
|
const PROGRESS_INTERVAL = 60_000;
|
|
389
351
|
const LIVENESS_GROWTH = 0.1;
|
|
@@ -395,81 +357,102 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
395
357
|
? parseConfig(options.config, options.version)
|
|
396
358
|
: options.config;
|
|
397
359
|
const onPrint = options.onPrint ?? console.log;
|
|
398
|
-
|
|
399
|
-
// keeps what it prints for the trace.
|
|
400
|
-
const capturedOutput = { lines: undefined as OutputLine[] | undefined };
|
|
360
|
+
let capturedLines: OutputLine[] | undefined;
|
|
401
361
|
const print = (text: string) => {
|
|
402
|
-
if (
|
|
362
|
+
if (capturedLines) capturedLines.push(text);
|
|
403
363
|
else onPrint(text);
|
|
404
364
|
};
|
|
405
365
|
const captureOutput = <Result>(rebuild: () => Result) => {
|
|
406
|
-
const outer =
|
|
366
|
+
const outer = capturedLines;
|
|
407
367
|
const lines: OutputLine[] = [];
|
|
408
|
-
|
|
368
|
+
capturedLines = lines;
|
|
409
369
|
try {
|
|
410
370
|
return { result: rebuild(), lines };
|
|
411
371
|
} finally {
|
|
412
|
-
|
|
372
|
+
capturedLines = outer;
|
|
413
373
|
}
|
|
414
374
|
};
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
setValueVersion(options.version);
|
|
418
|
-
const specification = createEnvironment(config, {
|
|
419
|
-
source: options.source,
|
|
420
|
-
loadModule: options.loadModule,
|
|
421
|
-
order,
|
|
422
|
-
loadClass: options.loadClass,
|
|
423
|
-
print,
|
|
424
|
-
files: { readFile: options.readFile, writeFile: options.writeFile },
|
|
425
|
-
seed: options.seed,
|
|
426
|
-
isTool: options.isTool,
|
|
427
|
-
isTraceRecorded: options.isTraceRecorded,
|
|
428
|
-
isSanyReported: options.isSanyReported,
|
|
429
|
-
isWarningEnabled: options.isWarningEnabled,
|
|
430
|
-
version: options.version,
|
|
431
|
-
});
|
|
375
|
+
const created = createCheckEnvironment(config, options, print);
|
|
376
|
+
const specification = created.specification;
|
|
432
377
|
reportStartup(specification, config, options.onProgress);
|
|
433
|
-
const
|
|
378
|
+
const coverage =
|
|
379
|
+
options.coverage === undefined
|
|
380
|
+
? undefined
|
|
381
|
+
: createCoverage(specification.environment.variables.length);
|
|
382
|
+
const environment: Environment = coverage
|
|
383
|
+
? {
|
|
384
|
+
...specification.environment,
|
|
385
|
+
evaluators: new WeakMap(),
|
|
386
|
+
entryEvaluators: new WeakMap(),
|
|
387
|
+
definitionEvaluators: new WeakMap(),
|
|
388
|
+
coverage,
|
|
389
|
+
}
|
|
390
|
+
: specification.environment;
|
|
434
391
|
const runtime = environment.runtime;
|
|
435
392
|
const is174 = runtime.version === "1.7.4";
|
|
436
393
|
runtime.pause = options.onPause ?? (() => {});
|
|
394
|
+
let description: SpecDescription | undefined;
|
|
395
|
+
const getDescription = () =>
|
|
396
|
+
(description ??= getSpecDescription(config, environment, specification.instanceActions));
|
|
437
397
|
runtime.getSpecification = () =>
|
|
438
|
-
getSpecificationValue(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
398
|
+
getSpecificationValue(getDescription(), config, environment, specification.variableLocations);
|
|
399
|
+
let searchDepth = 0;
|
|
400
|
+
let computedInitialStates: InitialStates | undefined;
|
|
401
|
+
const getTraceSpec = (trace: TraceStep[], loopStart: number | undefined) =>
|
|
402
|
+
options.traceSpec &&
|
|
403
|
+
writeTraceSpec({
|
|
404
|
+
module: options.traceSpec.module,
|
|
405
|
+
specName: specification.rootName,
|
|
406
|
+
rawConstants: config.rawConstants,
|
|
407
|
+
states: trace.map((step) => getStepState(step)),
|
|
408
|
+
loopStart,
|
|
409
|
+
modelValues: getModelValues().map((value) => value.name),
|
|
410
|
+
isDefined: (name) =>
|
|
411
|
+
environment.definitions.has(name) ||
|
|
412
|
+
environment.constants.has(name) ||
|
|
413
|
+
[...environment.definitions.keys()].some((key) =>
|
|
414
|
+
key.startsWith(`${name}${KEY_SEPARATOR}`),
|
|
415
|
+
),
|
|
416
|
+
});
|
|
445
417
|
const createResult = (
|
|
446
418
|
status: CheckStatus,
|
|
447
|
-
violation?:
|
|
419
|
+
violation?: ReportedViolation,
|
|
448
420
|
failure?: EvaluationFailure,
|
|
449
|
-
): CheckResult =>
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
421
|
+
): CheckResult => {
|
|
422
|
+
const traceSpec = getTraceSpec(
|
|
423
|
+
violation?.trace ?? failure?.trace ?? [],
|
|
424
|
+
status === "property-violation" ? undefined : violation?.loopStart,
|
|
425
|
+
);
|
|
426
|
+
return {
|
|
427
|
+
status,
|
|
428
|
+
violation: violation && { ...violation, loopStart: violation.loopStart },
|
|
429
|
+
failure,
|
|
430
|
+
generatedStates: runtime.generatedStates,
|
|
431
|
+
distinctStates: runtime.distinctStates,
|
|
432
|
+
queuedStates: runtime.queueSize,
|
|
433
|
+
depth: runtime.generatedStates === 0 ? 0 : Math.max(searchDepth, 1),
|
|
434
|
+
initialStates: computedInitialStates,
|
|
435
|
+
outDegrees: undefined,
|
|
436
|
+
fingerprintDistance: undefined,
|
|
437
|
+
coverage: coverage?.relations.some((relation) => relation.kind === "next")
|
|
438
|
+
? getCoverageReport(
|
|
439
|
+
coverage,
|
|
440
|
+
environment,
|
|
441
|
+
specification.variableLocations,
|
|
442
|
+
search?.getTlcOrder() ?? [],
|
|
443
|
+
)
|
|
444
|
+
: undefined,
|
|
445
|
+
...(traceSpec !== undefined && { traceSpec }),
|
|
446
|
+
};
|
|
447
|
+
};
|
|
461
448
|
const outDegrees = Array.from({ length: OUT_DEGREE_BUCKETS }, () => 0);
|
|
462
|
-
|
|
463
|
-
const getOutDegreeBucket = () => Math.min(
|
|
464
|
-
// TLC counts the state it was expanding when an evaluation failed, except TLC 1.7.4, whose
|
|
465
|
-
// worker stops before it counts the state.
|
|
449
|
+
let newStateCount = 0;
|
|
450
|
+
const getOutDegreeBucket = () => Math.min(newStateCount, OUT_DEGREE_BUCKETS - 1);
|
|
466
451
|
const getPartialOutDegrees = () =>
|
|
467
452
|
outDegrees.map((count, degree) => (degree === getOutDegreeBucket() ? count + 1 : count));
|
|
468
453
|
const getFailureOutDegrees = () => (is174 ? [...outDegrees] : getPartialOutDegrees());
|
|
469
|
-
// TLC 1.7.4 doesn't name the properties a counterexample violates, so it evaluates none of them.
|
|
470
454
|
const getViolatedProperties = (checker: LivenessChecker, path: Value[][], cycleStart: number) =>
|
|
471
455
|
is174 ? [] : checker.getViolatedProperties(path, cycleStart);
|
|
472
|
-
// A violation in a successor ends the expansion of a state before TLC counts it.
|
|
473
456
|
const withOutDegrees = (result: CheckResult, degrees = [...outDegrees]): CheckResult => ({
|
|
474
457
|
...result,
|
|
475
458
|
violationOutDegrees: degrees,
|
|
@@ -477,21 +460,24 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
477
460
|
const createSuccess = (): CheckResult => ({
|
|
478
461
|
...createResult("success"),
|
|
479
462
|
outDegrees: [...outDegrees],
|
|
480
|
-
fingerprintDistance:
|
|
481
|
-
|
|
482
|
-
runtime.generatedStates,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
463
|
+
fingerprintDistance: options.isFingerprintDistanceSkipped
|
|
464
|
+
? undefined
|
|
465
|
+
: getFingerprintDistance(runtime.distinctStates, runtime.generatedStates, (visit) =>
|
|
466
|
+
visit(
|
|
467
|
+
search
|
|
468
|
+
? search.getStoredFingerprints(states, fingerprintStates)
|
|
469
|
+
: BigInt64Array.from(states, runtime.getFingerprint),
|
|
470
|
+
),
|
|
471
|
+
),
|
|
488
472
|
});
|
|
489
473
|
|
|
490
474
|
const search = createSearch(
|
|
491
475
|
config,
|
|
492
476
|
environment,
|
|
493
|
-
|
|
477
|
+
specification.variableLocations,
|
|
478
|
+
() => created.order.getDeclarationOrder("variable"),
|
|
494
479
|
options.onProgress,
|
|
480
|
+
specification.moduleOperators,
|
|
495
481
|
);
|
|
496
482
|
const findViolatedAssumption = () =>
|
|
497
483
|
findAssumptionViolation(specification.assumptions, environment);
|
|
@@ -499,29 +485,24 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
499
485
|
runtime.isStarted = true;
|
|
500
486
|
const assumptionViolation = findViolatedAssumption();
|
|
501
487
|
if (assumptionViolation) return createResult("assumption-violation", assumptionViolation);
|
|
502
|
-
|
|
503
|
-
statistics.initialStates = { generated: 0, distinct: 0 };
|
|
488
|
+
computedInitialStates = { generated: 0, distinct: 0 };
|
|
504
489
|
options.onProgress?.({ kind: "initial-states-started" });
|
|
505
490
|
options.onProgress?.({
|
|
506
491
|
kind: "initial-states-computed",
|
|
507
|
-
initialStates:
|
|
492
|
+
initialStates: computedInitialStates,
|
|
508
493
|
});
|
|
509
494
|
return createSuccess();
|
|
510
495
|
}
|
|
511
|
-
const hasPostconditions =
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
>();
|
|
518
|
-
const getStepState = (step: TraceStep) => traceSteps.get(step)?.state ?? step.state;
|
|
496
|
+
const hasPostconditions =
|
|
497
|
+
config.postconditions.length > 0 ||
|
|
498
|
+
config.possible.length > 0 ||
|
|
499
|
+
specification.moduleOperators.some((operator) => operator.kind === "postcondition");
|
|
500
|
+
const tracedSteps = new WeakMap<TraceStep, TracedStep>();
|
|
501
|
+
const getStepState = (step: TraceStep) => tracedSteps.get(step)?.state ?? step.state;
|
|
519
502
|
const getStepAction = (step: TraceStep) => {
|
|
520
|
-
const action =
|
|
503
|
+
const action = tracedSteps.get(step)?.action;
|
|
521
504
|
return action ? toActionValue(action) : createActionRecord(step.action);
|
|
522
505
|
};
|
|
523
|
-
// Worker#printTrace checks the postconditions on the CounterExample of each trace it prints, so
|
|
524
|
-
// what they print follows the trace.
|
|
525
506
|
const checkTracePostconditions = (
|
|
526
507
|
trace: TraceStep[],
|
|
527
508
|
loop: { start: number; action: Value } | undefined,
|
|
@@ -541,7 +522,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
541
522
|
};
|
|
542
523
|
const reportViolation = (
|
|
543
524
|
status: CheckStatus,
|
|
544
|
-
violation:
|
|
525
|
+
violation: ReportedViolation,
|
|
545
526
|
getLoopAction?: () => Value,
|
|
546
527
|
) => {
|
|
547
528
|
const start = violation.loopStart;
|
|
@@ -549,76 +530,105 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
549
530
|
violation.trace,
|
|
550
531
|
start === undefined || !getLoopAction ? undefined : { start, action: getLoopAction() },
|
|
551
532
|
);
|
|
552
|
-
const traceOutput = [...(violation.traceOutput ?? []), ...checked.lines];
|
|
553
533
|
return createResult(status, {
|
|
554
534
|
...violation,
|
|
555
|
-
...(
|
|
535
|
+
...(checked.lines.length > 0 && { postconditionOutput: checked.lines }),
|
|
556
536
|
...(checked.unwitnessed && { unwitnessed: checked.unwitnessed }),
|
|
557
537
|
...(checked.postcondition && { postcondition: checked.postcondition }),
|
|
558
538
|
});
|
|
559
539
|
};
|
|
560
|
-
//
|
|
561
|
-
|
|
540
|
+
// Deviation from TLC: -continue ends with the status of the first violation, not a success.
|
|
541
|
+
let continuedStatus: CheckStatus | undefined;
|
|
542
|
+
const reportContinuedViolation = (
|
|
543
|
+
status: CheckStatus,
|
|
544
|
+
violation: Omit<Violation, "loopStart">,
|
|
545
|
+
) => {
|
|
546
|
+
continuedStatus ??= status;
|
|
562
547
|
options.onProgress?.({
|
|
563
548
|
kind: "violation",
|
|
564
549
|
status,
|
|
565
550
|
violation: { ...violation, loopStart: undefined },
|
|
566
551
|
});
|
|
552
|
+
};
|
|
567
553
|
const spec = search.spec;
|
|
568
554
|
const getFingerprintState = search.getFingerprintState;
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
555
|
+
// Tool's constructor splits the next-state relation into actions before TLC checks anything.
|
|
556
|
+
const nextActions = getDescription().actions;
|
|
557
|
+
runtime.getSuccessorAction = (state, next) =>
|
|
558
|
+
nextActions.find((action) =>
|
|
559
|
+
getSuccessors(action.expression, state, environment, action.scope).some((successor) =>
|
|
560
|
+
successor.state.every((value, index) => isSameValue(value, next[index])),
|
|
561
|
+
),
|
|
562
|
+
);
|
|
563
|
+
const addCoverageRelations = (kind: "init" | "next", actions: SpecAction[]) =>
|
|
564
|
+
actions.map((action): CoveredAction => ({
|
|
565
|
+
...action,
|
|
566
|
+
node: coverage
|
|
567
|
+
? addCoverageRelation(
|
|
568
|
+
coverage,
|
|
569
|
+
kind,
|
|
570
|
+
getCoverageLabel(action.name, action.expression, environment),
|
|
571
|
+
action.expression,
|
|
572
|
+
action.scope,
|
|
573
|
+
)
|
|
574
|
+
: -1,
|
|
575
|
+
}));
|
|
576
|
+
const coverageInits = addCoverageRelations("init", coverage ? getDescription().inits : []);
|
|
577
|
+
const coverageActions = addCoverageRelations("next", coverage ? nextActions : []);
|
|
578
|
+
if (coverage) buildCoverage(coverage, environment, getPrimedRanges(coverageActions, environment));
|
|
579
|
+
const walkCoveredSuccessors = (
|
|
580
|
+
action: CoveredAction,
|
|
581
|
+
state: Value[],
|
|
582
|
+
onState: (successor: Value[]) => void,
|
|
583
|
+
) =>
|
|
584
|
+
walkSuccessors(
|
|
585
|
+
action,
|
|
586
|
+
action.node,
|
|
587
|
+
state,
|
|
588
|
+
environment,
|
|
589
|
+
(successor) => {
|
|
590
|
+
if (coverage) coverage.primary[action.node]++;
|
|
591
|
+
onState(successor);
|
|
592
|
+
},
|
|
593
|
+
(partial) => {
|
|
594
|
+
const missing = environment.variables.filter(
|
|
595
|
+
(_variable, index) => partial[index] === undefined,
|
|
596
|
+
);
|
|
597
|
+
throw new TlaIncompleteSuccessorError(
|
|
598
|
+
`Successor state is not completely specified by action ${action.name}. The following variables are not assigned: ${missing.join(", ")}`,
|
|
599
|
+
partial,
|
|
600
|
+
action.name,
|
|
601
|
+
missing,
|
|
602
|
+
);
|
|
603
|
+
},
|
|
604
|
+
);
|
|
605
|
+
const getCoveredSuccessors = (action: CoveredAction, state: Value[]) => {
|
|
606
|
+
const successors: Successor[] = [];
|
|
607
|
+
walkCoveredSuccessors(action, state, (successor) =>
|
|
608
|
+
successors.push({ state: successor, action: action.name }),
|
|
609
|
+
);
|
|
610
|
+
return successors;
|
|
584
611
|
};
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const findFailedSources = (value: Value, sources: CallStack["sources"]): Expression[] => {
|
|
588
|
-
if (typeof value !== "object") return [];
|
|
589
|
-
const source = sources.get(value);
|
|
590
|
-
const failed = getHeldValues(value).find((held) => getFingerprintError(held) !== undefined);
|
|
591
|
-
return [
|
|
592
|
-
...(source ? [source] : []),
|
|
593
|
-
...(failed === undefined ? [] : findFailedSources(failed, sources)),
|
|
594
|
-
];
|
|
612
|
+
const rejectIncompleteInitialState = (partial: (Value | undefined)[]) => {
|
|
613
|
+
throw setExitCode(new TlaIllegalStateError([...partial]), EXIT_STATUS.error);
|
|
595
614
|
};
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
callStack.expressions.length = 0;
|
|
606
|
-
callStack.isFrozen = true;
|
|
607
|
-
callStack.fingerprint = { sources, reason: error.message };
|
|
608
|
-
}
|
|
609
|
-
throw error;
|
|
610
|
-
}
|
|
611
|
-
state.forEach(markFingerprinted);
|
|
615
|
+
const getCoveredInitialStates = () => {
|
|
616
|
+
const initialStates: Value[][] = [];
|
|
617
|
+
replayInitialStates(
|
|
618
|
+
coverageInits,
|
|
619
|
+
environment,
|
|
620
|
+
(state) => initialStates.push(state),
|
|
621
|
+
rejectIncompleteInitialState,
|
|
622
|
+
);
|
|
623
|
+
return initialStates;
|
|
612
624
|
};
|
|
613
|
-
// The replay adds the states it hasn't seen to TLC's set of states, which already holds the state
|
|
614
|
-
// that failed after TLC added it.
|
|
615
625
|
const createReplayedStates = () => {
|
|
616
|
-
const replayed =
|
|
626
|
+
const replayed = unstoredFingerprint ? [unstoredFingerprint] : [];
|
|
617
627
|
return (state: Value[], callStack: CallStack | undefined) => {
|
|
618
|
-
fingerprintReplayed(state, callStack);
|
|
628
|
+
fingerprintReplayed(state, getFingerprintState(state), callStack);
|
|
619
629
|
const fingerprintState = getFingerprintState(state);
|
|
620
630
|
const isSeen =
|
|
621
|
-
findStateIndex(getStateHash(fingerprintState), fingerprintState) !== -1 ||
|
|
631
|
+
findStateIndex(seenStates, getStateHash(fingerprintState), fingerprintState) !== -1 ||
|
|
622
632
|
replayed.some((seen) => isSameState(seen, fingerprintState));
|
|
623
633
|
if (isSeen) return false;
|
|
624
634
|
replayed.push(fingerprintState);
|
|
@@ -626,59 +636,48 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
626
636
|
return true;
|
|
627
637
|
};
|
|
628
638
|
};
|
|
629
|
-
// TLC's DoInitFunctor reports its progress again as it replays the initial states, and adds each
|
|
630
|
-
// one it hasn't seen to the behavior graph. After a FingerprintException, it only counts the
|
|
631
|
-
// states left, then throws the exception.
|
|
632
639
|
const replayInit = () => {
|
|
633
|
-
|
|
634
|
-
const deferred:
|
|
640
|
+
let replayedCount = 0;
|
|
641
|
+
const deferred: unknown[] = [];
|
|
635
642
|
const addReplayed = createReplayedStates();
|
|
636
|
-
return getReplayFailure((tracing) => {
|
|
637
|
-
replayInitialStates(
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
)
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
kind: "initial-state-violation",
|
|
658
|
-
...violation,
|
|
659
|
-
state: traced,
|
|
660
|
-
});
|
|
661
|
-
throw STOP_REPLAY;
|
|
662
|
-
}
|
|
663
|
-
} catch (error) {
|
|
664
|
-
if (!(error instanceof TlaEvaluationError) || !tracing.callStack?.fingerprint) {
|
|
665
|
-
throw error;
|
|
666
|
-
}
|
|
667
|
-
deferred.push(error);
|
|
643
|
+
return getReplayFailure(environment, (tracing) => {
|
|
644
|
+
replayInitialStates(getDescription().inits, tracing, (state) => {
|
|
645
|
+
reportInitialStatesProgress(replayedCount, (progress) => capturedLines?.push(progress));
|
|
646
|
+
replayedCount++;
|
|
647
|
+
runtime.generatedStates = replayedCount;
|
|
648
|
+
if (deferred.length > 0) return;
|
|
649
|
+
try {
|
|
650
|
+
const addFingerprint = () => {
|
|
651
|
+
if (!addReplayed(state, tracing.callStack)) return;
|
|
652
|
+
runtime.queueSize++;
|
|
653
|
+
liveness?.addInitialState(states.length, state, tracing);
|
|
654
|
+
};
|
|
655
|
+
const violation = search.checkReplayedInitialState(state, tracing, addFingerprint);
|
|
656
|
+
if (violation) {
|
|
657
|
+
const traced = traces.toTrace([{ action: undefined, state }], []).trace[0].state;
|
|
658
|
+
capturedLines?.push({
|
|
659
|
+
kind: "initial-state-violation",
|
|
660
|
+
...violation,
|
|
661
|
+
state: traced,
|
|
662
|
+
});
|
|
663
|
+
throw STOP_REPLAY;
|
|
668
664
|
}
|
|
669
|
-
}
|
|
670
|
-
|
|
665
|
+
} catch (error) {
|
|
666
|
+
const isFingerprintFailure =
|
|
667
|
+
error instanceof TlaEvaluationError && tracing.callStack?.fingerprint !== undefined;
|
|
668
|
+
if (!isFingerprintFailure && !isStackOverflow(error)) throw error;
|
|
669
|
+
deferred.push(error);
|
|
670
|
+
}
|
|
671
|
+
});
|
|
671
672
|
if (deferred.length > 0) throw deferred[0];
|
|
672
673
|
});
|
|
673
674
|
};
|
|
674
|
-
// TLC replays the expansion of a state with ModelChecker.doNext, which writes each successor in
|
|
675
|
-
// the model to the -dump state graph again.
|
|
676
675
|
const replayNext = (index: number) =>
|
|
677
|
-
getReplayFailure((tracing) => {
|
|
676
|
+
getReplayFailure(environment, (tracing) => {
|
|
678
677
|
const state = states[index];
|
|
679
678
|
const source = stateWriter && getGraphState(state, depths[index]);
|
|
680
679
|
const addReplayed = createReplayedStates();
|
|
681
|
-
replaySuccessors(
|
|
680
|
+
replaySuccessors(nextActions, state, tracing, (next, action) => {
|
|
682
681
|
const addFingerprint = () => {
|
|
683
682
|
const isUnseen = addReplayed(next, tracing.callStack);
|
|
684
683
|
if (source) {
|
|
@@ -686,9 +685,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
686
685
|
source,
|
|
687
686
|
getGraphState(next, depths[index] + 1),
|
|
688
687
|
!isUnseen,
|
|
689
|
-
isNamingEdges
|
|
690
|
-
? { name: action.name, signature: getActionSignature(action) }
|
|
691
|
-
: undefined,
|
|
688
|
+
isNamingEdges ? getGraphAction(action) : undefined,
|
|
692
689
|
);
|
|
693
690
|
}
|
|
694
691
|
return isUnseen;
|
|
@@ -698,9 +695,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
698
695
|
}
|
|
699
696
|
});
|
|
700
697
|
});
|
|
701
|
-
const isReducing = config.view !== undefined || config.symmetry !== undefined;
|
|
702
698
|
const tlcFingerprints: number[] = [];
|
|
703
|
-
// TLC warns about the liveness checker before it builds it.
|
|
704
699
|
if (search.properties.liveness.length > 0) {
|
|
705
700
|
options.onProgress?.({
|
|
706
701
|
kind: "liveness-initializing",
|
|
@@ -711,39 +706,46 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
711
706
|
const liveness = withLivenessExitCode(() =>
|
|
712
707
|
withUnexpectedException(() =>
|
|
713
708
|
createLivenessChecker(search.properties.liveness, spec.temporals, environment, {
|
|
714
|
-
getFingerprint: (
|
|
715
|
-
(tlcFingerprints[index] ??= Number(
|
|
709
|
+
getFingerprint: (successor) =>
|
|
710
|
+
(tlcFingerprints[successor.index] ??= Number(
|
|
711
|
+
BigInt.asIntN(32, runtime.getFingerprint(successor.state)),
|
|
712
|
+
)),
|
|
716
713
|
getSuccessors: (source, state) => {
|
|
717
714
|
const successors: LiveSuccessor[] = [];
|
|
718
715
|
if (spec.next === undefined) return successors;
|
|
719
|
-
// The constraints read the level of the state whose successors they check, as when TLC
|
|
720
|
-
// explored it.
|
|
721
716
|
const livenessSource = current.livenessSource;
|
|
722
717
|
current.livenessSource = source;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
718
|
+
try {
|
|
719
|
+
forEachSuccessor(
|
|
720
|
+
spec.next,
|
|
721
|
+
state,
|
|
722
|
+
environment,
|
|
723
|
+
(successor) => {
|
|
724
|
+
canonicalizeState(successor.state);
|
|
725
|
+
const isInModel =
|
|
726
|
+
search.satisfiesConstraints(successor.state, state) &&
|
|
727
|
+
search.satisfiesActionConstraints(state, successor.state);
|
|
728
|
+
if (!isInModel) return false;
|
|
729
|
+
const fingerprintState = getFingerprintState(successor.state);
|
|
730
|
+
const index = findStateIndex(
|
|
731
|
+
seenStates,
|
|
732
|
+
getStateHash(fingerprintState),
|
|
733
|
+
fingerprintState,
|
|
734
|
+
);
|
|
735
|
+
successors.push({ index, state: successor.state });
|
|
736
|
+
return false;
|
|
737
|
+
},
|
|
738
|
+
spec.scope,
|
|
739
|
+
);
|
|
740
|
+
} finally {
|
|
741
|
+
current.livenessSource = livenessSource;
|
|
742
|
+
}
|
|
741
743
|
return successors;
|
|
742
744
|
},
|
|
743
745
|
}),
|
|
744
746
|
),
|
|
745
747
|
);
|
|
746
|
-
|
|
748
|
+
if (liveness?.branches === 0) throw createTautologyError();
|
|
747
749
|
runtime.isStarted = true;
|
|
748
750
|
const isCanonicalizedFirst = search.isSymmetric || liveness !== undefined;
|
|
749
751
|
|
|
@@ -752,209 +754,21 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
752
754
|
const parents: number[] = [];
|
|
753
755
|
const actions: (string | undefined)[] = [];
|
|
754
756
|
const depths: number[] = [];
|
|
755
|
-
|
|
756
|
-
// and its index plus one side by side, probed by the hash.
|
|
757
|
-
const seenStates = { slots: new Int32Array(1 << 17), size: 0, shift: 16 };
|
|
757
|
+
const seenStates = createStateTable(fingerprintStates);
|
|
758
758
|
const canonicalizeState = createCanonicalizer();
|
|
759
759
|
|
|
760
|
-
const toRecord =
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
);
|
|
764
|
-
const getAliasState = (
|
|
765
|
-
alias: string,
|
|
766
|
-
steps: Successor[],
|
|
767
|
-
position: number,
|
|
768
|
-
loopStart: number | undefined,
|
|
769
|
-
) => {
|
|
770
|
-
// TLC evaluates TLCGet("level") and Trace in an alias at the state's position in the trace.
|
|
771
|
-
runtime.getLevel = () => position + 1;
|
|
772
|
-
runtime.getBehavior = () => steps.slice(0, position + 1).map((step) => step.state);
|
|
773
|
-
return evaluateAlias(
|
|
774
|
-
alias,
|
|
775
|
-
steps[position].state,
|
|
776
|
-
(steps[position + 1] ?? steps[loopStart ?? position]).state,
|
|
777
|
-
);
|
|
760
|
+
const toRecord = search.toRecord;
|
|
761
|
+
const getSpecInitialStates = () => {
|
|
762
|
+
if (coverage) return getCoveredInitialStates();
|
|
763
|
+
return spec.init === undefined ? [] : getInitialStates(spec.init, environment, spec.scope);
|
|
778
764
|
};
|
|
779
|
-
const
|
|
765
|
+
const isUnfingerprintable = (state: Value[]) => {
|
|
780
766
|
try {
|
|
781
|
-
|
|
782
|
-
const value = evaluate(createIdentifier(alias), getContext(environment, state, next));
|
|
783
|
-
const fieldOrder = body.kind === "Record" ? body.fields.map((field) => field.name) : [];
|
|
784
|
-
return toAliasRecord(value, fieldOrder) ?? toRecord(state);
|
|
767
|
+
return getFingerprintState(state).some((value) => getFingerprintError(value) !== undefined);
|
|
785
768
|
} catch (error) {
|
|
786
|
-
if (!(error instanceof
|
|
787
|
-
return
|
|
788
|
-
...toRecord(state),
|
|
789
|
-
_ALIASEvalError: formatNestedMessage(error.message, options.isTool ?? false),
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
};
|
|
793
|
-
// TLC finds the action of a step as the first action that takes it, evaluated as when the search
|
|
794
|
-
// expanded the previous state, by the values of a successor it holds and otherwise by fingerprint.
|
|
795
|
-
const findStepAction = (index: number, previous: Value[], state: Value[], isHeld: boolean) => {
|
|
796
|
-
const actions = getSpecNextActions();
|
|
797
|
-
const expanding = { ...current };
|
|
798
|
-
Object.assign(current, { index, isExpanding: true, candidate: undefined });
|
|
799
|
-
const getKey = isHeld ? (values: Value[]) => values : getFingerprintState;
|
|
800
|
-
const key = getKey(state);
|
|
801
|
-
const action = actions.find((item) =>
|
|
802
|
-
getSuccessors(item.expression, previous, environment, item.scope).some((successor) =>
|
|
803
|
-
isSameState(getKey(successor.state), key),
|
|
804
|
-
),
|
|
805
|
-
);
|
|
806
|
-
Object.assign(current, expanding);
|
|
807
|
-
return action;
|
|
808
|
-
};
|
|
809
|
-
// Before TLC prints a trace, it rebuilds from the initial predicate the states it does not keep,
|
|
810
|
-
// all but the last `known` ones. As it prints each later step, it finds the action that takes
|
|
811
|
-
// the step. Then it rebuilds the trace once more, unless the trace is a liveness counterexample
|
|
812
|
-
// or TLC is 1.7.4.
|
|
813
|
-
const toTrace = (
|
|
814
|
-
steps: Successor[],
|
|
815
|
-
path: number[],
|
|
816
|
-
traceOptions: TraceOptions = {},
|
|
817
|
-
): Behavior => {
|
|
818
|
-
const alias = config.alias;
|
|
819
|
-
const known = traceOptions.known ?? 1;
|
|
820
|
-
// Rebuilding the trace from the initial predicate can reset what TLCSet stored.
|
|
821
|
-
const initialOutput = steps.length > 1 ? captureOutput(getSpecInitialStates).lines : [];
|
|
822
|
-
// TLC finds the action that takes each step before it evaluates the alias.
|
|
823
|
-
const stepActions = steps.map((step, position) =>
|
|
824
|
-
position === 0 || step.action === "Stuttering"
|
|
825
|
-
? { result: undefined, lines: [] }
|
|
826
|
-
: captureOutput(() =>
|
|
827
|
-
findStepAction(
|
|
828
|
-
path[position - 1],
|
|
829
|
-
steps[position - 1].state,
|
|
830
|
-
step.state,
|
|
831
|
-
known === 2 && position === steps.length - 1,
|
|
832
|
-
),
|
|
833
|
-
),
|
|
834
|
-
);
|
|
835
|
-
const outputs = stepActions.map((step) => step.lines);
|
|
836
|
-
const loopStart = traceOptions.loopStart;
|
|
837
|
-
// 1.7.4's LiveWorker#printTrace rebuilds a lasso up to the start of its cycle at once, and then
|
|
838
|
-
// each state of the cycle as it prints it.
|
|
839
|
-
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
840
|
-
const prefixOutput = rebuilt > 0 ? [initialOutput, ...outputs.slice(1, rebuilt)].flat() : [];
|
|
841
|
-
return {
|
|
842
|
-
trace: steps.map((step, position) => {
|
|
843
|
-
const action = stepActions[position].result;
|
|
844
|
-
const traceStep: TraceStep = {
|
|
845
|
-
action: step.action,
|
|
846
|
-
label: action && getActionLabel(action, options.version),
|
|
847
|
-
state:
|
|
848
|
-
alias === undefined
|
|
849
|
-
? toRecord(step.state)
|
|
850
|
-
: getAliasState(alias, steps, position, loopStart),
|
|
851
|
-
output: position === 0 ? prefixOutput : position < rebuilt ? [] : outputs[position],
|
|
852
|
-
};
|
|
853
|
-
if (alias !== undefined || action) {
|
|
854
|
-
traceSteps.set(traceStep, { state: toRecord(step.state), action });
|
|
855
|
-
}
|
|
856
|
-
return traceStep;
|
|
857
|
-
}),
|
|
858
|
-
traceOutput: known > 0 && !is174 ? [initialOutput, ...outputs].flat() : [],
|
|
859
|
-
};
|
|
860
|
-
};
|
|
861
|
-
const getSpecInitialStates = () =>
|
|
862
|
-
spec.init === undefined ? [] : getInitialStates(spec.init, environment, spec.scope);
|
|
863
|
-
// TLC's Tool#getState rebuilds a successor action by action, up to the first action that
|
|
864
|
-
// generates it. A trace keeps what the spec prints as TLC rebuilds it, so finding its states
|
|
865
|
-
// prints nothing.
|
|
866
|
-
const findTraceSuccessor = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
867
|
-
captureOutput(() => {
|
|
868
|
-
for (const action of getSpecNextActions()) {
|
|
869
|
-
const successor = getSuccessors(action.expression, state, environment, action.scope).find(
|
|
870
|
-
isMatch,
|
|
871
|
-
);
|
|
872
|
-
if (successor) return { ...successor, action: successor.action ?? action.name };
|
|
873
|
-
}
|
|
874
|
-
return undefined;
|
|
875
|
-
}).result;
|
|
876
|
-
const hasFingerprint = (state: Value[], index: number) =>
|
|
877
|
-
isSameState(getFingerprintState(state), fingerprintStates[index]);
|
|
878
|
-
const findSuccessorWithFingerprint = (state: Value[], index: number) =>
|
|
879
|
-
findTraceSuccessor(state, (successor) => hasFingerprint(successor.state, index));
|
|
880
|
-
const getPathStates = (path: number[], nextFailure: string) => {
|
|
881
|
-
const initial = captureOutput(() =>
|
|
882
|
-
isReducing || isImpure(environment)
|
|
883
|
-
? getSpecInitialStates().find((state) => hasFingerprint(state, path[0]))
|
|
884
|
-
: states[path[0]],
|
|
885
|
-
).result;
|
|
886
|
-
if (!initial) throw new TlaEvaluationError(INITIAL_RECOVERY_FAILURE);
|
|
887
|
-
const steps: Successor[] = [{ state: initial, action: undefined }];
|
|
888
|
-
for (let position = 1; position < path.length; position++) {
|
|
889
|
-
const previous = steps[position - 1].state;
|
|
890
|
-
if (path[position - 1] === path[position]) {
|
|
891
|
-
steps.push({ state: previous, action: "Stuttering" });
|
|
892
|
-
continue;
|
|
893
|
-
}
|
|
894
|
-
const successor = findSuccessorWithFingerprint(previous, path[position]);
|
|
895
|
-
if (!successor) throw new TlaEvaluationError(nextFailure);
|
|
896
|
-
steps.push(successor);
|
|
897
|
-
}
|
|
898
|
-
return steps;
|
|
899
|
-
};
|
|
900
|
-
const getTrace = (index: number, lastSuccessor?: Successor) => {
|
|
901
|
-
const path: number[] = [];
|
|
902
|
-
for (let position = index; position !== -1; position = parents[position]) {
|
|
903
|
-
path.unshift(position);
|
|
904
|
-
}
|
|
905
|
-
const steps =
|
|
906
|
-
isReducing && path.length > 1
|
|
907
|
-
? getPathStates(path, INITIAL_RECOVERY_FAILURE)
|
|
908
|
-
: path.map((position) => ({ state: states[position], action: actions[position] }));
|
|
909
|
-
if (!lastSuccessor) return toTrace(steps, path);
|
|
910
|
-
const action = isReducing
|
|
911
|
-
? findTraceSuccessor(states[index], (successor) =>
|
|
912
|
-
isSameState(successor.state, lastSuccessor.state),
|
|
913
|
-
)?.action
|
|
914
|
-
: lastSuccessor.action;
|
|
915
|
-
return toTrace([...steps, { state: lastSuccessor.state, action }], path, { known: 2 });
|
|
916
|
-
};
|
|
917
|
-
// TLC prints a lone initial state without the alias. TLCTrace#getTrace still recovers it from the
|
|
918
|
-
// initial predicate, printing again, though TLC 1.7.4 doesn't.
|
|
919
|
-
const getStateTrace = (index: number): Behavior =>
|
|
920
|
-
parents[index] === -1
|
|
921
|
-
? {
|
|
922
|
-
trace: [{ action: undefined, label: undefined, state: toRecord(states[index]) }],
|
|
923
|
-
traceOutput: is174 ? [] : captureOutput(getSpecInitialStates).lines,
|
|
924
|
-
}
|
|
925
|
-
: getTrace(index);
|
|
926
|
-
// TLC rebuilds the trace again for the postcondition after it prints a violation, but not after
|
|
927
|
-
// an evaluation fails.
|
|
928
|
-
const getFailedTrace = (index: number, successor: Successor): Behavior => ({
|
|
929
|
-
trace: getTrace(index, successor).trace,
|
|
930
|
-
});
|
|
931
|
-
// TLC names the initial state it was checking unless a standard module's Java code failed.
|
|
932
|
-
const getFailureExitCode = (error: TlaEvaluationError, failureOptions: FailureOptions) => {
|
|
933
|
-
// TLC 1.7.4 exits with the result of its replay of the initial states, which only fails again
|
|
934
|
-
// when the error isn't in adding a state it has already seen to the behavior graph.
|
|
935
|
-
if (
|
|
936
|
-
failureOptions.isInitial &&
|
|
937
|
-
!failureOptions.callStack &&
|
|
938
|
-
!failureOptions.fingerprint &&
|
|
939
|
-
is174
|
|
940
|
-
) {
|
|
941
|
-
return EXIT_STATUS.success;
|
|
942
|
-
}
|
|
943
|
-
if (!failureOptions.callStack) {
|
|
944
|
-
return failureOptions.isInitial ? getInitialExitCode(error) : getErrorExitCode(error);
|
|
945
|
-
}
|
|
946
|
-
if (failureOptions.isCallStackFirst) return getErrorExitCode(error);
|
|
947
|
-
// Without a replay, TLC exits with the code of the error, as for any error it didn't expect.
|
|
948
|
-
if (failureOptions.isLiveCallStack) {
|
|
949
|
-
return (
|
|
950
|
-
getExitCode(error) ?? (error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.error)
|
|
951
|
-
);
|
|
769
|
+
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
770
|
+
return true;
|
|
952
771
|
}
|
|
953
|
-
// TLC exits with the code of a failed replay of the initial states regardless of the error, as
|
|
954
|
-
// it does for a replay that fails to fingerprint.
|
|
955
|
-
return failureOptions.isInitial || failureOptions.fingerprint
|
|
956
|
-
? EXIT_STATUS.specEvaluationFailure
|
|
957
|
-
: getReplayExitCode(error);
|
|
958
772
|
};
|
|
959
773
|
const createFailureResult = (
|
|
960
774
|
failed: unknown,
|
|
@@ -971,7 +785,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
971
785
|
const traceOutput = [...(behavior.traceOutput ?? []), ...(checked?.lines ?? [])];
|
|
972
786
|
return {
|
|
973
787
|
...createResult("error", undefined, {
|
|
974
|
-
...getFailureMessage(
|
|
788
|
+
...getFailureMessage(
|
|
789
|
+
error,
|
|
790
|
+
failureOptions.phase !== undefined && failureOptions.phase !== "initial",
|
|
791
|
+
),
|
|
975
792
|
...behavior,
|
|
976
793
|
...(traceOutput.length > 0 && { traceOutput }),
|
|
977
794
|
...(postcondition && { postcondition }),
|
|
@@ -979,33 +796,38 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
979
796
|
failureOptions.initialState && !(error instanceof TlaModuleError)
|
|
980
797
|
? toRecord(failureOptions.initialState)
|
|
981
798
|
: undefined,
|
|
982
|
-
exitCode: getFailureExitCode(error, failureOptions),
|
|
799
|
+
exitCode: getFailureExitCode(error, failureOptions, is174),
|
|
983
800
|
callStack: failureOptions.callStack,
|
|
984
|
-
...(failureOptions.
|
|
801
|
+
...(failureOptions.phase === "liveness" && { isCallStackFirst: true }),
|
|
985
802
|
...(failureOptions.fingerprint && { fingerprint: failureOptions.fingerprint }),
|
|
986
803
|
...(failureOptions.traceFailure && { traceFailure: failureOptions.traceFailure }),
|
|
987
804
|
}),
|
|
988
805
|
outDegrees: failureOptions.outDegrees,
|
|
989
806
|
};
|
|
990
807
|
};
|
|
991
|
-
// TLC reports a successor state that an action leaves incomplete with the trace to it, which ends
|
|
992
|
-
// with the partial state. It names the action when the next-state relation has several.
|
|
993
808
|
const reportIncompleteSuccessor = (index: number, error: TlaIncompleteSuccessorError) => {
|
|
994
809
|
runtime.generatedStates++;
|
|
995
|
-
const
|
|
810
|
+
const named =
|
|
811
|
+
nextActions.length === 1
|
|
812
|
+
? nextActions
|
|
813
|
+
: nextActions.filter((item) => item.name === error.action);
|
|
996
814
|
const action =
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const
|
|
1005
|
-
|
|
815
|
+
named.length === 1
|
|
816
|
+
? named[0]
|
|
817
|
+
: captureOutput(() =>
|
|
818
|
+
named.find((item) =>
|
|
819
|
+
hasIncompleteSuccessor(item.expression, states[index], environment, item.scope),
|
|
820
|
+
),
|
|
821
|
+
).result;
|
|
822
|
+
const message = getIncompleteSuccessorMessage(
|
|
823
|
+
error.variables,
|
|
824
|
+
error.action,
|
|
825
|
+
nextActions.length,
|
|
826
|
+
options.version,
|
|
827
|
+
);
|
|
1006
828
|
const undefinedValue = createModelValue("null");
|
|
1007
829
|
const partial = error.state.map((value) => value ?? undefinedValue);
|
|
1008
|
-
const failure = createFailureResult(error, getStateTrace(index));
|
|
830
|
+
const failure = createFailureResult(error, traces.getStateTrace(index));
|
|
1009
831
|
return withOutDegrees({
|
|
1010
832
|
...failure,
|
|
1011
833
|
failure: failure.failure && {
|
|
@@ -1025,72 +847,16 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1025
847
|
},
|
|
1026
848
|
});
|
|
1027
849
|
};
|
|
1028
|
-
const getPathSteps = (path: number[], loopStart?: number) => {
|
|
1029
|
-
const steps = getPathStates(path, NEXT_RECOVERY_FAILURE);
|
|
1030
|
-
const lastState = steps[steps.length - 1].state;
|
|
1031
|
-
const isClosed =
|
|
1032
|
-
!isReducing ||
|
|
1033
|
-
loopStart === undefined ||
|
|
1034
|
-
loopStart === path.length - 1 ||
|
|
1035
|
-
findSuccessorWithFingerprint(lastState, path[loopStart]) !== undefined;
|
|
1036
|
-
if (!isClosed) throw new TlaEvaluationError(NEXT_RECOVERY_FAILURE);
|
|
1037
|
-
return steps;
|
|
1038
|
-
};
|
|
1039
|
-
const getStateHash = (state: Value[]) => {
|
|
1040
|
-
let hash = 0x811c9dc5;
|
|
1041
|
-
for (let index = 0; index < state.length; index++)
|
|
1042
|
-
hash = combineHash(hash, getValueHash(state[index]));
|
|
1043
|
-
return hash & 0x3fffffff;
|
|
1044
|
-
};
|
|
1045
|
-
// TLC fingerprints a state once it finds the state in the model.
|
|
1046
850
|
const fingerprintModelState = (state: Value[]) => {
|
|
1047
851
|
for (const value of state) {
|
|
1048
852
|
const error = getFingerprintError(value);
|
|
1049
853
|
if (error) throw error;
|
|
1050
854
|
}
|
|
1051
855
|
};
|
|
1052
|
-
|
|
1053
|
-
for (let position = 0; position < state.length; position++) {
|
|
1054
|
-
if (!isSameValue(stored[position], state[position])) return false;
|
|
1055
|
-
}
|
|
1056
|
-
return true;
|
|
1057
|
-
};
|
|
1058
|
-
const getSlot = (hash: number) => (Math.imul(hash, 0x9e3779b1) >>> seenStates.shift) << 1;
|
|
1059
|
-
const findStateIndex = (hash: number, state: Value[]) => {
|
|
1060
|
-
const mask = seenStates.slots.length - 1;
|
|
1061
|
-
for (let slot = getSlot(hash); ; slot = (slot + 2) & mask) {
|
|
1062
|
-
const entry = seenStates.slots[slot + 1];
|
|
1063
|
-
if (entry === 0) return -1;
|
|
1064
|
-
if (seenStates.slots[slot] === hash && isSameState(fingerprintStates[entry - 1], state)) {
|
|
1065
|
-
return entry - 1;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
const insertSeen = (hash: number, entry: number) => {
|
|
1070
|
-
const mask = seenStates.slots.length - 1;
|
|
1071
|
-
let slot = getSlot(hash);
|
|
1072
|
-
while (seenStates.slots[slot + 1] !== 0) slot = (slot + 2) & mask;
|
|
1073
|
-
seenStates.slots[slot] = hash;
|
|
1074
|
-
seenStates.slots[slot + 1] = entry;
|
|
1075
|
-
};
|
|
1076
|
-
const markSeen = (hash: number, index: number) => {
|
|
1077
|
-
seenStates.size++;
|
|
1078
|
-
if (seenStates.size * 4 > seenStates.slots.length) {
|
|
1079
|
-
const slots = seenStates.slots;
|
|
1080
|
-
seenStates.slots = new Int32Array(slots.length * 2);
|
|
1081
|
-
seenStates.shift--;
|
|
1082
|
-
for (let slot = 0; slot < slots.length; slot += 2) {
|
|
1083
|
-
if (slots[slot + 1] !== 0) insertSeen(slots[slot], slots[slot + 1]);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
insertSeen(hash, index + 1);
|
|
1087
|
-
};
|
|
1088
|
-
// A new successor that TLC has added to its set of states before it checks the successor, which
|
|
1089
|
-
// the check stores after.
|
|
1090
|
-
const unstoredState = { fingerprint: undefined as Value[] | undefined };
|
|
856
|
+
let unstoredFingerprint: Value[] | undefined;
|
|
1091
857
|
const countDistinctState = (depth: number) => {
|
|
1092
858
|
runtime.distinctStates = states.length + 1;
|
|
1093
|
-
|
|
859
|
+
searchDepth = Math.max(searchDepth, depth);
|
|
1094
860
|
runtime.diameter = Math.max(runtime.diameter, depth);
|
|
1095
861
|
};
|
|
1096
862
|
const addState = (
|
|
@@ -1107,18 +873,41 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1107
873
|
depths.push(depth);
|
|
1108
874
|
};
|
|
1109
875
|
|
|
1110
|
-
const current = {
|
|
876
|
+
const current: SearchPosition = {
|
|
1111
877
|
index: -1,
|
|
1112
878
|
isExpanding: false,
|
|
1113
|
-
candidate: undefined
|
|
879
|
+
candidate: undefined,
|
|
1114
880
|
candidateLevel: 0,
|
|
1115
881
|
livenessSource: -1,
|
|
882
|
+
rebuilt: undefined,
|
|
1116
883
|
};
|
|
884
|
+
const traces = createTraceBuilder({
|
|
885
|
+
config,
|
|
886
|
+
options,
|
|
887
|
+
environment,
|
|
888
|
+
search,
|
|
889
|
+
nextActions,
|
|
890
|
+
current,
|
|
891
|
+
states,
|
|
892
|
+
fingerprintStates,
|
|
893
|
+
parents,
|
|
894
|
+
actions,
|
|
895
|
+
depths,
|
|
896
|
+
tracedSteps,
|
|
897
|
+
captureOutput,
|
|
898
|
+
getInitialStates: getSpecInitialStates,
|
|
899
|
+
findSuccessorAction: (state, isMatch) =>
|
|
900
|
+
coverage
|
|
901
|
+
? coverageActions.find((item) => getCoveredSuccessors(item, state).some(isMatch))
|
|
902
|
+
: nextActions.find((item) =>
|
|
903
|
+
getSuccessors(item.expression, state, environment, item.scope).some(isMatch),
|
|
904
|
+
),
|
|
905
|
+
});
|
|
1117
906
|
const getPath = (index: number): Value[][] =>
|
|
1118
907
|
index === -1 ? [] : [...getPath(parents[index]), states[index]];
|
|
1119
908
|
runtime.isSeen = (state) => {
|
|
1120
909
|
const fingerprintState = getFingerprintState(state);
|
|
1121
|
-
return findStateIndex(getStateHash(fingerprintState), fingerprintState) !== -1;
|
|
910
|
+
return findStateIndex(seenStates, getStateHash(fingerprintState), fingerprintState) !== -1;
|
|
1122
911
|
};
|
|
1123
912
|
runtime.getBehavior = (state) => {
|
|
1124
913
|
const index = state === current.candidate ? -1 : states.indexOf(state);
|
|
@@ -1130,11 +919,12 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1130
919
|
};
|
|
1131
920
|
runtime.getLevel = (state) => {
|
|
1132
921
|
const source = current.livenessSource;
|
|
1133
|
-
// TLC 1.7.4 reads the level of the state its worker explores, whichever state it evaluates.
|
|
1134
922
|
if (is174) {
|
|
1135
923
|
const explored = source !== -1 ? source : current.isExpanding ? current.index : -1;
|
|
1136
924
|
return explored === -1 ? 0 : depths[explored];
|
|
1137
925
|
}
|
|
926
|
+
const rebuilt = current.rebuilt;
|
|
927
|
+
if (rebuilt) return state === rebuilt.state ? rebuilt.level : rebuilt.level + 1;
|
|
1138
928
|
if (source !== -1) return state === states[source] ? depths[source] : depths[source] + 1;
|
|
1139
929
|
if (state === current.candidate) return current.candidateLevel;
|
|
1140
930
|
if (current.index === -1) return 0;
|
|
@@ -1142,6 +932,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1142
932
|
return current.isExpanding ? depths[current.index] + 1 : 0;
|
|
1143
933
|
};
|
|
1144
934
|
|
|
935
|
+
const getGraphAction = (action: SpecAction) => ({
|
|
936
|
+
name: action.name,
|
|
937
|
+
signature: getActionSignature(action),
|
|
938
|
+
});
|
|
1145
939
|
const getGraphState = (state: Value[], level: number): GraphState => ({
|
|
1146
940
|
fingerprint: BigInt.asIntN(64, runtime.getFingerprint(state)),
|
|
1147
941
|
level,
|
|
@@ -1149,7 +943,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1149
943
|
formatState(
|
|
1150
944
|
config.alias === undefined
|
|
1151
945
|
? toRecord(state)
|
|
1152
|
-
: evaluateAlias(config.alias, state, undefined),
|
|
946
|
+
: search.evaluateAlias(config.alias, state, undefined, options.isTool ?? false),
|
|
1153
947
|
),
|
|
1154
948
|
getText: () => formatState(toRecord(state)),
|
|
1155
949
|
});
|
|
@@ -1168,9 +962,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1168
962
|
fingerprintModelState(fingerprintState);
|
|
1169
963
|
state.forEach(markFingerprinted);
|
|
1170
964
|
}
|
|
1171
|
-
const isSeen = isInModel && findStateIndex(hash, fingerprintState) !== -1;
|
|
965
|
+
const isSeen = isInModel && findStateIndex(seenStates, hash, fingerprintState) !== -1;
|
|
1172
966
|
if (isSeen) return undefined;
|
|
1173
|
-
|
|
967
|
+
unstoredFingerprint = isInModel ? fingerprintState : undefined;
|
|
1174
968
|
if (isInModel) {
|
|
1175
969
|
countDistinctState(1);
|
|
1176
970
|
runtime.queueSize++;
|
|
@@ -1181,7 +975,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1181
975
|
search.getViolatedInvariants(state).forEach((invariant) =>
|
|
1182
976
|
reportContinuedViolation("invariant-violation", {
|
|
1183
977
|
name: invariant.name,
|
|
1184
|
-
...toTrace([{ action: undefined, state }], []),
|
|
978
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1185
979
|
}),
|
|
1186
980
|
);
|
|
1187
981
|
}
|
|
@@ -1189,21 +983,37 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1189
983
|
if (violated) {
|
|
1190
984
|
return reportViolation("invariant-violation", {
|
|
1191
985
|
name: violated.name,
|
|
1192
|
-
...toTrace([{ action: undefined, state }], []),
|
|
986
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1193
987
|
});
|
|
1194
988
|
}
|
|
1195
989
|
const failedPredicate = search.findFailedInitialPredicate(state);
|
|
1196
990
|
if (failedPredicate) {
|
|
1197
991
|
return reportViolation("liveness-violation", {
|
|
1198
992
|
name: failedPredicate.name,
|
|
1199
|
-
...toTrace([{ action: undefined, state }], []),
|
|
993
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1200
994
|
});
|
|
1201
995
|
}
|
|
1202
996
|
if (!isInModel) return undefined;
|
|
1203
|
-
|
|
997
|
+
markSeenState(seenStates, hash, states.length);
|
|
1204
998
|
addState(state, fingerprintState, -1, undefined);
|
|
1205
999
|
return undefined;
|
|
1206
1000
|
};
|
|
1001
|
+
// Looks a successor up, where the constraints keep it in the model, as the search does before it
|
|
1002
|
+
// checks the successor.
|
|
1003
|
+
const lookUpSuccessor = (state: Value[], successor: Successor) => {
|
|
1004
|
+
const fingerprintState = getFingerprintState(successor.state);
|
|
1005
|
+
const hash = getStateHash(fingerprintState);
|
|
1006
|
+
const foundIndex = findStateIndex(seenStates, hash, fingerprintState);
|
|
1007
|
+
const isStateInModel = search.satisfiesConstraints(successor.state, state);
|
|
1008
|
+
if (isStateInModel) search.trackStatePossible(successor.state);
|
|
1009
|
+
const isInModel = isStateInModel && search.satisfiesActionConstraints(state, successor.state);
|
|
1010
|
+
if (isInModel) {
|
|
1011
|
+
search.trackActionPossible(state, successor.state);
|
|
1012
|
+
fingerprintModelState(fingerprintState);
|
|
1013
|
+
successor.state.forEach(markFingerprinted);
|
|
1014
|
+
}
|
|
1015
|
+
return { fingerprintState, hash, isInModel, existing: isInModel ? foundIndex : -1 };
|
|
1016
|
+
};
|
|
1207
1017
|
const visitSuccessor = (
|
|
1208
1018
|
index: number,
|
|
1209
1019
|
successor: Successor,
|
|
@@ -1216,56 +1026,55 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1216
1026
|
current.candidate = successor.state;
|
|
1217
1027
|
current.candidateLevel = depths[index] + 1;
|
|
1218
1028
|
if (isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
const foundIndex = findStateIndex(hash, fingerprintState);
|
|
1222
|
-
const isStateInModel = search.satisfiesConstraints(successor.state, state);
|
|
1223
|
-
if (isStateInModel) search.trackStatePossible(successor.state);
|
|
1224
|
-
const isInModel = isStateInModel && search.satisfiesActionConstraints(state, successor.state);
|
|
1225
|
-
if (isInModel) {
|
|
1226
|
-
search.trackActionPossible(state, successor.state);
|
|
1227
|
-
fingerprintModelState(fingerprintState);
|
|
1228
|
-
successor.state.forEach(markFingerprinted);
|
|
1229
|
-
}
|
|
1230
|
-
const existing = isInModel ? foundIndex : -1;
|
|
1231
|
-
if (source && isInModel) {
|
|
1029
|
+
const found = lookUpSuccessor(state, successor);
|
|
1030
|
+
if (source && found.isInModel) {
|
|
1232
1031
|
stateWriter?.writeSuccessor(
|
|
1233
1032
|
source,
|
|
1234
1033
|
getGraphState(successor.state, depths[index] + 1),
|
|
1235
|
-
existing !== -1,
|
|
1236
|
-
action &&
|
|
1034
|
+
found.existing !== -1,
|
|
1035
|
+
action && getGraphAction(action),
|
|
1237
1036
|
);
|
|
1238
1037
|
}
|
|
1239
|
-
if (
|
|
1240
|
-
const
|
|
1038
|
+
if (source && !found.isInModel && options.dump?.constrained) {
|
|
1039
|
+
const excluded = getGraphState(successor.state, depths[index] + 1);
|
|
1040
|
+
search
|
|
1041
|
+
.getExcludingConstraints(state, successor.state)
|
|
1042
|
+
.forEach((constraint) =>
|
|
1043
|
+
stateWriter?.writeConstrained(
|
|
1044
|
+
source,
|
|
1045
|
+
excluded,
|
|
1046
|
+
action && getGraphAction(action),
|
|
1047
|
+
constraint,
|
|
1048
|
+
),
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
if (found.existing !== -1 && liveness) {
|
|
1052
|
+
const stored = states[found.existing];
|
|
1241
1053
|
const isStored = stored.every((value, position) => value === successor.state[position]);
|
|
1242
|
-
liveSuccessors.push({ index: existing, state: isStored ? stored : successor.state });
|
|
1054
|
+
liveSuccessors.push({ index: found.existing, state: isStored ? stored : successor.state });
|
|
1243
1055
|
}
|
|
1244
|
-
const isNew = isInModel && existing === -1;
|
|
1245
|
-
// TLC adds a new state to the behavior graph's successors before it checks the invariants.
|
|
1056
|
+
const isNew = found.isInModel && found.existing === -1;
|
|
1246
1057
|
if (isNew && liveness) liveSuccessors.push({ index: states.length, state: successor.state });
|
|
1247
|
-
|
|
1058
|
+
unstoredFingerprint = isNew ? found.fingerprintState : undefined;
|
|
1248
1059
|
if (isNew) {
|
|
1249
1060
|
countDistinctState(depths[index] + 1);
|
|
1250
|
-
|
|
1061
|
+
newStateCount++;
|
|
1062
|
+
if (coverage) coverage.secondary[coveredNode]++;
|
|
1251
1063
|
}
|
|
1252
|
-
if (existing === -1) {
|
|
1064
|
+
if (found.existing === -1) {
|
|
1253
1065
|
try {
|
|
1254
1066
|
const violated = search.findViolatedInvariant(successor.state, state);
|
|
1255
|
-
const violation = violated && { name: violated.name, ...getTrace(index, successor) };
|
|
1067
|
+
const violation = violated && { name: violated.name, ...traces.getTrace(index, successor) };
|
|
1256
1068
|
if (violation && !options.isContinued) {
|
|
1257
1069
|
return withOutDegrees(reportViolation("invariant-violation", violation));
|
|
1258
1070
|
}
|
|
1259
1071
|
if (violation) reportContinuedViolation("invariant-violation", violation);
|
|
1260
1072
|
} catch (error) {
|
|
1261
1073
|
if (isStackOverflow(error)) throw error;
|
|
1262
|
-
// TLC replays the expansion and skips the invariants of a state it has seen, the failed one
|
|
1263
|
-
// included unless the constraints exclude it. When the replay fails, TLC reports where and
|
|
1264
|
-
// leaves out the outdegree.
|
|
1265
1074
|
const replay = captureOutput(() => replayNext(index));
|
|
1266
1075
|
return createFailureResult(
|
|
1267
1076
|
error,
|
|
1268
|
-
appendTraceOutput(getFailedTrace(index, successor), replay.lines),
|
|
1077
|
+
appendTraceOutput(traces.getFailedTrace(index, successor), replay.lines),
|
|
1269
1078
|
replay.result ?? { outDegrees: getFailureOutDegrees() },
|
|
1270
1079
|
);
|
|
1271
1080
|
}
|
|
@@ -1273,53 +1082,126 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1273
1082
|
const violatedProperty = search.findViolatedActionProperty(state, successor.state);
|
|
1274
1083
|
const propertyViolation = violatedProperty && {
|
|
1275
1084
|
name: violatedProperty.name,
|
|
1276
|
-
...getTrace(index, successor),
|
|
1085
|
+
...traces.getTrace(index, successor),
|
|
1277
1086
|
};
|
|
1278
1087
|
if (propertyViolation && !options.isContinued) {
|
|
1279
1088
|
return withOutDegrees(reportViolation("liveness-violation", propertyViolation));
|
|
1280
1089
|
}
|
|
1281
1090
|
if (propertyViolation) reportContinuedViolation("liveness-violation", propertyViolation);
|
|
1282
1091
|
if (!isNew) return undefined;
|
|
1092
|
+
if (coverage) countCoverageVariables(coverage, successor.state);
|
|
1283
1093
|
if (!isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1284
|
-
|
|
1285
|
-
addState(successor.state, fingerprintState, index, successor.action);
|
|
1094
|
+
markSeenState(seenStates, found.hash, states.length);
|
|
1095
|
+
addState(successor.state, found.fingerprintState, index, successor.action);
|
|
1286
1096
|
runtime.queueSize++;
|
|
1287
1097
|
return undefined;
|
|
1288
1098
|
};
|
|
1289
1099
|
|
|
1290
|
-
|
|
1100
|
+
let outcome: CheckResult | undefined;
|
|
1101
|
+
let coveredNode = -1;
|
|
1291
1102
|
if (liveness) {
|
|
1292
1103
|
options.onProgress?.({ kind: "liveness-prepared", branches: liveness.branches });
|
|
1293
1104
|
}
|
|
1294
|
-
// TLC checks the assumptions once it has built the liveness checker in ModelChecker's
|
|
1295
|
-
// constructor.
|
|
1296
1105
|
const assumptionViolation = findViolatedAssumption();
|
|
1297
1106
|
if (assumptionViolation) return createResult("assumption-violation", assumptionViolation);
|
|
1298
1107
|
options.onProgress?.({ kind: "initial-states-started" });
|
|
1108
|
+
const typedChecks =
|
|
1109
|
+
!options.isContinued &&
|
|
1110
|
+
options.dump === undefined &&
|
|
1111
|
+
// A set of small integers on the tier is a 31-bit mask, which a lower bound could overflow.
|
|
1112
|
+
options.maxSetSize === undefined &&
|
|
1113
|
+
!hasPostconditions
|
|
1114
|
+
? search.getTypedChecks(liveness?.solutions)
|
|
1115
|
+
: undefined;
|
|
1116
|
+
const typed =
|
|
1117
|
+
typedChecks &&
|
|
1118
|
+
runTypedSearch(environment, {
|
|
1119
|
+
...typedChecks,
|
|
1120
|
+
isDeadlockChecked: config.checkDeadlock,
|
|
1121
|
+
isFingerprinted: !options.isFingerprintDistanceSkipped,
|
|
1122
|
+
livenessCheck: options.livenessCheck ?? "default",
|
|
1123
|
+
});
|
|
1124
|
+
if (typed && !typed.deadlock && !typed.violation && !typed.lasso) {
|
|
1125
|
+
for (let count = 2; count < typed.initialStates.generated; count *= 2) {
|
|
1126
|
+
reportInitialStatesProgress(count, options.onProgress);
|
|
1127
|
+
}
|
|
1128
|
+
options.onProgress?.({ kind: "initial-states-computed", initialStates: typed.initialStates });
|
|
1129
|
+
const statistics = {
|
|
1130
|
+
...createResult("success"),
|
|
1131
|
+
generatedStates: typed.generatedStates,
|
|
1132
|
+
distinctStates: typed.distinctStates,
|
|
1133
|
+
queuedStates: 0,
|
|
1134
|
+
depth: typed.generatedStates === 0 ? 0 : Math.max(typed.depth, 1),
|
|
1135
|
+
initialStates: typed.initialStates,
|
|
1136
|
+
};
|
|
1137
|
+
if (liveness && options.livenessCheck !== "off") {
|
|
1138
|
+
options.onProgress?.({
|
|
1139
|
+
kind: "liveness-started",
|
|
1140
|
+
branches: liveness.branches,
|
|
1141
|
+
isComplete: true,
|
|
1142
|
+
states: typed.distinctStates,
|
|
1143
|
+
statistics,
|
|
1144
|
+
});
|
|
1145
|
+
options.onProgress?.({ kind: "liveness-finished" });
|
|
1146
|
+
}
|
|
1147
|
+
return {
|
|
1148
|
+
...statistics,
|
|
1149
|
+
outDegrees: typed.outDegrees,
|
|
1150
|
+
fingerprintDistance: options.isFingerprintDistanceSkipped
|
|
1151
|
+
? undefined
|
|
1152
|
+
: getFingerprintDistance(
|
|
1153
|
+
typed.distinctStates,
|
|
1154
|
+
typed.generatedStates,
|
|
1155
|
+
typed.forEachFingerprintRun,
|
|
1156
|
+
),
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1299
1159
|
if (spec.init !== undefined) {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
outcome.result = visitInitialState(state);
|
|
1308
|
-
} catch (error) {
|
|
1309
|
-
const replay = captureOutput(replayInit);
|
|
1310
|
-
outcome.result = createFailureResult(
|
|
1311
|
-
error,
|
|
1312
|
-
{ trace: [], traceOutput: replay.lines },
|
|
1313
|
-
{ initialState: state, ...replay.result, isInitial: true },
|
|
1314
|
-
);
|
|
1315
|
-
}
|
|
1316
|
-
return outcome.result !== undefined;
|
|
1317
|
-
},
|
|
1318
|
-
spec.scope,
|
|
1160
|
+
let overflowState: Value[] | undefined;
|
|
1161
|
+
const reportInitialFailure = (error: unknown, state: Value[]) => {
|
|
1162
|
+
const replay = captureOutput(replayInit);
|
|
1163
|
+
return createFailureResult(
|
|
1164
|
+
error,
|
|
1165
|
+
{ trace: [], traceOutput: replay.lines },
|
|
1166
|
+
{ initialState: state, ...replay.result, phase: "initial" },
|
|
1319
1167
|
);
|
|
1168
|
+
};
|
|
1169
|
+
try {
|
|
1170
|
+
const onInitialState = (state: Value[]) => {
|
|
1171
|
+
reportInitialStatesProgress(runtime.initialStates, options.onProgress);
|
|
1172
|
+
if (overflowState) {
|
|
1173
|
+
runtime.generatedStates++;
|
|
1174
|
+
runtime.initialStates++;
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
try {
|
|
1178
|
+
outcome = visitInitialState(state);
|
|
1179
|
+
} catch (error) {
|
|
1180
|
+
if (isStackOverflow(error)) overflowState = state;
|
|
1181
|
+
else outcome = reportInitialFailure(error, state);
|
|
1182
|
+
}
|
|
1183
|
+
return outcome !== undefined;
|
|
1184
|
+
};
|
|
1185
|
+
if (coverage) {
|
|
1186
|
+
try {
|
|
1187
|
+
replayInitialStates(
|
|
1188
|
+
coverageInits,
|
|
1189
|
+
environment,
|
|
1190
|
+
(state) => {
|
|
1191
|
+
if (onInitialState(state)) throw STOP_WALK;
|
|
1192
|
+
},
|
|
1193
|
+
rejectIncompleteInitialState,
|
|
1194
|
+
);
|
|
1195
|
+
} catch (error) {
|
|
1196
|
+
if (error !== STOP_WALK) throw error;
|
|
1197
|
+
}
|
|
1198
|
+
} else {
|
|
1199
|
+
forEachInitialState(spec.init, environment, onInitialState, spec.scope);
|
|
1200
|
+
}
|
|
1201
|
+
if (overflowState) {
|
|
1202
|
+
outcome = reportInitialFailure(createStackOverflowError(), overflowState);
|
|
1203
|
+
}
|
|
1320
1204
|
} catch (error) {
|
|
1321
|
-
// TLC prints an illegal initial state with null for each variable it leaves undefined, and
|
|
1322
|
-
// stops before it prints the statistics.
|
|
1323
1205
|
if (error instanceof TlaIllegalStateError) {
|
|
1324
1206
|
const illegal = createFailureResult(
|
|
1325
1207
|
error,
|
|
@@ -1331,23 +1213,22 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1331
1213
|
failure: illegal.failure && { ...illegal.failure, isWithoutStatistics: true },
|
|
1332
1214
|
};
|
|
1333
1215
|
}
|
|
1334
|
-
// TLC prints the error before it replays the initial predicate with its call stack.
|
|
1335
1216
|
const replay = captureOutput(replayInit);
|
|
1336
1217
|
return createFailureResult(
|
|
1337
1218
|
error,
|
|
1338
1219
|
{ trace: [], traceOutput: replay.lines },
|
|
1339
|
-
{ ...replay.result,
|
|
1220
|
+
{ ...replay.result, phase: "initial" },
|
|
1340
1221
|
);
|
|
1341
1222
|
}
|
|
1342
1223
|
}
|
|
1343
|
-
if (outcome
|
|
1344
|
-
|
|
1224
|
+
if (outcome) return outcome;
|
|
1225
|
+
computedInitialStates = {
|
|
1345
1226
|
generated: runtime.initialStates,
|
|
1346
1227
|
distinct: runtime.distinctStates,
|
|
1347
1228
|
};
|
|
1348
1229
|
options.onProgress?.({
|
|
1349
1230
|
kind: "initial-states-computed",
|
|
1350
|
-
initialStates:
|
|
1231
|
+
initialStates: computedInitialStates,
|
|
1351
1232
|
});
|
|
1352
1233
|
|
|
1353
1234
|
const next = spec.next;
|
|
@@ -1359,15 +1240,31 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1359
1240
|
}
|
|
1360
1241
|
return createSuccess();
|
|
1361
1242
|
}
|
|
1362
|
-
// TLC labels and colors an edge of the -dump state graph by the action that generated it. When
|
|
1363
|
-
// the graph names its edges, the search generates successors action by action, as TLC does.
|
|
1364
1243
|
const isNamingEdges = Boolean(
|
|
1365
1244
|
options.dump?.dot && (options.dump.actionLabels || options.dump.colorize),
|
|
1366
1245
|
);
|
|
1367
1246
|
const forEachActionSuccessor = (
|
|
1368
1247
|
state: Value[],
|
|
1248
|
+
onUnsatisfied:
|
|
1249
|
+
| ((successor: Value[], conjunct: Expression, action?: SpecAction) => void)
|
|
1250
|
+
| undefined,
|
|
1369
1251
|
onSuccessor: (successor: Successor, action: SpecAction | undefined) => boolean,
|
|
1370
1252
|
) => {
|
|
1253
|
+
if (coverage) {
|
|
1254
|
+
let successorCount = 0;
|
|
1255
|
+
try {
|
|
1256
|
+
coverageActions.forEach((action) => {
|
|
1257
|
+
coveredNode = action.node;
|
|
1258
|
+
walkCoveredSuccessors(action, state, (successor) => {
|
|
1259
|
+
successorCount++;
|
|
1260
|
+
if (onSuccessor({ state: successor, action: action.name }, action)) throw STOP_WALK;
|
|
1261
|
+
});
|
|
1262
|
+
});
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
if (error !== STOP_WALK) throw error;
|
|
1265
|
+
}
|
|
1266
|
+
return successorCount;
|
|
1267
|
+
}
|
|
1371
1268
|
if (!isNamingEdges) {
|
|
1372
1269
|
return forEachSuccessor(
|
|
1373
1270
|
next,
|
|
@@ -1375,11 +1272,13 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1375
1272
|
environment,
|
|
1376
1273
|
(successor) => onSuccessor(successor, undefined),
|
|
1377
1274
|
spec.scope,
|
|
1275
|
+
undefined,
|
|
1276
|
+
onUnsatisfied,
|
|
1378
1277
|
);
|
|
1379
1278
|
}
|
|
1380
|
-
|
|
1381
|
-
return
|
|
1382
|
-
if (
|
|
1279
|
+
let isStopped = false;
|
|
1280
|
+
return nextActions.reduce((count, action) => {
|
|
1281
|
+
if (isStopped) return count;
|
|
1383
1282
|
return (
|
|
1384
1283
|
count +
|
|
1385
1284
|
forEachSuccessor(
|
|
@@ -1387,27 +1286,23 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1387
1286
|
state,
|
|
1388
1287
|
environment,
|
|
1389
1288
|
(successor) => {
|
|
1390
|
-
|
|
1391
|
-
return
|
|
1289
|
+
isStopped = onSuccessor(successor, action);
|
|
1290
|
+
return isStopped;
|
|
1392
1291
|
},
|
|
1393
1292
|
action.scope,
|
|
1293
|
+
undefined,
|
|
1294
|
+
onUnsatisfied && ((successor, conjunct) => onUnsatisfied(successor, conjunct, action)),
|
|
1394
1295
|
)
|
|
1395
1296
|
);
|
|
1396
1297
|
}, 0);
|
|
1397
1298
|
};
|
|
1398
|
-
// TLC's worker adds a state to the behavior graph even after its next states fail or violate a
|
|
1399
|
-
// property, and prints the call stack of an error in that, unless the error is a
|
|
1400
|
-
// FingerprintException, which the worker doesn't catch. TLC 1.7.4 prints none.
|
|
1401
1299
|
const getLiveCallStack = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1402
1300
|
if (!liveness || is174) return undefined;
|
|
1403
|
-
const replay = getReplayFailure((tracing) =>
|
|
1301
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1404
1302
|
liveness.addState(index, states[index], liveSuccessors, tracing),
|
|
1405
1303
|
);
|
|
1406
1304
|
return replay?.callStack.length && !replay.fingerprint ? replay.callStack : undefined;
|
|
1407
1305
|
};
|
|
1408
|
-
// TLC's worker adds the state to the behavior graph after it prints the trace. On an error in that,
|
|
1409
|
-
// it adds the state again to print the call stack instead of replaying the next-state relation,
|
|
1410
|
-
// which TLC 1.7.4 doesn't.
|
|
1411
1306
|
const addFailedLiveState = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1412
1307
|
try {
|
|
1413
1308
|
liveness?.addState(index, states[index], liveSuccessors);
|
|
@@ -1420,17 +1315,14 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1420
1315
|
const replayFailedNext = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1421
1316
|
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
1422
1317
|
if (live.result) {
|
|
1423
|
-
const result = { callStack: live.result
|
|
1318
|
+
const result: FailureOptions = { phase: "behavior-graph", callStack: live.result };
|
|
1424
1319
|
return { result, lines: live.lines };
|
|
1425
1320
|
}
|
|
1426
1321
|
const replay = captureOutput(() => replayNext(index));
|
|
1427
1322
|
return { result: replay.result, lines: [...live.lines, ...replay.lines] };
|
|
1428
1323
|
};
|
|
1429
|
-
// TLC reports a stack overflow while it computes next states without replaying it, with the
|
|
1430
|
-
// behavior up to the state it expands.
|
|
1431
1324
|
const reportNextStateOverflow = (index: number) =>
|
|
1432
|
-
createFailureResult(createStackOverflowError(), getStateTrace(index));
|
|
1433
|
-
// After the trace, TLC replays the next-state relation with its call stack, printing again.
|
|
1325
|
+
createFailureResult(createStackOverflowError(), traces.getStateTrace(index), { phase: "next" });
|
|
1434
1326
|
const reportNextStateFailure = (
|
|
1435
1327
|
error: unknown,
|
|
1436
1328
|
index: number,
|
|
@@ -1440,40 +1332,43 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1440
1332
|
const replay = replayFailedNext(index, liveSuccessors);
|
|
1441
1333
|
return createFailureResult(
|
|
1442
1334
|
withNextStateExitCode(error),
|
|
1443
|
-
appendTraceOutput(getStateTrace(index), replay.lines),
|
|
1444
|
-
{
|
|
1335
|
+
appendTraceOutput(traces.getStateTrace(index), replay.lines),
|
|
1336
|
+
{ phase: "next", ...replay.result },
|
|
1445
1337
|
);
|
|
1446
1338
|
};
|
|
1447
1339
|
const expandState = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1448
1340
|
const state = states[index];
|
|
1449
1341
|
const source = stateWriter && getGraphState(state, depths[index]);
|
|
1450
|
-
const
|
|
1342
|
+
const writeUnsatisfied =
|
|
1343
|
+
source && options.dump?.constrained
|
|
1344
|
+
? (successor: Value[], conjunct: Expression, action?: SpecAction) =>
|
|
1345
|
+
stateWriter?.writeConstrained(
|
|
1346
|
+
source,
|
|
1347
|
+
getGraphState(successor, depths[index] + 1),
|
|
1348
|
+
action && getGraphAction(action),
|
|
1349
|
+
describeRange(conjunct),
|
|
1350
|
+
)
|
|
1351
|
+
: undefined;
|
|
1352
|
+
const successorCount = forEachActionSuccessor(state, writeUnsatisfied, (successor, action) => {
|
|
1451
1353
|
try {
|
|
1452
|
-
outcome
|
|
1354
|
+
outcome = visitSuccessor(index, successor, liveSuccessors, source, action);
|
|
1453
1355
|
} catch (error) {
|
|
1454
1356
|
if (isStackOverflow(error)) {
|
|
1455
|
-
outcome
|
|
1357
|
+
outcome = reportNextStateOverflow(index);
|
|
1456
1358
|
return true;
|
|
1457
1359
|
}
|
|
1458
|
-
// TLC 1.7.4 reports the wrapped error without the trace, except for a failed property,
|
|
1459
|
-
// which it reports with the trace before it rethrows. The error stops its worker before it
|
|
1460
|
-
// adds the state to the behavior graph.
|
|
1461
1360
|
const replay = is174
|
|
1462
1361
|
? captureOutput(() => replayNext(index))
|
|
1463
1362
|
: replayFailedNext(index, liveSuccessors);
|
|
1464
1363
|
if (is174 && error instanceof TlaEvaluationError && !isHeadedError(error)) {
|
|
1465
|
-
outcome
|
|
1364
|
+
outcome = createFailureResult(
|
|
1466
1365
|
new TlaEvaluationError(`${getWrappedException(error)}${error.message}`, error),
|
|
1467
1366
|
appendTraceOutput({ trace: [] }, replay.lines),
|
|
1468
|
-
{
|
|
1367
|
+
{ phase: "next", ...replay.result },
|
|
1469
1368
|
);
|
|
1470
1369
|
return true;
|
|
1471
1370
|
}
|
|
1472
|
-
|
|
1473
|
-
// reports as an exception it didn't expect.
|
|
1474
|
-
const isTraceFailed = getFingerprintState(successor.state).some(
|
|
1475
|
-
(value) => getFingerprintError(value) !== undefined,
|
|
1476
|
-
);
|
|
1371
|
+
const isTraceFailed = isUnfingerprintable(successor.state);
|
|
1477
1372
|
const traceFailure =
|
|
1478
1373
|
isTraceFailed && error instanceof TlaEvaluationError
|
|
1479
1374
|
? getFailureMessage(
|
|
@@ -1483,20 +1378,19 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1483
1378
|
true,
|
|
1484
1379
|
)
|
|
1485
1380
|
: undefined;
|
|
1486
|
-
outcome
|
|
1381
|
+
outcome = createFailureResult(
|
|
1487
1382
|
error,
|
|
1488
1383
|
appendTraceOutput(
|
|
1489
|
-
traceFailure ? getStateTrace(index) : getFailedTrace(index, successor),
|
|
1384
|
+
traceFailure ? traces.getStateTrace(index) : traces.getFailedTrace(index, successor),
|
|
1490
1385
|
replay.lines,
|
|
1491
1386
|
),
|
|
1492
|
-
{
|
|
1387
|
+
{ phase: "next", ...replay.result, traceFailure },
|
|
1493
1388
|
);
|
|
1494
1389
|
}
|
|
1495
|
-
return outcome
|
|
1390
|
+
return outcome !== undefined;
|
|
1496
1391
|
});
|
|
1497
1392
|
current.isExpanding = false;
|
|
1498
|
-
const result = outcome
|
|
1499
|
-
// TLC 1.7.4's worker stops at a violation.
|
|
1393
|
+
const result = outcome;
|
|
1500
1394
|
if (result?.violation && !is174) {
|
|
1501
1395
|
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
1502
1396
|
return {
|
|
@@ -1507,10 +1401,12 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1507
1401
|
}
|
|
1508
1402
|
if (result) return result;
|
|
1509
1403
|
const addLiveState = () => {
|
|
1510
|
-
if (liveness && source && is174
|
|
1404
|
+
if (liveness && source && (is174 || options.dump?.stuttering)) {
|
|
1405
|
+
stateWriter?.writeStuttering(source);
|
|
1406
|
+
}
|
|
1511
1407
|
const accepted = liveness?.addState(index, state, liveSuccessors);
|
|
1512
1408
|
if (!liveness || !accepted) return undefined;
|
|
1513
|
-
const steps = getPathSteps(accepted);
|
|
1409
|
+
const steps = traces.getPathSteps(accepted);
|
|
1514
1410
|
const properties = getViolatedProperties(
|
|
1515
1411
|
liveness,
|
|
1516
1412
|
steps.map((step) => step.state),
|
|
@@ -1519,14 +1415,14 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1519
1415
|
return reportViolation("property-violation", {
|
|
1520
1416
|
name: properties[0],
|
|
1521
1417
|
properties,
|
|
1522
|
-
...toTrace(steps, accepted, { known: 0 }),
|
|
1418
|
+
...traces.toTrace(steps, accepted, { known: 0 }),
|
|
1523
1419
|
});
|
|
1524
1420
|
};
|
|
1525
1421
|
if (successorCount === 0 && config.checkDeadlock) {
|
|
1526
|
-
const deadlock = reportViolation("deadlock", {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1422
|
+
const deadlock = reportViolation("deadlock", {
|
|
1423
|
+
name: "deadlock",
|
|
1424
|
+
...traces.getStateTrace(index),
|
|
1425
|
+
});
|
|
1530
1426
|
const live = captureOutput(() => {
|
|
1531
1427
|
try {
|
|
1532
1428
|
return { additional: addLiveState()?.violation };
|
|
@@ -1538,7 +1434,6 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1538
1434
|
const reported = deadlock.violation
|
|
1539
1435
|
? { ...deadlock, violation: appendTraceOutput(deadlock.violation, live.lines) }
|
|
1540
1436
|
: deadlock;
|
|
1541
|
-
// An error in adding the state stops TLC 1.7.4's worker before it counts the state.
|
|
1542
1437
|
const counted = withOutDegrees(
|
|
1543
1438
|
reported,
|
|
1544
1439
|
live.result.isFailed ? getFailureOutDegrees() : getPartialOutDegrees(),
|
|
@@ -1550,8 +1445,6 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1550
1445
|
try {
|
|
1551
1446
|
return addLiveState();
|
|
1552
1447
|
} catch (error) {
|
|
1553
|
-
// TLC 1.7.4's worker reports an error in adding a state to the behavior graph as an exception
|
|
1554
|
-
// it didn't expect, without the trace or a call stack, and exits as for any general error.
|
|
1555
1448
|
if (is174 && error instanceof TlaEvaluationError) {
|
|
1556
1449
|
const unexpected = new TlaEvaluationError(
|
|
1557
1450
|
`${isEvalException(error) ? UNEXPECTED_EVAL_EXCEPTION : UNEXPECTED_EXCEPTION}${error.message}`,
|
|
@@ -1562,20 +1455,16 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1562
1455
|
{ outDegrees: getFailureOutDegrees() },
|
|
1563
1456
|
);
|
|
1564
1457
|
}
|
|
1565
|
-
|
|
1566
|
-
// before the error, and reports the error as one in computing next states.
|
|
1567
|
-
const replay = getReplayFailure((tracing) =>
|
|
1458
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1568
1459
|
liveness?.addState(index, state, liveSuccessors, tracing),
|
|
1569
1460
|
);
|
|
1570
|
-
return createFailureResult(error, getStateTrace(index), {
|
|
1461
|
+
return createFailureResult(error, traces.getStateTrace(index), {
|
|
1571
1462
|
outDegrees: getFailureOutDegrees(),
|
|
1572
1463
|
callStack: replay?.callStack.length ? replay.callStack : undefined,
|
|
1573
|
-
|
|
1574
|
-
isCallStackFirst: true,
|
|
1464
|
+
phase: "liveness",
|
|
1575
1465
|
});
|
|
1576
1466
|
}
|
|
1577
1467
|
};
|
|
1578
|
-
// TLC's Liveness#printStutteringCounterExampleWarning.
|
|
1579
1468
|
const getStutteringWarning = () => {
|
|
1580
1469
|
const name = config.specification;
|
|
1581
1470
|
const book =
|
|
@@ -1593,12 +1482,11 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1593
1482
|
text: `The stuttering counterexample above may be caused by the absence of a fairness constraint in the behavior specification ${name} defined at ${formatRange(range)}. To rule out such counterexamples, conjoin a suitable fairness constraint to ${name} ${book}`,
|
|
1594
1483
|
};
|
|
1595
1484
|
};
|
|
1596
|
-
// TLC names the properties and the step back into the cycle from the states it prints.
|
|
1597
1485
|
const reportLasso = (checker: LivenessChecker, lasso: Lasso) => {
|
|
1598
1486
|
const path = [...lasso.prefix, ...lasso.cycle];
|
|
1599
1487
|
const loopStart = lasso.prefix.length;
|
|
1600
|
-
const steps = getPathSteps(path, loopStart);
|
|
1601
|
-
const trace = toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1488
|
+
const steps = traces.getPathSteps(path, loopStart);
|
|
1489
|
+
const trace = traces.toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1602
1490
|
const properties = getViolatedProperties(
|
|
1603
1491
|
checker,
|
|
1604
1492
|
steps.map((step) => step.state),
|
|
@@ -1610,7 +1498,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1610
1498
|
const loop =
|
|
1611
1499
|
cycleStart === cycleEnd
|
|
1612
1500
|
? { result: undefined, lines: [] }
|
|
1613
|
-
: captureOutput(() =>
|
|
1501
|
+
: captureOutput(() =>
|
|
1502
|
+
traces.findStepAction(cycleEnd, lastState, states[cycleStart], false),
|
|
1503
|
+
);
|
|
1614
1504
|
const isStutteringWarned = cycleStart === cycleEnd && lasso.isCycleConstrained;
|
|
1615
1505
|
return reportViolation(
|
|
1616
1506
|
"liveness-violation",
|
|
@@ -1628,12 +1518,19 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1628
1518
|
? getStepAction(trace[trace.length - 1])
|
|
1629
1519
|
: loop.result
|
|
1630
1520
|
? toActionValue(loop.result)
|
|
1631
|
-
: createActionRecord(
|
|
1521
|
+
: createActionRecord(
|
|
1522
|
+
traces.findSuccessorWithFingerprint(lastState, cycleStart)?.action,
|
|
1523
|
+
),
|
|
1632
1524
|
);
|
|
1633
1525
|
};
|
|
1634
|
-
const isPeriodic = liveness !== undefined && options.livenessCheck
|
|
1526
|
+
const isPeriodic = liveness !== undefined && (options.livenessCheck ?? "default") === "default";
|
|
1635
1527
|
const startedAt = performance.now();
|
|
1636
|
-
const periodic = {
|
|
1528
|
+
const periodic = {
|
|
1529
|
+
at: startedAt + PERIODIC_START,
|
|
1530
|
+
size: 1,
|
|
1531
|
+
time: 0,
|
|
1532
|
+
coverageCount: Math.trunc(options.coverage ?? 0),
|
|
1533
|
+
};
|
|
1637
1534
|
const findPeriodicViolation = (expanded: number) => {
|
|
1638
1535
|
const now = performance.now();
|
|
1639
1536
|
const isGrown = (expanded - periodic.size) / periodic.size > LIVENESS_GROWTH;
|
|
@@ -1652,62 +1549,180 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1652
1549
|
periodic.time += performance.now() - now;
|
|
1653
1550
|
return lasso;
|
|
1654
1551
|
};
|
|
1655
|
-
|
|
1552
|
+
const adoptTypedSearch = (searched: TypedResult) => {
|
|
1553
|
+
runtime.generatedStates = searched.generatedStates;
|
|
1554
|
+
runtime.distinctStates = searched.distinctStates;
|
|
1555
|
+
runtime.queueSize = searched.queuedStates;
|
|
1556
|
+
runtime.diameter = searched.depth;
|
|
1557
|
+
searchDepth = searched.depth;
|
|
1558
|
+
outDegrees.splice(0, outDegrees.length, ...searched.outDegrees);
|
|
1559
|
+
newStateCount = 0;
|
|
1560
|
+
};
|
|
1561
|
+
// The tier found a state without successors, or a successor that violates an invariant or an
|
|
1562
|
+
// action property. The interpreter rebuilds the tier's path to it and reports it, as it would after
|
|
1563
|
+
// its own search.
|
|
1564
|
+
const path = typed?.deadlock ?? typed?.violation;
|
|
1565
|
+
const initialIndex = path ? states.findIndex((state) => path.isPathState(0, state)) : -1;
|
|
1566
|
+
if (typed && path && initialIndex !== -1) {
|
|
1567
|
+
const steps: { successor: Successor; action: SpecAction | undefined }[] = [];
|
|
1568
|
+
const getLastState = () => steps.at(-1)?.successor.state ?? states[initialIndex];
|
|
1569
|
+
for (let position = 1; position === steps.length + 1 && position < path.length; position++) {
|
|
1570
|
+
// The interpreter expands only the states it stores, which it has canonicalized.
|
|
1571
|
+
canonicalizeState(getLastState());
|
|
1572
|
+
forEachActionSuccessor(getLastState(), undefined, (successor, action) => {
|
|
1573
|
+
if (!path.isPathState(position, successor.state)) return false;
|
|
1574
|
+
steps.push({ successor, action });
|
|
1575
|
+
return true;
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
const isRebuilt = steps.length === path.length - 1;
|
|
1579
|
+
const violating = typed.violation && isRebuilt ? steps.pop() : undefined;
|
|
1580
|
+
if (violating && isCanonicalizedFirst) canonicalizeState(violating.successor.state);
|
|
1581
|
+
const violatedInvariant =
|
|
1582
|
+
violating && search.findViolatedInvariant(violating.successor.state, getLastState());
|
|
1583
|
+
const violatedProperty =
|
|
1584
|
+
violating &&
|
|
1585
|
+
!violatedInvariant &&
|
|
1586
|
+
search.findViolatedActionProperty(getLastState(), violating.successor.state);
|
|
1587
|
+
const violated = violatedInvariant ?? violatedProperty;
|
|
1588
|
+
const isDeadlocked =
|
|
1589
|
+
typed.deadlock !== undefined &&
|
|
1590
|
+
isRebuilt &&
|
|
1591
|
+
forEachActionSuccessor(getLastState(), undefined, () => true) === 0;
|
|
1592
|
+
if (isDeadlocked || violated) {
|
|
1593
|
+
const parent = { index: initialIndex };
|
|
1594
|
+
for (const step of steps) {
|
|
1595
|
+
visitSuccessor(parent.index, step.successor, [], undefined, step.action);
|
|
1596
|
+
parent.index = states.length - 1;
|
|
1597
|
+
}
|
|
1598
|
+
adoptTypedSearch(typed);
|
|
1599
|
+
Object.assign(current, { index: parent.index, candidate: undefined, isExpanding: true });
|
|
1600
|
+
if (violating && violated) {
|
|
1601
|
+
lookUpSuccessor(states[parent.index], violating.successor);
|
|
1602
|
+
current.candidate = violating.successor.state;
|
|
1603
|
+
current.candidateLevel = depths[parent.index] + 1;
|
|
1604
|
+
return withOutDegrees(
|
|
1605
|
+
reportViolation(violatedInvariant ? "invariant-violation" : "liveness-violation", {
|
|
1606
|
+
name: violated.name,
|
|
1607
|
+
...traces.getTrace(parent.index, violating.successor),
|
|
1608
|
+
}),
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
const result = expandState(parent.index, []);
|
|
1612
|
+
if (result) return result;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
// The tier found a behavior that violates a temporal property after its whole search. The
|
|
1616
|
+
// interpreter stores the paths to the lasso's states and reports it, as it would after its own.
|
|
1617
|
+
const lassoSteps = new Map<number, { successor: Successor; action: SpecAction | undefined }>();
|
|
1618
|
+
for (const entry of typed?.lasso?.states ?? []) {
|
|
1619
|
+
const initial = entry.parent === -1 ? states.find(entry.isState) : undefined;
|
|
1620
|
+
if (initial) {
|
|
1621
|
+
lassoSteps.set(entry.index, {
|
|
1622
|
+
successor: { state: initial, action: undefined },
|
|
1623
|
+
action: undefined,
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
const parent = lassoSteps.get(entry.parent)?.successor.state;
|
|
1627
|
+
if (!parent) continue;
|
|
1628
|
+
// The interpreter expands only the states it stores, which it has canonicalized.
|
|
1629
|
+
canonicalizeState(parent);
|
|
1630
|
+
forEachActionSuccessor(parent, undefined, (successor, action) => {
|
|
1631
|
+
if (!entry.isState(successor.state)) return false;
|
|
1632
|
+
lassoSteps.set(entry.index, { successor, action });
|
|
1633
|
+
return true;
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
const lassoIndexes = new Map<number, number>();
|
|
1637
|
+
const typedLasso =
|
|
1638
|
+
typed?.lasso && lassoSteps.size === typed.lasso.states.length ? typed.lasso : undefined;
|
|
1639
|
+
typedLasso?.states.forEach((entry) => {
|
|
1640
|
+
const step = lassoSteps.get(entry.index);
|
|
1641
|
+
const parent = lassoIndexes.get(entry.parent);
|
|
1642
|
+
if (step && parent !== undefined)
|
|
1643
|
+
visitSuccessor(parent, step.successor, [], undefined, step.action);
|
|
1644
|
+
lassoIndexes.set(
|
|
1645
|
+
entry.index,
|
|
1646
|
+
parent === undefined ? states.findIndex(entry.isState) : states.length - 1,
|
|
1647
|
+
);
|
|
1648
|
+
});
|
|
1649
|
+
if (typed && typedLasso) adoptTypedSearch(typed);
|
|
1650
|
+
for (
|
|
1651
|
+
let index = typedLasso ? states.length : 0;
|
|
1652
|
+
index < states.length && !runtime.isStopped;
|
|
1653
|
+
index++
|
|
1654
|
+
) {
|
|
1656
1655
|
current.index = index;
|
|
1657
1656
|
current.candidate = undefined;
|
|
1658
1657
|
runtime.queueSize = states.length - index - 1;
|
|
1659
1658
|
current.isExpanding = true;
|
|
1660
1659
|
const liveSuccessors: LiveSuccessor[] = [];
|
|
1661
1660
|
try {
|
|
1662
|
-
outcome
|
|
1661
|
+
outcome = expandState(index, liveSuccessors);
|
|
1663
1662
|
} catch (error) {
|
|
1664
|
-
outcome
|
|
1663
|
+
outcome =
|
|
1665
1664
|
error instanceof TlaIncompleteSuccessorError
|
|
1666
1665
|
? reportIncompleteSuccessor(index, error)
|
|
1667
1666
|
: reportNextStateFailure(error, index, liveSuccessors);
|
|
1668
1667
|
}
|
|
1669
|
-
if (outcome
|
|
1668
|
+
if (outcome) return outcome;
|
|
1670
1669
|
outDegrees[getOutDegreeBucket()]++;
|
|
1671
|
-
|
|
1672
|
-
// TLC's AbstractChecker#runTLC checks the liveness properties on the state graph so far, then
|
|
1673
|
-
// reports how far the search got.
|
|
1670
|
+
newStateCount = 0;
|
|
1674
1671
|
if ((isPeriodic || options.onProgress) && performance.now() >= periodic.at) {
|
|
1675
1672
|
periodic.at = performance.now() + PROGRESS_INTERVAL;
|
|
1676
1673
|
const lasso = isPeriodic ? findPeriodicViolation(index + 1) : undefined;
|
|
1677
1674
|
if (liveness && lasso) return reportLasso(liveness, lasso);
|
|
1678
|
-
options.
|
|
1675
|
+
const isCoverageDue = options.coverage !== undefined && periodic.coverageCount === 0;
|
|
1676
|
+
periodic.coverageCount = isCoverageDue
|
|
1677
|
+
? Math.trunc(options.coverage ?? 0)
|
|
1678
|
+
: periodic.coverageCount - 1;
|
|
1679
|
+
const progress = createResult("success");
|
|
1680
|
+
options.onProgress?.({
|
|
1681
|
+
kind: "progress",
|
|
1682
|
+
statistics: { ...progress, coverage: isCoverageDue ? progress.coverage : undefined },
|
|
1683
|
+
});
|
|
1679
1684
|
}
|
|
1680
1685
|
}
|
|
1681
1686
|
|
|
1682
1687
|
current.index = -1;
|
|
1683
1688
|
current.candidate = undefined;
|
|
1684
|
-
|
|
1689
|
+
const finalLiveness = options.livenessCheck === "off" ? undefined : liveness;
|
|
1690
|
+
if (finalLiveness) {
|
|
1685
1691
|
options.onProgress?.({
|
|
1686
1692
|
kind: "liveness-started",
|
|
1687
|
-
branches:
|
|
1693
|
+
branches: finalLiveness.branches,
|
|
1688
1694
|
isComplete: true,
|
|
1689
1695
|
states: runtime.distinctStates,
|
|
1690
1696
|
statistics: createResult("success"),
|
|
1691
1697
|
});
|
|
1692
1698
|
}
|
|
1693
|
-
const
|
|
1694
|
-
|
|
1699
|
+
const getLassoIndexes = (indexes: number[]) =>
|
|
1700
|
+
indexes.map((index) => lassoIndexes.get(index) ?? -1);
|
|
1701
|
+
const lasso = typedLasso
|
|
1702
|
+
? {
|
|
1703
|
+
prefix: getLassoIndexes(typedLasso.prefix),
|
|
1704
|
+
cycle: getLassoIndexes(typedLasso.cycle),
|
|
1705
|
+
isCycleConstrained: typedLasso.isCycleConstrained,
|
|
1706
|
+
}
|
|
1707
|
+
: finalLiveness?.findViolation();
|
|
1708
|
+
if (finalLiveness && lasso) return reportLasso(finalLiveness, lasso);
|
|
1695
1709
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1710
|
+
if (finalLiveness) options.onProgress?.({ kind: "liveness-finished" });
|
|
1711
|
+
const missingPostcondition = specification.moduleOperators.find(
|
|
1712
|
+
(operator) => operator.kind === "postcondition" && operator.key === undefined,
|
|
1713
|
+
);
|
|
1714
|
+
if (missingPostcondition) {
|
|
1715
|
+
return createFailureResult(createMissingOperatorError(missingPostcondition), { trace: [] });
|
|
1716
|
+
}
|
|
1717
|
+
const postcondition = search.findPostconditionViolation();
|
|
1718
|
+
if (postcondition) {
|
|
1719
|
+
return createResult("postcondition-violation", {
|
|
1720
|
+
name: postcondition.name,
|
|
1721
|
+
message: postcondition.message,
|
|
1722
|
+
counts: postcondition.counts,
|
|
1723
|
+
trace: [],
|
|
1724
|
+
postcondition,
|
|
1725
|
+
});
|
|
1711
1726
|
}
|
|
1712
|
-
return createSuccess();
|
|
1727
|
+
return continuedStatus ? createResult(continuedStatus) : createSuccess();
|
|
1713
1728
|
};
|