tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.b4a856304
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +0 -34
- package/dist/index.d.ts +0 -34
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +43 -43
- package/dist/prove.js +47 -47
- package/dist/run.cjs +30 -30
- package/dist/run.js +33 -33
- package/dist/transfer.cjs +38 -38
- package/dist/transfer.js +39 -39
- package/package.json +1 -1
- package/src/ast.ts +5 -0
- package/src/bags.ts +5 -2
- package/src/builtins.ts +8 -1
- package/src/check.ts +193 -128
- package/src/cli/run.ts +2 -0
- package/src/cli/runtime-invariants.ts +7 -8
- package/src/cli/shared.ts +4 -0
- package/src/cli/tlc-arguments.ts +30 -24
- package/src/cli/tlc-usage.ts +3 -2
- package/src/evaluate.ts +102 -26
- package/src/java-overrides.ts +9 -4
- package/src/json-reader.ts +2 -1
- package/src/json.ts +11 -4
- package/src/levels.ts +15 -7
- package/src/lexer.ts +83 -72
- package/src/liveness-checker.ts +106 -77
- package/src/liveness.ts +34 -10
- package/src/parallel.ts +33 -26
- package/src/parser.ts +226 -163
- package/src/pcal/ast.ts +65 -53
- package/src/pcal/parse.ts +191 -144
- package/src/pcal/tokenize.ts +115 -91
- package/src/pcal/translate.ts +98 -83
- package/src/pcal/validate.ts +50 -48
- package/src/pretty-print.ts +6 -6
- package/src/randomization.ts +4 -1
- package/src/resolve.ts +70 -12
- package/src/runtime.ts +18 -11
- package/src/sany/builtins.ts +3 -1
- package/src/sany/generator.ts +127 -74
- package/src/sany/levels.ts +9 -5
- package/src/sany/lexer.ts +44 -40
- package/src/sany/linter.ts +1 -0
- package/src/search.ts +1 -1
- package/src/simulate.ts +59 -50
- package/src/spec-description.ts +34 -23
- package/src/standard-definitions.ts +3 -0
- package/src/standard-modules.ts +12 -1
- package/src/state-graph.ts +8 -1
- package/src/subexpressions.ts +47 -38
- package/src/successors.ts +35 -14
- package/src/symmetry.ts +19 -4
- package/src/tlc/fingerprint.ts +21 -15
- package/src/tlc/jar-data.ts +1 -0
- package/src/tlc/messages.ts +21 -2
- package/src/tlc/order.ts +38 -20
- package/src/tlc/random.ts +30 -18
- package/src/tlc/replay.ts +33 -13
- package/src/tlc/summary.ts +45 -36
- package/src/tlc/tlc-operators.ts +14 -4
- package/src/tlc/tlcext-operators.ts +15 -11
- package/src/tlc/trace-spec.ts +4 -0
- package/src/tlc/value-stream.ts +13 -9
- package/src/tlc/version.ts +1 -0
- package/src/values.ts +181 -74
package/package.json
CHANGED
package/src/ast.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface IdentifierExpression {
|
|
|
42
42
|
resolution?: LocalResolution;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// spelling holds the text of an operator written as a synonym, such as (+) for \oplus, which SANY
|
|
46
|
+
// reports as written.
|
|
45
47
|
export interface ApplyExpression {
|
|
46
48
|
kind: "Apply";
|
|
47
49
|
operator: string;
|
|
@@ -75,6 +77,8 @@ export interface JunctionExpression {
|
|
|
75
77
|
kind: "And" | "Or";
|
|
76
78
|
operands: Expression[];
|
|
77
79
|
isBulleted?: boolean;
|
|
80
|
+
// SANY parses A /\ B /\ C as (A /\ B) /\ C, whose node of each prefix of two or more operands ends
|
|
81
|
+
// after the parentheses of its last operand.
|
|
78
82
|
prefixEnds?: SourceLocation[];
|
|
79
83
|
location: SourceLocation;
|
|
80
84
|
}
|
|
@@ -241,6 +245,7 @@ export interface FunctionApplicationExpression {
|
|
|
241
245
|
location: SourceLocation;
|
|
242
246
|
}
|
|
243
247
|
|
|
248
|
+
// SANY parses [e1, ..., en] as a function application without the function, and rejects it.
|
|
244
249
|
export interface BracketExpression {
|
|
245
250
|
kind: "Bracket";
|
|
246
251
|
args: Expression[];
|
package/src/bags.ts
CHANGED
|
@@ -85,6 +85,8 @@ const findCount = (functionValue: FunctionValue, element: Value) => {
|
|
|
85
85
|
return position === -1 ? undefined : functionValue.range[position];
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
// Bags.java casts each count to IntValue, so a count that isn't an integer fails with a
|
|
89
|
+
// ClassCastException.
|
|
88
90
|
const toCount = (value: Value) => {
|
|
89
91
|
if (typeof value === "number") return value;
|
|
90
92
|
const javaClass = `tlc2.value.impl.${getJavaClassName(value)}`;
|
|
@@ -99,7 +101,7 @@ const addCounts = (left: Value, right: Value) => {
|
|
|
99
101
|
return sum;
|
|
100
102
|
};
|
|
101
103
|
|
|
102
|
-
//
|
|
104
|
+
// Bags.java subtracts counts as Java ints, which wrap, where the - of the TLA+ definition overflows.
|
|
103
105
|
const subtractCounts = (functionValue: FunctionValue, index: number, other: FunctionValue) => {
|
|
104
106
|
const count = toCount(functionValue.range[index]);
|
|
105
107
|
const removed = findCount(other, functionValue.domain[index]);
|
|
@@ -121,6 +123,7 @@ const getPairs = (functionValue: FunctionValue) =>
|
|
|
121
123
|
|
|
122
124
|
const EMPTY_BAG = createSortedFunction([], []);
|
|
123
125
|
|
|
126
|
+
// SubBag compares the counts with the >= of Naturals, which Integers replaces when TLC loads it.
|
|
124
127
|
export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Builtin[] => [
|
|
125
128
|
defineConstant("EmptyBag", EMPTY_BAG),
|
|
126
129
|
defineOperator("IsABag", 1, (args) => {
|
|
@@ -239,7 +242,7 @@ export const createBagsOperators = (builtins: ReadonlyMap<string, Builtin>): Bui
|
|
|
239
242
|
(subBags, key, index) =>
|
|
240
243
|
subBags.flatMap((entries) => [
|
|
241
244
|
entries,
|
|
242
|
-
...Array.from({ length: counts[index] }, (
|
|
245
|
+
...Array.from({ length: counts[index] }, (_, copies): [Value, Value][] => [
|
|
243
246
|
...entries,
|
|
244
247
|
[key, copies + 1],
|
|
245
248
|
]),
|
package/src/builtins.ts
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
type Value,
|
|
19
19
|
} from "./values";
|
|
20
20
|
|
|
21
|
+
// TLC evaluates these in its core, or its Java code takes integers, so a wrong argument is an
|
|
22
|
+
// evaluation failure. Every other standard-module operator raises an EvalException.
|
|
21
23
|
const CORE_OPERATOR_NAMES = new Set([
|
|
22
24
|
"=",
|
|
23
25
|
"#",
|
|
@@ -227,9 +229,12 @@ export const getKindString = (value: Value) => KIND_STRINGS[getJavaClassName(val
|
|
|
227
229
|
const getJavaOverrideMessage = (signature: string, message: string) =>
|
|
228
230
|
`Attempted to apply the operator overridden by the Java method\n${signature},\nbut it produced the following error:\n${message}`;
|
|
229
231
|
|
|
230
|
-
const createJavaOverrideError = (signature: string, message: string) =>
|
|
232
|
+
export const createJavaOverrideError = (signature: string, message: string) =>
|
|
231
233
|
new TlaEvaluationError(getJavaOverrideMessage(signature, message));
|
|
232
234
|
|
|
235
|
+
// TLC reports a failure inside an operator's Java method as a failure of the method, except an
|
|
236
|
+
// EvalException the method raises itself, and a NullPointerException as an EvalException. A method
|
|
237
|
+
// that evaluates its own arguments reports every failure as a failure of the method.
|
|
233
238
|
export const overrideWithJava = (builtin: Builtin, signature: string): Builtin => {
|
|
234
239
|
const reportAsJavaFailure =
|
|
235
240
|
<Arguments extends unknown[]>(compute: (...args: Arguments) => Value) =>
|
|
@@ -242,6 +247,7 @@ export const overrideWithJava = (builtin: Builtin, signature: string): Builtin =
|
|
|
242
247
|
throw error;
|
|
243
248
|
}
|
|
244
249
|
const isFingerprinted = isFingerprintedSince(depth);
|
|
250
|
+
// The wrapping error replaces the FingerprintException.
|
|
245
251
|
if (setTrace.sets) setTrace.sets.length = depth;
|
|
246
252
|
const isWrapped =
|
|
247
253
|
builtin.isLazy === true || !(error instanceof TlaModuleError) || isFingerprinted;
|
|
@@ -305,6 +311,7 @@ const getIntegerArgument = (value: Value, position: string, name: string) => {
|
|
|
305
311
|
return value;
|
|
306
312
|
};
|
|
307
313
|
|
|
314
|
+
// The error of an argument that isn't an integer names the operator as TLC's method does.
|
|
308
315
|
export const defineComparison = (
|
|
309
316
|
name: string,
|
|
310
317
|
compare: (left: number, right: number) => boolean,
|