tla-ts 0.0.3-dev.6a30eee → 0.0.3-dev.6d0aeb6
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 +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +58 -22
- package/dist/index.d.ts +58 -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 -18
- package/dist/run-cli.js +22 -20
- package/dist/transfer.cjs +40 -15
- package/dist/transfer.js +40 -15
- package/package.json +1 -1
- package/src/ast.ts +101 -1
- package/src/builtins.ts +9 -3
- package/src/check.ts +473 -100
- 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 +158 -49
- package/src/errors.ts +93 -3
- package/src/evaluate.ts +214 -147
- package/src/exit-codes.ts +21 -14
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +16 -15
- package/src/levels.ts +181 -45
- package/src/live-check.ts +132 -70
- package/src/liveness.ts +118 -24
- package/src/parallel-worker.ts +2 -2
- package/src/parallel.ts +5 -2
- package/src/parser.ts +71 -19
- package/src/resolve.ts +490 -95
- package/src/run-cli.ts +104 -18
- package/src/runtime.ts +2 -0
- 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/state-graph.ts +157 -0
- package/src/subexpressions.ts +35 -23
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +176 -36
- package/src/symmetry.ts +16 -6
- 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 +8 -4
- 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,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
|
}
|
|
@@ -192,6 +198,7 @@ export interface FunctionSetExpression {
|
|
|
192
198
|
export interface RecordField {
|
|
193
199
|
name: string;
|
|
194
200
|
value: Expression;
|
|
201
|
+
location: SourceLocation;
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
export interface RecordExpression {
|
|
@@ -280,6 +287,7 @@ export type Selector =
|
|
|
280
287
|
export interface SubexpressionExpression {
|
|
281
288
|
kind: "Subexpression";
|
|
282
289
|
selectors: Selector[];
|
|
290
|
+
selectorRanges?: SourceRange[];
|
|
283
291
|
location: SourceLocation;
|
|
284
292
|
}
|
|
285
293
|
|
|
@@ -442,12 +450,14 @@ export type StepBody =
|
|
|
442
450
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
443
451
|
| { kind: "Qed" };
|
|
444
452
|
|
|
445
|
-
// head is the range of the step number and its statement, without the proof
|
|
453
|
+
// head is the range of the step number and its statement, without the proof, and statement is the
|
|
454
|
+
// range of the statement alone.
|
|
446
455
|
export interface ProofStep {
|
|
447
456
|
name: string | undefined;
|
|
448
457
|
token: string;
|
|
449
458
|
body: StepBody;
|
|
450
459
|
head: SourceRange;
|
|
460
|
+
statement: SourceRange;
|
|
451
461
|
proof: Proof | undefined;
|
|
452
462
|
location: SourceLocation;
|
|
453
463
|
}
|
|
@@ -486,3 +496,93 @@ export interface Module {
|
|
|
486
496
|
uses: UseOrHide[];
|
|
487
497
|
units: ModuleUnit[];
|
|
488
498
|
}
|
|
499
|
+
|
|
500
|
+
export const getChildren = (expression: Expression): Expression[] => {
|
|
501
|
+
switch (expression.kind) {
|
|
502
|
+
case "Number":
|
|
503
|
+
case "Decimal":
|
|
504
|
+
case "String":
|
|
505
|
+
case "Identifier":
|
|
506
|
+
case "OperatorReference":
|
|
507
|
+
case "ExceptAt":
|
|
508
|
+
return [];
|
|
509
|
+
case "Apply":
|
|
510
|
+
return expression.args;
|
|
511
|
+
case "Lambda":
|
|
512
|
+
return [expression.body];
|
|
513
|
+
case "And":
|
|
514
|
+
case "Or":
|
|
515
|
+
return expression.operands;
|
|
516
|
+
case "Prime":
|
|
517
|
+
case "Unchanged":
|
|
518
|
+
case "Enabled":
|
|
519
|
+
case "Always":
|
|
520
|
+
case "Eventually":
|
|
521
|
+
return [expression.expression];
|
|
522
|
+
case "If":
|
|
523
|
+
return [expression.condition, expression.consequent, expression.alternative];
|
|
524
|
+
case "Case":
|
|
525
|
+
return [
|
|
526
|
+
...expression.arms.flatMap((arm) => [arm.condition, arm.body]),
|
|
527
|
+
...(expression.other ? [expression.other] : []),
|
|
528
|
+
];
|
|
529
|
+
case "Let":
|
|
530
|
+
return [
|
|
531
|
+
...expression.definitions.flatMap((definition) =>
|
|
532
|
+
definition.kind === "Function"
|
|
533
|
+
? [...definition.bounds.map((bound) => bound.set), definition.body]
|
|
534
|
+
: [definition.body],
|
|
535
|
+
),
|
|
536
|
+
expression.body,
|
|
537
|
+
];
|
|
538
|
+
case "Forall":
|
|
539
|
+
case "Exists":
|
|
540
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
541
|
+
case "UnboundedQuantifier":
|
|
542
|
+
return [expression.body];
|
|
543
|
+
case "Choose":
|
|
544
|
+
return [...(expression.set ? [expression.set] : []), expression.body];
|
|
545
|
+
case "SetEnumeration":
|
|
546
|
+
case "Tuple":
|
|
547
|
+
return expression.elements;
|
|
548
|
+
case "SetFilter":
|
|
549
|
+
return [expression.bound.set, expression.predicate];
|
|
550
|
+
case "SetMap":
|
|
551
|
+
return [expression.expression, ...expression.bounds.map((bound) => bound.set)];
|
|
552
|
+
case "FunctionConstruction":
|
|
553
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
554
|
+
case "FunctionSet":
|
|
555
|
+
return [expression.domain, expression.range];
|
|
556
|
+
case "Record":
|
|
557
|
+
case "RecordSet":
|
|
558
|
+
return expression.fields.map((field) => field.value);
|
|
559
|
+
case "Except":
|
|
560
|
+
return [
|
|
561
|
+
expression.function,
|
|
562
|
+
...expression.updates.flatMap((update) => [
|
|
563
|
+
...update.path.flatMap((step) => (step.kind === "Index" ? step.args : [])),
|
|
564
|
+
update.value,
|
|
565
|
+
]),
|
|
566
|
+
];
|
|
567
|
+
case "FunctionApplication":
|
|
568
|
+
return [expression.function, ...expression.args];
|
|
569
|
+
case "FieldAccess":
|
|
570
|
+
return [expression.record];
|
|
571
|
+
case "Product":
|
|
572
|
+
return expression.factors;
|
|
573
|
+
case "BoxAction":
|
|
574
|
+
case "AngleAction":
|
|
575
|
+
return [expression.action, expression.subscript];
|
|
576
|
+
case "WeakFairness":
|
|
577
|
+
case "StrongFairness":
|
|
578
|
+
return [expression.subscript, expression.action];
|
|
579
|
+
case "Label":
|
|
580
|
+
return [expression.body];
|
|
581
|
+
case "Subexpression":
|
|
582
|
+
return expression.selectors.flatMap((selector) => ("args" in selector ? selector.args : []));
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
export const isLocallyResolved = (expression: Expression) =>
|
|
587
|
+
(expression.kind === "Identifier" || expression.kind === "Apply") &&
|
|
588
|
+
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);
|