tla-ts 0.0.3-dev.bffbba3 → 0.0.3-dev.c949d82
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.d.cts +32 -22
- package/dist/index.d.ts +32 -22
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +1 -1
- package/dist/run-cli.cjs +3 -2
- package/dist/run-cli.js +19 -18
- package/dist/transfer.cjs +30 -21
- package/dist/transfer.js +30 -21
- package/package.json +1 -1
- package/src/ast.ts +2 -0
- package/src/check.ts +109 -29
- package/src/codegen.ts +6 -3
- package/src/config.ts +224 -170
- package/src/environment.ts +47 -18
- package/src/errors.ts +56 -1
- package/src/evaluate.ts +43 -12
- package/src/exit-codes.ts +22 -3
- package/src/live-check.ts +129 -49
- package/src/liveness.ts +63 -9
- package/src/parallel-worker.ts +2 -2
- package/src/parallel.ts +2 -2
- package/src/parser.ts +17 -9
- package/src/resolve.ts +46 -16
- package/src/run-cli.ts +27 -8
- package/src/spec-description.ts +1 -2
- package/src/successors.ts +25 -15
- package/src/symmetry.ts +16 -6
- package/src/tableau.ts +1 -1
- package/src/tlc-module.ts +6 -6
- package/src/tlc-modules.ts +4 -0
- package/src/tlc-order.ts +8 -4
- package/src/tlc-random.ts +9 -6
- package/src/tlc-summary.ts +20 -5
- package/src/values.ts +62 -9
package/src/values.ts
CHANGED
|
@@ -1224,9 +1224,7 @@ const enumerateSet = (value: Value): Value[] => {
|
|
|
1224
1224
|
if (isOverriddenSet(value.base)) getCardinality(value.base);
|
|
1225
1225
|
const base = toFiniteSet(value.base).elements;
|
|
1226
1226
|
if (base.length > MAXIMUM_ENUMERATED_SUBSET_BASE) {
|
|
1227
|
-
throw new TlaEvaluationError(
|
|
1228
|
-
`SUBSET of a set with ${base.length} elements is too large to enumerate`,
|
|
1229
|
-
);
|
|
1227
|
+
throw new TlaEvaluationError(describeOverflow(value));
|
|
1230
1228
|
}
|
|
1231
1229
|
return getSortedSubsets(base);
|
|
1232
1230
|
}
|
|
@@ -1752,10 +1750,61 @@ export const markLambdaFunction = <FunctionLike extends FunctionValue | LazyFunc
|
|
|
1752
1750
|
return functionValue;
|
|
1753
1751
|
};
|
|
1754
1752
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1753
|
+
// TLC applies a tuple, a record and a function over an interval with their own classes, and each
|
|
1754
|
+
// reports a missing argument in its own words.
|
|
1755
|
+
const getFunctionClass = (functionValue: FunctionValue) => {
|
|
1756
|
+
const domain = functionValue.domain;
|
|
1757
|
+
if (domain.length === 0) return lambdaFunctions.has(functionValue) ? "FcnRcdValue" : "TupleValue";
|
|
1758
|
+
if (domain === intervalDomains[domain.length]) return "TupleValue";
|
|
1759
|
+
if (intervalArrays.has(domain)) return "IntervalFcnRcdValue";
|
|
1760
|
+
return domain.every((key) => typeof key === "string") ? "RecordValue" : "FcnRcdValue";
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
const describeNotInDomain = (functionValue: FunctionValue, argument: Value) =>
|
|
1764
|
+
`Attempted to apply function:\n${prettyPrint(formatValue(functionValue))}\nto argument ${prettyPrint(formatValue(argument))}, which is not in the domain of the function.`;
|
|
1765
|
+
|
|
1766
|
+
const describeNonIntegerArgument = (argument: Value) =>
|
|
1767
|
+
`Attempted to apply function with integer domain to the non-integer argument ${prettyPrint(formatValue(argument))}`;
|
|
1768
|
+
|
|
1769
|
+
const describeMissingArgument = (
|
|
1770
|
+
functionValue: FunctionValue | LazyFunctionValue,
|
|
1771
|
+
argument: Value,
|
|
1772
|
+
) => {
|
|
1773
|
+
if (lambdaFunctions.has(functionValue) || functionValue.kind === "LazyFunction")
|
|
1774
|
+
return `In applying the function\n${prettyPrint(formatValue(functionValue))},\nthe first argument is:\n${prettyPrint(formatValue(argument))}\nwhich is not in its domain.\n`;
|
|
1775
|
+
const functionClass = getFunctionClass(functionValue);
|
|
1776
|
+
if (functionClass === "TupleValue")
|
|
1777
|
+
return typeof argument === "number"
|
|
1778
|
+
? `Attempted to access index ${argument} of tuple\n${prettyPrint(formatValue(functionValue))}\nwhich is out of bounds.`
|
|
1779
|
+
: `Attempted to access tuple at a non integral index: ${prettyPrint(formatValue(argument))}`;
|
|
1780
|
+
if (functionClass === "RecordValue")
|
|
1781
|
+
return typeof argument === "string"
|
|
1782
|
+
? `Attempted to access nonexistent field '${argument}' of record\n${prettyPrint(formatValue(functionValue))}`
|
|
1783
|
+
: `Attempted to access record by a non-string argument: ${prettyPrint(formatValue(argument))}`;
|
|
1784
|
+
return functionClass === "IntervalFcnRcdValue" && typeof argument !== "number"
|
|
1785
|
+
? describeNonIntegerArgument(argument)
|
|
1786
|
+
: describeNotInDomain(functionValue, argument);
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
// TLC selects a field of a value that isn't a record from the function the value converts to,
|
|
1790
|
+
// which keeps a tuple's domain as an interval.
|
|
1791
|
+
export const describeMissingField = (functionValue: FunctionValue, field: string) =>
|
|
1792
|
+
getFunctionClass(functionValue) === "FcnRcdValue"
|
|
1793
|
+
? describeNotInDomain(functionValue, field)
|
|
1794
|
+
: describeNonIntegerArgument(field);
|
|
1795
|
+
|
|
1796
|
+
export const isRecordValue = (functionValue: FunctionValue) =>
|
|
1797
|
+
getFunctionClass(functionValue) === "RecordValue";
|
|
1798
|
+
|
|
1799
|
+
// TLC checks the type of an argument to a tuple or a record before it looks the argument up, so
|
|
1800
|
+
// it never compares the argument with a key of another type.
|
|
1801
|
+
const isForeignKey = (domain: Value[], argument: Value) => {
|
|
1802
|
+
const first = domain[0];
|
|
1803
|
+
return typeof first === "number"
|
|
1804
|
+
? typeof argument !== "number" &&
|
|
1805
|
+
(domain === intervalDomains[domain.length] || intervalArrays.has(domain))
|
|
1806
|
+
: typeof first === "string" && typeof argument !== "string";
|
|
1807
|
+
};
|
|
1759
1808
|
|
|
1760
1809
|
const findKeyIndex = (domain: Value[], argument: Value) => {
|
|
1761
1810
|
const first = domain[0];
|
|
@@ -1774,6 +1823,7 @@ export const applyFunction = (
|
|
|
1774
1823
|
functionValue: Value,
|
|
1775
1824
|
argument: Value,
|
|
1776
1825
|
describeMissing?: (functionValue: FunctionValue) => string,
|
|
1826
|
+
describeNonFunction?: (value: Value) => string,
|
|
1777
1827
|
): Value => {
|
|
1778
1828
|
if (typeof functionValue === "object" && functionValue.kind === "LazyFunction") {
|
|
1779
1829
|
if (!isElementOf(argument, functionValue.domain)) {
|
|
@@ -1787,10 +1837,13 @@ export const applyFunction = (
|
|
|
1787
1837
|
}
|
|
1788
1838
|
if (typeof functionValue !== "object" || functionValue.kind !== "Function") {
|
|
1789
1839
|
throw new TlaEvaluationError(
|
|
1790
|
-
|
|
1840
|
+
describeNonFunction?.(functionValue) ??
|
|
1841
|
+
`Attempted to apply ${formatValue(functionValue)}, which is not a function`,
|
|
1791
1842
|
);
|
|
1792
1843
|
}
|
|
1793
|
-
const position =
|
|
1844
|
+
const position = isForeignKey(functionValue.domain, argument)
|
|
1845
|
+
? -1
|
|
1846
|
+
: findKeyIndex(functionValue.domain, argument);
|
|
1794
1847
|
if (position === -1) {
|
|
1795
1848
|
throw new TlaEvaluationError(
|
|
1796
1849
|
describeMissing?.(functionValue) ?? describeMissingArgument(functionValue, argument),
|