tla-ts 0.0.3-dev.4cf9a33 → 0.0.3-dev.4fdd845

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 +164 -40
  5. package/dist/index.d.ts +164 -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 +49 -6
  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 +225 -206
  25. package/src/environment.ts +417 -124
  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 +32 -4
  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 +419 -122
  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 +1334 -452
  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 +3112 -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 +354 -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 +683 -256
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,26 +38,32 @@ interface StringExpression {
38
38
  interface IdentifierExpression {
39
39
  kind: "Identifier";
40
40
  name: string;
41
+ selectorRanges?: SourceRange[];
41
42
  location: SourceLocation;
42
43
  resolution?: LocalResolution;
43
44
  }
44
45
  interface ApplyExpression {
45
46
  kind: "Apply";
46
47
  operator: string;
48
+ spelling?: string;
47
49
  args: Expression[];
48
50
  argumentCounts?: number[];
49
51
  argumentsRange?: SourceRange;
52
+ selectorRanges?: SourceRange[];
53
+ argumentRanges?: (SourceRange | undefined)[];
50
54
  location: SourceLocation;
51
55
  resolution?: LocalResolution;
52
56
  }
53
57
  interface OperatorReferenceExpression {
54
58
  kind: "OperatorReference";
55
59
  operator: string;
60
+ spelling?: string;
56
61
  location: SourceLocation;
57
62
  }
58
63
  interface LambdaExpression {
59
64
  kind: "Lambda";
60
65
  params: string[];
66
+ paramRanges?: SourceRange[];
61
67
  body: Expression;
62
68
  location: SourceLocation;
63
69
  }
@@ -65,6 +71,7 @@ interface JunctionExpression {
65
71
  kind: "And" | "Or";
66
72
  operands: Expression[];
67
73
  isBulleted?: boolean;
74
+ prefixEnds?: SourceLocation[];
68
75
  location: SourceLocation;
69
76
  }
70
77
  interface PrimeExpression {
@@ -109,9 +116,11 @@ interface LetExpression {
109
116
  type BoundPattern = {
110
117
  kind: "Name";
111
118
  name: string;
119
+ ranges?: SourceRange[];
112
120
  } | {
113
121
  kind: "Tuple";
114
122
  names: string[];
123
+ ranges?: SourceRange[];
115
124
  };
116
125
  interface Bound {
117
126
  pattern: BoundPattern;
@@ -127,6 +136,7 @@ interface UnboundedQuantifierExpression {
127
136
  kind: "UnboundedQuantifier";
128
137
  quantifier: "Forall" | "Exists";
129
138
  names: string[];
139
+ nameRanges?: SourceRange[];
130
140
  isTemporal?: boolean;
131
141
  body: Expression;
132
142
  location: SourceLocation;
@@ -210,6 +220,11 @@ interface FunctionApplicationExpression {
210
220
  args: Expression[];
211
221
  location: SourceLocation;
212
222
  }
223
+ interface BracketExpression {
224
+ kind: "Bracket";
225
+ args: Expression[];
226
+ location: SourceLocation;
227
+ }
213
228
  interface FieldAccessExpression {
214
229
  kind: "FieldAccess";
215
230
  record: Expression;
@@ -243,6 +258,7 @@ interface LabelExpression {
243
258
  kind: "Label";
244
259
  name: string;
245
260
  params: string[];
261
+ paramRanges?: SourceRange[];
246
262
  body: Expression;
247
263
  location: SourceLocation;
248
264
  }
@@ -264,9 +280,11 @@ type Selector = {
264
280
  interface SubexpressionExpression {
265
281
  kind: "Subexpression";
266
282
  selectors: Selector[];
283
+ selectorRanges?: SourceRange[];
284
+ argumentRanges?: (SourceRange | undefined)[];
267
285
  location: SourceLocation;
268
286
  }
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;
287
+ 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
288
  interface OperatorParam {
271
289
  name: string;
272
290
  arity: number;
@@ -289,6 +307,7 @@ interface FunctionDefinition {
289
307
  body: Expression;
290
308
  isLocal: boolean;
291
309
  isRecursive: boolean;
310
+ isSelfReferential?: boolean;
292
311
  location: SourceLocation;
293
312
  }
294
313
  type Definition = OperatorDefinition | FunctionDefinition;
@@ -305,6 +324,7 @@ interface Assumption {
305
324
  }
306
325
  interface InstanceSubstitution {
307
326
  name: string;
327
+ nameRange: SourceRange;
308
328
  expression: Expression;
309
329
  }
310
330
  interface Instance {
@@ -324,6 +344,7 @@ interface NewSymbol {
324
344
  arity: number;
325
345
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
326
346
  set: Expression | undefined;
347
+ nameRange?: SourceRange;
327
348
  location: SourceLocation;
328
349
  }
329
350
  interface AssumeProve {
@@ -373,6 +394,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
373
394
  } | {
374
395
  kind: "Take";
375
396
  names: string[];
397
+ nameRanges?: SourceRange[];
376
398
  bounds: Bound[];
377
399
  } | {
378
400
  kind: "Witness";
@@ -380,6 +402,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
380
402
  } | {
381
403
  kind: "Pick";
382
404
  names: string[];
405
+ nameRanges?: SourceRange[];
383
406
  bounds: Bound[];
384
407
  body: Expression;
385
408
  } | {
@@ -397,6 +420,7 @@ interface ProofStep {
397
420
  token: string;
398
421
  body: StepBody;
399
422
  head: SourceRange;
423
+ statement: SourceRange;
400
424
  proof: Proof | undefined;
401
425
  location: SourceLocation;
402
426
  }
@@ -407,11 +431,9 @@ interface Theorem {
407
431
  location: SourceLocation;
408
432
  }
409
433
  type ModuleUnit = {
410
- kind: "Constants";
411
- declarations: Declaration[];
412
- } | {
413
- kind: "Variables";
434
+ kind: "Constants" | "Variables";
414
435
  declarations: Declaration[];
436
+ location: SourceLocation;
415
437
  } | {
416
438
  kind: "Recursive";
417
439
  declarations: Declaration[];
@@ -449,6 +471,7 @@ interface Module {
449
471
  uses: UseOrHide[];
450
472
  units: ModuleUnit[];
451
473
  }
474
+ type TlcVersion = "1.7.4" | "master";
452
475
  type ConfigValue = {
453
476
  kind: "Number";
454
477
  value: number;
@@ -495,7 +518,46 @@ interface ModelConfig {
495
518
  periodic: string | undefined;
496
519
  rlReward: string | undefined;
497
520
  }
498
- export declare const parseConfig: (source: string) => ModelConfig;
521
+ export declare const parseConfig: (source: string, version?: TlcVersion) => ModelConfig;
522
+ interface JavaOverride {
523
+ module: string;
524
+ operator: string;
525
+ signature: string;
526
+ isMatched: boolean;
527
+ }
528
+ export declare class TlaError extends Error {
529
+ constructor(message: string, cause?: unknown);
530
+ }
531
+ interface SyntaxFailure {
532
+ reason: string;
533
+ line: number;
534
+ column: number;
535
+ isEnd: boolean;
536
+ }
537
+ interface SanyError {
538
+ location: string;
539
+ message: string;
540
+ }
541
+ interface SanyReport {
542
+ errors: SanyError[];
543
+ warnings: SanyError[];
544
+ isFatal: boolean;
545
+ parseError?: string;
546
+ }
547
+ export declare class TlaSyntaxError extends TlaError {
548
+ failure: SyntaxFailure | undefined;
549
+ sany: SanyReport | undefined;
550
+ constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
551
+ }
552
+ export declare class TlaConfigError extends TlaError {
553
+ constructor(message: string, cause?: unknown);
554
+ }
555
+ export declare class TlaEvaluationError extends TlaError {
556
+ constructor(message: string, cause?: unknown);
557
+ }
558
+ export declare class TlaUnsupportedError extends TlaError {
559
+ constructor(message: string, cause?: unknown);
560
+ }
499
561
  interface ModelValue {
500
562
  kind: "ModelValue";
501
563
  name: string;
@@ -519,6 +581,7 @@ interface FunctionValue {
519
581
  hash: number;
520
582
  fingerprint: number;
521
583
  writtenKeys: Value[] | undefined;
584
+ functionClass: FunctionClass | undefined;
522
585
  }
523
586
  interface IntervalValue {
524
587
  kind: "Interval";
@@ -557,10 +620,15 @@ interface SetOperationValue {
557
620
  left: Value;
558
621
  right: Value;
559
622
  }
623
+ interface FilteredSetSource {
624
+ names: string;
625
+ predicate: string;
626
+ }
560
627
  interface FilteredSetValue {
561
628
  kind: "FilteredSet";
562
629
  base: Value;
563
630
  test: (element: Value) => boolean;
631
+ source?: FilteredSetSource;
564
632
  }
565
633
  interface UnionValue {
566
634
  kind: "Union";
@@ -579,39 +647,14 @@ interface LazyFunctionValue {
579
647
  domain: Value;
580
648
  apply: (argument: Value) => Value;
581
649
  source?: LazyFunctionSource;
650
+ functionClass?: FunctionClass;
582
651
  }
583
652
  type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
653
+ type FunctionClass = "lambda" | "tuple" | "record";
584
654
  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 {
655
+ interface FingerprintFailure {
656
+ sources: Expression[];
589
657
  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
658
  }
616
659
  interface StateDump {
617
660
  path: string;
@@ -633,38 +676,110 @@ interface CheckOptions {
633
676
  workers?: number;
634
677
  livenessCheck?: "default" | "final";
635
678
  dump?: StateDump;
679
+ isTool?: boolean;
680
+ isTraceRecorded?: boolean;
681
+ isSanyReported?: boolean;
682
+ isWarningEnabled?: boolean;
683
+ version?: TlcVersion;
684
+ onProgress?: (progress: CheckProgress) => void;
685
+ }
686
+ interface InitialStatesProgress {
687
+ kind: "initial-states-progress";
688
+ count: number;
689
+ }
690
+ interface InitialStateViolation {
691
+ kind: "initial-state-violation";
692
+ status: "invariant-violation" | "liveness-violation";
693
+ name: string;
694
+ state: Record<string, Value>;
636
695
  }
696
+ type OutputLine = string | InitialStatesProgress | InitialStateViolation;
697
+ type CheckProgress = {
698
+ kind: "parsed";
699
+ } | {
700
+ kind: "constant-level-invariant";
701
+ name: string;
702
+ } | {
703
+ kind: "state-level-property";
704
+ name: string;
705
+ } | {
706
+ kind: "liveness-initializing";
707
+ isSymmetric: boolean;
708
+ isConstrained: boolean;
709
+ } | {
710
+ kind: "liveness-prepared";
711
+ branches: number;
712
+ } | {
713
+ kind: "initial-states-started";
714
+ } | InitialStatesProgress | {
715
+ kind: "initial-states-computed";
716
+ initialStates: InitialStates;
717
+ } | {
718
+ kind: "progress";
719
+ statistics: SearchStatistics;
720
+ } | {
721
+ kind: "liveness-started";
722
+ branches: number;
723
+ isComplete: boolean;
724
+ states: number;
725
+ statistics: SearchStatistics;
726
+ } | {
727
+ kind: "liveness-finished";
728
+ } | {
729
+ kind: "warning";
730
+ code: number;
731
+ text: string;
732
+ } | ({
733
+ kind: "java-override";
734
+ } & JavaOverride);
735
+ interface SearchStatistics extends Pick<CheckResult, "generatedStates" | "distinctStates" | "queuedStates" | "depth"> {}
637
736
  type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
638
737
  interface TraceStep {
639
738
  action: string | undefined;
640
739
  label: string | undefined;
641
740
  state: Record<string, Value>;
741
+ output?: OutputLine[];
642
742
  }
643
743
  interface Violation {
644
744
  name: string;
645
745
  properties?: string[];
646
746
  trace: TraceStep[];
747
+ traceOutput?: OutputLine[];
647
748
  loopStart: number | undefined;
648
749
  loopLabel?: string;
649
750
  message?: string;
650
751
  counts?: string;
651
752
  unwitnessed?: Postcondition;
753
+ postcondition?: Postcondition;
754
+ warning?: {
755
+ code: number;
756
+ text: string;
757
+ };
652
758
  }
653
759
  interface Postcondition {
654
760
  name: string;
761
+ code: number;
655
762
  message: string;
656
763
  counts?: string;
657
764
  }
658
765
  interface EvaluationFailure {
766
+ code: number;
659
767
  message: string;
768
+ toolMessage: string;
660
769
  trace: TraceStep[];
770
+ traceOutput?: OutputLine[];
661
771
  initialState: Record<string, Value> | undefined;
662
772
  exitCode: number;
663
- replay?: Replay;
773
+ callStack: Expression[] | undefined;
774
+ isCallStackFirst?: boolean;
775
+ fingerprint?: FingerprintFailure;
776
+ traceFailure?: FailureMessage;
777
+ postcondition?: Postcondition;
778
+ isWithoutStatistics?: boolean;
664
779
  }
665
- interface Replay {
666
- output: string[];
667
- callStack: string[] | undefined;
780
+ interface InitialStates {
781
+ generated: number;
782
+ distinct: number;
668
783
  }
669
784
  interface CheckResult {
670
785
  status: CheckStatus;
@@ -674,9 +789,18 @@ interface CheckResult {
674
789
  distinctStates: number;
675
790
  queuedStates: number;
676
791
  depth: number;
792
+ initialStates: InitialStates | undefined;
677
793
  outDegrees: number[] | undefined;
678
794
  fingerprintDistance: bigint | undefined;
795
+ additionalViolation?: Violation;
796
+ liveCallStack?: Expression[];
797
+ violationOutDegrees?: number[];
798
+ }
799
+ interface FailureMessage {
800
+ code: number;
801
+ message: string;
802
+ toolMessage: string;
679
803
  }
680
804
  export declare const check: (options: CheckOptions) => Promise<CheckResult>;
681
805
  export declare const parseModule: (source: string) => Module;
682
- export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
806
+ export type { CheckOptions, CheckProgress, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };