tla-ts 0.0.3-dev.3ce2f00 → 0.0.3-dev.3ef4193

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