tla-ts 0.0.3-dev.d34b19a → 0.0.3-dev.e5b05b9

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.
Files changed (55) hide show
  1. package/README.md +5 -1
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +71 -22
  4. package/dist/index.d.ts +71 -22
  5. package/dist/index.js +1 -1
  6. package/dist/parallel-worker.cjs +1 -1
  7. package/dist/parallel-worker.js +2 -2
  8. package/dist/parallel.cjs +1 -1
  9. package/dist/parallel.js +2 -2
  10. package/dist/run-cli.cjs +20 -17
  11. package/dist/run-cli.js +22 -19
  12. package/dist/transfer.cjs +45 -15
  13. package/dist/transfer.js +45 -15
  14. package/package.json +1 -1
  15. package/src/ast.ts +121 -4
  16. package/src/builtins.ts +9 -3
  17. package/src/check.ts +514 -99
  18. package/src/cli-options.ts +11 -5
  19. package/src/codegen.ts +15 -22
  20. package/src/config.ts +224 -170
  21. package/src/dependencies.ts +2 -2
  22. package/src/environment.ts +334 -96
  23. package/src/errors.ts +109 -3
  24. package/src/evaluate.ts +255 -159
  25. package/src/exit-codes.ts +39 -42
  26. package/src/fingerprints.ts +2 -1
  27. package/src/instances.ts +16 -15
  28. package/src/levels.ts +185 -44
  29. package/src/live-check.ts +772 -0
  30. package/src/liveness.ts +120 -543
  31. package/src/parallel-worker.ts +2 -2
  32. package/src/parallel.ts +20 -4
  33. package/src/parser.ts +182 -53
  34. package/src/resolve.ts +1302 -412
  35. package/src/run-cli.ts +115 -20
  36. package/src/runtime.ts +3 -1
  37. package/src/sany-lexer.ts +615 -0
  38. package/src/sany-parse-error.ts +3143 -0
  39. package/src/spec-description.ts +19 -8
  40. package/src/standard-modules.ts +54 -45
  41. package/src/standard-ranges.ts +116 -0
  42. package/src/state-graph.ts +157 -0
  43. package/src/subexpressions.ts +124 -159
  44. package/src/substitution-levels.ts +38 -17
  45. package/src/successors.ts +183 -39
  46. package/src/symmetry.ts +16 -6
  47. package/src/tableau.ts +51 -24
  48. package/src/tlc-ext.ts +29 -12
  49. package/src/tlc-module.ts +14 -33
  50. package/src/tlc-modules.ts +4 -0
  51. package/src/tlc-order.ts +25 -7
  52. package/src/tlc-random.ts +9 -6
  53. package/src/tlc-summary.ts +20 -5
  54. package/src/value-sources.ts +29 -0
  55. package/src/values.ts +242 -61
@@ -1,17 +1,26 @@
1
- import type {
2
- Bound,
3
- Definition,
4
- Expression,
5
- Instance,
6
- Module,
7
- OperatorParam,
8
- Selector,
9
- SourceLocation,
1
+ import {
2
+ getChildren,
3
+ type Definition,
4
+ type Expression,
5
+ type Instance,
6
+ type Module,
7
+ type OperatorParam,
8
+ type Selector,
9
+ type SourceLocation,
10
+ type SourceRange,
10
11
  } from "./ast";
11
- import { TlaSyntaxError } from "./errors";
12
- import { getChildren } from "./evaluate";
12
+ import { formatRange, TlaSyntaxError } from "./errors";
13
13
  import { getSourceName, mapChildren, mapDefinition } from "./instances";
14
- import { getArity, getBoundNames, getPatternNames, LOCAL_RESOLUTION } from "./resolve";
14
+ import {
15
+ getArity,
16
+ getBinder,
17
+ getNameSelectors,
18
+ getOperandIndex,
19
+ getOperands,
20
+ LOCAL_RESOLUTION,
21
+ selectionErrors,
22
+ selections,
23
+ } from "./resolve";
15
24
 
16
25
  type Lookup = (name: string) => Definition | undefined;
17
26
 
@@ -27,114 +36,19 @@ interface Selection {
27
36
  location: SourceLocation;
28
37
  }
29
38
 
39
+ // A name that selects a subexpression, with the range of each part and of the arguments of each
40
+ // part, where SANY reports an error in selecting that part.
41
+ interface SelectingName {
42
+ location: SourceLocation;
43
+ selectorRanges?: SourceRange[];
44
+ argumentRanges?: (SourceRange | undefined)[];
45
+ }
46
+
30
47
  const SELECTION_NAME = "$subexpression";
31
48
 
32
49
  const createError = (message: string, location: SourceLocation) =>
33
50
  new TlaSyntaxError(`${message} at line ${location.line}, column ${location.column}`);
34
51
 
35
- const getBoundSets = (bounds: Bound[]) =>
36
- bounds
37
- .filter((bound, index) => index === 0 || bounds[index - 1].set !== bound.set)
38
- .map((bound) => bound.set);
39
-
40
- const getOperandIndex = (operand: number | "<<" | ">>", count: number) => {
41
- if (typeof operand === "number") return operand >= 1 && operand <= count ? operand - 1 : -1;
42
- if (operand === "<<") return count > 0 ? 0 : -1;
43
- return count === 2 ? 1 : -1;
44
- };
45
-
46
- const getOperands = (expression: Expression): Expression[] | undefined => {
47
- switch (expression.kind) {
48
- case "Apply":
49
- return expression.args;
50
- case "And":
51
- case "Or":
52
- return expression.operands;
53
- case "If":
54
- return [expression.condition, expression.consequent, expression.alternative];
55
- case "Tuple":
56
- case "SetEnumeration":
57
- return expression.elements;
58
- case "Record":
59
- case "RecordSet":
60
- return expression.fields.map((field) => field.value);
61
- case "FunctionApplication":
62
- return [
63
- expression.function,
64
- expression.args.length === 1
65
- ? expression.args[0]
66
- : { kind: "Tuple", elements: expression.args, location: expression.location },
67
- ];
68
- case "FieldAccess":
69
- return [
70
- expression.record,
71
- { kind: "String", value: expression.field, location: expression.location },
72
- ];
73
- case "Prime":
74
- case "Unchanged":
75
- case "Enabled":
76
- case "Always":
77
- case "Eventually":
78
- return [expression.expression];
79
- case "BoxAction":
80
- case "AngleAction":
81
- return [expression.action, expression.subscript];
82
- case "WeakFairness":
83
- case "StrongFairness":
84
- return [expression.subscript, expression.action];
85
- case "FunctionSet":
86
- return [expression.domain, expression.range];
87
- case "Product":
88
- return expression.factors;
89
- case "Except":
90
- return [expression.function];
91
- default:
92
- return undefined;
93
- }
94
- };
95
-
96
- const getBinder = (
97
- expression: Expression,
98
- ): { names: string[]; body: Expression; sets: Expression[] } | undefined => {
99
- switch (expression.kind) {
100
- case "Forall":
101
- case "Exists":
102
- case "FunctionConstruction":
103
- return {
104
- names: getBoundNames(expression.bounds),
105
- body: expression.body,
106
- sets: getBoundSets(expression.bounds),
107
- };
108
- case "SetMap":
109
- return {
110
- names: getBoundNames(expression.bounds),
111
- body: expression.expression,
112
- sets: getBoundSets(expression.bounds),
113
- };
114
- case "SetFilter":
115
- return {
116
- names: getPatternNames(expression.bound.pattern),
117
- body: expression.predicate,
118
- sets: [expression.bound.set],
119
- };
120
- case "Choose":
121
- return {
122
- names: getPatternNames(expression.pattern),
123
- body: expression.body,
124
- sets: expression.set ? [expression.set] : [],
125
- };
126
- case "UnboundedQuantifier":
127
- case "Lambda":
128
- return {
129
- names: expression.kind === "Lambda" ? expression.params : expression.names,
130
- body: expression.body,
131
- sets: [],
132
- };
133
- default:
134
- return undefined;
135
- }
136
- };
137
-
138
52
  const findLabel = (
139
53
  expression: Expression,
140
54
  name: string,
@@ -153,9 +67,6 @@ const findLabel = (
153
67
  return undefined;
154
68
  };
155
69
 
156
- const takeArguments = (args: Expression[], count: number, pool: Expression[]) =>
157
- args.length === 0 && pool.length > 0 ? pool.splice(0, count) : args;
158
-
159
70
  const wrapLets = (body: Expression, lets: Definition[][], location: SourceLocation) =>
160
71
  lets.reduceRight<Expression>(
161
72
  (inner, definitions) => ({ kind: "Let", definitions, body: inner, location }),
@@ -235,14 +146,30 @@ const applyDefinition = (definition: Definition, selection: Selection) => {
235
146
  return createApplication({ ...selection, params: [...selection.params, ...params] }, reference);
236
147
  };
237
148
 
149
+ // Generator.selectorToNode reports the first part of a name that selects nothing, after it analyzes
150
+ // the arguments of the parts before, and goes on after the name. An operator or a label must be given
151
+ // all its arguments, except in a name that an operator argument may select whole.
238
152
  const selectSubexpression = (
239
153
  selectors: Selector[],
240
154
  lookup: Lookup,
241
- location: SourceLocation,
242
- pool: Expression[],
155
+ reference: Expression & SelectingName,
156
+ isOperator: boolean,
243
157
  ): Expression => {
158
+ const location = reference.location;
244
159
  const selection: Selection = { params: [], args: [], lets: [], location };
245
- const state = { index: 0, current: undefined as Expression | undefined };
160
+ const state = { index: 0, current: undefined as Expression | undefined, isFailed: false };
161
+
162
+ const report = (range: SourceRange | undefined, message: string) => {
163
+ if (!range) throw createError(message, location);
164
+ selectionErrors.set(reference, {
165
+ args: selectors
166
+ .slice(0, state.index)
167
+ .flatMap((selector) => ("args" in selector ? selector.args : [])),
168
+ error: { location: formatRange(range), message },
169
+ });
170
+ state.isFailed = true;
171
+ return undefined;
172
+ };
246
173
 
247
174
  const findDefinition = (local: Definition[] | undefined) => {
248
175
  const names: string[] = [];
@@ -256,9 +183,8 @@ const selectSubexpression = (
256
183
  const definition = local
257
184
  ? local.find((candidate) => getSourceName(candidate) === name)
258
185
  : lookup(name);
259
- if (definition) {
260
- return { definition, args: takeArguments(args, getArity(definition), pool) };
261
- }
186
+ if (definition)
187
+ return { definition, name, args, earlier: args.length - selector.args.length };
262
188
  state.index++;
263
189
  }
264
190
  throw createError(`Unknown operator ${names.join("!")}`, location);
@@ -269,8 +195,11 @@ const selectSubexpression = (
269
195
  const definition = found.definition;
270
196
  const arity = getArity(definition);
271
197
  const isLast = state.index === selectors.length - 1;
272
- if (found.args.length !== arity && found.args.length !== 0) {
273
- throw createError(`The operator ${definition.name} requires ${arity} arguments`, location);
198
+ if (found.args.length !== arity && (!isOperator || found.args.length !== 0)) {
199
+ return report(
200
+ reference.argumentRanges?.[state.index] ?? location.range,
201
+ `The operator ${found.name} requires ${arity - found.earlier} arguments.`,
202
+ );
274
203
  }
275
204
  if (isLast) return { definition, args: found.args };
276
205
  if (definition.kind !== "Operator") {
@@ -284,14 +213,19 @@ const selectSubexpression = (
284
213
  };
285
214
 
286
215
  const followLabels = () => {
287
- while (state.index < selectors.length) {
216
+ while (state.index < selectors.length && !state.isFailed) {
288
217
  const selector = selectors[state.index];
289
218
  if (selector.kind !== "Name") return;
219
+ const range = reference.selectorRanges?.[state.index];
290
220
  const found = state.current && findLabel(state.current, selector.name, []);
291
- if (!found) throw createError(`Cannot find label ${selector.name}`, location);
221
+ if (!found) return report(range, `Cannot find label \`${selector.name}'.`);
222
+ const params = found.label.params;
223
+ if (!isOperator && selector.args.length !== params.length) {
224
+ return report(range, `Label \`${selector.name}' used with wrong number of arguments.`);
225
+ }
292
226
  selection.lets.push(...found.lets);
293
- selection.params.push(...found.label.params.map((name) => ({ name, arity: 0 })));
294
- selection.args.push(...takeArguments(selector.args, found.label.params.length, pool));
227
+ selection.params.push(...params.map((name) => ({ name, arity: 0 })));
228
+ selection.args.push(...selector.args);
295
229
  state.current = found.label.body;
296
230
  state.index++;
297
231
  }
@@ -317,9 +251,7 @@ const selectSubexpression = (
317
251
  const binder = getBinder(current);
318
252
  if (binder && (selector.kind === "Bound" || selector.kind === "At")) {
319
253
  selection.params.push(...binder.names.map((name) => ({ name, arity: 0 })));
320
- if (selector.kind === "Bound") {
321
- selection.args.push(...takeArguments(selector.args, binder.names.length, pool));
322
- }
254
+ if (selector.kind === "Bound") selection.args.push(...selector.args);
323
255
  state.current = binder.body;
324
256
  return;
325
257
  }
@@ -349,9 +281,10 @@ const selectSubexpression = (
349
281
  };
350
282
 
351
283
  const first = enterDefinition(undefined);
284
+ if (state.isFailed) return reference;
352
285
  if (first) return applyDefinition(first.definition, { ...selection, args: first.args });
353
286
  followLabels();
354
- while (state.index < selectors.length) {
287
+ while (state.index < selectors.length && !state.isFailed) {
355
288
  const selector = selectors[state.index];
356
289
  if (selector.kind === "Name") {
357
290
  while (state.current?.kind === "Label") state.current = state.current.body;
@@ -360,6 +293,7 @@ const selectSubexpression = (
360
293
  }
361
294
  selection.lets.push(state.current.definitions);
362
295
  const last = enterDefinition(state.current.definitions);
296
+ if (state.isFailed) return reference;
363
297
  if (last) {
364
298
  return applyDefinition(last.definition, {
365
299
  ...selection,
@@ -372,19 +306,22 @@ const selectSubexpression = (
372
306
  selectOperand(selector);
373
307
  state.index++;
374
308
  }
309
+ if (state.isFailed) return reference;
375
310
  if (!state.current) throw createError("Subexpression selection failed", location);
376
311
  return createApplication(selection, state.current);
377
312
  };
378
313
 
379
- const getQualifiedSelectors = (name: string, lookup: Lookup): Selector[] | undefined => {
314
+ // A name such as Op(1)!lab(2) whose first parts name a definition selects part of it.
315
+ const getQualifiedSelectors = (
316
+ name: string,
317
+ args: Expression[],
318
+ counts: number[] | undefined,
319
+ lookup: Lookup,
320
+ ) => {
380
321
  if (!name.includes("!") || lookup(name)) return undefined;
381
322
  const parts = name.split("!");
382
- const prefix = parts.findIndex((_, index) => lookup(parts.slice(0, index + 1).join("!")));
383
- if (prefix === -1) return undefined;
384
- return [
385
- { kind: "Name", name: parts.slice(0, prefix + 1).join("!"), args: [] },
386
- ...parts.slice(prefix + 1).map((part): Selector => ({ kind: "Name", name: part, args: [] })),
387
- ];
323
+ if (!parts.some((_, index) => lookup(parts.slice(0, index + 1).join("!")))) return undefined;
324
+ return getNameSelectors(name, args, counts);
388
325
  };
389
326
 
390
327
  const containsReference = (expression: Expression): boolean =>
@@ -393,25 +330,48 @@ const containsReference = (expression: Expression): boolean =>
393
330
  (expression.kind === "Apply" && expression.operator.includes("!")) ||
394
331
  getChildren(expression).some(containsReference);
395
332
 
396
- const resolveSubexpressions = (expression: Expression, lookup: Lookup): Expression => {
333
+ // A reference into a theorem whose statement is an ASSUME/PROVE stays for name resolution to check.
334
+ // isOperator holds where an operator may be given, as the argument of an operator that may take one.
335
+ const resolveSubexpressions = (
336
+ expression: Expression,
337
+ lookup: Lookup,
338
+ goals: ReadonlySet<string>,
339
+ isOperator = false,
340
+ ): Expression => {
397
341
  if (!containsReference(expression)) return expression;
398
342
  if (expression.kind === "Let") {
399
343
  const local: Lookup = (name) =>
400
344
  expression.definitions.find((definition) => definition.name === name) ?? lookup(name);
401
- return mapChildren(expression, (child) => resolveSubexpressions(child, local));
345
+ return mapChildren(expression, (child) => resolveSubexpressions(child, local, goals));
402
346
  }
403
- const mapped = mapChildren(expression, (child) => resolveSubexpressions(child, lookup));
404
- if (mapped.kind === "Subexpression") {
405
- return selectSubexpression(mapped.selectors, lookup, mapped.location, []);
406
- }
407
- const name =
408
- mapped.kind === "Identifier" ? mapped.name : mapped.kind === "Apply" ? mapped.operator : "";
409
- const selectors = getQualifiedSelectors(name, lookup);
410
- if (!selectors) return mapped;
411
- const pool = mapped.kind === "Apply" ? [...mapped.args] : [];
412
- const resolved = selectSubexpression(selectors, lookup, mapped.location, pool);
413
- if (pool.length > 0) throw createError(`Too many arguments for ${name}`, mapped.location);
414
- return resolved;
347
+ const callee = expression.kind === "Apply" ? lookup(expression.operator) : undefined;
348
+ const mapped =
349
+ expression.kind === "Apply"
350
+ ? {
351
+ ...expression,
352
+ args: expression.args.map((arg, index) =>
353
+ resolveSubexpressions(
354
+ arg,
355
+ lookup,
356
+ goals,
357
+ callee?.kind !== "Operator" || callee.params[index]?.arity !== 0,
358
+ ),
359
+ ),
360
+ }
361
+ : mapChildren(expression, (child) => resolveSubexpressions(child, lookup, goals));
362
+ const selectors =
363
+ mapped.kind === "Subexpression"
364
+ ? mapped.selectors
365
+ : mapped.kind === "Identifier"
366
+ ? getQualifiedSelectors(mapped.name, [], undefined, lookup)
367
+ : mapped.kind === "Apply"
368
+ ? getQualifiedSelectors(mapped.operator, mapped.args, mapped.argumentCounts, lookup)
369
+ : undefined;
370
+ const first = selectors?.[0];
371
+ if (!selectors || (first?.kind === "Name" && goals.has(first.name))) return mapped;
372
+ const selected = selectSubexpression(selectors, lookup, mapped, isOperator);
373
+ if (selected !== mapped) selections.add(selected);
374
+ return selected;
415
375
  };
416
376
 
417
377
  const createLookup = (definitions: Definition[]): Lookup => {
@@ -424,8 +384,8 @@ export const resolveInstanceSubexpressions = (instance: Instance, module: Module
424
384
  return {
425
385
  ...instance,
426
386
  substitutions: instance.substitutions.map((substitution) => ({
427
- name: substitution.name,
428
- expression: resolveSubexpressions(substitution.expression, lookup),
387
+ ...substitution,
388
+ expression: resolveSubexpressions(substitution.expression, lookup, new Set(), true),
429
389
  })),
430
390
  };
431
391
  };
@@ -436,14 +396,19 @@ export const resolveModuleSubexpressions = (module: Module, available: Definitio
436
396
  module.definitions.some((definition) => containsReference(definition.body)) ||
437
397
  module.assumptions.some((assumption) => containsReference(assumption.expression));
438
398
  if (!hasReferences) return module;
399
+ const goals = new Set(
400
+ module.theorems.flatMap((theorem) =>
401
+ theorem.name !== undefined && theorem.statement.kind === "AssumeProve" ? [theorem.name] : [],
402
+ ),
403
+ );
439
404
  return {
440
405
  ...module,
441
406
  definitions: module.definitions.map((definition) =>
442
- mapDefinition(definition, (child) => resolveSubexpressions(child, lookup)),
407
+ mapDefinition(definition, (child) => resolveSubexpressions(child, lookup, goals)),
443
408
  ),
444
409
  assumptions: module.assumptions.map((assumption) => ({
445
410
  ...assumption,
446
- expression: resolveSubexpressions(assumption.expression, lookup),
411
+ expression: resolveSubexpressions(assumption.expression, lookup, goals),
447
412
  })),
448
413
  };
449
414
  };
@@ -1,6 +1,8 @@
1
- import type { Declaration, Definition, Expression, SourceLocation } from "./ast";
2
- import { TlaSyntaxError } from "./errors";
1
+ import type { Declaration, Definition, Expression, SourceLocation, Theorem } from "./ast";
2
+ import { createSanyError, formatRange } from "./errors";
3
3
  import {
4
+ ACTION_LEVEL,
5
+ analyzeAssumeProve,
4
6
  createLevelAnalyzer,
5
7
  getArgumentKey,
6
8
  MAX_LEVEL,
@@ -24,6 +26,7 @@ interface ModuleContext {
24
26
  variables: string[];
25
27
  definitions: Definition[];
26
28
  assumptions: Expression[];
29
+ theorems: Theorem[];
27
30
  getDefinition: (name: string) => Definition | undefined;
28
31
  }
29
32
 
@@ -46,10 +49,7 @@ interface Substituted {
46
49
  const getMaxLevel = (operator: OperatorLevels, index: number) =>
47
50
  operator.maxLevels[index] ?? MAX_LEVEL;
48
51
 
49
- export const checkInstances = (
50
- checks: InstanceCheck[],
51
- getModule: (name: string) => ModuleContext,
52
- ) => {
52
+ export const createInstanceChecker = (getModule: (name: string) => ModuleContext) => {
53
53
  const analyzers = new Map<string, ReturnType<typeof createLevelAnalyzer>>();
54
54
  const getAnalyzer = (name: string) => {
55
55
  const cached = analyzers.get(name);
@@ -101,17 +101,38 @@ export const checkInstances = (
101
101
  definition.formals.every((formal) => formal.name !== operator && formal.name !== param),
102
102
  ),
103
103
  );
104
+ const addAssumedLevels = (data: ReturnType<typeof analyzeAssumeProve>) => {
105
+ addLevels(data, () => true);
106
+ module.constants.forEach((constant) => {
107
+ if (data.params.has(constant.name)) {
108
+ putConstraint(levels.constraints, constant.name, ACTION_LEVEL);
109
+ }
110
+ });
111
+ };
104
112
  module.assumptions.forEach((assumption) =>
105
- addLevels(analyzer.analyze(assumption, new Map()), () => true),
113
+ addAssumedLevels(analyzer.analyze(assumption, new Map())),
114
+ );
115
+ module.theorems.forEach((theorem) =>
116
+ theorem.statement.kind === "AssumeProve"
117
+ ? addAssumedLevels(analyzeAssumeProve(theorem.statement, new Map(), analyzer))
118
+ : addLevels(analyzer.analyze(theorem.statement, new Map()), () => true),
106
119
  );
107
120
  moduleLevels.set(name, levels);
108
121
  return levels;
109
122
  };
110
123
 
111
- const messages = new Set<string>();
112
- checks.forEach((check) => {
113
- const location = `at line ${check.location.line}, column ${check.location.column}`;
114
- const addMessage = (message: string) => messages.add(`${message} ${location}`);
124
+ return (check: InstanceCheck) => {
125
+ const errors = new Map<string, { location: string; message: string }>();
126
+ // SANY reports each error at the whole instance.
127
+ const location = formatRange(
128
+ check.location.range ?? {
129
+ module: check.instancer,
130
+ start: check.location,
131
+ end: check.location,
132
+ },
133
+ );
134
+ const addMessage = (message: string) =>
135
+ errors.set(`${location}\n${message}`, { location, message });
115
136
  const instancee = getModule(check.module);
116
137
  const levels = getModuleLevels(check.module);
117
138
  const analyzer = getAnalyzer(check.instancer);
@@ -141,14 +162,14 @@ export const checkInstances = (
141
162
  ];
142
163
  });
143
164
  const getLevelMessage = (name: string, level: number) =>
144
- `Level error in instantiating module '${check.module}': the level of the expression or operator substituted for '${name}' must be at most ${level}`;
165
+ `Level error in instantiating module '${check.module}':\nThe level of the expression or operator substituted for '${name}' \nmust be at most ${level}.`;
145
166
  substituted.forEach((item) => {
146
167
  if (!levels.isConstant && item.level > item.maximumLevel) {
147
168
  addMessage(getLevelMessage(item.name, item.maximumLevel));
148
169
  }
149
170
  if (!item.isLeibniz) {
150
171
  addMessage(
151
- `Error in instantiating module '${check.module}': a non-Leibniz operator substituted for '${item.name}'`,
172
+ `Error in instantiating module '${check.module}':\n A non-Leibniz operator substituted for '${item.name}'.`,
152
173
  );
153
174
  }
154
175
  });
@@ -162,7 +183,7 @@ export const checkInstances = (
162
183
  const minimum = levels.argConstraints.get(getArgumentKey(item.name, index));
163
184
  if (minimum !== undefined && getMaxLevel(operator, index) < minimum) {
164
185
  addMessage(
165
- `Level error in instantiating module '${check.module}': the level of the argument ${index + 1} of the operator ${operator.name} must be at least ${minimum}`,
186
+ `Level error in instantiating module '${check.module}':\nThe level of the argument ${index + 1} of the operator ${operator.name} \nmust be at least ${minimum}.`,
166
187
  );
167
188
  }
168
189
  });
@@ -175,10 +196,10 @@ export const checkInstances = (
175
196
  const maximum = getMaxLevel(operator, parameter.index);
176
197
  if (argument.level > maximum) {
177
198
  addMessage(
178
- `Level error when instantiating module '${check.module}': the level of the argument ${parameter.index} of the operator ${parameter.operator}' must be at most ${maximum}`,
199
+ `Level error when instantiating module '${check.module}':\nThe level of the argument ${parameter.index} of the operator ${parameter.operator}' \nmust be at most ${maximum}.`,
179
200
  );
180
201
  }
181
202
  });
182
- });
183
- if (messages.size > 0) throw new TlaSyntaxError([...messages].join("\n"));
203
+ if (errors.size > 0) throw createSanyError([...errors.values()]);
204
+ };
184
205
  };