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/dependencies.ts
CHANGED
|
@@ -2,21 +2,17 @@ import { getChildren, isLocallyResolved, type Definition, type Expression } from
|
|
|
2
2
|
import type { Environment } from "./evaluate";
|
|
3
3
|
import { ACTION_LEVEL, CONSTANT_LEVEL, TEMPORAL_LEVEL, VARIABLE_LEVEL } from "./levels";
|
|
4
4
|
|
|
5
|
-
// The names of a spec that the facts depend on, which are final before the environment is built.
|
|
6
5
|
interface DefinitionNames extends Pick<
|
|
7
6
|
Environment,
|
|
8
7
|
"definitions" | "substitutions" | "constants" | "variableIndex" | "builtins" | "variables"
|
|
9
8
|
> {}
|
|
10
9
|
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// all, once, when the environment is created. A row of words holds a definition's facts: the first
|
|
15
|
-
// word holds the flags below, and the rest a bitset of the variables it reads.
|
|
10
|
+
// Each fact is reachability over the definitions a definition calls, so one pass over the call
|
|
11
|
+
// graph computes them all. A row's first word holds the flags below, and the rest a bitset of the
|
|
12
|
+
// variables the definition reads.
|
|
16
13
|
export interface DefinitionFacts {
|
|
17
14
|
ids: Map<Definition, number>;
|
|
18
15
|
rows: Uint32Array;
|
|
19
|
-
// The words of each row: one of flags, then one per 32 variables.
|
|
20
16
|
words: number;
|
|
21
17
|
}
|
|
22
18
|
|
|
@@ -70,8 +66,8 @@ const IMPURE_BUILTINS = new Set([
|
|
|
70
66
|
"TLCSet",
|
|
71
67
|
]);
|
|
72
68
|
|
|
73
|
-
// UNION and \cup
|
|
74
|
-
//
|
|
69
|
+
// UNION and \cup stream the sets they combine until TLC caches them, and TLC builds a new one at
|
|
70
|
+
// each evaluation.
|
|
75
71
|
const STREAMED_BUILTINS = new Set(["UNION", "\\cup"]);
|
|
76
72
|
|
|
77
73
|
const getReferencedName = (expression: Expression) => {
|
|
@@ -89,12 +85,11 @@ interface Edge {
|
|
|
89
85
|
// The configuration replaces the name by a constant value, which TLC's level and variable
|
|
90
86
|
// analyses take for a constant and its effect analysis evaluates.
|
|
91
87
|
isOverridden: boolean;
|
|
92
|
-
//
|
|
93
|
-
//
|
|
88
|
+
// Outside every action and temporal operator, where the level of the callee counts. An operator
|
|
89
|
+
// such as ENABLED fixes the level of what it holds.
|
|
94
90
|
isLevelCounted: boolean;
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
// The facts an expression's own nodes establish, with the definitions it refers to.
|
|
98
93
|
const collectLocalFacts = (
|
|
99
94
|
expressions: Expression[],
|
|
100
95
|
environment: DefinitionNames,
|
|
@@ -102,9 +97,8 @@ const collectLocalFacts = (
|
|
|
102
97
|
) => {
|
|
103
98
|
const row = new Uint32Array(words);
|
|
104
99
|
const edges: Edge[] = [];
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
// below one counts towards the level, variables and callees included.
|
|
100
|
+
// Undefined for a node whose level the nodes it holds decide. Nothing below an action or temporal
|
|
101
|
+
// operator, or ENABLED, counts towards the level, variables and callees included.
|
|
108
102
|
const getOwnLevelFlags = (node: Expression) => {
|
|
109
103
|
const kind = node.kind;
|
|
110
104
|
if (ACTION_KINDS.has(kind) || (kind === "Apply" && node.operator === "\\cdot")) {
|
|
@@ -139,7 +133,12 @@ const collectLocalFacts = (
|
|
|
139
133
|
const definition = environment.definitions.get(target);
|
|
140
134
|
const isOverridden = environment.constants.has(name);
|
|
141
135
|
const variableIndex = environment.variableIndex.get(name);
|
|
142
|
-
|
|
136
|
+
// TLC's level bound takes an instance's definition named like a variable for the variable.
|
|
137
|
+
if (
|
|
138
|
+
variableIndex !== undefined ||
|
|
139
|
+
environment.builtins.get(name)?.isStateLevel ||
|
|
140
|
+
(definition && environment.variableIndex.has(definition.name))
|
|
141
|
+
) {
|
|
143
142
|
row[0] |= NONCONSTANT;
|
|
144
143
|
}
|
|
145
144
|
if (variableIndex !== undefined) {
|
|
@@ -162,7 +161,7 @@ const collectLocalFacts = (
|
|
|
162
161
|
builtin?.isStateLevel &&
|
|
163
162
|
!builtin.isLevelConstant
|
|
164
163
|
) {
|
|
165
|
-
row[0] |= VARIABLE_LEVEL_FLAGS;
|
|
164
|
+
row[0] |= builtin.isActionLevel ? ACTION_LEVEL_FLAGS : VARIABLE_LEVEL_FLAGS;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|
|
@@ -177,9 +176,8 @@ const getDefinitionExpressions = (definition: Definition) =>
|
|
|
177
176
|
? [...definition.bounds.map((bound) => bound.set), definition.body]
|
|
178
177
|
: [definition.body];
|
|
179
178
|
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
// callees first, so each component ors in components that are already final.
|
|
179
|
+
// Tarjan's algorithm lists the strongly connected components with the callees first, so each
|
|
180
|
+
// component ors in components that are already final.
|
|
183
181
|
const closeRows = (local: Uint32Array, words: number, edges: Int32Array[], mask: number) => {
|
|
184
182
|
const count = edges.length;
|
|
185
183
|
const closed = local.slice();
|
|
@@ -187,7 +185,6 @@ const closeRows = (local: Uint32Array, words: number, edges: Int32Array[], mask:
|
|
|
187
185
|
const lowLink = new Int32Array(count);
|
|
188
186
|
const component = new Int32Array(count).fill(-1);
|
|
189
187
|
const stack: number[] = [];
|
|
190
|
-
// The frame of a depth-first visit: the node and the edge it resumes at.
|
|
191
188
|
const frames: number[] = [];
|
|
192
189
|
let nextIndex = 0;
|
|
193
190
|
let componentCount = 0;
|
|
@@ -226,7 +223,7 @@ const closeRows = (local: Uint32Array, words: number, edges: Int32Array[], mask:
|
|
|
226
223
|
lowLink[caller] = Math.min(lowLink[caller], lowLink[node]);
|
|
227
224
|
}
|
|
228
225
|
if (lowLink[node] !== index[node]) continue;
|
|
229
|
-
// The component
|
|
226
|
+
// The component's members share one row, which ors in their callees' rows.
|
|
230
227
|
const members: number[] = [];
|
|
231
228
|
for (;;) {
|
|
232
229
|
const member = stack.pop() ?? node;
|
|
@@ -299,8 +296,6 @@ export const createDefinitionFacts = (environment: DefinitionNames): DefinitionF
|
|
|
299
296
|
return { ids, rows, words };
|
|
300
297
|
};
|
|
301
298
|
|
|
302
|
-
// The facts of a definition: from the table, or for a LET definition from its own body and the
|
|
303
|
-
// table's rows of the definitions it calls.
|
|
304
299
|
const getRow = (definition: Definition, environment: Environment): Uint32Array => {
|
|
305
300
|
const facts = environment.facts;
|
|
306
301
|
const id = facts.ids.get(definition);
|
|
@@ -309,7 +304,6 @@ const getRow = (definition: Definition, environment: Environment): Uint32Array =
|
|
|
309
304
|
: facts.rows.subarray(id * facts.words, (id + 1) * facts.words);
|
|
310
305
|
};
|
|
311
306
|
|
|
312
|
-
// The facts of expressions: their own, with the rows of the definitions they call ored in.
|
|
313
307
|
const getExpressionsRow = (expressions: Expression[], environment: Environment) => {
|
|
314
308
|
const words = environment.facts.words;
|
|
315
309
|
const local = collectLocalFacts(expressions, environment, words);
|
|
@@ -337,7 +331,6 @@ export const isImpureDefinition = (
|
|
|
337
331
|
effect: keyof typeof EFFECT_FLAGS = "any",
|
|
338
332
|
) => (getRow(definition, environment)[0] & EFFECT_FLAGS[effect]) !== 0;
|
|
339
333
|
|
|
340
|
-
// The liveness level of a definition: constant, variable, action or temporal.
|
|
341
334
|
export const getDefinitionLevel = (definition: Definition, environment: Environment) => {
|
|
342
335
|
const flags = getRow(definition, environment)[0] & TEMPORAL_LEVEL_FLAGS;
|
|
343
336
|
return flags === TEMPORAL_LEVEL_FLAGS
|
|
@@ -359,8 +352,7 @@ const toVariables = (row: Uint32Array) => {
|
|
|
359
352
|
return variables;
|
|
360
353
|
};
|
|
361
354
|
|
|
362
|
-
//
|
|
363
|
-
// decide its value, or undefined when it has an effect or is an action.
|
|
355
|
+
// Undefined when the expression has an effect or is an action.
|
|
364
356
|
export const getReadVariables = (
|
|
365
357
|
expression: Expression,
|
|
366
358
|
environment: Environment,
|