tla-ts 0.0.2 → 0.0.3-dev.3cf2ad0
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 +63 -11
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +2 -2
- 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 -2
- package/dist/run-cli.js +20 -2
- package/dist/transfer.cjs +12 -12
- package/dist/transfer.js +12 -12
- package/package.json +3 -1
- package/src/ast.ts +43 -3
- package/src/check.ts +43 -10
- package/src/cli-options.ts +58 -0
- package/src/errors.ts +37 -1
- package/src/evaluate.ts +3 -1
- package/src/fingerprints.ts +46 -11
- package/src/lexer.ts +6 -1
- package/src/obligation-action.ts +384 -0
- package/src/obligation-anon.ts +575 -0
- package/src/obligation-deref.ts +637 -0
- package/src/obligation-expression.ts +1060 -0
- package/src/obligation-format.ts +406 -0
- package/src/obligation-generate.ts +1074 -0
- package/src/obligation-levels.ts +329 -0
- package/src/obligation-module.ts +1042 -0
- package/src/obligation-printer.ts +889 -0
- package/src/obligation-proof.ts +76 -0
- package/src/obligation-source.ts +1084 -0
- package/src/obligation-tuples.ts +184 -0
- package/src/obligations.ts +316 -0
- package/src/parallel-worker.ts +163 -211
- package/src/parallel.ts +58 -33
- package/src/parser.ts +285 -52
- package/src/run-cli.ts +295 -27
- package/src/standard-levels.ts +3 -3
- package/src/symmetry.ts +5 -1
- package/src/transfer.ts +22 -1
- package/src/values.ts +59 -23
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](https://npmjs.com/package/tla-ts)
|
|
4
4
|
[](https://npmjs.com/package/tla-ts)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
tla-ts is a drop-in replacement for [TLC](https://github.com/tlaplus/tlaplus) that's **2× faster**.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
TLA+ lets you write formal models of a system, and TLC model checks them. But TLC is written in Java and needs the JVM. tla-ts runs anywhere JavaScript runs, such as the browser, Node, and Bun. Try it in the [playground](https://tla-ts.aidenybai.com).
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
import { check } from "tla-ts";
|
|
@@ -30,19 +30,65 @@ result.status; // "invariant-violation"
|
|
|
30
30
|
npm install tla-ts
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Command line
|
|
34
|
+
|
|
35
|
+
The `tla-ts` command takes TLC's options and prints TLC's output. `tla-ts prove` takes tlapm's options and prints tlapm's output.
|
|
36
|
+
|
|
37
|
+
### Check a spec
|
|
38
|
+
|
|
39
|
+
To check a spec, pass its path:
|
|
34
40
|
|
|
35
41
|
```shell
|
|
36
|
-
npx tla-ts Spec.tla
|
|
42
|
+
npx tla-ts Spec.tla
|
|
37
43
|
```
|
|
38
44
|
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
tla-ts reads the configuration from `Spec.cfg` next to the spec. It exits with the exit code TLC uses for the same result.
|
|
46
|
+
|
|
47
|
+
You can pass several paths, or a glob such as `"specs/*.tla"`. tla-ts checks each spec in turn and exits with the exit code of the first spec that fails. A glob skips each module that has no `.cfg` next to it, so it doesn't check helper modules that other specs import. tla-ts never skips a path that you pass by name. If you pass a `.cfg` path, tla-ts checks the `.tla` file with the same name.
|
|
48
|
+
|
|
49
|
+
The options are:
|
|
50
|
+
|
|
51
|
+
- `-config <Spec.cfg>`: read the configuration from this file. You can use it only when you check one spec.
|
|
52
|
+
- `-deadlock`: don't report deadlocks.
|
|
53
|
+
- `-lncheck final`: check liveness once, after the search ends.
|
|
54
|
+
- `-seed <num>`: seed `RandomElement` and the `Randomization` module. The default is 0.
|
|
55
|
+
- `-workers <count|auto>`: search with this number of worker threads. `auto` uses one thread per core. The default is 1.
|
|
56
|
+
|
|
57
|
+
TLC can replace a module's operators with Java methods, and tla-ts reads the same files. If the spec's directory has `Module.class`, tla-ts replaces each operator in `Module` with the public static method that has the same name and arity.
|
|
58
|
+
|
|
59
|
+
### Generate proof obligations
|
|
60
|
+
|
|
61
|
+
A proof obligation is one claim that a backend prover must prove. `tla-ts prove -N` prints the obligations of a module, as `tlapm -N` does. It doesn't run a prover. For example, this command prints every obligation in `Module.tla` with its text:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
npx tla-ts prove -N --toolbox 0 0 --printallobs Module.tla
|
|
65
|
+
```
|
|
44
66
|
|
|
45
|
-
|
|
67
|
+
With `--toolbox` or `--line`, tla-ts writes the messages of the TLA+ Toolbox protocol to stderr, as tlapm does. If you pass a tlapm option that isn't in this list, tla-ts prints an error:
|
|
68
|
+
|
|
69
|
+
- `--toolbox <start> <end>`: print Toolbox messages for the proofs from line `start` to line `end`. `0 0` selects the whole module.
|
|
70
|
+
- `--line <num>`: print Toolbox messages for the proof at this line.
|
|
71
|
+
- `--printallobs`: print the text of each obligation.
|
|
72
|
+
- `--summary`: print the number of obligations in each module, and list its missing and omitted proofs. You don't need `-N` with `--summary`.
|
|
73
|
+
- `--strict`: report missing proofs, omitted proofs and a selected range with no obligations as errors.
|
|
74
|
+
- `-I <directory>`: search this directory for modules.
|
|
75
|
+
|
|
76
|
+
tla-ts searches for modules in the same order as tlapm:
|
|
77
|
+
|
|
78
|
+
1. The directory of each module you pass, the last one first.
|
|
79
|
+
2. The current directory.
|
|
80
|
+
3. The standard library of tlapm, which has the `TLAPS` module. tla-ts searches it only if `tlapm` is on your `PATH`.
|
|
81
|
+
4. The `-I` directories, the last one first.
|
|
82
|
+
|
|
83
|
+
### Prove with tlapm
|
|
84
|
+
|
|
85
|
+
tla-ts doesn't include a prover. Without `-N` or `--summary`, `tla-ts prove` runs [tlapm](https://github.com/tlaplus/tlapm) from your `PATH`:
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
npx tla-ts prove Module.tla
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
tla-ts expands the globs and passes every argument to tlapm, so all of tlapm's options work. tlapm sends the obligations to its provers, and tla-ts exits with the exit code of tlapm. If `tlapm` isn't on your `PATH`, tla-ts prints an error and exits with code 1.
|
|
46
92
|
|
|
47
93
|
## API reference
|
|
48
94
|
|
|
@@ -80,7 +126,13 @@ The result has these fields:
|
|
|
80
126
|
- `failure`: the message and trace when `status` is `"error"`.
|
|
81
127
|
- `generatedStates`, `distinctStates`, and `depth`: TLC's state counts.
|
|
82
128
|
|
|
83
|
-
Workers run in Node, Bun, Deno, and the browser,
|
|
129
|
+
Workers run in Node, Bun, Deno, and cross-origin isolated pages in the browser. Like TLC's workers, they share one table of 64-bit fingerprints. `check` runs on the calling thread in these cases:
|
|
130
|
+
|
|
131
|
+
- `SharedArrayBuffer` is unavailable, as on a page without cross-origin isolation.
|
|
132
|
+
- The spec has liveness properties.
|
|
133
|
+
- The spec uses impure operators such as `Print`.
|
|
134
|
+
|
|
135
|
+
After a violation, `check` reruns on the calling thread to return the exact trace.
|
|
84
136
|
|
|
85
137
|
`check` supports:
|
|
86
138
|
|
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.M,exports.TlaError=e.N,exports.TlaEvaluationError=e.P,exports.TlaSyntaxError=e.I,exports.TlaUnsupportedError=e.L,exports.check=t.t,exports.formatValue=e.E,exports.parseConfig=e.A,exports.parseModule=e.b;
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,7 @@ interface ApplyExpression {
|
|
|
45
45
|
kind: "Apply";
|
|
46
46
|
operator: string;
|
|
47
47
|
args: Expression[];
|
|
48
|
+
argumentCounts?: number[];
|
|
48
49
|
location: SourceLocation;
|
|
49
50
|
resolution?: LocalResolution;
|
|
50
51
|
}
|
|
@@ -62,6 +63,7 @@ interface LambdaExpression {
|
|
|
62
63
|
interface JunctionExpression {
|
|
63
64
|
kind: "And" | "Or";
|
|
64
65
|
operands: Expression[];
|
|
66
|
+
isBulleted?: boolean;
|
|
65
67
|
location: SourceLocation;
|
|
66
68
|
}
|
|
67
69
|
interface PrimeExpression {
|
|
@@ -122,6 +124,7 @@ interface QuantifierExpression {
|
|
|
122
124
|
}
|
|
123
125
|
interface UnboundedQuantifierExpression {
|
|
124
126
|
kind: "UnboundedQuantifier";
|
|
127
|
+
quantifier: "Forall" | "Exists";
|
|
125
128
|
names: string[];
|
|
126
129
|
isTemporal?: boolean;
|
|
127
130
|
body: Expression;
|
|
@@ -265,6 +268,7 @@ type Expression = NumberExpression | DecimalExpression | StringExpression | Iden
|
|
|
265
268
|
interface OperatorParam {
|
|
266
269
|
name: string;
|
|
267
270
|
arity: number;
|
|
271
|
+
location?: SourceLocation;
|
|
268
272
|
}
|
|
269
273
|
interface OperatorDefinition {
|
|
270
274
|
kind: "Operator";
|
|
@@ -309,6 +313,8 @@ interface Instance {
|
|
|
309
313
|
substitutions: InstanceSubstitution[];
|
|
310
314
|
isLocal: boolean;
|
|
311
315
|
location: SourceLocation;
|
|
316
|
+
instanceRange: SourceRange;
|
|
317
|
+
definitionRange?: SourceRange;
|
|
312
318
|
}
|
|
313
319
|
interface NewSymbol {
|
|
314
320
|
kind: "NewSymbol";
|
|
@@ -334,16 +340,19 @@ interface UseOrHide {
|
|
|
334
340
|
isOnly: boolean;
|
|
335
341
|
facts: Fact[];
|
|
336
342
|
defs: Fact[];
|
|
343
|
+
keyword: SourceRange;
|
|
337
344
|
location: SourceLocation;
|
|
338
345
|
}
|
|
339
346
|
type Proof = {
|
|
340
347
|
kind: "Obvious" | "Omitted";
|
|
348
|
+
keyword: SourceRange;
|
|
341
349
|
location: SourceLocation;
|
|
342
350
|
} | {
|
|
343
351
|
kind: "By";
|
|
344
352
|
isOnly: boolean;
|
|
345
353
|
facts: Fact[];
|
|
346
354
|
defs: Fact[];
|
|
355
|
+
keyword: SourceRange;
|
|
347
356
|
location: SourceLocation;
|
|
348
357
|
} | {
|
|
349
358
|
kind: "Steps";
|
|
@@ -383,7 +392,9 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
383
392
|
};
|
|
384
393
|
interface ProofStep {
|
|
385
394
|
name: string | undefined;
|
|
395
|
+
token: string;
|
|
386
396
|
body: StepBody;
|
|
397
|
+
head: SourceRange;
|
|
387
398
|
proof: Proof | undefined;
|
|
388
399
|
location: SourceLocation;
|
|
389
400
|
}
|
|
@@ -393,10 +404,39 @@ interface Theorem {
|
|
|
393
404
|
proof: Proof | undefined;
|
|
394
405
|
location: SourceLocation;
|
|
395
406
|
}
|
|
407
|
+
type ModuleUnit = {
|
|
408
|
+
kind: "Constants";
|
|
409
|
+
declarations: Declaration[];
|
|
410
|
+
} | {
|
|
411
|
+
kind: "Variables";
|
|
412
|
+
declarations: Declaration[];
|
|
413
|
+
} | {
|
|
414
|
+
kind: "Recursive";
|
|
415
|
+
declarations: Declaration[];
|
|
416
|
+
} | {
|
|
417
|
+
kind: "Definition";
|
|
418
|
+
definition: Definition;
|
|
419
|
+
} | {
|
|
420
|
+
kind: "Instance";
|
|
421
|
+
instance: Instance;
|
|
422
|
+
} | {
|
|
423
|
+
kind: "Assumption";
|
|
424
|
+
assumption: Assumption;
|
|
425
|
+
} | {
|
|
426
|
+
kind: "Theorem";
|
|
427
|
+
theorem: Theorem;
|
|
428
|
+
} | {
|
|
429
|
+
kind: "Use";
|
|
430
|
+
use: UseOrHide;
|
|
431
|
+
} | {
|
|
432
|
+
kind: "Module";
|
|
433
|
+
module: Module;
|
|
434
|
+
};
|
|
396
435
|
interface Module {
|
|
397
436
|
name: string;
|
|
398
437
|
modules: Module[];
|
|
399
438
|
extends: string[];
|
|
439
|
+
extendsRanges: SourceRange[];
|
|
400
440
|
constants: Declaration[];
|
|
401
441
|
variables: Declaration[];
|
|
402
442
|
definitions: Definition[];
|
|
@@ -405,6 +445,7 @@ interface Module {
|
|
|
405
445
|
location: SourceLocation;
|
|
406
446
|
theorems: Theorem[];
|
|
407
447
|
uses: UseOrHide[];
|
|
448
|
+
units: ModuleUnit[];
|
|
408
449
|
}
|
|
409
450
|
type ConfigValue = {
|
|
410
451
|
kind: "Number";
|
|
@@ -456,8 +497,15 @@ export declare const parseConfig: (source: string) => ModelConfig;
|
|
|
456
497
|
export declare class TlaError extends Error {
|
|
457
498
|
constructor(message: string, cause?: unknown);
|
|
458
499
|
}
|
|
500
|
+
interface SyntaxFailure {
|
|
501
|
+
reason: string;
|
|
502
|
+
line: number;
|
|
503
|
+
column: number;
|
|
504
|
+
isEnd: boolean;
|
|
505
|
+
}
|
|
459
506
|
export declare class TlaSyntaxError extends TlaError {
|
|
460
|
-
|
|
507
|
+
failure: SyntaxFailure | undefined;
|
|
508
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
|
|
461
509
|
}
|
|
462
510
|
export declare class TlaConfigError extends TlaError {
|
|
463
511
|
constructor(message: string, cause?: unknown);
|
|
@@ -471,6 +519,8 @@ export declare class TlaUnsupportedError extends TlaError {
|
|
|
471
519
|
interface ModelValue {
|
|
472
520
|
kind: "ModelValue";
|
|
473
521
|
name: string;
|
|
522
|
+
type: string | undefined;
|
|
523
|
+
rank: number;
|
|
474
524
|
}
|
|
475
525
|
interface SetValue {
|
|
476
526
|
kind: "Set";
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface ApplyExpression {
|
|
|
45
45
|
kind: "Apply";
|
|
46
46
|
operator: string;
|
|
47
47
|
args: Expression[];
|
|
48
|
+
argumentCounts?: number[];
|
|
48
49
|
location: SourceLocation;
|
|
49
50
|
resolution?: LocalResolution;
|
|
50
51
|
}
|
|
@@ -62,6 +63,7 @@ interface LambdaExpression {
|
|
|
62
63
|
interface JunctionExpression {
|
|
63
64
|
kind: "And" | "Or";
|
|
64
65
|
operands: Expression[];
|
|
66
|
+
isBulleted?: boolean;
|
|
65
67
|
location: SourceLocation;
|
|
66
68
|
}
|
|
67
69
|
interface PrimeExpression {
|
|
@@ -122,6 +124,7 @@ interface QuantifierExpression {
|
|
|
122
124
|
}
|
|
123
125
|
interface UnboundedQuantifierExpression {
|
|
124
126
|
kind: "UnboundedQuantifier";
|
|
127
|
+
quantifier: "Forall" | "Exists";
|
|
125
128
|
names: string[];
|
|
126
129
|
isTemporal?: boolean;
|
|
127
130
|
body: Expression;
|
|
@@ -265,6 +268,7 @@ type Expression = NumberExpression | DecimalExpression | StringExpression | Iden
|
|
|
265
268
|
interface OperatorParam {
|
|
266
269
|
name: string;
|
|
267
270
|
arity: number;
|
|
271
|
+
location?: SourceLocation;
|
|
268
272
|
}
|
|
269
273
|
interface OperatorDefinition {
|
|
270
274
|
kind: "Operator";
|
|
@@ -309,6 +313,8 @@ interface Instance {
|
|
|
309
313
|
substitutions: InstanceSubstitution[];
|
|
310
314
|
isLocal: boolean;
|
|
311
315
|
location: SourceLocation;
|
|
316
|
+
instanceRange: SourceRange;
|
|
317
|
+
definitionRange?: SourceRange;
|
|
312
318
|
}
|
|
313
319
|
interface NewSymbol {
|
|
314
320
|
kind: "NewSymbol";
|
|
@@ -334,16 +340,19 @@ interface UseOrHide {
|
|
|
334
340
|
isOnly: boolean;
|
|
335
341
|
facts: Fact[];
|
|
336
342
|
defs: Fact[];
|
|
343
|
+
keyword: SourceRange;
|
|
337
344
|
location: SourceLocation;
|
|
338
345
|
}
|
|
339
346
|
type Proof = {
|
|
340
347
|
kind: "Obvious" | "Omitted";
|
|
348
|
+
keyword: SourceRange;
|
|
341
349
|
location: SourceLocation;
|
|
342
350
|
} | {
|
|
343
351
|
kind: "By";
|
|
344
352
|
isOnly: boolean;
|
|
345
353
|
facts: Fact[];
|
|
346
354
|
defs: Fact[];
|
|
355
|
+
keyword: SourceRange;
|
|
347
356
|
location: SourceLocation;
|
|
348
357
|
} | {
|
|
349
358
|
kind: "Steps";
|
|
@@ -383,7 +392,9 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
383
392
|
};
|
|
384
393
|
interface ProofStep {
|
|
385
394
|
name: string | undefined;
|
|
395
|
+
token: string;
|
|
386
396
|
body: StepBody;
|
|
397
|
+
head: SourceRange;
|
|
387
398
|
proof: Proof | undefined;
|
|
388
399
|
location: SourceLocation;
|
|
389
400
|
}
|
|
@@ -393,10 +404,39 @@ interface Theorem {
|
|
|
393
404
|
proof: Proof | undefined;
|
|
394
405
|
location: SourceLocation;
|
|
395
406
|
}
|
|
407
|
+
type ModuleUnit = {
|
|
408
|
+
kind: "Constants";
|
|
409
|
+
declarations: Declaration[];
|
|
410
|
+
} | {
|
|
411
|
+
kind: "Variables";
|
|
412
|
+
declarations: Declaration[];
|
|
413
|
+
} | {
|
|
414
|
+
kind: "Recursive";
|
|
415
|
+
declarations: Declaration[];
|
|
416
|
+
} | {
|
|
417
|
+
kind: "Definition";
|
|
418
|
+
definition: Definition;
|
|
419
|
+
} | {
|
|
420
|
+
kind: "Instance";
|
|
421
|
+
instance: Instance;
|
|
422
|
+
} | {
|
|
423
|
+
kind: "Assumption";
|
|
424
|
+
assumption: Assumption;
|
|
425
|
+
} | {
|
|
426
|
+
kind: "Theorem";
|
|
427
|
+
theorem: Theorem;
|
|
428
|
+
} | {
|
|
429
|
+
kind: "Use";
|
|
430
|
+
use: UseOrHide;
|
|
431
|
+
} | {
|
|
432
|
+
kind: "Module";
|
|
433
|
+
module: Module;
|
|
434
|
+
};
|
|
396
435
|
interface Module {
|
|
397
436
|
name: string;
|
|
398
437
|
modules: Module[];
|
|
399
438
|
extends: string[];
|
|
439
|
+
extendsRanges: SourceRange[];
|
|
400
440
|
constants: Declaration[];
|
|
401
441
|
variables: Declaration[];
|
|
402
442
|
definitions: Definition[];
|
|
@@ -405,6 +445,7 @@ interface Module {
|
|
|
405
445
|
location: SourceLocation;
|
|
406
446
|
theorems: Theorem[];
|
|
407
447
|
uses: UseOrHide[];
|
|
448
|
+
units: ModuleUnit[];
|
|
408
449
|
}
|
|
409
450
|
type ConfigValue = {
|
|
410
451
|
kind: "Number";
|
|
@@ -456,8 +497,15 @@ export declare const parseConfig: (source: string) => ModelConfig;
|
|
|
456
497
|
export declare class TlaError extends Error {
|
|
457
498
|
constructor(message: string, cause?: unknown);
|
|
458
499
|
}
|
|
500
|
+
interface SyntaxFailure {
|
|
501
|
+
reason: string;
|
|
502
|
+
line: number;
|
|
503
|
+
column: number;
|
|
504
|
+
isEnd: boolean;
|
|
505
|
+
}
|
|
459
506
|
export declare class TlaSyntaxError extends TlaError {
|
|
460
|
-
|
|
507
|
+
failure: SyntaxFailure | undefined;
|
|
508
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure);
|
|
461
509
|
}
|
|
462
510
|
export declare class TlaConfigError extends TlaError {
|
|
463
511
|
constructor(message: string, cause?: unknown);
|
|
@@ -471,6 +519,8 @@ export declare class TlaUnsupportedError extends TlaError {
|
|
|
471
519
|
interface ModelValue {
|
|
472
520
|
kind: "ModelValue";
|
|
473
521
|
name: string;
|
|
522
|
+
type: string | undefined;
|
|
523
|
+
rank: number;
|
|
474
524
|
}
|
|
475
525
|
interface SetValue {
|
|
476
526
|
kind: "Set";
|
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{A as e,
|
|
9
|
+
import{A as e,E as t,I as n,L as r,M as i,N as a,P as o,b as s}from"./transfer.js";import{t as c}from"./parallel.js";export{i as TlaConfigError,a as TlaError,o as TlaEvaluationError,n as TlaSyntaxError,r as TlaUnsupportedError,c as check,t as formatValue,e as parseConfig,s as parseModule};
|
package/dist/parallel-worker.cjs
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
|
-
const e=require("./transfer.cjs"),t=
|
|
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,
|
|
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.O(e._(t.source,t.config,i));let o=e.D(),s=e.y(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)),l=c?.spec.next;if(!c||l===void 0)return n.postMessage({type:`abort`});let u=t.index,d=e.T(),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.w(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)||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.D()===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{D as e,O as t,T as n,_ as r,c as i,n as a,o,r as s,s as c,t as l,u,v as d,w 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=(
|
|
12
|
+
`node:worker_threads`)).parentPort,h=(m,h)=>{let g=new Map(m.modules),_=e=>g.get(e),v=new Map(m.classes);t(r(m.source,m.config,_));let y=e(),b=p(m.config,{source:m.source,loadModule:_,loadClass:e=>v.get(e),print:()=>{},files:{readFile:void 0,writeFile:void 0}}).environment,x=u(m.config,b,()=>d(m.source,_)),S=x?.spec.next;if(!x||S===void 0)return h.postMessage({type:`abort`});let C=m.index,w=n(),T=l(b.variables.length),E={fingerprints:m.fingerprints},D=m.requests,O=m.remaining,k=x.isSymmetric?s():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=a(),o=e.states.slice(e.end-r,e.end),s=r>0&&o.every(i.encode);s&&(e.end-=r);let c=s?i.finish():a().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=f(S,t,b,x.spec.scope),e.generated+=e.successors.length,e.successors.length===0&&m.config.checkDeadlock))return;let n=e.successors;for(;e.index<n.length;e.index++){if(c(E.fingerprints))return`paused`;let r=n[e.index];if(x.findViolatedActionProperty(t,r.state))return;if(!x.satisfiesActionConstraints(t,r.state)||k&&(i(r.state,A),!k.insert(A[0],A[1])))continue;w(r.state);let a=x.getFingerprintState(r.state);if(i(a,A),o(E.fingerprints,A[0],A[1])){if(x.findViolatedInvariant(r.state,t))return;x.satisfiesConstraints(r.state,t)&&(e.next.push(r.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 t=>{let n={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(n);if(e===void 0)return;if(P(n),e===`paused`){let e=new Promise(e=>j.resume=e);R({type:`paused`}),await e,F(n)}else if(!await L(n))break}if(e()===y)return M.states=n.next,Atomics.store(O,C,M.states.length),{type:`level`,level:t,generated:n.generated,added:n.next.length,outDegrees:n.outDegrees,fingerprints:x.getStoredFingerprints(n.next,n.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.A(n.config):n.config,i=()=>e.l({...n,config:r}),a=n.workers??1;if(a<2||typeof SharedArrayBuffer!=`function`||r.view!==void 0||r.postconditions.length>0||r.possible.length>0)return i();let o=/* @__PURE__ */ new Map,s=e=>{let t=n.loadModule?.(e);return o.set(e,t),t},c=/* @__PURE__ */ new Map,l=e=>{let t=n.loadClass?.(e);return c.set(e,t),t};e.O(e._(n.source,r,s));let u=e.D(),d=e.y(r,{source:n.source,loadModule:s,loadClass:l,print:n.onPrint??console.log,files:{readFile:n.readFile,writeFile:n.writeFile}}),f=d.environment,p=e.u(r,f,()=>e.v(n.source,s));if(e.d(d.assumptions,f)||!p||p.spec.init===void 0||p.spec.next===void 0||p.properties.liveness.length>0||e.S(f))return i();let m=e.T(),h={fingerprints:e.i()},g=/* @__PURE__ */ new Int32Array(2),_=Array.from({length:a},e.n),v={generatedStates:0,distinctStates:0,queuedStates:0,depth:0,outDegrees:Array.from({length:32},()=>0)},y=[],b=()=>({status:`success`,violation:void 0,failure:void 0,...v,fingerprintDistance:e.m(v.distinctStates,v.generatedStates,()=>{let e=new BigInt64Array(v.distinctStates);return y.reduce((t,n)=>(e.set(n,t),t+n.length),0),e})}),x=t=>{let n=[];for(let r of e.C(t,f,p.spec.scope))if(m(r),v.generatedStates++,e.c(p.getFingerprintState(r),g),e.s(h.fingerprints)&&(h.fingerprints=e.a(h.fingerprints)),e.o(h.fingerprints,g[0],g[1])){if(p.findViolatedInvariant(r)||p.findFailedInitialPredicate(r))return!1;if(p.satisfiesConstraints(r)){if(!_[n.length%a].encode(r))return!1;n.push(r),v.distinctStates++}}return y.push(BigInt64Array.from(n,e=>f.runtime.getFingerprint(e))),!0};try{if(!x(p.spec.init))return i()}catch(t){if(!(t instanceof e.P))throw t;return i()}if(e.D()!==u)return i();if(v.depth=v.generatedStates===0?0:1,v.distinctStates===0)return b();let S=[],C={count:a,resolve:e=>{}},w=e=>{S.push(e),(e.type===`abort`||S.length===C.count)&&C.resolve(S.splice(0))},T=e=>new Promise(t=>{C.count=e,C.resolve=t}),E=T(a),D=new Int32Array(new SharedArrayBuffer(a*4)),O=new Int32Array(new SharedArrayBuffer(a*4)),k=await Promise.all(Array.from({length:a},()=>t(w))),A=()=>k.forEach(e=>e.terminate()),j=/* @__PURE__ */ new Map,M=(e,t)=>{let n=e<t?`${e}:${t}`:`${t}:${e}`,r=j.get(n)??new MessageChannel;return j.set(n,r),e<t?r.port1:r.port2};k.forEach((e,t)=>{let i=Array.from({length:a},(e,n)=>n===t?void 0:M(t,n)),s=_[t].finish(),l={type:`start`,source:n.source,config:r,modules:[...o],classes:[...c],index:t,ports:i,seed:s,fingerprints:h.fingerprints,requests:D,remaining:O};e.postMessage(l,[...i.filter(e=>e!==void 0),s.words.buffer])});let N=e=>e.some(e=>e.type===`abort`),P=e=>k.forEach(t=>t.postMessage(e)),F=async t=>{let n=t.filter(e=>e.type===`paused`).length;if(n===0||N(t))return t;h.fingerprints=e.a(h.fingerprints);let r=T(n);return P({type:`resize`,fingerprints:h.fingerprints}),[...t.filter(e=>e.type!==`paused`),...await F(await r)]};if(N(await E))return A(),i();for(let e=1;;e++){let t=T(a);D.forEach((e,t)=>Atomics.store(D,t,0)),P({type:`level`,level:e});let n=await F(await t);if(N(n))return A(),i();let r=n.flatMap(e=>e.type===`level`?[e]:[]),o=r.reduce((e,t)=>e+t.added,0);if(v.generatedStates+=r.reduce((e,t)=>e+t.generated,0),v.distinctStates+=o,r.forEach(e=>{e.outDegrees.forEach((e,t)=>v.outDegrees[t]+=e),y.push(e.fingerprints)}),o===0)return A(),b();v.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{
|
|
9
|
+
import{A as e,C as t,D as n,O as r,P as i,S as ee,T as a,_ as o,a as s,c,d as l,i as u,l as d,m as f,n as p,o as m,s as h,u as g,v as _,y as v}from"./transfer.js";const y=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()}},b=async b=>{let x=typeof b.config==`string`?e(b.config):b.config,S=()=>d({...b,config:x}),C=b.workers??1;if(C<2||typeof SharedArrayBuffer!=`function`||x.view!==void 0||x.postconditions.length>0||x.possible.length>0)return S();let w=/* @__PURE__ */ new Map,T=e=>{let t=b.loadModule?.(e);return w.set(e,t),t},E=/* @__PURE__ */ new Map,D=e=>{let t=b.loadClass?.(e);return E.set(e,t),t};r(o(b.source,x,T));let O=n(),k=v(x,{source:b.source,loadModule:T,loadClass:D,print:b.onPrint??console.log,files:{readFile:b.readFile,writeFile:b.writeFile}}),A=k.environment,j=g(x,A,()=>_(b.source,T));if(l(k.assumptions,A)||!j||j.spec.init===void 0||j.spec.next===void 0||j.properties.liveness.length>0||ee(A))return S();let M=a(),N={fingerprints:u()},P=/* @__PURE__ */ new Int32Array(2),F=Array.from({length:C},p),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:f(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 n=[];for(let r of t(e,A,j.spec.scope))if(M(r),I.generatedStates++,c(j.getFingerprintState(r),P),h(N.fingerprints)&&(N.fingerprints=s(N.fingerprints)),m(N.fingerprints,P[0],P[1])){if(j.findViolatedInvariant(r)||j.findFailedInitialPredicate(r))return!1;if(j.satisfiesConstraints(r)){if(!F[n.length%C].encode(r))return!1;n.push(r),I.distinctStates++}}return L.push(BigInt64Array.from(n,e=>A.runtime.getFingerprint(e))),!0};try{if(!z(j.spec.init))return S()}catch(e){if(!(e instanceof i))throw e;return S()}if(n()!==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},()=>y(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:b.source,config:x,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=s(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{b as t};
|