tla-ts 0.0.3-dev.bffbba3 → 0.0.3-dev.c2b256f

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 +150 -8
  5. package/dist/index.d.ts +150 -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 +57 -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 +1358 -219
  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 +457 -132
  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 +112 -29
  34. package/src/live-check.ts +220 -84
  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 +445 -147
  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 +1439 -411
  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 +37 -9
  76. package/src/tlc-replay.ts +655 -0
  77. package/src/tlc-summary.ts +20 -5
  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 +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,32 +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[];
52
+ argumentsRange?: SourceRange;
53
+ selectorRanges?: SourceRange[];
54
+ argumentRanges?: (SourceRange | undefined)[];
49
55
  location: SourceLocation;
50
56
  resolution?: LocalResolution;
51
57
  }
52
58
  interface OperatorReferenceExpression {
53
59
  kind: "OperatorReference";
54
60
  operator: string;
61
+ spelling?: string;
55
62
  location: SourceLocation;
56
63
  }
57
64
  interface LambdaExpression {
58
65
  kind: "Lambda";
59
66
  params: string[];
67
+ paramRanges?: SourceRange[];
60
68
  body: Expression;
69
+ operator?: string;
61
70
  location: SourceLocation;
62
71
  }
63
72
  interface JunctionExpression {
64
73
  kind: "And" | "Or";
65
74
  operands: Expression[];
66
75
  isBulleted?: boolean;
76
+ prefixEnds?: SourceLocation[];
67
77
  location: SourceLocation;
68
78
  }
69
79
  interface PrimeExpression {
@@ -108,9 +118,11 @@ interface LetExpression {
108
118
  type BoundPattern = {
109
119
  kind: "Name";
110
120
  name: string;
121
+ ranges?: SourceRange[];
111
122
  } | {
112
123
  kind: "Tuple";
113
124
  names: string[];
125
+ ranges?: SourceRange[];
114
126
  };
115
127
  interface Bound {
116
128
  pattern: BoundPattern;
@@ -126,6 +138,7 @@ interface UnboundedQuantifierExpression {
126
138
  kind: "UnboundedQuantifier";
127
139
  quantifier: "Forall" | "Exists";
128
140
  names: string[];
141
+ nameRanges?: SourceRange[];
129
142
  isTemporal?: boolean;
130
143
  body: Expression;
131
144
  location: SourceLocation;
@@ -175,6 +188,7 @@ interface FunctionSetExpression {
175
188
  interface RecordField {
176
189
  name: string;
177
190
  value: Expression;
191
+ location: SourceLocation;
178
192
  }
179
193
  interface RecordExpression {
180
194
  kind: "Record" | "RecordSet";
@@ -208,6 +222,11 @@ interface FunctionApplicationExpression {
208
222
  args: Expression[];
209
223
  location: SourceLocation;
210
224
  }
225
+ interface BracketExpression {
226
+ kind: "Bracket";
227
+ args: Expression[];
228
+ location: SourceLocation;
229
+ }
211
230
  interface FieldAccessExpression {
212
231
  kind: "FieldAccess";
213
232
  record: Expression;
@@ -241,6 +260,7 @@ interface LabelExpression {
241
260
  kind: "Label";
242
261
  name: string;
243
262
  params: string[];
263
+ paramRanges?: SourceRange[];
244
264
  body: Expression;
245
265
  location: SourceLocation;
246
266
  }
@@ -262,9 +282,11 @@ type Selector = {
262
282
  interface SubexpressionExpression {
263
283
  kind: "Subexpression";
264
284
  selectors: Selector[];
285
+ selectorRanges?: SourceRange[];
286
+ argumentRanges?: (SourceRange | undefined)[];
265
287
  location: SourceLocation;
266
288
  }
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;
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;
268
290
  interface OperatorParam {
269
291
  name: string;
270
292
  arity: number;
@@ -287,6 +309,7 @@ interface FunctionDefinition {
287
309
  body: Expression;
288
310
  isLocal: boolean;
289
311
  isRecursive: boolean;
312
+ isSelfReferential?: boolean;
290
313
  location: SourceLocation;
291
314
  }
292
315
  type Definition = OperatorDefinition | FunctionDefinition;
@@ -303,6 +326,7 @@ interface Assumption {
303
326
  }
304
327
  interface InstanceSubstitution {
305
328
  name: string;
329
+ nameRange: SourceRange;
306
330
  expression: Expression;
307
331
  }
308
332
  interface Instance {
@@ -322,6 +346,7 @@ interface NewSymbol {
322
346
  arity: number;
323
347
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
324
348
  set: Expression | undefined;
349
+ nameRange?: SourceRange;
325
350
  location: SourceLocation;
326
351
  }
327
352
  interface AssumeProve {
@@ -371,6 +396,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
371
396
  } | {
372
397
  kind: "Take";
373
398
  names: string[];
399
+ nameRanges?: SourceRange[];
374
400
  bounds: Bound[];
375
401
  } | {
376
402
  kind: "Witness";
@@ -378,6 +404,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
378
404
  } | {
379
405
  kind: "Pick";
380
406
  names: string[];
407
+ nameRanges?: SourceRange[];
381
408
  bounds: Bound[];
382
409
  body: Expression;
383
410
  } | {
@@ -395,6 +422,7 @@ interface ProofStep {
395
422
  token: string;
396
423
  body: StepBody;
397
424
  head: SourceRange;
425
+ statement: SourceRange;
398
426
  proof: Proof | undefined;
399
427
  location: SourceLocation;
400
428
  }
@@ -405,11 +433,9 @@ interface Theorem {
405
433
  location: SourceLocation;
406
434
  }
407
435
  type ModuleUnit = {
408
- kind: "Constants";
409
- declarations: Declaration[];
410
- } | {
411
- kind: "Variables";
436
+ kind: "Constants" | "Variables";
412
437
  declarations: Declaration[];
438
+ location: SourceLocation;
413
439
  } | {
414
440
  kind: "Recursive";
415
441
  declarations: Declaration[];
@@ -447,6 +473,7 @@ interface Module {
447
473
  uses: UseOrHide[];
448
474
  units: ModuleUnit[];
449
475
  }
476
+ type TlcVersion = "1.7.4" | "master";
450
477
  type ConfigValue = {
451
478
  kind: "Number";
452
479
  value: number;
@@ -493,7 +520,13 @@ interface ModelConfig {
493
520
  periodic: string | undefined;
494
521
  rlReward: string | undefined;
495
522
  }
496
- 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
+ }
497
530
  export declare class TlaError extends Error {
498
531
  constructor(message: string, cause?: unknown);
499
532
  }
@@ -503,9 +536,20 @@ interface SyntaxFailure {
503
536
  column: number;
504
537
  isEnd: boolean;
505
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
+ }
506
549
  export declare class TlaSyntaxError extends TlaError {
507
550
  failure: SyntaxFailure | undefined;
508
- constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
551
+ sany: SanyReport | undefined;
552
+ constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
509
553
  }
510
554
  export declare class TlaConfigError extends TlaError {
511
555
  constructor(message: string, cause?: unknown);
@@ -539,6 +583,7 @@ interface FunctionValue {
539
583
  hash: number;
540
584
  fingerprint: number;
541
585
  writtenKeys: Value[] | undefined;
586
+ functionClass: FunctionClass | undefined;
542
587
  }
543
588
  interface IntervalValue {
544
589
  kind: "Interval";
@@ -577,10 +622,15 @@ interface SetOperationValue {
577
622
  left: Value;
578
623
  right: Value;
579
624
  }
625
+ interface FilteredSetSource {
626
+ names: string;
627
+ predicate: string;
628
+ }
580
629
  interface FilteredSetValue {
581
630
  kind: "FilteredSet";
582
631
  base: Value;
583
632
  test: (element: Value) => boolean;
633
+ source?: FilteredSetSource;
584
634
  }
585
635
  interface UnionValue {
586
636
  kind: "Union";
@@ -599,9 +649,15 @@ interface LazyFunctionValue {
599
649
  domain: Value;
600
650
  apply: (argument: Value) => Value;
601
651
  source?: LazyFunctionSource;
652
+ functionClass?: FunctionClass;
602
653
  }
603
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";
604
656
  export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
657
+ interface FingerprintFailure {
658
+ sources: Expression[];
659
+ reason: string;
660
+ }
605
661
  interface StateDump {
606
662
  path: string;
607
663
  dot?: boolean;
@@ -622,33 +678,110 @@ interface CheckOptions {
622
678
  workers?: number;
623
679
  livenessCheck?: "default" | "final";
624
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>;
625
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"> {}
626
738
  type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
627
739
  interface TraceStep {
628
740
  action: string | undefined;
629
741
  label: string | undefined;
630
742
  state: Record<string, Value>;
743
+ output?: OutputLine[];
631
744
  }
632
745
  interface Violation {
633
746
  name: string;
634
747
  properties?: string[];
635
748
  trace: TraceStep[];
749
+ traceOutput?: OutputLine[];
636
750
  loopStart: number | undefined;
637
751
  loopLabel?: string;
638
752
  message?: string;
639
753
  counts?: string;
640
754
  unwitnessed?: Postcondition;
755
+ postcondition?: Postcondition;
756
+ warning?: {
757
+ code: number;
758
+ text: string;
759
+ };
641
760
  }
642
761
  interface Postcondition {
643
762
  name: string;
763
+ code: number;
644
764
  message: string;
645
765
  counts?: string;
646
766
  }
647
767
  interface EvaluationFailure {
768
+ code: number;
648
769
  message: string;
770
+ toolMessage: string;
649
771
  trace: TraceStep[];
772
+ traceOutput?: OutputLine[];
650
773
  initialState: Record<string, Value> | undefined;
651
774
  exitCode: number;
775
+ callStack: Expression[] | undefined;
776
+ isCallStackFirst?: boolean;
777
+ fingerprint?: FingerprintFailure;
778
+ traceFailure?: FailureMessage;
779
+ postcondition?: Postcondition;
780
+ isWithoutStatistics?: boolean;
781
+ }
782
+ interface InitialStates {
783
+ generated: number;
784
+ distinct: number;
652
785
  }
653
786
  interface CheckResult {
654
787
  status: CheckStatus;
@@ -658,9 +791,18 @@ interface CheckResult {
658
791
  distinctStates: number;
659
792
  queuedStates: number;
660
793
  depth: number;
794
+ initialStates: InitialStates | undefined;
661
795
  outDegrees: number[] | undefined;
662
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;
663
805
  }
664
806
  export declare const check: (options: CheckOptions) => Promise<CheckResult>;
665
807
  export declare const parseModule: (source: string) => Module;
666
- 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 };