tla-ts 0.0.3-dev.974cfcb → 0.0.3-dev.9b15ea6

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 (80) 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 +146 -8
  5. package/dist/index.d.ts +146 -8
  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 -20
  12. package/dist/run-cli.js +1351 -20
  13. package/dist/transfer.cjs +86 -28
  14. package/dist/transfer.js +86 -28
  15. package/package.json +5 -1
  16. package/src/ast.ts +48 -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 +1352 -215
  22. package/src/cli.ts +8 -1
  23. package/src/codegen.ts +68 -18
  24. package/src/config.ts +252 -179
  25. package/src/environment.ts +451 -129
  26. package/src/errors.ts +217 -3
  27. package/src/evaluate.ts +724 -117
  28. package/src/exit-codes.ts +5 -4
  29. package/src/index.ts +1 -0
  30. package/src/instances.ts +4 -2
  31. package/src/java-overrides.ts +104 -25
  32. package/src/levels.ts +183 -37
  33. package/src/lexer.ts +14 -1
  34. package/src/live-check.ts +212 -124
  35. package/src/liveness.ts +192 -65
  36. package/src/obligation-expression.ts +2 -2
  37. package/src/obligation-source.ts +2 -0
  38. package/src/parallel-worker.ts +8 -3
  39. package/src/parallel.ts +56 -5
  40. package/src/parser.ts +423 -126
  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 +1363 -405
  48. package/src/run-cli.ts +1167 -155
  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 +26 -7
  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 +162 -114
  69. package/src/symmetry.ts +180 -52
  70. package/src/tableau.ts +4 -2
  71. package/src/tlc-ext.ts +13 -17
  72. package/src/tlc-messages.ts +329 -0
  73. package/src/tlc-module.ts +46 -18
  74. package/src/tlc-order.ts +56 -6
  75. package/src/tlc-random.ts +28 -3
  76. package/src/tlc-replay.ts +655 -0
  77. package/src/tlc-version.ts +18 -0
  78. package/src/transfer.ts +15 -3
  79. package/src/value-sources.ts +29 -0
  80. package/src/values.ts +684 -204
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,6 +38,7 @@ 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
  }
@@ -46,6 +47,9 @@ interface ApplyExpression {
46
47
  operator: string;
47
48
  args: Expression[];
48
49
  argumentCounts?: number[];
50
+ argumentsRange?: SourceRange;
51
+ selectorRanges?: SourceRange[];
52
+ argumentRanges?: (SourceRange | undefined)[];
49
53
  location: SourceLocation;
50
54
  resolution?: LocalResolution;
51
55
  }
@@ -57,6 +61,7 @@ interface OperatorReferenceExpression {
57
61
  interface LambdaExpression {
58
62
  kind: "Lambda";
59
63
  params: string[];
64
+ paramRanges?: SourceRange[];
60
65
  body: Expression;
61
66
  location: SourceLocation;
62
67
  }
@@ -64,6 +69,7 @@ interface JunctionExpression {
64
69
  kind: "And" | "Or";
65
70
  operands: Expression[];
66
71
  isBulleted?: boolean;
72
+ prefixEnds?: SourceLocation[];
67
73
  location: SourceLocation;
68
74
  }
69
75
  interface PrimeExpression {
@@ -108,9 +114,11 @@ interface LetExpression {
108
114
  type BoundPattern = {
109
115
  kind: "Name";
110
116
  name: string;
117
+ ranges?: SourceRange[];
111
118
  } | {
112
119
  kind: "Tuple";
113
120
  names: string[];
121
+ ranges?: SourceRange[];
114
122
  };
115
123
  interface Bound {
116
124
  pattern: BoundPattern;
@@ -126,6 +134,7 @@ interface UnboundedQuantifierExpression {
126
134
  kind: "UnboundedQuantifier";
127
135
  quantifier: "Forall" | "Exists";
128
136
  names: string[];
137
+ nameRanges?: SourceRange[];
129
138
  isTemporal?: boolean;
130
139
  body: Expression;
131
140
  location: SourceLocation;
@@ -175,6 +184,7 @@ interface FunctionSetExpression {
175
184
  interface RecordField {
176
185
  name: string;
177
186
  value: Expression;
187
+ location: SourceLocation;
178
188
  }
179
189
  interface RecordExpression {
180
190
  kind: "Record" | "RecordSet";
@@ -208,6 +218,11 @@ interface FunctionApplicationExpression {
208
218
  args: Expression[];
209
219
  location: SourceLocation;
210
220
  }
221
+ interface BracketExpression {
222
+ kind: "Bracket";
223
+ args: Expression[];
224
+ location: SourceLocation;
225
+ }
211
226
  interface FieldAccessExpression {
212
227
  kind: "FieldAccess";
213
228
  record: Expression;
@@ -241,6 +256,7 @@ interface LabelExpression {
241
256
  kind: "Label";
242
257
  name: string;
243
258
  params: string[];
259
+ paramRanges?: SourceRange[];
244
260
  body: Expression;
245
261
  location: SourceLocation;
246
262
  }
@@ -262,9 +278,11 @@ type Selector = {
262
278
  interface SubexpressionExpression {
263
279
  kind: "Subexpression";
264
280
  selectors: Selector[];
281
+ selectorRanges?: SourceRange[];
282
+ argumentRanges?: (SourceRange | undefined)[];
265
283
  location: SourceLocation;
266
284
  }
267
- 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;
285
+ 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;
268
286
  interface OperatorParam {
269
287
  name: string;
270
288
  arity: number;
@@ -287,6 +305,7 @@ interface FunctionDefinition {
287
305
  body: Expression;
288
306
  isLocal: boolean;
289
307
  isRecursive: boolean;
308
+ isSelfReferential?: boolean;
290
309
  location: SourceLocation;
291
310
  }
292
311
  type Definition = OperatorDefinition | FunctionDefinition;
@@ -303,6 +322,7 @@ interface Assumption {
303
322
  }
304
323
  interface InstanceSubstitution {
305
324
  name: string;
325
+ nameRange: SourceRange;
306
326
  expression: Expression;
307
327
  }
308
328
  interface Instance {
@@ -322,6 +342,7 @@ interface NewSymbol {
322
342
  arity: number;
323
343
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
324
344
  set: Expression | undefined;
345
+ nameRange?: SourceRange;
325
346
  location: SourceLocation;
326
347
  }
327
348
  interface AssumeProve {
@@ -371,6 +392,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
371
392
  } | {
372
393
  kind: "Take";
373
394
  names: string[];
395
+ nameRanges?: SourceRange[];
374
396
  bounds: Bound[];
375
397
  } | {
376
398
  kind: "Witness";
@@ -378,6 +400,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
378
400
  } | {
379
401
  kind: "Pick";
380
402
  names: string[];
403
+ nameRanges?: SourceRange[];
381
404
  bounds: Bound[];
382
405
  body: Expression;
383
406
  } | {
@@ -395,6 +418,7 @@ interface ProofStep {
395
418
  token: string;
396
419
  body: StepBody;
397
420
  head: SourceRange;
421
+ statement: SourceRange;
398
422
  proof: Proof | undefined;
399
423
  location: SourceLocation;
400
424
  }
@@ -405,11 +429,9 @@ interface Theorem {
405
429
  location: SourceLocation;
406
430
  }
407
431
  type ModuleUnit = {
408
- kind: "Constants";
409
- declarations: Declaration[];
410
- } | {
411
- kind: "Variables";
432
+ kind: "Constants" | "Variables";
412
433
  declarations: Declaration[];
434
+ location: SourceLocation;
413
435
  } | {
414
436
  kind: "Recursive";
415
437
  declarations: Declaration[];
@@ -447,6 +469,7 @@ interface Module {
447
469
  uses: UseOrHide[];
448
470
  units: ModuleUnit[];
449
471
  }
472
+ type TlcVersion = "1.7.4" | "master";
450
473
  type ConfigValue = {
451
474
  kind: "Number";
452
475
  value: number;
@@ -493,7 +516,13 @@ interface ModelConfig {
493
516
  periodic: string | undefined;
494
517
  rlReward: string | undefined;
495
518
  }
496
- export declare const parseConfig: (source: string) => ModelConfig;
519
+ export declare const parseConfig: (source: string, version?: TlcVersion) => ModelConfig;
520
+ interface JavaOverride {
521
+ module: string;
522
+ operator: string;
523
+ signature: string;
524
+ isMatched: boolean;
525
+ }
497
526
  export declare class TlaError extends Error {
498
527
  constructor(message: string, cause?: unknown);
499
528
  }
@@ -503,9 +532,20 @@ interface SyntaxFailure {
503
532
  column: number;
504
533
  isEnd: boolean;
505
534
  }
535
+ interface SanyError {
536
+ location: string;
537
+ message: string;
538
+ }
539
+ interface SanyReport {
540
+ errors: SanyError[];
541
+ warnings: SanyError[];
542
+ isFatal: boolean;
543
+ parseError?: string;
544
+ }
506
545
  export declare class TlaSyntaxError extends TlaError {
507
546
  failure: SyntaxFailure | undefined;
508
- constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
547
+ sany: SanyReport | undefined;
548
+ constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
509
549
  }
510
550
  export declare class TlaConfigError extends TlaError {
511
551
  constructor(message: string, cause?: unknown);
@@ -539,6 +579,7 @@ interface FunctionValue {
539
579
  hash: number;
540
580
  fingerprint: number;
541
581
  writtenKeys: Value[] | undefined;
582
+ functionClass: FunctionClass | undefined;
542
583
  }
543
584
  interface IntervalValue {
544
585
  kind: "Interval";
@@ -577,10 +618,15 @@ interface SetOperationValue {
577
618
  left: Value;
578
619
  right: Value;
579
620
  }
621
+ interface FilteredSetSource {
622
+ names: string;
623
+ predicate: string;
624
+ }
580
625
  interface FilteredSetValue {
581
626
  kind: "FilteredSet";
582
627
  base: Value;
583
628
  test: (element: Value) => boolean;
629
+ source?: FilteredSetSource;
584
630
  }
585
631
  interface UnionValue {
586
632
  kind: "Union";
@@ -599,9 +645,15 @@ interface LazyFunctionValue {
599
645
  domain: Value;
600
646
  apply: (argument: Value) => Value;
601
647
  source?: LazyFunctionSource;
648
+ functionClass?: FunctionClass;
602
649
  }
603
650
  type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
651
+ type FunctionClass = "lambda" | "tuple" | "record";
604
652
  export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
653
+ interface FingerprintFailure {
654
+ sources: Expression[];
655
+ reason: string;
656
+ }
605
657
  interface StateDump {
606
658
  path: string;
607
659
  dot?: boolean;
@@ -622,33 +674,110 @@ interface CheckOptions {
622
674
  workers?: number;
623
675
  livenessCheck?: "default" | "final";
624
676
  dump?: StateDump;
677
+ isTool?: boolean;
678
+ isTraceRecorded?: boolean;
679
+ isSanyReported?: boolean;
680
+ isWarningEnabled?: boolean;
681
+ version?: TlcVersion;
682
+ onProgress?: (progress: CheckProgress) => void;
683
+ }
684
+ interface InitialStatesProgress {
685
+ kind: "initial-states-progress";
686
+ count: number;
687
+ }
688
+ interface InitialStateViolation {
689
+ kind: "initial-state-violation";
690
+ status: "invariant-violation" | "liveness-violation";
691
+ name: string;
692
+ state: Record<string, Value>;
625
693
  }
694
+ type OutputLine = string | InitialStatesProgress | InitialStateViolation;
695
+ type CheckProgress = {
696
+ kind: "parsed";
697
+ } | {
698
+ kind: "constant-level-invariant";
699
+ name: string;
700
+ } | {
701
+ kind: "state-level-property";
702
+ name: string;
703
+ } | {
704
+ kind: "liveness-initializing";
705
+ isSymmetric: boolean;
706
+ isConstrained: boolean;
707
+ } | {
708
+ kind: "liveness-prepared";
709
+ branches: number;
710
+ } | {
711
+ kind: "initial-states-started";
712
+ } | InitialStatesProgress | {
713
+ kind: "initial-states-computed";
714
+ initialStates: InitialStates;
715
+ } | {
716
+ kind: "progress";
717
+ statistics: SearchStatistics;
718
+ } | {
719
+ kind: "liveness-started";
720
+ branches: number;
721
+ isComplete: boolean;
722
+ states: number;
723
+ statistics: SearchStatistics;
724
+ } | {
725
+ kind: "liveness-finished";
726
+ } | {
727
+ kind: "warning";
728
+ code: number;
729
+ text: string;
730
+ } | ({
731
+ kind: "java-override";
732
+ } & JavaOverride);
733
+ interface SearchStatistics extends Pick<CheckResult, "generatedStates" | "distinctStates" | "queuedStates" | "depth"> {}
626
734
  type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
627
735
  interface TraceStep {
628
736
  action: string | undefined;
629
737
  label: string | undefined;
630
738
  state: Record<string, Value>;
739
+ output?: OutputLine[];
631
740
  }
632
741
  interface Violation {
633
742
  name: string;
634
743
  properties?: string[];
635
744
  trace: TraceStep[];
745
+ traceOutput?: OutputLine[];
636
746
  loopStart: number | undefined;
637
747
  loopLabel?: string;
638
748
  message?: string;
639
749
  counts?: string;
640
750
  unwitnessed?: Postcondition;
751
+ postcondition?: Postcondition;
752
+ warning?: {
753
+ code: number;
754
+ text: string;
755
+ };
641
756
  }
642
757
  interface Postcondition {
643
758
  name: string;
759
+ code: number;
644
760
  message: string;
645
761
  counts?: string;
646
762
  }
647
763
  interface EvaluationFailure {
764
+ code: number;
648
765
  message: string;
766
+ toolMessage: string;
649
767
  trace: TraceStep[];
768
+ traceOutput?: OutputLine[];
650
769
  initialState: Record<string, Value> | undefined;
651
770
  exitCode: number;
771
+ callStack: Expression[] | undefined;
772
+ isCallStackFirst?: boolean;
773
+ fingerprint?: FingerprintFailure;
774
+ traceFailure?: FailureMessage;
775
+ postcondition?: Postcondition;
776
+ isWithoutStatistics?: boolean;
777
+ }
778
+ interface InitialStates {
779
+ generated: number;
780
+ distinct: number;
652
781
  }
653
782
  interface CheckResult {
654
783
  status: CheckStatus;
@@ -658,9 +787,18 @@ interface CheckResult {
658
787
  distinctStates: number;
659
788
  queuedStates: number;
660
789
  depth: number;
790
+ initialStates: InitialStates | undefined;
661
791
  outDegrees: number[] | undefined;
662
792
  fingerprintDistance: bigint | undefined;
793
+ additionalViolation?: Violation;
794
+ liveCallStack?: Expression[];
795
+ violationOutDegrees?: number[];
796
+ }
797
+ interface FailureMessage {
798
+ code: number;
799
+ message: string;
800
+ toolMessage: string;
663
801
  }
664
802
  export declare const check: (options: CheckOptions) => Promise<CheckResult>;
665
803
  export declare const parseModule: (source: string) => Module;
666
- export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
804
+ export type { CheckOptions, CheckProgress, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };