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/parallel.ts
CHANGED
|
@@ -25,15 +25,17 @@ import {
|
|
|
25
25
|
reportStartup,
|
|
26
26
|
} from "./search";
|
|
27
27
|
import { getInitialStates } from "./successors";
|
|
28
|
+
import { setFingerprintPolynomial } from "./tlc/fingerprint";
|
|
28
29
|
import { createTlcOrder } from "./tlc/order";
|
|
29
30
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
30
31
|
import { createStateEncoder, type EncodedStates } from "./transfer";
|
|
31
32
|
import type { TlcVersion } from "./tlc/version";
|
|
32
33
|
import {
|
|
33
34
|
createCanonicalizer,
|
|
34
|
-
|
|
35
|
+
freezeStringOrder,
|
|
36
|
+
getUnorderedString,
|
|
35
37
|
setStringOrder,
|
|
36
|
-
|
|
38
|
+
setValueOptions,
|
|
37
39
|
type Value,
|
|
38
40
|
} from "./values";
|
|
39
41
|
import { spawnWorker, type Port } from "./worker";
|
|
@@ -48,15 +50,18 @@ export interface StartMessage {
|
|
|
48
50
|
ports: (Port | undefined)[];
|
|
49
51
|
seed: EncodedStates;
|
|
50
52
|
isTool: boolean | undefined;
|
|
51
|
-
|
|
53
|
+
traceFile: string | undefined;
|
|
52
54
|
isWarningEnabled: boolean | undefined;
|
|
53
55
|
version: TlcVersion | undefined;
|
|
56
|
+
fingerprintPolynomial: number | undefined;
|
|
57
|
+
maxSetSize: number | undefined;
|
|
58
|
+
isLazyValueExpanded: boolean | undefined;
|
|
54
59
|
fingerprints: SharedFingerprints;
|
|
55
60
|
requests: Int32Array;
|
|
56
61
|
remaining: Int32Array;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
interface LevelMessage {
|
|
60
65
|
type: "level";
|
|
61
66
|
generated: number;
|
|
62
67
|
added: number;
|
|
@@ -66,7 +71,7 @@ export interface LevelMessage {
|
|
|
66
71
|
|
|
67
72
|
export type WorkerMessage =
|
|
68
73
|
| { type: "ready" }
|
|
69
|
-
| { type: "abort" }
|
|
74
|
+
| { type: "abort"; string?: string }
|
|
70
75
|
| { type: "paused" }
|
|
71
76
|
| LevelMessage;
|
|
72
77
|
|
|
@@ -81,7 +86,6 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
81
86
|
: options.config;
|
|
82
87
|
const print = options.onPrint ?? console.log;
|
|
83
88
|
const printed = { count: 0 };
|
|
84
|
-
// What each point the search reports is about, such as the invariant TLC warns about.
|
|
85
89
|
const getKey = (progress: CheckProgress) =>
|
|
86
90
|
[
|
|
87
91
|
progress.kind,
|
|
@@ -96,7 +100,10 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
96
100
|
};
|
|
97
101
|
// The search on the calling thread prints and reports what this one did while it started, so it
|
|
98
102
|
// skips that.
|
|
99
|
-
const fallBack = () => {
|
|
103
|
+
const fallBack = (createdString?: string) => {
|
|
104
|
+
if (createdString !== undefined) {
|
|
105
|
+
options.onProgress?.({ kind: "sequential-fallback", string: createdString });
|
|
106
|
+
}
|
|
100
107
|
const skipped = { count: printed.count };
|
|
101
108
|
return checkSequentially({
|
|
102
109
|
...options,
|
|
@@ -108,15 +115,19 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
108
115
|
});
|
|
109
116
|
};
|
|
110
117
|
const workerCount = options.workers ?? 1;
|
|
111
|
-
// TLC's workers write the -dump state graph
|
|
112
|
-
//
|
|
118
|
+
// TLC's workers write the -dump state graph, and print the violations -continue goes on past, in
|
|
119
|
+
// whichever order they find them, so one worker does what a single TLC worker does. The
|
|
120
|
+
// coverage counts live in one worker's evaluators.
|
|
113
121
|
const isSequential =
|
|
114
122
|
workerCount < 2 ||
|
|
115
123
|
typeof SharedArrayBuffer !== "function" ||
|
|
116
124
|
options.dump !== undefined ||
|
|
125
|
+
options.coverage !== undefined ||
|
|
126
|
+
options.isContinued === true ||
|
|
117
127
|
config.view !== undefined ||
|
|
118
128
|
config.postconditions.length > 0 ||
|
|
119
|
-
config.possible.length > 0
|
|
129
|
+
config.possible.length > 0 ||
|
|
130
|
+
(options.moduleOperators?.length ?? 0) > 0;
|
|
120
131
|
if (isSequential) return fallBack();
|
|
121
132
|
const modules = new Map<string, string | undefined>();
|
|
122
133
|
const loadModule = (name: string) => {
|
|
@@ -132,8 +143,9 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
132
143
|
};
|
|
133
144
|
const order = createTlcOrder(options.source, loadModule);
|
|
134
145
|
setStringOrder(order.getStringOrder(config));
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
setValueOptions(options);
|
|
147
|
+
setFingerprintPolynomial(options.fingerprintPolynomial ?? 0);
|
|
148
|
+
freezeStringOrder();
|
|
137
149
|
const specification = createEnvironment(config, {
|
|
138
150
|
source: options.source,
|
|
139
151
|
loadModule,
|
|
@@ -143,9 +155,13 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
143
155
|
printed.count++;
|
|
144
156
|
print(text);
|
|
145
157
|
},
|
|
146
|
-
files: {
|
|
158
|
+
files: {
|
|
159
|
+
readFile: options.readFile,
|
|
160
|
+
writeFile: options.writeFile,
|
|
161
|
+
makeDirectory: options.makeDirectory,
|
|
162
|
+
},
|
|
147
163
|
isTool: options.isTool,
|
|
148
|
-
|
|
164
|
+
traceFile: options.traceSpec?.traceFile,
|
|
149
165
|
isSanyReported: options.isSanyReported,
|
|
150
166
|
isWarningEnabled: options.isWarningEnabled,
|
|
151
167
|
version: options.version,
|
|
@@ -155,6 +171,7 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
155
171
|
const search = createSearch(
|
|
156
172
|
config,
|
|
157
173
|
environment,
|
|
174
|
+
specification.variableLocations,
|
|
158
175
|
() => order.getDeclarationOrder("variable"),
|
|
159
176
|
report,
|
|
160
177
|
);
|
|
@@ -232,7 +249,8 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
232
249
|
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
233
250
|
return fallBack();
|
|
234
251
|
}
|
|
235
|
-
|
|
252
|
+
const unorderedString = getUnorderedString();
|
|
253
|
+
if (unorderedString !== undefined) return fallBack(unorderedString);
|
|
236
254
|
statistics.depth = statistics.generatedStates === 0 ? 0 : 1;
|
|
237
255
|
statistics.initialStates = {
|
|
238
256
|
generated: statistics.generatedStates,
|
|
@@ -289,9 +307,12 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
289
307
|
ports,
|
|
290
308
|
seed,
|
|
291
309
|
isTool: options.isTool,
|
|
292
|
-
|
|
310
|
+
traceFile: options.traceSpec?.traceFile,
|
|
293
311
|
isWarningEnabled: options.isWarningEnabled,
|
|
294
312
|
version: options.version,
|
|
313
|
+
fingerprintPolynomial: options.fingerprintPolynomial,
|
|
314
|
+
maxSetSize: options.maxSetSize,
|
|
315
|
+
isLazyValueExpanded: options.isLazyValueExpanded,
|
|
295
316
|
fingerprints: shared.fingerprints,
|
|
296
317
|
requests,
|
|
297
318
|
remaining,
|
|
@@ -324,7 +345,10 @@ export const check = async (options: CheckOptions): Promise<CheckResult> => {
|
|
|
324
345
|
const messages = await collectLevels(await reported);
|
|
325
346
|
if (isAborted(messages)) {
|
|
326
347
|
terminate();
|
|
327
|
-
|
|
348
|
+
const aborted = messages.find(
|
|
349
|
+
(message) => message.type === "abort" && message.string !== undefined,
|
|
350
|
+
);
|
|
351
|
+
return fallBack(aborted?.type === "abort" ? aborted.string : undefined);
|
|
328
352
|
}
|
|
329
353
|
const levels = messages.flatMap((message) => (message.type === "level" ? [message] : []));
|
|
330
354
|
const added = levels.reduce((sum, message) => sum + message.added, 0);
|