tla-ts 0.0.3-dev.3cf2ad0 → 0.0.3-dev.3ef4193
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 +16 -2
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +158 -8
- package/dist/index.d.ts +158 -8
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +1351 -19
- package/dist/run-cli.js +1351 -19
- package/dist/transfer.cjs +88 -18
- package/dist/transfer.js +88 -18
- package/package.json +5 -1
- package/src/ast.ts +146 -6
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -11
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1539 -235
- package/src/cli-options.ts +11 -5
- package/src/cli.ts +8 -1
- package/src/codegen.ts +77 -37
- package/src/config.ts +252 -179
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +524 -140
- package/src/errors.ts +224 -3
- package/src/evaluate.ts +796 -246
- package/src/exit-codes.ts +22 -43
- package/src/index.ts +1 -0
- package/src/instances.ts +19 -16
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +191 -45
- package/src/lexer.ts +37 -5
- package/src/live-check.ts +828 -0
- package/src/liveness.ts +218 -572
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +13 -4
- package/src/parallel.ts +73 -6
- package/src/parser.ts +436 -144
- package/src/pcal-ast.ts +770 -0
- package/src/pcal-parse.ts +1523 -0
- package/src/pcal-tokenize.ts +516 -0
- package/src/pcal-translate.ts +1230 -0
- package/src/pcal-validate.ts +454 -0
- package/src/randomization.ts +24 -7
- package/src/resolve.ts +1424 -415
- package/src/run-cli.ts +1200 -143
- package/src/runtime.ts +19 -1
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3112 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +545 -0
- package/src/sany-linter.ts +122 -0
- package/src/sany-modules.ts +1398 -0
- package/src/sany-nodes.ts +463 -0
- package/src/sany-parse-error.ts +2161 -0
- package/src/sany-report.ts +354 -0
- package/src/sany-selectors.ts +738 -0
- package/src/sany-source.ts +248 -0
- package/src/sany-xml.ts +1017 -0
- package/src/spec-description.ts +42 -11
- package/src/standard-modules.ts +200 -148
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +180 -0
- package/src/subexpressions.ts +231 -171
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +219 -107
- package/src/symmetry.ts +189 -53
- package/src/tableau.ts +54 -25
- package/src/tlc-ext.ts +42 -29
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +52 -43
- package/src/tlc-order.ts +73 -9
- package/src/tlc-random.ts +37 -9
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-summary.ts +20 -5
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/value-sources.ts +29 -0
- package/src/values.ts +708 -180
package/src/tlc-random.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TlaEvaluationError } from "./errors";
|
|
2
|
+
import type { TlcVersion } from "./tlc-version";
|
|
2
3
|
import {
|
|
3
4
|
createRecord,
|
|
4
5
|
createSortedFunction,
|
|
@@ -181,8 +182,10 @@ const createShiftTable = (length: number) => {
|
|
|
181
182
|
|
|
182
183
|
// Extending a fingerprint by a byte is linear over GF(2), so extending it by a value's bytes
|
|
183
184
|
// XORs the value's own fingerprint from zero into the fingerprint shifted by their length.
|
|
184
|
-
// The fingerprinter caches each distinct variable value for one pass over the stored states.
|
|
185
|
-
|
|
185
|
+
// The fingerprinter caches each distinct variable value for one pass over the stored states. It
|
|
186
|
+
// reads a state's variables in `order` and writes each fingerprint's low and high words into
|
|
187
|
+
// `words`, an Int32Array over a little-endian BigInt64Array.
|
|
188
|
+
export const createTlcFingerprinter = (order: number[], words: Int32Array) => {
|
|
186
189
|
const shiftTables = new Map<number, Int32Array>();
|
|
187
190
|
const indices = new Map<Value, number>();
|
|
188
191
|
const contributions: number[] = [];
|
|
@@ -204,11 +207,11 @@ export const createTlcFingerprinter = () => {
|
|
|
204
207
|
shiftTables.set(length, table);
|
|
205
208
|
return table;
|
|
206
209
|
};
|
|
207
|
-
return (state: Value[]) => {
|
|
210
|
+
return (state: Value[], position: number) => {
|
|
208
211
|
const outer = { high, low };
|
|
209
212
|
const fingerprint = { high: INITIAL_HIGH, low: INITIAL_LOW };
|
|
210
|
-
for (const
|
|
211
|
-
const contribution = getContribution(
|
|
213
|
+
for (const index of order) {
|
|
214
|
+
const contribution = getContribution(state[index]);
|
|
212
215
|
const table = getShiftTable(contributions[contribution]);
|
|
213
216
|
const extended = {
|
|
214
217
|
high: contributions[contribution + 1],
|
|
@@ -225,7 +228,8 @@ export const createTlcFingerprinter = () => {
|
|
|
225
228
|
}
|
|
226
229
|
high = outer.high;
|
|
227
230
|
low = outer.low;
|
|
228
|
-
|
|
231
|
+
words[2 * position] = fingerprint.low;
|
|
232
|
+
words[2 * position + 1] = fingerprint.high;
|
|
229
233
|
};
|
|
230
234
|
};
|
|
231
235
|
|
|
@@ -286,7 +290,7 @@ const getModulusAndMultiplier = (size: number) => {
|
|
|
286
290
|
|
|
287
291
|
// EnumerableValue.SubsetEnumerator: count indices below size from a full-period linear
|
|
288
292
|
// congruential generator that starts at random.nextInt(size).
|
|
289
|
-
const
|
|
293
|
+
const getSubsetIndicesMaster = (count: number, size: number, random: JavaRandom) => {
|
|
290
294
|
if (size <= 0) return [];
|
|
291
295
|
const generator = getModulusAndMultiplier(size);
|
|
292
296
|
const state = { index: BigInt(random.nextInt(size)) };
|
|
@@ -299,6 +303,18 @@ const getSubsetIndices = (count: number, size: number, random: JavaRandom) => {
|
|
|
299
303
|
});
|
|
300
304
|
};
|
|
301
305
|
|
|
306
|
+
// TLC 1.7.4's EnumerableValue.SubsetEnumerator: the i-th index is (x * i + a) mod size, for a
|
|
307
|
+
// prime x above size and a = random.nextInt(size), so the first size indices are distinct.
|
|
308
|
+
const getSubsetIndices174 = (count: number, size: number, random: JavaRandom) => {
|
|
309
|
+
if (size <= 0) return [];
|
|
310
|
+
const stride = BigInt(size < 191 ? 191 : MAXIMUM_INT);
|
|
311
|
+
const offset = BigInt(random.nextInt(size));
|
|
312
|
+
return Array.from(
|
|
313
|
+
{ length: Math.min(count, size) },
|
|
314
|
+
(_, index) => (stride * BigInt(index) + offset) % BigInt(size),
|
|
315
|
+
);
|
|
316
|
+
};
|
|
317
|
+
|
|
302
318
|
const LARGE_STRIDE = (1n << 63n) - 1n - 24n;
|
|
303
319
|
|
|
304
320
|
// SetOfFcnsOrRcdsValue.BigIntegerSubsetEnumerator, for products with more than 2^31 - 1
|
|
@@ -352,15 +368,27 @@ const getProduct = (set: Value): Product | undefined => {
|
|
|
352
368
|
return undefined;
|
|
353
369
|
};
|
|
354
370
|
|
|
371
|
+
// TLC 1.7.4 enumerates a set of tuples to draw from it.
|
|
372
|
+
export const getEnumeratedFactors = (set: Value, version: TlcVersion) =>
|
|
373
|
+
version === "1.7.4" && typeof set === "object" && set.kind === "ProductSet"
|
|
374
|
+
? set.factors
|
|
375
|
+
: undefined;
|
|
376
|
+
|
|
355
377
|
// Enumerable#getRandomSubset, which Randomization's RandomSubset calls.
|
|
356
|
-
export const getRandomSubset = (
|
|
378
|
+
export const getRandomSubset = (
|
|
379
|
+
count: number,
|
|
380
|
+
set: Value,
|
|
381
|
+
random: JavaRandom,
|
|
382
|
+
version: TlcVersion,
|
|
383
|
+
): Value[] => {
|
|
357
384
|
if (isEmptySet(set)) return [];
|
|
385
|
+
const getSubsetIndices = version === "1.7.4" ? getSubsetIndices174 : getSubsetIndicesMaster;
|
|
358
386
|
if (typeof set === "object" && set.kind === "Interval") {
|
|
359
387
|
return getSubsetIndices(count, Math.max(0, set.high - set.low + 1), random).map(
|
|
360
388
|
(index) => set.low + Number(index),
|
|
361
389
|
);
|
|
362
390
|
}
|
|
363
|
-
const product = getProduct(set);
|
|
391
|
+
const product = getEnumeratedFactors(set, version) ? undefined : getProduct(set);
|
|
364
392
|
if (product) {
|
|
365
393
|
const size = product.lists.reduce((total, list) => total * BigInt(list.length), 1n);
|
|
366
394
|
const indices =
|