tla-ts 0.0.3-dev.3cf2ad0 → 0.0.3-dev.40085a4
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 +16 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +71 -22
- package/dist/index.d.ts +71 -22
- 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 +20 -17
- package/dist/run-cli.js +22 -19
- package/dist/transfer.cjs +46 -16
- package/dist/transfer.js +46 -16
- package/package.json +1 -1
- package/src/ast.ts +121 -4
- package/src/builtins.ts +9 -3
- package/src/check.ts +514 -99
- package/src/cli-options.ts +11 -5
- package/src/codegen.ts +15 -22
- package/src/config.ts +224 -170
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +410 -130
- package/src/errors.ts +109 -3
- package/src/evaluate.ts +255 -159
- package/src/exit-codes.ts +39 -42
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +17 -16
- package/src/levels.ts +185 -44
- package/src/lexer.ts +5 -1
- package/src/live-check.ts +772 -0
- package/src/liveness.ts +120 -543
- package/src/parallel-worker.ts +7 -3
- package/src/parallel.ts +20 -4
- package/src/parser.ts +184 -54
- package/src/resolve.ts +1378 -420
- package/src/run-cli.ts +115 -20
- package/src/runtime.ts +3 -1
- package/src/sany-lexer.ts +615 -0
- package/src/sany-parse-error.ts +3143 -0
- package/src/spec-description.ts +19 -8
- package/src/standard-modules.ts +54 -45
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +231 -171
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +183 -39
- package/src/symmetry.ts +25 -7
- package/src/tableau.ts +51 -24
- package/src/tlc-ext.ts +29 -12
- package/src/tlc-module.ts +14 -33
- package/src/tlc-modules.ts +4 -0
- package/src/tlc-order.ts +25 -7
- package/src/tlc-random.ts +9 -6
- package/src/tlc-summary.ts +20 -5
- package/src/value-sources.ts +29 -0
- package/src/values.ts +242 -61
package/package.json
CHANGED
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,11 @@ 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[];
|
|
56
|
+
// The range of the arguments of each part of a name like F(x)!l(y), for a part that takes some.
|
|
57
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
50
58
|
location: SourceLocation;
|
|
51
59
|
resolution?: LocalResolution;
|
|
52
60
|
}
|
|
@@ -60,6 +68,7 @@ export interface OperatorReferenceExpression {
|
|
|
60
68
|
export interface LambdaExpression {
|
|
61
69
|
kind: "Lambda";
|
|
62
70
|
params: string[];
|
|
71
|
+
paramRanges?: SourceRange[];
|
|
63
72
|
body: Expression;
|
|
64
73
|
location: SourceLocation;
|
|
65
74
|
}
|
|
@@ -117,7 +126,10 @@ export interface LetExpression {
|
|
|
117
126
|
location: SourceLocation;
|
|
118
127
|
}
|
|
119
128
|
|
|
120
|
-
|
|
129
|
+
// ranges holds the range of each name the pattern binds.
|
|
130
|
+
export type BoundPattern =
|
|
131
|
+
| { kind: "Name"; name: string; ranges?: SourceRange[] }
|
|
132
|
+
| { kind: "Tuple"; names: string[]; ranges?: SourceRange[] };
|
|
121
133
|
|
|
122
134
|
export interface Bound {
|
|
123
135
|
pattern: BoundPattern;
|
|
@@ -135,6 +147,7 @@ export interface UnboundedQuantifierExpression {
|
|
|
135
147
|
kind: "UnboundedQuantifier";
|
|
136
148
|
quantifier: "Forall" | "Exists";
|
|
137
149
|
names: string[];
|
|
150
|
+
nameRanges?: SourceRange[];
|
|
138
151
|
isTemporal?: boolean;
|
|
139
152
|
body: Expression;
|
|
140
153
|
location: SourceLocation;
|
|
@@ -192,6 +205,7 @@ export interface FunctionSetExpression {
|
|
|
192
205
|
export interface RecordField {
|
|
193
206
|
name: string;
|
|
194
207
|
value: Expression;
|
|
208
|
+
location: SourceLocation;
|
|
195
209
|
}
|
|
196
210
|
|
|
197
211
|
export interface RecordExpression {
|
|
@@ -266,6 +280,7 @@ export interface LabelExpression {
|
|
|
266
280
|
kind: "Label";
|
|
267
281
|
name: string;
|
|
268
282
|
params: string[];
|
|
283
|
+
paramRanges?: SourceRange[];
|
|
269
284
|
body: Expression;
|
|
270
285
|
location: SourceLocation;
|
|
271
286
|
}
|
|
@@ -280,6 +295,8 @@ export type Selector =
|
|
|
280
295
|
export interface SubexpressionExpression {
|
|
281
296
|
kind: "Subexpression";
|
|
282
297
|
selectors: Selector[];
|
|
298
|
+
selectorRanges?: SourceRange[];
|
|
299
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
283
300
|
location: SourceLocation;
|
|
284
301
|
}
|
|
285
302
|
|
|
@@ -363,6 +380,7 @@ export interface Assumption {
|
|
|
363
380
|
|
|
364
381
|
export interface InstanceSubstitution {
|
|
365
382
|
name: string;
|
|
383
|
+
nameRange: SourceRange;
|
|
366
384
|
expression: Expression;
|
|
367
385
|
}
|
|
368
386
|
|
|
@@ -384,6 +402,7 @@ export interface NewSymbol {
|
|
|
384
402
|
arity: number;
|
|
385
403
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
386
404
|
set: Expression | undefined;
|
|
405
|
+
nameRange?: SourceRange;
|
|
387
406
|
location: SourceLocation;
|
|
388
407
|
}
|
|
389
408
|
|
|
@@ -435,19 +454,27 @@ export type StepBody =
|
|
|
435
454
|
| Instance
|
|
436
455
|
| DefineStep
|
|
437
456
|
| { kind: "Have"; expression: Expression }
|
|
438
|
-
| { kind: "Take"; names: string[]; bounds: Bound[] }
|
|
457
|
+
| { kind: "Take"; names: string[]; nameRanges?: SourceRange[]; bounds: Bound[] }
|
|
439
458
|
| { kind: "Witness"; expressions: Expression[] }
|
|
440
|
-
| {
|
|
459
|
+
| {
|
|
460
|
+
kind: "Pick";
|
|
461
|
+
names: string[];
|
|
462
|
+
nameRanges?: SourceRange[];
|
|
463
|
+
bounds: Bound[];
|
|
464
|
+
body: Expression;
|
|
465
|
+
}
|
|
441
466
|
| { kind: "Case"; expression: Expression }
|
|
442
467
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
443
468
|
| { kind: "Qed" };
|
|
444
469
|
|
|
445
|
-
// head is the range of the step number and its statement, without the proof
|
|
470
|
+
// head is the range of the step number and its statement, without the proof, and statement is the
|
|
471
|
+
// range of the statement alone.
|
|
446
472
|
export interface ProofStep {
|
|
447
473
|
name: string | undefined;
|
|
448
474
|
token: string;
|
|
449
475
|
body: StepBody;
|
|
450
476
|
head: SourceRange;
|
|
477
|
+
statement: SourceRange;
|
|
451
478
|
proof: Proof | undefined;
|
|
452
479
|
location: SourceLocation;
|
|
453
480
|
}
|
|
@@ -486,3 +513,93 @@ export interface Module {
|
|
|
486
513
|
uses: UseOrHide[];
|
|
487
514
|
units: ModuleUnit[];
|
|
488
515
|
}
|
|
516
|
+
|
|
517
|
+
export const getChildren = (expression: Expression): Expression[] => {
|
|
518
|
+
switch (expression.kind) {
|
|
519
|
+
case "Number":
|
|
520
|
+
case "Decimal":
|
|
521
|
+
case "String":
|
|
522
|
+
case "Identifier":
|
|
523
|
+
case "OperatorReference":
|
|
524
|
+
case "ExceptAt":
|
|
525
|
+
return [];
|
|
526
|
+
case "Apply":
|
|
527
|
+
return expression.args;
|
|
528
|
+
case "Lambda":
|
|
529
|
+
return [expression.body];
|
|
530
|
+
case "And":
|
|
531
|
+
case "Or":
|
|
532
|
+
return expression.operands;
|
|
533
|
+
case "Prime":
|
|
534
|
+
case "Unchanged":
|
|
535
|
+
case "Enabled":
|
|
536
|
+
case "Always":
|
|
537
|
+
case "Eventually":
|
|
538
|
+
return [expression.expression];
|
|
539
|
+
case "If":
|
|
540
|
+
return [expression.condition, expression.consequent, expression.alternative];
|
|
541
|
+
case "Case":
|
|
542
|
+
return [
|
|
543
|
+
...expression.arms.flatMap((arm) => [arm.condition, arm.body]),
|
|
544
|
+
...(expression.other ? [expression.other] : []),
|
|
545
|
+
];
|
|
546
|
+
case "Let":
|
|
547
|
+
return [
|
|
548
|
+
...expression.definitions.flatMap((definition) =>
|
|
549
|
+
definition.kind === "Function"
|
|
550
|
+
? [...definition.bounds.map((bound) => bound.set), definition.body]
|
|
551
|
+
: [definition.body],
|
|
552
|
+
),
|
|
553
|
+
expression.body,
|
|
554
|
+
];
|
|
555
|
+
case "Forall":
|
|
556
|
+
case "Exists":
|
|
557
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
558
|
+
case "UnboundedQuantifier":
|
|
559
|
+
return [expression.body];
|
|
560
|
+
case "Choose":
|
|
561
|
+
return [...(expression.set ? [expression.set] : []), expression.body];
|
|
562
|
+
case "SetEnumeration":
|
|
563
|
+
case "Tuple":
|
|
564
|
+
return expression.elements;
|
|
565
|
+
case "SetFilter":
|
|
566
|
+
return [expression.bound.set, expression.predicate];
|
|
567
|
+
case "SetMap":
|
|
568
|
+
return [expression.expression, ...expression.bounds.map((bound) => bound.set)];
|
|
569
|
+
case "FunctionConstruction":
|
|
570
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
571
|
+
case "FunctionSet":
|
|
572
|
+
return [expression.domain, expression.range];
|
|
573
|
+
case "Record":
|
|
574
|
+
case "RecordSet":
|
|
575
|
+
return expression.fields.map((field) => field.value);
|
|
576
|
+
case "Except":
|
|
577
|
+
return [
|
|
578
|
+
expression.function,
|
|
579
|
+
...expression.updates.flatMap((update) => [
|
|
580
|
+
...update.path.flatMap((step) => (step.kind === "Index" ? step.args : [])),
|
|
581
|
+
update.value,
|
|
582
|
+
]),
|
|
583
|
+
];
|
|
584
|
+
case "FunctionApplication":
|
|
585
|
+
return [expression.function, ...expression.args];
|
|
586
|
+
case "FieldAccess":
|
|
587
|
+
return [expression.record];
|
|
588
|
+
case "Product":
|
|
589
|
+
return expression.factors;
|
|
590
|
+
case "BoxAction":
|
|
591
|
+
case "AngleAction":
|
|
592
|
+
return [expression.action, expression.subscript];
|
|
593
|
+
case "WeakFairness":
|
|
594
|
+
case "StrongFairness":
|
|
595
|
+
return [expression.subscript, expression.action];
|
|
596
|
+
case "Label":
|
|
597
|
+
return [expression.body];
|
|
598
|
+
case "Subexpression":
|
|
599
|
+
return expression.selectors.flatMap((selector) => ("args" in selector ? selector.args : []));
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
export const isLocallyResolved = (expression: Expression) =>
|
|
604
|
+
(expression.kind === "Identifier" || expression.kind === "Apply") &&
|
|
605
|
+
expression.resolution?.kind === "Local";
|
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
|
|
301
|
-
|
|
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 =
|
|
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);
|