tla-ts 0.0.8-dev.d9bffda → 0.0.9-dev.0dd11f695
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/compile.cjs +23 -0
- package/dist/compile.js +23 -0
- package/dist/deciders.cjs +15 -15
- package/dist/deciders.js +40 -40
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +80 -10
- package/dist/index.d.ts +80 -10
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove-worker.cjs +1 -1
- package/dist/prove-worker.js +1 -1
- package/dist/prove.cjs +116 -36
- package/dist/prove.js +116 -36
- package/dist/run.cjs +143 -31
- package/dist/run.js +143 -31
- package/dist/tlapm.cjs +2 -2
- package/dist/tlapm.js +1 -1
- package/dist/transfer.cjs +128 -103
- package/dist/transfer.js +128 -103
- package/dist/worker.cjs +7 -7
- package/dist/worker.js +7 -7
- package/package.json +3 -1
- package/src/ast.ts +7 -21
- package/src/bags.ts +99 -99
- package/src/builtins.ts +44 -75
- package/src/bundled-modules.ts +1 -8
- package/src/check.ts +605 -311
- package/src/cli/options.ts +12 -3
- package/src/cli/run.ts +2 -2
- package/src/cli/runtime-invariants.ts +135 -0
- package/src/cli/shared.ts +20 -9
- package/src/cli/tlc-arguments.ts +646 -0
- package/src/cli/tlc-usage.ts +362 -0
- package/src/cli/tlc.ts +571 -185
- package/src/cli/typescript.ts +26 -0
- package/src/cli/xml-exporter.ts +4 -10
- package/src/codegen.ts +190 -46
- package/src/config.ts +101 -68
- package/src/coverage.ts +855 -0
- package/src/dependencies.ts +20 -28
- package/src/dfid.ts +636 -0
- package/src/environment.ts +266 -98
- package/src/errors.ts +142 -45
- package/src/evaluate.ts +632 -298
- package/src/exit-codes.ts +37 -1
- package/src/index.ts +3 -0
- package/src/instances.ts +85 -9
- package/src/java-overrides.ts +2 -12
- package/src/json-reader.ts +456 -0
- package/src/json.ts +262 -139
- package/src/levels.ts +2 -3
- package/src/lexer.ts +17 -26
- package/src/liveness-checker.ts +10 -18
- package/src/liveness.ts +121 -49
- package/src/parallel-worker.ts +14 -10
- package/src/parallel.ts +41 -17
- package/src/parser.ts +436 -90
- package/src/pcal/ast.ts +7 -28
- package/src/pcal/parse.ts +11 -39
- package/src/pcal/tokenize.ts +4 -20
- package/src/pcal/translate.ts +10 -42
- package/src/pcal/validate.ts +3 -21
- package/src/pretty-print.ts +1 -2
- package/src/prover/smt/solver/solver.ts +31 -27
- package/src/randomization.ts +84 -35
- package/src/resolve.ts +18 -60
- package/src/runtime.ts +11 -4
- package/src/sany/builtins.ts +3 -4
- package/src/sany/generator.ts +128 -176
- package/src/sany/levels.ts +6 -30
- package/src/sany/lexer.ts +7 -23
- package/src/sany/linter.ts +31 -29
- package/src/sany/modules.ts +1 -5
- package/src/sany/nodes.ts +4 -28
- package/src/sany/parse-error.ts +44 -100
- package/src/sany/report.ts +25 -40
- package/src/sany/selectors.ts +8 -22
- package/src/sany/source.ts +8 -15
- package/src/sany/xml.ts +11 -42
- package/src/search.ts +547 -144
- package/src/simulate.ts +694 -0
- package/src/spec-description.ts +166 -48
- package/src/standard-definitions.ts +2 -3
- package/src/standard-modules.ts +264 -68
- package/src/state-graph.ts +51 -18
- package/src/subexpressions.ts +31 -5
- package/src/successors.ts +267 -77
- package/src/symmetry.ts +31 -8
- package/src/tableau.ts +1 -2
- package/src/tlc/fingerprint.ts +183 -61
- package/src/tlc/jar-data.ts +113 -6
- package/src/tlc/messages.ts +122 -37
- package/src/tlc/order.ts +33 -38
- package/src/tlc/random.ts +16 -16
- package/src/tlc/replay.ts +563 -211
- package/src/tlc/summary.ts +2 -4
- package/src/tlc/tlc-operators.ts +81 -36
- package/src/tlc/tlcext-operators.ts +138 -117
- package/src/tlc/trace-spec.ts +273 -0
- package/src/tlc/value-stream.ts +143 -0
- package/src/tlc/version.ts +2 -4
- package/src/typescript/actions.ts +494 -0
- package/src/typescript/collections.ts +615 -0
- package/src/typescript/compile.ts +70 -0
- package/src/typescript/context.ts +106 -0
- package/src/typescript/emit.ts +122 -0
- package/src/typescript/expressions.ts +508 -0
- package/src/typescript/formula.ts +160 -0
- package/src/typescript/functions.ts +295 -0
- package/src/typescript/model.ts +164 -0
- package/src/typescript/names.ts +116 -0
- package/src/typescript/program.ts +51 -0
- package/src/typescript/properties.ts +148 -0
- package/src/typescript/scope.ts +117 -0
- package/src/typescript/steps.ts +175 -0
- package/src/typescript/types.ts +178 -0
- package/src/values.ts +832 -255
package/src/symmetry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Expression } from "./ast";
|
|
1
|
+
import type { BoundPattern, Expression } from "./ast";
|
|
2
2
|
import type { Substitution } from "./config";
|
|
3
3
|
import { TlaConfigError, TlaEvaluationError, UNEXPECTED_EXCEPTION } from "./errors";
|
|
4
4
|
import { EXIT_STATUS, setExitCode } from "./exit-codes";
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
type Value,
|
|
21
21
|
} from "./values";
|
|
22
22
|
|
|
23
|
-
// The image of each model value a permutation moves, by name.
|
|
24
23
|
type Images = Map<string, ModelValue>;
|
|
25
24
|
|
|
26
25
|
const getPermutationKey = (permutation: Images) =>
|
|
@@ -59,8 +58,32 @@ const toImages = (value: Value) => {
|
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
// SyntaxTreeNode.getHumanReadableImage, which joins the tokens of an expression without spaces.
|
|
61
|
+
const getBoundImage = (pattern: BoundPattern, set: Expression | undefined) => {
|
|
62
|
+
const names = pattern.kind === "Name" ? pattern.name : `<<${pattern.names.join(",")}>>`;
|
|
63
|
+
return set ? `${names}\\in${getExpressionImage(set)}` : names;
|
|
64
|
+
};
|
|
65
|
+
|
|
62
66
|
const getExpressionImage = (expression: Expression): string => {
|
|
63
67
|
if (expression.kind === "Identifier") return expression.name;
|
|
68
|
+
if (expression.kind === "Number") return expression.text ?? String(expression.value);
|
|
69
|
+
if (expression.kind === "SetEnumeration") {
|
|
70
|
+
return `{${expression.elements.map(getExpressionImage).join(",")}}`;
|
|
71
|
+
}
|
|
72
|
+
if (expression.kind === "Choose") {
|
|
73
|
+
return `CHOOSE${getBoundImage(expression.pattern, expression.set)}:${getExpressionImage(expression.body)}`;
|
|
74
|
+
}
|
|
75
|
+
if (expression.kind === "Tuple")
|
|
76
|
+
return `<<${expression.elements.map(getExpressionImage).join(",")}>>`;
|
|
77
|
+
if (expression.kind === "Record") {
|
|
78
|
+
const fields = expression.fields.map(
|
|
79
|
+
(field) => `${field.name}|->${getExpressionImage(field.value)}`,
|
|
80
|
+
);
|
|
81
|
+
return `[${fields.join(",")}]`;
|
|
82
|
+
}
|
|
83
|
+
if (expression.kind === "FunctionConstruction") {
|
|
84
|
+
const bounds = expression.bounds.map((bound) => getBoundImage(bound.pattern, bound.set));
|
|
85
|
+
return `[${bounds.join(",")}|->${getExpressionImage(expression.body)}]`;
|
|
86
|
+
}
|
|
64
87
|
if (expression.kind !== "Apply") return "";
|
|
65
88
|
const args = expression.args.map(getExpressionImage);
|
|
66
89
|
return /^[A-Za-z_]/.test(expression.operator)
|
|
@@ -99,10 +122,11 @@ export const getSymmetryGroup = (
|
|
|
99
122
|
if (!elements.every(isFunctionValue)) {
|
|
100
123
|
throw createSymmetryError("The symmetry values must be function records.");
|
|
101
124
|
}
|
|
102
|
-
const permutations = elements.map(toImages);
|
|
103
125
|
// Tool#getSymmetryPerms warns about each permuted set with fewer than two elements, by the name
|
|
104
126
|
// the config substitutes for it. As many permuted sets as permutations means none has two.
|
|
105
|
-
const
|
|
127
|
+
const body = definition.body;
|
|
128
|
+
const permutedSets =
|
|
129
|
+
body.kind === "Apply" ? body.args : body.kind === "SetEnumeration" ? body.elements : [];
|
|
106
130
|
const configNames = new Map(
|
|
107
131
|
substitutions
|
|
108
132
|
.filter((substitution) => substitution.module === undefined)
|
|
@@ -125,7 +149,7 @@ export const getSymmetryGroup = (
|
|
|
125
149
|
return undefined;
|
|
126
150
|
}
|
|
127
151
|
const group = new Map<string, Images>();
|
|
128
|
-
|
|
152
|
+
elements.map(toImages).forEach((permutation) => {
|
|
129
153
|
if (permutation.size > 0) group.set(getPermutationKey(permutation), permutation);
|
|
130
154
|
});
|
|
131
155
|
const generators = [...group.values()];
|
|
@@ -242,9 +266,8 @@ const permuteValue = (value: Value, images: Images): Value => {
|
|
|
242
266
|
return elements ? createSet(elements) : set;
|
|
243
267
|
};
|
|
244
268
|
|
|
245
|
-
//
|
|
246
|
-
//
|
|
247
|
-
// next permutation as soon as a variable's image is larger than the smallest state's.
|
|
269
|
+
// TLC permutes the state under each permutation, variable by variable, and moves on to the next
|
|
270
|
+
// permutation as soon as a variable's image is larger than the smallest state's.
|
|
248
271
|
export const getRepresentative = (
|
|
249
272
|
state: Value[],
|
|
250
273
|
permutations: Images[],
|
package/src/tableau.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface LiveEnabled {
|
|
|
23
23
|
interface LiveAction {
|
|
24
24
|
kind: "Action";
|
|
25
25
|
expression: Expression;
|
|
26
|
-
|
|
26
|
+
subscript: Expression | undefined;
|
|
27
27
|
scope: Scope | undefined;
|
|
28
28
|
enabled?: LiveEnabled;
|
|
29
29
|
}
|
|
@@ -164,7 +164,6 @@ const containsAction = (expression: LiveExpression): boolean => {
|
|
|
164
164
|
const termKeys = new WeakMap<LiveExpression, string>();
|
|
165
165
|
const atoms = { count: 0 };
|
|
166
166
|
|
|
167
|
-
// A term's structure as a string in which each atom stands for itself, so equal terms share a key.
|
|
168
167
|
export const getTermKey = (expression: LiveExpression): string => {
|
|
169
168
|
const cached = termKeys.get(expression);
|
|
170
169
|
if (cached !== undefined) return cached;
|
package/src/tlc/fingerprint.ts
CHANGED
|
@@ -8,75 +8,202 @@ import {
|
|
|
8
8
|
type Value,
|
|
9
9
|
} from "../values";
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
const
|
|
11
|
+
// TLC's FP64.Polys, the irreducible polynomials that -fp picks from.
|
|
12
|
+
const POLYNOMIALS = [
|
|
13
|
+
0x911498ae0e66bad6n,
|
|
14
|
+
0xda8a0ba66dae0181n,
|
|
15
|
+
0xc02f176b8f268d9fn,
|
|
16
|
+
0xd617bb1220fc7812n,
|
|
17
|
+
0xc6fd951ad34f9f74n,
|
|
18
|
+
0xdd1897bd991704d4n,
|
|
19
|
+
0xf5394c541cbfd343n,
|
|
20
|
+
0xb1dded37b5c7b8f7n,
|
|
21
|
+
0xb713ff61039dc632n,
|
|
22
|
+
0xdfb340cb2fb03d43n,
|
|
23
|
+
0xbc3e7e4c5ecb76a3n,
|
|
24
|
+
0xdbb4b1349cd7058an,
|
|
25
|
+
0xf53e9dcb9e915cdfn,
|
|
26
|
+
0xca5f58e90dd01848n,
|
|
27
|
+
0x80e7ff4406891aa1n,
|
|
28
|
+
0xab541bf881fa8571n,
|
|
29
|
+
0xbf274e07ac5499d5n,
|
|
30
|
+
0x939b1ea933040a4en,
|
|
31
|
+
0xb791a595448d75b1n,
|
|
32
|
+
0x8bf88d6ef85563a2n,
|
|
33
|
+
0xecb33ec339513a53n,
|
|
34
|
+
0xfa2d3e722db5208an,
|
|
35
|
+
0xb4e2058aac479d24n,
|
|
36
|
+
0xafbd6474e7213b82n,
|
|
37
|
+
0x98c1694d14ffaeefn,
|
|
38
|
+
0xe188fb5c0a125e24n,
|
|
39
|
+
0xfa71cc3865487d80n,
|
|
40
|
+
0x891135f7c1c94569n,
|
|
41
|
+
0xcf77cdd16d22e3e6n,
|
|
42
|
+
0xeb5e3a1d2e2bb4b5n,
|
|
43
|
+
0x92f7f5b69cd00c55n,
|
|
44
|
+
0xa9fbbe40ca3b9ae9n,
|
|
45
|
+
0x84a7b33d85295bden,
|
|
46
|
+
0xebd4680dbb6fdee2n,
|
|
47
|
+
0xa31fc46a0583b4d0n,
|
|
48
|
+
0xa792c94f15de3e49n,
|
|
49
|
+
0xd9d60a9feff4521an,
|
|
50
|
+
0x9227ba31dfdda04bn,
|
|
51
|
+
0xfb4c89c607ce162dn,
|
|
52
|
+
0xa89b3b2e01479cc0n,
|
|
53
|
+
0xb35a0c2a28b89f7dn,
|
|
54
|
+
0x91d0b700b99d9ec2n,
|
|
55
|
+
0xf0646bbda05020b0n,
|
|
56
|
+
0xcb5d5f63ce043056n,
|
|
57
|
+
0xd276b6a04f42a1b8n,
|
|
58
|
+
0xbc1a7a7dbfeb47a3n,
|
|
59
|
+
0xe138acff7a963036n,
|
|
60
|
+
0xed860223c1557ee7n,
|
|
61
|
+
0x9b2491e980150ab6n,
|
|
62
|
+
0xe7e03dd8a5b4e59en,
|
|
63
|
+
0xaaa3f5eac516783cn,
|
|
64
|
+
0xfe78cc267a724180n,
|
|
65
|
+
0xc22519a21edfac64n,
|
|
66
|
+
0xcdb2941933fec60fn,
|
|
67
|
+
0xc5f485551ef38aa1n,
|
|
68
|
+
0xa19293d250bd3335n,
|
|
69
|
+
0xa4d4c215a50b7afen,
|
|
70
|
+
0xc1155176406a5070n,
|
|
71
|
+
0xecadaa8200e123ecn,
|
|
72
|
+
0xbacfe629d58b2f08n,
|
|
73
|
+
0xded991082148cb42n,
|
|
74
|
+
0x9a0ccbe5deaa88dbn,
|
|
75
|
+
0x9a83246f342061bbn,
|
|
76
|
+
0xb71482842297ab05n,
|
|
77
|
+
0xf2407eeb997592bdn,
|
|
78
|
+
0xb7b43d4b5c4c4bccn,
|
|
79
|
+
0xb339a2568221ffe7n,
|
|
80
|
+
0xdb4b6b379446ef9en,
|
|
81
|
+
0xe43c205bb5c0b2b6n,
|
|
82
|
+
0xe8e1d141f19d6db0n,
|
|
83
|
+
0xd19e8710a4ea1c86n,
|
|
84
|
+
0x9704cecfa8d6d07bn,
|
|
85
|
+
0xb0a35716162c3f26n,
|
|
86
|
+
0xa2a68c0cf56390acn,
|
|
87
|
+
0xe4a74bc601c95b46n,
|
|
88
|
+
0xe668fff675595e56n,
|
|
89
|
+
0xe0ea77ebe06fabbbn,
|
|
90
|
+
0xa8bb94f585279523n,
|
|
91
|
+
0xbeb667b42b684f21n,
|
|
92
|
+
0xd7b65410189e28afn,
|
|
93
|
+
0x85722037beffc5b9n,
|
|
94
|
+
0xe7e7c5f773426204n,
|
|
95
|
+
0xa5fd0cc8e060c6f4n,
|
|
96
|
+
0xb8f91ee9065dcf95n,
|
|
97
|
+
0xb4047008040f8b50n,
|
|
98
|
+
0xecb9ab6291c8cfccn,
|
|
99
|
+
0xe08bb9b70caad6dfn,
|
|
100
|
+
0xd6e086a301d95d56n,
|
|
101
|
+
0xf6a808f5f3fb9da3n,
|
|
102
|
+
0xfa74b8a8ef86fbc5n,
|
|
103
|
+
0xa0b6b33ba9e6381cn,
|
|
104
|
+
0x8c78703427873dbbn,
|
|
105
|
+
0xc5516ea423011021n,
|
|
106
|
+
0xb075cce8528ae7e2n,
|
|
107
|
+
0x92e4a37979e2b13bn,
|
|
108
|
+
0xafc9ab000ed81026n,
|
|
109
|
+
0xf1873f2a861a518an,
|
|
110
|
+
0xf885d6b35770192cn,
|
|
111
|
+
0xd2a82f27f71f5f7en,
|
|
112
|
+
0xd5e7a4dd8beb2d9fn,
|
|
113
|
+
0xbab9e7e65dc23e0fn,
|
|
114
|
+
0xd5fc877c0bdf5b85n,
|
|
115
|
+
0xab428169b9f31c02n,
|
|
116
|
+
0xb7b1351f9266d3ean,
|
|
117
|
+
0xfad564914328f635n,
|
|
118
|
+
0x9623ecb1000db9bdn,
|
|
119
|
+
0x88d371ec6644c892n,
|
|
120
|
+
0xd0a71270573e271cn,
|
|
121
|
+
0xbd200d763f9d81b4n,
|
|
122
|
+
0x8484fd96374bf2ean,
|
|
123
|
+
0xe0d0810749432294n,
|
|
124
|
+
0x8ebe9dadc88658ban,
|
|
125
|
+
0xf6268c58993ae542n,
|
|
126
|
+
0xd6cc88fed0d359c9n,
|
|
127
|
+
0xbcaddb8d40a16690n,
|
|
128
|
+
0x92817c6db421cbf6n,
|
|
129
|
+
0xac63721120a371b5n,
|
|
130
|
+
0xd6cc137fdced0820n,
|
|
131
|
+
0xf1c5fbaebb617bd7n,
|
|
132
|
+
0xac35d78c765237a5n,
|
|
133
|
+
0xbd0a471fa9a23116n,
|
|
134
|
+
0x943a7031b946a5aen,
|
|
135
|
+
0xe4e83520cb1aaebbn,
|
|
136
|
+
0xe92a4b73246dd124n,
|
|
137
|
+
0xafc1e070787c4c86n,
|
|
138
|
+
0xdfe84d42cf06286bn,
|
|
139
|
+
0x8b29ec962e4b964bn,
|
|
140
|
+
0x807eb5de812ede0fn,
|
|
141
|
+
0xa3cd71299c8b3bfdn,
|
|
142
|
+
0x845b8031ef886f35n,
|
|
143
|
+
0x91f5a5fa9c5515a5n,
|
|
144
|
+
];
|
|
13
145
|
|
|
14
|
-
const
|
|
15
|
-
const powers: bigint[] = [];
|
|
16
|
-
for (let power = 1n << 63n; powers.length < 72;) {
|
|
17
|
-
powers.push(power);
|
|
18
|
-
power = (power >> 1n) ^ ((power & 1n) === 0n ? 0n : IRREDUCIBLE_POLYNOMIAL);
|
|
19
|
-
}
|
|
20
|
-
return Array.from({ length: 256 }, (_, byte) =>
|
|
21
|
-
powers
|
|
22
|
-
.slice(64, 72)
|
|
23
|
-
.reverse()
|
|
24
|
-
.reduce((value, power, bit) => ((byte >> bit) & 1 ? value ^ power : value), 0n),
|
|
25
|
-
);
|
|
26
|
-
})();
|
|
146
|
+
const selected = { polynomial: POLYNOMIALS[0] };
|
|
27
147
|
|
|
28
|
-
const
|
|
29
|
-
Number(BigInt.asIntN(32, entry >> 32n)),
|
|
30
|
-
);
|
|
31
|
-
const BYTE_MOD_LOW = Int32Array.from(BYTE_MOD_TABLE, (entry) => Number(BigInt.asIntN(32, entry)));
|
|
148
|
+
export const getFingerprintPolynomial = () => selected.polynomial;
|
|
32
149
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
150
|
+
const SLICE_HIGH_0 = new Int32Array(256);
|
|
151
|
+
const SLICE_HIGH_1 = new Int32Array(256);
|
|
152
|
+
const SLICE_HIGH_2 = new Int32Array(256);
|
|
153
|
+
const SLICE_HIGH_3 = new Int32Array(256);
|
|
154
|
+
const SLICE_LOW_0 = new Int32Array(256);
|
|
155
|
+
const SLICE_LOW_1 = new Int32Array(256);
|
|
156
|
+
const SLICE_LOW_2 = new Int32Array(256);
|
|
157
|
+
const SLICE_LOW_3 = new Int32Array(256);
|
|
158
|
+
// The polynomial's high and low 32 bits, which avoid a BigInt operation for every byte.
|
|
159
|
+
const initial = { high: 0, low: 0 };
|
|
160
|
+
let high = 0;
|
|
161
|
+
let low = 0;
|
|
39
162
|
|
|
40
163
|
const extendByte = (byte: number) => {
|
|
41
164
|
const index = (byte ^ low) & 0xff;
|
|
42
|
-
low = ((low >>> 8) | (high << 24)) ^
|
|
43
|
-
high = (high >>> 8) ^
|
|
165
|
+
low = ((low >>> 8) | (high << 24)) ^ SLICE_LOW_0[index];
|
|
166
|
+
high = (high >>> 8) ^ SLICE_HIGH_0[index];
|
|
44
167
|
};
|
|
45
168
|
|
|
46
169
|
// Extending is linear over GF(2), so extending by four bytes at once shifts the fingerprint by a
|
|
47
170
|
// word and adds, for each of the four, the fingerprint from zero of that byte followed by the zero
|
|
48
|
-
// bytes that come after it:
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
171
|
+
// bytes that come after it: SLICE_HIGH_k and SLICE_LOW_k hold them for k zero bytes after.
|
|
172
|
+
export const setFingerprintPolynomial = (index: number) => {
|
|
173
|
+
const polynomial = POLYNOMIALS[index];
|
|
174
|
+
selected.polynomial = polynomial;
|
|
175
|
+
const powers: bigint[] = [];
|
|
176
|
+
for (let power = 1n << 63n; powers.length < 72;) {
|
|
177
|
+
powers.push(power);
|
|
178
|
+
power = (power >> 1n) ^ ((power & 1n) === 0n ? 0n : polynomial);
|
|
179
|
+
}
|
|
180
|
+
const bytePowers = powers.slice(64, 72).reverse();
|
|
181
|
+
for (let byte = 0; byte < 256; byte++) {
|
|
182
|
+
const entry = bytePowers.reduce(
|
|
183
|
+
(value, power, bit) => ((byte >> bit) & 1 ? value ^ power : value),
|
|
184
|
+
0n,
|
|
185
|
+
);
|
|
186
|
+
SLICE_HIGH_0[byte] = Number(BigInt.asIntN(32, entry >> 32n));
|
|
187
|
+
SLICE_LOW_0[byte] = Number(BigInt.asIntN(32, entry));
|
|
188
|
+
}
|
|
189
|
+
const highs = [SLICE_HIGH_0, SLICE_HIGH_1, SLICE_HIGH_2, SLICE_HIGH_3];
|
|
190
|
+
const lows = [SLICE_LOW_0, SLICE_LOW_1, SLICE_LOW_2, SLICE_LOW_3];
|
|
52
191
|
for (let zeros = 1; zeros < 4; zeros++) {
|
|
53
192
|
const previousHigh = highs[zeros - 1];
|
|
54
193
|
const previousLow = lows[zeros - 1];
|
|
55
|
-
const sliceHigh = new Int32Array(256);
|
|
56
|
-
const sliceLow = new Int32Array(256);
|
|
57
194
|
for (let byte = 0; byte < 256; byte++) {
|
|
58
195
|
const index = previousLow[byte] & 0xff;
|
|
59
|
-
|
|
60
|
-
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^
|
|
61
|
-
|
|
196
|
+
lows[zeros][byte] =
|
|
197
|
+
((previousLow[byte] >>> 8) | (previousHigh[byte] << 24)) ^ SLICE_LOW_0[index];
|
|
198
|
+
highs[zeros][byte] = (previousHigh[byte] >>> 8) ^ SLICE_HIGH_0[index];
|
|
62
199
|
}
|
|
63
|
-
highs.push(sliceHigh);
|
|
64
|
-
lows.push(sliceLow);
|
|
65
200
|
}
|
|
66
|
-
|
|
201
|
+
initial.high = Number(BigInt.asIntN(32, polynomial >> 32n));
|
|
202
|
+
initial.low = Number(BigInt.asIntN(32, polynomial));
|
|
67
203
|
};
|
|
68
204
|
|
|
69
|
-
|
|
70
|
-
const SLICE_HIGH_0 = SLICES.highs[0];
|
|
71
|
-
const SLICE_HIGH_1 = SLICES.highs[1];
|
|
72
|
-
const SLICE_HIGH_2 = SLICES.highs[2];
|
|
73
|
-
const SLICE_HIGH_3 = SLICES.highs[3];
|
|
74
|
-
const SLICE_LOW_0 = SLICES.lows[0];
|
|
75
|
-
const SLICE_LOW_1 = SLICES.lows[1];
|
|
76
|
-
const SLICE_LOW_2 = SLICES.lows[2];
|
|
77
|
-
const SLICE_LOW_3 = SLICES.lows[3];
|
|
205
|
+
setFingerprintPolynomial(0);
|
|
78
206
|
|
|
79
|
-
// Extends the fingerprint by the four bytes of a word, lowest first.
|
|
80
207
|
const extendInt = (word: number) => {
|
|
81
208
|
const mixed = low ^ word;
|
|
82
209
|
const first = mixed & 0xff;
|
|
@@ -94,9 +221,8 @@ const SET_ENUM_VALUE = 5;
|
|
|
94
221
|
const FCN_RCD_VALUE = 9;
|
|
95
222
|
const MODEL_VALUE = 21;
|
|
96
223
|
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// UniqueString token, and TLC numbers tokens from 1 in intern order.
|
|
224
|
+
// Returns how many bytes it extends the fingerprint by. A model value extends it with its
|
|
225
|
+
// UniqueString token, which TLC numbers from 1 in intern order.
|
|
100
226
|
const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
101
227
|
if (typeof value === "boolean") {
|
|
102
228
|
extendByte(BOOL_VALUE);
|
|
@@ -128,7 +254,6 @@ const extendScalar = (value: boolean | number | string | ModelValue) => {
|
|
|
128
254
|
return 5;
|
|
129
255
|
};
|
|
130
256
|
|
|
131
|
-
// Value#fingerPrint for each of TLC's value classes.
|
|
132
257
|
const extendValue = (value: Value) => {
|
|
133
258
|
if (typeof value !== "object" || isModelValue(value)) {
|
|
134
259
|
extendScalar(value);
|
|
@@ -148,12 +273,11 @@ const extendValue = (value: Value) => {
|
|
|
148
273
|
}
|
|
149
274
|
};
|
|
150
275
|
|
|
151
|
-
//
|
|
152
|
-
// fingerprint another, so this restores the fingerprint it interrupts.
|
|
276
|
+
// Evaluating a lazy value can fingerprint another, so this restores the fingerprint it interrupts.
|
|
153
277
|
export const getTlcFingerprint = (state: Value[]) => {
|
|
154
278
|
const outer = { high, low };
|
|
155
|
-
high =
|
|
156
|
-
low =
|
|
279
|
+
high = initial.high;
|
|
280
|
+
low = initial.low;
|
|
157
281
|
for (const value of state) extendValue(value);
|
|
158
282
|
const fingerprint = (BigInt(high >>> 0) << 32n) | BigInt(low >>> 0);
|
|
159
283
|
high = outer.high;
|
|
@@ -161,8 +285,6 @@ export const getTlcFingerprint = (state: Value[]) => {
|
|
|
161
285
|
return fingerprint;
|
|
162
286
|
};
|
|
163
287
|
|
|
164
|
-
// TLCStateMut#fingerPrint of each state's variables in TLC's variable order, as the fingerprint
|
|
165
|
-
// store reads them.
|
|
166
288
|
export const getTlcFingerprints = (states: Value[][], order: number[]) => {
|
|
167
289
|
const fingerprints = new BigInt64Array(states.length);
|
|
168
290
|
// Each fingerprint's low and high words, as a BigInt64Array is little-endian.
|
|
@@ -170,8 +292,8 @@ export const getTlcFingerprints = (states: Value[][], order: number[]) => {
|
|
|
170
292
|
const outerHigh = high;
|
|
171
293
|
const outerLow = low;
|
|
172
294
|
states.forEach((state, position) => {
|
|
173
|
-
high =
|
|
174
|
-
low =
|
|
295
|
+
high = initial.high;
|
|
296
|
+
low = initial.low;
|
|
175
297
|
for (const index of order) extendValue(state[index]);
|
|
176
298
|
words[2 * position] = low;
|
|
177
299
|
words[2 * position + 1] = high;
|
package/src/tlc/jar-data.ts
CHANGED
|
@@ -430,6 +430,16 @@ export const TLC_RUNTIME_STRINGS = [
|
|
|
430
430
|
"levelmean",
|
|
431
431
|
"levelvariance",
|
|
432
432
|
"bfs",
|
|
433
|
+
"beginLine",
|
|
434
|
+
"beginColumn",
|
|
435
|
+
"endLine",
|
|
436
|
+
"endColumn",
|
|
437
|
+
"module",
|
|
438
|
+
"name",
|
|
439
|
+
"location",
|
|
440
|
+
"context",
|
|
441
|
+
"parameters",
|
|
442
|
+
"_action",
|
|
433
443
|
];
|
|
434
444
|
|
|
435
445
|
export const SANY_NODE_NAMES = [
|
|
@@ -550,10 +560,6 @@ export const SANY_NODE_NAMES = [
|
|
|
550
560
|
"N_AssertStep",
|
|
551
561
|
];
|
|
552
562
|
|
|
553
|
-
// The standard modules that a spec may ship its own file of, such as CommunityModules' Json.tla,
|
|
554
|
-
// which SANY reads in place of its own.
|
|
555
|
-
export const USER_STANDARD_MODULES = new Set(["Bags", "Json", "Randomization", "TLCExt"]);
|
|
556
|
-
|
|
557
563
|
export const TLC_MODULE_SOURCES = new Map([
|
|
558
564
|
[
|
|
559
565
|
"Naturals",
|
|
@@ -925,9 +931,57 @@ _PrintCounts == PrintT(_Counts)
|
|
|
925
931
|
],
|
|
926
932
|
]);
|
|
927
933
|
|
|
928
|
-
//
|
|
929
|
-
// them in TLC's errors.
|
|
934
|
+
// As java.lang.reflect.Method prints them in TLC's errors.
|
|
930
935
|
export const TLC_JAVA_METHODS = new Map([
|
|
936
|
+
[
|
|
937
|
+
"Bags",
|
|
938
|
+
new Map([
|
|
939
|
+
[
|
|
940
|
+
"IsABag",
|
|
941
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.IsABag(tlc2.value.impl.Value)",
|
|
942
|
+
],
|
|
943
|
+
[
|
|
944
|
+
"BagCardinality",
|
|
945
|
+
"public static tlc2.value.impl.IntValue tlc2.module.Bags.BagCardinality(tlc2.value.impl.Value)",
|
|
946
|
+
],
|
|
947
|
+
[
|
|
948
|
+
"BagIn",
|
|
949
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.BagIn(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
950
|
+
],
|
|
951
|
+
[
|
|
952
|
+
"CopiesIn",
|
|
953
|
+
"public static tlc2.value.impl.IntValue tlc2.module.Bags.CopiesIn(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
954
|
+
],
|
|
955
|
+
[
|
|
956
|
+
"\\oplus",
|
|
957
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagCup(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
958
|
+
],
|
|
959
|
+
[
|
|
960
|
+
"\\ominus",
|
|
961
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagDiff(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
962
|
+
],
|
|
963
|
+
[
|
|
964
|
+
"BagUnion",
|
|
965
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagUnion(tlc2.value.impl.Value)",
|
|
966
|
+
],
|
|
967
|
+
[
|
|
968
|
+
"\\sqsubseteq",
|
|
969
|
+
"public static tlc2.value.IBoolValue tlc2.module.Bags.SqSubseteq(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
970
|
+
],
|
|
971
|
+
[
|
|
972
|
+
"BagOfAll",
|
|
973
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagOfAll(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
974
|
+
],
|
|
975
|
+
[
|
|
976
|
+
"BagToSet",
|
|
977
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.BagToSet(tlc2.value.impl.Value)",
|
|
978
|
+
],
|
|
979
|
+
[
|
|
980
|
+
"SetToBag",
|
|
981
|
+
"public static tlc2.value.impl.Value tlc2.module.Bags.SetToBag(tlc2.value.impl.Value)",
|
|
982
|
+
],
|
|
983
|
+
]),
|
|
984
|
+
],
|
|
931
985
|
[
|
|
932
986
|
"FiniteSets",
|
|
933
987
|
new Map([
|
|
@@ -1023,4 +1077,57 @@ export const TLC_JAVA_METHODS = new Map([
|
|
|
1023
1077
|
],
|
|
1024
1078
|
]),
|
|
1025
1079
|
],
|
|
1080
|
+
[
|
|
1081
|
+
"TLCExt",
|
|
1082
|
+
new Map([
|
|
1083
|
+
[
|
|
1084
|
+
"AssertError",
|
|
1085
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.assertError(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1086
|
+
],
|
|
1087
|
+
[
|
|
1088
|
+
"PickSuccessor",
|
|
1089
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.pickSuccessor(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1090
|
+
],
|
|
1091
|
+
[
|
|
1092
|
+
"ToTrace",
|
|
1093
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.lassoOrdinal(tlc2.value.impl.Value)",
|
|
1094
|
+
],
|
|
1095
|
+
[
|
|
1096
|
+
"CounterExample",
|
|
1097
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.error(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel) throws java.io.IOException",
|
|
1098
|
+
],
|
|
1099
|
+
[
|
|
1100
|
+
"Trace",
|
|
1101
|
+
"public static tlc2.value.impl.TupleValue tlc2.module.TLCExt.getTrace(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel) throws java.io.IOException",
|
|
1102
|
+
],
|
|
1103
|
+
[
|
|
1104
|
+
"TLCDefer",
|
|
1105
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcDefer(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1106
|
+
],
|
|
1107
|
+
[
|
|
1108
|
+
"TLCNoOp",
|
|
1109
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcNoOp(tlc2.value.impl.Value)",
|
|
1110
|
+
],
|
|
1111
|
+
[
|
|
1112
|
+
"TLCModelValue",
|
|
1113
|
+
"public static synchronized tlc2.value.impl.Value tlc2.module.TLCExt.tlcModelValue(tlc2.value.impl.Value)",
|
|
1114
|
+
],
|
|
1115
|
+
[
|
|
1116
|
+
"TLCCache",
|
|
1117
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcEval2(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1118
|
+
],
|
|
1119
|
+
[
|
|
1120
|
+
"TLCFP",
|
|
1121
|
+
"public static synchronized tlc2.value.impl.IntValue tlc2.module.TLCExt.tlcFingerprint(tlc2.value.impl.Value)",
|
|
1122
|
+
],
|
|
1123
|
+
[
|
|
1124
|
+
"TLCEvalDefinition",
|
|
1125
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcDefByName(tlc2.tool.impl.Tool,tla2sany.semantic.ExprOrOpArgNode[],tlc2.util.Context,tlc2.tool.TLCState,tlc2.tool.TLCState,int,tlc2.tool.coverage.CostModel)",
|
|
1126
|
+
],
|
|
1127
|
+
[
|
|
1128
|
+
"TLCGetOrDefault",
|
|
1129
|
+
"public static tlc2.value.impl.Value tlc2.module.TLCExt.tlcGetOrDefault(tlc2.value.impl.Value,tlc2.value.impl.Value)",
|
|
1130
|
+
],
|
|
1131
|
+
]),
|
|
1132
|
+
],
|
|
1026
1133
|
]);
|