tla-ts 0.0.10-dev.d618a2d79 → 0.0.10-dev.e5c8dc315
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/dist/compile.cjs +3 -3
- package/dist/compile.js +1 -1
- package/dist/deciders.cjs +36 -36
- package/dist/deciders.js +53 -53
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -4
- package/dist/index.d.ts +18 -4
- 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 +56 -56
- package/dist/prove.js +78 -78
- package/dist/run.cjs +40 -44
- package/dist/run.js +42 -46
- package/dist/tlapm.cjs +1 -1
- package/dist/tlapm.js +2 -2
- package/dist/transfer.cjs +97 -92
- package/dist/transfer.js +97 -92
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +1 -1
- package/src/ast.ts +31 -3
- package/src/bags.ts +50 -29
- package/src/builtins.ts +4 -3
- package/src/check-failure.ts +13 -11
- package/src/check-trace.ts +146 -93
- package/src/check.ts +518 -281
- package/src/cli/runtime-invariants.ts +20 -56
- package/src/cli/tlc-arguments.ts +2 -2
- package/src/cli/tlc-output.ts +18 -4
- package/src/cli/tlc.ts +18 -12
- package/src/cli/xml-exporter.ts +1 -1
- package/src/codegen.ts +23 -10
- package/src/coverage.ts +255 -18
- package/src/dependencies.ts +68 -15
- package/src/dfid.ts +101 -36
- package/src/environment.ts +155 -66
- package/src/errors.ts +7 -0
- package/src/evaluate.ts +424 -135
- package/src/exit-codes.ts +28 -14
- package/src/instances.ts +152 -25
- package/src/java-hash.ts +14 -0
- package/src/java-overrides.ts +2 -2
- package/src/levels.ts +675 -236
- package/src/lexer.ts +12 -2
- package/src/liveness-checker.ts +179 -60
- package/src/liveness.ts +55 -10
- package/src/obligations/index.ts +1 -1
- package/src/obligations/normalize.ts +1 -4
- package/src/obligations/printer.ts +5 -5
- package/src/obligations/source.ts +2 -0
- package/src/parallel-worker.ts +8 -2
- package/src/parallel.ts +5 -0
- package/src/parser.ts +180 -149
- package/src/prover/isabelle/isar/attrib.ts +4 -4
- package/src/prover/isabelle/isar/rule-cases.ts +8 -6
- package/src/prover/isabelle/provers/clasimp.ts +1 -1
- package/src/prover/isabelle/provers/hypsubst.ts +2 -2
- package/src/prover/isabelle/pure/rewriter.ts +3 -3
- package/src/prover/isabelle/pure/term.ts +3 -3
- package/src/prover/prep/md5.ts +26 -29
- package/src/prover/smt/rewrite.ts +2 -7
- package/src/prover/smt/simplify.ts +1 -1
- package/src/prover/smt/solver/ackermannize-bv-tactic.ts +3 -2
- package/src/prover/smt/solver/arith-rewriter.ts +11 -3
- package/src/prover/smt/solver/array-rewriter.ts +12 -2
- package/src/prover/smt/solver/asserted-formulas.ts +171 -58
- package/src/prover/smt/solver/ast-lt.ts +1 -1
- package/src/prover/smt/solver/ast.ts +66 -14
- package/src/prover/smt/solver/auf-solver.ts +23 -12
- package/src/prover/smt/solver/bit-blast-tactic.ts +28 -2
- package/src/prover/smt/solver/blast-term-ite.ts +47 -0
- package/src/prover/smt/solver/bound-simplifier.ts +11 -13
- package/src/prover/smt/solver/bv-decl-plugin.ts +13 -10
- package/src/prover/smt/solver/bv-rewriter.ts +1 -1
- package/src/prover/smt/solver/bv1-blast.ts +1 -1
- package/src/prover/smt/solver/card2bv.ts +35 -18
- package/src/prover/smt/solver/cofactor-elim-term-ite.ts +39 -24
- package/src/prover/smt/solver/context.ts +84 -15
- package/src/prover/smt/solver/ctx-simplify.ts +9 -4
- package/src/prover/smt/solver/datatype-decl-plugin.ts +15 -7
- package/src/prover/smt/solver/dependent-expr-state.ts +28 -16
- package/src/prover/smt/solver/diff-neq.ts +9 -8
- package/src/prover/smt/solver/dt2bv-tactic.ts +66 -28
- package/src/prover/smt/solver/elim-bounds.ts +89 -0
- package/src/prover/smt/solver/elim-term-ite-tactic.ts +48 -0
- package/src/prover/smt/solver/elim-uncnstr.ts +31 -28
- package/src/prover/smt/solver/eq2bv-tactic.ts +15 -6
- package/src/prover/smt/solver/euf/arith-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/array-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/bv-internalize.ts +1 -1
- package/src/prover/smt/solver/euf/egraph.ts +4 -11
- package/src/prover/smt/solver/euf/euf-solver.ts +1 -2
- package/src/prover/smt/solver/euf/mam.ts +1 -5
- package/src/prover/smt/solver/euf/q-ematch.ts +1 -2
- package/src/prover/smt/solver/euf/th-solver.ts +0 -7
- package/src/prover/smt/solver/expr2polynomial.ts +204 -79
- package/src/prover/smt/solver/factor.ts +36 -14
- package/src/prover/smt/solver/fd-solver.ts +608 -139
- package/src/prover/smt/solver/fix-dl-var.ts +2 -3
- package/src/prover/smt/solver/fm-tactic.ts +9 -7
- package/src/prover/smt/solver/fpa-rewriter.ts +1 -2
- package/src/prover/smt/solver/fpa2bv-converter.ts +3 -1
- package/src/prover/smt/solver/fpa2bv-rewriter.ts +1 -0
- package/src/prover/smt/solver/fpa2bv-tactic.ts +1 -1
- package/src/prover/smt/solver/goal.ts +6 -3
- package/src/prover/smt/solver/goal2nlsat.ts +57 -30
- package/src/prover/smt/solver/hashtable.ts +4 -0
- package/src/prover/smt/solver/internalizer.ts +1 -1
- package/src/prover/smt/solver/lia2pb.ts +1 -1
- package/src/prover/smt/solver/logic-tactics.ts +15 -5
- package/src/prover/smt/solver/lp/core-solver.ts +12 -8
- package/src/prover/smt/solver/lp/lar-solver.ts +1 -1
- package/src/prover/smt/solver/lp/lp-settings.ts +6 -2
- package/src/prover/smt/solver/lp/nla-core.ts +1 -1
- package/src/prover/smt/solver/lp/nla-grobner.ts +158 -80
- package/src/prover/smt/solver/lp/nra-solver.ts +45 -39
- package/src/prover/smt/solver/lp/pdd-interval.ts +6 -2
- package/src/prover/smt/solver/lp/pdd-simplifier.ts +60 -20
- package/src/prover/smt/solver/lp/pdd-solver.ts +72 -39
- package/src/prover/smt/solver/lp/pdd.ts +725 -290
- package/src/prover/smt/solver/lp/union-find.ts +1 -1
- package/src/prover/smt/solver/mam-compiler.ts +1 -1
- package/src/prover/smt/solver/maxcore.ts +2 -1
- package/src/prover/smt/solver/maxsmt-base.ts +1 -0
- package/src/prover/smt/solver/model-based-opt.ts +1 -1
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/model-evaluator.ts +2 -0
- package/src/prover/smt/solver/model-generator.ts +85 -43
- package/src/prover/smt/solver/mpf.ts +2 -4
- package/src/prover/smt/solver/mus.ts +2 -3
- package/src/prover/smt/solver/muz/dl-context.ts +22 -44
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +1 -1
- package/src/prover/smt/solver/muz/dl-mk-slice.ts +3 -3
- package/src/prover/smt/solver/muz/dl-rule.ts +8 -9
- package/src/prover/smt/solver/muz/hnf.ts +2 -2
- package/src/prover/smt/solver/muz/horn-subsume-model-converter.ts +1 -1
- package/src/prover/smt/solver/muz/horn-tactic.ts +15 -2
- package/src/prover/smt/solver/muz/rule-properties.ts +22 -0
- package/src/prover/smt/solver/muz/spacer-context.ts +2 -4
- package/src/prover/smt/solver/muz/spacer-pdr.ts +1 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +1 -1
- package/src/prover/smt/solver/nlqsat.ts +2 -1
- package/src/prover/smt/solver/nlsat/algebraic.ts +196 -92
- package/src/prover/smt/solver/nlsat/atoms.ts +52 -33
- package/src/prover/smt/solver/nlsat/explain.ts +375 -217
- package/src/prover/smt/solver/nlsat/levelwise.ts +460 -240
- package/src/prover/smt/solver/nlsat/polynomial.ts +2366 -681
- package/src/prover/smt/solver/nlsat/solver.ts +74 -64
- package/src/prover/smt/solver/nlsat/transcendentals.ts +41 -17
- package/src/prover/smt/solver/nlsat/upolynomial-factorization.ts +8 -4
- package/src/prover/smt/solver/nlsat/upolynomial.ts +41 -18
- package/src/prover/smt/solver/nlsat-tactic.ts +1 -1
- package/src/prover/smt/solver/nnf.ts +6 -2
- package/src/prover/smt/solver/normalize-bounds.ts +2 -2
- package/src/prover/smt/solver/occf.ts +1 -1
- package/src/prover/smt/solver/opt-context.ts +21 -7
- package/src/prover/smt/solver/opt-nlsat.ts +29 -18
- package/src/prover/smt/solver/opt-pareto.ts +19 -0
- package/src/prover/smt/solver/opt-preprocess.ts +1 -1
- package/src/prover/smt/solver/opt-solver.ts +10 -6
- package/src/prover/smt/solver/optsmt.ts +1 -1
- package/src/prover/smt/solver/parallel-tactic.ts +1 -1
- package/src/prover/smt/solver/pb-rewriter.ts +1 -4
- package/src/prover/smt/solver/pb2bv-tactic.ts +9 -3
- package/src/prover/smt/solver/poly-rewriter.ts +75 -18
- package/src/prover/smt/solver/probes.ts +88 -23
- package/src/prover/smt/solver/proto-model.ts +8 -8
- package/src/prover/smt/solver/purify-arith.ts +51 -49
- package/src/prover/smt/solver/push-app-ite.ts +37 -0
- package/src/prover/smt/solver/qe-arith-plugin.ts +2 -4
- package/src/prover/smt/solver/qe-lite.ts +2 -2
- package/src/prover/smt/solver/qe.ts +3 -2
- package/src/prover/smt/solver/qsat.ts +23 -8
- package/src/prover/smt/solver/quantifier-manager.ts +14 -9
- package/src/prover/smt/solver/recfun-decl-plugin.ts +2 -1
- package/src/prover/smt/solver/reduce-args.ts +2 -2
- package/src/prover/smt/solver/rewriter-tpl.ts +7 -6
- package/src/prover/smt/solver/rewriter.ts +31 -25
- package/src/prover/smt/solver/rlimit.ts +7 -3
- package/src/prover/smt/solver/sat/config.ts +1 -1
- package/src/prover/smt/solver/sat/goal2sat.ts +75 -12
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +149 -47
- package/src/prover/smt/solver/sat/model-converter.ts +1 -1
- package/src/prover/smt/solver/sat/pb-constraint.ts +7 -0
- package/src/prover/smt/solver/sat/pb-solver.ts +26 -7
- package/src/prover/smt/solver/sat/sat-tactic.ts +54 -25
- package/src/prover/smt/solver/sat/sat2goal.ts +75 -50
- package/src/prover/smt/solver/sat/simplifier.ts +1 -1
- package/src/prover/smt/solver/sat/solver.ts +27 -47
- package/src/prover/smt/solver/seq-axioms.ts +20 -35
- package/src/prover/smt/solver/seq-decl-plugin.ts +1 -1
- package/src/prover/smt/solver/seq-derive.ts +2 -2
- package/src/prover/smt/solver/seq-eq-solver.ts +2 -2
- package/src/prover/smt/solver/seq-monadic.ts +7 -5
- package/src/prover/smt/solver/seq-re-rewriter.ts +2 -1
- package/src/prover/smt/solver/seq-re-util.ts +1 -1
- package/src/prover/smt/solver/seq-regex-bisim.ts +1 -1
- package/src/prover/smt/solver/seq-regex-live.ts +2 -2
- package/src/prover/smt/solver/seq-rewriter.ts +31 -29
- package/src/prover/smt/solver/seq-skolem.ts +0 -23
- package/src/prover/smt/solver/seq-view-witness.ts +4 -4
- package/src/prover/smt/solver/smt-consequences.ts +1 -1
- package/src/prover/smt/solver/smt-kernel.ts +48 -7
- package/src/prover/smt/solver/smt-setup.ts +106 -13
- package/src/prover/smt/solver/smtlib-parser.ts +589 -224
- package/src/prover/smt/solver/smtlib-script.ts +718 -213
- package/src/prover/smt/solver/solve-eqs.ts +36 -37
- package/src/prover/smt/solver/solver.ts +18 -4
- package/src/prover/smt/solver/tactic.ts +389 -199
- package/src/prover/smt/solver/theory-bv.ts +13 -3
- package/src/prover/smt/solver/theory-fpa.ts +1 -1
- package/src/prover/smt/solver/theory-lra-final-check.ts +1 -0
- package/src/prover/smt/solver/theory-lra-internalize.ts +2 -0
- package/src/prover/smt/solver/theory-lra-propagate.ts +12 -3
- package/src/prover/smt/solver/theory-lra-state.ts +1 -1
- package/src/prover/smt/solver/theory-lra.ts +1 -1
- package/src/prover/smt/solver/theory-pb.ts +24 -7
- package/src/prover/smt/solver/theory-seq-solve.ts +1 -1
- package/src/prover/smt/solver/theory-seq-state.ts +2 -21
- package/src/prover/smt/solver/theory-without-terms.ts +24 -0
- package/src/prover/smt/solver/tseitin-cnf.ts +15 -5
- package/src/prover/tlapm/cache.ts +8 -8
- package/src/prover/zenon/index-table.ts +5 -2
- package/src/prover/zenon/isar-case.ts +1 -1
- package/src/prover/zenon/isar.ts +2 -2
- package/src/prover/zenon/phrase.ts +1 -1
- package/src/resolve.ts +1311 -268
- package/src/runtime.ts +21 -2
- package/src/sany/builtins.ts +10 -10
- package/src/sany/generation.ts +5 -15
- package/src/sany/generator-def-entries.ts +123 -36
- package/src/sany/generator-definitions.ts +5 -3
- package/src/sany/generator-expressions.ts +60 -37
- package/src/sany/generator-proofs.ts +19 -12
- package/src/sany/generator.ts +12 -6
- package/src/sany/lexer.ts +15 -7
- package/src/sany/modules.ts +4 -2
- package/src/sany/nodes.ts +1 -1
- package/src/sany/selectors.ts +12 -6
- package/src/sany/xml.ts +2 -3
- package/src/search.ts +321 -135
- package/src/simulate.ts +247 -185
- package/src/spec-description.ts +15 -7
- package/src/standard-definitions.ts +1 -0
- package/src/standard-modules.ts +56 -22
- package/src/subexpressions.ts +666 -147
- package/src/successors.ts +50 -20
- package/src/symmetry.ts +2 -1
- package/src/tlc/jar-data.ts +10 -0
- package/src/tlc/messages.ts +3 -3
- package/src/tlc/order.ts +14 -3
- package/src/tlc/random.ts +2 -1
- package/src/tlc/replay.ts +147 -46
- package/src/tlc/tlc-operators.ts +10 -8
- package/src/tlc/tlcext-operators.ts +44 -15
- package/src/tlc/trace-spec.ts +9 -22
- package/src/trace-liveness.ts +529 -0
- package/src/typed-tier.ts +52 -31
- package/src/typescript/types.ts +2 -2
- package/src/values.ts +150 -79
package/src/tlc/tlc-operators.ts
CHANGED
|
@@ -16,12 +16,13 @@ import {
|
|
|
16
16
|
toEnumeratedSet,
|
|
17
17
|
} from "../builtins";
|
|
18
18
|
import { getNamedRegisters, NAMED_REGISTER_PREFIX, type CheckerRuntime } from "../runtime";
|
|
19
|
-
import { createActionRecord, setTlcValue } from "./tlcext-operators";
|
|
19
|
+
import { createActionRecord, createTlcRecord, setTlcValue } from "./tlcext-operators";
|
|
20
20
|
import { getRandomElement } from "./random";
|
|
21
21
|
import {
|
|
22
22
|
ANY_SET,
|
|
23
23
|
createFunction,
|
|
24
24
|
createSet,
|
|
25
|
+
createSortedFunction,
|
|
25
26
|
createTuple,
|
|
26
27
|
createWrittenFunction,
|
|
27
28
|
formatNormalizedCopies,
|
|
@@ -34,7 +35,6 @@ import {
|
|
|
34
35
|
toFiniteSet,
|
|
35
36
|
type Value,
|
|
36
37
|
rankString,
|
|
37
|
-
setFunctionClass,
|
|
38
38
|
} from "../values";
|
|
39
39
|
import { getFingerprintPolynomial } from "./fingerprint";
|
|
40
40
|
import { zeroPad } from "./messages";
|
|
@@ -43,10 +43,9 @@ const formatCalendarVersion = (date: Date) =>
|
|
|
43
43
|
`${date.getUTCFullYear()}.${zeroPad(date.getUTCMonth() + 1)}.${zeroPad(date.getUTCDate())}.${zeroPad(date.getUTCHours())}${zeroPad(date.getUTCMinutes())}${zeroPad(date.getUTCSeconds())}`;
|
|
44
44
|
|
|
45
45
|
const getRegisterFunction = <Key extends Value>(registers: Map<Key, Value>) =>
|
|
46
|
-
createFunction(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setFunctionClass(createWrittenFunction(fields), "record");
|
|
46
|
+
createFunction(
|
|
47
|
+
[...registers].map((entry): [Value, Value] => [entry[0], createTuple([entry[1]])]),
|
|
48
|
+
);
|
|
50
49
|
|
|
51
50
|
const CHECKER_KEYS = new Set(["diameter", "generated", "distinct", "queue", "stats", "config"]);
|
|
52
51
|
const TLC_174_KEYS = new Set(["diameter", "distinct", "queue", "duration", "level"]);
|
|
@@ -133,7 +132,7 @@ const getTlcValue = (runtime: CheckerRuntime, key: Value, context: Context | und
|
|
|
133
132
|
}
|
|
134
133
|
if (typeof key !== "string") {
|
|
135
134
|
throw new TlaModuleError(
|
|
136
|
-
`The argument of TLCGet should be a nonnegative integer, but instead it is:\n${formatValue(key)}`,
|
|
135
|
+
`The argument of TLCGet should be a nonnegative integer, but instead it is:\n${prettyPrint(formatValue(key))}`,
|
|
137
136
|
);
|
|
138
137
|
}
|
|
139
138
|
return getRuntimeValue(runtime, key, context?.state);
|
|
@@ -160,8 +159,11 @@ const normalizeDeeply = (value: Value): void => {
|
|
|
160
159
|
const convertLikeTlcEval = (value: Value): Value => {
|
|
161
160
|
if (typeof value !== "object") return value;
|
|
162
161
|
switch (value.kind) {
|
|
163
|
-
case "ModelValue":
|
|
164
162
|
case "Function":
|
|
163
|
+
return value.functionClass === undefined
|
|
164
|
+
? value
|
|
165
|
+
: createSortedFunction(value.domain, value.range);
|
|
166
|
+
case "ModelValue":
|
|
165
167
|
case "MixedSet":
|
|
166
168
|
case "InfiniteSet":
|
|
167
169
|
case "SequenceSet":
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
TlaUnsupportedError,
|
|
16
16
|
} from "../errors";
|
|
17
17
|
import { getTlcFingerprint } from "./fingerprint";
|
|
18
|
+
import { prettyPrint } from "../pretty-print";
|
|
18
19
|
import { formatMessage, formatNestedMessage, MESSAGE_CODE, MESSAGE_LEVEL } from "./messages";
|
|
19
20
|
import {
|
|
20
21
|
describeRange,
|
|
@@ -37,11 +38,14 @@ import {
|
|
|
37
38
|
createRecord,
|
|
38
39
|
createSet,
|
|
39
40
|
createTuple,
|
|
41
|
+
createWrittenFunction,
|
|
40
42
|
formatState,
|
|
41
43
|
formatValue,
|
|
42
44
|
getFingerprintError,
|
|
43
45
|
getSequenceElements,
|
|
44
46
|
getValueKey,
|
|
47
|
+
rankString,
|
|
48
|
+
setFunctionClass,
|
|
45
49
|
toFiniteSet,
|
|
46
50
|
type Value,
|
|
47
51
|
} from "../values";
|
|
@@ -63,19 +67,31 @@ export const createActionRecord = (action: string | undefined) =>
|
|
|
63
67
|
|
|
64
68
|
const counterExamples = new WeakSet<Value & object>();
|
|
65
69
|
|
|
66
|
-
const
|
|
67
|
-
|
|
70
|
+
export const createTlcRecord = (fields: [string, Value][]) =>
|
|
71
|
+
setFunctionClass(createWrittenFunction(fields), "record");
|
|
72
|
+
|
|
73
|
+
const createCounterExampleRecord = (action: Value[], states: Value[], isConsole = true) => {
|
|
74
|
+
// TLC's CounterExample interns its field names as the class loads, which orders them as strings.
|
|
75
|
+
["state", "action", "console"].forEach(rankString);
|
|
76
|
+
const fields: [string, Value][] = [
|
|
68
77
|
["action", createSet(action)],
|
|
69
78
|
["state", createSet(states)],
|
|
70
|
-
]
|
|
79
|
+
];
|
|
80
|
+
const counterExample = createTlcRecord(isConsole ? fields : [...fields, ["console", false]]);
|
|
71
81
|
counterExamples.add(counterExample);
|
|
72
82
|
return counterExample;
|
|
73
83
|
};
|
|
74
84
|
|
|
85
|
+
export interface CounterExampleLoop {
|
|
86
|
+
start: number;
|
|
87
|
+
action: Value;
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
export const createCounterExample = (
|
|
76
91
|
stateRecords: Record<string, Value>[],
|
|
77
92
|
actions: Value[],
|
|
78
|
-
loop:
|
|
93
|
+
loop: CounterExampleLoop | undefined,
|
|
94
|
+
isConsole = true,
|
|
79
95
|
) => {
|
|
80
96
|
const states = stateRecords.map((state, index) =>
|
|
81
97
|
createTuple([index + 1, createRecord(Object.entries(state))]),
|
|
@@ -86,7 +102,7 @@ export const createCounterExample = (
|
|
|
86
102
|
const closing = loop
|
|
87
103
|
? [createTuple([states[states.length - 1], loop.action, states[loop.start]])]
|
|
88
104
|
: [];
|
|
89
|
-
return createCounterExampleRecord([...steps, ...closing], states);
|
|
105
|
+
return createCounterExampleRecord([...steps, ...closing], states, isConsole);
|
|
90
106
|
};
|
|
91
107
|
|
|
92
108
|
const getRegister = (runtime: CheckerRuntime, key: Value) => {
|
|
@@ -126,7 +142,7 @@ export const setTlcValue = (
|
|
|
126
142
|
return;
|
|
127
143
|
}
|
|
128
144
|
throw new TlaModuleError(
|
|
129
|
-
`The first argument of TLCSet should be a nonnegative integer, but instead it is:\n${formatValue(key)}`,
|
|
145
|
+
`The first argument of TLCSet should be a nonnegative integer, but instead it is:\n${prettyPrint(formatValue(key))}`,
|
|
130
146
|
);
|
|
131
147
|
};
|
|
132
148
|
|
|
@@ -232,7 +248,7 @@ export const createTlcExtOperators = (
|
|
|
232
248
|
const counterExample = getValue(args, 0, "ToTrace");
|
|
233
249
|
if (typeof counterExample !== "object" || !counterExamples.has(counterExample)) {
|
|
234
250
|
throw new TlaModuleError(
|
|
235
|
-
`The argument of ToTrace should be a CounterExample, but instead it is:\n${formatValue(counterExample)}`,
|
|
251
|
+
`The argument of ToTrace should be a CounterExample, but instead it is:\n${prettyPrint(formatValue(counterExample))}`,
|
|
236
252
|
);
|
|
237
253
|
}
|
|
238
254
|
const states = toFiniteSet(applyFunction(counterExample, "state")).elements.map(
|
|
@@ -246,7 +262,7 @@ export const createTlcExtOperators = (
|
|
|
246
262
|
const name = getValue(args, 0, "TLCModelValue");
|
|
247
263
|
if (typeof name !== "string") {
|
|
248
264
|
throw new TlaModuleError(
|
|
249
|
-
`The argument of ModelValue should be a string, but instead it is:\n${formatValue(name)}`,
|
|
265
|
+
`The argument of ModelValue should be a string, but instead it is:\n${prettyPrint(formatValue(name))}`,
|
|
250
266
|
);
|
|
251
267
|
}
|
|
252
268
|
return createModelValue(name);
|
|
@@ -263,10 +279,13 @@ export const createTlcExtOperators = (
|
|
|
263
279
|
defineOperator("TLCNoOp", 1, (args) => getValue(args, 0, "TLCNoOp")),
|
|
264
280
|
{
|
|
265
281
|
...defineLazyOperator("PickSuccessor", 1, (args, context) => {
|
|
266
|
-
// Deviation from TLC: TLCExt#pickSuccessor fingerprints a partial successor and fails, where TLCExt.tla promises TRUE.
|
|
267
282
|
const next = context?.next ?? (context?.environment.variables ?? []).map(() => undefined);
|
|
268
|
-
|
|
269
|
-
if (
|
|
283
|
+
// A simulation remembers no states, so TLC evaluates the guard before it looks at the successor.
|
|
284
|
+
if (runtime.getSimulationValue === undefined) {
|
|
285
|
+
// Deviation from TLC: TLCExt#pickSuccessor fingerprints a partial successor and fails, where TLCExt.tla promises TRUE.
|
|
286
|
+
if (!isCompleteState(next)) return true;
|
|
287
|
+
if (context?.next && runtime.isSeen(next)) return true;
|
|
288
|
+
}
|
|
270
289
|
const guard = getOperator(args, 0, "PickSuccessor");
|
|
271
290
|
const isPicked = guard.call([]);
|
|
272
291
|
if (typeof isPicked !== "boolean") {
|
|
@@ -274,7 +293,13 @@ export const createTlcExtOperators = (
|
|
|
274
293
|
`In evaluating TLCExt!PickSuccessor, a non-boolean expression (${getKindString(isPicked)}) was used as the condition of an IF.\n${guard.expression ? describeNode(guard.expression) : ""}`,
|
|
275
294
|
);
|
|
276
295
|
}
|
|
277
|
-
if (
|
|
296
|
+
if (
|
|
297
|
+
isPicked ||
|
|
298
|
+
!context?.next ||
|
|
299
|
+
!isCompleteState(next) ||
|
|
300
|
+
!context.state ||
|
|
301
|
+
!isCompleteState(context.state)
|
|
302
|
+
) {
|
|
278
303
|
return true;
|
|
279
304
|
}
|
|
280
305
|
const state = context.state;
|
|
@@ -303,9 +328,13 @@ export const createTlcExtOperators = (
|
|
|
303
328
|
} else if (answer[0] === "d") {
|
|
304
329
|
printOverride(formatState(runtime.toRecord(next), runtime.toRecord(state)));
|
|
305
330
|
} else if (answer[0] === "e") {
|
|
331
|
+
if (runtime.markExplored) {
|
|
332
|
+
runtime.markExplored(next);
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
306
335
|
if (runtime.getSimulationValue === undefined) {
|
|
307
336
|
throw new TlaUnsupportedError(
|
|
308
|
-
"tla-ts can't mark a state explored while it
|
|
337
|
+
"tla-ts can't mark a state explored while it searches depth first.",
|
|
309
338
|
);
|
|
310
339
|
}
|
|
311
340
|
printOverride(
|
|
@@ -348,7 +377,7 @@ export const createTlcExtOperators = (
|
|
|
348
377
|
const name = getThunk(args, 0, "TLCEvalDefinition")();
|
|
349
378
|
if (typeof name !== "string") {
|
|
350
379
|
throw new TlaModuleError(
|
|
351
|
-
`The argument of TLCEvalDefinition should be a string, but instead it is:\n${formatValue(name)}`,
|
|
380
|
+
`The argument of TLCEvalDefinition should be a string, but instead it is:\n${prettyPrint(formatValue(name))}`,
|
|
352
381
|
);
|
|
353
382
|
}
|
|
354
383
|
const definition = context ? getDefinition(name, context.environment) : undefined;
|
|
@@ -356,7 +385,7 @@ export const createTlcExtOperators = (
|
|
|
356
385
|
if (builtin?.arity === 0) return builtin.evaluate([], context);
|
|
357
386
|
if (!definition || !context) {
|
|
358
387
|
throw new TlaModuleError(
|
|
359
|
-
`The argument of TLCEvalDefinition should be a name of a definition reachable from the root module, but instead it is:\n${formatValue(name)}`,
|
|
388
|
+
`The argument of TLCEvalDefinition should be a name of a definition reachable from the root module, but instead it is:\n${prettyPrint(formatValue(name))}`,
|
|
360
389
|
);
|
|
361
390
|
}
|
|
362
391
|
if (definition.kind === "Operator" && definition.params.length > 0) {
|
package/src/tlc/trace-spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHashMapOrder } from "../java-hash";
|
|
2
2
|
import { formatValue, type Value } from "../values";
|
|
3
3
|
import { zeroPad } from "./messages";
|
|
4
4
|
|
|
@@ -18,20 +18,6 @@ const CLOSING_TAG = `${"=".repeat(77)}\n`;
|
|
|
18
18
|
const LASSO_START = "_TTraceLassoStart";
|
|
19
19
|
const LASSO_END = "_TTraceLassoEnd";
|
|
20
20
|
|
|
21
|
-
const getHashMapHash = (text: string) => {
|
|
22
|
-
const hash = getJavaHashCode(text);
|
|
23
|
-
return hash ^ (hash >>> 16);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const getHashOrder = (names: string[]) => {
|
|
27
|
-
const unique = [...new Set(names)];
|
|
28
|
-
const capacity = 2 ** Math.max(4, Math.ceil(Math.log2(unique.length / 0.75)));
|
|
29
|
-
return unique
|
|
30
|
-
.map((name, index) => ({ name, index, bucket: getHashMapHash(name) & (capacity - 1) }))
|
|
31
|
-
.sort((left, right) => left.bucket - right.bucket || left.index - right.index)
|
|
32
|
-
.map((entry) => entry.name);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
21
|
const formatJavaDate = (date: Date) => {
|
|
36
22
|
const getPart = (options: Intl.DateTimeFormatOptions, type: Intl.DateTimeFormatPartTypes) =>
|
|
37
23
|
new Intl.DateTimeFormat("en-US", options).formatToParts(date).find((part) => part.type === type)
|
|
@@ -57,7 +43,7 @@ const getConjunction = (state: [string, string][], prefix?: string) =>
|
|
|
57
43
|
indent(
|
|
58
44
|
[
|
|
59
45
|
...(prefix === undefined ? [] : [prefix]),
|
|
60
|
-
...state.map((
|
|
46
|
+
...state.map((assignment) => `${assignment[0]} = (${assignment[1]})`),
|
|
61
47
|
].join("\n/\\\n"),
|
|
62
48
|
2,
|
|
63
49
|
);
|
|
@@ -102,7 +88,7 @@ ${examples}`;
|
|
|
102
88
|
export const writeTraceSpec = (input: TraceSpecInput) => {
|
|
103
89
|
const loopStart = input.loopStart;
|
|
104
90
|
const states = input.states.map((state) =>
|
|
105
|
-
|
|
91
|
+
getHashMapOrder(Object.keys(state)).map((name): [string, string] => [
|
|
106
92
|
name,
|
|
107
93
|
formatValue(state[name]),
|
|
108
94
|
]),
|
|
@@ -127,11 +113,11 @@ export const writeTraceSpec = (input: TraceSpecInput) => {
|
|
|
127
113
|
...(isLasso ? [LASSO_START, LASSO_END] : []),
|
|
128
114
|
];
|
|
129
115
|
const teConstantsModule = `${specName}_TEConstants`;
|
|
130
|
-
const constantModules =
|
|
116
|
+
const constantModules = getHashMapOrder([
|
|
131
117
|
"TLC",
|
|
132
118
|
...(teConstants.length > 0 ? [teConstantsModule] : []),
|
|
133
119
|
]);
|
|
134
|
-
const extendedModules =
|
|
120
|
+
const extendedModules = getHashMapOrder([
|
|
135
121
|
"Toolbox",
|
|
136
122
|
"TLCExt",
|
|
137
123
|
"Naturals",
|
|
@@ -187,10 +173,11 @@ ${lassoStep}${variables
|
|
|
187
173
|
definition: `\n_view ==\n${INDENT}<<${variables.join(", ")}, IF TLCGet("level") = ${LASSO_END} + 1 THEN ${LASSO_START} ELSE TLCGet("level")>>\n`,
|
|
188
174
|
}
|
|
189
175
|
: { config: "", definition: "" };
|
|
190
|
-
const deserializedTrace = `\n${getPrimer(traceModule,
|
|
176
|
+
const deserializedTrace = `\n${getPrimer(traceModule, getHashMapOrder(["IOUtils", ...constantModules, specName]))}trace == IODeserialize("${input.module}.bin", TRUE)\n\n${CLOSING_TAG}`;
|
|
191
177
|
const traceFunction = `${INDENT}<<\n${states
|
|
192
178
|
.map(
|
|
193
|
-
(state) =>
|
|
179
|
+
(state) =>
|
|
180
|
+
`${INDENT}([${state.map((assignment) => `${assignment[0]} |-> ${assignment[1]}`).join(",")}])`,
|
|
194
181
|
)
|
|
195
182
|
.join(",\n")}\n${INDENT}>>${SEPARATOR}\n`;
|
|
196
183
|
|
|
@@ -217,7 +204,7 @@ ${lassoStep}${variables
|
|
|
217
204
|
" In this case, it is advised to uncomment the module below to deserialize the\n",
|
|
218
205
|
" trace from a generated binary file.\n",
|
|
219
206
|
`\n\\*${deserializedTrace.replaceAll("\n", "\n\\*")}\n\n`,
|
|
220
|
-
getPrimer(traceModule,
|
|
207
|
+
getPrimer(traceModule, getHashMapOrder([...constantModules, specName])),
|
|
221
208
|
`trace == \n${traceFunction}\n`,
|
|
222
209
|
...(teConstants.length > 0
|
|
223
210
|
? [
|