tla-ts 0.0.3-dev.33ae522 → 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.cjs +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +13 -13
- package/dist/run-cli.js +22 -22
- package/dist/transfer.cjs +27 -18
- package/dist/transfer.js +27 -18
- package/package.json +1 -1
- package/src/ast.ts +28 -4
- package/src/check.ts +12 -8
- package/src/environment.ts +290 -102
- package/src/errors.ts +25 -3
- package/src/evaluate.ts +3 -3
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +1 -1
- package/src/levels.ts +143 -30
- package/src/parser.ts +154 -46
- package/src/resolve.ts +1331 -451
- package/src/run-cli.ts +5 -2
- package/src/sany-lexer.ts +615 -0
- package/src/sany-parse-error.ts +3143 -0
- package/src/standard-modules.ts +2 -2
- package/src/standard-ranges.ts +116 -0
- package/src/subexpressions.ts +221 -161
- package/src/substitution-levels.ts +38 -17
- package/src/symmetry.ts +93 -35
- package/src/values.ts +70 -8
package/package.json
CHANGED
package/src/ast.ts
CHANGED
|
@@ -33,9 +33,12 @@ export interface StringExpression {
|
|
|
33
33
|
location: SourceLocation;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// selectorRanges holds the range of each part of a name such as foo!lab, where SANY reports an
|
|
37
|
+
// error in selecting that part.
|
|
36
38
|
export interface IdentifierExpression {
|
|
37
39
|
kind: "Identifier";
|
|
38
40
|
name: string;
|
|
41
|
+
selectorRanges?: SourceRange[];
|
|
39
42
|
location: SourceLocation;
|
|
40
43
|
resolution?: LocalResolution;
|
|
41
44
|
}
|
|
@@ -49,6 +52,9 @@ export interface ApplyExpression {
|
|
|
49
52
|
argumentCounts?: number[];
|
|
50
53
|
// The range of the parenthesized arguments of a named operator, where SANY reports their count.
|
|
51
54
|
argumentsRange?: SourceRange;
|
|
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)[];
|
|
52
58
|
location: SourceLocation;
|
|
53
59
|
resolution?: LocalResolution;
|
|
54
60
|
}
|
|
@@ -62,6 +68,7 @@ export interface OperatorReferenceExpression {
|
|
|
62
68
|
export interface LambdaExpression {
|
|
63
69
|
kind: "Lambda";
|
|
64
70
|
params: string[];
|
|
71
|
+
paramRanges?: SourceRange[];
|
|
65
72
|
body: Expression;
|
|
66
73
|
location: SourceLocation;
|
|
67
74
|
}
|
|
@@ -119,7 +126,10 @@ export interface LetExpression {
|
|
|
119
126
|
location: SourceLocation;
|
|
120
127
|
}
|
|
121
128
|
|
|
122
|
-
|
|
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[] };
|
|
123
133
|
|
|
124
134
|
export interface Bound {
|
|
125
135
|
pattern: BoundPattern;
|
|
@@ -137,6 +147,7 @@ export interface UnboundedQuantifierExpression {
|
|
|
137
147
|
kind: "UnboundedQuantifier";
|
|
138
148
|
quantifier: "Forall" | "Exists";
|
|
139
149
|
names: string[];
|
|
150
|
+
nameRanges?: SourceRange[];
|
|
140
151
|
isTemporal?: boolean;
|
|
141
152
|
body: Expression;
|
|
142
153
|
location: SourceLocation;
|
|
@@ -269,6 +280,7 @@ export interface LabelExpression {
|
|
|
269
280
|
kind: "Label";
|
|
270
281
|
name: string;
|
|
271
282
|
params: string[];
|
|
283
|
+
paramRanges?: SourceRange[];
|
|
272
284
|
body: Expression;
|
|
273
285
|
location: SourceLocation;
|
|
274
286
|
}
|
|
@@ -283,6 +295,8 @@ export type Selector =
|
|
|
283
295
|
export interface SubexpressionExpression {
|
|
284
296
|
kind: "Subexpression";
|
|
285
297
|
selectors: Selector[];
|
|
298
|
+
selectorRanges?: SourceRange[];
|
|
299
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
286
300
|
location: SourceLocation;
|
|
287
301
|
}
|
|
288
302
|
|
|
@@ -366,6 +380,7 @@ export interface Assumption {
|
|
|
366
380
|
|
|
367
381
|
export interface InstanceSubstitution {
|
|
368
382
|
name: string;
|
|
383
|
+
nameRange: SourceRange;
|
|
369
384
|
expression: Expression;
|
|
370
385
|
}
|
|
371
386
|
|
|
@@ -387,6 +402,7 @@ export interface NewSymbol {
|
|
|
387
402
|
arity: number;
|
|
388
403
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
389
404
|
set: Expression | undefined;
|
|
405
|
+
nameRange?: SourceRange;
|
|
390
406
|
location: SourceLocation;
|
|
391
407
|
}
|
|
392
408
|
|
|
@@ -438,19 +454,27 @@ export type StepBody =
|
|
|
438
454
|
| Instance
|
|
439
455
|
| DefineStep
|
|
440
456
|
| { kind: "Have"; expression: Expression }
|
|
441
|
-
| { kind: "Take"; names: string[]; bounds: Bound[] }
|
|
457
|
+
| { kind: "Take"; names: string[]; nameRanges?: SourceRange[]; bounds: Bound[] }
|
|
442
458
|
| { kind: "Witness"; expressions: Expression[] }
|
|
443
|
-
| {
|
|
459
|
+
| {
|
|
460
|
+
kind: "Pick";
|
|
461
|
+
names: string[];
|
|
462
|
+
nameRanges?: SourceRange[];
|
|
463
|
+
bounds: Bound[];
|
|
464
|
+
body: Expression;
|
|
465
|
+
}
|
|
444
466
|
| { kind: "Case"; expression: Expression }
|
|
445
467
|
| { kind: "Assert"; isSuffices: boolean; statement: Expression | AssumeProve }
|
|
446
468
|
| { kind: "Qed" };
|
|
447
469
|
|
|
448
|
-
// head is the range of the step number and its statement, without the proof
|
|
470
|
+
// head is the range of the step number and its statement, without the proof, and statement is the
|
|
471
|
+
// range of the statement alone.
|
|
449
472
|
export interface ProofStep {
|
|
450
473
|
name: string | undefined;
|
|
451
474
|
token: string;
|
|
452
475
|
body: StepBody;
|
|
453
476
|
head: SourceRange;
|
|
477
|
+
statement: SourceRange;
|
|
454
478
|
proof: Proof | undefined;
|
|
455
479
|
location: SourceLocation;
|
|
456
480
|
}
|
package/src/check.ts
CHANGED
|
@@ -72,6 +72,7 @@ import { createCounterExample } from "./tlc-ext";
|
|
|
72
72
|
import { getFingerprintTrace, valueSources } from "./value-sources";
|
|
73
73
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc-summary";
|
|
74
74
|
import {
|
|
75
|
+
assertFingerprintable,
|
|
75
76
|
combineHash,
|
|
76
77
|
createModelValue,
|
|
77
78
|
formatState,
|
|
@@ -751,7 +752,7 @@ export const createSearch = (
|
|
|
751
752
|
const possible = getPossiblePredicates(config.possible, environment);
|
|
752
753
|
if (environment.variables.length === 0) return undefined;
|
|
753
754
|
const symmetryGroup =
|
|
754
|
-
config.symmetry === undefined ?
|
|
755
|
+
config.symmetry === undefined ? undefined : getSymmetryGroup(config.symmetry, environment);
|
|
755
756
|
if (config.view !== undefined) getConfigOperator("view function", config.view, environment);
|
|
756
757
|
const view =
|
|
757
758
|
config.view === undefined
|
|
@@ -783,14 +784,12 @@ export const createSearch = (
|
|
|
783
784
|
.sort((left, right) => getTlcPosition(left) - getTlcPosition(right));
|
|
784
785
|
return tlcOrder.indices;
|
|
785
786
|
};
|
|
786
|
-
// A representative in TLC's variable order is the one whose fingerprint TLC reports.
|
|
787
|
-
const order = symmetryGroup.length > 0 ? getTlcOrder() : undefined;
|
|
788
787
|
const getViewValue = (expression: Expression, state: Value[]) =>
|
|
789
788
|
evaluate(expression, getContext(environment, state, undefined));
|
|
790
789
|
const getTlcStateFingerprint = (state: Value[]) => {
|
|
791
790
|
const indices = getTlcOrder();
|
|
792
791
|
const representative =
|
|
793
|
-
symmetryGroup
|
|
792
|
+
symmetryGroup === undefined ? state : getRepresentative(state, symmetryGroup, indices);
|
|
794
793
|
return getTlcFingerprint(
|
|
795
794
|
view === undefined
|
|
796
795
|
? indices.map((index) => representative[index])
|
|
@@ -813,7 +812,7 @@ export const createSearch = (
|
|
|
813
812
|
return {
|
|
814
813
|
properties,
|
|
815
814
|
spec,
|
|
816
|
-
isSymmetric: symmetryGroup
|
|
815
|
+
isSymmetric: symmetryGroup !== undefined,
|
|
817
816
|
getTlcOrder,
|
|
818
817
|
getStoredFingerprints: (states, fingerprintStates) => {
|
|
819
818
|
if (view !== undefined || isFingerprintedLikeTlc) {
|
|
@@ -829,8 +828,11 @@ export const createSearch = (
|
|
|
829
828
|
},
|
|
830
829
|
getFingerprintState: (state) => {
|
|
831
830
|
if (isFingerprintedLikeTlc) return [String(getTlcStateFingerprint(state))];
|
|
831
|
+
// A representative in TLC's variable order is the one whose fingerprint TLC reports.
|
|
832
832
|
const representative =
|
|
833
|
-
symmetryGroup
|
|
833
|
+
symmetryGroup === undefined
|
|
834
|
+
? state
|
|
835
|
+
: getRepresentative(state, symmetryGroup, getTlcOrder());
|
|
834
836
|
return view === undefined ? representative : [getViewValue(view.expression, representative)];
|
|
835
837
|
},
|
|
836
838
|
findViolatedInvariant: (state, parent) =>
|
|
@@ -1130,12 +1132,13 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1130
1132
|
failure: { ...result.failure, replay: { output: replayed, ...replayedStack, isBeforeError } },
|
|
1131
1133
|
};
|
|
1132
1134
|
};
|
|
1133
|
-
// TLC fingerprints a state outside CallStackTool, so a failure
|
|
1135
|
+
// TLC fingerprints a state outside CallStackTool, so a failure of a value with a source leaves
|
|
1136
|
+
// the stack empty. Any other failure keeps the stack of the initial predicate.
|
|
1134
1137
|
const fingerprintReplayed = (state: Value[], traced: Environment) => {
|
|
1135
1138
|
try {
|
|
1136
1139
|
getStateHash(getFingerprintState(state));
|
|
1137
1140
|
} catch (error) {
|
|
1138
|
-
if (traced.trace) traced.trace.length = 0;
|
|
1141
|
+
if (traced.trace && getFingerprintTrace(error)) traced.trace.length = 0;
|
|
1139
1142
|
throw error;
|
|
1140
1143
|
}
|
|
1141
1144
|
};
|
|
@@ -1388,6 +1391,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1388
1391
|
let hash = 0x811c9dc5;
|
|
1389
1392
|
for (let index = 0; index < state.length; index++)
|
|
1390
1393
|
hash = combineHash(hash, getValueHash(state[index]));
|
|
1394
|
+
assertFingerprintable(state);
|
|
1391
1395
|
return hash & 0x3fffffff;
|
|
1392
1396
|
};
|
|
1393
1397
|
const isSameState = (stored: Value[], state: Value[]) => {
|