tla-ts 0.0.3 → 0.0.4-dev.5f6a4bf
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 +32 -12
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +160 -8
- package/dist/index.d.ts +160 -8
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +2 -2
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +45 -18
- package/dist/run-cli.js +45 -18
- package/dist/transfer.cjs +1393 -18
- package/dist/transfer.js +1393 -18
- package/package.json +5 -1
- package/src/ast.ts +147 -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 +254 -181
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +540 -140
- package/src/errors.ts +224 -3
- package/src/evaluate.ts +796 -246
- package/src/exit-codes.ts +22 -43
- package/src/fingerprints.ts +46 -11
- 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 +127 -30
- 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 +174 -213
- package/src/parallel.ts +131 -39
- package/src/parser.ts +456 -147
- 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 +1481 -426
- package/src/run-cli.ts +1212 -143
- package/src/runtime.ts +19 -1
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3128 -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 +356 -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 +194 -54
- 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-modules.ts +4 -0
- package/src/tlc-order.ts +78 -10
- 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 +731 -184
package/src/runtime.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { createJavaRandom, getTlcFingerprint, type JavaRandom } from "./tlc-random";
|
|
2
2
|
import { createFunction, createRecord, type Value } from "./values";
|
|
3
|
+
import type { TlcVersion } from "./tlc-version";
|
|
3
4
|
|
|
4
5
|
export interface CheckerRuntime {
|
|
5
6
|
getLevel: (state: (Value | undefined)[]) => number;
|
|
6
7
|
getBehavior: (state: Value[]) => Value[][];
|
|
7
8
|
getSpecification: () => Value;
|
|
8
9
|
counterExample: Value | undefined;
|
|
9
|
-
setLivenessSource: (index: number) => void;
|
|
10
|
+
setLivenessSource: (index: number | undefined) => void;
|
|
10
11
|
getCurrentState: () => Value[] | undefined;
|
|
11
12
|
getFingerprint: (state: Value[]) => bigint;
|
|
12
13
|
getRandom: () => JavaRandom;
|
|
13
14
|
evaluateAtStartup: <Result>(evaluate: () => Result) => Result;
|
|
14
15
|
pause: () => void;
|
|
16
|
+
// Prints a warning TLC raises while it evaluates, with its message code. TLC prints each
|
|
17
|
+
// distinct warning once.
|
|
18
|
+
warn: (code: number, text: string) => void;
|
|
19
|
+
// TLC's -nowarning turns the warnings off, and with them the shortcut that evaluates the rest
|
|
20
|
+
// of an action once it assigns every variable, since that shortcut skips a warning.
|
|
21
|
+
isWarningEnabled: boolean;
|
|
22
|
+
// TLC's -tool, under which the message of an error that TLC raises with a code holds the
|
|
23
|
+
// code's markers, which AssertError compares with.
|
|
24
|
+
isTool: boolean;
|
|
25
|
+
// The TLC whose messages tla-ts reproduces.
|
|
26
|
+
version: TlcVersion;
|
|
15
27
|
seed: bigint;
|
|
16
28
|
isSeen: (state: Value[]) => boolean;
|
|
17
29
|
generatedStates: number;
|
|
@@ -24,6 +36,7 @@ export interface CheckerRuntime {
|
|
|
24
36
|
properties: Map<string, string>;
|
|
25
37
|
possibleCounts: Map<string, number>;
|
|
26
38
|
isStopped: boolean;
|
|
39
|
+
isStarted: boolean;
|
|
27
40
|
checkDeadlock: boolean;
|
|
28
41
|
startedAt: number;
|
|
29
42
|
}
|
|
@@ -64,6 +77,10 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
|
|
|
64
77
|
}
|
|
65
78
|
},
|
|
66
79
|
pause: () => {},
|
|
80
|
+
warn: () => {},
|
|
81
|
+
isWarningEnabled: true,
|
|
82
|
+
isTool: false,
|
|
83
|
+
version: "master",
|
|
67
84
|
seed,
|
|
68
85
|
generatedStates: 0,
|
|
69
86
|
distinctStates: 0,
|
|
@@ -75,6 +92,7 @@ export const createRuntime = (checkDeadlock: boolean, seed = 0n): CheckerRuntime
|
|
|
75
92
|
properties: new Map(),
|
|
76
93
|
possibleCounts: new Map(),
|
|
77
94
|
isStopped: false,
|
|
95
|
+
isStarted: false,
|
|
78
96
|
checkDeadlock,
|
|
79
97
|
startedAt: Date.now(),
|
|
80
98
|
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { FormalParamNode, LevelFields, OpDefNode, SanyLocation } from "./sany-nodes";
|
|
2
|
+
|
|
3
|
+
// tla2sany.semantic.BuiltInOperators: name, arity, level, maximum argument levels and argument
|
|
4
|
+
// weights. SANY leaves the levels of "." and \neg unset.
|
|
5
|
+
const BUILTIN_OPERATORS: [string, number, number, number[] | undefined, number[] | undefined][] = [
|
|
6
|
+
["STRING", 0, 0, [], []],
|
|
7
|
+
["FALSE", 0, 0, [], []],
|
|
8
|
+
["TRUE", 0, 0, [], []],
|
|
9
|
+
["BOOLEAN", 0, 0, [], []],
|
|
10
|
+
["=", 2, 0, [2, 2], [1, 1]],
|
|
11
|
+
["/=", 2, 0, [2, 2], [1, 1]],
|
|
12
|
+
[".", 2, 0, undefined, undefined],
|
|
13
|
+
["'", 1, 2, [1], [0]],
|
|
14
|
+
["\\lnot", 1, 0, [3], [1]],
|
|
15
|
+
["\\neg", 1, 0, undefined, undefined],
|
|
16
|
+
["\\land", 2, 0, [3, 3], [1, 1]],
|
|
17
|
+
["\\lor", 2, 0, [3, 3], [1, 1]],
|
|
18
|
+
["\\equiv", 2, 0, [3, 3], [1, 1]],
|
|
19
|
+
["=>", 2, 0, [3, 3], [1, 1]],
|
|
20
|
+
["SUBSET", 1, 0, [2], [1]],
|
|
21
|
+
["UNION", 1, 0, [2], [1]],
|
|
22
|
+
["DOMAIN", 1, 0, [2], [1]],
|
|
23
|
+
["\\subseteq", 2, 0, [2, 2], [1, 1]],
|
|
24
|
+
["\\in", 2, 0, [2, 2], [1, 1]],
|
|
25
|
+
["\\notin", 2, 0, [2, 2], [1, 1]],
|
|
26
|
+
["\\", 2, 0, [2, 2], [1, 1]],
|
|
27
|
+
["\\intersect", 2, 0, [2, 2], [1, 1]],
|
|
28
|
+
["\\union", 2, 0, [2, 2], [1, 1]],
|
|
29
|
+
["\\times", 2, 0, [2, 2], [1, 1]],
|
|
30
|
+
["~>", 2, 3, [3, 3], [0, 0]],
|
|
31
|
+
["[]", 1, 3, [3], [0]],
|
|
32
|
+
["<>", 1, 3, [3], [0]],
|
|
33
|
+
["ENABLED", 1, 1, [2], [0]],
|
|
34
|
+
["UNCHANGED", 1, 2, [1], [0]],
|
|
35
|
+
["\\cdot", 2, 2, [2, 2], [0, 0]],
|
|
36
|
+
["-+->", 2, 3, [3, 3], [0, 0]],
|
|
37
|
+
["$AngleAct", 2, 2, [2, 1], [0, 0]],
|
|
38
|
+
["$BoundedChoose", -1, 0, [2], [1]],
|
|
39
|
+
["$BoundedExists", -1, 0, [3], [1]],
|
|
40
|
+
["$BoundedForall", -1, 0, [3], [1]],
|
|
41
|
+
["$CartesianProd", -1, 0, [2], [1]],
|
|
42
|
+
["$Case", -1, 0, [3], [1]],
|
|
43
|
+
["$ConjList", -1, 0, [3], [1]],
|
|
44
|
+
["$DisjList", -1, 0, [3], [1]],
|
|
45
|
+
["$Except", -1, 0, [2], [1]],
|
|
46
|
+
["$FcnApply", 2, 0, [2, 2], [1, 1]],
|
|
47
|
+
["$FcnConstructor", -1, 0, [3], [1]],
|
|
48
|
+
["$IfThenElse", 3, 0, [3, 3, 3], [1, 1, 1]],
|
|
49
|
+
["$NonRecursiveFcnSpec", 1, 0, [3], [1]],
|
|
50
|
+
["$Pair", 2, 0, [3, 3], [1, 1]],
|
|
51
|
+
["$RcdConstructor", -1, 0, [3], [1]],
|
|
52
|
+
["$RcdSelect", 2, 0, [2, 0], [1, 1]],
|
|
53
|
+
["$RecursiveFcnSpec", 1, 0, [3], [1]],
|
|
54
|
+
["$Seq", -1, 0, [2], [1]],
|
|
55
|
+
["$SetEnumerate", -1, 0, [2], [1]],
|
|
56
|
+
["$SetOfAll", -1, 0, [2], [1]],
|
|
57
|
+
["$SetOfFcns", -1, 0, [2], [1]],
|
|
58
|
+
["$SetOfRcds", -1, 0, [2], [1]],
|
|
59
|
+
["$SF", 2, 3, [1, 2], [0, 0]],
|
|
60
|
+
["$SquareAct", 2, 2, [2, 1], [0, 0]],
|
|
61
|
+
["$SubsetOf", 1, 0, [2], [1]],
|
|
62
|
+
["$TemporalExists", 1, 3, [3], [0]],
|
|
63
|
+
["$TemporalForall", 1, 3, [3], [0]],
|
|
64
|
+
["$TemporalWhile", 2, 3, [3, 3], [0, 0]],
|
|
65
|
+
["$Tuple", -1, 0, [2], [1]],
|
|
66
|
+
["$UnboundedChoose", 1, 0, [2], [1]],
|
|
67
|
+
["$UnboundedExists", 1, 0, [3], [1]],
|
|
68
|
+
["$UnboundedForall", 1, 0, [3], [1]],
|
|
69
|
+
["$WF", 2, 3, [1, 2], [0, 0]],
|
|
70
|
+
["$Nop", 1, 0, [3], [1]],
|
|
71
|
+
["$Qed", 0, 0, [], []],
|
|
72
|
+
["$Pfcase", 1, 0, [3], [1]],
|
|
73
|
+
["$Have", 1, 0, [3], [1]],
|
|
74
|
+
["$Take", 1, 0, [3], [1]],
|
|
75
|
+
["$Pick", 1, 0, [3], [1]],
|
|
76
|
+
["$Witness", -1, 0, [2], [1]],
|
|
77
|
+
["$Suffices", 1, 0, [3], [1]],
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
export const BUILTIN_LOCATION: SanyLocation = {
|
|
81
|
+
file: "--TLA+ BUILTINS--",
|
|
82
|
+
beginLine: 0,
|
|
83
|
+
beginColumn: 0,
|
|
84
|
+
endLine: 0,
|
|
85
|
+
endColumn: 0,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const createLevelFields = (id: number): LevelFields => ({
|
|
89
|
+
id,
|
|
90
|
+
levelChecked: 0,
|
|
91
|
+
level: 0,
|
|
92
|
+
levelParams: new Set(),
|
|
93
|
+
allParams: new Set(),
|
|
94
|
+
nonLeibnizParams: new Set(),
|
|
95
|
+
argLevelParams: new Map(),
|
|
96
|
+
levelCorrect: true,
|
|
97
|
+
levelConstraints: new Map(),
|
|
98
|
+
argLevelConstraints: new Map(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// The builtin operators in the order SANY adds them to its global context. OpDefNode's constructor
|
|
102
|
+
// for a builtin numbers the operator, then its phony parameters.
|
|
103
|
+
export const createBuiltins = (getId: () => number) =>
|
|
104
|
+
BUILTIN_OPERATORS.map(([name, arity, level, maxLevels, weights]): OpDefNode => {
|
|
105
|
+
const id = getId();
|
|
106
|
+
const params =
|
|
107
|
+
arity < 0
|
|
108
|
+
? undefined
|
|
109
|
+
: Array.from({ length: arity }, (_, index): FormalParamNode => ({
|
|
110
|
+
...createLevelFields(getId()),
|
|
111
|
+
kind: "FormalParam",
|
|
112
|
+
name: `Formal_${index}`,
|
|
113
|
+
arity: 0,
|
|
114
|
+
location: undefined,
|
|
115
|
+
}));
|
|
116
|
+
const isLevelSet = maxLevels !== undefined && weights !== undefined;
|
|
117
|
+
const isLeibnizArg = weights?.map((weight) => weight > 0);
|
|
118
|
+
return {
|
|
119
|
+
...createLevelFields(id),
|
|
120
|
+
levelChecked: isLevelSet ? 99 : 0,
|
|
121
|
+
level,
|
|
122
|
+
kind: "OpDef",
|
|
123
|
+
defKind: "BuiltIn",
|
|
124
|
+
name,
|
|
125
|
+
arity,
|
|
126
|
+
params,
|
|
127
|
+
body: undefined,
|
|
128
|
+
isLocal: false,
|
|
129
|
+
location: BUILTIN_LOCATION,
|
|
130
|
+
module: undefined,
|
|
131
|
+
source: undefined,
|
|
132
|
+
preComments: [],
|
|
133
|
+
isDefined: true,
|
|
134
|
+
inRecursive: false,
|
|
135
|
+
inRecursiveSection: false,
|
|
136
|
+
recursiveSection: -1,
|
|
137
|
+
letInLevel: 0,
|
|
138
|
+
weights: arity < 0 ? (weights ?? []).slice(0, 1) : (weights ?? []),
|
|
139
|
+
isLeibnizArg: isLevelSet ? isLeibnizArg : undefined,
|
|
140
|
+
isLeibniz: isLeibnizArg?.every(Boolean) ?? true,
|
|
141
|
+
opLevelCond: undefined,
|
|
142
|
+
maxLevels: arity < 0 ? (maxLevels ?? []).slice(0, 1) : (maxLevels ?? []),
|
|
143
|
+
minMaxLevel: undefined,
|
|
144
|
+
labels: new Map(),
|
|
145
|
+
step: undefined,
|
|
146
|
+
};
|
|
147
|
+
});
|