tla-ts 0.0.9-dev.8298a52 → 0.0.10-dev.06b481ee0
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 +8 -0
- package/dist/compile.cjs +6 -6
- package/dist/compile.js +10 -10
- package/dist/deciders.cjs +41 -37
- package/dist/deciders.js +57 -53
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +121 -12
- package/dist/index.d.ts +121 -12
- 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 +144 -31
- package/dist/run.js +144 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +134 -104
- package/dist/transfer.js +134 -104
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/ast.ts +56 -60
- package/src/bags.ts +128 -110
- package/src/builtins.ts +31 -77
- package/src/bundled-modules.ts +1 -8
- package/src/check-failure.ts +118 -0
- package/src/check-trace.ts +320 -0
- package/src/check.ts +1155 -900
- package/src/cli/options.ts +12 -32
- package/src/cli/run.ts +0 -2
- package/src/cli/runtime-invariants.ts +100 -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 +701 -0
- package/src/cli/tlc-usage.ts +360 -0
- package/src/cli/tlc.ts +318 -656
- package/src/cli/typescript.ts +0 -3
- package/src/cli/xml-exporter.ts +27 -49
- package/src/cli.ts +0 -1
- package/src/codegen.ts +217 -82
- package/src/config.ts +140 -109
- package/src/coverage.ts +1019 -0
- package/src/dependencies.ts +101 -66
- package/src/dfid.ts +683 -0
- package/src/environment-config.ts +315 -0
- package/src/environment.ts +260 -371
- package/src/errors.ts +93 -58
- package/src/evaluate.ts +848 -374
- package/src/exit-codes.ts +63 -13
- package/src/fingerprints.ts +75 -11
- package/src/index.ts +3 -0
- package/src/instances.ts +97 -43
- package/src/java-hash.ts +21 -0
- package/src/java-overrides.ts +6 -21
- package/src/json-reader.ts +455 -0
- package/src/json.ts +252 -139
- package/src/levels.ts +231 -154
- package/src/lexer.ts +83 -101
- package/src/liveness-checker.ts +743 -325
- package/src/liveness.ts +224 -131
- 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 +39 -20
- package/src/obligations/levels.ts +27 -18
- package/src/obligations/module.ts +28 -55
- package/src/obligations/normalize.ts +31 -41
- package/src/obligations/operators.ts +0 -3
- package/src/obligations/pragma.ts +52 -24
- package/src/obligations/printer.ts +94 -63
- 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 +121 -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 +34 -57
- package/src/parallel.ts +62 -72
- package/src/parser.ts +1184 -531
- 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 +226 -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 +1 -15
- package/src/prover/isabelle/provers/classical.ts +58 -61
- package/src/prover/isabelle/provers/hypsubst.ts +29 -54
- 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 +34 -77
- 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 +4 -47
- 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 +26 -31
- 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 +1021 -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 +626 -56
- 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 +319 -0
- package/src/prover/smt/solver/array.ts +1 -3
- package/src/prover/smt/solver/asserted-formulas.ts +241 -99
- package/src/prover/smt/solver/ast-lt.ts +165 -21
- package/src/prover/smt/solver/ast-util.ts +160 -7
- package/src/prover/smt/solver/ast.ts +1480 -184
- package/src/prover/smt/solver/auf-solver.ts +30 -56
- package/src/prover/smt/solver/bit-blast-tactic.ts +608 -0
- package/src/prover/smt/solver/bit-blaster.ts +871 -0
- package/src/prover/smt/solver/blast-term-ite.ts +47 -0
- package/src/prover/smt/solver/bound-manager.ts +196 -0
- package/src/prover/smt/solver/bound-simplifier.ts +598 -0
- package/src/prover/smt/solver/bv-bound-chk.ts +492 -0
- package/src/prover/smt/solver/bv-decl-plugin.ts +341 -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 +127 -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 +293 -0
- package/src/prover/smt/solver/conflict-resolution.ts +78 -11
- package/src/prover/smt/solver/context.ts +600 -187
- package/src/prover/smt/solver/ctx-simplify.ts +34 -52
- package/src/prover/smt/solver/ctx-solver-simplify.ts +122 -0
- package/src/prover/smt/solver/datatype-decl-plugin.ts +580 -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 +93 -0
- package/src/prover/smt/solver/der.ts +39 -30
- package/src/prover/smt/solver/diff-neq.ts +205 -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 +296 -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-bounds.ts +89 -0
- package/src/prover/smt/solver/elim-small-bv-tactic.ts +129 -0
- package/src/prover/smt/solver/elim-term-ite-tactic.ts +48 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +542 -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 +901 -0
- package/src/prover/smt/solver/euf/euf-solver.ts +1204 -0
- package/src/prover/smt/solver/euf/fpa-solver.ts +317 -0
- package/src/prover/smt/solver/euf/mam.ts +1046 -0
- package/src/prover/smt/solver/euf/q-ematch.ts +829 -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 +328 -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 +271 -0
- package/src/prover/smt/solver/factor.ts +163 -0
- package/src/prover/smt/solver/fd-solver.ts +734 -0
- package/src/prover/smt/solver/fingerprints.ts +15 -26
- package/src/prover/smt/solver/fix-dl-var.ts +147 -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 +639 -0
- package/src/prover/smt/solver/fpa2bv-converter.ts +2251 -0
- package/src/prover/smt/solver/fpa2bv-rewriter.ts +349 -0
- package/src/prover/smt/solver/fpa2bv-tactic.ts +73 -0
- package/src/prover/smt/solver/goal.ts +179 -28
- package/src/prover/smt/solver/goal2nlsat.ts +216 -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 +30 -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 +113 -133
- 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 +355 -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 +18 -31
- package/src/prover/smt/solver/lp/core-solver.ts +35 -37
- package/src/prover/smt/solver/lp/cross-nested.ts +4 -21
- 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 +70 -83
- package/src/prover/smt/solver/lp/lar-term.ts +0 -5
- package/src/prover/smt/solver/lp/lp-settings.ts +6 -16
- package/src/prover/smt/solver/lp/maximize-term.ts +76 -52
- package/src/prover/smt/solver/lp/nex-creator.ts +7 -30
- package/src/prover/smt/solver/lp/nex.ts +2 -7
- 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 +92 -136
- 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 +177 -149
- 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 +164 -147
- package/src/prover/smt/solver/lp/numeric-pair.ts +0 -4
- package/src/prover/smt/solver/lp/pdd-interval.ts +6 -5
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +61 -34
- package/src/prover/smt/solver/lp/pdd-solver.ts +74 -72
- package/src/prover/smt/solver/lp/pdd.ts +730 -358
- 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 +310 -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 +106 -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 +20 -63
- package/src/prover/smt/solver/model-evaluator.ts +192 -40
- package/src/prover/smt/solver/model-finder.ts +14 -32
- package/src/prover/smt/solver/model-generator.ts +104 -46
- 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 +709 -0
- package/src/prover/smt/solver/mus.ts +50 -0
- package/src/prover/smt/solver/muz/dl-context.ts +382 -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 +495 -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 +214 -0
- package/src/prover/smt/solver/muz/rule-properties.ts +359 -0
- package/src/prover/smt/solver/muz/spacer-context.ts +1404 -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 +219 -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 +357 -236
- package/src/prover/smt/solver/nlsat/atoms.ts +73 -54
- package/src/prover/smt/solver/nlsat/evaluator.ts +16 -22
- package/src/prover/smt/solver/nlsat/explain.ts +429 -275
- package/src/prover/smt/solver/nlsat/interval-set.ts +9 -51
- package/src/prover/smt/solver/nlsat/levelwise.ts +477 -344
- package/src/prover/smt/solver/nlsat/mpbq.ts +47 -14
- package/src/prover/smt/solver/nlsat/polynomial.ts +2385 -832
- package/src/prover/smt/solver/nlsat/solver.ts +297 -156
- package/src/prover/smt/solver/nlsat/transcendental-eval.ts +310 -0
- package/src/prover/smt/solver/nlsat/transcendentals.ts +391 -0
- package/src/prover/smt/solver/nlsat/types.ts +0 -9
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +9 -51
- package/src/prover/smt/solver/nlsat/upolynomial.ts +49 -109
- package/src/prover/smt/solver/nlsat-tactic.ts +82 -0
- package/src/prover/smt/solver/nnf.ts +112 -61
- 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 +801 -0
- package/src/prover/smt/solver/opt-nlsat.ts +386 -0
- package/src/prover/smt/solver/opt-pareto.ts +301 -0
- package/src/prover/smt/solver/opt-preprocess.ts +101 -0
- package/src/prover/smt/solver/opt-solver.ts +312 -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 +281 -0
- package/src/prover/smt/solver/pb2bv-tactic.ts +540 -0
- package/src/prover/smt/solver/poly-rewriter.ts +261 -79
- package/src/prover/smt/solver/probes.ts +577 -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/push-app-ite.ts +37 -0
- package/src/prover/smt/solver/qe-arith-plugin.ts +1096 -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 +41 -51
- package/src/prover/smt/solver/qe-mbp.ts +270 -0
- package/src/prover/smt/solver/qe.ts +1499 -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 +829 -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 +22 -32
- 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 +262 -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 +59 -135
- package/src/prover/smt/solver/rewriter.ts +507 -144
- package/src/prover/smt/solver/rlimit.ts +46 -24
- 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 +579 -0
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +464 -0
- package/src/prover/smt/solver/sat/model-converter.ts +136 -0
- package/src/prover/smt/solver/sat/pb-constraint.ts +268 -0
- package/src/prover/smt/solver/sat/pb-solver.ts +1596 -0
- package/src/prover/smt/solver/sat/probing.ts +170 -0
- package/src/prover/smt/solver/sat/sat-tactic.ts +53 -0
- package/src/prover/smt/solver/sat/sat2goal.ts +189 -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 +2107 -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 +995 -0
- package/src/prover/smt/solver/seq-decl-plugin.ts +819 -0
- package/src/prover/smt/solver/seq-derive.ts +1298 -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 +730 -0
- package/src/prover/smt/solver/seq-range-predicate.ts +235 -0
- package/src/prover/smt/solver/seq-re-rewriter.ts +1171 -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 +2404 -0
- package/src/prover/smt/solver/seq-skolem.ts +294 -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 +124 -0
- package/src/prover/smt/solver/smt-logics.ts +66 -0
- package/src/prover/smt/solver/smt-setup.ts +589 -0
- package/src/prover/smt/solver/smt2-printer.ts +765 -0
- package/src/prover/smt/solver/smtlib-parser.ts +3546 -406
- package/src/prover/smt/solver/smtlib-script.ts +2134 -0
- package/src/prover/smt/solver/solve-eqs.ts +928 -0
- package/src/prover/smt/solver/solver.ts +129 -38
- 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 +2141 -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 +1210 -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 +60 -91
- package/src/prover/smt/solver/theory-lra-internalize.ts +96 -53
- package/src/prover/smt/solver/theory-lra-model.ts +23 -53
- package/src/prover/smt/solver/theory-lra-propagate.ts +34 -42
- package/src/prover/smt/solver/theory-lra-state.ts +7 -28
- package/src/prover/smt/solver/theory-lra.ts +189 -9
- package/src/prover/smt/solver/theory-pb.ts +951 -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 +852 -0
- package/src/prover/smt/solver/theory-seq.ts +961 -0
- package/src/prover/smt/solver/theory-without-terms.ts +24 -0
- package/src/prover/smt/solver/theory.ts +189 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +486 -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 +74 -48
- 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 +24 -6
- package/src/prover/zenon/expr.ts +29 -28
- package/src/prover/zenon/index-table.ts +33 -61
- package/src/prover/zenon/isar-case.ts +9 -21
- package/src/prover/zenon/isar.ts +37 -67
- 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 +2 -14
- package/src/prover/zenon/proof.ts +0 -11
- package/src/prover/zenon/propositional-rules.ts +0 -7
- package/src/prover/zenon/rules.ts +3 -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 +1132 -430
- package/src/runtime.ts +33 -23
- package/src/sany/builtins.ts +11 -14
- package/src/sany/generation.ts +383 -0
- package/src/sany/generator-def-entries.ts +210 -0
- package/src/sany/generator-definitions.ts +688 -0
- package/src/sany/generator-expressions.ts +1108 -0
- package/src/sany/generator-proofs.ts +665 -0
- package/src/sany/generator.ts +192 -2764
- package/src/sany/levels.ts +5 -35
- package/src/sany/lexer.ts +61 -80
- package/src/sany/linter.ts +0 -10
- package/src/sany/modules.ts +5 -7
- package/src/sany/nodes.ts +6 -44
- package/src/sany/parse-error.ts +39 -117
- package/src/sany/report.ts +32 -69
- package/src/sany/selectors.ts +60 -82
- package/src/sany/source.ts +1 -17
- package/src/sany/xml.ts +37 -120
- package/src/search.ts +913 -227
- package/src/simulate.ts +765 -0
- package/src/spec-description.ts +198 -104
- package/src/standard-definitions.ts +4 -4
- package/src/standard-modules.ts +302 -99
- package/src/state-graph.ts +52 -33
- package/src/subexpressions.ts +578 -166
- package/src/substitution-levels.ts +7 -7
- package/src/successors.ts +296 -105
- package/src/symmetry.ts +37 -28
- package/src/tableau.ts +29 -26
- package/src/tlc/fingerprint.ts +267 -79
- package/src/tlc/jar-data.ts +122 -6
- package/src/tlc/messages.ts +127 -56
- package/src/tlc/order.ts +53 -72
- package/src/tlc/random.ts +38 -49
- package/src/tlc/replay.ts +579 -230
- package/src/tlc/summary.ts +64 -60
- package/src/tlc/tlc-operators.ts +83 -47
- package/src/tlc/tlcext-operators.ts +205 -127
- package/src/tlc/trace-spec.ts +235 -0
- package/src/tlc/value-stream.ts +139 -0
- package/src/tlc/version.ts +1 -4
- package/src/trace-liveness.ts +529 -0
- package/src/transfer.ts +22 -25
- package/src/typed-tier.ts +6556 -0
- package/src/typescript/actions.ts +10 -25
- package/src/typescript/collections.ts +34 -35
- package/src/typescript/compile.ts +1 -8
- package/src/typescript/context.ts +0 -12
- package/src/typescript/emit.ts +0 -1
- package/src/typescript/expressions.ts +0 -12
- package/src/typescript/formula.ts +9 -15
- package/src/typescript/functions.ts +6 -17
- package/src/typescript/model.ts +14 -16
- package/src/typescript/names.ts +0 -2
- package/src/typescript/program.ts +0 -3
- package/src/typescript/properties.ts +6 -8
- package/src/typescript/scope.ts +0 -5
- package/src/typescript/steps.ts +20 -28
- package/src/typescript/types.ts +3 -10
- package/src/values.ts +917 -522
- 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,15 @@
|
|
|
1
1
|
import type { Expression } from "./ast";
|
|
2
2
|
import { parseConfig, type ModelConfig } from "./config";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
countCoverageVariables,
|
|
5
|
+
createCoverage,
|
|
6
|
+
createCoverageEnvironment,
|
|
7
|
+
getCoverageReport,
|
|
8
|
+
type CoverageReport,
|
|
9
|
+
} from "./coverage";
|
|
4
10
|
import {
|
|
5
11
|
createStackOverflowError,
|
|
6
|
-
getErrorExitCode,
|
|
7
12
|
isStackOverflow,
|
|
8
|
-
TlaConfigError,
|
|
9
13
|
TlaEvaluationError,
|
|
10
14
|
TlaIllegalStateError,
|
|
11
15
|
TlaIncompleteSuccessorError,
|
|
@@ -13,18 +17,37 @@ import {
|
|
|
13
17
|
TlaStackOverflowError,
|
|
14
18
|
UNEXPECTED_EVAL_EXCEPTION,
|
|
15
19
|
UNEXPECTED_EXCEPTION,
|
|
20
|
+
formatRange,
|
|
16
21
|
} from "./errors";
|
|
17
22
|
import {
|
|
18
|
-
|
|
19
|
-
evaluate,
|
|
20
|
-
formatRange,
|
|
23
|
+
describeRange,
|
|
21
24
|
getDefinition,
|
|
22
|
-
isImpure,
|
|
23
25
|
type CallStack,
|
|
24
|
-
type Environment,
|
|
25
26
|
type FingerprintFailure,
|
|
27
|
+
type State,
|
|
26
28
|
} from "./evaluate";
|
|
27
|
-
import { EXIT_STATUS,
|
|
29
|
+
import { EXIT_STATUS, setExitCode, withLivenessExitCode } from "./exit-codes";
|
|
30
|
+
import {
|
|
31
|
+
fingerprintReplayed,
|
|
32
|
+
getFailureExitCode,
|
|
33
|
+
getReplayFailure,
|
|
34
|
+
type FailureOptions,
|
|
35
|
+
} from "./check-failure";
|
|
36
|
+
import {
|
|
37
|
+
createTraceBuilder,
|
|
38
|
+
NEXT_RECOVERY_FAILURE,
|
|
39
|
+
type Behavior,
|
|
40
|
+
type SearchPosition,
|
|
41
|
+
type TracedStep,
|
|
42
|
+
} from "./check-trace";
|
|
43
|
+
import {
|
|
44
|
+
createStateTable,
|
|
45
|
+
findStateIndex,
|
|
46
|
+
getStateHash,
|
|
47
|
+
isSameState,
|
|
48
|
+
markSeenState,
|
|
49
|
+
type StateTable,
|
|
50
|
+
} from "./fingerprints";
|
|
28
51
|
import type { JavaOverride } from "./java-overrides";
|
|
29
52
|
import {
|
|
30
53
|
createLivenessChecker,
|
|
@@ -33,23 +56,27 @@ import {
|
|
|
33
56
|
type LiveSuccessor,
|
|
34
57
|
} from "./liveness-checker";
|
|
35
58
|
import {
|
|
36
|
-
|
|
59
|
+
addActionCoverage,
|
|
60
|
+
createCheckEnvironment,
|
|
61
|
+
createMissingOperatorError,
|
|
37
62
|
createSearch,
|
|
63
|
+
getIncompleteSuccessorMessage,
|
|
38
64
|
findAssumptionViolation,
|
|
39
|
-
getConfigDefinition,
|
|
40
|
-
getContext,
|
|
41
65
|
reportInitialStatesProgress,
|
|
42
66
|
reportStartup,
|
|
67
|
+
STOP_WALK,
|
|
68
|
+
walkCoveredSuccessors,
|
|
43
69
|
withNextStateExitCode,
|
|
70
|
+
type CoveredAction,
|
|
44
71
|
} from "./search";
|
|
45
72
|
import {
|
|
46
73
|
getActionLabel,
|
|
47
74
|
getActionSignature,
|
|
48
|
-
|
|
49
|
-
getNextActions,
|
|
75
|
+
getSpecDescription,
|
|
50
76
|
getSpecificationValue,
|
|
51
77
|
toActionValue,
|
|
52
78
|
type SpecAction,
|
|
79
|
+
type SpecDescription,
|
|
53
80
|
} from "./spec-description";
|
|
54
81
|
import {
|
|
55
82
|
createStateWriter,
|
|
@@ -58,15 +85,15 @@ import {
|
|
|
58
85
|
type StateWriter,
|
|
59
86
|
} from "./state-graph";
|
|
60
87
|
import {
|
|
88
|
+
createIncompleteSuccessorError,
|
|
61
89
|
forEachInitialState,
|
|
62
90
|
forEachSuccessor,
|
|
63
91
|
getInitialStates,
|
|
64
92
|
getSuccessors,
|
|
93
|
+
hasIncompleteSuccessor,
|
|
65
94
|
type Successor,
|
|
66
95
|
} from "./successors";
|
|
67
96
|
import {
|
|
68
|
-
formatNestedMessage,
|
|
69
|
-
getCodedMessage,
|
|
70
97
|
getFailureMessage,
|
|
71
98
|
getWrappedException,
|
|
72
99
|
isEvalException,
|
|
@@ -75,25 +102,26 @@ import {
|
|
|
75
102
|
withUnexpectedException,
|
|
76
103
|
type FailureMessage,
|
|
77
104
|
} from "./tlc/messages";
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
105
|
+
import { createTautologyError } from "./liveness";
|
|
106
|
+
import { KEY_SEPARATOR } from "./resolve";
|
|
107
|
+
import { writeTraceSpec } from "./tlc/trace-spec";
|
|
108
|
+
import { replayInitialStates, replaySuccessors, walkSuccessors } from "./tlc/replay";
|
|
80
109
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
81
|
-
import {
|
|
110
|
+
import {
|
|
111
|
+
createActionRecord,
|
|
112
|
+
createCounterExample,
|
|
113
|
+
type CounterExampleLoop,
|
|
114
|
+
} from "./tlc/tlcext-operators";
|
|
82
115
|
import type { TlcVersion } from "./tlc/version";
|
|
116
|
+
import { runTypedSearch, type TypedResult } from "./typed-tier";
|
|
83
117
|
import {
|
|
84
|
-
combineHash,
|
|
85
118
|
createCanonicalizer,
|
|
86
119
|
createModelValue,
|
|
87
120
|
formatState,
|
|
88
121
|
getFingerprintError,
|
|
89
|
-
|
|
90
|
-
getValueHash,
|
|
91
|
-
isFunctionValue,
|
|
122
|
+
getModelValues,
|
|
92
123
|
isSameValue,
|
|
93
124
|
markFingerprinted,
|
|
94
|
-
setStringOrder,
|
|
95
|
-
setValueVersion,
|
|
96
|
-
toFiniteFunction,
|
|
97
125
|
type Value,
|
|
98
126
|
} from "./values";
|
|
99
127
|
|
|
@@ -105,37 +133,58 @@ export interface CheckOptions {
|
|
|
105
133
|
onPrint?: (text: string) => void;
|
|
106
134
|
onPause?: () => void;
|
|
107
135
|
readFile?: (path: string) => string | undefined;
|
|
108
|
-
writeFile?: (path: string, content: string) => void;
|
|
136
|
+
writeFile?: (path: string, content: string | Uint8Array) => void;
|
|
137
|
+
makeDirectory?: (path: string) => void;
|
|
109
138
|
seed?: bigint;
|
|
110
139
|
workers?: number;
|
|
111
|
-
|
|
112
|
-
livenessCheck?: "default" | "final";
|
|
113
|
-
|
|
140
|
+
/** TLC's -lncheck: "final" checks liveness only on the complete graph, "off" never looks for a cycle. */
|
|
141
|
+
livenessCheck?: "default" | "final" | "off";
|
|
142
|
+
/** TLC's -fp: the index of the polynomial in TLC's FP64.Polys that fingerprints states. */
|
|
143
|
+
fingerprintPolynomial?: number;
|
|
144
|
+
/** False for TLC's -terse, which prints a lazy value, such as SUBSET S, without enumerating it. */
|
|
145
|
+
isLazyValueExpanded?: boolean;
|
|
146
|
+
/** TLC's -view: prints each state as the value of the configuration's VIEW. */
|
|
147
|
+
isViewPrinted?: boolean;
|
|
148
|
+
/** TLC's -maxSetSize: the most elements TLC enumerates into a set, or states into a list of them. */
|
|
149
|
+
maxSetSize?: number;
|
|
150
|
+
/** TLC's -dump: writes the reachable states, or with `dot` the state graph, through writeFile. */
|
|
114
151
|
dump?: StateDump;
|
|
115
|
-
|
|
152
|
+
/** TLC's -tool, which changes the messages of TLC's errors. */
|
|
116
153
|
isTool?: boolean;
|
|
117
|
-
|
|
118
|
-
// onProgress and goes on.
|
|
154
|
+
/** TLC's -continue: reports each violation through onProgress and goes on. */
|
|
119
155
|
isContinued?: boolean;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
156
|
+
/** Skips fingerprintDistance, which takes fingerprinting every state again after the search. */
|
|
157
|
+
isFingerprintDistanceSkipped?: boolean;
|
|
158
|
+
moduleOperators?: ModuleOperator[];
|
|
159
|
+
/** TLC's trace exploration spec, and the binary trace TLC records for it unless -noTEBin. */
|
|
160
|
+
traceSpec?: TraceSpecOptions;
|
|
161
|
+
/** Whether the caller printed SANY's report, its warnings included, before the check. */
|
|
123
162
|
isSanyReported?: boolean;
|
|
124
|
-
|
|
163
|
+
/** False for TLC's -nowarning, which changes how TLC computes some successors. */
|
|
125
164
|
isWarningEnabled?: boolean;
|
|
126
|
-
|
|
165
|
+
/** TLC's -coverage, in minutes. */
|
|
166
|
+
coverage?: number;
|
|
127
167
|
version?: TlcVersion;
|
|
128
|
-
// Reports the points of the search at which TLC prints a message.
|
|
129
168
|
onProgress?: (progress: CheckProgress) => void;
|
|
130
169
|
}
|
|
131
170
|
|
|
171
|
+
export interface TraceSpecOptions {
|
|
172
|
+
module: string;
|
|
173
|
+
traceFile?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface ModuleOperator {
|
|
177
|
+
kind: "postcondition" | "constraint" | "view";
|
|
178
|
+
module: string;
|
|
179
|
+
operator: string;
|
|
180
|
+
constants?: Record<string, string>;
|
|
181
|
+
}
|
|
182
|
+
|
|
132
183
|
export interface InitialStatesProgress {
|
|
133
184
|
kind: "initial-states-progress";
|
|
134
185
|
count: number;
|
|
135
186
|
}
|
|
136
187
|
|
|
137
|
-
// A check that TLC's DoInitFunctor reports as violated before it stops its replay of the initial
|
|
138
|
-
// states.
|
|
139
188
|
export interface InitialStateViolation {
|
|
140
189
|
kind: "initial-state-violation";
|
|
141
190
|
status: "invariant-violation" | "liveness-violation";
|
|
@@ -143,10 +192,8 @@ export interface InitialStateViolation {
|
|
|
143
192
|
state: Record<string, Value>;
|
|
144
193
|
}
|
|
145
194
|
|
|
146
|
-
// A line the spec prints, or what TLC reports as it replays the initial states.
|
|
147
195
|
export type OutputLine = string | InitialStatesProgress | InitialStateViolation;
|
|
148
196
|
|
|
149
|
-
// The points of the search at which TLC prints a message.
|
|
150
197
|
export type CheckProgress =
|
|
151
198
|
| { kind: "parsed" }
|
|
152
199
|
| { kind: "constant-level-invariant"; name: string }
|
|
@@ -160,23 +207,21 @@ export type CheckProgress =
|
|
|
160
207
|
| {
|
|
161
208
|
kind: "liveness-started";
|
|
162
209
|
branches: number;
|
|
163
|
-
|
|
210
|
+
/** Whether TLC checks the complete state graph. */
|
|
164
211
|
isComplete: boolean;
|
|
212
|
+
/** How many states the graphs of all branches have together. */
|
|
165
213
|
states: number;
|
|
166
214
|
statistics: SearchStatistics;
|
|
167
215
|
}
|
|
168
216
|
| { kind: "liveness-finished" }
|
|
169
217
|
| { kind: "sequential-fallback"; string: string }
|
|
170
|
-
// A warning TLC prints as it evaluates the spec, with its message code.
|
|
171
218
|
| { kind: "warning"; code: number; text: string }
|
|
172
|
-
// A violation that the search goes on past with -continue.
|
|
173
219
|
| { 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
220
|
| ({ kind: "java-override" } & JavaOverride);
|
|
176
221
|
|
|
177
222
|
export interface SearchStatistics extends Pick<
|
|
178
223
|
CheckResult,
|
|
179
|
-
"generatedStates" | "distinctStates" | "queuedStates" | "depth"
|
|
224
|
+
"generatedStates" | "distinctStates" | "queuedStates" | "depth" | "coverage"
|
|
180
225
|
> {}
|
|
181
226
|
|
|
182
227
|
export type CheckStatus =
|
|
@@ -191,45 +236,47 @@ export type CheckStatus =
|
|
|
191
236
|
|
|
192
237
|
export interface TraceStep {
|
|
193
238
|
action: string | undefined;
|
|
194
|
-
|
|
239
|
+
/** TLC's name, parameters and location for the action that took this step. */
|
|
195
240
|
label: string | undefined;
|
|
196
241
|
state: Record<string, Value>;
|
|
197
|
-
|
|
198
|
-
// trace. The first step has what TLC prints before the trace.
|
|
242
|
+
/** What the spec prints before this step as TLC rebuilds the trace, and before it for the first. */
|
|
199
243
|
output?: OutputLine[];
|
|
200
244
|
}
|
|
201
245
|
|
|
202
246
|
export interface Violation {
|
|
203
247
|
name: string;
|
|
204
|
-
|
|
248
|
+
/** Every temporal property that a liveness counterexample violates, in the configuration's order. */
|
|
205
249
|
properties?: string[];
|
|
206
250
|
trace: TraceStep[];
|
|
207
|
-
|
|
208
|
-
// the cycle of a lasso or rebuilds the trace once more.
|
|
251
|
+
/** What the spec prints after the trace, as TLC finds the lasso's step back or rebuilds the trace. */
|
|
209
252
|
traceOutput?: OutputLine[];
|
|
253
|
+
/** What the postconditions print, which TLC checks after the lasso's step back. */
|
|
254
|
+
postconditionOutput?: OutputLine[];
|
|
210
255
|
loopStart: number | undefined;
|
|
211
256
|
loopLabel?: string;
|
|
212
257
|
message?: string;
|
|
213
258
|
counts?: string;
|
|
214
259
|
unwitnessed?: Postcondition;
|
|
215
|
-
|
|
216
|
-
// prints one.
|
|
260
|
+
/** A POSTCONDITION that is false or fails, which TLC checks as it prints the counterexample. */
|
|
217
261
|
postcondition?: Postcondition;
|
|
218
|
-
|
|
262
|
+
/** What TLC warns about after a counterexample, with its code. */
|
|
219
263
|
warning?: { code: number; text: string };
|
|
220
264
|
}
|
|
221
265
|
|
|
222
266
|
export interface Postcondition {
|
|
223
267
|
name: string;
|
|
224
|
-
// TLC's message code.
|
|
225
268
|
code: number;
|
|
226
269
|
message: string;
|
|
227
270
|
counts?: string;
|
|
228
271
|
}
|
|
229
272
|
|
|
230
|
-
|
|
273
|
+
export interface TraceFailure extends FailureMessage {
|
|
274
|
+
/** What the spec prints as TLC rebuilds the step it then fails to print. */
|
|
275
|
+
output: OutputLine[];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** An evaluation that failed during the search, with the behavior up to the state TLC was working on. */
|
|
231
279
|
export interface EvaluationFailure {
|
|
232
|
-
// TLC's code for the message, and its text with and without -tool.
|
|
233
280
|
code: number;
|
|
234
281
|
message: string;
|
|
235
282
|
toolMessage: string;
|
|
@@ -237,28 +284,20 @@ export interface EvaluationFailure {
|
|
|
237
284
|
traceOutput?: OutputLine[];
|
|
238
285
|
initialState: Record<string, Value> | undefined;
|
|
239
286
|
exitCode: number;
|
|
240
|
-
|
|
241
|
-
// them by replaying the failure.
|
|
287
|
+
/** The expressions TLC was evaluating, outermost first, when its replay finds them. */
|
|
242
288
|
callStack: Expression[] | undefined;
|
|
243
|
-
|
|
289
|
+
/** Whether TLC prints the call stack before the error, as it does for a failed liveness check. */
|
|
244
290
|
isCallStackFirst?: boolean;
|
|
245
|
-
|
|
291
|
+
/** The FingerprintException the replay raises, which TLC reports in place of the call stack. */
|
|
246
292
|
fingerprint?: FingerprintFailure;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// A POSTCONDITION that is false or fails after the trace, which TLC checks as it prints one.
|
|
293
|
+
/** How TLC reports failing again as it prints the trace, since it can't fingerprint the state. */
|
|
294
|
+
traceFailure?: TraceFailure;
|
|
295
|
+
/** A POSTCONDITION that is false or fails after the trace, which TLC checks as it prints one. */
|
|
251
296
|
postcondition?: Postcondition;
|
|
252
|
-
|
|
297
|
+
/** Whether TLC stops before it prints the statistics, as it does for an illegal initial state. */
|
|
253
298
|
isWithoutStatistics?: boolean;
|
|
254
299
|
}
|
|
255
300
|
|
|
256
|
-
// Where TLC's replay of a failure fails.
|
|
257
|
-
interface ReplayFailure {
|
|
258
|
-
callStack: Expression[];
|
|
259
|
-
fingerprint: FingerprintFailure | undefined;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
301
|
export interface InitialStates {
|
|
263
302
|
generated: number;
|
|
264
303
|
distinct: number;
|
|
@@ -272,104 +311,52 @@ export interface CheckResult {
|
|
|
272
311
|
distinctStates: number;
|
|
273
312
|
queuedStates: number;
|
|
274
313
|
depth: number;
|
|
275
|
-
|
|
276
|
-
// them all without a violation or an error.
|
|
314
|
+
/** Once TLC computed all the initial states without a violation or an error. */
|
|
277
315
|
initialStates: InitialStates | undefined;
|
|
278
|
-
|
|
279
|
-
// the outdegree of the state graph.
|
|
316
|
+
/** How many expanded states found each number of new states, when TLC prints the outdegree. */
|
|
280
317
|
outDegrees: number[] | undefined;
|
|
281
|
-
|
|
282
|
-
// collision from the actual fingerprints.
|
|
318
|
+
/** The smallest distance between two fingerprints, when TLC estimates a collision from them. */
|
|
283
319
|
fingerprintDistance: bigint | undefined;
|
|
284
|
-
|
|
285
|
-
// which it reports after the deadlock.
|
|
320
|
+
/** A temporal property TLC finds violated as it adds the state it stopped at to the behavior graph, reported after. */
|
|
286
321
|
additionalViolation?: Violation;
|
|
287
|
-
|
|
322
|
+
/** Where TLC's worker fails to add the state to the behavior graph after it reports a violation. */
|
|
288
323
|
liveCallStack?: Expression[];
|
|
289
|
-
|
|
290
|
-
// stop on a violation without an error code, which TLC 1.7.4 reports as a successful search.
|
|
324
|
+
/** The outdegrees when TLC's workers stop on a violation that TLC 1.7.4 reports as a success. */
|
|
291
325
|
violationOutDegrees?: number[];
|
|
326
|
+
traceSpec?: string;
|
|
327
|
+
coverage?: CoverageReport;
|
|
292
328
|
}
|
|
293
329
|
|
|
294
|
-
interface
|
|
295
|
-
trace: TraceStep[];
|
|
296
|
-
traceOutput?: OutputLine[];
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
interface TraceOptions {
|
|
330
|
+
interface ReportedViolation extends Omit<Violation, "loopStart"> {
|
|
300
331
|
loopStart?: number;
|
|
301
|
-
known?: number;
|
|
302
332
|
}
|
|
303
333
|
|
|
304
|
-
interface
|
|
305
|
-
|
|
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;
|
|
334
|
+
interface CounterExampleOptions {
|
|
335
|
+
isConsole: boolean;
|
|
316
336
|
}
|
|
317
337
|
|
|
318
|
-
// TLC prints what the spec prints as it replays a failure after the trace.
|
|
319
338
|
const appendTraceOutput = <Traced extends Behavior>(behavior: Traced, lines: OutputLine[]) => ({
|
|
320
339
|
...behavior,
|
|
321
340
|
traceOutput: [...(behavior.traceOutput ?? []), ...lines],
|
|
322
341
|
});
|
|
323
342
|
|
|
324
|
-
const
|
|
325
|
-
|
|
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])),
|
|
343
|
+
const toUnexpectedError = (error: TlaEvaluationError) =>
|
|
344
|
+
new TlaEvaluationError(
|
|
345
|
+
`${isEvalException(error) ? UNEXPECTED_EVAL_EXCEPTION : UNEXPECTED_EXCEPTION}${error.message}`,
|
|
337
346
|
);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// Stops a replay where TLC stops it without a failure, as at a violated invariant.
|
|
341
|
-
const STOP_REPLAY = new Error("The replay stopped");
|
|
342
|
-
|
|
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
347
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
348
|
+
const getTraceFailure = (error: TlaEvaluationError, output: OutputLine[]): TraceFailure => ({
|
|
349
|
+
...getFailureMessage(
|
|
350
|
+
isEvalException(error)
|
|
351
|
+
? new TlaEvaluationError(`${UNEXPECTED_EVAL_EXCEPTION}${error.message}`)
|
|
352
|
+
: error,
|
|
353
|
+
true,
|
|
354
|
+
),
|
|
355
|
+
output,
|
|
356
|
+
});
|
|
362
357
|
|
|
363
|
-
|
|
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
|
-
};
|
|
358
|
+
const STOP_REPLAY = new Error("The replay stopped");
|
|
371
359
|
|
|
372
|
-
// TLC finishes the -dump file whether or not the search finds a violation.
|
|
373
360
|
export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
374
361
|
const stateWriter =
|
|
375
362
|
options.dump && createStateWriter(options.dump, options.writeFile, options.version);
|
|
@@ -382,8 +369,6 @@ export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
|
382
369
|
}
|
|
383
370
|
};
|
|
384
371
|
|
|
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
372
|
const PERIODIC_START = 3000;
|
|
388
373
|
const PROGRESS_INTERVAL = 60_000;
|
|
389
374
|
const LIVENESS_GROWTH = 0.1;
|
|
@@ -395,81 +380,98 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
395
380
|
? parseConfig(options.config, options.version)
|
|
396
381
|
: options.config;
|
|
397
382
|
const onPrint = options.onPrint ?? console.log;
|
|
398
|
-
|
|
399
|
-
// keeps what it prints for the trace.
|
|
400
|
-
const capturedOutput = { lines: undefined as OutputLine[] | undefined };
|
|
383
|
+
let capturedLines: OutputLine[] | undefined;
|
|
401
384
|
const print = (text: string) => {
|
|
402
|
-
if (
|
|
385
|
+
if (capturedLines) capturedLines.push(text);
|
|
403
386
|
else onPrint(text);
|
|
404
387
|
};
|
|
405
388
|
const captureOutput = <Result>(rebuild: () => Result) => {
|
|
406
|
-
const outer =
|
|
389
|
+
const outer = capturedLines;
|
|
407
390
|
const lines: OutputLine[] = [];
|
|
408
|
-
|
|
391
|
+
capturedLines = lines;
|
|
409
392
|
try {
|
|
410
393
|
return { result: rebuild(), lines };
|
|
411
394
|
} finally {
|
|
412
|
-
|
|
395
|
+
capturedLines = outer;
|
|
413
396
|
}
|
|
414
397
|
};
|
|
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
|
-
});
|
|
398
|
+
const created = createCheckEnvironment(config, options, print);
|
|
399
|
+
const specification = created.specification;
|
|
432
400
|
reportStartup(specification, config, options.onProgress);
|
|
433
|
-
const
|
|
401
|
+
const coverage =
|
|
402
|
+
options.coverage === undefined
|
|
403
|
+
? undefined
|
|
404
|
+
: createCoverage(specification.environment.variables.length);
|
|
405
|
+
const environment = coverage
|
|
406
|
+
? createCoverageEnvironment(specification.environment, coverage)
|
|
407
|
+
: specification.environment;
|
|
434
408
|
const runtime = environment.runtime;
|
|
435
409
|
const is174 = runtime.version === "1.7.4";
|
|
436
410
|
runtime.pause = options.onPause ?? (() => {});
|
|
411
|
+
let description: SpecDescription | undefined;
|
|
412
|
+
const getDescription = () =>
|
|
413
|
+
(description ??= getSpecDescription(config, environment, specification.instanceActions));
|
|
437
414
|
runtime.getSpecification = () =>
|
|
438
|
-
getSpecificationValue(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
415
|
+
getSpecificationValue(getDescription(), config, environment, specification.variableLocations);
|
|
416
|
+
let searchDepth = 0;
|
|
417
|
+
let computedInitialStates: InitialStates | undefined;
|
|
418
|
+
const getTraceSpec = (trace: TraceStep[], loopStart: number | undefined) =>
|
|
419
|
+
options.traceSpec &&
|
|
420
|
+
writeTraceSpec({
|
|
421
|
+
module: options.traceSpec.module,
|
|
422
|
+
specName: specification.rootName,
|
|
423
|
+
rawConstants: config.rawConstants,
|
|
424
|
+
states: trace.map((step) => getStepState(step)),
|
|
425
|
+
loopStart,
|
|
426
|
+
modelValues: getModelValues().map((value) => value.name),
|
|
427
|
+
isDefined: (name) =>
|
|
428
|
+
environment.definitions.has(name) ||
|
|
429
|
+
environment.constants.has(name) ||
|
|
430
|
+
[...environment.definitions.keys()].some((key) =>
|
|
431
|
+
key.startsWith(`${name}${KEY_SEPARATOR}`),
|
|
432
|
+
),
|
|
433
|
+
});
|
|
434
|
+
const getCoverage = () =>
|
|
435
|
+
coverage?.relations.some((relation) => relation.kind === "next")
|
|
436
|
+
? getCoverageReport(
|
|
437
|
+
coverage,
|
|
438
|
+
environment,
|
|
439
|
+
specification.variableLocations,
|
|
440
|
+
search?.getTlcOrder() ?? [],
|
|
441
|
+
)
|
|
442
|
+
: undefined;
|
|
445
443
|
const createResult = (
|
|
446
444
|
status: CheckStatus,
|
|
447
|
-
violation?:
|
|
445
|
+
violation?: ReportedViolation,
|
|
448
446
|
failure?: EvaluationFailure,
|
|
449
|
-
): CheckResult =>
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
447
|
+
): CheckResult => {
|
|
448
|
+
const traceSpec = getTraceSpec(
|
|
449
|
+
violation?.trace ?? failure?.trace ?? [],
|
|
450
|
+
status === "property-violation" ? undefined : violation?.loopStart,
|
|
451
|
+
);
|
|
452
|
+
return {
|
|
453
|
+
status,
|
|
454
|
+
violation: violation && { ...violation, loopStart: violation.loopStart },
|
|
455
|
+
failure,
|
|
456
|
+
generatedStates: runtime.generatedStates,
|
|
457
|
+
distinctStates: runtime.distinctStates,
|
|
458
|
+
queuedStates: runtime.queueSize,
|
|
459
|
+
depth: runtime.generatedStates === 0 ? 0 : Math.max(searchDepth, 1),
|
|
460
|
+
initialStates: computedInitialStates,
|
|
461
|
+
outDegrees: undefined,
|
|
462
|
+
fingerprintDistance: undefined,
|
|
463
|
+
coverage: getCoverage(),
|
|
464
|
+
...(traceSpec !== undefined && { traceSpec }),
|
|
465
|
+
};
|
|
466
|
+
};
|
|
461
467
|
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.
|
|
468
|
+
let newStateCount = 0;
|
|
469
|
+
const getOutDegreeBucket = () => Math.min(newStateCount, OUT_DEGREE_BUCKETS - 1);
|
|
466
470
|
const getPartialOutDegrees = () =>
|
|
467
471
|
outDegrees.map((count, degree) => (degree === getOutDegreeBucket() ? count + 1 : count));
|
|
468
472
|
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
473
|
const getViolatedProperties = (checker: LivenessChecker, path: Value[][], cycleStart: number) =>
|
|
471
474
|
is174 ? [] : checker.getViolatedProperties(path, cycleStart);
|
|
472
|
-
// A violation in a successor ends the expansion of a state before TLC counts it.
|
|
473
475
|
const withOutDegrees = (result: CheckResult, degrees = [...outDegrees]): CheckResult => ({
|
|
474
476
|
...result,
|
|
475
477
|
violationOutDegrees: degrees,
|
|
@@ -477,21 +479,30 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
477
479
|
const createSuccess = (): CheckResult => ({
|
|
478
480
|
...createResult("success"),
|
|
479
481
|
outDegrees: [...outDegrees],
|
|
480
|
-
fingerprintDistance:
|
|
481
|
-
|
|
482
|
-
runtime.generatedStates,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
482
|
+
fingerprintDistance: options.isFingerprintDistanceSkipped
|
|
483
|
+
? undefined
|
|
484
|
+
: getFingerprintDistance(runtime.distinctStates, runtime.generatedStates, (visit) =>
|
|
485
|
+
visit(
|
|
486
|
+
search
|
|
487
|
+
? search.getStoredFingerprints(
|
|
488
|
+
exploredStates.length === 0 ? states : states.concat(exploredStates),
|
|
489
|
+
exploredStates.length === 0
|
|
490
|
+
? fingerprintStates
|
|
491
|
+
: fingerprintStates.concat(exploredFingerprintStates),
|
|
492
|
+
)
|
|
493
|
+
: BigInt64Array.from(states, runtime.getFingerprint),
|
|
494
|
+
),
|
|
495
|
+
),
|
|
488
496
|
});
|
|
489
497
|
|
|
490
498
|
const search = createSearch(
|
|
491
499
|
config,
|
|
492
500
|
environment,
|
|
493
|
-
|
|
501
|
+
specification.variableLocations,
|
|
502
|
+
() => created.order.getDeclarationOrder("variable"),
|
|
494
503
|
options.onProgress,
|
|
504
|
+
specification.moduleOperators,
|
|
505
|
+
specification.runtimeInvariants,
|
|
495
506
|
);
|
|
496
507
|
const findViolatedAssumption = () =>
|
|
497
508
|
findAssumptionViolation(specification.assumptions, environment);
|
|
@@ -499,38 +510,38 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
499
510
|
runtime.isStarted = true;
|
|
500
511
|
const assumptionViolation = findViolatedAssumption();
|
|
501
512
|
if (assumptionViolation) return createResult("assumption-violation", assumptionViolation);
|
|
502
|
-
|
|
503
|
-
statistics.initialStates = { generated: 0, distinct: 0 };
|
|
513
|
+
computedInitialStates = { generated: 0, distinct: 0 };
|
|
504
514
|
options.onProgress?.({ kind: "initial-states-started" });
|
|
505
515
|
options.onProgress?.({
|
|
506
516
|
kind: "initial-states-computed",
|
|
507
|
-
initialStates:
|
|
517
|
+
initialStates: computedInitialStates,
|
|
508
518
|
});
|
|
509
519
|
return createSuccess();
|
|
510
520
|
}
|
|
511
|
-
const hasPostconditions =
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const
|
|
521
|
+
const hasPostconditions =
|
|
522
|
+
config.postconditions.length > 0 ||
|
|
523
|
+
config.possible.length > 0 ||
|
|
524
|
+
specification.moduleOperators.some((operator) => operator.kind === "postcondition");
|
|
525
|
+
const tracedSteps = new WeakMap<TraceStep, TracedStep>();
|
|
526
|
+
const getStepState = (step: TraceStep) => tracedSteps.get(step)?.state ?? step.state;
|
|
527
|
+
// TLC's Worker#doPostCondition and LiveCheck bind CounterExample to the alias of each state, while its initial states and lassos keep the states.
|
|
528
|
+
const getStepAlias = (step: TraceStep) => tracedSteps.get(step)?.alias ?? step.state;
|
|
519
529
|
const getStepAction = (step: TraceStep) => {
|
|
520
|
-
const action =
|
|
530
|
+
const action = tracedSteps.get(step)?.action;
|
|
521
531
|
return action ? toActionValue(action) : createActionRecord(step.action);
|
|
522
532
|
};
|
|
523
|
-
// Worker#printTrace checks the postconditions on the CounterExample of each trace it prints, so
|
|
524
|
-
// what they print follows the trace.
|
|
525
533
|
const checkTracePostconditions = (
|
|
526
534
|
trace: TraceStep[],
|
|
527
|
-
loop:
|
|
535
|
+
loop: CounterExampleLoop | undefined,
|
|
536
|
+
getState: (step: TraceStep) => Record<string, Value>,
|
|
537
|
+
isConsole = true,
|
|
528
538
|
) => {
|
|
529
539
|
if (hasPostconditions) {
|
|
530
540
|
runtime.counterExample = createCounterExample(
|
|
531
|
-
trace.map(
|
|
541
|
+
trace.map(getState),
|
|
532
542
|
trace.slice(1).map(getStepAction),
|
|
533
543
|
loop,
|
|
544
|
+
isConsole,
|
|
534
545
|
);
|
|
535
546
|
}
|
|
536
547
|
const unwitnessed = search.findUnwitnessedPossible();
|
|
@@ -541,84 +552,99 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
541
552
|
};
|
|
542
553
|
const reportViolation = (
|
|
543
554
|
status: CheckStatus,
|
|
544
|
-
violation:
|
|
555
|
+
violation: ReportedViolation,
|
|
556
|
+
getState = getStepAlias,
|
|
545
557
|
getLoopAction?: () => Value,
|
|
546
558
|
) => {
|
|
547
559
|
const start = violation.loopStart;
|
|
548
560
|
const checked = checkTracePostconditions(
|
|
549
561
|
violation.trace,
|
|
550
562
|
start === undefined || !getLoopAction ? undefined : { start, action: getLoopAction() },
|
|
563
|
+
getState,
|
|
551
564
|
);
|
|
552
|
-
const traceOutput = [...(violation.traceOutput ?? []), ...checked.lines];
|
|
553
565
|
return createResult(status, {
|
|
554
566
|
...violation,
|
|
555
|
-
...(
|
|
567
|
+
...(checked.lines.length > 0 && { postconditionOutput: checked.lines }),
|
|
556
568
|
...(checked.unwitnessed && { unwitnessed: checked.unwitnessed }),
|
|
557
569
|
...(checked.postcondition && { postcondition: checked.postcondition }),
|
|
558
570
|
});
|
|
559
571
|
};
|
|
560
|
-
//
|
|
561
|
-
|
|
572
|
+
// Deviation from TLC: -continue ends with the status of the first violation, not a success.
|
|
573
|
+
let continuedStatus: CheckStatus | undefined;
|
|
574
|
+
const reportContinuedViolation = (
|
|
575
|
+
status: CheckStatus,
|
|
576
|
+
violation: Omit<Violation, "loopStart">,
|
|
577
|
+
) => {
|
|
578
|
+
continuedStatus ??= status;
|
|
562
579
|
options.onProgress?.({
|
|
563
580
|
kind: "violation",
|
|
564
581
|
status,
|
|
565
582
|
violation: { ...violation, loopStart: undefined },
|
|
566
583
|
});
|
|
584
|
+
};
|
|
567
585
|
const spec = search.spec;
|
|
568
586
|
const getFingerprintState = search.getFingerprintState;
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
587
|
+
// Tool's constructor splits the next-state relation into actions before TLC checks anything.
|
|
588
|
+
const nextActions = getDescription().actions;
|
|
589
|
+
const covered = coverage && addActionCoverage(coverage, environment, getDescription());
|
|
590
|
+
const coverageInits = covered?.inits ?? [];
|
|
591
|
+
const coverageActions = covered?.actions ?? [];
|
|
592
|
+
const hasCoveredIncompleteSuccessor = (action: CoveredAction, state: Value[]) => {
|
|
593
|
+
let complete = 0;
|
|
594
|
+
let incomplete = 0;
|
|
595
|
+
walkSuccessors(
|
|
596
|
+
action,
|
|
597
|
+
action.node,
|
|
598
|
+
state,
|
|
599
|
+
environment,
|
|
600
|
+
() => complete++,
|
|
601
|
+
() => {
|
|
602
|
+
incomplete++;
|
|
603
|
+
return true;
|
|
604
|
+
},
|
|
605
|
+
);
|
|
606
|
+
if (coverage) coverage.primary[action.node] += complete + incomplete;
|
|
607
|
+
return incomplete > 0;
|
|
584
608
|
};
|
|
585
|
-
//
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
609
|
+
// TLC generates the successors of each action again, which its coverage counts.
|
|
610
|
+
const findSuccessorAction = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
611
|
+
coverage
|
|
612
|
+
? coverageActions.find((item) => {
|
|
613
|
+
const successors: Successor[] = [];
|
|
614
|
+
walkCoveredSuccessors(coverage, item, state, environment, (successor) =>
|
|
615
|
+
successors.push({ state: successor, action: item.name }),
|
|
616
|
+
);
|
|
617
|
+
return successors.some(isMatch);
|
|
618
|
+
})
|
|
619
|
+
: nextActions.find((item) =>
|
|
620
|
+
getSuccessors(item.expression, state, environment, item.scope).some(isMatch),
|
|
621
|
+
);
|
|
622
|
+
runtime.getSuccessorAction = (state, next) =>
|
|
623
|
+
findSuccessorAction(state, (successor) =>
|
|
624
|
+
successor.state.every((value, index) => isSameValue(value, next[index])),
|
|
625
|
+
);
|
|
626
|
+
const rejectIncompleteInitialState = (partial: (Value | undefined)[]) => {
|
|
627
|
+
throw setExitCode(new TlaIllegalStateError([...partial]), EXIT_STATUS.error);
|
|
595
628
|
};
|
|
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);
|
|
629
|
+
const getCoveredInitialStates = () => {
|
|
630
|
+
const initialStates: Value[][] = [];
|
|
631
|
+
replayInitialStates(
|
|
632
|
+
coverageInits,
|
|
633
|
+
environment,
|
|
634
|
+
(state) => initialStates.push(state),
|
|
635
|
+
rejectIncompleteInitialState,
|
|
636
|
+
);
|
|
637
|
+
return initialStates;
|
|
612
638
|
};
|
|
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
639
|
const createReplayedStates = () => {
|
|
616
|
-
const replayed =
|
|
640
|
+
const replayed = unstoredFingerprint ? [unstoredFingerprint] : [];
|
|
617
641
|
return (state: Value[], callStack: CallStack | undefined) => {
|
|
618
|
-
fingerprintReplayed(state, callStack);
|
|
642
|
+
fingerprintReplayed(state, getFingerprintState(state), callStack);
|
|
619
643
|
const fingerprintState = getFingerprintState(state);
|
|
644
|
+
const hash = getStateHash(fingerprintState);
|
|
620
645
|
const isSeen =
|
|
621
|
-
findStateIndex(
|
|
646
|
+
findStateIndex(seenStates, hash, fingerprintState) !== -1 ||
|
|
647
|
+
isExplored(hash, fingerprintState) ||
|
|
622
648
|
replayed.some((seen) => isSameState(seen, fingerprintState));
|
|
623
649
|
if (isSeen) return false;
|
|
624
650
|
replayed.push(fingerprintState);
|
|
@@ -626,59 +652,49 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
626
652
|
return true;
|
|
627
653
|
};
|
|
628
654
|
};
|
|
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
655
|
const replayInit = () => {
|
|
633
|
-
|
|
634
|
-
const deferred:
|
|
656
|
+
let replayedCount = 0;
|
|
657
|
+
const deferred: unknown[] = [];
|
|
635
658
|
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
|
-
capturedOutput.lines?.push({
|
|
657
|
-
kind: "initial-state-violation",
|
|
658
|
-
...violation,
|
|
659
|
-
state: traced,
|
|
660
|
-
});
|
|
659
|
+
return getReplayFailure(environment, (tracing) => {
|
|
660
|
+
replayInitialStates(coverage ? coverageInits : getDescription().inits, tracing, (state) => {
|
|
661
|
+
reportInitialStatesProgress(replayedCount, (progress) => capturedLines?.push(progress));
|
|
662
|
+
replayedCount++;
|
|
663
|
+
runtime.generatedStates = replayedCount;
|
|
664
|
+
if (deferred.length > 0) return;
|
|
665
|
+
try {
|
|
666
|
+
const addFingerprint = () => {
|
|
667
|
+
if (!addReplayed(state, tracing.callStack)) return;
|
|
668
|
+
runtime.queueSize++;
|
|
669
|
+
liveness?.addInitialState(states.length, state, tracing);
|
|
670
|
+
};
|
|
671
|
+
search.checkReplayedInitialState(state, tracing, addFingerprint, (violation) => {
|
|
672
|
+
const traced = traces.toTrace([{ action: undefined, state }], []).trace[0].state;
|
|
673
|
+
capturedLines?.push({
|
|
674
|
+
kind: "initial-state-violation",
|
|
675
|
+
...violation,
|
|
676
|
+
state: traced,
|
|
677
|
+
});
|
|
678
|
+
if (!options.isContinued || violation.status !== "invariant-violation") {
|
|
661
679
|
throw STOP_REPLAY;
|
|
662
680
|
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
);
|
|
681
|
+
});
|
|
682
|
+
} catch (error) {
|
|
683
|
+
const isFingerprintFailure =
|
|
684
|
+
error instanceof TlaEvaluationError && tracing.callStack?.fingerprint !== undefined;
|
|
685
|
+
if (!isFingerprintFailure && !isStackOverflow(error)) throw error;
|
|
686
|
+
deferred.push(error);
|
|
687
|
+
}
|
|
688
|
+
});
|
|
671
689
|
if (deferred.length > 0) throw deferred[0];
|
|
672
690
|
});
|
|
673
691
|
};
|
|
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
692
|
const replayNext = (index: number) =>
|
|
677
|
-
getReplayFailure((tracing) => {
|
|
693
|
+
getReplayFailure(environment, (tracing) => {
|
|
678
694
|
const state = states[index];
|
|
679
695
|
const source = stateWriter && getGraphState(state, depths[index]);
|
|
680
696
|
const addReplayed = createReplayedStates();
|
|
681
|
-
replaySuccessors(
|
|
697
|
+
replaySuccessors(coverage ? coverageActions : nextActions, state, tracing, (next, action) => {
|
|
682
698
|
const addFingerprint = () => {
|
|
683
699
|
const isUnseen = addReplayed(next, tracing.callStack);
|
|
684
700
|
if (source) {
|
|
@@ -686,9 +702,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
686
702
|
source,
|
|
687
703
|
getGraphState(next, depths[index] + 1),
|
|
688
704
|
!isUnseen,
|
|
689
|
-
isNamingEdges
|
|
690
|
-
? { name: action.name, signature: getActionSignature(action) }
|
|
691
|
-
: undefined,
|
|
705
|
+
isNamingEdges ? getGraphAction(action) : undefined,
|
|
692
706
|
);
|
|
693
707
|
}
|
|
694
708
|
return isUnseen;
|
|
@@ -698,9 +712,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
698
712
|
}
|
|
699
713
|
});
|
|
700
714
|
});
|
|
701
|
-
const isReducing = config.view !== undefined || config.symmetry !== undefined;
|
|
702
715
|
const tlcFingerprints: number[] = [];
|
|
703
|
-
// TLC warns about the liveness checker before it builds it.
|
|
704
716
|
if (search.properties.liveness.length > 0) {
|
|
705
717
|
options.onProgress?.({
|
|
706
718
|
kind: "liveness-initializing",
|
|
@@ -708,45 +720,88 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
708
720
|
isConstrained: search.isConstrained,
|
|
709
721
|
});
|
|
710
722
|
}
|
|
723
|
+
let liveState: Value[] = [];
|
|
724
|
+
const addIncomplete = (successor: State, action: string | undefined) => {
|
|
725
|
+
if (
|
|
726
|
+
search.satisfiesConstraints(successor, liveState) &&
|
|
727
|
+
search.satisfiesActionConstraints(liveState, successor)
|
|
728
|
+
) {
|
|
729
|
+
throw createIncompleteSuccessorError(successor, action, environment);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
711
732
|
const liveness = withLivenessExitCode(() =>
|
|
712
733
|
withUnexpectedException(() =>
|
|
713
734
|
createLivenessChecker(search.properties.liveness, spec.temporals, environment, {
|
|
714
|
-
getFingerprint: (
|
|
715
|
-
(tlcFingerprints[index] ??= Number(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
735
|
+
getFingerprint: (successor) =>
|
|
736
|
+
(tlcFingerprints[successor.index] ??= Number(
|
|
737
|
+
BigInt.asIntN(32, runtime.getFingerprint(successor.state)),
|
|
738
|
+
)),
|
|
739
|
+
forEachActionSuccessors: (source, state, onSuccessors, replay) => {
|
|
740
|
+
liveState = state;
|
|
741
|
+
let successors: LiveSuccessor[] = [];
|
|
742
|
+
const addSuccessor = (successor: Value[]) => {
|
|
743
|
+
canonicalizeState(successor);
|
|
744
|
+
const isInModel =
|
|
745
|
+
search.satisfiesConstraints(successor, state) &&
|
|
746
|
+
search.satisfiesActionConstraints(state, successor);
|
|
747
|
+
if (!isInModel) return;
|
|
748
|
+
const fingerprintState = getFingerprintState(successor);
|
|
749
|
+
const hash = getStateHash(fingerprintState);
|
|
750
|
+
const index = findStateIndex(seenStates, hash, fingerprintState);
|
|
751
|
+
successors.push({
|
|
752
|
+
index: index === -1 ? getPendingIndex(hash, fingerprintState) : index,
|
|
753
|
+
state: successor,
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
const visitSuccessor = (successor: Successor) => {
|
|
757
|
+
addSuccessor(successor.state);
|
|
758
|
+
return false;
|
|
759
|
+
};
|
|
760
|
+
const actionCount = coverage ? coverageActions.length : nextActions.length;
|
|
761
|
+
for (let position = 0; position < actionCount; position++) {
|
|
762
|
+
successors = [];
|
|
763
|
+
const livenessSource = current.livenessSource;
|
|
764
|
+
current.livenessSource = source;
|
|
765
|
+
try {
|
|
766
|
+
if (coverage) {
|
|
767
|
+
// TLC's coverage counts the successors of each action the graph generates again.
|
|
768
|
+
walkCoveredSuccessors(
|
|
769
|
+
coverage,
|
|
770
|
+
coverageActions[position],
|
|
771
|
+
state,
|
|
772
|
+
replay ?? environment,
|
|
773
|
+
addSuccessor,
|
|
774
|
+
addIncomplete,
|
|
775
|
+
);
|
|
776
|
+
} else if (replay) {
|
|
777
|
+
const action = nextActions[position];
|
|
778
|
+
walkSuccessors(action, -1, state, replay, addSuccessor, (partial) => {
|
|
779
|
+
addIncomplete(partial, action.name);
|
|
780
|
+
return true;
|
|
781
|
+
});
|
|
782
|
+
} else {
|
|
783
|
+
const action = nextActions[position];
|
|
784
|
+
forEachSuccessor(
|
|
785
|
+
action.expression,
|
|
786
|
+
state,
|
|
787
|
+
environment,
|
|
788
|
+
visitSuccessor,
|
|
789
|
+
action.scope,
|
|
790
|
+
undefined,
|
|
791
|
+
undefined,
|
|
792
|
+
addIncomplete,
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
} finally {
|
|
796
|
+
current.livenessSource = livenessSource;
|
|
797
|
+
}
|
|
798
|
+
onSuccessors(successors);
|
|
743
799
|
}
|
|
744
|
-
return successors;
|
|
745
800
|
},
|
|
746
801
|
}),
|
|
747
802
|
),
|
|
748
803
|
);
|
|
749
|
-
|
|
804
|
+
if (liveness?.branches === 0) throw createTautologyError();
|
|
750
805
|
runtime.isStarted = true;
|
|
751
806
|
const isCanonicalizedFirst = search.isSymmetric || liveness !== undefined;
|
|
752
807
|
|
|
@@ -755,270 +810,145 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
755
810
|
const parents: number[] = [];
|
|
756
811
|
const actions: (string | undefined)[] = [];
|
|
757
812
|
const depths: number[] = [];
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
// TLC evaluates TLCGet("level") and Trace in an alias at the state's position in the trace. The
|
|
774
|
-
// search reads them again once the alias is evaluated, as it goes on with -continue.
|
|
775
|
-
const searchLevel = runtime.getLevel;
|
|
776
|
-
const searchBehavior = runtime.getBehavior;
|
|
777
|
-
runtime.getLevel = () => position + 1;
|
|
778
|
-
runtime.getBehavior = () => steps.slice(0, position + 1).map((step) => step.state);
|
|
779
|
-
try {
|
|
780
|
-
return evaluateAlias(
|
|
781
|
-
alias,
|
|
782
|
-
steps[position].state,
|
|
783
|
-
(steps[position + 1] ?? steps[loopStart ?? position]).state,
|
|
784
|
-
);
|
|
785
|
-
} finally {
|
|
786
|
-
runtime.getLevel = searchLevel;
|
|
787
|
-
runtime.getBehavior = searchBehavior;
|
|
813
|
+
const seenStates = createStateTable(fingerprintStates);
|
|
814
|
+
const exploredStates: Value[][] = [];
|
|
815
|
+
const exploredFingerprintStates: Value[][] = [];
|
|
816
|
+
let exploredTable: StateTable | undefined;
|
|
817
|
+
const isExplored = (hash: number, fingerprintState: Value[]) =>
|
|
818
|
+
exploredTable !== undefined && findStateIndex(exploredTable, hash, fingerprintState) !== -1;
|
|
819
|
+
const pendingFingerprintStates: Value[][] = [];
|
|
820
|
+
let pendingStates: StateTable | undefined;
|
|
821
|
+
const getPendingIndex = (hash: number, fingerprintState: Value[]) => {
|
|
822
|
+
pendingStates ??= createStateTable(pendingFingerprintStates);
|
|
823
|
+
const found = findStateIndex(pendingStates, hash, fingerprintState);
|
|
824
|
+
const position = found === -1 ? pendingFingerprintStates.length : found;
|
|
825
|
+
if (found === -1) {
|
|
826
|
+
markSeenState(pendingStates, hash, position);
|
|
827
|
+
pendingFingerprintStates.push(fingerprintState);
|
|
788
828
|
}
|
|
829
|
+
return -2 - position;
|
|
789
830
|
};
|
|
790
|
-
const
|
|
831
|
+
const canonicalizeState = createCanonicalizer();
|
|
832
|
+
|
|
833
|
+
const toRecord = search.toRecord;
|
|
834
|
+
const getUncoveredInitialStates = () =>
|
|
835
|
+
spec.init === undefined ? [] : getInitialStates(spec.init, environment, spec.scope);
|
|
836
|
+
const getSpecInitialStates = () =>
|
|
837
|
+
coverage ? getCoveredInitialStates() : getUncoveredInitialStates();
|
|
838
|
+
const isUnfingerprintable = (state: Value[]) => {
|
|
791
839
|
try {
|
|
792
|
-
|
|
793
|
-
const value = evaluate(createIdentifier(alias), getContext(environment, state, next));
|
|
794
|
-
const fieldOrder = body.kind === "Record" ? body.fields.map((field) => field.name) : [];
|
|
795
|
-
return toAliasRecord(value, fieldOrder) ?? toRecord(state);
|
|
840
|
+
return getFingerprintState(state).some((value) => getFingerprintError(value) !== undefined);
|
|
796
841
|
} catch (error) {
|
|
797
|
-
if (!(error instanceof
|
|
798
|
-
return
|
|
799
|
-
...toRecord(state),
|
|
800
|
-
_ALIASEvalError: formatNestedMessage(error.message, options.isTool ?? false),
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
};
|
|
804
|
-
// TLC finds the action of a step as the first action that takes it, evaluated as when the search
|
|
805
|
-
// expanded the previous state, by the values of a successor it holds and otherwise by fingerprint.
|
|
806
|
-
const findStepAction = (index: number, previous: Value[], state: Value[], isHeld: boolean) => {
|
|
807
|
-
const actions = getSpecNextActions();
|
|
808
|
-
const expanding = { ...current };
|
|
809
|
-
Object.assign(current, { index, isExpanding: true, candidate: undefined });
|
|
810
|
-
const getKey = isHeld ? (values: Value[]) => values : getFingerprintState;
|
|
811
|
-
const key = getKey(state);
|
|
812
|
-
try {
|
|
813
|
-
return actions.find((item) =>
|
|
814
|
-
getSuccessors(item.expression, previous, environment, item.scope).some((successor) =>
|
|
815
|
-
isSameState(getKey(successor.state), key),
|
|
816
|
-
),
|
|
817
|
-
);
|
|
818
|
-
} finally {
|
|
819
|
-
Object.assign(current, expanding);
|
|
842
|
+
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
843
|
+
return true;
|
|
820
844
|
}
|
|
821
845
|
};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
traceOptions: TraceOptions = {},
|
|
830
|
-
): Behavior => {
|
|
831
|
-
const alias = config.alias;
|
|
832
|
-
const known = traceOptions.known ?? 1;
|
|
833
|
-
// Rebuilding the trace from the initial predicate can reset what TLCSet stored.
|
|
834
|
-
const initialOutput = steps.length > 1 ? captureOutput(getSpecInitialStates).lines : [];
|
|
835
|
-
// TLC finds the action that takes each step before it evaluates the alias.
|
|
836
|
-
const stepActions = steps.map((step, position) =>
|
|
837
|
-
position === 0 || step.action === "Stuttering"
|
|
838
|
-
? { result: undefined, lines: [] }
|
|
839
|
-
: captureOutput(() =>
|
|
840
|
-
findStepAction(
|
|
841
|
-
path[position - 1],
|
|
842
|
-
steps[position - 1].state,
|
|
843
|
-
step.state,
|
|
844
|
-
known === 2 && position === steps.length - 1,
|
|
845
|
-
),
|
|
846
|
-
),
|
|
846
|
+
const checkFailedTrace = (behavior: Behavior, counterExample?: CounterExampleOptions) => {
|
|
847
|
+
if (!counterExample) return { behavior, postcondition: undefined };
|
|
848
|
+
const checked = checkTracePostconditions(
|
|
849
|
+
behavior.trace,
|
|
850
|
+
undefined,
|
|
851
|
+
getStepAlias,
|
|
852
|
+
counterExample.isConsole,
|
|
847
853
|
);
|
|
848
|
-
const outputs = stepActions.map((step) => step.lines);
|
|
849
|
-
const loopStart = traceOptions.loopStart;
|
|
850
|
-
// 1.7.4's LiveWorker#printTrace rebuilds a lasso up to the start of its cycle at once, and then
|
|
851
|
-
// each state of the cycle as it prints it.
|
|
852
|
-
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
853
|
-
const prefixOutput = rebuilt > 0 ? [initialOutput, ...outputs.slice(1, rebuilt)].flat() : [];
|
|
854
854
|
return {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
const traceStep: TraceStep = {
|
|
858
|
-
action: step.action,
|
|
859
|
-
label: action && getActionLabel(action, options.version),
|
|
860
|
-
state:
|
|
861
|
-
alias === undefined
|
|
862
|
-
? toRecord(step.state)
|
|
863
|
-
: getAliasState(alias, steps, position, loopStart),
|
|
864
|
-
output: position === 0 ? prefixOutput : position < rebuilt ? [] : outputs[position],
|
|
865
|
-
};
|
|
866
|
-
if (alias !== undefined || action) {
|
|
867
|
-
traceSteps.set(traceStep, { state: toRecord(step.state), action });
|
|
868
|
-
}
|
|
869
|
-
return traceStep;
|
|
870
|
-
}),
|
|
871
|
-
traceOutput: known > 0 && !is174 ? [initialOutput, ...outputs].flat() : [],
|
|
855
|
+
behavior: appendTraceOutput(behavior, checked.lines),
|
|
856
|
+
postcondition: checked.unwitnessed ?? checked.postcondition,
|
|
872
857
|
};
|
|
873
858
|
};
|
|
874
|
-
const getSpecInitialStates = () =>
|
|
875
|
-
spec.init === undefined ? [] : getInitialStates(spec.init, environment, spec.scope);
|
|
876
|
-
// TLC's Tool#getState rebuilds a successor action by action, up to the first action that
|
|
877
|
-
// generates it. A trace keeps what the spec prints as TLC rebuilds it, so finding its states
|
|
878
|
-
// prints nothing.
|
|
879
|
-
const findTraceSuccessor = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
880
|
-
captureOutput(() => {
|
|
881
|
-
for (const action of getSpecNextActions()) {
|
|
882
|
-
const successor = getSuccessors(action.expression, state, environment, action.scope).find(
|
|
883
|
-
isMatch,
|
|
884
|
-
);
|
|
885
|
-
if (successor) return { ...successor, action: successor.action ?? action.name };
|
|
886
|
-
}
|
|
887
|
-
return undefined;
|
|
888
|
-
}).result;
|
|
889
|
-
const hasFingerprint = (state: Value[], index: number) =>
|
|
890
|
-
isSameState(getFingerprintState(state), fingerprintStates[index]);
|
|
891
|
-
const findSuccessorWithFingerprint = (state: Value[], index: number) =>
|
|
892
|
-
findTraceSuccessor(state, (successor) => hasFingerprint(successor.state, index));
|
|
893
|
-
const getPathStates = (path: number[], nextFailure: string) => {
|
|
894
|
-
const initial = captureOutput(() =>
|
|
895
|
-
isReducing || isImpure(environment)
|
|
896
|
-
? getSpecInitialStates().find((state) => hasFingerprint(state, path[0]))
|
|
897
|
-
: states[path[0]],
|
|
898
|
-
).result;
|
|
899
|
-
if (!initial) throw new TlaEvaluationError(INITIAL_RECOVERY_FAILURE);
|
|
900
|
-
const steps: Successor[] = [{ state: initial, action: undefined }];
|
|
901
|
-
for (let position = 1; position < path.length; position++) {
|
|
902
|
-
const previous = steps[position - 1].state;
|
|
903
|
-
if (path[position - 1] === path[position]) {
|
|
904
|
-
steps.push({ state: previous, action: "Stuttering" });
|
|
905
|
-
continue;
|
|
906
|
-
}
|
|
907
|
-
const successor = findSuccessorWithFingerprint(previous, path[position]);
|
|
908
|
-
if (!successor) throw new TlaEvaluationError(nextFailure);
|
|
909
|
-
steps.push(successor);
|
|
910
|
-
}
|
|
911
|
-
return steps;
|
|
912
|
-
};
|
|
913
|
-
const getTrace = (index: number, lastSuccessor?: Successor) => {
|
|
914
|
-
const path: number[] = [];
|
|
915
|
-
for (let position = index; position !== -1; position = parents[position]) {
|
|
916
|
-
path.unshift(position);
|
|
917
|
-
}
|
|
918
|
-
const steps =
|
|
919
|
-
isReducing && path.length > 1
|
|
920
|
-
? getPathStates(path, INITIAL_RECOVERY_FAILURE)
|
|
921
|
-
: path.map((position) => ({ state: states[position], action: actions[position] }));
|
|
922
|
-
if (!lastSuccessor) return toTrace(steps, path);
|
|
923
|
-
const action = isReducing
|
|
924
|
-
? findTraceSuccessor(states[index], (successor) =>
|
|
925
|
-
isSameState(successor.state, lastSuccessor.state),
|
|
926
|
-
)?.action
|
|
927
|
-
: lastSuccessor.action;
|
|
928
|
-
return toTrace([...steps, { state: lastSuccessor.state, action }], path, { known: 2 });
|
|
929
|
-
};
|
|
930
|
-
// TLC prints a lone initial state without the alias. TLCTrace#getTrace still recovers it from the
|
|
931
|
-
// initial predicate, printing again, though TLC 1.7.4 doesn't.
|
|
932
|
-
const getStateTrace = (index: number): Behavior =>
|
|
933
|
-
parents[index] === -1
|
|
934
|
-
? {
|
|
935
|
-
trace: [{ action: undefined, label: undefined, state: toRecord(states[index]) }],
|
|
936
|
-
traceOutput: is174 ? [] : captureOutput(getSpecInitialStates).lines,
|
|
937
|
-
}
|
|
938
|
-
: getTrace(index);
|
|
939
|
-
// TLC rebuilds the trace again for the postcondition after it prints a violation, but not after
|
|
940
|
-
// an evaluation fails.
|
|
941
|
-
const getFailedTrace = (index: number, successor: Successor): Behavior => ({
|
|
942
|
-
trace: getTrace(index, successor).trace,
|
|
943
|
-
});
|
|
944
|
-
// TLC names the initial state it was checking unless a standard module's Java code failed.
|
|
945
|
-
const getFailureExitCode = (error: TlaEvaluationError, failureOptions: FailureOptions) => {
|
|
946
|
-
// TLC 1.7.4 exits with the result of its replay of the initial states, which only fails again
|
|
947
|
-
// when the error isn't in adding a state it has already seen to the behavior graph.
|
|
948
|
-
if (
|
|
949
|
-
failureOptions.isInitial &&
|
|
950
|
-
!failureOptions.callStack &&
|
|
951
|
-
!failureOptions.fingerprint &&
|
|
952
|
-
is174
|
|
953
|
-
) {
|
|
954
|
-
return EXIT_STATUS.success;
|
|
955
|
-
}
|
|
956
|
-
if (!failureOptions.callStack) {
|
|
957
|
-
return failureOptions.isInitial ? getInitialExitCode(error) : getErrorExitCode(error);
|
|
958
|
-
}
|
|
959
|
-
if (failureOptions.isCallStackFirst) return getErrorExitCode(error);
|
|
960
|
-
// Without a replay, TLC exits with the code of the error, as for any error it didn't expect.
|
|
961
|
-
if (failureOptions.isLiveCallStack) {
|
|
962
|
-
return (
|
|
963
|
-
getExitCode(error) ?? (error instanceof TlaModuleError ? error.exitCode : EXIT_STATUS.error)
|
|
964
|
-
);
|
|
965
|
-
}
|
|
966
|
-
// TLC exits with the code of a failed replay of the initial states regardless of the error, as
|
|
967
|
-
// it does for a replay that fails to fingerprint.
|
|
968
|
-
return failureOptions.isInitial || failureOptions.fingerprint
|
|
969
|
-
? EXIT_STATUS.specEvaluationFailure
|
|
970
|
-
: getReplayExitCode(error);
|
|
971
|
-
};
|
|
972
859
|
const createFailureResult = (
|
|
973
860
|
failed: unknown,
|
|
974
861
|
behavior: Behavior,
|
|
975
862
|
failureOptions: FailureOptions = {},
|
|
863
|
+
postcondition?: Postcondition,
|
|
976
864
|
) => {
|
|
977
865
|
const error = isStackOverflow(failed) ? new TlaStackOverflowError() : failed;
|
|
978
866
|
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
979
|
-
const checked =
|
|
980
|
-
behavior.trace.length > 0 && !failureOptions.traceFailure
|
|
981
|
-
? checkTracePostconditions(behavior.trace, undefined)
|
|
982
|
-
: undefined;
|
|
983
|
-
const postcondition = checked?.unwitnessed ?? checked?.postcondition;
|
|
984
|
-
const traceOutput = [...(behavior.traceOutput ?? []), ...(checked?.lines ?? [])];
|
|
985
867
|
return {
|
|
986
868
|
...createResult("error", undefined, {
|
|
987
|
-
...getFailureMessage(
|
|
869
|
+
...getFailureMessage(
|
|
870
|
+
error,
|
|
871
|
+
failureOptions.phase !== undefined && failureOptions.phase !== "initial",
|
|
872
|
+
),
|
|
988
873
|
...behavior,
|
|
989
|
-
...(traceOutput.length > 0 && { traceOutput }),
|
|
990
874
|
...(postcondition && { postcondition }),
|
|
991
875
|
initialState:
|
|
992
876
|
failureOptions.initialState && !(error instanceof TlaModuleError)
|
|
993
877
|
? toRecord(failureOptions.initialState)
|
|
994
878
|
: undefined,
|
|
995
|
-
exitCode: getFailureExitCode(error, failureOptions),
|
|
879
|
+
exitCode: getFailureExitCode(error, failureOptions, is174),
|
|
996
880
|
callStack: failureOptions.callStack,
|
|
997
|
-
...(failureOptions.
|
|
881
|
+
...(failureOptions.phase === "liveness" && { isCallStackFirst: true }),
|
|
998
882
|
...(failureOptions.fingerprint && { fingerprint: failureOptions.fingerprint }),
|
|
999
883
|
...(failureOptions.traceFailure && { traceFailure: failureOptions.traceFailure }),
|
|
1000
884
|
}),
|
|
1001
885
|
outDegrees: failureOptions.outDegrees,
|
|
1002
886
|
};
|
|
1003
887
|
};
|
|
1004
|
-
// TLC
|
|
1005
|
-
|
|
1006
|
-
|
|
888
|
+
// Deviation from TLC: Worker#doPostCondition throws an ArrayIndexOutOfBoundsException at an incomplete successor, where tla-ts checks the postconditions with the successor in CounterExample.
|
|
889
|
+
const reportIncompleteSuccessor = (
|
|
890
|
+
index: number,
|
|
891
|
+
error: TlaIncompleteSuccessorError,
|
|
892
|
+
liveSuccessors: LiveSuccessor[],
|
|
893
|
+
) => {
|
|
1007
894
|
runtime.generatedStates++;
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
895
|
+
const found = captureOutput(() => {
|
|
896
|
+
try {
|
|
897
|
+
return {
|
|
898
|
+
action: coverage
|
|
899
|
+
? coverageActions.find((item) => hasCoveredIncompleteSuccessor(item, states[index]))
|
|
900
|
+
: nextActions.find((item) =>
|
|
901
|
+
hasIncompleteSuccessor(item.expression, states[index], environment, item.scope),
|
|
902
|
+
),
|
|
903
|
+
failed: undefined,
|
|
904
|
+
};
|
|
905
|
+
} catch (failed) {
|
|
906
|
+
if (!(failed instanceof TlaEvaluationError)) throw failed;
|
|
907
|
+
return { action: undefined, failed };
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
const action = found.result.action;
|
|
911
|
+
const traceFailure = found.result.failed && getTraceFailure(found.result.failed, found.lines);
|
|
912
|
+
const message = getIncompleteSuccessorMessage(
|
|
913
|
+
error.variables,
|
|
914
|
+
error.action,
|
|
915
|
+
nextActions.length,
|
|
916
|
+
options.version,
|
|
917
|
+
);
|
|
918
|
+
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
919
|
+
const trace = traces.getStateTrace(index, {
|
|
920
|
+
incomplete: error.state,
|
|
921
|
+
isPrintedOnly: true,
|
|
922
|
+
}).trace;
|
|
923
|
+
const checked = checkFailedTrace(
|
|
924
|
+
appendTraceOutput(
|
|
925
|
+
{
|
|
926
|
+
trace: traceFailure
|
|
927
|
+
? trace
|
|
928
|
+
: [
|
|
929
|
+
...trace,
|
|
930
|
+
traces.getIncompleteStep(
|
|
931
|
+
error.state,
|
|
932
|
+
trace.length + 1,
|
|
933
|
+
{
|
|
934
|
+
action: error.action,
|
|
935
|
+
label: action && getActionLabel(action, options.version),
|
|
936
|
+
output: found.lines,
|
|
937
|
+
},
|
|
938
|
+
action,
|
|
939
|
+
),
|
|
940
|
+
],
|
|
941
|
+
},
|
|
942
|
+
live.lines,
|
|
943
|
+
),
|
|
944
|
+
{ isConsole: true },
|
|
945
|
+
);
|
|
946
|
+
const failure = createFailureResult(
|
|
947
|
+
error,
|
|
948
|
+
checked.behavior,
|
|
949
|
+
{ callStack: live.result, traceFailure },
|
|
950
|
+
checked.postcondition,
|
|
951
|
+
);
|
|
1022
952
|
return withOutDegrees({
|
|
1023
953
|
...failure,
|
|
1024
954
|
failure: failure.failure && {
|
|
@@ -1027,83 +957,19 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1027
957
|
message,
|
|
1028
958
|
toolMessage: message,
|
|
1029
959
|
exitCode: EXIT_STATUS.specEvaluationFailure,
|
|
1030
|
-
trace: [
|
|
1031
|
-
...failure.failure.trace,
|
|
1032
|
-
{
|
|
1033
|
-
action: error.action,
|
|
1034
|
-
label: action && getActionLabel(action, options.version),
|
|
1035
|
-
state: toRecord(partial),
|
|
1036
|
-
},
|
|
1037
|
-
],
|
|
1038
960
|
},
|
|
1039
961
|
});
|
|
1040
962
|
};
|
|
1041
|
-
const getPathSteps = (path: number[], loopStart?: number) => {
|
|
1042
|
-
const steps = getPathStates(path, NEXT_RECOVERY_FAILURE);
|
|
1043
|
-
const lastState = steps[steps.length - 1].state;
|
|
1044
|
-
const isClosed =
|
|
1045
|
-
!isReducing ||
|
|
1046
|
-
loopStart === undefined ||
|
|
1047
|
-
loopStart === path.length - 1 ||
|
|
1048
|
-
findSuccessorWithFingerprint(lastState, path[loopStart]) !== undefined;
|
|
1049
|
-
if (!isClosed) throw new TlaEvaluationError(NEXT_RECOVERY_FAILURE);
|
|
1050
|
-
return steps;
|
|
1051
|
-
};
|
|
1052
|
-
const getStateHash = (state: Value[]) => {
|
|
1053
|
-
let hash = 0x811c9dc5;
|
|
1054
|
-
for (let index = 0; index < state.length; index++)
|
|
1055
|
-
hash = combineHash(hash, getValueHash(state[index]));
|
|
1056
|
-
return hash & 0x3fffffff;
|
|
1057
|
-
};
|
|
1058
|
-
// TLC fingerprints a state once it finds the state in the model.
|
|
1059
963
|
const fingerprintModelState = (state: Value[]) => {
|
|
1060
964
|
for (const value of state) {
|
|
1061
965
|
const error = getFingerprintError(value);
|
|
1062
966
|
if (error) throw error;
|
|
1063
967
|
}
|
|
1064
968
|
};
|
|
1065
|
-
|
|
1066
|
-
for (let position = 0; position < state.length; position++) {
|
|
1067
|
-
if (!isSameValue(stored[position], state[position])) return false;
|
|
1068
|
-
}
|
|
1069
|
-
return true;
|
|
1070
|
-
};
|
|
1071
|
-
const getSlot = (hash: number) => (Math.imul(hash, 0x9e3779b1) >>> seenStates.shift) << 1;
|
|
1072
|
-
const findStateIndex = (hash: number, state: Value[]) => {
|
|
1073
|
-
const mask = seenStates.slots.length - 1;
|
|
1074
|
-
for (let slot = getSlot(hash); ; slot = (slot + 2) & mask) {
|
|
1075
|
-
const entry = seenStates.slots[slot + 1];
|
|
1076
|
-
if (entry === 0) return -1;
|
|
1077
|
-
if (seenStates.slots[slot] === hash && isSameState(fingerprintStates[entry - 1], state)) {
|
|
1078
|
-
return entry - 1;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
const insertSeen = (hash: number, entry: number) => {
|
|
1083
|
-
const mask = seenStates.slots.length - 1;
|
|
1084
|
-
let slot = getSlot(hash);
|
|
1085
|
-
while (seenStates.slots[slot + 1] !== 0) slot = (slot + 2) & mask;
|
|
1086
|
-
seenStates.slots[slot] = hash;
|
|
1087
|
-
seenStates.slots[slot + 1] = entry;
|
|
1088
|
-
};
|
|
1089
|
-
const markSeen = (hash: number, index: number) => {
|
|
1090
|
-
seenStates.size++;
|
|
1091
|
-
if (seenStates.size * 4 > seenStates.slots.length) {
|
|
1092
|
-
const slots = seenStates.slots;
|
|
1093
|
-
seenStates.slots = new Int32Array(slots.length * 2);
|
|
1094
|
-
seenStates.shift--;
|
|
1095
|
-
for (let slot = 0; slot < slots.length; slot += 2) {
|
|
1096
|
-
if (slots[slot + 1] !== 0) insertSeen(slots[slot], slots[slot + 1]);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
insertSeen(hash, index + 1);
|
|
1100
|
-
};
|
|
1101
|
-
// A new successor that TLC has added to its set of states before it checks the successor, which
|
|
1102
|
-
// the check stores after.
|
|
1103
|
-
const unstoredState = { fingerprint: undefined as Value[] | undefined };
|
|
969
|
+
let unstoredFingerprint: Value[] | undefined;
|
|
1104
970
|
const countDistinctState = (depth: number) => {
|
|
1105
|
-
runtime.distinctStates = states.length + 1;
|
|
1106
|
-
|
|
971
|
+
runtime.distinctStates = states.length + exploredStates.length + 1;
|
|
972
|
+
searchDepth = Math.max(searchDepth, depth);
|
|
1107
973
|
runtime.diameter = Math.max(runtime.diameter, depth);
|
|
1108
974
|
};
|
|
1109
975
|
const addState = (
|
|
@@ -1120,34 +986,69 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1120
986
|
depths.push(depth);
|
|
1121
987
|
};
|
|
1122
988
|
|
|
1123
|
-
const current = {
|
|
989
|
+
const current: SearchPosition = {
|
|
1124
990
|
index: -1,
|
|
1125
991
|
isExpanding: false,
|
|
1126
|
-
candidate: undefined
|
|
992
|
+
candidate: undefined,
|
|
1127
993
|
candidateLevel: 0,
|
|
1128
994
|
livenessSource: -1,
|
|
995
|
+
rebuilt: undefined,
|
|
1129
996
|
};
|
|
997
|
+
const traces = createTraceBuilder({
|
|
998
|
+
config,
|
|
999
|
+
options,
|
|
1000
|
+
environment,
|
|
1001
|
+
search,
|
|
1002
|
+
nextActions,
|
|
1003
|
+
current,
|
|
1004
|
+
states,
|
|
1005
|
+
fingerprintStates,
|
|
1006
|
+
parents,
|
|
1007
|
+
actions,
|
|
1008
|
+
depths,
|
|
1009
|
+
tracedSteps,
|
|
1010
|
+
captureOutput,
|
|
1011
|
+
getInitialStates: getSpecInitialStates,
|
|
1012
|
+
getUncoveredInitialStates,
|
|
1013
|
+
findSuccessorAction,
|
|
1014
|
+
});
|
|
1130
1015
|
const getPath = (index: number): Value[][] =>
|
|
1131
1016
|
index === -1 ? [] : [...getPath(parents[index]), states[index]];
|
|
1017
|
+
// TLC adds a successor's fingerprint to its set before it checks the invariants of the successor.
|
|
1132
1018
|
runtime.isSeen = (state) => {
|
|
1133
1019
|
const fingerprintState = getFingerprintState(state);
|
|
1134
|
-
|
|
1020
|
+
const hash = getStateHash(fingerprintState);
|
|
1021
|
+
return (
|
|
1022
|
+
findStateIndex(seenStates, hash, fingerprintState) !== -1 ||
|
|
1023
|
+
isExplored(hash, fingerprintState) ||
|
|
1024
|
+
(unstoredFingerprint !== undefined && isSameState(unstoredFingerprint, fingerprintState))
|
|
1025
|
+
);
|
|
1026
|
+
};
|
|
1027
|
+
runtime.markExplored = (state) => {
|
|
1028
|
+
const fingerprintState = getFingerprintState(state);
|
|
1029
|
+
exploredTable ??= createStateTable(exploredFingerprintStates);
|
|
1030
|
+
markSeenState(exploredTable, getStateHash(fingerprintState), exploredStates.length);
|
|
1031
|
+
exploredStates.push(state);
|
|
1032
|
+
exploredFingerprintStates.push(fingerprintState);
|
|
1033
|
+
runtime.distinctStates++;
|
|
1135
1034
|
};
|
|
1136
1035
|
runtime.getBehavior = (state) => {
|
|
1137
1036
|
const index = state === current.candidate ? -1 : states.indexOf(state);
|
|
1138
1037
|
return index === -1 ? [...getPath(current.index), state] : getPath(index);
|
|
1139
1038
|
};
|
|
1140
|
-
runtime.getCurrentState = () =>
|
|
1039
|
+
runtime.getCurrentState = () =>
|
|
1040
|
+
current.rebuilt?.state ?? (current.index === -1 ? undefined : states[current.index]);
|
|
1141
1041
|
runtime.setLivenessSource = (index) => {
|
|
1142
1042
|
current.livenessSource = index ?? -1;
|
|
1143
1043
|
};
|
|
1144
1044
|
runtime.getLevel = (state) => {
|
|
1145
1045
|
const source = current.livenessSource;
|
|
1146
|
-
// TLC 1.7.4 reads the level of the state its worker explores, whichever state it evaluates.
|
|
1147
1046
|
if (is174) {
|
|
1148
1047
|
const explored = source !== -1 ? source : current.isExpanding ? current.index : -1;
|
|
1149
1048
|
return explored === -1 ? 0 : depths[explored];
|
|
1150
1049
|
}
|
|
1050
|
+
const rebuilt = current.rebuilt;
|
|
1051
|
+
if (rebuilt) return state === rebuilt.state ? rebuilt.level : rebuilt.level + 1;
|
|
1151
1052
|
if (source !== -1) return state === states[source] ? depths[source] : depths[source] + 1;
|
|
1152
1053
|
if (state === current.candidate) return current.candidateLevel;
|
|
1153
1054
|
if (current.index === -1) return 0;
|
|
@@ -1155,6 +1056,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1155
1056
|
return current.isExpanding ? depths[current.index] + 1 : 0;
|
|
1156
1057
|
};
|
|
1157
1058
|
|
|
1059
|
+
const getGraphAction = (action: SpecAction) => ({
|
|
1060
|
+
name: action.name,
|
|
1061
|
+
signature: getActionSignature(action),
|
|
1062
|
+
});
|
|
1158
1063
|
const getGraphState = (state: Value[], level: number): GraphState => ({
|
|
1159
1064
|
fingerprint: BigInt.asIntN(64, runtime.getFingerprint(state)),
|
|
1160
1065
|
level,
|
|
@@ -1162,28 +1067,29 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1162
1067
|
formatState(
|
|
1163
1068
|
config.alias === undefined
|
|
1164
1069
|
? toRecord(state)
|
|
1165
|
-
: evaluateAlias(config.alias, state, undefined),
|
|
1070
|
+
: search.evaluateAlias(config.alias, state, undefined, options.isTool ?? false),
|
|
1166
1071
|
),
|
|
1167
1072
|
getText: () => formatState(toRecord(state)),
|
|
1168
1073
|
});
|
|
1169
1074
|
|
|
1170
1075
|
const visitInitialState = (state: Value[]) => {
|
|
1171
|
-
canonicalizeState(state);
|
|
1172
1076
|
runtime.generatedStates++;
|
|
1173
1077
|
runtime.initialStates++;
|
|
1174
1078
|
current.candidate = state;
|
|
1175
1079
|
current.candidateLevel = 1;
|
|
1176
|
-
const fingerprintState = getFingerprintState(state);
|
|
1177
|
-
const hash = getStateHash(fingerprintState);
|
|
1178
1080
|
const isInModel = search.satisfiesConstraints(state);
|
|
1081
|
+
// TLC fingerprints only a state in the model, which sorts its records in place.
|
|
1082
|
+
if (isInModel) canonicalizeState(state);
|
|
1083
|
+
const fingerprintState = isInModel ? getFingerprintState(state) : state;
|
|
1084
|
+
const hash = isInModel ? getStateHash(fingerprintState) : 0;
|
|
1179
1085
|
if (isInModel) {
|
|
1180
1086
|
search.trackStatePossible(state);
|
|
1181
1087
|
fingerprintModelState(fingerprintState);
|
|
1182
1088
|
state.forEach(markFingerprinted);
|
|
1183
1089
|
}
|
|
1184
|
-
const isSeen = isInModel && findStateIndex(hash, fingerprintState) !== -1;
|
|
1090
|
+
const isSeen = isInModel && findStateIndex(seenStates, hash, fingerprintState) !== -1;
|
|
1185
1091
|
if (isSeen) return undefined;
|
|
1186
|
-
|
|
1092
|
+
unstoredFingerprint = isInModel ? fingerprintState : undefined;
|
|
1187
1093
|
if (isInModel) {
|
|
1188
1094
|
countDistinctState(1);
|
|
1189
1095
|
runtime.queueSize++;
|
|
@@ -1191,32 +1097,56 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1191
1097
|
stateWriter?.writeInitialState(getGraphState(state, 1));
|
|
1192
1098
|
}
|
|
1193
1099
|
if (options.isContinued) {
|
|
1194
|
-
search.
|
|
1100
|
+
search.forEachViolatedInvariant(state, (invariant) =>
|
|
1195
1101
|
reportContinuedViolation("invariant-violation", {
|
|
1196
1102
|
name: invariant.name,
|
|
1197
|
-
...toTrace([{ action: undefined, state }], []),
|
|
1103
|
+
...traces.toTrace([{ action: undefined, state }], []),
|
|
1198
1104
|
}),
|
|
1199
1105
|
);
|
|
1200
1106
|
}
|
|
1201
1107
|
const violated = options.isContinued ? undefined : search.findViolatedInvariant(state);
|
|
1202
1108
|
if (violated) {
|
|
1203
|
-
return reportViolation(
|
|
1204
|
-
|
|
1205
|
-
...toTrace([{ action: undefined, state }], []),
|
|
1206
|
-
|
|
1109
|
+
return reportViolation(
|
|
1110
|
+
"invariant-violation",
|
|
1111
|
+
{ name: violated.name, ...traces.toTrace([{ action: undefined, state }], []) },
|
|
1112
|
+
getStepState,
|
|
1113
|
+
);
|
|
1207
1114
|
}
|
|
1208
1115
|
const failedPredicate = search.findFailedInitialPredicate(state);
|
|
1209
1116
|
if (failedPredicate) {
|
|
1210
|
-
return reportViolation(
|
|
1211
|
-
|
|
1212
|
-
...toTrace([{ action: undefined, state }], []),
|
|
1213
|
-
|
|
1117
|
+
return reportViolation(
|
|
1118
|
+
"liveness-violation",
|
|
1119
|
+
{ name: failedPredicate.name, ...traces.toTrace([{ action: undefined, state }], []) },
|
|
1120
|
+
getStepState,
|
|
1121
|
+
);
|
|
1214
1122
|
}
|
|
1215
1123
|
if (!isInModel) return undefined;
|
|
1216
|
-
|
|
1124
|
+
markSeenState(seenStates, hash, states.length);
|
|
1217
1125
|
addState(state, fingerprintState, -1, undefined);
|
|
1218
1126
|
return undefined;
|
|
1219
1127
|
};
|
|
1128
|
+
// Looks a successor up, where the constraints keep it in the model, as the search does before it
|
|
1129
|
+
// checks the successor.
|
|
1130
|
+
const lookUpSuccessor = (state: Value[], successor: Successor) => {
|
|
1131
|
+
const isStateInModel = search.satisfiesConstraints(successor.state, state);
|
|
1132
|
+
if (isStateInModel) search.trackStatePossible(successor.state);
|
|
1133
|
+
const isInModel = isStateInModel && search.satisfiesActionConstraints(state, successor.state);
|
|
1134
|
+
const fingerprintState = isInModel ? getFingerprintState(successor.state) : successor.state;
|
|
1135
|
+
const hash = isInModel ? getStateHash(fingerprintState) : 0;
|
|
1136
|
+
if (isInModel) {
|
|
1137
|
+
search.trackActionPossible(state, successor.state);
|
|
1138
|
+
fingerprintModelState(fingerprintState);
|
|
1139
|
+
successor.state.forEach(markFingerprinted);
|
|
1140
|
+
}
|
|
1141
|
+
const existing = isInModel ? findStateIndex(seenStates, hash, fingerprintState) : -1;
|
|
1142
|
+
return {
|
|
1143
|
+
fingerprintState,
|
|
1144
|
+
hash,
|
|
1145
|
+
isInModel,
|
|
1146
|
+
existing,
|
|
1147
|
+
isSeen: existing !== -1 || (isInModel && isExplored(hash, fingerprintState)),
|
|
1148
|
+
};
|
|
1149
|
+
};
|
|
1220
1150
|
const visitSuccessor = (
|
|
1221
1151
|
index: number,
|
|
1222
1152
|
successor: Successor,
|
|
@@ -1229,56 +1159,67 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1229
1159
|
current.candidate = successor.state;
|
|
1230
1160
|
current.candidateLevel = depths[index] + 1;
|
|
1231
1161
|
if (isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
const foundIndex = findStateIndex(hash, fingerprintState);
|
|
1235
|
-
const isStateInModel = search.satisfiesConstraints(successor.state, state);
|
|
1236
|
-
if (isStateInModel) search.trackStatePossible(successor.state);
|
|
1237
|
-
const isInModel = isStateInModel && search.satisfiesActionConstraints(state, successor.state);
|
|
1238
|
-
if (isInModel) {
|
|
1239
|
-
search.trackActionPossible(state, successor.state);
|
|
1240
|
-
fingerprintModelState(fingerprintState);
|
|
1241
|
-
successor.state.forEach(markFingerprinted);
|
|
1242
|
-
}
|
|
1243
|
-
const existing = isInModel ? foundIndex : -1;
|
|
1244
|
-
if (source && isInModel) {
|
|
1162
|
+
const found = lookUpSuccessor(state, successor);
|
|
1163
|
+
if (source && found.isInModel) {
|
|
1245
1164
|
stateWriter?.writeSuccessor(
|
|
1246
1165
|
source,
|
|
1247
1166
|
getGraphState(successor.state, depths[index] + 1),
|
|
1248
|
-
|
|
1249
|
-
action &&
|
|
1167
|
+
found.isSeen,
|
|
1168
|
+
action && getGraphAction(action),
|
|
1250
1169
|
);
|
|
1251
1170
|
}
|
|
1252
|
-
if (
|
|
1253
|
-
const
|
|
1171
|
+
if (source && !found.isInModel && options.dump?.constrained) {
|
|
1172
|
+
const excluded = getGraphState(successor.state, depths[index] + 1);
|
|
1173
|
+
search
|
|
1174
|
+
.getExcludingConstraints(state, successor.state)
|
|
1175
|
+
.forEach((constraint) =>
|
|
1176
|
+
stateWriter?.writeConstrained(
|
|
1177
|
+
source,
|
|
1178
|
+
excluded,
|
|
1179
|
+
action && getGraphAction(action),
|
|
1180
|
+
constraint,
|
|
1181
|
+
),
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
if (found.existing !== -1 && liveness) {
|
|
1185
|
+
const stored = states[found.existing];
|
|
1254
1186
|
const isStored = stored.every((value, position) => value === successor.state[position]);
|
|
1255
|
-
liveSuccessors.push({ index: existing, state: isStored ? stored : successor.state });
|
|
1187
|
+
liveSuccessors.push({ index: found.existing, state: isStored ? stored : successor.state });
|
|
1188
|
+
}
|
|
1189
|
+
if (found.isSeen && found.existing === -1 && liveness) {
|
|
1190
|
+
liveSuccessors.push({
|
|
1191
|
+
index: getPendingIndex(found.hash, found.fingerprintState),
|
|
1192
|
+
state: successor.state,
|
|
1193
|
+
});
|
|
1256
1194
|
}
|
|
1257
|
-
const isNew = isInModel &&
|
|
1258
|
-
// TLC adds a new state to the behavior graph's successors before it checks the invariants.
|
|
1195
|
+
const isNew = found.isInModel && !found.isSeen;
|
|
1259
1196
|
if (isNew && liveness) liveSuccessors.push({ index: states.length, state: successor.state });
|
|
1260
|
-
|
|
1197
|
+
unstoredFingerprint = isNew ? found.fingerprintState : undefined;
|
|
1261
1198
|
if (isNew) {
|
|
1262
1199
|
countDistinctState(depths[index] + 1);
|
|
1263
|
-
|
|
1200
|
+
newStateCount++;
|
|
1201
|
+
if (coverage) coverage.secondary[coveredNode]++;
|
|
1264
1202
|
}
|
|
1265
|
-
if (
|
|
1203
|
+
if (!found.isSeen) {
|
|
1266
1204
|
try {
|
|
1267
1205
|
const violated = search.findViolatedInvariant(successor.state, state);
|
|
1268
|
-
const violation = violated && {
|
|
1206
|
+
const violation = violated && {
|
|
1207
|
+
name: violated.name,
|
|
1208
|
+
...traces.getTrace(index, successor, { isPrintedOnly: options.isContinued }),
|
|
1209
|
+
};
|
|
1269
1210
|
if (violation && !options.isContinued) {
|
|
1270
1211
|
return withOutDegrees(reportViolation("invariant-violation", violation));
|
|
1271
1212
|
}
|
|
1272
1213
|
if (violation) reportContinuedViolation("invariant-violation", violation);
|
|
1273
1214
|
} catch (error) {
|
|
1274
1215
|
if (isStackOverflow(error)) throw error;
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1216
|
+
const behavior = traces.getTrace(index, successor, { isPrintedOnly: true });
|
|
1217
|
+
const replay = is174
|
|
1218
|
+
? captureOutput(() => replayNext(index))
|
|
1219
|
+
: replayFailedNext(index, liveSuccessors);
|
|
1279
1220
|
return createFailureResult(
|
|
1280
1221
|
error,
|
|
1281
|
-
appendTraceOutput(
|
|
1222
|
+
appendTraceOutput(behavior, replay.lines),
|
|
1282
1223
|
replay.result ?? { outDegrees: getFailureOutDegrees() },
|
|
1283
1224
|
);
|
|
1284
1225
|
}
|
|
@@ -1286,81 +1227,172 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1286
1227
|
const violatedProperty = search.findViolatedActionProperty(state, successor.state);
|
|
1287
1228
|
const propertyViolation = violatedProperty && {
|
|
1288
1229
|
name: violatedProperty.name,
|
|
1289
|
-
...getTrace(index, successor),
|
|
1230
|
+
...traces.getTrace(index, successor, { isPrintedOnly: options.isContinued }),
|
|
1290
1231
|
};
|
|
1291
1232
|
if (propertyViolation && !options.isContinued) {
|
|
1292
1233
|
return withOutDegrees(reportViolation("liveness-violation", propertyViolation));
|
|
1293
1234
|
}
|
|
1294
1235
|
if (propertyViolation) reportContinuedViolation("liveness-violation", propertyViolation);
|
|
1295
1236
|
if (!isNew) return undefined;
|
|
1237
|
+
if (coverage) countCoverageVariables(coverage, successor.state);
|
|
1296
1238
|
if (!isCanonicalizedFirst) canonicalizeState(successor.state);
|
|
1297
|
-
|
|
1298
|
-
|
|
1239
|
+
markSeenState(seenStates, found.hash, states.length);
|
|
1240
|
+
if (pendingStates) {
|
|
1241
|
+
const pending = findStateIndex(pendingStates, found.hash, found.fingerprintState);
|
|
1242
|
+
if (pending !== -1) liveness?.storeState(-2 - pending, states.length);
|
|
1243
|
+
}
|
|
1244
|
+
addState(successor.state, found.fingerprintState, index, successor.action);
|
|
1299
1245
|
runtime.queueSize++;
|
|
1300
1246
|
return undefined;
|
|
1301
1247
|
};
|
|
1302
1248
|
|
|
1303
|
-
|
|
1249
|
+
let outcome: CheckResult | undefined;
|
|
1250
|
+
let coveredNode = -1;
|
|
1304
1251
|
if (liveness) {
|
|
1305
1252
|
options.onProgress?.({ kind: "liveness-prepared", branches: liveness.branches });
|
|
1306
1253
|
}
|
|
1307
|
-
// TLC checks the assumptions once it has built the liveness checker in ModelChecker's
|
|
1308
|
-
// constructor.
|
|
1309
1254
|
const assumptionViolation = findViolatedAssumption();
|
|
1310
1255
|
if (assumptionViolation) return createResult("assumption-violation", assumptionViolation);
|
|
1311
1256
|
options.onProgress?.({ kind: "initial-states-started" });
|
|
1257
|
+
const typedChecks =
|
|
1258
|
+
!options.isContinued &&
|
|
1259
|
+
options.dump === undefined &&
|
|
1260
|
+
// A set of small integers on the tier is a 31-bit mask, which a lower bound could overflow.
|
|
1261
|
+
options.maxSetSize === undefined &&
|
|
1262
|
+
!hasPostconditions
|
|
1263
|
+
? search.getTypedChecks(liveness?.solutions)
|
|
1264
|
+
: undefined;
|
|
1265
|
+
const typed =
|
|
1266
|
+
typedChecks &&
|
|
1267
|
+
runTypedSearch(environment, {
|
|
1268
|
+
...typedChecks,
|
|
1269
|
+
isDeadlockChecked: config.checkDeadlock,
|
|
1270
|
+
isFingerprinted: !options.isFingerprintDistanceSkipped,
|
|
1271
|
+
livenessCheck: options.livenessCheck ?? "default",
|
|
1272
|
+
});
|
|
1273
|
+
if (typed && !typed.deadlock && !typed.violation && !typed.lasso) {
|
|
1274
|
+
for (let count = 2; count < typed.initialStates.generated; count *= 2) {
|
|
1275
|
+
reportInitialStatesProgress(count, options.onProgress);
|
|
1276
|
+
}
|
|
1277
|
+
options.onProgress?.({ kind: "initial-states-computed", initialStates: typed.initialStates });
|
|
1278
|
+
const statistics = {
|
|
1279
|
+
...createResult("success"),
|
|
1280
|
+
generatedStates: typed.generatedStates,
|
|
1281
|
+
distinctStates: typed.distinctStates,
|
|
1282
|
+
queuedStates: 0,
|
|
1283
|
+
depth: typed.generatedStates === 0 ? 0 : Math.max(typed.depth, 1),
|
|
1284
|
+
initialStates: typed.initialStates,
|
|
1285
|
+
};
|
|
1286
|
+
if (liveness && options.livenessCheck !== "off") {
|
|
1287
|
+
options.onProgress?.({
|
|
1288
|
+
kind: "liveness-started",
|
|
1289
|
+
branches: liveness.branches,
|
|
1290
|
+
isComplete: true,
|
|
1291
|
+
states: liveness.branches * typed.distinctStates,
|
|
1292
|
+
statistics,
|
|
1293
|
+
});
|
|
1294
|
+
options.onProgress?.({ kind: "liveness-finished" });
|
|
1295
|
+
}
|
|
1296
|
+
return {
|
|
1297
|
+
...statistics,
|
|
1298
|
+
outDegrees: typed.outDegrees,
|
|
1299
|
+
fingerprintDistance: options.isFingerprintDistanceSkipped
|
|
1300
|
+
? undefined
|
|
1301
|
+
: getFingerprintDistance(
|
|
1302
|
+
typed.distinctStates,
|
|
1303
|
+
typed.generatedStates,
|
|
1304
|
+
typed.forEachFingerprintRun,
|
|
1305
|
+
),
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1312
1308
|
if (spec.init !== undefined) {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
outcome.result = visitInitialState(state);
|
|
1321
|
-
} catch (error) {
|
|
1322
|
-
const replay = captureOutput(replayInit);
|
|
1323
|
-
outcome.result = createFailureResult(
|
|
1324
|
-
error,
|
|
1325
|
-
{ trace: [], traceOutput: replay.lines },
|
|
1326
|
-
{ initialState: state, ...replay.result, isInitial: true },
|
|
1327
|
-
);
|
|
1328
|
-
}
|
|
1329
|
-
return outcome.result !== undefined;
|
|
1330
|
-
},
|
|
1331
|
-
spec.scope,
|
|
1309
|
+
let overflowState: Value[] | undefined;
|
|
1310
|
+
const reportInitialFailure = (error: unknown, state: Value[]) => {
|
|
1311
|
+
const replay = captureOutput(replayInit);
|
|
1312
|
+
return createFailureResult(
|
|
1313
|
+
error,
|
|
1314
|
+
{ trace: [], traceOutput: replay.lines },
|
|
1315
|
+
{ initialState: state, ...replay.result, phase: "initial" },
|
|
1332
1316
|
);
|
|
1317
|
+
};
|
|
1318
|
+
try {
|
|
1319
|
+
const onInitialState = (state: Value[]) => {
|
|
1320
|
+
reportInitialStatesProgress(runtime.initialStates, options.onProgress);
|
|
1321
|
+
if (overflowState) {
|
|
1322
|
+
runtime.generatedStates++;
|
|
1323
|
+
runtime.initialStates++;
|
|
1324
|
+
return false;
|
|
1325
|
+
}
|
|
1326
|
+
try {
|
|
1327
|
+
outcome = visitInitialState(state);
|
|
1328
|
+
} catch (error) {
|
|
1329
|
+
if (isStackOverflow(error)) overflowState = state;
|
|
1330
|
+
else outcome = reportInitialFailure(error, state);
|
|
1331
|
+
}
|
|
1332
|
+
return outcome !== undefined;
|
|
1333
|
+
};
|
|
1334
|
+
if (coverage) {
|
|
1335
|
+
try {
|
|
1336
|
+
replayInitialStates(
|
|
1337
|
+
coverageInits,
|
|
1338
|
+
environment,
|
|
1339
|
+
(state) => {
|
|
1340
|
+
if (onInitialState(state)) throw STOP_WALK;
|
|
1341
|
+
},
|
|
1342
|
+
rejectIncompleteInitialState,
|
|
1343
|
+
);
|
|
1344
|
+
} catch (error) {
|
|
1345
|
+
if (error !== STOP_WALK) throw error;
|
|
1346
|
+
}
|
|
1347
|
+
} else {
|
|
1348
|
+
forEachInitialState(spec.init, environment, onInitialState, spec.scope);
|
|
1349
|
+
}
|
|
1350
|
+
if (overflowState) {
|
|
1351
|
+
outcome = reportInitialFailure(createStackOverflowError(), overflowState);
|
|
1352
|
+
}
|
|
1333
1353
|
} catch (error) {
|
|
1334
|
-
// TLC prints an illegal initial state with null for each variable it leaves undefined, and
|
|
1335
|
-
// stops before it prints the statistics.
|
|
1336
1354
|
if (error instanceof TlaIllegalStateError) {
|
|
1355
|
+
reportInitialStatesProgress(runtime.initialStates, options.onProgress);
|
|
1356
|
+
runtime.generatedStates++;
|
|
1357
|
+
runtime.initialStates++;
|
|
1358
|
+
const state = error.state.map((value) => value ?? createModelValue("null"));
|
|
1359
|
+
// Deviation from TLC: CounterExample holds a Java null for an unassigned variable and leaks a NullPointerException, where tla-ts binds the model value null.
|
|
1360
|
+
const checked = checkTracePostconditions(
|
|
1361
|
+
[{ action: undefined, label: undefined, state: toRecord(state) }],
|
|
1362
|
+
undefined,
|
|
1363
|
+
getStepState,
|
|
1364
|
+
);
|
|
1365
|
+
const postcondition = checked.unwitnessed ?? checked.postcondition;
|
|
1337
1366
|
const illegal = createFailureResult(
|
|
1338
1367
|
error,
|
|
1339
|
-
{ trace: [] },
|
|
1340
|
-
{ initialState:
|
|
1368
|
+
{ trace: [], traceOutput: checked.lines },
|
|
1369
|
+
{ initialState: state },
|
|
1341
1370
|
);
|
|
1342
1371
|
return {
|
|
1343
1372
|
...illegal,
|
|
1344
|
-
failure: illegal.failure && {
|
|
1373
|
+
failure: illegal.failure && {
|
|
1374
|
+
...illegal.failure,
|
|
1375
|
+
isWithoutStatistics: true,
|
|
1376
|
+
...(postcondition && { postcondition }),
|
|
1377
|
+
},
|
|
1345
1378
|
};
|
|
1346
1379
|
}
|
|
1347
|
-
// TLC prints the error before it replays the initial predicate with its call stack.
|
|
1348
1380
|
const replay = captureOutput(replayInit);
|
|
1349
1381
|
return createFailureResult(
|
|
1350
1382
|
error,
|
|
1351
1383
|
{ trace: [], traceOutput: replay.lines },
|
|
1352
|
-
{ ...replay.result,
|
|
1384
|
+
{ ...replay.result, phase: "initial" },
|
|
1353
1385
|
);
|
|
1354
1386
|
}
|
|
1355
1387
|
}
|
|
1356
|
-
if (outcome
|
|
1357
|
-
|
|
1388
|
+
if (outcome) return outcome;
|
|
1389
|
+
computedInitialStates = {
|
|
1358
1390
|
generated: runtime.initialStates,
|
|
1359
1391
|
distinct: runtime.distinctStates,
|
|
1360
1392
|
};
|
|
1361
1393
|
options.onProgress?.({
|
|
1362
1394
|
kind: "initial-states-computed",
|
|
1363
|
-
initialStates:
|
|
1395
|
+
initialStates: computedInitialStates,
|
|
1364
1396
|
});
|
|
1365
1397
|
|
|
1366
1398
|
const next = spec.next;
|
|
@@ -1372,15 +1404,31 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1372
1404
|
}
|
|
1373
1405
|
return createSuccess();
|
|
1374
1406
|
}
|
|
1375
|
-
// TLC labels and colors an edge of the -dump state graph by the action that generated it. When
|
|
1376
|
-
// the graph names its edges, the search generates successors action by action, as TLC does.
|
|
1377
1407
|
const isNamingEdges = Boolean(
|
|
1378
1408
|
options.dump?.dot && (options.dump.actionLabels || options.dump.colorize),
|
|
1379
1409
|
);
|
|
1380
1410
|
const forEachActionSuccessor = (
|
|
1381
1411
|
state: Value[],
|
|
1412
|
+
onUnsatisfied:
|
|
1413
|
+
| ((successor: Value[], conjunct: Expression, action?: SpecAction) => void)
|
|
1414
|
+
| undefined,
|
|
1382
1415
|
onSuccessor: (successor: Successor, action: SpecAction | undefined) => boolean,
|
|
1383
1416
|
) => {
|
|
1417
|
+
if (coverage) {
|
|
1418
|
+
let successorCount = 0;
|
|
1419
|
+
try {
|
|
1420
|
+
coverageActions.forEach((action) => {
|
|
1421
|
+
coveredNode = action.node;
|
|
1422
|
+
walkCoveredSuccessors(coverage, action, state, environment, (successor) => {
|
|
1423
|
+
successorCount++;
|
|
1424
|
+
if (onSuccessor({ state: successor, action: action.name }, action)) throw STOP_WALK;
|
|
1425
|
+
});
|
|
1426
|
+
});
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
if (error !== STOP_WALK) throw error;
|
|
1429
|
+
}
|
|
1430
|
+
return successorCount;
|
|
1431
|
+
}
|
|
1384
1432
|
if (!isNamingEdges) {
|
|
1385
1433
|
return forEachSuccessor(
|
|
1386
1434
|
next,
|
|
@@ -1388,11 +1436,13 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1388
1436
|
environment,
|
|
1389
1437
|
(successor) => onSuccessor(successor, undefined),
|
|
1390
1438
|
spec.scope,
|
|
1439
|
+
undefined,
|
|
1440
|
+
onUnsatisfied,
|
|
1391
1441
|
);
|
|
1392
1442
|
}
|
|
1393
|
-
|
|
1394
|
-
return
|
|
1395
|
-
if (
|
|
1443
|
+
let isStopped = false;
|
|
1444
|
+
return nextActions.reduce((count, action) => {
|
|
1445
|
+
if (isStopped) return count;
|
|
1396
1446
|
return (
|
|
1397
1447
|
count +
|
|
1398
1448
|
forEachSuccessor(
|
|
@@ -1400,158 +1450,212 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1400
1450
|
state,
|
|
1401
1451
|
environment,
|
|
1402
1452
|
(successor) => {
|
|
1403
|
-
|
|
1404
|
-
return
|
|
1453
|
+
isStopped = onSuccessor(successor, action);
|
|
1454
|
+
return isStopped;
|
|
1405
1455
|
},
|
|
1406
1456
|
action.scope,
|
|
1457
|
+
undefined,
|
|
1458
|
+
onUnsatisfied && ((successor, conjunct) => onUnsatisfied(successor, conjunct, action)),
|
|
1407
1459
|
)
|
|
1408
1460
|
);
|
|
1409
1461
|
}, 0);
|
|
1410
1462
|
};
|
|
1411
|
-
// TLC'
|
|
1412
|
-
// property, and prints the call stack of an error in that, unless the error is a
|
|
1413
|
-
// FingerprintException, which the worker doesn't catch. TLC 1.7.4 prints none.
|
|
1463
|
+
// Deviation from TLC: Worker#doNextCheckLiveness doesn't catch a FingerprintException from its rerun, so TLC prints the behavior without the failure.
|
|
1414
1464
|
const getLiveCallStack = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1415
1465
|
if (!liveness || is174) return undefined;
|
|
1416
|
-
const replay = getReplayFailure((tracing) =>
|
|
1466
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1417
1467
|
liveness.addState(index, states[index], liveSuccessors, tracing),
|
|
1418
1468
|
);
|
|
1419
1469
|
return replay?.callStack.length && !replay.fingerprint ? replay.callStack : undefined;
|
|
1420
1470
|
};
|
|
1421
|
-
// TLC's worker adds the state to the behavior graph after it prints the trace. On an error in that,
|
|
1422
|
-
// it adds the state again to print the call stack instead of replaying the next-state relation,
|
|
1423
|
-
// which TLC 1.7.4 doesn't.
|
|
1424
1471
|
const addFailedLiveState = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1425
1472
|
try {
|
|
1426
1473
|
liveness?.addState(index, states[index], liveSuccessors);
|
|
1427
1474
|
return undefined;
|
|
1428
1475
|
} catch (error) {
|
|
1429
1476
|
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
1477
|
+
// TLC fails to fingerprint an incomplete successor with an exception Worker#doNextCheckLiveness doesn't rerun for a call stack.
|
|
1478
|
+
if (error instanceof TlaIncompleteSuccessorError) return undefined;
|
|
1430
1479
|
return getLiveCallStack(index, liveSuccessors);
|
|
1431
1480
|
}
|
|
1432
1481
|
};
|
|
1433
1482
|
const replayFailedNext = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1434
1483
|
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
1435
1484
|
if (live.result) {
|
|
1436
|
-
const result = { callStack: live.result
|
|
1485
|
+
const result: FailureOptions = { phase: "behavior-graph", callStack: live.result };
|
|
1437
1486
|
return { result, lines: live.lines };
|
|
1438
1487
|
}
|
|
1439
1488
|
const replay = captureOutput(() => replayNext(index));
|
|
1440
|
-
|
|
1489
|
+
const result: FailureOptions =
|
|
1490
|
+
replay.result ?? (is174 ? {} : { outDegrees: getFailureOutDegrees() });
|
|
1491
|
+
return { result, lines: [...live.lines, ...replay.lines] };
|
|
1492
|
+
};
|
|
1493
|
+
const getNextFailureTrace = (index: number, counterExample?: CounterExampleOptions) =>
|
|
1494
|
+
checkFailedTrace(
|
|
1495
|
+
traces.getStateTrace(index, { isPrintedOnly: !counterExample }),
|
|
1496
|
+
counterExample,
|
|
1497
|
+
);
|
|
1498
|
+
const reportNextStateOverflow = (index: number, counterExample?: CounterExampleOptions) => {
|
|
1499
|
+
const checked = getNextFailureTrace(index, counterExample);
|
|
1500
|
+
return createFailureResult(
|
|
1501
|
+
createStackOverflowError(),
|
|
1502
|
+
checked.behavior,
|
|
1503
|
+
{ phase: "next" },
|
|
1504
|
+
checked.postcondition,
|
|
1505
|
+
);
|
|
1441
1506
|
};
|
|
1442
|
-
// TLC
|
|
1443
|
-
//
|
|
1444
|
-
const reportNextStateOverflow = (index: number) =>
|
|
1445
|
-
createFailureResult(createStackOverflowError(), getStateTrace(index));
|
|
1446
|
-
// After the trace, TLC replays the next-state relation with its call stack, printing again.
|
|
1507
|
+
// Deviation from TLC: under -continue, TLC's Worker reports a state whose next-state relation failed as deadlocked, or else reports the failure twice as its replay fails again.
|
|
1508
|
+
// Deviation from TLC: under -continue, ModelChecker#doNextEvalFailed rethrows a failed invariant to Worker#doNextFailed, which reports it again with the code of its error.
|
|
1447
1509
|
const reportNextStateFailure = (
|
|
1448
1510
|
error: unknown,
|
|
1449
1511
|
index: number,
|
|
1450
1512
|
liveSuccessors: LiveSuccessor[],
|
|
1513
|
+
generated: number,
|
|
1451
1514
|
) => {
|
|
1452
|
-
|
|
1515
|
+
// TLC's Worker goes on to find a state without successors deadlocked after it fails, which checks the postconditions.
|
|
1516
|
+
const counterExample =
|
|
1517
|
+
config.checkDeadlock && runtime.generatedStates === generated
|
|
1518
|
+
? { isConsole: false }
|
|
1519
|
+
: undefined;
|
|
1520
|
+
if (isStackOverflow(error)) return reportNextStateOverflow(index, counterExample);
|
|
1521
|
+
const checked = getNextFailureTrace(index, counterExample);
|
|
1453
1522
|
const replay = replayFailedNext(index, liveSuccessors);
|
|
1454
1523
|
return createFailureResult(
|
|
1455
1524
|
withNextStateExitCode(error),
|
|
1456
|
-
appendTraceOutput(
|
|
1457
|
-
{
|
|
1525
|
+
appendTraceOutput(checked.behavior, replay.lines),
|
|
1526
|
+
{ phase: "next", ...replay.result },
|
|
1527
|
+
checked.postcondition,
|
|
1528
|
+
);
|
|
1529
|
+
};
|
|
1530
|
+
const addLiveState = (
|
|
1531
|
+
index: number,
|
|
1532
|
+
liveSuccessors: LiveSuccessor[],
|
|
1533
|
+
source: GraphState | undefined,
|
|
1534
|
+
) => {
|
|
1535
|
+
if (liveness && source && (is174 || options.dump?.stuttering)) {
|
|
1536
|
+
stateWriter?.writeStuttering(source);
|
|
1537
|
+
}
|
|
1538
|
+
const accepted = liveness?.addState(index, states[index], liveSuccessors);
|
|
1539
|
+
if (!liveness || !accepted) return undefined;
|
|
1540
|
+
// Deviation from TLC: under -continue, TLC's LiveCheck throws an InvariantViolatedException after it reports the property, which its Worker reports as unexpected.
|
|
1541
|
+
const steps = traces.getPathSteps(accepted);
|
|
1542
|
+
const properties = getViolatedProperties(
|
|
1543
|
+
liveness,
|
|
1544
|
+
steps.map((step) => step.state),
|
|
1545
|
+
steps.length - 1,
|
|
1458
1546
|
);
|
|
1547
|
+
return reportViolation("property-violation", {
|
|
1548
|
+
name: properties[0],
|
|
1549
|
+
properties,
|
|
1550
|
+
...traces.toTrace(steps, accepted, { known: 0 }),
|
|
1551
|
+
});
|
|
1459
1552
|
};
|
|
1553
|
+
const addReportedLiveState = (
|
|
1554
|
+
index: number,
|
|
1555
|
+
liveSuccessors: LiveSuccessor[],
|
|
1556
|
+
source: GraphState | undefined,
|
|
1557
|
+
) =>
|
|
1558
|
+
captureOutput(() => {
|
|
1559
|
+
try {
|
|
1560
|
+
return {
|
|
1561
|
+
additional: addLiveState(index, liveSuccessors, source)?.violation,
|
|
1562
|
+
isFailed: false,
|
|
1563
|
+
callStack: undefined,
|
|
1564
|
+
};
|
|
1565
|
+
} catch (error) {
|
|
1566
|
+
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
1567
|
+
return {
|
|
1568
|
+
additional: undefined,
|
|
1569
|
+
isFailed: true,
|
|
1570
|
+
callStack: getLiveCallStack(index, liveSuccessors),
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1460
1574
|
const expandState = (index: number, liveSuccessors: LiveSuccessor[]) => {
|
|
1461
1575
|
const state = states[index];
|
|
1462
1576
|
const source = stateWriter && getGraphState(state, depths[index]);
|
|
1463
|
-
const
|
|
1577
|
+
const writeUnsatisfied =
|
|
1578
|
+
source && options.dump?.constrained
|
|
1579
|
+
? (successor: Value[], conjunct: Expression, action?: SpecAction) =>
|
|
1580
|
+
stateWriter?.writeConstrained(
|
|
1581
|
+
source,
|
|
1582
|
+
getGraphState(successor, depths[index] + 1),
|
|
1583
|
+
action && getGraphAction(action),
|
|
1584
|
+
describeRange(conjunct),
|
|
1585
|
+
)
|
|
1586
|
+
: undefined;
|
|
1587
|
+
const successorCount = forEachActionSuccessor(state, writeUnsatisfied, (successor, action) => {
|
|
1464
1588
|
try {
|
|
1465
|
-
outcome
|
|
1589
|
+
outcome = visitSuccessor(index, successor, liveSuccessors, source, action);
|
|
1466
1590
|
} catch (error) {
|
|
1467
1591
|
if (isStackOverflow(error)) {
|
|
1468
|
-
outcome
|
|
1592
|
+
outcome = reportNextStateOverflow(index);
|
|
1469
1593
|
return true;
|
|
1470
1594
|
}
|
|
1471
|
-
// TLC 1.7.4 reports the wrapped error without the trace, except for a failed property,
|
|
1472
|
-
// which it reports with the trace before it rethrows. The error stops its worker before it
|
|
1473
|
-
// adds the state to the behavior graph.
|
|
1474
|
-
const replay = is174
|
|
1475
|
-
? captureOutput(() => replayNext(index))
|
|
1476
|
-
: replayFailedNext(index, liveSuccessors);
|
|
1477
1595
|
if (is174 && error instanceof TlaEvaluationError && !isHeadedError(error)) {
|
|
1478
|
-
|
|
1596
|
+
const replay = captureOutput(() => replayNext(index));
|
|
1597
|
+
outcome = createFailureResult(
|
|
1479
1598
|
new TlaEvaluationError(`${getWrappedException(error)}${error.message}`, error),
|
|
1480
1599
|
appendTraceOutput({ trace: [] }, replay.lines),
|
|
1481
|
-
{
|
|
1600
|
+
{ phase: "next", ...replay.result },
|
|
1482
1601
|
);
|
|
1483
1602
|
return true;
|
|
1484
1603
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
(value) => getFingerprintError(value) !== undefined,
|
|
1489
|
-
);
|
|
1490
|
-
const traceFailure =
|
|
1491
|
-
isTraceFailed && error instanceof TlaEvaluationError
|
|
1492
|
-
? getFailureMessage(
|
|
1493
|
-
isEvalException(error)
|
|
1494
|
-
? new TlaEvaluationError(`${UNEXPECTED_EVAL_EXCEPTION}${error.message}`)
|
|
1495
|
-
: error,
|
|
1496
|
-
true,
|
|
1497
|
-
)
|
|
1604
|
+
const traceError =
|
|
1605
|
+
error instanceof TlaEvaluationError && isUnfingerprintable(successor.state)
|
|
1606
|
+
? error
|
|
1498
1607
|
: undefined;
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1608
|
+
const behavior = traceError
|
|
1609
|
+
? traces.getStateTrace(index, { isPrintedOnly: true })
|
|
1610
|
+
: traces.getTrace(index, successor, { isPrintedOnly: true });
|
|
1611
|
+
const traceFailure =
|
|
1612
|
+
traceError &&
|
|
1613
|
+
getTraceFailure(
|
|
1614
|
+
traceError,
|
|
1615
|
+
captureOutput(() => {
|
|
1616
|
+
try {
|
|
1617
|
+
traces.findStepAction(index, state, successor.state, true);
|
|
1618
|
+
} catch (failed) {
|
|
1619
|
+
if (!(failed instanceof TlaEvaluationError)) throw failed;
|
|
1620
|
+
}
|
|
1621
|
+
}).lines,
|
|
1622
|
+
);
|
|
1623
|
+
const replay = is174
|
|
1624
|
+
? captureOutput(() => replayNext(index))
|
|
1625
|
+
: replayFailedNext(index, liveSuccessors);
|
|
1626
|
+
outcome = createFailureResult(error, appendTraceOutput(behavior, replay.lines), {
|
|
1627
|
+
phase: "next",
|
|
1628
|
+
...replay.result,
|
|
1629
|
+
traceFailure,
|
|
1630
|
+
});
|
|
1507
1631
|
}
|
|
1508
|
-
return outcome
|
|
1632
|
+
return outcome !== undefined;
|
|
1509
1633
|
});
|
|
1510
1634
|
current.isExpanding = false;
|
|
1511
|
-
const result = outcome
|
|
1512
|
-
// TLC 1.7.4's worker stops at a violation.
|
|
1635
|
+
const result = outcome;
|
|
1513
1636
|
if (result?.violation && !is174) {
|
|
1514
|
-
const live =
|
|
1637
|
+
const live = addReportedLiveState(index, liveSuccessors, source);
|
|
1515
1638
|
return {
|
|
1516
1639
|
...result,
|
|
1517
1640
|
violation: appendTraceOutput(result.violation, live.lines),
|
|
1518
|
-
|
|
1641
|
+
// TLC adds the state to the behavior graph before it reports the coverage.
|
|
1642
|
+
coverage: getCoverage(),
|
|
1643
|
+
...(live.result.additional && { additionalViolation: live.result.additional }),
|
|
1644
|
+
...(live.result.callStack && { liveCallStack: live.result.callStack }),
|
|
1519
1645
|
};
|
|
1520
1646
|
}
|
|
1521
1647
|
if (result) return result;
|
|
1522
|
-
const addLiveState = () => {
|
|
1523
|
-
if (liveness && source && is174) stateWriter?.writeStuttering(source);
|
|
1524
|
-
const accepted = liveness?.addState(index, state, liveSuccessors);
|
|
1525
|
-
if (!liveness || !accepted) return undefined;
|
|
1526
|
-
const steps = getPathSteps(accepted);
|
|
1527
|
-
const properties = getViolatedProperties(
|
|
1528
|
-
liveness,
|
|
1529
|
-
steps.map((step) => step.state),
|
|
1530
|
-
steps.length - 1,
|
|
1531
|
-
);
|
|
1532
|
-
return reportViolation("property-violation", {
|
|
1533
|
-
name: properties[0],
|
|
1534
|
-
properties,
|
|
1535
|
-
...toTrace(steps, accepted, { known: 0 }),
|
|
1536
|
-
});
|
|
1537
|
-
};
|
|
1538
1648
|
if (successorCount === 0 && config.checkDeadlock) {
|
|
1539
|
-
const deadlock = reportViolation("deadlock", {
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
// expanded.
|
|
1543
|
-
const live = captureOutput(() => {
|
|
1544
|
-
try {
|
|
1545
|
-
return { additional: addLiveState()?.violation };
|
|
1546
|
-
} catch (error) {
|
|
1547
|
-
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
1548
|
-
return { isFailed: true, callStack: getLiveCallStack(index, liveSuccessors) };
|
|
1549
|
-
}
|
|
1649
|
+
const deadlock = reportViolation("deadlock", {
|
|
1650
|
+
name: "deadlock",
|
|
1651
|
+
...traces.getStateTrace(index),
|
|
1550
1652
|
});
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1653
|
+
const live = addReportedLiveState(index, liveSuccessors, source);
|
|
1654
|
+
const reported = {
|
|
1655
|
+
...deadlock,
|
|
1656
|
+
violation: deadlock.violation && appendTraceOutput(deadlock.violation, live.lines),
|
|
1657
|
+
coverage: getCoverage(),
|
|
1658
|
+
};
|
|
1555
1659
|
const counted = withOutDegrees(
|
|
1556
1660
|
reported,
|
|
1557
1661
|
live.result.isFailed ? getFailureOutDegrees() : getPartialOutDegrees(),
|
|
@@ -1561,34 +1665,27 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1561
1665
|
return live.result.callStack ? { ...counted, liveCallStack: live.result.callStack } : counted;
|
|
1562
1666
|
}
|
|
1563
1667
|
try {
|
|
1564
|
-
return addLiveState();
|
|
1668
|
+
return addLiveState(index, liveSuccessors, source);
|
|
1565
1669
|
} catch (error) {
|
|
1566
|
-
// TLC 1.7.4's worker reports an error in adding a state to the behavior graph as an exception
|
|
1567
|
-
// it didn't expect, without the trace or a call stack, and exits as for any general error.
|
|
1568
1670
|
if (is174 && error instanceof TlaEvaluationError) {
|
|
1569
|
-
const unexpected = new TlaEvaluationError(
|
|
1570
|
-
`${isEvalException(error) ? UNEXPECTED_EVAL_EXCEPTION : UNEXPECTED_EXCEPTION}${error.message}`,
|
|
1571
|
-
);
|
|
1572
1671
|
return createFailureResult(
|
|
1573
|
-
setExitCode(
|
|
1672
|
+
setExitCode(toUnexpectedError(error), EXIT_STATUS.error),
|
|
1574
1673
|
{ trace: [] },
|
|
1575
1674
|
{ outDegrees: getFailureOutDegrees() },
|
|
1576
1675
|
);
|
|
1577
1676
|
}
|
|
1578
|
-
|
|
1579
|
-
// before the error, and reports the error as one in computing next states.
|
|
1580
|
-
const replay = getReplayFailure((tracing) =>
|
|
1677
|
+
const replay = getReplayFailure(environment, (tracing) =>
|
|
1581
1678
|
liveness?.addState(index, state, liveSuccessors, tracing),
|
|
1582
1679
|
);
|
|
1583
|
-
|
|
1680
|
+
const behavior = traces.getStateTrace(index, { isPrintedOnly: true });
|
|
1681
|
+
const replayed = captureOutput(() => replayNext(index));
|
|
1682
|
+
return createFailureResult(error, appendTraceOutput(behavior, replayed.lines), {
|
|
1584
1683
|
outDegrees: getFailureOutDegrees(),
|
|
1585
1684
|
callStack: replay?.callStack.length ? replay.callStack : undefined,
|
|
1586
|
-
|
|
1587
|
-
isCallStackFirst: true,
|
|
1685
|
+
phase: "liveness",
|
|
1588
1686
|
});
|
|
1589
1687
|
}
|
|
1590
1688
|
};
|
|
1591
|
-
// TLC's Liveness#printStutteringCounterExampleWarning.
|
|
1592
1689
|
const getStutteringWarning = () => {
|
|
1593
1690
|
const name = config.specification;
|
|
1594
1691
|
const book =
|
|
@@ -1606,12 +1703,21 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1606
1703
|
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}`,
|
|
1607
1704
|
};
|
|
1608
1705
|
};
|
|
1609
|
-
|
|
1706
|
+
const toLivenessFailure = (error: TlaEvaluationError) =>
|
|
1707
|
+
setExitCode(toUnexpectedError(error), EXIT_STATUS.abort);
|
|
1708
|
+
const getLassoSteps = (path: number[]) => {
|
|
1709
|
+
try {
|
|
1710
|
+
return traces.getPathSteps(path);
|
|
1711
|
+
} catch (error) {
|
|
1712
|
+
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
1713
|
+
throw toLivenessFailure(error);
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1610
1716
|
const reportLasso = (checker: LivenessChecker, lasso: Lasso) => {
|
|
1611
1717
|
const path = [...lasso.prefix, ...lasso.cycle];
|
|
1612
1718
|
const loopStart = lasso.prefix.length;
|
|
1613
|
-
const steps =
|
|
1614
|
-
const trace = toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1719
|
+
const steps = getLassoSteps(path);
|
|
1720
|
+
const trace = traces.toTrace(steps, path, { loopStart, known: 0 }).trace;
|
|
1615
1721
|
const properties = getViolatedProperties(
|
|
1616
1722
|
checker,
|
|
1617
1723
|
steps.map((step) => step.state),
|
|
@@ -1620,11 +1726,28 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1620
1726
|
const cycleStart = path[loopStart];
|
|
1621
1727
|
const cycleEnd = path[path.length - 1];
|
|
1622
1728
|
const lastState = steps[steps.length - 1].state;
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
const
|
|
1729
|
+
const isStuttering = cycleStart === cycleEnd;
|
|
1730
|
+
const loop = isStuttering
|
|
1731
|
+
? { result: undefined, lines: [] }
|
|
1732
|
+
: captureOutput(() => traces.findStepAction(cycleEnd, lastState, states[cycleStart], false));
|
|
1733
|
+
const back =
|
|
1734
|
+
isStuttering || loop.result
|
|
1735
|
+
? undefined
|
|
1736
|
+
: traces.findSuccessorWithFingerprint(lastState, cycleEnd, cycleStart);
|
|
1737
|
+
if (!isStuttering && !loop.result && !back) {
|
|
1738
|
+
options.onProgress?.({
|
|
1739
|
+
kind: "violation",
|
|
1740
|
+
status: "property-violation",
|
|
1741
|
+
violation: {
|
|
1742
|
+
name: properties[0],
|
|
1743
|
+
properties,
|
|
1744
|
+
trace,
|
|
1745
|
+
traceOutput: loop.lines,
|
|
1746
|
+
loopStart: undefined,
|
|
1747
|
+
},
|
|
1748
|
+
});
|
|
1749
|
+
throw toLivenessFailure(new TlaEvaluationError(NEXT_RECOVERY_FAILURE));
|
|
1750
|
+
}
|
|
1628
1751
|
return reportViolation(
|
|
1629
1752
|
"liveness-violation",
|
|
1630
1753
|
{
|
|
@@ -1634,93 +1757,225 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1634
1757
|
traceOutput: loop.lines,
|
|
1635
1758
|
loopStart,
|
|
1636
1759
|
loopLabel: loop.result && getActionLabel(loop.result, options.version),
|
|
1637
|
-
warning:
|
|
1760
|
+
warning: isStuttering && lasso.isCycleConstrained ? getStutteringWarning() : undefined,
|
|
1638
1761
|
},
|
|
1762
|
+
getStepState,
|
|
1639
1763
|
() =>
|
|
1640
|
-
|
|
1764
|
+
isStuttering
|
|
1641
1765
|
? getStepAction(trace[trace.length - 1])
|
|
1642
1766
|
: loop.result
|
|
1643
1767
|
? toActionValue(loop.result)
|
|
1644
|
-
: createActionRecord(
|
|
1768
|
+
: createActionRecord(back?.action),
|
|
1645
1769
|
);
|
|
1646
1770
|
};
|
|
1647
|
-
const isPeriodic = liveness !== undefined && options.livenessCheck
|
|
1771
|
+
const isPeriodic = liveness !== undefined && (options.livenessCheck ?? "default") === "default";
|
|
1648
1772
|
const startedAt = performance.now();
|
|
1649
|
-
const periodic = {
|
|
1650
|
-
|
|
1773
|
+
const periodic = {
|
|
1774
|
+
at: startedAt + PERIODIC_START,
|
|
1775
|
+
checkedCounts: liveness?.getStateCounts().map(() => 1) ?? [],
|
|
1776
|
+
time: 0,
|
|
1777
|
+
coverageCount: Math.trunc(options.coverage ?? 0),
|
|
1778
|
+
};
|
|
1779
|
+
const getGraphStates = (checker: LivenessChecker) =>
|
|
1780
|
+
checker.getStateCounts().reduce((sum, count) => sum + count, 0);
|
|
1781
|
+
const findPeriodicViolation = (checker: LivenessChecker) => {
|
|
1651
1782
|
const now = performance.now();
|
|
1652
|
-
const
|
|
1783
|
+
const counts = checker.getStateCounts();
|
|
1784
|
+
const isGrown = counts.some(
|
|
1785
|
+
(count, branch) =>
|
|
1786
|
+
(count - periodic.checkedCounts[branch]) / periodic.checkedCounts[branch] > LIVENESS_GROWTH,
|
|
1787
|
+
);
|
|
1653
1788
|
if (!isGrown || periodic.time > (now - startedAt) * LIVENESS_RATIO) return undefined;
|
|
1654
|
-
periodic.
|
|
1655
|
-
if (!liveness) return undefined;
|
|
1789
|
+
periodic.checkedCounts = counts;
|
|
1656
1790
|
options.onProgress?.({
|
|
1657
1791
|
kind: "liveness-started",
|
|
1658
|
-
branches:
|
|
1792
|
+
branches: checker.branches,
|
|
1659
1793
|
isComplete: false,
|
|
1660
|
-
states:
|
|
1794
|
+
states: getGraphStates(checker),
|
|
1661
1795
|
statistics: createResult("success"),
|
|
1662
1796
|
});
|
|
1663
|
-
const lasso =
|
|
1797
|
+
const lasso = checker.findViolation();
|
|
1664
1798
|
if (!lasso) options.onProgress?.({ kind: "liveness-finished" });
|
|
1665
1799
|
periodic.time += performance.now() - now;
|
|
1666
1800
|
return lasso;
|
|
1667
1801
|
};
|
|
1668
|
-
|
|
1802
|
+
const adoptTypedSearch = (searched: TypedResult) => {
|
|
1803
|
+
runtime.generatedStates = searched.generatedStates;
|
|
1804
|
+
runtime.distinctStates = searched.distinctStates;
|
|
1805
|
+
runtime.queueSize = searched.queuedStates;
|
|
1806
|
+
runtime.diameter = searched.depth;
|
|
1807
|
+
searchDepth = searched.depth;
|
|
1808
|
+
outDegrees.splice(0, outDegrees.length, ...searched.outDegrees);
|
|
1809
|
+
newStateCount = 0;
|
|
1810
|
+
};
|
|
1811
|
+
// The tier found a state without successors, or a successor that violates an invariant or an
|
|
1812
|
+
// action property. The interpreter rebuilds the tier's path to it and reports it, as it would after
|
|
1813
|
+
// its own search.
|
|
1814
|
+
const path = typed?.deadlock ?? typed?.violation;
|
|
1815
|
+
const initialIndex = path ? states.findIndex((state) => path.isPathState(0, state)) : -1;
|
|
1816
|
+
if (typed && path && initialIndex !== -1) {
|
|
1817
|
+
const steps: { successor: Successor; action: SpecAction | undefined }[] = [];
|
|
1818
|
+
const getLastState = () => steps.at(-1)?.successor.state ?? states[initialIndex];
|
|
1819
|
+
for (let position = 1; position === steps.length + 1 && position < path.length; position++) {
|
|
1820
|
+
// The interpreter expands only the states it stores, which it has canonicalized.
|
|
1821
|
+
canonicalizeState(getLastState());
|
|
1822
|
+
forEachActionSuccessor(getLastState(), undefined, (successor, action) => {
|
|
1823
|
+
if (!path.isPathState(position, successor.state)) return false;
|
|
1824
|
+
steps.push({ successor, action });
|
|
1825
|
+
return true;
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
const isRebuilt = steps.length === path.length - 1;
|
|
1829
|
+
const violating = typed.violation && isRebuilt ? steps.pop() : undefined;
|
|
1830
|
+
if (violating && isCanonicalizedFirst) canonicalizeState(violating.successor.state);
|
|
1831
|
+
const violatedInvariant =
|
|
1832
|
+
violating && search.findViolatedInvariant(violating.successor.state, getLastState());
|
|
1833
|
+
const violatedProperty =
|
|
1834
|
+
violating &&
|
|
1835
|
+
!violatedInvariant &&
|
|
1836
|
+
search.findViolatedActionProperty(getLastState(), violating.successor.state);
|
|
1837
|
+
const violated = violatedInvariant ?? violatedProperty;
|
|
1838
|
+
const isDeadlocked =
|
|
1839
|
+
typed.deadlock !== undefined &&
|
|
1840
|
+
isRebuilt &&
|
|
1841
|
+
forEachActionSuccessor(getLastState(), undefined, () => true) === 0;
|
|
1842
|
+
if (isDeadlocked || violated) {
|
|
1843
|
+
const parent = { index: initialIndex };
|
|
1844
|
+
for (const step of steps) {
|
|
1845
|
+
visitSuccessor(parent.index, step.successor, [], undefined, step.action);
|
|
1846
|
+
parent.index = states.length - 1;
|
|
1847
|
+
}
|
|
1848
|
+
adoptTypedSearch(typed);
|
|
1849
|
+
Object.assign(current, { index: parent.index, candidate: undefined, isExpanding: true });
|
|
1850
|
+
if (violating && violated) {
|
|
1851
|
+
lookUpSuccessor(states[parent.index], violating.successor);
|
|
1852
|
+
current.candidate = violating.successor.state;
|
|
1853
|
+
current.candidateLevel = depths[parent.index] + 1;
|
|
1854
|
+
return withOutDegrees(
|
|
1855
|
+
reportViolation(violatedInvariant ? "invariant-violation" : "liveness-violation", {
|
|
1856
|
+
name: violated.name,
|
|
1857
|
+
...traces.getTrace(parent.index, violating.successor),
|
|
1858
|
+
}),
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1861
|
+
const result = expandState(parent.index, []);
|
|
1862
|
+
if (result) return result;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
// The tier found a behavior that violates a temporal property after its whole search. The
|
|
1866
|
+
// interpreter stores the paths to the lasso's states and reports it, as it would after its own.
|
|
1867
|
+
const lassoSteps = new Map<number, { successor: Successor; action: SpecAction | undefined }>();
|
|
1868
|
+
for (const entry of typed?.lasso?.states ?? []) {
|
|
1869
|
+
const initial = entry.parent === -1 ? states.find(entry.isState) : undefined;
|
|
1870
|
+
if (initial) {
|
|
1871
|
+
lassoSteps.set(entry.index, {
|
|
1872
|
+
successor: { state: initial, action: undefined },
|
|
1873
|
+
action: undefined,
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
const parent = lassoSteps.get(entry.parent)?.successor.state;
|
|
1877
|
+
if (!parent) continue;
|
|
1878
|
+
// The interpreter expands only the states it stores, which it has canonicalized.
|
|
1879
|
+
canonicalizeState(parent);
|
|
1880
|
+
forEachActionSuccessor(parent, undefined, (successor, action) => {
|
|
1881
|
+
if (!entry.isState(successor.state)) return false;
|
|
1882
|
+
lassoSteps.set(entry.index, { successor, action });
|
|
1883
|
+
return true;
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
const lassoIndexes = new Map<number, number>();
|
|
1887
|
+
const typedLasso =
|
|
1888
|
+
typed?.lasso && lassoSteps.size === typed.lasso.states.length ? typed.lasso : undefined;
|
|
1889
|
+
typedLasso?.states.forEach((entry) => {
|
|
1890
|
+
const step = lassoSteps.get(entry.index);
|
|
1891
|
+
const parent = lassoIndexes.get(entry.parent);
|
|
1892
|
+
if (step && parent !== undefined)
|
|
1893
|
+
visitSuccessor(parent, step.successor, [], undefined, step.action);
|
|
1894
|
+
lassoIndexes.set(
|
|
1895
|
+
entry.index,
|
|
1896
|
+
parent === undefined ? states.findIndex(entry.isState) : states.length - 1,
|
|
1897
|
+
);
|
|
1898
|
+
});
|
|
1899
|
+
if (typed && typedLasso) adoptTypedSearch(typed);
|
|
1900
|
+
for (
|
|
1901
|
+
let index = typedLasso ? states.length : 0;
|
|
1902
|
+
index < states.length && !runtime.isStopped;
|
|
1903
|
+
index++
|
|
1904
|
+
) {
|
|
1669
1905
|
current.index = index;
|
|
1670
1906
|
current.candidate = undefined;
|
|
1671
1907
|
runtime.queueSize = states.length - index - 1;
|
|
1672
1908
|
current.isExpanding = true;
|
|
1673
1909
|
const liveSuccessors: LiveSuccessor[] = [];
|
|
1910
|
+
const generated = runtime.generatedStates;
|
|
1674
1911
|
try {
|
|
1675
|
-
outcome
|
|
1912
|
+
outcome = expandState(index, liveSuccessors);
|
|
1676
1913
|
} catch (error) {
|
|
1677
|
-
outcome
|
|
1914
|
+
outcome =
|
|
1678
1915
|
error instanceof TlaIncompleteSuccessorError
|
|
1679
|
-
? reportIncompleteSuccessor(index, error)
|
|
1680
|
-
: reportNextStateFailure(error, index, liveSuccessors);
|
|
1916
|
+
? reportIncompleteSuccessor(index, error, liveSuccessors)
|
|
1917
|
+
: reportNextStateFailure(error, index, liveSuccessors, generated);
|
|
1681
1918
|
}
|
|
1682
|
-
if (outcome
|
|
1919
|
+
if (outcome) return outcome;
|
|
1683
1920
|
outDegrees[getOutDegreeBucket()]++;
|
|
1684
|
-
|
|
1685
|
-
// TLC's AbstractChecker#runTLC checks the liveness properties on the state graph so far, then
|
|
1686
|
-
// reports how far the search got.
|
|
1921
|
+
newStateCount = 0;
|
|
1687
1922
|
if ((isPeriodic || options.onProgress) && performance.now() >= periodic.at) {
|
|
1688
1923
|
periodic.at = performance.now() + PROGRESS_INTERVAL;
|
|
1689
|
-
const lasso = isPeriodic ? findPeriodicViolation(
|
|
1924
|
+
const lasso = isPeriodic && liveness ? findPeriodicViolation(liveness) : undefined;
|
|
1690
1925
|
if (liveness && lasso) return reportLasso(liveness, lasso);
|
|
1691
|
-
options.
|
|
1926
|
+
const isCoverageDue = options.coverage !== undefined && periodic.coverageCount === 0;
|
|
1927
|
+
periodic.coverageCount = isCoverageDue
|
|
1928
|
+
? Math.trunc(options.coverage ?? 0)
|
|
1929
|
+
: periodic.coverageCount - 1;
|
|
1930
|
+
const progress = createResult("success");
|
|
1931
|
+
options.onProgress?.({
|
|
1932
|
+
kind: "progress",
|
|
1933
|
+
statistics: { ...progress, coverage: isCoverageDue ? progress.coverage : undefined },
|
|
1934
|
+
});
|
|
1692
1935
|
}
|
|
1693
1936
|
}
|
|
1694
1937
|
|
|
1695
1938
|
current.index = -1;
|
|
1696
1939
|
current.candidate = undefined;
|
|
1697
|
-
|
|
1940
|
+
const finalLiveness = options.livenessCheck === "off" ? undefined : liveness;
|
|
1941
|
+
if (finalLiveness) {
|
|
1698
1942
|
options.onProgress?.({
|
|
1699
1943
|
kind: "liveness-started",
|
|
1700
|
-
branches:
|
|
1944
|
+
branches: finalLiveness.branches,
|
|
1701
1945
|
isComplete: true,
|
|
1702
|
-
states:
|
|
1946
|
+
states: typedLasso
|
|
1947
|
+
? finalLiveness.branches * runtime.distinctStates
|
|
1948
|
+
: getGraphStates(finalLiveness),
|
|
1703
1949
|
statistics: createResult("success"),
|
|
1704
1950
|
});
|
|
1705
1951
|
}
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1952
|
+
const getLassoIndexes = (indexes: number[]) =>
|
|
1953
|
+
indexes.map((index) => lassoIndexes.get(index) ?? -1);
|
|
1954
|
+
const lasso = typedLasso
|
|
1955
|
+
? {
|
|
1956
|
+
prefix: getLassoIndexes(typedLasso.prefix),
|
|
1957
|
+
cycle: getLassoIndexes(typedLasso.cycle),
|
|
1958
|
+
isCycleConstrained: typedLasso.isCycleConstrained,
|
|
1959
|
+
}
|
|
1960
|
+
: finalLiveness?.findViolation();
|
|
1961
|
+
if (finalLiveness && lasso) return reportLasso(finalLiveness, lasso);
|
|
1708
1962
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1963
|
+
if (finalLiveness) options.onProgress?.({ kind: "liveness-finished" });
|
|
1964
|
+
const missingPostcondition = specification.moduleOperators.find(
|
|
1965
|
+
(operator) => operator.kind === "postcondition" && operator.key === undefined,
|
|
1966
|
+
);
|
|
1967
|
+
if (missingPostcondition) {
|
|
1968
|
+
return createFailureResult(createMissingOperatorError(missingPostcondition), { trace: [] });
|
|
1969
|
+
}
|
|
1970
|
+
const postcondition = search.findPostconditionViolation();
|
|
1971
|
+
if (postcondition) {
|
|
1972
|
+
return createResult("postcondition-violation", {
|
|
1973
|
+
name: postcondition.name,
|
|
1974
|
+
message: postcondition.message,
|
|
1975
|
+
counts: postcondition.counts,
|
|
1976
|
+
trace: [],
|
|
1977
|
+
postcondition,
|
|
1978
|
+
});
|
|
1724
1979
|
}
|
|
1725
|
-
return createSuccess();
|
|
1980
|
+
return continuedStatus ? createResult(continuedStatus) : createSuccess();
|
|
1726
1981
|
};
|