tla-ts 0.0.3-dev.3cf2ad0 → 0.0.3-dev.40085a4
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/README.md +16 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +71 -22
- package/dist/index.d.ts +71 -22
- 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 +20 -17
- package/dist/run-cli.js +22 -19
- package/dist/transfer.cjs +46 -16
- package/dist/transfer.js +46 -16
- package/package.json +1 -1
- package/src/ast.ts +121 -4
- package/src/builtins.ts +9 -3
- package/src/check.ts +514 -99
- package/src/cli-options.ts +11 -5
- package/src/codegen.ts +15 -22
- package/src/config.ts +224 -170
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +410 -130
- package/src/errors.ts +109 -3
- package/src/evaluate.ts +255 -159
- package/src/exit-codes.ts +39 -42
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +17 -16
- package/src/levels.ts +185 -44
- package/src/lexer.ts +5 -1
- package/src/live-check.ts +772 -0
- package/src/liveness.ts +120 -543
- package/src/parallel-worker.ts +7 -3
- package/src/parallel.ts +20 -4
- package/src/parser.ts +184 -54
- package/src/resolve.ts +1378 -420
- package/src/run-cli.ts +115 -20
- package/src/runtime.ts +3 -1
- package/src/sany-lexer.ts +615 -0
- package/src/sany-parse-error.ts +3143 -0
- package/src/spec-description.ts +19 -8
- package/src/standard-modules.ts +54 -45
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +231 -171
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +183 -39
- package/src/symmetry.ts +25 -7
- package/src/tableau.ts +51 -24
- package/src/tlc-ext.ts +29 -12
- package/src/tlc-module.ts +14 -33
- package/src/tlc-modules.ts +4 -0
- package/src/tlc-order.ts +25 -7
- package/src/tlc-random.ts +9 -6
- package/src/tlc-summary.ts +20 -5
- package/src/value-sources.ts +29 -0
- package/src/values.ts +242 -61
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ The options are:
|
|
|
50
50
|
|
|
51
51
|
- `-config <Spec.cfg>`: read the configuration from this file. You can use it only when you check one spec.
|
|
52
52
|
- `-deadlock`: don't report deadlocks.
|
|
53
|
+
- `-dump [dot[,colorize][,actionlabels][,snapshot]] <file>`: write every reachable state to `<file>.dump`, or with `dot`, the state graph to `<file>.dot`. The output matches TLC run with `-fp 0`. tla-ts doesn't support the `constrained`, `stuttering`, or `strict` formats.
|
|
53
54
|
- `-lncheck final`: check liveness once, after the search ends.
|
|
54
55
|
- `-seed <num>`: seed `RandomElement` and the `Randomization` module. The default is 0.
|
|
55
56
|
- `-workers <count|auto>`: search with this number of worker threads. `auto` uses one thread per core. The default is 1.
|
|
@@ -115,9 +116,12 @@ const result = await check({
|
|
|
115
116
|
| `loadClass` | Returns a compiled Java class that overrides a module's operators with constants |
|
|
116
117
|
| `onPrint` | Receives the output of `Print` and `PrintT`. Defaults to `console.log` |
|
|
117
118
|
| `onPause` | Runs when `TLCSet("pause", TRUE)` pauses checking, which resumes when it returns |
|
|
118
|
-
| `readFile`, `writeFile` | Read and write files for the Json module
|
|
119
|
+
| `readFile`, `writeFile` | Read and write files for the Json module and `dump` |
|
|
119
120
|
| `seed` | A `bigint` seed. Defaults to `0n`, and matches TLC run with the same `-seed` and `-fp 0` |
|
|
120
121
|
| `workers` | The number of worker threads. Defaults to 1 |
|
|
122
|
+
| `dump` | Writes the reachable states or the state graph, as TLC's `-dump` does |
|
|
123
|
+
|
|
124
|
+
`dump` takes the `path` that `check` passes to `writeFile` before it returns. Set `dot` to write the state graph in the DOT language of Graphviz, and `colorize`, `actionLabels`, or `snapshot` for TLC's formats of the same names. A dump checks the spec on the calling thread, as one TLC worker does.
|
|
121
125
|
|
|
122
126
|
The result has these fields:
|
|
123
127
|
|
|
@@ -131,8 +135,9 @@ Workers run in Node, Bun, Deno, and cross-origin isolated pages in the browser.
|
|
|
131
135
|
- `SharedArrayBuffer` is unavailable, as on a page without cross-origin isolation.
|
|
132
136
|
- The spec has liveness properties.
|
|
133
137
|
- The spec uses impure operators such as `Print`.
|
|
138
|
+
- The configuration has `VIEW`, `POSTCONDITION`, or `_POSSIBLE`.
|
|
134
139
|
|
|
135
|
-
After a violation, `check` reruns on the calling thread to return
|
|
140
|
+
After a violation or an error, `check` reruns on the calling thread to return TLC's exact trace.
|
|
136
141
|
|
|
137
142
|
`check` supports:
|
|
138
143
|
|
|
@@ -196,6 +201,15 @@ Wall time on one worker, including JVM and Node startup. Both checkers report th
|
|
|
196
201
|
| [Bounded queue](packages/tla-ts/benchmarks/queue) | 44,044 | 0.37 s | 0.17 s | 2.2× |
|
|
197
202
|
| 542 conformance models | | 986.6 s | 403.3 s | 2.4× |
|
|
198
203
|
|
|
204
|
+
Wall time on 8 workers, also including startup. Each time is the median of 3 runs on an Apple M4 Pro.
|
|
205
|
+
|
|
206
|
+
| Spec | Distinct states | TLC | tla-ts | Speedup |
|
|
207
|
+
| --------------------------------------------------------------------------------------------------------------------- | --------------: | ------: | -----: | ------: |
|
|
208
|
+
| [Raft with reconfiguration](https://github.com/will62794/tla-web/blob/8193eb0/specs/RaftWithReconfigSingleServer.tla) | 298,493 | 10.50 s | 8.96 s | 1.2× |
|
|
209
|
+
| [Sailfish](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/dag-consensus) | 109,604 | 4.34 s | 4.07 s | 1.1× |
|
|
210
|
+
| [Fast Paxos](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/SimplifiedFastPaxos) | 25,617 | 3.91 s | 2.57 s | 1.5× |
|
|
211
|
+
| [Buffered random access file](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/braf) | 3,316 | 4.70 s | 3.61 s | 1.3× |
|
|
212
|
+
|
|
199
213
|
## Development
|
|
200
214
|
|
|
201
215
|
```shell
|
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.
|
|
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;
|
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
|
+
selectorRanges?: SourceRange[];
|
|
41
42
|
location: SourceLocation;
|
|
42
43
|
resolution?: LocalResolution;
|
|
43
44
|
}
|
|
@@ -46,6 +47,9 @@ interface ApplyExpression {
|
|
|
46
47
|
operator: string;
|
|
47
48
|
args: Expression[];
|
|
48
49
|
argumentCounts?: number[];
|
|
50
|
+
argumentsRange?: SourceRange;
|
|
51
|
+
selectorRanges?: SourceRange[];
|
|
52
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
49
53
|
location: SourceLocation;
|
|
50
54
|
resolution?: LocalResolution;
|
|
51
55
|
}
|
|
@@ -57,6 +61,7 @@ interface OperatorReferenceExpression {
|
|
|
57
61
|
interface LambdaExpression {
|
|
58
62
|
kind: "Lambda";
|
|
59
63
|
params: string[];
|
|
64
|
+
paramRanges?: SourceRange[];
|
|
60
65
|
body: Expression;
|
|
61
66
|
location: SourceLocation;
|
|
62
67
|
}
|
|
@@ -108,9 +113,11 @@ interface LetExpression {
|
|
|
108
113
|
type BoundPattern = {
|
|
109
114
|
kind: "Name";
|
|
110
115
|
name: string;
|
|
116
|
+
ranges?: SourceRange[];
|
|
111
117
|
} | {
|
|
112
118
|
kind: "Tuple";
|
|
113
119
|
names: string[];
|
|
120
|
+
ranges?: SourceRange[];
|
|
114
121
|
};
|
|
115
122
|
interface Bound {
|
|
116
123
|
pattern: BoundPattern;
|
|
@@ -126,6 +133,7 @@ interface UnboundedQuantifierExpression {
|
|
|
126
133
|
kind: "UnboundedQuantifier";
|
|
127
134
|
quantifier: "Forall" | "Exists";
|
|
128
135
|
names: string[];
|
|
136
|
+
nameRanges?: SourceRange[];
|
|
129
137
|
isTemporal?: boolean;
|
|
130
138
|
body: Expression;
|
|
131
139
|
location: SourceLocation;
|
|
@@ -175,6 +183,7 @@ interface FunctionSetExpression {
|
|
|
175
183
|
interface RecordField {
|
|
176
184
|
name: string;
|
|
177
185
|
value: Expression;
|
|
186
|
+
location: SourceLocation;
|
|
178
187
|
}
|
|
179
188
|
interface RecordExpression {
|
|
180
189
|
kind: "Record" | "RecordSet";
|
|
@@ -241,6 +250,7 @@ interface LabelExpression {
|
|
|
241
250
|
kind: "Label";
|
|
242
251
|
name: string;
|
|
243
252
|
params: string[];
|
|
253
|
+
paramRanges?: SourceRange[];
|
|
244
254
|
body: Expression;
|
|
245
255
|
location: SourceLocation;
|
|
246
256
|
}
|
|
@@ -262,6 +272,8 @@ type Selector = {
|
|
|
262
272
|
interface SubexpressionExpression {
|
|
263
273
|
kind: "Subexpression";
|
|
264
274
|
selectors: Selector[];
|
|
275
|
+
selectorRanges?: SourceRange[];
|
|
276
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
265
277
|
location: SourceLocation;
|
|
266
278
|
}
|
|
267
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;
|
|
@@ -303,6 +315,7 @@ interface Assumption {
|
|
|
303
315
|
}
|
|
304
316
|
interface InstanceSubstitution {
|
|
305
317
|
name: string;
|
|
318
|
+
nameRange: SourceRange;
|
|
306
319
|
expression: Expression;
|
|
307
320
|
}
|
|
308
321
|
interface Instance {
|
|
@@ -322,6 +335,7 @@ interface NewSymbol {
|
|
|
322
335
|
arity: number;
|
|
323
336
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
324
337
|
set: Expression | undefined;
|
|
338
|
+
nameRange?: SourceRange;
|
|
325
339
|
location: SourceLocation;
|
|
326
340
|
}
|
|
327
341
|
interface AssumeProve {
|
|
@@ -371,6 +385,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
371
385
|
} | {
|
|
372
386
|
kind: "Take";
|
|
373
387
|
names: string[];
|
|
388
|
+
nameRanges?: SourceRange[];
|
|
374
389
|
bounds: Bound[];
|
|
375
390
|
} | {
|
|
376
391
|
kind: "Witness";
|
|
@@ -378,6 +393,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
378
393
|
} | {
|
|
379
394
|
kind: "Pick";
|
|
380
395
|
names: string[];
|
|
396
|
+
nameRanges?: SourceRange[];
|
|
381
397
|
bounds: Bound[];
|
|
382
398
|
body: Expression;
|
|
383
399
|
} | {
|
|
@@ -395,6 +411,7 @@ interface ProofStep {
|
|
|
395
411
|
token: string;
|
|
396
412
|
body: StepBody;
|
|
397
413
|
head: SourceRange;
|
|
414
|
+
statement: SourceRange;
|
|
398
415
|
proof: Proof | undefined;
|
|
399
416
|
location: SourceLocation;
|
|
400
417
|
}
|
|
@@ -494,28 +511,6 @@ interface ModelConfig {
|
|
|
494
511
|
rlReward: string | undefined;
|
|
495
512
|
}
|
|
496
513
|
export declare const parseConfig: (source: string) => ModelConfig;
|
|
497
|
-
export declare class TlaError extends Error {
|
|
498
|
-
constructor(message: string, cause?: unknown);
|
|
499
|
-
}
|
|
500
|
-
interface SyntaxFailure {
|
|
501
|
-
reason: string;
|
|
502
|
-
line: number;
|
|
503
|
-
column: number;
|
|
504
|
-
isEnd: boolean;
|
|
505
|
-
}
|
|
506
|
-
export declare class TlaSyntaxError extends TlaError {
|
|
507
|
-
failure: SyntaxFailure | undefined;
|
|
508
|
-
constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
|
|
509
|
-
}
|
|
510
|
-
export declare class TlaConfigError extends TlaError {
|
|
511
|
-
constructor(message: string, cause?: unknown);
|
|
512
|
-
}
|
|
513
|
-
export declare class TlaEvaluationError extends TlaError {
|
|
514
|
-
constructor(message: string, cause?: unknown);
|
|
515
|
-
}
|
|
516
|
-
export declare class TlaUnsupportedError extends TlaError {
|
|
517
|
-
constructor(message: string, cause?: unknown);
|
|
518
|
-
}
|
|
519
514
|
interface ModelValue {
|
|
520
515
|
kind: "ModelValue";
|
|
521
516
|
name: string;
|
|
@@ -602,6 +597,46 @@ interface LazyFunctionValue {
|
|
|
602
597
|
}
|
|
603
598
|
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
604
599
|
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 {
|
|
604
|
+
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
|
+
}
|
|
633
|
+
interface StateDump {
|
|
634
|
+
path: string;
|
|
635
|
+
dot?: boolean;
|
|
636
|
+
colorize?: boolean;
|
|
637
|
+
actionLabels?: boolean;
|
|
638
|
+
snapshot?: boolean;
|
|
639
|
+
}
|
|
605
640
|
interface CheckOptions {
|
|
606
641
|
source: string;
|
|
607
642
|
config: string | ModelConfig;
|
|
@@ -614,6 +649,7 @@ interface CheckOptions {
|
|
|
614
649
|
seed?: bigint;
|
|
615
650
|
workers?: number;
|
|
616
651
|
livenessCheck?: "default" | "final";
|
|
652
|
+
dump?: StateDump;
|
|
617
653
|
}
|
|
618
654
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
619
655
|
interface TraceStep {
|
|
@@ -623,6 +659,7 @@ interface TraceStep {
|
|
|
623
659
|
}
|
|
624
660
|
interface Violation {
|
|
625
661
|
name: string;
|
|
662
|
+
properties?: string[];
|
|
626
663
|
trace: TraceStep[];
|
|
627
664
|
loopStart: number | undefined;
|
|
628
665
|
loopLabel?: string;
|
|
@@ -640,6 +677,18 @@ interface EvaluationFailure {
|
|
|
640
677
|
trace: TraceStep[];
|
|
641
678
|
initialState: Record<string, Value> | undefined;
|
|
642
679
|
exitCode: number;
|
|
680
|
+
replay?: Replay;
|
|
681
|
+
isWithoutStatistics?: boolean;
|
|
682
|
+
}
|
|
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;
|
|
643
692
|
}
|
|
644
693
|
interface CheckResult {
|
|
645
694
|
status: CheckStatus;
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ interface StringExpression {
|
|
|
38
38
|
interface IdentifierExpression {
|
|
39
39
|
kind: "Identifier";
|
|
40
40
|
name: string;
|
|
41
|
+
selectorRanges?: SourceRange[];
|
|
41
42
|
location: SourceLocation;
|
|
42
43
|
resolution?: LocalResolution;
|
|
43
44
|
}
|
|
@@ -46,6 +47,9 @@ interface ApplyExpression {
|
|
|
46
47
|
operator: string;
|
|
47
48
|
args: Expression[];
|
|
48
49
|
argumentCounts?: number[];
|
|
50
|
+
argumentsRange?: SourceRange;
|
|
51
|
+
selectorRanges?: SourceRange[];
|
|
52
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
49
53
|
location: SourceLocation;
|
|
50
54
|
resolution?: LocalResolution;
|
|
51
55
|
}
|
|
@@ -57,6 +61,7 @@ interface OperatorReferenceExpression {
|
|
|
57
61
|
interface LambdaExpression {
|
|
58
62
|
kind: "Lambda";
|
|
59
63
|
params: string[];
|
|
64
|
+
paramRanges?: SourceRange[];
|
|
60
65
|
body: Expression;
|
|
61
66
|
location: SourceLocation;
|
|
62
67
|
}
|
|
@@ -108,9 +113,11 @@ interface LetExpression {
|
|
|
108
113
|
type BoundPattern = {
|
|
109
114
|
kind: "Name";
|
|
110
115
|
name: string;
|
|
116
|
+
ranges?: SourceRange[];
|
|
111
117
|
} | {
|
|
112
118
|
kind: "Tuple";
|
|
113
119
|
names: string[];
|
|
120
|
+
ranges?: SourceRange[];
|
|
114
121
|
};
|
|
115
122
|
interface Bound {
|
|
116
123
|
pattern: BoundPattern;
|
|
@@ -126,6 +133,7 @@ interface UnboundedQuantifierExpression {
|
|
|
126
133
|
kind: "UnboundedQuantifier";
|
|
127
134
|
quantifier: "Forall" | "Exists";
|
|
128
135
|
names: string[];
|
|
136
|
+
nameRanges?: SourceRange[];
|
|
129
137
|
isTemporal?: boolean;
|
|
130
138
|
body: Expression;
|
|
131
139
|
location: SourceLocation;
|
|
@@ -175,6 +183,7 @@ interface FunctionSetExpression {
|
|
|
175
183
|
interface RecordField {
|
|
176
184
|
name: string;
|
|
177
185
|
value: Expression;
|
|
186
|
+
location: SourceLocation;
|
|
178
187
|
}
|
|
179
188
|
interface RecordExpression {
|
|
180
189
|
kind: "Record" | "RecordSet";
|
|
@@ -241,6 +250,7 @@ interface LabelExpression {
|
|
|
241
250
|
kind: "Label";
|
|
242
251
|
name: string;
|
|
243
252
|
params: string[];
|
|
253
|
+
paramRanges?: SourceRange[];
|
|
244
254
|
body: Expression;
|
|
245
255
|
location: SourceLocation;
|
|
246
256
|
}
|
|
@@ -262,6 +272,8 @@ type Selector = {
|
|
|
262
272
|
interface SubexpressionExpression {
|
|
263
273
|
kind: "Subexpression";
|
|
264
274
|
selectors: Selector[];
|
|
275
|
+
selectorRanges?: SourceRange[];
|
|
276
|
+
argumentRanges?: (SourceRange | undefined)[];
|
|
265
277
|
location: SourceLocation;
|
|
266
278
|
}
|
|
267
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;
|
|
@@ -303,6 +315,7 @@ interface Assumption {
|
|
|
303
315
|
}
|
|
304
316
|
interface InstanceSubstitution {
|
|
305
317
|
name: string;
|
|
318
|
+
nameRange: SourceRange;
|
|
306
319
|
expression: Expression;
|
|
307
320
|
}
|
|
308
321
|
interface Instance {
|
|
@@ -322,6 +335,7 @@ interface NewSymbol {
|
|
|
322
335
|
arity: number;
|
|
323
336
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
324
337
|
set: Expression | undefined;
|
|
338
|
+
nameRange?: SourceRange;
|
|
325
339
|
location: SourceLocation;
|
|
326
340
|
}
|
|
327
341
|
interface AssumeProve {
|
|
@@ -371,6 +385,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
371
385
|
} | {
|
|
372
386
|
kind: "Take";
|
|
373
387
|
names: string[];
|
|
388
|
+
nameRanges?: SourceRange[];
|
|
374
389
|
bounds: Bound[];
|
|
375
390
|
} | {
|
|
376
391
|
kind: "Witness";
|
|
@@ -378,6 +393,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
378
393
|
} | {
|
|
379
394
|
kind: "Pick";
|
|
380
395
|
names: string[];
|
|
396
|
+
nameRanges?: SourceRange[];
|
|
381
397
|
bounds: Bound[];
|
|
382
398
|
body: Expression;
|
|
383
399
|
} | {
|
|
@@ -395,6 +411,7 @@ interface ProofStep {
|
|
|
395
411
|
token: string;
|
|
396
412
|
body: StepBody;
|
|
397
413
|
head: SourceRange;
|
|
414
|
+
statement: SourceRange;
|
|
398
415
|
proof: Proof | undefined;
|
|
399
416
|
location: SourceLocation;
|
|
400
417
|
}
|
|
@@ -494,28 +511,6 @@ interface ModelConfig {
|
|
|
494
511
|
rlReward: string | undefined;
|
|
495
512
|
}
|
|
496
513
|
export declare const parseConfig: (source: string) => ModelConfig;
|
|
497
|
-
export declare class TlaError extends Error {
|
|
498
|
-
constructor(message: string, cause?: unknown);
|
|
499
|
-
}
|
|
500
|
-
interface SyntaxFailure {
|
|
501
|
-
reason: string;
|
|
502
|
-
line: number;
|
|
503
|
-
column: number;
|
|
504
|
-
isEnd: boolean;
|
|
505
|
-
}
|
|
506
|
-
export declare class TlaSyntaxError extends TlaError {
|
|
507
|
-
failure: SyntaxFailure | undefined;
|
|
508
|
-
constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
|
|
509
|
-
}
|
|
510
|
-
export declare class TlaConfigError extends TlaError {
|
|
511
|
-
constructor(message: string, cause?: unknown);
|
|
512
|
-
}
|
|
513
|
-
export declare class TlaEvaluationError extends TlaError {
|
|
514
|
-
constructor(message: string, cause?: unknown);
|
|
515
|
-
}
|
|
516
|
-
export declare class TlaUnsupportedError extends TlaError {
|
|
517
|
-
constructor(message: string, cause?: unknown);
|
|
518
|
-
}
|
|
519
514
|
interface ModelValue {
|
|
520
515
|
kind: "ModelValue";
|
|
521
516
|
name: string;
|
|
@@ -602,6 +597,46 @@ interface LazyFunctionValue {
|
|
|
602
597
|
}
|
|
603
598
|
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
604
599
|
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 {
|
|
604
|
+
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
|
+
}
|
|
633
|
+
interface StateDump {
|
|
634
|
+
path: string;
|
|
635
|
+
dot?: boolean;
|
|
636
|
+
colorize?: boolean;
|
|
637
|
+
actionLabels?: boolean;
|
|
638
|
+
snapshot?: boolean;
|
|
639
|
+
}
|
|
605
640
|
interface CheckOptions {
|
|
606
641
|
source: string;
|
|
607
642
|
config: string | ModelConfig;
|
|
@@ -614,6 +649,7 @@ interface CheckOptions {
|
|
|
614
649
|
seed?: bigint;
|
|
615
650
|
workers?: number;
|
|
616
651
|
livenessCheck?: "default" | "final";
|
|
652
|
+
dump?: StateDump;
|
|
617
653
|
}
|
|
618
654
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
619
655
|
interface TraceStep {
|
|
@@ -623,6 +659,7 @@ interface TraceStep {
|
|
|
623
659
|
}
|
|
624
660
|
interface Violation {
|
|
625
661
|
name: string;
|
|
662
|
+
properties?: string[];
|
|
626
663
|
trace: TraceStep[];
|
|
627
664
|
loopStart: number | undefined;
|
|
628
665
|
loopLabel?: string;
|
|
@@ -640,6 +677,18 @@ interface EvaluationFailure {
|
|
|
640
677
|
trace: TraceStep[];
|
|
641
678
|
initialState: Record<string, Value> | undefined;
|
|
642
679
|
exitCode: number;
|
|
680
|
+
replay?: Replay;
|
|
681
|
+
isWithoutStatistics?: boolean;
|
|
682
|
+
}
|
|
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;
|
|
643
692
|
}
|
|
644
693
|
interface CheckResult {
|
|
645
694
|
status: CheckStatus;
|
package/dist/index.js
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
|
-
import{
|
|
9
|
+
import{F as e,L as t,N as n,O as r,P as i,R as a,j as o,x as s}from"./transfer.js";import{t as c}from"./parallel.js";export{n as TlaConfigError,i as TlaError,e as TlaEvaluationError,t as TlaSyntaxError,a as TlaUnsupportedError,c as check,r as formatValue,o as parseConfig,s as parseModule};
|
package/dist/parallel-worker.cjs
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
const e=require("./transfer.cjs"),t=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
10
10
|
/* @vite-ignore */
|
|
11
11
|
/* webpackIgnore: true */
|
|
12
|
-
`node:worker_threads`)).parentPort,n=(t,n)=>{let r=new Map(t.modules),i=e=>r.get(e),a=new Map(t.classes);e.
|
|
12
|
+
`node:worker_threads`)).parentPort,n=(t,n)=>{let r=new Map(t.modules),i=e=>r.get(e),a=new Map(t.classes);e.A(e.y(t.source,t.config,i));let o=e.k(),s=e._(t.config,{source:t.source,loadModule:i,loadClass:e=>a.get(e),print:()=>{},files:{readFile:void 0,writeFile:void 0}}).environment,c=e.u(t.config,s,()=>e.v(t.source,i,`variable`)),l=c?.spec.next;if(!c||l===void 0)return n.postMessage({type:`abort`});let u=t.index,d=e.E(),f=e.t(s.variables.length),p={fingerprints:t.fingerprints},m=t.requests,h=t.remaining,g=c.isSymmetric?e.r():void 0,_=/* @__PURE__ */ new Int32Array(2),v={resume:()=>{},loot:e=>{}};t.ports.forEach(e=>{e?.addEventListener(`message`,e=>v.loot(e.data)),e?.start?.()});let y={states:f(t.seed).map(d)},b=(n,r)=>{let i=Atomics.load(m,u)-1,a=Math.floor((n.end-n.origin-1)/2),o=e.n(),s=n.states.slice(n.end-a,n.end),c=a>0&&s.every(o.encode);c&&(n.end-=a);let l=c?o.finish():e.n().finish();t.ports[i]?.postMessage(l,[l.words.buffer]),Atomics.store(m,u,r),Atomics.notify(m,u)},x=e=>{Atomics.store(h,u,0),Atomics.compareExchange(m,u,0,-1)!==0&&b(e,-1)},S=e=>{Atomics.store(h,u,e.end-e.origin),Atomics.store(m,u,0)},C=n=>{for(;n.origin<n.end;n.origin++){let r=n.states[n.origin];if(!n.successors&&(Atomics.load(m,u)>0&&b(n,0),Atomics.store(h,u,n.end-n.origin-1),n.successors=e.T(l,r,s,c.spec.scope),n.generated+=n.successors.length,n.successors.length===0&&t.config.checkDeadlock))return;let i=n.successors;for(;n.index<i.length;n.index++){if(e.s(p.fingerprints))return`paused`;let t=i[n.index];if(c.findViolatedActionProperty(r,t.state))return;if(!c.satisfiesActionConstraints(r,t.state)){if(c.findViolatedInvariant(t.state,r))return;continue}if(g&&(e.c(t.state,_),!g.insert(_[0],_[1])))continue;d(t.state);let a=c.getFingerprintState(t.state);if(e.c(a,_),e.o(p.fingerprints,_[0],_[1])){if(c.findViolatedInvariant(t.state,r))return;c.satisfiesConstraints(t.state,r)&&(n.next.push(t.state),n.fingerprintStates.push(a),n.added++)}}n.outDegrees[Math.min(n.added,31)]++,n.successors=void 0,n.index=0,n.added=0}return`done`},w=async e=>{let n=/* @__PURE__ */ new Set;for(;;){let r=t.ports.reduce((e,t,r)=>!t||n.has(r)||Atomics.load(h,r)<2?e:e===void 0||Atomics.load(h,r)>Atomics.load(h,e)?r:e,void 0);if(r===void 0)return!1;let i=Atomics.compareExchange(m,r,0,u+1);if(i===-1&&n.add(r),i>0&&Atomics.wait(m,r,i),i!==0)continue;let a=await new Promise(e=>v.loot=e);if(a.count===0)n.add(r);else return e.states=f(a).map(d),e.origin=0,e.end=e.states.length,S(e),!0}},T=e=>n.postMessage(e,e.type===`level`?[e.fingerprints.buffer]:[]),E=async t=>{let n={states:y.states,origin:0,end:y.states.length,successors:void 0,index:0,added:0,generated:0,outDegrees:Array.from({length:32},()=>0),next:[],fingerprintStates:[]};for(;;){let e=C(n);if(e===void 0)return;if(x(n),e===`paused`){let e=new Promise(e=>v.resume=e);T({type:`paused`}),await e,S(n)}else if(!await w(n))break}if(e.k()===o)return y.states=n.next,Atomics.store(h,u,y.states.length),{type:`level`,level:t,generated:n.generated,added:n.next.length,outDegrees:n.outDegrees,fingerprints:c.getStoredFingerprints(n.next,n.fingerprintStates)}},D=e=>{E(e).then(e=>T(e??{type:`abort`}),()=>T({type:`abort`}))};n.addEventListener(`message`,e=>{let t=e.data;t.type===`level`&&D(t.level),t.type===`resize`&&(p.fingerprints=t.fingerprints,v.resume())}),Atomics.store(h,u,y.states.length),T({type:`ready`})};t().then(e=>{let t=r=>{let i=r.data;if(i.type===`start`){e.removeEventListener?.(`message`,t);try{n(i,e)}catch{e.postMessage({type:`abort`})}}};e.addEventListener(`message`,t),e.start?.()});
|
package/dist/parallel-worker.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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
|
-
import{
|
|
9
|
+
import{A as e,E as t,T as n,_ as r,c as i,k as a,n as o,o as s,r as c,s as l,t as u,u as d,v as f,y as p}from"./transfer.js";const m=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
10
10
|
/* @vite-ignore */
|
|
11
11
|
/* webpackIgnore: true */
|
|
12
|
-
`node:worker_threads`)).parentPort,h=(m,h)=>{let g=new Map(m.modules),_=e=>g.get(e),v=new Map(m.classes);
|
|
12
|
+
`node:worker_threads`)).parentPort,h=(m,h)=>{let g=new Map(m.modules),_=e=>g.get(e),v=new Map(m.classes);e(p(m.source,m.config,_));let y=a(),b=r(m.config,{source:m.source,loadModule:_,loadClass:e=>v.get(e),print:()=>{},files:{readFile:void 0,writeFile:void 0}}).environment,x=d(m.config,b,()=>f(m.source,_,`variable`)),S=x?.spec.next;if(!x||S===void 0)return h.postMessage({type:`abort`});let C=m.index,w=t(),T=u(b.variables.length),E={fingerprints:m.fingerprints},D=m.requests,O=m.remaining,k=x.isSymmetric?c():void 0,A=/* @__PURE__ */ new Int32Array(2),j={resume:()=>{},loot:e=>{}};m.ports.forEach(e=>{e?.addEventListener(`message`,e=>j.loot(e.data)),e?.start?.()});let M={states:T(m.seed).map(w)},N=(e,t)=>{let n=Atomics.load(D,C)-1,r=Math.floor((e.end-e.origin-1)/2),i=o(),a=e.states.slice(e.end-r,e.end),s=r>0&&a.every(i.encode);s&&(e.end-=r);let c=s?i.finish():o().finish();m.ports[n]?.postMessage(c,[c.words.buffer]),Atomics.store(D,C,t),Atomics.notify(D,C)},P=e=>{Atomics.store(O,C,0),Atomics.compareExchange(D,C,0,-1)!==0&&N(e,-1)},F=e=>{Atomics.store(O,C,e.end-e.origin),Atomics.store(D,C,0)},I=e=>{for(;e.origin<e.end;e.origin++){let t=e.states[e.origin];if(!e.successors&&(Atomics.load(D,C)>0&&N(e,0),Atomics.store(O,C,e.end-e.origin-1),e.successors=n(S,t,b,x.spec.scope),e.generated+=e.successors.length,e.successors.length===0&&m.config.checkDeadlock))return;let r=e.successors;for(;e.index<r.length;e.index++){if(l(E.fingerprints))return`paused`;let n=r[e.index];if(x.findViolatedActionProperty(t,n.state))return;if(!x.satisfiesActionConstraints(t,n.state)){if(x.findViolatedInvariant(n.state,t))return;continue}if(k&&(i(n.state,A),!k.insert(A[0],A[1])))continue;w(n.state);let a=x.getFingerprintState(n.state);if(i(a,A),s(E.fingerprints,A[0],A[1])){if(x.findViolatedInvariant(n.state,t))return;x.satisfiesConstraints(n.state,t)&&(e.next.push(n.state),e.fingerprintStates.push(a),e.added++)}}e.outDegrees[Math.min(e.added,31)]++,e.successors=void 0,e.index=0,e.added=0}return`done`},L=async e=>{let t=/* @__PURE__ */ new Set;for(;;){let n=m.ports.reduce((e,n,r)=>!n||t.has(r)||Atomics.load(O,r)<2?e:e===void 0||Atomics.load(O,r)>Atomics.load(O,e)?r:e,void 0);if(n===void 0)return!1;let r=Atomics.compareExchange(D,n,0,C+1);if(r===-1&&t.add(n),r>0&&Atomics.wait(D,n,r),r!==0)continue;let i=await new Promise(e=>j.loot=e);if(i.count===0)t.add(n);else return e.states=T(i).map(w),e.origin=0,e.end=e.states.length,F(e),!0}},R=e=>h.postMessage(e,e.type===`level`?[e.fingerprints.buffer]:[]),z=async e=>{let t={states:M.states,origin:0,end:M.states.length,successors:void 0,index:0,added:0,generated:0,outDegrees:Array.from({length:32},()=>0),next:[],fingerprintStates:[]};for(;;){let e=I(t);if(e===void 0)return;if(P(t),e===`paused`){let e=new Promise(e=>j.resume=e);R({type:`paused`}),await e,F(t)}else if(!await L(t))break}if(a()===y)return M.states=t.next,Atomics.store(O,C,M.states.length),{type:`level`,level:e,generated:t.generated,added:t.next.length,outDegrees:t.outDegrees,fingerprints:x.getStoredFingerprints(t.next,t.fingerprintStates)}},B=e=>{z(e).then(e=>R(e??{type:`abort`}),()=>R({type:`abort`}))};h.addEventListener(`message`,e=>{let t=e.data;t.type===`level`&&B(t.level),t.type===`resize`&&(E.fingerprints=t.fingerprints,j.resume())}),Atomics.store(O,C,M.states.length),R({type:`ready`})};m().then(e=>{let t=n=>{let r=n.data;if(r.type===`start`){e.removeEventListener?.(`message`,t);try{h(r,e)}catch{e.postMessage({type:`abort`})}}};e.addEventListener(`message`,t),e.start?.()});
|
package/dist/parallel.cjs
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
const e=require("./transfer.cjs"),t=async e=>{if(typeof Worker==`function`){let t=new Worker(new URL(`./parallel-worker.js`,require("url").pathToFileURL(__filename).href),{type:`module`});return t.addEventListener(`message`,t=>e(t.data)),t.addEventListener(`error`,()=>e({type:`abort`})),t}let t=new(await(import(
|
|
10
10
|
/* @vite-ignore */
|
|
11
11
|
/* webpackIgnore: true */
|
|
12
|
-
`node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,require("url").pathToFileURL(__filename).href));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},n=async n=>{let r=typeof n.config==`string`?e.
|
|
12
|
+
`node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,require("url").pathToFileURL(__filename).href));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},n=async n=>{let r=typeof n.config==`string`?e.j(n.config):n.config,i=n.onPrint??console.log,a={count:0},o=()=>{let t={count:a.count};return e.l({...n,config:r,onPrint:e=>t.count-->0?void 0:i(e)})},s=n.workers??1;if(s<2||typeof SharedArrayBuffer!=`function`||n.dump!==void 0||r.view!==void 0||r.postconditions.length>0||r.possible.length>0)return o();let c=/* @__PURE__ */ new Map,l=e=>{let t=n.loadModule?.(e);return c.set(e,t),t},u=/* @__PURE__ */ new Map,d=e=>{let t=n.loadClass?.(e);return u.set(e,t),t};e.A(e.y(n.source,r,l));let f=e.k(),p=e._(r,{source:n.source,loadModule:l,loadClass:d,print:e=>{a.count++,i(e)},files:{readFile:n.readFile,writeFile:n.writeFile}}),m=p.environment,h=e.u(r,m,()=>e.v(n.source,l,`variable`));if(e.d(p.assumptions,m)||!h||h.spec.init===void 0||h.spec.next===void 0||h.properties.liveness.length>0||e.C(m))return o();let g=e.E(),_={fingerprints:e.i()},v=/* @__PURE__ */ new Int32Array(2),y=Array.from({length:s},e.n),b={generatedStates:0,distinctStates:0,queuedStates:0,depth:0,outDegrees:Array.from({length:32},()=>0)},x=[],S=()=>({status:`success`,violation:void 0,failure:void 0,...b,fingerprintDistance:e.m(b.distinctStates,b.generatedStates,()=>{let e=new BigInt64Array(b.distinctStates);return x.reduce((t,n)=>(e.set(n,t),t+n.length),0),e})}),C=t=>{let n=[];for(let r of e.w(t,m,h.spec.scope))if(g(r),b.generatedStates++,e.c(h.getFingerprintState(r),v),e.s(_.fingerprints)&&(_.fingerprints=e.a(_.fingerprints)),e.o(_.fingerprints,v[0],v[1])){if(h.findViolatedInvariant(r)||h.findFailedInitialPredicate(r))return!1;if(h.satisfiesConstraints(r)){if(!y[n.length%s].encode(r))return!1;n.push(r),b.distinctStates++}}return x.push(BigInt64Array.from(n,e=>m.runtime.getFingerprint(e))),!0};try{if(!C(h.spec.init))return o()}catch(t){if(!(t instanceof e.F))throw t;return o()}if(e.k()!==f)return o();if(b.depth=b.generatedStates===0?0:1,b.distinctStates===0)return S();let w=[],T={count:s,resolve:e=>{}},E=e=>{w.push(e),(e.type===`abort`||w.length===T.count)&&T.resolve(w.splice(0))},D=e=>new Promise(t=>{T.count=e,T.resolve=t}),O=D(s),k=new Int32Array(new SharedArrayBuffer(s*4)),A=new Int32Array(new SharedArrayBuffer(s*4)),j=await Promise.all(Array.from({length:s},()=>t(E))),M=()=>j.forEach(e=>e.terminate()),N=/* @__PURE__ */ new Map,P=(e,t)=>{let n=e<t?`${e}:${t}`:`${t}:${e}`,r=N.get(n)??new MessageChannel;return N.set(n,r),e<t?r.port1:r.port2};j.forEach((e,t)=>{let i=Array.from({length:s},(e,n)=>n===t?void 0:P(t,n)),a=y[t].finish(),o={type:`start`,source:n.source,config:r,modules:[...c],classes:[...u],index:t,ports:i,seed:a,fingerprints:_.fingerprints,requests:k,remaining:A};e.postMessage(o,[...i.filter(e=>e!==void 0),a.words.buffer])});let F=e=>e.some(e=>e.type===`abort`),I=e=>j.forEach(t=>t.postMessage(e)),L=async t=>{let n=t.filter(e=>e.type===`paused`).length;if(n===0||F(t))return t;_.fingerprints=e.a(_.fingerprints);let r=D(n);return I({type:`resize`,fingerprints:_.fingerprints}),[...t.filter(e=>e.type!==`paused`),...await L(await r)]};if(F(await O))return M(),o();for(let e=1;;e++){let t=D(s);k.forEach((e,t)=>Atomics.store(k,t,0)),I({type:`level`,level:e});let n=await L(await t);if(F(n))return M(),o();let r=n.flatMap(e=>e.type===`level`?[e]:[]),i=r.reduce((e,t)=>e+t.added,0);if(b.generatedStates+=r.reduce((e,t)=>e+t.generated,0),b.distinctStates+=i,r.forEach(e=>{e.outDegrees.forEach((e,t)=>b.outDegrees[t]+=e),x.push(e.fingerprints)}),i===0)return M(),S();b.depth++}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
package/dist/parallel.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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
|
-
import{A as e,C as t,
|
|
9
|
+
import{A as e,C as t,E as n,F as r,_ as i,a,c as o,d as s,i as c,j as l,k as u,l as ee,m as te,n as d,o as f,s as ne,u as p,v as m,w as h,y as g}from"./transfer.js";const _=async e=>{if(typeof Worker==`function`){let t=new Worker(new URL(`./parallel-worker.js`,import.meta.url),{type:`module`});return t.addEventListener(`message`,t=>e(t.data)),t.addEventListener(`error`,()=>e({type:`abort`})),t}let t=new(await(import(
|
|
10
10
|
/* @vite-ignore */
|
|
11
11
|
/* webpackIgnore: true */
|
|
12
|
-
`node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,import.meta.url));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},
|
|
12
|
+
`node:worker_threads`))).Worker(new URL(`./parallel-worker.js`,import.meta.url));return t.on(`message`,e),t.on(`error`,()=>e({type:`abort`})),{postMessage:(e,n)=>t.postMessage(e,n),terminate:()=>void t.terminate()}},v=async v=>{let y=typeof v.config==`string`?l(v.config):v.config,b=v.onPrint??console.log,x={count:0},S=()=>{let e={count:x.count};return ee({...v,config:y,onPrint:t=>e.count-->0?void 0:b(t)})},C=v.workers??1;if(C<2||typeof SharedArrayBuffer!=`function`||v.dump!==void 0||y.view!==void 0||y.postconditions.length>0||y.possible.length>0)return S();let w=/* @__PURE__ */ new Map,T=e=>{let t=v.loadModule?.(e);return w.set(e,t),t},E=/* @__PURE__ */ new Map,D=e=>{let t=v.loadClass?.(e);return E.set(e,t),t};e(g(v.source,y,T));let O=u(),k=i(y,{source:v.source,loadModule:T,loadClass:D,print:e=>{x.count++,b(e)},files:{readFile:v.readFile,writeFile:v.writeFile}}),A=k.environment,j=p(y,A,()=>m(v.source,T,`variable`));if(s(k.assumptions,A)||!j||j.spec.init===void 0||j.spec.next===void 0||j.properties.liveness.length>0||t(A))return S();let M=n(),N={fingerprints:c()},P=/* @__PURE__ */ new Int32Array(2),F=Array.from({length:C},d),I={generatedStates:0,distinctStates:0,queuedStates:0,depth:0,outDegrees:Array.from({length:32},()=>0)},L=[],R=()=>({status:`success`,violation:void 0,failure:void 0,...I,fingerprintDistance:te(I.distinctStates,I.generatedStates,()=>{let e=new BigInt64Array(I.distinctStates);return L.reduce((t,n)=>(e.set(n,t),t+n.length),0),e})}),z=e=>{let t=[];for(let n of h(e,A,j.spec.scope))if(M(n),I.generatedStates++,o(j.getFingerprintState(n),P),ne(N.fingerprints)&&(N.fingerprints=a(N.fingerprints)),f(N.fingerprints,P[0],P[1])){if(j.findViolatedInvariant(n)||j.findFailedInitialPredicate(n))return!1;if(j.satisfiesConstraints(n)){if(!F[t.length%C].encode(n))return!1;t.push(n),I.distinctStates++}}return L.push(BigInt64Array.from(t,e=>A.runtime.getFingerprint(e))),!0};try{if(!z(j.spec.init))return S()}catch(e){if(!(e instanceof r))throw e;return S()}if(u()!==O)return S();if(I.depth=I.generatedStates===0?0:1,I.distinctStates===0)return R();let B=[],V={count:C,resolve:e=>{}},H=e=>{B.push(e),(e.type===`abort`||B.length===V.count)&&V.resolve(B.splice(0))},U=e=>new Promise(t=>{V.count=e,V.resolve=t}),W=U(C),G=new Int32Array(new SharedArrayBuffer(C*4)),K=new Int32Array(new SharedArrayBuffer(C*4)),q=await Promise.all(Array.from({length:C},()=>_(H))),J=()=>q.forEach(e=>e.terminate()),Y=/* @__PURE__ */ new Map,X=(e,t)=>{let n=e<t?`${e}:${t}`:`${t}:${e}`,r=Y.get(n)??new MessageChannel;return Y.set(n,r),e<t?r.port1:r.port2};q.forEach((e,t)=>{let n=Array.from({length:C},(e,n)=>n===t?void 0:X(t,n)),r=F[t].finish(),i={type:`start`,source:v.source,config:y,modules:[...w],classes:[...E],index:t,ports:n,seed:r,fingerprints:N.fingerprints,requests:G,remaining:K};e.postMessage(i,[...n.filter(e=>e!==void 0),r.words.buffer])});let Z=e=>e.some(e=>e.type===`abort`),Q=e=>q.forEach(t=>t.postMessage(e)),$=async e=>{let t=e.filter(e=>e.type===`paused`).length;if(t===0||Z(e))return e;N.fingerprints=a(N.fingerprints);let n=U(t);return Q({type:`resize`,fingerprints:N.fingerprints}),[...e.filter(e=>e.type!==`paused`),...await $(await n)]};if(Z(await W))return J(),S();for(let e=1;;e++){let t=U(C);G.forEach((e,t)=>Atomics.store(G,t,0)),Q({type:`level`,level:e});let n=await $(await t);if(Z(n))return J(),S();let r=n.flatMap(e=>e.type===`level`?[e]:[]),i=r.reduce((e,t)=>e+t.added,0);if(I.generatedStates+=r.reduce((e,t)=>e+t.generated,0),I.distinctStates+=i,r.forEach(e=>{e.outDegrees.forEach((e,t)=>I.outDegrees[t]+=e),L.push(e.fingerprints)}),i===0)return J(),R();I.depth++}};export{v as t};
|