tla-ts 0.0.3-dev.3504663 → 0.0.3-dev.3539317

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tla-ts",
3
- "version": "0.0.3-dev.3504663",
3
+ "version": "0.0.3-dev.3539317",
4
4
  "description": "A TLA+ interpreter and model checker in TypeScript, 2× faster than TLC",
5
5
  "keywords": [
6
6
  "formal verification",
package/src/ast.ts CHANGED
@@ -53,6 +53,8 @@ export interface ApplyExpression {
53
53
  // The range of the parenthesized arguments of a named operator, where SANY reports their count.
54
54
  argumentsRange?: SourceRange;
55
55
  selectorRanges?: SourceRange[];
56
+ // The range of the arguments of each part of a name like F(x)!l(y), for a part that takes some.
57
+ argumentRanges?: (SourceRange | undefined)[];
56
58
  location: SourceLocation;
57
59
  resolution?: LocalResolution;
58
60
  }
@@ -66,6 +68,7 @@ export interface OperatorReferenceExpression {
66
68
  export interface LambdaExpression {
67
69
  kind: "Lambda";
68
70
  params: string[];
71
+ paramRanges?: SourceRange[];
69
72
  body: Expression;
70
73
  location: SourceLocation;
71
74
  }
@@ -123,7 +126,10 @@ export interface LetExpression {
123
126
  location: SourceLocation;
124
127
  }
125
128
 
126
- export type BoundPattern = { kind: "Name"; name: string } | { kind: "Tuple"; names: string[] };
129
+ // ranges holds the range of each name the pattern binds.
130
+ export type BoundPattern =
131
+ | { kind: "Name"; name: string; ranges?: SourceRange[] }
132
+ | { kind: "Tuple"; names: string[]; ranges?: SourceRange[] };
127
133
 
128
134
  export interface Bound {
129
135
  pattern: BoundPattern;
@@ -141,6 +147,7 @@ export interface UnboundedQuantifierExpression {
141
147
  kind: "UnboundedQuantifier";
142
148
  quantifier: "Forall" | "Exists";
143
149
  names: string[];
150
+ nameRanges?: SourceRange[];
144
151
  isTemporal?: boolean;
145
152
  body: Expression;
146
153
  location: SourceLocation;
@@ -273,6 +280,7 @@ export interface LabelExpression {
273
280
  kind: "Label";
274
281
  name: string;
275
282
  params: string[];
283
+ paramRanges?: SourceRange[];
276
284
  body: Expression;
277
285
  location: SourceLocation;
278
286
  }
@@ -288,6 +296,7 @@ export interface SubexpressionExpression {
288
296
  kind: "Subexpression";
289
297
  selectors: Selector[];
290
298
  selectorRanges?: SourceRange[];
299
+ argumentRanges?: (SourceRange | undefined)[];
291
300
  location: SourceLocation;
292
301
  }
293
302
 
@@ -371,6 +380,7 @@ export interface Assumption {
371
380
 
372
381
  export interface InstanceSubstitution {
373
382
  name: string;
383
+ nameRange: SourceRange;
374
384
  expression: Expression;
375
385
  }
376
386
 
@@ -392,6 +402,7 @@ export interface NewSymbol {
392
402
  arity: number;
393
403
  level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
394
404
  set: Expression | undefined;
405
+ nameRange?: SourceRange;
395
406
  location: SourceLocation;
396
407
  }
397
408
 
@@ -443,9 +454,15 @@ export type StepBody =
443
454
  | Instance
444
455
  | DefineStep
445
456
  | { kind: "Have"; expression: Expression }
446
- | { kind: "Take"; names: string[]; bounds: Bound[] }
457
+ | { kind: "Take"; names: string[]; nameRanges?: SourceRange[]; bounds: Bound[] }
447
458
  | { kind: "Witness"; expressions: Expression[] }
448
- | { kind: "Pick"; names: string[]; bounds: Bound[]; body: Expression }
459
+ | {
460
+ kind: "Pick";
461
+ names: string[];
462
+ nameRanges?: SourceRange[];
463
+ bounds: Bound[];
464
+ body: Expression;
465
+ }
449
466
  | { kind: "Case"; expression: Expression }
450
467
  | { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
451
468
  | { kind: "Qed" };
package/src/check.ts CHANGED
@@ -752,7 +752,7 @@ export const createSearch = (
752
752
  const possible = getPossiblePredicates(config.possible, environment);
753
753
  if (environment.variables.length === 0) return undefined;
754
754
  const symmetryGroup =
755
- config.symmetry === undefined ? [] : getSymmetryGroup(config.symmetry, environment);
755
+ config.symmetry === undefined ? undefined : getSymmetryGroup(config.symmetry, environment);
756
756
  if (config.view !== undefined) getConfigOperator("view function", config.view, environment);
757
757
  const view =
758
758
  config.view === undefined
@@ -784,14 +784,12 @@ export const createSearch = (
784
784
  .sort((left, right) => getTlcPosition(left) - getTlcPosition(right));
785
785
  return tlcOrder.indices;
786
786
  };
787
- // A representative in TLC's variable order is the one whose fingerprint TLC reports.
788
- const order = symmetryGroup.length > 0 ? getTlcOrder() : undefined;
789
787
  const getViewValue = (expression: Expression, state: Value[]) =>
790
788
  evaluate(expression, getContext(environment, state, undefined));
791
789
  const getTlcStateFingerprint = (state: Value[]) => {
792
790
  const indices = getTlcOrder();
793
791
  const representative =
794
- symmetryGroup.length === 0 ? state : getRepresentative(state, symmetryGroup, indices);
792
+ symmetryGroup === undefined ? state : getRepresentative(state, symmetryGroup, indices);
795
793
  return getTlcFingerprint(
796
794
  view === undefined
797
795
  ? indices.map((index) => representative[index])
@@ -814,7 +812,7 @@ export const createSearch = (
814
812
  return {
815
813
  properties,
816
814
  spec,
817
- isSymmetric: symmetryGroup.length > 0,
815
+ isSymmetric: symmetryGroup !== undefined,
818
816
  getTlcOrder,
819
817
  getStoredFingerprints: (states, fingerprintStates) => {
820
818
  if (view !== undefined || isFingerprintedLikeTlc) {
@@ -830,8 +828,11 @@ export const createSearch = (
830
828
  },
831
829
  getFingerprintState: (state) => {
832
830
  if (isFingerprintedLikeTlc) return [String(getTlcStateFingerprint(state))];
831
+ // A representative in TLC's variable order is the one whose fingerprint TLC reports.
833
832
  const representative =
834
- symmetryGroup.length === 0 ? state : getRepresentative(state, symmetryGroup, order);
833
+ symmetryGroup === undefined
834
+ ? state
835
+ : getRepresentative(state, symmetryGroup, getTlcOrder());
835
836
  return view === undefined ? representative : [getViewValue(view.expression, representative)];
836
837
  },
837
838
  findViolatedInvariant: (state, parent) =>