tla-ts 0.0.10-dev.68b2c4968 → 0.0.10-dev.6b2a6741a
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/deciders.cjs +1 -1
- package/dist/deciders.js +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/prove.cjs +6 -6
- package/dist/prove.js +6 -6
- package/dist/run.cjs +7 -7
- package/dist/run.js +7 -7
- package/dist/transfer.cjs +33 -33
- package/dist/transfer.js +29 -29
- package/package.json +1 -1
- package/src/ast.ts +1 -0
- package/src/cli/xml-exporter.ts +1 -1
- package/src/codegen.ts +3 -3
- package/src/environment.ts +40 -33
- package/src/instances.ts +4 -4
- package/src/java-overrides.ts +2 -2
- package/src/levels.ts +4 -4
- package/src/obligations/index.ts +1 -1
- package/src/obligations/normalize.ts +1 -4
- package/src/obligations/printer.ts +5 -5
- package/src/parser.ts +35 -106
- package/src/prover/isabelle/isar/attrib.ts +4 -4
- package/src/prover/isabelle/pure/rewriter.ts +3 -3
- package/src/prover/isabelle/pure/term.ts +3 -3
- package/src/prover/prep/md5.ts +26 -29
- package/src/prover/smt/solver/logic-tactics.ts +2 -2
- package/src/prover/smt/solver/opt-preprocess.ts +1 -1
- package/src/prover/smt/solver/seq-decl-plugin.ts +1 -1
- package/src/prover/smt/solver/seq-rewriter.ts +1 -1
- package/src/prover/smt/solver/tactic.ts +4 -4
- package/src/prover/tlapm/cache.ts +8 -8
- package/src/resolve.ts +374 -125
- package/src/runtime.ts +1 -1
- package/src/sany/builtins.ts +10 -10
- package/src/sany/generation.ts +1 -0
- package/src/sany/generator-definitions.ts +1 -0
- package/src/sany/generator-expressions.ts +6 -3
- package/src/sany/generator-proofs.ts +4 -2
- package/src/sany/lexer.ts +3 -3
- package/src/sany/modules.ts +4 -2
- package/src/sany/selectors.ts +5 -1
- package/src/sany/xml.ts +2 -3
- package/src/subexpressions.ts +102 -18
- package/src/symmetry.ts +1 -1
- package/src/tlc/jar-data.ts +1 -3
- package/src/tlc/messages.ts +3 -3
- package/src/tlc/tlc-operators.ts +3 -1
- package/src/tlc/trace-spec.ts +3 -2
- package/src/values.ts +4 -4
package/src/runtime.ts
CHANGED
|
@@ -110,7 +110,7 @@ export const NAMED_REGISTER_PREFIX = "s:";
|
|
|
110
110
|
const POSSIBLE_REGISTER = "s:_possible";
|
|
111
111
|
|
|
112
112
|
export const getPossibleCounts = (runtime: CheckerRuntime) =>
|
|
113
|
-
createFunction([...runtime.possibleCounts].map((
|
|
113
|
+
createFunction([...runtime.possibleCounts].map((entry): [Value, Value] => [entry[0], entry[1]]));
|
|
114
114
|
|
|
115
115
|
export const getNamedRegisters = (runtime: CheckerRuntime): Map<string, Value> =>
|
|
116
116
|
runtime.possibleCounts.size === 0
|
package/src/sany/builtins.ts
CHANGED
|
@@ -98,28 +98,28 @@ export const createLevelFields = (id: number): LevelFields => ({
|
|
|
98
98
|
|
|
99
99
|
// SANY's order: OpDefNode's constructor numbers each builtin, then its phony parameters.
|
|
100
100
|
export const createBuiltins = (getId: () => number) =>
|
|
101
|
-
BUILTIN_OPERATORS.map((
|
|
101
|
+
BUILTIN_OPERATORS.map((operator): OpDefNode => {
|
|
102
102
|
const id = getId();
|
|
103
103
|
const params =
|
|
104
|
-
|
|
104
|
+
operator[1] < 0
|
|
105
105
|
? undefined
|
|
106
|
-
: Array.from({ length:
|
|
106
|
+
: Array.from({ length: operator[1] }, (_value, index): FormalParamNode => ({
|
|
107
107
|
...createLevelFields(getId()),
|
|
108
108
|
kind: "FormalParam",
|
|
109
109
|
name: `Formal_${index}`,
|
|
110
110
|
arity: 0,
|
|
111
111
|
location: undefined,
|
|
112
112
|
}));
|
|
113
|
-
const isLevelSet =
|
|
114
|
-
const isLeibnizArg =
|
|
113
|
+
const isLevelSet = operator[3] !== undefined && operator[4] !== undefined;
|
|
114
|
+
const isLeibnizArg = operator[4]?.map((weight) => weight > 0);
|
|
115
115
|
return {
|
|
116
116
|
...createLevelFields(id),
|
|
117
117
|
levelChecked: isLevelSet ? 99 : 0,
|
|
118
|
-
level,
|
|
118
|
+
level: operator[2],
|
|
119
119
|
kind: "OpDef",
|
|
120
120
|
defKind: "BuiltIn",
|
|
121
|
-
name,
|
|
122
|
-
arity,
|
|
121
|
+
name: operator[0],
|
|
122
|
+
arity: operator[1],
|
|
123
123
|
params,
|
|
124
124
|
body: undefined,
|
|
125
125
|
isLocal: false,
|
|
@@ -132,11 +132,11 @@ export const createBuiltins = (getId: () => number) =>
|
|
|
132
132
|
inRecursiveSection: false,
|
|
133
133
|
recursiveSection: -1,
|
|
134
134
|
letInLevel: 0,
|
|
135
|
-
weights:
|
|
135
|
+
weights: operator[1] < 0 ? (operator[4] ?? []).slice(0, 1) : (operator[4] ?? []),
|
|
136
136
|
isLeibnizArg: isLevelSet ? isLeibnizArg : undefined,
|
|
137
137
|
isLeibniz: isLeibnizArg?.every(Boolean) ?? true,
|
|
138
138
|
opLevelCond: undefined,
|
|
139
|
-
maxLevels:
|
|
139
|
+
maxLevels: operator[1] < 0 ? (operator[3] ?? []).slice(0, 1) : (operator[3] ?? []),
|
|
140
140
|
minMaxLevel: undefined,
|
|
141
141
|
labels: new Map(),
|
|
142
142
|
step: undefined,
|
package/src/sany/generation.ts
CHANGED
|
@@ -370,6 +370,7 @@ export const matchArguments = (
|
|
|
370
370
|
getSymbolArity(operand.op) === param.arity &&
|
|
371
371
|
!(
|
|
372
372
|
operand.op.kind === "OpDef" &&
|
|
373
|
+
// Deviation from SANY: OpDefNode#matchingOpArgOperand reads as many parameters as a RECURSIVE declaration gives and crashes when the definition has fewer.
|
|
373
374
|
(operand.op.params ?? []).some((parameter) => parameter.arity > 0)
|
|
374
375
|
);
|
|
375
376
|
if (param.arity > 0 && !isMatching) {
|
|
@@ -123,6 +123,7 @@ export const processOperator = (
|
|
|
123
123
|
const params = getParams(generation, definition, paramsSpan, true);
|
|
124
124
|
const existing = resolveSymbol(generation.contexts, name);
|
|
125
125
|
if (existing?.kind === "OpDef" && existing.inRecursive && !existing.isDefined) {
|
|
126
|
+
// Deviation from SANY: Generator#processOperator compares only the last parameter's arity with the RECURSIVE declaration's.
|
|
126
127
|
const isMatching =
|
|
127
128
|
existing.params?.length === params.length && params.every((param) => param.arity === 0);
|
|
128
129
|
if (existing.letInLevel !== generation.curLevel) {
|
|
@@ -282,10 +282,13 @@ export const generateArgument = (
|
|
|
282
282
|
argument: Expression,
|
|
283
283
|
operatorLocation: SanyLocation,
|
|
284
284
|
): ExprOrOpArgNode => {
|
|
285
|
-
const
|
|
285
|
+
const params =
|
|
286
286
|
operator.kind === "OpDef" &&
|
|
287
|
-
(operator.defKind === "UserDefined" || operator.defKind === "ModuleInstance")
|
|
288
|
-
|
|
287
|
+
(operator.defKind === "UserDefined" || operator.defKind === "ModuleInstance")
|
|
288
|
+
? (operator.params ?? [])
|
|
289
|
+
: undefined;
|
|
290
|
+
if (params !== undefined && params.length <= index) return createNullNode(generation);
|
|
291
|
+
const expectedArity = params?.[index]?.arity ?? 0;
|
|
289
292
|
if (expectedArity === 0) return generateExpression(generation, argument);
|
|
290
293
|
const span = getExpressionSpan(generation.file, argument);
|
|
291
294
|
const location = getSpanLocation(generation.file, span);
|
|
@@ -108,9 +108,11 @@ const getFactModules = (generation: ModuleGeneration, fact: Fact & { kind: "Modu
|
|
|
108
108
|
const generateFacts = (generation: ModuleGeneration, facts: Fact[]) =>
|
|
109
109
|
facts.flatMap((fact): FactNode[] => {
|
|
110
110
|
if (fact.kind === "ModuleFact") return getFactModules(generation, fact);
|
|
111
|
-
const
|
|
111
|
+
const reference: Expression =
|
|
112
|
+
fact.kind === "ExceptAt" ? { kind: "Identifier", name: "@", location: fact.location } : fact;
|
|
113
|
+
const items = getSelectorItems(reference);
|
|
112
114
|
if (items === undefined || !isGeneralId(items)) return [generateExpression(generation, fact)];
|
|
113
|
-
const node = generateSelector(generation,
|
|
115
|
+
const node = generateSelector(generation, reference, 0, true, false);
|
|
114
116
|
if (node.kind === "ThmOrAssumpDef") throw new TlaSyntaxError("Expected a fact");
|
|
115
117
|
return [node];
|
|
116
118
|
});
|
package/src/sany/lexer.ts
CHANGED
|
@@ -302,9 +302,9 @@ const getLongerMatch = (best: TokenMatch, match: TokenMatch) =>
|
|
|
302
302
|
|
|
303
303
|
const matchPatterns = (patterns: [string, RegExp[]][], source: string, offset: number) =>
|
|
304
304
|
patterns
|
|
305
|
-
.map((
|
|
306
|
-
kind: getKind(
|
|
307
|
-
length: Math.max(...
|
|
305
|
+
.map((pattern) => ({
|
|
306
|
+
kind: getKind(pattern[0]),
|
|
307
|
+
length: Math.max(...pattern[1].map((regex) => getMatchLength(regex, source, offset))),
|
|
308
308
|
}))
|
|
309
309
|
.reduce(getLongerMatch, { kind: -1, length: 0 });
|
|
310
310
|
|
package/src/sany/modules.ts
CHANGED
|
@@ -1289,8 +1289,10 @@ _TLCTrace ==
|
|
|
1289
1289
|
]);
|
|
1290
1290
|
|
|
1291
1291
|
export const SANY_174_STANDARD_MODULES = new Map([
|
|
1292
|
-
...[...SANY_STANDARD_MODULES].filter((
|
|
1293
|
-
["FiniteSets", "Integers", "Naturals", "RealTime", "Reals", "Sequences", "TLC"].includes(
|
|
1292
|
+
...[...SANY_STANDARD_MODULES].filter((entry) =>
|
|
1293
|
+
["FiniteSets", "Integers", "Naturals", "RealTime", "Reals", "Sequences", "TLC"].includes(
|
|
1294
|
+
entry[0],
|
|
1295
|
+
),
|
|
1294
1296
|
),
|
|
1295
1297
|
["Bags", BAGS.replace("\nLOCAL INSTANCE Naturals\n", "\nEXTENDS TLC\nLOCAL INSTANCE Naturals\n")],
|
|
1296
1298
|
[
|
package/src/sany/selectors.ts
CHANGED
|
@@ -414,7 +414,11 @@ export const createSelectorResolver =
|
|
|
414
414
|
const number = getArgNumber(item.op, operator.arity);
|
|
415
415
|
if (number === -1) return addNonexistentError();
|
|
416
416
|
walk.node = operands[number - 1];
|
|
417
|
-
} else if (
|
|
417
|
+
} else if (
|
|
418
|
+
operator.kind === "OpDef" &&
|
|
419
|
+
operator.defKind === "BuiltIn" &&
|
|
420
|
+
node.nullKind !== "null"
|
|
421
|
+
) {
|
|
418
422
|
if (operator.name === "$RcdConstructor" || operator.name === "$SetOfRcds") {
|
|
419
423
|
if (operandNumber === -1) return addNonexistentError();
|
|
420
424
|
const pair = operands[operandNumber - 1];
|
package/src/sany/xml.ts
CHANGED
|
@@ -894,10 +894,9 @@ const exportSpecification = (
|
|
|
894
894
|
"context",
|
|
895
895
|
[...entries.entries()]
|
|
896
896
|
.toSorted(
|
|
897
|
-
([
|
|
898
|
-
getHashMapBucket(first, capacity) - getHashMapBucket(second, capacity),
|
|
897
|
+
(left, right) => getHashMapBucket(left[0], capacity) - getHashMapBucket(right[0], capacity),
|
|
899
898
|
)
|
|
900
|
-
.map((
|
|
899
|
+
.map((pair) => createElement("entry", [createText("UID", pair[0]), pair[1]])),
|
|
901
900
|
);
|
|
902
901
|
return createElement("modules", [
|
|
903
902
|
createText("RootModule", root.name),
|
package/src/subexpressions.ts
CHANGED
|
@@ -23,12 +23,14 @@ import {
|
|
|
23
23
|
getNameSelectors,
|
|
24
24
|
getOperandIndex,
|
|
25
25
|
getOperands,
|
|
26
|
+
getParamArities,
|
|
26
27
|
isBefore,
|
|
27
28
|
LOCAL_RESOLUTION,
|
|
28
29
|
nullSelections,
|
|
29
30
|
selectionErrors,
|
|
30
31
|
selections,
|
|
31
32
|
type NullSelection,
|
|
33
|
+
type SelectionArguments,
|
|
32
34
|
} from "./resolve";
|
|
33
35
|
|
|
34
36
|
type Lookup = (name: string) => Definition | undefined;
|
|
@@ -70,6 +72,12 @@ const getSelectorName = (selector: Selector) => {
|
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
74
|
|
|
75
|
+
const getExpressionArguments = (
|
|
76
|
+
operator: string,
|
|
77
|
+
range: SourceRange | undefined,
|
|
78
|
+
args: Expression[],
|
|
79
|
+
): SelectionArguments => ({ operator, range, args, params: args.map(() => 0) });
|
|
80
|
+
|
|
73
81
|
const createError = (message: string, location: SourceLocation) =>
|
|
74
82
|
new TlaSyntaxError(`${message} at line ${location.line}, column ${location.column}`);
|
|
75
83
|
|
|
@@ -173,6 +181,7 @@ const applyDefinition = (definition: Definition, selection: Selection) => {
|
|
|
173
181
|
const selectSubexpression = (
|
|
174
182
|
selectors: Selector[],
|
|
175
183
|
lookup: Lookup,
|
|
184
|
+
isGoal: (name: string) => boolean,
|
|
176
185
|
reference: Expression & SelectingName,
|
|
177
186
|
isOperator: boolean,
|
|
178
187
|
): Expression => {
|
|
@@ -182,6 +191,7 @@ const selectSubexpression = (
|
|
|
182
191
|
let current: Expression | undefined;
|
|
183
192
|
let isFailed = false;
|
|
184
193
|
const nulls: NullSelection[] = [];
|
|
194
|
+
const applications: SelectionArguments[] = [];
|
|
185
195
|
const checkNull = (node: Expression | undefined, message: string) => {
|
|
186
196
|
const range = reference.selectorRanges?.[selectorIndex];
|
|
187
197
|
if (node && range) nulls.push({ node, error: { location: formatRange(range), message } });
|
|
@@ -190,9 +200,7 @@ const selectSubexpression = (
|
|
|
190
200
|
const report = (range: SourceRange | undefined, message: string) => {
|
|
191
201
|
if (!range) throw createError(message, location);
|
|
192
202
|
selectionErrors.set(reference, {
|
|
193
|
-
|
|
194
|
-
.slice(0, selectorIndex)
|
|
195
|
-
.flatMap((selector) => ("args" in selector ? selector.args : [])),
|
|
203
|
+
applications,
|
|
196
204
|
error: { location: formatRange(range), message },
|
|
197
205
|
});
|
|
198
206
|
isFailed = true;
|
|
@@ -235,6 +243,24 @@ const selectSubexpression = (
|
|
|
235
243
|
);
|
|
236
244
|
}
|
|
237
245
|
if (isLast) return { definition, args: found.args };
|
|
246
|
+
applications.push({
|
|
247
|
+
operator: found.name,
|
|
248
|
+
range: reference.selectorRanges?.[selectorIndex],
|
|
249
|
+
args: found.args,
|
|
250
|
+
params: getParamArities(definition),
|
|
251
|
+
});
|
|
252
|
+
const range = definition.location.range;
|
|
253
|
+
if (
|
|
254
|
+
definition.isRecursive &&
|
|
255
|
+
range &&
|
|
256
|
+
range.module === location.range?.module &&
|
|
257
|
+
isBefore(location, range.end)
|
|
258
|
+
) {
|
|
259
|
+
return report(
|
|
260
|
+
reference.selectorRanges?.[selectorIndex],
|
|
261
|
+
`Subexpression of \`${found.name}' used inside the operator's definition.`,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
238
264
|
if (definition.kind !== "Operator") {
|
|
239
265
|
throw createError(`Cannot select a subexpression of ${definition.name}`, location);
|
|
240
266
|
}
|
|
@@ -259,6 +285,7 @@ const selectSubexpression = (
|
|
|
259
285
|
selection.lets.push(...found.lets);
|
|
260
286
|
selection.params.push(...params.map((name) => ({ name, arity: 0 })));
|
|
261
287
|
selection.args.push(...selector.args);
|
|
288
|
+
applications.push(getExpressionArguments(selector.name, range, selector.args));
|
|
262
289
|
current = found.label.body;
|
|
263
290
|
selectorIndex++;
|
|
264
291
|
}
|
|
@@ -267,14 +294,42 @@ const selectSubexpression = (
|
|
|
267
294
|
const selectOperand = (selector: Selector) => {
|
|
268
295
|
if (!current) throw createError("Subexpression selection failed", location);
|
|
269
296
|
if (selector.kind === "Colon") return;
|
|
297
|
+
const range = reference.selectorRanges?.[selectorIndex];
|
|
298
|
+
const currentRange = current.location.range;
|
|
299
|
+
if (
|
|
300
|
+
(current.kind === "Subexpression" ||
|
|
301
|
+
(current.kind === "Identifier" && current.name.includes("!")) ||
|
|
302
|
+
(current.kind === "Apply" && current.operator.includes("!"))) &&
|
|
303
|
+
(currentRange?.module !== location.range?.module || isBefore(current.location, location))
|
|
304
|
+
) {
|
|
305
|
+
const selected = resolveSubexpressions(current, lookup, isGoal);
|
|
306
|
+
if (selectionErrors.has(selected)) {
|
|
307
|
+
report(
|
|
308
|
+
range,
|
|
309
|
+
`Choosing operand \`${getSelectorName(selector)}' of subexpression with no operands.`,
|
|
310
|
+
);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (selections.has(selected) && selected.kind !== "Lambda") {
|
|
314
|
+
current =
|
|
315
|
+
selected.kind === "Let" &&
|
|
316
|
+
selected.body.kind === "Apply" &&
|
|
317
|
+
selected.body.operator === SELECTION_NAME
|
|
318
|
+
? selected.body
|
|
319
|
+
: // SANY wraps a selection without parameters in $Nop, whose only operand is the selection.
|
|
320
|
+
{ kind: "Tuple", elements: [selected], location: selected.location };
|
|
321
|
+
}
|
|
322
|
+
}
|
|
270
323
|
if (current.kind === "Label") {
|
|
271
324
|
current = current.body;
|
|
272
325
|
selectOperand(selector);
|
|
273
326
|
return;
|
|
274
327
|
}
|
|
328
|
+
const nonexistent = `Nonexistent operand specified by \`${getSelectorName(selector)}'.`;
|
|
275
329
|
if (current.kind === "Let") {
|
|
276
330
|
if (selector.kind !== "Operand" || getOperandIndex(selector.operand, 1) !== 0) {
|
|
277
|
-
|
|
331
|
+
report(range, "A LET/IN expression has only one operand.");
|
|
332
|
+
return;
|
|
278
333
|
}
|
|
279
334
|
selection.lets.push(current.definitions);
|
|
280
335
|
current = current.body;
|
|
@@ -283,38 +338,61 @@ const selectSubexpression = (
|
|
|
283
338
|
const binder = getBinder(current);
|
|
284
339
|
if (binder && (selector.kind === "Bound" || selector.kind === "At")) {
|
|
285
340
|
selection.params.push(...binder.names.map((name) => ({ name, arity: 0 })));
|
|
286
|
-
if (selector.kind === "Bound")
|
|
341
|
+
if (selector.kind === "Bound") {
|
|
342
|
+
selection.args.push(...selector.args);
|
|
343
|
+
applications.push(getExpressionArguments("", range, selector.args));
|
|
344
|
+
}
|
|
287
345
|
current = binder.body;
|
|
288
346
|
return;
|
|
289
347
|
}
|
|
290
|
-
if (current.kind === "Case"
|
|
348
|
+
if (current.kind === "Case") {
|
|
291
349
|
const arms = [
|
|
292
350
|
...current.arms,
|
|
293
351
|
...(current.other ? [{ condition: undefined, body: current.other }] : []),
|
|
294
352
|
];
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
353
|
+
if (selectorIndex === selectors.length - 1) {
|
|
354
|
+
report(range, "Subexpression of CASE must have form !i!j.");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const arm =
|
|
358
|
+
selector.kind === "Operand"
|
|
359
|
+
? arms[getOperandIndex(selector.operand, arms.length)]
|
|
360
|
+
: undefined;
|
|
361
|
+
if (!arm) {
|
|
362
|
+
report(range, nonexistent);
|
|
363
|
+
return;
|
|
299
364
|
}
|
|
300
365
|
selectorIndex++;
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
|
|
366
|
+
const next = selectors[selectorIndex];
|
|
367
|
+
const part = next.kind === "Operand" ? getOperandIndex(next.operand, 2) : -1;
|
|
368
|
+
const nextRange = reference.selectorRanges?.[selectorIndex];
|
|
369
|
+
if (part === -1) {
|
|
370
|
+
report(
|
|
371
|
+
nextRange,
|
|
372
|
+
"Second selector for CASE subexpression must specify one of two operands.",
|
|
373
|
+
);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const chosen = part === 0 ? arm.condition : arm.body;
|
|
377
|
+
if (!chosen) {
|
|
378
|
+
report(nextRange, "Selecting OTHER in a CASE statement.");
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
304
381
|
current = chosen;
|
|
305
382
|
return;
|
|
306
383
|
}
|
|
307
|
-
if (selector.kind !== "Operand")
|
|
308
|
-
throw createError("Unexpected subexpression selector", location);
|
|
309
384
|
const operands = binder ? binder.sets : getOperands(current);
|
|
310
|
-
const range = reference.selectorRanges?.[selectorIndex];
|
|
311
385
|
if (!operands && current.kind !== "Identifier") {
|
|
312
386
|
report(range, "Selecting subexpression of expression that has none.");
|
|
313
387
|
return;
|
|
314
388
|
}
|
|
389
|
+
if (selector.kind !== "Operand") {
|
|
390
|
+
report(range, nonexistent);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
315
393
|
const operand = operands?.[getOperandIndex(selector.operand, operands.length)];
|
|
316
394
|
if (!operand) {
|
|
317
|
-
report(range,
|
|
395
|
+
report(range, nonexistent);
|
|
318
396
|
return;
|
|
319
397
|
}
|
|
320
398
|
current = operand;
|
|
@@ -358,6 +436,12 @@ const selectSubexpression = (
|
|
|
358
436
|
}
|
|
359
437
|
if (isFailed) return reference;
|
|
360
438
|
if (!current) throw createError("Subexpression selection failed", location);
|
|
439
|
+
const params = selection.params.length;
|
|
440
|
+
const args = selection.args.length;
|
|
441
|
+
if (params !== args && (!isOperator || args > 0)) {
|
|
442
|
+
report(location.range, `Expected ${params} arguments but found ${args}.`);
|
|
443
|
+
return reference;
|
|
444
|
+
}
|
|
361
445
|
const selected = createApplication(selection, current);
|
|
362
446
|
nullSelections.set(selected, nulls);
|
|
363
447
|
return selected;
|
|
@@ -425,7 +509,7 @@ const resolveSubexpressions = (
|
|
|
425
509
|
const first = selectors?.[0];
|
|
426
510
|
if (!selectors || (first?.kind === "Name" && isGoal(first.name))) return mapped;
|
|
427
511
|
if (first?.kind === "Name" && selectors[1].kind !== "Name" && !lookup(first.name)) return mapped;
|
|
428
|
-
const selected = selectSubexpression(selectors, lookup, mapped, isOperator);
|
|
512
|
+
const selected = selectSubexpression(selectors, lookup, isGoal, mapped, isOperator);
|
|
429
513
|
if (selected !== mapped) selections.add(selected);
|
|
430
514
|
return selected;
|
|
431
515
|
};
|
package/src/symmetry.ts
CHANGED
package/src/tlc/jar-data.ts
CHANGED
|
@@ -144,9 +144,7 @@ export const SANY_OPERATOR_SYNONYMS = [
|
|
|
144
144
|
];
|
|
145
145
|
|
|
146
146
|
const SYNONYMS = new Map(
|
|
147
|
-
SANY_OPERATOR_SYNONYMS.flatMap(([
|
|
148
|
-
synonyms.map((synonym) => [synonym, canonical]),
|
|
149
|
-
),
|
|
147
|
+
SANY_OPERATOR_SYNONYMS.flatMap((names) => names.slice(1).map((synonym) => [synonym, names[0]])),
|
|
150
148
|
);
|
|
151
149
|
|
|
152
150
|
export const resolveSynonym = (name: string) =>
|
package/src/tlc/messages.ts
CHANGED
|
@@ -345,14 +345,14 @@ interface CodedMessage {
|
|
|
345
345
|
let codedMessagePatterns: { pattern: RegExp; message: CodedMessage }[] | undefined;
|
|
346
346
|
|
|
347
347
|
const getCodedMessagePatterns = () =>
|
|
348
|
-
(codedMessagePatterns ??= CODED_MESSAGES.map((
|
|
348
|
+
(codedMessagePatterns ??= CODED_MESSAGES.map((codedMessage) => ({
|
|
349
349
|
pattern: new RegExp(
|
|
350
|
-
`^${
|
|
350
|
+
`^${codedMessage[1]
|
|
351
351
|
.split(/%\d+%/)
|
|
352
352
|
.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
353
353
|
.join("[\\s\\S]*")}$`,
|
|
354
354
|
),
|
|
355
|
-
message: { code, isEvalException },
|
|
355
|
+
message: { code: codedMessage[0], isEvalException: codedMessage[2] },
|
|
356
356
|
})));
|
|
357
357
|
|
|
358
358
|
const UNCODED_MESSAGE_PATTERN =
|
package/src/tlc/tlc-operators.ts
CHANGED
|
@@ -43,7 +43,9 @@ const formatCalendarVersion = (date: Date) =>
|
|
|
43
43
|
`${date.getUTCFullYear()}.${zeroPad(date.getUTCMonth() + 1)}.${zeroPad(date.getUTCDate())}.${zeroPad(date.getUTCHours())}${zeroPad(date.getUTCMinutes())}${zeroPad(date.getUTCSeconds())}`;
|
|
44
44
|
|
|
45
45
|
const getRegisterFunction = <Key extends Value>(registers: Map<Key, Value>) =>
|
|
46
|
-
createFunction(
|
|
46
|
+
createFunction(
|
|
47
|
+
[...registers].map((entry): [Value, Value] => [entry[0], createTuple([entry[1]])]),
|
|
48
|
+
);
|
|
47
49
|
|
|
48
50
|
const createTlcRecord = (fields: [string, Value][]) =>
|
|
49
51
|
setFunctionClass(createWrittenFunction(fields), "record");
|
package/src/tlc/trace-spec.ts
CHANGED
|
@@ -57,7 +57,7 @@ const getConjunction = (state: [string, string][], prefix?: string) =>
|
|
|
57
57
|
indent(
|
|
58
58
|
[
|
|
59
59
|
...(prefix === undefined ? [] : [prefix]),
|
|
60
|
-
...state.map((
|
|
60
|
+
...state.map((assignment) => `${assignment[0]} = (${assignment[1]})`),
|
|
61
61
|
].join("\n/\\\n"),
|
|
62
62
|
2,
|
|
63
63
|
);
|
|
@@ -190,7 +190,8 @@ ${lassoStep}${variables
|
|
|
190
190
|
const deserializedTrace = `\n${getPrimer(traceModule, getHashOrder(["IOUtils", ...constantModules, specName]))}trace == IODeserialize("${input.module}.bin", TRUE)\n\n${CLOSING_TAG}`;
|
|
191
191
|
const traceFunction = `${INDENT}<<\n${states
|
|
192
192
|
.map(
|
|
193
|
-
(state) =>
|
|
193
|
+
(state) =>
|
|
194
|
+
`${INDENT}([${state.map((assignment) => `${assignment[0]} |-> ${assignment[1]}`).join(",")}])`,
|
|
194
195
|
)
|
|
195
196
|
.join(",\n")}\n${INDENT}>>${SEPARATOR}\n`;
|
|
196
197
|
|
package/src/values.ts
CHANGED
|
@@ -3111,10 +3111,10 @@ export const formatState = (state: Record<string, Value>, previous?: Record<stri
|
|
|
3111
3111
|
);
|
|
3112
3112
|
}
|
|
3113
3113
|
return entries
|
|
3114
|
-
.filter((
|
|
3115
|
-
.filter((
|
|
3116
|
-
.map((
|
|
3117
|
-
const text = formatJava(format, [
|
|
3114
|
+
.filter((entry) => !(isFormatted && entry[0] === "_format"))
|
|
3115
|
+
.filter((entry) => !previous || !isUnchanged(previous[entry[0]], entry[1]))
|
|
3116
|
+
.map((entry) => {
|
|
3117
|
+
const text = formatJava(format, [entry[0], prettyPrint(formatValue(entry[1]))]);
|
|
3118
3118
|
if (text === undefined) {
|
|
3119
3119
|
throw new TlaAliasFormatError(
|
|
3120
3120
|
`The _format field of the ALIAS ${alias} is ${formatValue(format)}, but it must format two strings, the name and the value of a field.`,
|