tla-ts 0.0.3-dev.e5b05b9 → 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 (79) 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 -48
  5. package/dist/index.d.ts +150 -48
  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 +1352 -23
  13. package/dist/transfer.cjs +83 -43
  14. package/dist/transfer.js +83 -43
  15. package/package.json +5 -1
  16. package/src/ast.ts +28 -4
  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 +226 -207
  25. package/src/environment.ts +221 -75
  26. package/src/errors.ts +130 -15
  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 +6 -1
  34. package/src/lexer.ts +122 -29
  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 +327 -147
  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 +252 -87
  49. package/src/run-cli.ts +1162 -200
  50. package/src/runtime.ts +16 -0
  51. package/src/sany-builtins.ts +147 -0
  52. package/src/sany-generator.ts +3128 -0
  53. package/src/sany-levels.ts +1208 -0
  54. package/src/sany-lexer.ts +410 -480
  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 +2033 -3015
  59. package/src/sany-report.ts +356 -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/state-graph.ts +29 -6
  66. package/src/subexpressions.ts +121 -26
  67. package/src/successors.ts +141 -173
  68. package/src/symmetry.ts +168 -50
  69. package/src/tableau.ts +3 -1
  70. package/src/tlc-ext.ts +13 -17
  71. package/src/tlc-messages.ts +329 -0
  72. package/src/tlc-module.ts +49 -21
  73. package/src/tlc-modules.ts +0 -4
  74. package/src/tlc-order.ts +55 -9
  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/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.N,exports.TlaError=e.P,exports.TlaEvaluationError=e.F,exports.TlaSyntaxError=e.L,exports.TlaUnsupportedError=e.R,exports.check=t.t,exports.formatValue=e.O,exports.parseConfig=e.j,exports.parseModule=e.x;
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
+ spelling?: string;
41
42
  selectorRanges?: SourceRange[];
42
43
  location: SourceLocation;
43
44
  resolution?: LocalResolution;
@@ -45,6 +46,7 @@ interface IdentifierExpression {
45
46
  interface ApplyExpression {
46
47
  kind: "Apply";
47
48
  operator: string;
49
+ spelling?: string;
48
50
  args: Expression[];
49
51
  argumentCounts?: number[];
50
52
  argumentsRange?: SourceRange;
@@ -56,6 +58,7 @@ interface ApplyExpression {
56
58
  interface OperatorReferenceExpression {
57
59
  kind: "OperatorReference";
58
60
  operator: string;
61
+ spelling?: string;
59
62
  location: SourceLocation;
60
63
  }
61
64
  interface LambdaExpression {
@@ -63,12 +66,14 @@ interface LambdaExpression {
63
66
  params: string[];
64
67
  paramRanges?: SourceRange[];
65
68
  body: Expression;
69
+ operator?: string;
66
70
  location: SourceLocation;
67
71
  }
68
72
  interface JunctionExpression {
69
73
  kind: "And" | "Or";
70
74
  operands: Expression[];
71
75
  isBulleted?: boolean;
76
+ prefixEnds?: SourceLocation[];
72
77
  location: SourceLocation;
73
78
  }
74
79
  interface PrimeExpression {
@@ -217,6 +222,11 @@ interface FunctionApplicationExpression {
217
222
  args: Expression[];
218
223
  location: SourceLocation;
219
224
  }
225
+ interface BracketExpression {
226
+ kind: "Bracket";
227
+ args: Expression[];
228
+ location: SourceLocation;
229
+ }
220
230
  interface FieldAccessExpression {
221
231
  kind: "FieldAccess";
222
232
  record: Expression;
@@ -276,7 +286,7 @@ interface SubexpressionExpression {
276
286
  argumentRanges?: (SourceRange | undefined)[];
277
287
  location: SourceLocation;
278
288
  }
279
- 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;
280
290
  interface OperatorParam {
281
291
  name: string;
282
292
  arity: number;
@@ -299,6 +309,7 @@ interface FunctionDefinition {
299
309
  body: Expression;
300
310
  isLocal: boolean;
301
311
  isRecursive: boolean;
312
+ isSelfReferential?: boolean;
302
313
  location: SourceLocation;
303
314
  }
304
315
  type Definition = OperatorDefinition | FunctionDefinition;
@@ -422,11 +433,9 @@ interface Theorem {
422
433
  location: SourceLocation;
423
434
  }
424
435
  type ModuleUnit = {
425
- kind: "Constants";
426
- declarations: Declaration[];
427
- } | {
428
- kind: "Variables";
436
+ kind: "Constants" | "Variables";
429
437
  declarations: Declaration[];
438
+ location: SourceLocation;
430
439
  } | {
431
440
  kind: "Recursive";
432
441
  declarations: Declaration[];
@@ -464,6 +473,7 @@ interface Module {
464
473
  uses: UseOrHide[];
465
474
  units: ModuleUnit[];
466
475
  }
476
+ type TlcVersion = "1.7.4" | "master";
467
477
  type ConfigValue = {
468
478
  kind: "Number";
469
479
  value: number;
@@ -510,7 +520,46 @@ interface ModelConfig {
510
520
  periodic: string | undefined;
511
521
  rlReward: string | undefined;
512
522
  }
513
- 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
+ }
514
563
  interface ModelValue {
515
564
  kind: "ModelValue";
516
565
  name: string;
@@ -534,6 +583,7 @@ interface FunctionValue {
534
583
  hash: number;
535
584
  fingerprint: number;
536
585
  writtenKeys: Value[] | undefined;
586
+ functionClass: FunctionClass | undefined;
537
587
  }
538
588
  interface IntervalValue {
539
589
  kind: "Interval";
@@ -572,10 +622,15 @@ interface SetOperationValue {
572
622
  left: Value;
573
623
  right: Value;
574
624
  }
625
+ interface FilteredSetSource {
626
+ names: string;
627
+ predicate: string;
628
+ }
575
629
  interface FilteredSetValue {
576
630
  kind: "FilteredSet";
577
631
  base: Value;
578
632
  test: (element: Value) => boolean;
633
+ source?: FilteredSetSource;
579
634
  }
580
635
  interface UnionValue {
581
636
  kind: "Union";
@@ -594,41 +649,14 @@ interface LazyFunctionValue {
594
649
  domain: Value;
595
650
  apply: (argument: Value) => Value;
596
651
  source?: LazyFunctionSource;
652
+ functionClass?: FunctionClass;
597
653
  }
598
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";
599
656
  export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
600
- export declare class TlaError extends Error {
601
- constructor(message: string, cause?: unknown);
602
- }
603
- interface SyntaxFailure {
657
+ interface FingerprintFailure {
658
+ sources: Expression[];
604
659
  reason: string;
605
- line: number;
606
- column: number;
607
- isEnd: boolean;
608
- }
609
- interface SanyError {
610
- location: string;
611
- message: string;
612
- }
613
- interface SanyReport {
614
- errors: SanyError[];
615
- warnings: SanyError[];
616
- isFatal: boolean;
617
- parseError?: string;
618
- }
619
- export declare class TlaSyntaxError extends TlaError {
620
- failure: SyntaxFailure | undefined;
621
- sany: SanyReport | undefined;
622
- constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
623
- }
624
- export declare class TlaConfigError extends TlaError {
625
- constructor(message: string, cause?: unknown);
626
- }
627
- export declare class TlaEvaluationError extends TlaError {
628
- constructor(message: string, cause?: unknown);
629
- }
630
- export declare class TlaUnsupportedError extends TlaError {
631
- constructor(message: string, cause?: unknown);
632
660
  }
633
661
  interface StateDump {
634
662
  path: string;
@@ -650,45 +678,110 @@ interface CheckOptions {
650
678
  workers?: number;
651
679
  livenessCheck?: "default" | "final";
652
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>;
653
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"> {}
654
738
  type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
655
739
  interface TraceStep {
656
740
  action: string | undefined;
657
741
  label: string | undefined;
658
742
  state: Record<string, Value>;
743
+ output?: OutputLine[];
659
744
  }
660
745
  interface Violation {
661
746
  name: string;
662
747
  properties?: string[];
663
748
  trace: TraceStep[];
749
+ traceOutput?: OutputLine[];
664
750
  loopStart: number | undefined;
665
751
  loopLabel?: string;
666
752
  message?: string;
667
753
  counts?: string;
668
754
  unwitnessed?: Postcondition;
755
+ postcondition?: Postcondition;
756
+ warning?: {
757
+ code: number;
758
+ text: string;
759
+ };
669
760
  }
670
761
  interface Postcondition {
671
762
  name: string;
763
+ code: number;
672
764
  message: string;
673
765
  counts?: string;
674
766
  }
675
767
  interface EvaluationFailure {
768
+ code: number;
676
769
  message: string;
770
+ toolMessage: string;
677
771
  trace: TraceStep[];
772
+ traceOutput?: OutputLine[];
678
773
  initialState: Record<string, Value> | undefined;
679
774
  exitCode: number;
680
- replay?: Replay;
775
+ callStack: Expression[] | undefined;
776
+ isCallStackFirst?: boolean;
777
+ fingerprint?: FingerprintFailure;
778
+ traceFailure?: FailureMessage;
779
+ postcondition?: Postcondition;
681
780
  isWithoutStatistics?: boolean;
682
781
  }
683
- interface Replay {
684
- output: string[];
685
- callStack: string[] | undefined;
686
- fingerprint?: Fingerprint;
687
- isBeforeError?: boolean;
688
- }
689
- interface Fingerprint {
690
- sources: string[];
691
- reason: string;
782
+ interface InitialStates {
783
+ generated: number;
784
+ distinct: number;
692
785
  }
693
786
  interface CheckResult {
694
787
  status: CheckStatus;
@@ -698,9 +791,18 @@ interface CheckResult {
698
791
  distinctStates: number;
699
792
  queuedStates: number;
700
793
  depth: number;
794
+ initialStates: InitialStates | undefined;
701
795
  outDegrees: number[] | undefined;
702
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;
703
805
  }
704
806
  export declare const check: (options: CheckOptions) => Promise<CheckResult>;
705
807
  export declare const parseModule: (source: string) => Module;
706
- 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 };