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/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/run-cli.cjs +3 -3
- package/dist/run-cli.js +20 -20
- package/dist/transfer.cjs +24 -23
- package/dist/transfer.js +24 -23
- package/package.json +1 -1
- package/src/ast.ts +20 -3
- package/src/check.ts +7 -6
- package/src/environment.ts +264 -93
- package/src/errors.ts +15 -4
- package/src/instances.ts +1 -1
- package/src/levels.ts +31 -26
- package/src/parser.ts +103 -36
- package/src/resolve.ts +1105 -525
- package/src/run-cli.ts +2 -0
- package/src/standard-ranges.ts +116 -0
- package/src/subexpressions.ts +210 -162
- package/src/symmetry.ts +93 -35
package/package.json
CHANGED
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
|
-
|
|
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
|
-
| {
|
|
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 ?
|
|
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
|
|
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
|
|
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
|
|
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) =>
|