tla-ts 0.0.3-dev.d9ff6f2 → 0.0.3-dev.e8bef80

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 (81) hide show
  1. package/dist/cli.cjs +1 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.cts +166 -40
  5. package/dist/index.d.ts +166 -40
  6. package/dist/index.js +1 -1
  7. package/dist/parallel-worker.cjs +1 -1
  8. package/dist/parallel-worker.js +2 -2
  9. package/dist/parallel.cjs +1 -1
  10. package/dist/parallel.js +2 -2
  11. package/dist/run-cli.cjs +1351 -22
  12. package/dist/run-cli.js +1351 -22
  13. package/dist/transfer.cjs +83 -34
  14. package/dist/transfer.js +83 -34
  15. package/package.json +5 -1
  16. package/src/ast.ts +55 -7
  17. package/src/bags.ts +4 -7
  18. package/src/builtins.ts +29 -11
  19. package/src/bundled-modules.ts +3 -3
  20. package/src/canonical.ts +4 -3
  21. package/src/check.ts +1331 -367
  22. package/src/cli.ts +8 -1
  23. package/src/codegen.ts +68 -21
  24. package/src/config.ts +226 -207
  25. package/src/environment.ts +423 -127
  26. package/src/errors.ts +168 -9
  27. package/src/evaluate.ts +720 -177
  28. package/src/exit-codes.ts +6 -24
  29. package/src/index.ts +1 -0
  30. package/src/instances.ts +3 -1
  31. package/src/java-overrides.ts +104 -25
  32. package/src/levels.ts +149 -31
  33. package/src/lexer.ts +122 -29
  34. package/src/live-check.ts +204 -148
  35. package/src/liveness.ts +191 -122
  36. package/src/obligation-expression.ts +2 -2
  37. package/src/obligation-source.ts +2 -0
  38. package/src/parallel-worker.ts +6 -1
  39. package/src/parallel.ts +57 -6
  40. package/src/parser.ts +428 -141
  41. package/src/pcal-ast.ts +770 -0
  42. package/src/pcal-parse.ts +1523 -0
  43. package/src/pcal-tokenize.ts +516 -0
  44. package/src/pcal-translate.ts +1230 -0
  45. package/src/pcal-validate.ts +454 -0
  46. package/src/randomization.ts +24 -7
  47. package/src/resolve.ts +1436 -459
  48. package/src/run-cli.ts +1166 -181
  49. package/src/runtime.ts +16 -0
  50. package/src/sany-builtins.ts +147 -0
  51. package/src/sany-generator.ts +3128 -0
  52. package/src/sany-levels.ts +1208 -0
  53. package/src/sany-lexer.ts +545 -0
  54. package/src/sany-linter.ts +122 -0
  55. package/src/sany-modules.ts +1398 -0
  56. package/src/sany-nodes.ts +463 -0
  57. package/src/sany-parse-error.ts +2161 -0
  58. package/src/sany-report.ts +356 -0
  59. package/src/sany-selectors.ts +738 -0
  60. package/src/sany-source.ts +248 -0
  61. package/src/sany-xml.ts +1017 -0
  62. package/src/spec-description.ts +25 -5
  63. package/src/standard-modules.ts +203 -146
  64. package/src/standard-ranges.ts +116 -0
  65. package/src/state-graph.ts +29 -6
  66. package/src/subexpressions.ts +221 -161
  67. package/src/substitution-levels.ts +38 -17
  68. package/src/successors.ts +161 -167
  69. package/src/symmetry.ts +168 -50
  70. package/src/tableau.ts +3 -1
  71. package/src/tlc-ext.ts +13 -17
  72. package/src/tlc-messages.ts +329 -0
  73. package/src/tlc-module.ts +49 -21
  74. package/src/tlc-modules.ts +0 -4
  75. package/src/tlc-order.ts +55 -9
  76. package/src/tlc-random.ts +28 -3
  77. package/src/tlc-replay.ts +655 -0
  78. package/src/tlc-version.ts +18 -0
  79. package/src/transfer.ts +15 -3
  80. package/src/value-sources.ts +29 -0
  81. package/src/values.ts +680 -255
package/dist/cli.cjs CHANGED
@@ -7,4 +7,4 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- require("node:module").enableCompileCache?.(),Promise.resolve().then(()=>require("./run-cli.cjs")).then(e=>e.runCli());
10
+ let e=require("node:module"),t=require("node:path");const n=process.argv.find(e=>e.startsWith(`-Djava.io.tmpdir=`))?.slice(17);e.enableCompileCache?.(n&&(0,t.join)(n,`node-compile-cache`)),Promise.resolve().then(()=>require("./run-cli.cjs")).then(e=>e.runCli());
package/dist/cli.js CHANGED
@@ -7,4 +7,4 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- import{enableCompileCache as e}from"node:module";e?.(),import(`./run-cli.js`).then(e=>e.runCli());
10
+ import{enableCompileCache as e}from"node:module";import{join as t}from"node:path";const n=process.argv.find(e=>e.startsWith(`-Djava.io.tmpdir=`))?.slice(17);e?.(n&&t(n,`node-compile-cache`)),import(`./run-cli.js`).then(e=>e.runCli());
package/dist/index.cjs CHANGED
@@ -6,4 +6,4 @@
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./transfer.cjs"),t=require("./parallel.cjs");exports.TlaConfigError=e.M,exports.TlaError=e.N,exports.TlaEvaluationError=e.P,exports.TlaSyntaxError=e.I,exports.TlaUnsupportedError=e.L,exports.check=t.t,exports.formatValue=e.D,exports.parseConfig=e.A,exports.parseModule=e.b;
9
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./transfer.cjs"),t=require("./parallel.cjs");exports.TlaConfigError=e.at,exports.TlaError=e.ot,exports.TlaEvaluationError=e.st,exports.TlaSyntaxError=e.ft,exports.TlaUnsupportedError=e.pt,exports.check=t.t,exports.formatValue=e.q,exports.parseConfig=e.Z,exports.parseModule=e.w;
package/dist/index.d.cts CHANGED
@@ -38,33 +38,42 @@ interface StringExpression {
38
38
  interface IdentifierExpression {
39
39
  kind: "Identifier";
40
40
  name: string;
41
+ spelling?: string;
42
+ selectorRanges?: SourceRange[];
41
43
  location: SourceLocation;
42
44
  resolution?: LocalResolution;
43
45
  }
44
46
  interface ApplyExpression {
45
47
  kind: "Apply";
46
48
  operator: string;
49
+ spelling?: string;
47
50
  args: Expression[];
48
51
  argumentCounts?: number[];
49
52
  argumentsRange?: SourceRange;
53
+ selectorRanges?: SourceRange[];
54
+ argumentRanges?: (SourceRange | undefined)[];
50
55
  location: SourceLocation;
51
56
  resolution?: LocalResolution;
52
57
  }
53
58
  interface OperatorReferenceExpression {
54
59
  kind: "OperatorReference";
55
60
  operator: string;
61
+ spelling?: string;
56
62
  location: SourceLocation;
57
63
  }
58
64
  interface LambdaExpression {
59
65
  kind: "Lambda";
60
66
  params: string[];
67
+ paramRanges?: SourceRange[];
61
68
  body: Expression;
69
+ operator?: string;
62
70
  location: SourceLocation;
63
71
  }
64
72
  interface JunctionExpression {
65
73
  kind: "And" | "Or";
66
74
  operands: Expression[];
67
75
  isBulleted?: boolean;
76
+ prefixEnds?: SourceLocation[];
68
77
  location: SourceLocation;
69
78
  }
70
79
  interface PrimeExpression {
@@ -109,9 +118,11 @@ interface LetExpression {
109
118
  type BoundPattern = {
110
119
  kind: "Name";
111
120
  name: string;
121
+ ranges?: SourceRange[];
112
122
  } | {
113
123
  kind: "Tuple";
114
124
  names: string[];
125
+ ranges?: SourceRange[];
115
126
  };
116
127
  interface Bound {
117
128
  pattern: BoundPattern;
@@ -127,6 +138,7 @@ interface UnboundedQuantifierExpression {
127
138
  kind: "UnboundedQuantifier";
128
139
  quantifier: "Forall" | "Exists";
129
140
  names: string[];
141
+ nameRanges?: SourceRange[];
130
142
  isTemporal?: boolean;
131
143
  body: Expression;
132
144
  location: SourceLocation;
@@ -210,6 +222,11 @@ interface FunctionApplicationExpression {
210
222
  args: Expression[];
211
223
  location: SourceLocation;
212
224
  }
225
+ interface BracketExpression {
226
+ kind: "Bracket";
227
+ args: Expression[];
228
+ location: SourceLocation;
229
+ }
213
230
  interface FieldAccessExpression {
214
231
  kind: "FieldAccess";
215
232
  record: Expression;
@@ -243,6 +260,7 @@ interface LabelExpression {
243
260
  kind: "Label";
244
261
  name: string;
245
262
  params: string[];
263
+ paramRanges?: SourceRange[];
246
264
  body: Expression;
247
265
  location: SourceLocation;
248
266
  }
@@ -264,9 +282,11 @@ type Selector = {
264
282
  interface SubexpressionExpression {
265
283
  kind: "Subexpression";
266
284
  selectors: Selector[];
285
+ selectorRanges?: SourceRange[];
286
+ argumentRanges?: (SourceRange | undefined)[];
267
287
  location: SourceLocation;
268
288
  }
269
- type Expression = NumberExpression | DecimalExpression | StringExpression | IdentifierExpression | ApplyExpression | OperatorReferenceExpression | LambdaExpression | JunctionExpression | PrimeExpression | UnchangedExpression | EnabledExpression | IfExpression | CaseExpression | LetExpression | QuantifierExpression | UnboundedQuantifierExpression | ChooseExpression | SetEnumerationExpression | SetFilterExpression | SetMapExpression | TupleExpression | FunctionConstructionExpression | FunctionSetExpression | RecordExpression | ExceptExpression | ExceptAtExpression | FunctionApplicationExpression | FieldAccessExpression | ProductExpression | TemporalExpression | ActionExpression | FairnessExpression | LabelExpression | SubexpressionExpression;
289
+ type Expression = NumberExpression | DecimalExpression | StringExpression | IdentifierExpression | ApplyExpression | OperatorReferenceExpression | LambdaExpression | JunctionExpression | PrimeExpression | UnchangedExpression | EnabledExpression | IfExpression | CaseExpression | LetExpression | QuantifierExpression | UnboundedQuantifierExpression | ChooseExpression | SetEnumerationExpression | SetFilterExpression | SetMapExpression | TupleExpression | FunctionConstructionExpression | FunctionSetExpression | RecordExpression | ExceptExpression | ExceptAtExpression | FunctionApplicationExpression | BracketExpression | FieldAccessExpression | ProductExpression | TemporalExpression | ActionExpression | FairnessExpression | LabelExpression | SubexpressionExpression;
270
290
  interface OperatorParam {
271
291
  name: string;
272
292
  arity: number;
@@ -289,6 +309,7 @@ interface FunctionDefinition {
289
309
  body: Expression;
290
310
  isLocal: boolean;
291
311
  isRecursive: boolean;
312
+ isSelfReferential?: boolean;
292
313
  location: SourceLocation;
293
314
  }
294
315
  type Definition = OperatorDefinition | FunctionDefinition;
@@ -305,6 +326,7 @@ interface Assumption {
305
326
  }
306
327
  interface InstanceSubstitution {
307
328
  name: string;
329
+ nameRange: SourceRange;
308
330
  expression: Expression;
309
331
  }
310
332
  interface Instance {
@@ -324,6 +346,7 @@ interface NewSymbol {
324
346
  arity: number;
325
347
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
326
348
  set: Expression | undefined;
349
+ nameRange?: SourceRange;
327
350
  location: SourceLocation;
328
351
  }
329
352
  interface AssumeProve {
@@ -373,6 +396,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
373
396
  } | {
374
397
  kind: "Take";
375
398
  names: string[];
399
+ nameRanges?: SourceRange[];
376
400
  bounds: Bound[];
377
401
  } | {
378
402
  kind: "Witness";
@@ -380,6 +404,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
380
404
  } | {
381
405
  kind: "Pick";
382
406
  names: string[];
407
+ nameRanges?: SourceRange[];
383
408
  bounds: Bound[];
384
409
  body: Expression;
385
410
  } | {
@@ -397,6 +422,7 @@ interface ProofStep {
397
422
  token: string;
398
423
  body: StepBody;
399
424
  head: SourceRange;
425
+ statement: SourceRange;
400
426
  proof: Proof | undefined;
401
427
  location: SourceLocation;
402
428
  }
@@ -407,11 +433,9 @@ interface Theorem {
407
433
  location: SourceLocation;
408
434
  }
409
435
  type ModuleUnit = {
410
- kind: "Constants";
411
- declarations: Declaration[];
412
- } | {
413
- kind: "Variables";
436
+ kind: "Constants" | "Variables";
414
437
  declarations: Declaration[];
438
+ location: SourceLocation;
415
439
  } | {
416
440
  kind: "Recursive";
417
441
  declarations: Declaration[];
@@ -449,6 +473,7 @@ interface Module {
449
473
  uses: UseOrHide[];
450
474
  units: ModuleUnit[];
451
475
  }
476
+ type TlcVersion = "1.7.4" | "master";
452
477
  type ConfigValue = {
453
478
  kind: "Number";
454
479
  value: number;
@@ -495,7 +520,46 @@ interface ModelConfig {
495
520
  periodic: string | undefined;
496
521
  rlReward: string | undefined;
497
522
  }
498
- export declare const parseConfig: (source: string) => ModelConfig;
523
+ export declare const parseConfig: (source: string, version?: TlcVersion) => ModelConfig;
524
+ interface JavaOverride {
525
+ module: string;
526
+ operator: string;
527
+ signature: string;
528
+ isMatched: boolean;
529
+ }
530
+ export declare class TlaError extends Error {
531
+ constructor(message: string, cause?: unknown);
532
+ }
533
+ interface SyntaxFailure {
534
+ reason: string;
535
+ line: number;
536
+ column: number;
537
+ isEnd: boolean;
538
+ }
539
+ interface SanyError {
540
+ location: string;
541
+ message: string;
542
+ }
543
+ interface SanyReport {
544
+ errors: SanyError[];
545
+ warnings: SanyError[];
546
+ isFatal: boolean;
547
+ parseError?: string;
548
+ }
549
+ export declare class TlaSyntaxError extends TlaError {
550
+ failure: SyntaxFailure | undefined;
551
+ sany: SanyReport | undefined;
552
+ constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
553
+ }
554
+ export declare class TlaConfigError extends TlaError {
555
+ constructor(message: string, cause?: unknown);
556
+ }
557
+ export declare class TlaEvaluationError extends TlaError {
558
+ constructor(message: string, cause?: unknown);
559
+ }
560
+ export declare class TlaUnsupportedError extends TlaError {
561
+ constructor(message: string, cause?: unknown);
562
+ }
499
563
  interface ModelValue {
500
564
  kind: "ModelValue";
501
565
  name: string;
@@ -519,6 +583,7 @@ interface FunctionValue {
519
583
  hash: number;
520
584
  fingerprint: number;
521
585
  writtenKeys: Value[] | undefined;
586
+ functionClass: FunctionClass | undefined;
522
587
  }
523
588
  interface IntervalValue {
524
589
  kind: "Interval";
@@ -557,10 +622,15 @@ interface SetOperationValue {
557
622
  left: Value;
558
623
  right: Value;
559
624
  }
625
+ interface FilteredSetSource {
626
+ names: string;
627
+ predicate: string;
628
+ }
560
629
  interface FilteredSetValue {
561
630
  kind: "FilteredSet";
562
631
  base: Value;
563
632
  test: (element: Value) => boolean;
633
+ source?: FilteredSetSource;
564
634
  }
565
635
  interface UnionValue {
566
636
  kind: "Union";
@@ -579,39 +649,14 @@ interface LazyFunctionValue {
579
649
  domain: Value;
580
650
  apply: (argument: Value) => Value;
581
651
  source?: LazyFunctionSource;
652
+ functionClass?: FunctionClass;
582
653
  }
583
654
  type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
655
+ type FunctionClass = "lambda" | "tuple" | "record";
584
656
  export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
585
- export declare class TlaError extends Error {
586
- constructor(message: string, cause?: unknown);
587
- }
588
- interface SyntaxFailure {
657
+ interface FingerprintFailure {
658
+ sources: Expression[];
589
659
  reason: string;
590
- line: number;
591
- column: number;
592
- isEnd: boolean;
593
- }
594
- interface SanyError {
595
- location: string;
596
- message: string;
597
- }
598
- interface SanyReport {
599
- errors: SanyError[];
600
- isFatal: boolean;
601
- }
602
- export declare class TlaSyntaxError extends TlaError {
603
- failure: SyntaxFailure | undefined;
604
- sany: SanyReport | undefined;
605
- constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
606
- }
607
- export declare class TlaConfigError extends TlaError {
608
- constructor(message: string, cause?: unknown);
609
- }
610
- export declare class TlaEvaluationError extends TlaError {
611
- constructor(message: string, cause?: unknown);
612
- }
613
- export declare class TlaUnsupportedError extends TlaError {
614
- constructor(message: string, cause?: unknown);
615
660
  }
616
661
  interface StateDump {
617
662
  path: string;
@@ -633,38 +678,110 @@ interface CheckOptions {
633
678
  workers?: number;
634
679
  livenessCheck?: "default" | "final";
635
680
  dump?: StateDump;
681
+ isTool?: boolean;
682
+ isTraceRecorded?: boolean;
683
+ isSanyReported?: boolean;
684
+ isWarningEnabled?: boolean;
685
+ version?: TlcVersion;
686
+ onProgress?: (progress: CheckProgress) => void;
687
+ }
688
+ interface InitialStatesProgress {
689
+ kind: "initial-states-progress";
690
+ count: number;
691
+ }
692
+ interface InitialStateViolation {
693
+ kind: "initial-state-violation";
694
+ status: "invariant-violation" | "liveness-violation";
695
+ name: string;
696
+ state: Record<string, Value>;
636
697
  }
698
+ type OutputLine = string | InitialStatesProgress | InitialStateViolation;
699
+ type CheckProgress = {
700
+ kind: "parsed";
701
+ } | {
702
+ kind: "constant-level-invariant";
703
+ name: string;
704
+ } | {
705
+ kind: "state-level-property";
706
+ name: string;
707
+ } | {
708
+ kind: "liveness-initializing";
709
+ isSymmetric: boolean;
710
+ isConstrained: boolean;
711
+ } | {
712
+ kind: "liveness-prepared";
713
+ branches: number;
714
+ } | {
715
+ kind: "initial-states-started";
716
+ } | InitialStatesProgress | {
717
+ kind: "initial-states-computed";
718
+ initialStates: InitialStates;
719
+ } | {
720
+ kind: "progress";
721
+ statistics: SearchStatistics;
722
+ } | {
723
+ kind: "liveness-started";
724
+ branches: number;
725
+ isComplete: boolean;
726
+ states: number;
727
+ statistics: SearchStatistics;
728
+ } | {
729
+ kind: "liveness-finished";
730
+ } | {
731
+ kind: "warning";
732
+ code: number;
733
+ text: string;
734
+ } | ({
735
+ kind: "java-override";
736
+ } & JavaOverride);
737
+ interface SearchStatistics extends Pick<CheckResult, "generatedStates" | "distinctStates" | "queuedStates" | "depth"> {}
637
738
  type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
638
739
  interface TraceStep {
639
740
  action: string | undefined;
640
741
  label: string | undefined;
641
742
  state: Record<string, Value>;
743
+ output?: OutputLine[];
642
744
  }
643
745
  interface Violation {
644
746
  name: string;
645
747
  properties?: string[];
646
748
  trace: TraceStep[];
749
+ traceOutput?: OutputLine[];
647
750
  loopStart: number | undefined;
648
751
  loopLabel?: string;
649
752
  message?: string;
650
753
  counts?: string;
651
754
  unwitnessed?: Postcondition;
755
+ postcondition?: Postcondition;
756
+ warning?: {
757
+ code: number;
758
+ text: string;
759
+ };
652
760
  }
653
761
  interface Postcondition {
654
762
  name: string;
763
+ code: number;
655
764
  message: string;
656
765
  counts?: string;
657
766
  }
658
767
  interface EvaluationFailure {
768
+ code: number;
659
769
  message: string;
770
+ toolMessage: string;
660
771
  trace: TraceStep[];
772
+ traceOutput?: OutputLine[];
661
773
  initialState: Record<string, Value> | undefined;
662
774
  exitCode: number;
663
- replay?: Replay;
775
+ callStack: Expression[] | undefined;
776
+ isCallStackFirst?: boolean;
777
+ fingerprint?: FingerprintFailure;
778
+ traceFailure?: FailureMessage;
779
+ postcondition?: Postcondition;
780
+ isWithoutStatistics?: boolean;
664
781
  }
665
- interface Replay {
666
- output: string[];
667
- callStack: string[] | undefined;
782
+ interface InitialStates {
783
+ generated: number;
784
+ distinct: number;
668
785
  }
669
786
  interface CheckResult {
670
787
  status: CheckStatus;
@@ -674,9 +791,18 @@ interface CheckResult {
674
791
  distinctStates: number;
675
792
  queuedStates: number;
676
793
  depth: number;
794
+ initialStates: InitialStates | undefined;
677
795
  outDegrees: number[] | undefined;
678
796
  fingerprintDistance: bigint | undefined;
797
+ additionalViolation?: Violation;
798
+ liveCallStack?: Expression[];
799
+ violationOutDegrees?: number[];
800
+ }
801
+ interface FailureMessage {
802
+ code: number;
803
+ message: string;
804
+ toolMessage: string;
679
805
  }
680
806
  export declare const check: (options: CheckOptions) => Promise<CheckResult>;
681
807
  export declare const parseModule: (source: string) => Module;
682
- export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
808
+ export type { CheckOptions, CheckProgress, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };