tla-ts 0.0.3-dev.30014f9 → 0.0.3-dev.31e0776
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 +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- 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 +17 -16
- package/dist/run-cli.js +6 -5
- package/dist/transfer.cjs +26 -14
- package/dist/transfer.js +26 -14
- package/package.json +1 -1
- package/src/ast.ts +90 -0
- package/src/check.ts +191 -54
- package/src/cli-options.ts +11 -5
- package/src/codegen.ts +9 -19
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +75 -16
- package/src/errors.ts +9 -2
- package/src/evaluate.ts +75 -135
- package/src/exit-codes.ts +21 -43
- package/src/instances.ts +15 -14
- package/src/levels.ts +8 -8
- package/src/live-check.ts +710 -0
- package/src/liveness.ts +5 -523
- package/src/parallel.ts +3 -0
- package/src/resolve.ts +16 -15
- package/src/run-cli.ts +58 -13
- package/src/runtime.ts +3 -1
- package/src/spec-description.ts +18 -6
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +10 -10
- package/src/successors.ts +66 -9
- package/src/tlc-ext.ts +29 -12
- package/src/tlc-module.ts +9 -28
- package/src/values.ts +20 -4
package/src/values.ts
CHANGED
|
@@ -1069,13 +1069,16 @@ const isTlcEnumerable = (value: Value) => isSetValue(value) && !isOverriddenSet(
|
|
|
1069
1069
|
const formatUnion = (value: UnionValue, isStrict = false) =>
|
|
1070
1070
|
`UNION(${formatValue(value.base, isStrict)})`;
|
|
1071
1071
|
|
|
1072
|
-
const getUnionSets = (
|
|
1072
|
+
const getUnionSets = (
|
|
1073
|
+
value: UnionValue,
|
|
1074
|
+
getElements = (set: Value) => toFiniteSet(set).elements,
|
|
1075
|
+
) => {
|
|
1073
1076
|
if (!isTlcEnumerable(value.base)) {
|
|
1074
1077
|
throw new TlaEvaluationError(
|
|
1075
1078
|
`Attempted to enumerate the nonenumerable set:\n${formatUnion(value)}`,
|
|
1076
1079
|
);
|
|
1077
1080
|
}
|
|
1078
|
-
return
|
|
1081
|
+
return getElements(value.base);
|
|
1079
1082
|
};
|
|
1080
1083
|
|
|
1081
1084
|
const getUnionSet = (set: Value, index: number, union: UnionValue) => {
|
|
@@ -1111,7 +1114,7 @@ export const isEnumerable = (value: Value): boolean => {
|
|
|
1111
1114
|
case "ProductSet":
|
|
1112
1115
|
return value.factors.every(isEnumerable) || getEmptiness(value) === true;
|
|
1113
1116
|
case "Union":
|
|
1114
|
-
return isEnumerable(value.base) &&
|
|
1117
|
+
return isEnumerable(value.base) && getStreamedElements(value.base).every(isEnumerable);
|
|
1115
1118
|
case "SetOperation":
|
|
1116
1119
|
if (value.operator === "\\cup") return isEnumerable(value.left) && isEnumerable(value.right);
|
|
1117
1120
|
if (value.operator === "\\cap") return isEnumerable(value.left) || isEnumerable(value.right);
|
|
@@ -1345,8 +1348,10 @@ export const toFiniteSet = (value: Value): SetValue => {
|
|
|
1345
1348
|
// so an element that two of them share comes up once for each.
|
|
1346
1349
|
export const getStreamedElements = (value: Value): Value[] => {
|
|
1347
1350
|
if (typeof value !== "object" || finiteSets.has(value)) return toFiniteSet(value).elements;
|
|
1351
|
+
// TLC streams the sets of a UNION it hasn't enumerated, so a set that appears twice there yields
|
|
1352
|
+
// its elements twice.
|
|
1348
1353
|
if (value.kind === "Union") {
|
|
1349
|
-
return getUnionSets(value).flatMap((set, index) =>
|
|
1354
|
+
return getUnionSets(value, getStreamedElements).flatMap((set, index) =>
|
|
1350
1355
|
getStreamedElements(getUnionSet(set, index, value)),
|
|
1351
1356
|
);
|
|
1352
1357
|
}
|
|
@@ -2116,3 +2121,14 @@ export const formatValue = (value: Value, isStrict = false, isNormalized = false
|
|
|
2116
2121
|
}
|
|
2117
2122
|
}
|
|
2118
2123
|
};
|
|
2124
|
+
|
|
2125
|
+
// TLC's TLCState.toString: a line per variable, as a conjunction when there are several.
|
|
2126
|
+
export const formatState = (state: Record<string, Value>) => {
|
|
2127
|
+
const entries = Object.entries(state);
|
|
2128
|
+
return entries
|
|
2129
|
+
.map(
|
|
2130
|
+
([name, value]) =>
|
|
2131
|
+
`${entries.length === 1 ? "" : "/\\ "}${name} = ${prettyPrint(formatValue(value))}\n`,
|
|
2132
|
+
)
|
|
2133
|
+
.join("");
|
|
2134
|
+
};
|