tla-ts 0.0.3-dev.6a30eee → 0.0.3-dev.6d0aeb6
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 +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +58 -22
- package/dist/index.d.ts +58 -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 -18
- package/dist/run-cli.js +22 -20
- package/dist/transfer.cjs +40 -15
- package/dist/transfer.js +40 -15
- package/package.json +1 -1
- package/src/ast.ts +101 -1
- package/src/builtins.ts +9 -3
- package/src/check.ts +473 -100
- 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 +158 -49
- package/src/errors.ts +93 -3
- package/src/evaluate.ts +214 -147
- package/src/exit-codes.ts +21 -14
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +16 -15
- package/src/levels.ts +181 -45
- package/src/live-check.ts +132 -70
- package/src/liveness.ts +118 -24
- package/src/parallel-worker.ts +2 -2
- package/src/parallel.ts +5 -2
- package/src/parser.ts +71 -19
- package/src/resolve.ts +490 -95
- package/src/run-cli.ts +104 -18
- package/src/runtime.ts +2 -0
- 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/state-graph.ts +157 -0
- package/src/subexpressions.ts +35 -23
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +176 -36
- package/src/symmetry.ts +16 -6
- 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 +8 -4
- 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
|
|
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,8 @@ interface ApplyExpression {
|
|
|
46
47
|
operator: string;
|
|
47
48
|
args: Expression[];
|
|
48
49
|
argumentCounts?: number[];
|
|
50
|
+
argumentsRange?: SourceRange;
|
|
51
|
+
selectorRanges?: SourceRange[];
|
|
49
52
|
location: SourceLocation;
|
|
50
53
|
resolution?: LocalResolution;
|
|
51
54
|
}
|
|
@@ -175,6 +178,7 @@ interface FunctionSetExpression {
|
|
|
175
178
|
interface RecordField {
|
|
176
179
|
name: string;
|
|
177
180
|
value: Expression;
|
|
181
|
+
location: SourceLocation;
|
|
178
182
|
}
|
|
179
183
|
interface RecordExpression {
|
|
180
184
|
kind: "Record" | "RecordSet";
|
|
@@ -262,6 +266,7 @@ type Selector = {
|
|
|
262
266
|
interface SubexpressionExpression {
|
|
263
267
|
kind: "Subexpression";
|
|
264
268
|
selectors: Selector[];
|
|
269
|
+
selectorRanges?: SourceRange[];
|
|
265
270
|
location: SourceLocation;
|
|
266
271
|
}
|
|
267
272
|
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;
|
|
@@ -395,6 +400,7 @@ interface ProofStep {
|
|
|
395
400
|
token: string;
|
|
396
401
|
body: StepBody;
|
|
397
402
|
head: SourceRange;
|
|
403
|
+
statement: SourceRange;
|
|
398
404
|
proof: Proof | undefined;
|
|
399
405
|
location: SourceLocation;
|
|
400
406
|
}
|
|
@@ -494,28 +500,6 @@ interface ModelConfig {
|
|
|
494
500
|
rlReward: string | undefined;
|
|
495
501
|
}
|
|
496
502
|
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
503
|
interface ModelValue {
|
|
520
504
|
kind: "ModelValue";
|
|
521
505
|
name: string;
|
|
@@ -602,6 +586,45 @@ interface LazyFunctionValue {
|
|
|
602
586
|
}
|
|
603
587
|
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
604
588
|
export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
|
|
589
|
+
export declare class TlaError extends Error {
|
|
590
|
+
constructor(message: string, cause?: unknown);
|
|
591
|
+
}
|
|
592
|
+
interface SyntaxFailure {
|
|
593
|
+
reason: string;
|
|
594
|
+
line: number;
|
|
595
|
+
column: number;
|
|
596
|
+
isEnd: boolean;
|
|
597
|
+
}
|
|
598
|
+
interface SanyError {
|
|
599
|
+
location: string;
|
|
600
|
+
message: string;
|
|
601
|
+
}
|
|
602
|
+
interface SanyReport {
|
|
603
|
+
errors: SanyError[];
|
|
604
|
+
isFatal: boolean;
|
|
605
|
+
parseError?: string;
|
|
606
|
+
}
|
|
607
|
+
export declare class TlaSyntaxError extends TlaError {
|
|
608
|
+
failure: SyntaxFailure | undefined;
|
|
609
|
+
sany: SanyReport | undefined;
|
|
610
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
|
|
611
|
+
}
|
|
612
|
+
export declare class TlaConfigError extends TlaError {
|
|
613
|
+
constructor(message: string, cause?: unknown);
|
|
614
|
+
}
|
|
615
|
+
export declare class TlaEvaluationError extends TlaError {
|
|
616
|
+
constructor(message: string, cause?: unknown);
|
|
617
|
+
}
|
|
618
|
+
export declare class TlaUnsupportedError extends TlaError {
|
|
619
|
+
constructor(message: string, cause?: unknown);
|
|
620
|
+
}
|
|
621
|
+
interface StateDump {
|
|
622
|
+
path: string;
|
|
623
|
+
dot?: boolean;
|
|
624
|
+
colorize?: boolean;
|
|
625
|
+
actionLabels?: boolean;
|
|
626
|
+
snapshot?: boolean;
|
|
627
|
+
}
|
|
605
628
|
interface CheckOptions {
|
|
606
629
|
source: string;
|
|
607
630
|
config: string | ModelConfig;
|
|
@@ -614,6 +637,7 @@ interface CheckOptions {
|
|
|
614
637
|
seed?: bigint;
|
|
615
638
|
workers?: number;
|
|
616
639
|
livenessCheck?: "default" | "final";
|
|
640
|
+
dump?: StateDump;
|
|
617
641
|
}
|
|
618
642
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
619
643
|
interface TraceStep {
|
|
@@ -641,6 +665,18 @@ interface EvaluationFailure {
|
|
|
641
665
|
trace: TraceStep[];
|
|
642
666
|
initialState: Record<string, Value> | undefined;
|
|
643
667
|
exitCode: number;
|
|
668
|
+
replay?: Replay;
|
|
669
|
+
isWithoutStatistics?: boolean;
|
|
670
|
+
}
|
|
671
|
+
interface Replay {
|
|
672
|
+
output: string[];
|
|
673
|
+
callStack: string[] | undefined;
|
|
674
|
+
fingerprint?: Fingerprint;
|
|
675
|
+
isBeforeError?: boolean;
|
|
676
|
+
}
|
|
677
|
+
interface Fingerprint {
|
|
678
|
+
sources: string[];
|
|
679
|
+
reason: string;
|
|
644
680
|
}
|
|
645
681
|
interface CheckResult {
|
|
646
682
|
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,8 @@ interface ApplyExpression {
|
|
|
46
47
|
operator: string;
|
|
47
48
|
args: Expression[];
|
|
48
49
|
argumentCounts?: number[];
|
|
50
|
+
argumentsRange?: SourceRange;
|
|
51
|
+
selectorRanges?: SourceRange[];
|
|
49
52
|
location: SourceLocation;
|
|
50
53
|
resolution?: LocalResolution;
|
|
51
54
|
}
|
|
@@ -175,6 +178,7 @@ interface FunctionSetExpression {
|
|
|
175
178
|
interface RecordField {
|
|
176
179
|
name: string;
|
|
177
180
|
value: Expression;
|
|
181
|
+
location: SourceLocation;
|
|
178
182
|
}
|
|
179
183
|
interface RecordExpression {
|
|
180
184
|
kind: "Record" | "RecordSet";
|
|
@@ -262,6 +266,7 @@ type Selector = {
|
|
|
262
266
|
interface SubexpressionExpression {
|
|
263
267
|
kind: "Subexpression";
|
|
264
268
|
selectors: Selector[];
|
|
269
|
+
selectorRanges?: SourceRange[];
|
|
265
270
|
location: SourceLocation;
|
|
266
271
|
}
|
|
267
272
|
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;
|
|
@@ -395,6 +400,7 @@ interface ProofStep {
|
|
|
395
400
|
token: string;
|
|
396
401
|
body: StepBody;
|
|
397
402
|
head: SourceRange;
|
|
403
|
+
statement: SourceRange;
|
|
398
404
|
proof: Proof | undefined;
|
|
399
405
|
location: SourceLocation;
|
|
400
406
|
}
|
|
@@ -494,28 +500,6 @@ interface ModelConfig {
|
|
|
494
500
|
rlReward: string | undefined;
|
|
495
501
|
}
|
|
496
502
|
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
503
|
interface ModelValue {
|
|
520
504
|
kind: "ModelValue";
|
|
521
505
|
name: string;
|
|
@@ -602,6 +586,45 @@ interface LazyFunctionValue {
|
|
|
602
586
|
}
|
|
603
587
|
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
604
588
|
export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
|
|
589
|
+
export declare class TlaError extends Error {
|
|
590
|
+
constructor(message: string, cause?: unknown);
|
|
591
|
+
}
|
|
592
|
+
interface SyntaxFailure {
|
|
593
|
+
reason: string;
|
|
594
|
+
line: number;
|
|
595
|
+
column: number;
|
|
596
|
+
isEnd: boolean;
|
|
597
|
+
}
|
|
598
|
+
interface SanyError {
|
|
599
|
+
location: string;
|
|
600
|
+
message: string;
|
|
601
|
+
}
|
|
602
|
+
interface SanyReport {
|
|
603
|
+
errors: SanyError[];
|
|
604
|
+
isFatal: boolean;
|
|
605
|
+
parseError?: string;
|
|
606
|
+
}
|
|
607
|
+
export declare class TlaSyntaxError extends TlaError {
|
|
608
|
+
failure: SyntaxFailure | undefined;
|
|
609
|
+
sany: SanyReport | undefined;
|
|
610
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
|
|
611
|
+
}
|
|
612
|
+
export declare class TlaConfigError extends TlaError {
|
|
613
|
+
constructor(message: string, cause?: unknown);
|
|
614
|
+
}
|
|
615
|
+
export declare class TlaEvaluationError extends TlaError {
|
|
616
|
+
constructor(message: string, cause?: unknown);
|
|
617
|
+
}
|
|
618
|
+
export declare class TlaUnsupportedError extends TlaError {
|
|
619
|
+
constructor(message: string, cause?: unknown);
|
|
620
|
+
}
|
|
621
|
+
interface StateDump {
|
|
622
|
+
path: string;
|
|
623
|
+
dot?: boolean;
|
|
624
|
+
colorize?: boolean;
|
|
625
|
+
actionLabels?: boolean;
|
|
626
|
+
snapshot?: boolean;
|
|
627
|
+
}
|
|
605
628
|
interface CheckOptions {
|
|
606
629
|
source: string;
|
|
607
630
|
config: string | ModelConfig;
|
|
@@ -614,6 +637,7 @@ interface CheckOptions {
|
|
|
614
637
|
seed?: bigint;
|
|
615
638
|
workers?: number;
|
|
616
639
|
livenessCheck?: "default" | "final";
|
|
640
|
+
dump?: StateDump;
|
|
617
641
|
}
|
|
618
642
|
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
619
643
|
interface TraceStep {
|
|
@@ -641,6 +665,18 @@ interface EvaluationFailure {
|
|
|
641
665
|
trace: TraceStep[];
|
|
642
666
|
initialState: Record<string, Value> | undefined;
|
|
643
667
|
exitCode: number;
|
|
668
|
+
replay?: Replay;
|
|
669
|
+
isWithoutStatistics?: boolean;
|
|
670
|
+
}
|
|
671
|
+
interface Replay {
|
|
672
|
+
output: string[];
|
|
673
|
+
callStack: string[] | undefined;
|
|
674
|
+
fingerprint?: Fingerprint;
|
|
675
|
+
isBeforeError?: boolean;
|
|
676
|
+
}
|
|
677
|
+
interface Fingerprint {
|
|
678
|
+
sources: string[];
|
|
679
|
+
reason: string;
|
|
644
680
|
}
|
|
645
681
|
interface CheckResult {
|
|
646
682
|
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()}},v=async v=>{let y=typeof v.config==`string`?
|
|
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};
|