tla-ts 0.0.2 → 0.0.3-dev.14337b3
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 +78 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +85 -15
- package/dist/index.d.ts +85 -15
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +2 -2
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +22 -2
- package/dist/run-cli.js +22 -2
- package/dist/transfer.cjs +37 -16
- package/dist/transfer.js +37 -16
- package/package.json +3 -1
- package/src/ast.ts +137 -4
- package/src/check.ts +378 -100
- package/src/cli-options.ts +64 -0
- package/src/codegen.ts +15 -22
- package/src/config.ts +224 -170
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +116 -28
- package/src/errors.ts +101 -3
- package/src/evaluate.ts +129 -153
- package/src/exit-codes.ts +39 -42
- package/src/fingerprints.ts +46 -11
- package/src/instances.ts +16 -15
- package/src/levels.ts +62 -34
- package/src/lexer.ts +11 -2
- package/src/live-check.ts +772 -0
- package/src/liveness.ts +116 -543
- package/src/obligation-action.ts +384 -0
- package/src/obligation-anon.ts +575 -0
- package/src/obligation-deref.ts +637 -0
- package/src/obligation-expression.ts +1060 -0
- package/src/obligation-format.ts +406 -0
- package/src/obligation-generate.ts +1074 -0
- package/src/obligation-levels.ts +329 -0
- package/src/obligation-module.ts +1042 -0
- package/src/obligation-printer.ts +889 -0
- package/src/obligation-proof.ts +76 -0
- package/src/obligation-source.ts +1084 -0
- package/src/obligation-tuples.ts +184 -0
- package/src/obligations.ts +316 -0
- package/src/parallel-worker.ts +168 -212
- package/src/parallel.ts +78 -37
- package/src/parser.ts +315 -60
- package/src/resolve.ts +122 -44
- package/src/run-cli.ts +376 -44
- package/src/runtime.ts +3 -1
- package/src/spec-description.ts +19 -8
- package/src/standard-levels.ts +3 -3
- package/src/standard-modules.ts +2 -7
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +10 -10
- package/src/successors.ts +99 -25
- package/src/symmetry.ts +30 -8
- 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/transfer.ts +22 -1
- package/src/values.ts +179 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tla-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-dev.14337b3",
|
|
4
4
|
"description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formal verification",
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
"conformance:sany": "tsx scripts/proof-conformance.ts",
|
|
72
72
|
"conformance:record": "tsx scripts/record-tlc.ts",
|
|
73
73
|
"conformance:record-sany": "tsx scripts/record-sany.ts",
|
|
74
|
+
"conformance:record-tlapm": "tsx scripts/record-tlapm.ts",
|
|
75
|
+
"conformance:tlapm": "tsx scripts/tlapm-conformance.ts",
|
|
74
76
|
"publint": "publint",
|
|
75
77
|
"test": "vp test",
|
|
76
78
|
"typecheck": "tsc --noEmit"
|
package/src/ast.ts
CHANGED
|
@@ -44,6 +44,11 @@ export interface ApplyExpression {
|
|
|
44
44
|
kind: "Apply";
|
|
45
45
|
operator: string;
|
|
46
46
|
args: Expression[];
|
|
47
|
+
// The number of args each part of a name like F(x)!l(y) takes, when a part before the last takes
|
|
48
|
+
// some.
|
|
49
|
+
argumentCounts?: number[];
|
|
50
|
+
// The range of the parenthesized arguments of a named operator, where SANY reports their count.
|
|
51
|
+
argumentsRange?: SourceRange;
|
|
47
52
|
location: SourceLocation;
|
|
48
53
|
resolution?: LocalResolution;
|
|
49
54
|
}
|
|
@@ -64,6 +69,7 @@ export interface LambdaExpression {
|
|
|
64
69
|
export interface JunctionExpression {
|
|
65
70
|
kind: "And" | "Or";
|
|
66
71
|
operands: Expression[];
|
|
72
|
+
isBulleted?: boolean;
|
|
67
73
|
location: SourceLocation;
|
|
68
74
|
}
|
|
69
75
|
|
|
@@ -129,6 +135,7 @@ export interface QuantifierExpression {
|
|
|
129
135
|
|
|
130
136
|
export interface UnboundedQuantifierExpression {
|
|
131
137
|
kind: "UnboundedQuantifier";
|
|
138
|
+
quantifier: "Forall" | "Exists";
|
|
132
139
|
names: string[];
|
|
133
140
|
isTemporal?: boolean;
|
|
134
141
|
body: Expression;
|
|
@@ -187,6 +194,7 @@ export interface FunctionSetExpression {
|
|
|
187
194
|
export interface RecordField {
|
|
188
195
|
name: string;
|
|
189
196
|
value: Expression;
|
|
197
|
+
location: SourceLocation;
|
|
190
198
|
}
|
|
191
199
|
|
|
192
200
|
export interface RecordExpression {
|
|
@@ -317,6 +325,7 @@ export type Expression =
|
|
|
317
325
|
export interface OperatorParam {
|
|
318
326
|
name: string;
|
|
319
327
|
arity: number;
|
|
328
|
+
location?: SourceLocation;
|
|
320
329
|
}
|
|
321
330
|
|
|
322
331
|
export interface OperatorDefinition {
|
|
@@ -368,6 +377,8 @@ export interface Instance {
|
|
|
368
377
|
substitutions: InstanceSubstitution[];
|
|
369
378
|
isLocal: boolean;
|
|
370
379
|
location: SourceLocation;
|
|
380
|
+
instanceRange: SourceRange;
|
|
381
|
+
definitionRange?: SourceRange;
|
|
371
382
|
}
|
|
372
383
|
|
|
373
384
|
export interface NewSymbol {
|
|
@@ -388,18 +399,33 @@ export interface AssumeProve {
|
|
|
388
399
|
|
|
389
400
|
export type Fact = Expression | { kind: "ModuleFact"; name: string; location: SourceLocation };
|
|
390
401
|
|
|
402
|
+
// keyword is the range of the USE or HIDE token and any ONLY after it.
|
|
391
403
|
export interface UseOrHide {
|
|
392
404
|
kind: "Use" | "Hide";
|
|
393
405
|
isOnly: boolean;
|
|
394
406
|
facts: Fact[];
|
|
395
407
|
defs: Fact[];
|
|
408
|
+
keyword: SourceRange;
|
|
396
409
|
location: SourceLocation;
|
|
397
410
|
}
|
|
398
411
|
|
|
412
|
+
// keyword is the range of the BY, OBVIOUS, or OMITTED token.
|
|
399
413
|
export type Proof =
|
|
400
|
-
| { kind: "Obvious" | "Omitted"; location: SourceLocation }
|
|
401
|
-
| {
|
|
402
|
-
|
|
414
|
+
| { kind: "Obvious" | "Omitted"; keyword: SourceRange; location: SourceLocation }
|
|
415
|
+
| {
|
|
416
|
+
kind: "By";
|
|
417
|
+
isOnly: boolean;
|
|
418
|
+
facts: Fact[];
|
|
419
|
+
defs: Fact[];
|
|
420
|
+
keyword: SourceRange;
|
|
421
|
+
location: SourceLocation;
|
|
422
|
+
}
|
|
423
|
+
| {
|
|
424
|
+
kind: "Steps";
|
|
425
|
+
level: number;
|
|
426
|
+
steps: ProofStep[];
|
|
427
|
+
location: SourceLocation;
|
|
428
|
+
};
|
|
403
429
|
|
|
404
430
|
export interface DefineStep {
|
|
405
431
|
kind: "Define";
|
|
@@ -419,9 +445,12 @@ export type StepBody =
|
|
|
419
445
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
420
446
|
| { kind: "Qed" };
|
|
421
447
|
|
|
448
|
+
// head is the range of the step number and its statement, without the proof.
|
|
422
449
|
export interface ProofStep {
|
|
423
450
|
name: string | undefined;
|
|
451
|
+
token: string;
|
|
424
452
|
body: StepBody;
|
|
453
|
+
head: SourceRange;
|
|
425
454
|
proof: Proof | undefined;
|
|
426
455
|
location: SourceLocation;
|
|
427
456
|
}
|
|
@@ -433,10 +462,23 @@ export interface Theorem {
|
|
|
433
462
|
location: SourceLocation;
|
|
434
463
|
}
|
|
435
464
|
|
|
465
|
+
// The units of a module in source order, for consumers that need the order across kinds.
|
|
466
|
+
export type ModuleUnit =
|
|
467
|
+
| { kind: "Constants"; declarations: Declaration[] }
|
|
468
|
+
| { kind: "Variables"; declarations: Declaration[] }
|
|
469
|
+
| { kind: "Recursive"; declarations: Declaration[] }
|
|
470
|
+
| { kind: "Definition"; definition: Definition }
|
|
471
|
+
| { kind: "Instance"; instance: Instance }
|
|
472
|
+
| { kind: "Assumption"; assumption: Assumption }
|
|
473
|
+
| { kind: "Theorem"; theorem: Theorem }
|
|
474
|
+
| { kind: "Use"; use: UseOrHide }
|
|
475
|
+
| { kind: "Module"; module: Module };
|
|
476
|
+
|
|
436
477
|
export interface Module {
|
|
437
478
|
name: string;
|
|
438
479
|
modules: Module[];
|
|
439
480
|
extends: string[];
|
|
481
|
+
extendsRanges: SourceRange[];
|
|
440
482
|
constants: Declaration[];
|
|
441
483
|
variables: Declaration[];
|
|
442
484
|
definitions: Definition[];
|
|
@@ -445,4 +487,95 @@ export interface Module {
|
|
|
445
487
|
location: SourceLocation;
|
|
446
488
|
theorems: Theorem[];
|
|
447
489
|
uses: UseOrHide[];
|
|
448
|
-
|
|
490
|
+
units: ModuleUnit[];
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export const getChildren = (expression: Expression): Expression[] => {
|
|
494
|
+
switch (expression.kind) {
|
|
495
|
+
case "Number":
|
|
496
|
+
case "Decimal":
|
|
497
|
+
case "String":
|
|
498
|
+
case "Identifier":
|
|
499
|
+
case "OperatorReference":
|
|
500
|
+
case "ExceptAt":
|
|
501
|
+
return [];
|
|
502
|
+
case "Apply":
|
|
503
|
+
return expression.args;
|
|
504
|
+
case "Lambda":
|
|
505
|
+
return [expression.body];
|
|
506
|
+
case "And":
|
|
507
|
+
case "Or":
|
|
508
|
+
return expression.operands;
|
|
509
|
+
case "Prime":
|
|
510
|
+
case "Unchanged":
|
|
511
|
+
case "Enabled":
|
|
512
|
+
case "Always":
|
|
513
|
+
case "Eventually":
|
|
514
|
+
return [expression.expression];
|
|
515
|
+
case "If":
|
|
516
|
+
return [expression.condition, expression.consequent, expression.alternative];
|
|
517
|
+
case "Case":
|
|
518
|
+
return [
|
|
519
|
+
...expression.arms.flatMap((arm) => [arm.condition, arm.body]),
|
|
520
|
+
...(expression.other ? [expression.other] : []),
|
|
521
|
+
];
|
|
522
|
+
case "Let":
|
|
523
|
+
return [
|
|
524
|
+
...expression.definitions.flatMap((definition) =>
|
|
525
|
+
definition.kind === "Function"
|
|
526
|
+
? [...definition.bounds.map((bound) => bound.set), definition.body]
|
|
527
|
+
: [definition.body],
|
|
528
|
+
),
|
|
529
|
+
expression.body,
|
|
530
|
+
];
|
|
531
|
+
case "Forall":
|
|
532
|
+
case "Exists":
|
|
533
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
534
|
+
case "UnboundedQuantifier":
|
|
535
|
+
return [expression.body];
|
|
536
|
+
case "Choose":
|
|
537
|
+
return [...(expression.set ? [expression.set] : []), expression.body];
|
|
538
|
+
case "SetEnumeration":
|
|
539
|
+
case "Tuple":
|
|
540
|
+
return expression.elements;
|
|
541
|
+
case "SetFilter":
|
|
542
|
+
return [expression.bound.set, expression.predicate];
|
|
543
|
+
case "SetMap":
|
|
544
|
+
return [expression.expression, ...expression.bounds.map((bound) => bound.set)];
|
|
545
|
+
case "FunctionConstruction":
|
|
546
|
+
return [...expression.bounds.map((bound) => bound.set), expression.body];
|
|
547
|
+
case "FunctionSet":
|
|
548
|
+
return [expression.domain, expression.range];
|
|
549
|
+
case "Record":
|
|
550
|
+
case "RecordSet":
|
|
551
|
+
return expression.fields.map((field) => field.value);
|
|
552
|
+
case "Except":
|
|
553
|
+
return [
|
|
554
|
+
expression.function,
|
|
555
|
+
...expression.updates.flatMap((update) => [
|
|
556
|
+
...update.path.flatMap((step) => (step.kind === "Index" ? step.args : [])),
|
|
557
|
+
update.value,
|
|
558
|
+
]),
|
|
559
|
+
];
|
|
560
|
+
case "FunctionApplication":
|
|
561
|
+
return [expression.function, ...expression.args];
|
|
562
|
+
case "FieldAccess":
|
|
563
|
+
return [expression.record];
|
|
564
|
+
case "Product":
|
|
565
|
+
return expression.factors;
|
|
566
|
+
case "BoxAction":
|
|
567
|
+
case "AngleAction":
|
|
568
|
+
return [expression.action, expression.subscript];
|
|
569
|
+
case "WeakFairness":
|
|
570
|
+
case "StrongFairness":
|
|
571
|
+
return [expression.subscript, expression.action];
|
|
572
|
+
case "Label":
|
|
573
|
+
return [expression.body];
|
|
574
|
+
case "Subexpression":
|
|
575
|
+
return expression.selectors.flatMap((selector) => ("args" in selector ? selector.args : []));
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
export const isLocallyResolved = (expression: Expression) =>
|
|
580
|
+
(expression.kind === "Identifier" || expression.kind === "Apply") &&
|
|
581
|
+
expression.resolution?.kind === "Local";
|