tla-ts 0.0.3-dev.5ea4534 → 0.0.3-dev.5fd6731

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 (49) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.cts +59 -22
  3. package/dist/index.d.ts +59 -22
  4. package/dist/index.js +1 -1
  5. package/dist/parallel-worker.cjs +1 -1
  6. package/dist/parallel-worker.js +2 -2
  7. package/dist/parallel.cjs +1 -1
  8. package/dist/parallel.js +2 -2
  9. package/dist/run-cli.cjs +14 -12
  10. package/dist/run-cli.js +22 -20
  11. package/dist/transfer.cjs +39 -21
  12. package/dist/transfer.js +39 -21
  13. package/package.json +1 -1
  14. package/src/ast.ts +27 -4
  15. package/src/builtins.ts +9 -3
  16. package/src/check.ts +357 -79
  17. package/src/codegen.ts +6 -3
  18. package/src/config.ts +224 -170
  19. package/src/environment.ts +249 -87
  20. package/src/errors.ts +100 -1
  21. package/src/evaluate.ts +182 -26
  22. package/src/exit-codes.ts +22 -3
  23. package/src/fingerprints.ts +2 -1
  24. package/src/instances.ts +1 -1
  25. package/src/levels.ts +177 -36
  26. package/src/live-check.ts +132 -70
  27. package/src/liveness.ts +117 -22
  28. package/src/parallel-worker.ts +2 -2
  29. package/src/parallel.ts +2 -2
  30. package/src/parser.ts +155 -49
  31. package/src/resolve.ts +911 -342
  32. package/src/run-cli.ts +61 -11
  33. package/src/sany-lexer.ts +615 -0
  34. package/src/sany-parse-error.ts +3143 -0
  35. package/src/spec-description.ts +1 -2
  36. package/src/standard-modules.ts +54 -45
  37. package/src/standard-ranges.ts +116 -0
  38. package/src/subexpressions.ts +26 -14
  39. package/src/substitution-levels.ts +38 -17
  40. package/src/successors.ts +169 -33
  41. package/src/symmetry.ts +16 -6
  42. package/src/tableau.ts +51 -24
  43. package/src/tlc-module.ts +6 -6
  44. package/src/tlc-modules.ts +4 -0
  45. package/src/tlc-order.ts +8 -4
  46. package/src/tlc-random.ts +9 -6
  47. package/src/tlc-summary.ts +20 -5
  48. package/src/value-sources.ts +29 -0
  49. package/src/values.ts +231 -61
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tla-ts",
3
- "version": "0.0.3-dev.5ea4534",
3
+ "version": "0.0.3-dev.5fd6731",
4
4
  "description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
5
5
  "keywords": [
6
6
  "formal verification",
package/src/ast.ts CHANGED
@@ -33,9 +33,12 @@ export interface StringExpression {
33
33
  location: SourceLocation;
34
34
  }
35
35
 
36
+ // selectorRanges holds the range of each part of a name such as foo!lab, where SANY reports an
37
+ // error in selecting that part.
36
38
  export interface IdentifierExpression {
37
39
  kind: "Identifier";
38
40
  name: string;
41
+ selectorRanges?: SourceRange[];
39
42
  location: SourceLocation;
40
43
  resolution?: LocalResolution;
41
44
  }
@@ -47,6 +50,9 @@ export interface ApplyExpression {
47
50
  // The number of args each part of a name like F(x)!l(y) takes, when a part before the last takes
48
51
  // some.
49
52
  argumentCounts?: number[];
53
+ // The range of the parenthesized arguments of a named operator, where SANY reports their count.
54
+ argumentsRange?: SourceRange;
55
+ selectorRanges?: SourceRange[];
50
56
  location: SourceLocation;
51
57
  resolution?: LocalResolution;
52
58
  }
@@ -60,6 +66,7 @@ export interface OperatorReferenceExpression {
60
66
  export interface LambdaExpression {
61
67
  kind: "Lambda";
62
68
  params: string[];
69
+ paramRanges?: SourceRange[];
63
70
  body: Expression;
64
71
  location: SourceLocation;
65
72
  }
@@ -117,7 +124,10 @@ export interface LetExpression {
117
124
  location: SourceLocation;
118
125
  }
119
126
 
120
- export type BoundPattern = { kind: "Name"; name: string } | { kind: "Tuple"; names: string[] };
127
+ // ranges holds the range of each name the pattern binds.
128
+ export type BoundPattern =
129
+ | { kind: "Name"; name: string; ranges?: SourceRange[] }
130
+ | { kind: "Tuple"; names: string[]; ranges?: SourceRange[] };
121
131
 
122
132
  export interface Bound {
123
133
  pattern: BoundPattern;
@@ -135,6 +145,7 @@ export interface UnboundedQuantifierExpression {
135
145
  kind: "UnboundedQuantifier";
136
146
  quantifier: "Forall" | "Exists";
137
147
  names: string[];
148
+ nameRanges?: SourceRange[];
138
149
  isTemporal?: boolean;
139
150
  body: Expression;
140
151
  location: SourceLocation;
@@ -192,6 +203,7 @@ export interface FunctionSetExpression {
192
203
  export interface RecordField {
193
204
  name: string;
194
205
  value: Expression;
206
+ location: SourceLocation;
195
207
  }
196
208
 
197
209
  export interface RecordExpression {
@@ -280,6 +292,7 @@ export type Selector =
280
292
  export interface SubexpressionExpression {
281
293
  kind: "Subexpression";
282
294
  selectors: Selector[];
295
+ selectorRanges?: SourceRange[];
283
296
  location: SourceLocation;
284
297
  }
285
298
 
@@ -363,6 +376,7 @@ export interface Assumption {
363
376
 
364
377
  export interface InstanceSubstitution {
365
378
  name: string;
379
+ nameRange: SourceRange;
366
380
  expression: Expression;
367
381
  }
368
382
 
@@ -384,6 +398,7 @@ export interface NewSymbol {
384
398
  arity: number;
385
399
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
386
400
  set: Expression | undefined;
401
+ nameRange?: SourceRange;
387
402
  location: SourceLocation;
388
403
  }
389
404
 
@@ -435,19 +450,27 @@ export type StepBody =
435
450
  | Instance
436
451
  | DefineStep
437
452
  | { kind: "Have"; expression: Expression }
438
- | { kind: "Take"; names: string[]; bounds: Bound[] }
453
+ | { kind: "Take"; names: string[]; nameRanges?: SourceRange[]; bounds: Bound[] }
439
454
  | { kind: "Witness"; expressions: Expression[] }
440
- | { kind: "Pick"; names: string[]; bounds: Bound[]; body: Expression }
455
+ | {
456
+ kind: "Pick";
457
+ names: string[];
458
+ nameRanges?: SourceRange[];
459
+ bounds: Bound[];
460
+ body: Expression;
461
+ }
441
462
  | { kind: "Case"; expression: Expression }
442
463
  | { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
443
464
  | { kind: "Qed" };
444
465
 
445
- // head is the range of the step number and its statement, without the proof.
466
+ // head is the range of the step number and its statement, without the proof, and statement is the
467
+ // range of the statement alone.
446
468
  export interface ProofStep {
447
469
  name: string | undefined;
448
470
  token: string;
449
471
  body: StepBody;
450
472
  head: SourceRange;
473
+ statement: SourceRange;
451
474
  proof: Proof | undefined;
452
475
  location: SourceLocation;
453
476
  }
package/src/builtins.ts CHANGED
@@ -297,15 +297,21 @@ export const getJavaInteger = (value: Value, signature: string) => {
297
297
  return value;
298
298
  };
299
299
 
300
- export const getIntegersSignature = (method: string, result: string, arity: number) =>
301
- `public static tlc2.value.impl.${result} tlc2.module.Integers.${method}(${Array.from({ length: arity }, () => "tlc2.value.impl.IntValue").join(",")})`;
300
+ export const getArithmeticSignature = (
301
+ javaClass: "Naturals" | "Integers",
302
+ method: string,
303
+ result: string,
304
+ arity: number,
305
+ ) =>
306
+ `public static tlc2.value.impl.${result} tlc2.module.${javaClass}.${method}(${Array.from({ length: arity }, () => "tlc2.value.impl.IntValue").join(",")})`;
302
307
 
303
308
  export const defineArithmetic = (
309
+ javaClass: "Naturals" | "Integers",
304
310
  name: string,
305
311
  method: string,
306
312
  compute: (left: number, right: number) => number,
307
313
  ) => {
308
- const signature = getIntegersSignature(method, "IntValue", 2);
314
+ const signature = getArithmeticSignature(javaClass, method, "IntValue", 2);
309
315
  return defineBinary(name, (left, right) => {
310
316
  const leftNumber = getJavaInteger(left, signature);
311
317
  const rightNumber = getJavaInteger(right, signature);