tla-ts 0.0.3-dev.cf3b82c → 0.0.3-dev.cfd469d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- 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 +14 -12
- package/dist/run-cli.js +22 -20
- package/dist/transfer.cjs +35 -20
- package/dist/transfer.js +35 -20
- package/package.json +1 -1
- package/src/ast.ts +27 -4
- package/src/builtins.ts +9 -3
- package/src/check.ts +234 -53
- package/src/config.ts +224 -170
- package/src/environment.ts +231 -74
- package/src/errors.ts +74 -1
- package/src/evaluate.ts +131 -13
- package/src/exit-codes.ts +4 -4
- package/src/fingerprints.ts +2 -1
- package/src/instances.ts +1 -1
- package/src/levels.ts +177 -36
- package/src/live-check.ts +3 -1
- package/src/liveness.ts +66 -6
- package/src/parser.ts +155 -49
- package/src/resolve.ts +985 -384
- package/src/run-cli.ts +61 -11
- package/src/sany-lexer.ts +615 -0
- package/src/sany-parse-error.ts +3143 -0
- package/src/spec-description.ts +1 -2
- package/src/standard-modules.ts +52 -38
- package/src/standard-ranges.ts +116 -0
- package/src/subexpressions.ts +26 -14
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +87 -17
- package/src/value-sources.ts +29 -0
- package/src/values.ts +122 -42
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
|
}
|
|
@@ -57,6 +60,7 @@ interface OperatorReferenceExpression {
|
|
|
57
60
|
interface LambdaExpression {
|
|
58
61
|
kind: "Lambda";
|
|
59
62
|
params: string[];
|
|
63
|
+
paramRanges?: SourceRange[];
|
|
60
64
|
body: Expression;
|
|
61
65
|
location: SourceLocation;
|
|
62
66
|
}
|
|
@@ -108,9 +112,11 @@ interface LetExpression {
|
|
|
108
112
|
type BoundPattern = {
|
|
109
113
|
kind: "Name";
|
|
110
114
|
name: string;
|
|
115
|
+
ranges?: SourceRange[];
|
|
111
116
|
} | {
|
|
112
117
|
kind: "Tuple";
|
|
113
118
|
names: string[];
|
|
119
|
+
ranges?: SourceRange[];
|
|
114
120
|
};
|
|
115
121
|
interface Bound {
|
|
116
122
|
pattern: BoundPattern;
|
|
@@ -126,6 +132,7 @@ interface UnboundedQuantifierExpression {
|
|
|
126
132
|
kind: "UnboundedQuantifier";
|
|
127
133
|
quantifier: "Forall" | "Exists";
|
|
128
134
|
names: string[];
|
|
135
|
+
nameRanges?: SourceRange[];
|
|
129
136
|
isTemporal?: boolean;
|
|
130
137
|
body: Expression;
|
|
131
138
|
location: SourceLocation;
|
|
@@ -175,6 +182,7 @@ interface FunctionSetExpression {
|
|
|
175
182
|
interface RecordField {
|
|
176
183
|
name: string;
|
|
177
184
|
value: Expression;
|
|
185
|
+
location: SourceLocation;
|
|
178
186
|
}
|
|
179
187
|
interface RecordExpression {
|
|
180
188
|
kind: "Record" | "RecordSet";
|
|
@@ -262,6 +270,7 @@ type Selector = {
|
|
|
262
270
|
interface SubexpressionExpression {
|
|
263
271
|
kind: "Subexpression";
|
|
264
272
|
selectors: Selector[];
|
|
273
|
+
selectorRanges?: SourceRange[];
|
|
265
274
|
location: SourceLocation;
|
|
266
275
|
}
|
|
267
276
|
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 +312,7 @@ interface Assumption {
|
|
|
303
312
|
}
|
|
304
313
|
interface InstanceSubstitution {
|
|
305
314
|
name: string;
|
|
315
|
+
nameRange: SourceRange;
|
|
306
316
|
expression: Expression;
|
|
307
317
|
}
|
|
308
318
|
interface Instance {
|
|
@@ -322,6 +332,7 @@ interface NewSymbol {
|
|
|
322
332
|
arity: number;
|
|
323
333
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
324
334
|
set: Expression | undefined;
|
|
335
|
+
nameRange?: SourceRange;
|
|
325
336
|
location: SourceLocation;
|
|
326
337
|
}
|
|
327
338
|
interface AssumeProve {
|
|
@@ -371,6 +382,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
371
382
|
} | {
|
|
372
383
|
kind: "Take";
|
|
373
384
|
names: string[];
|
|
385
|
+
nameRanges?: SourceRange[];
|
|
374
386
|
bounds: Bound[];
|
|
375
387
|
} | {
|
|
376
388
|
kind: "Witness";
|
|
@@ -378,6 +390,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
378
390
|
} | {
|
|
379
391
|
kind: "Pick";
|
|
380
392
|
names: string[];
|
|
393
|
+
nameRanges?: SourceRange[];
|
|
381
394
|
bounds: Bound[];
|
|
382
395
|
body: Expression;
|
|
383
396
|
} | {
|
|
@@ -395,6 +408,7 @@ interface ProofStep {
|
|
|
395
408
|
token: string;
|
|
396
409
|
body: StepBody;
|
|
397
410
|
head: SourceRange;
|
|
411
|
+
statement: SourceRange;
|
|
398
412
|
proof: Proof | undefined;
|
|
399
413
|
location: SourceLocation;
|
|
400
414
|
}
|
|
@@ -589,9 +603,20 @@ interface SyntaxFailure {
|
|
|
589
603
|
column: number;
|
|
590
604
|
isEnd: boolean;
|
|
591
605
|
}
|
|
606
|
+
interface SanyError {
|
|
607
|
+
location: string;
|
|
608
|
+
message: string;
|
|
609
|
+
}
|
|
610
|
+
interface SanyReport {
|
|
611
|
+
errors: SanyError[];
|
|
612
|
+
warnings: SanyError[];
|
|
613
|
+
isFatal: boolean;
|
|
614
|
+
parseError?: string;
|
|
615
|
+
}
|
|
592
616
|
export declare class TlaSyntaxError extends TlaError {
|
|
593
617
|
failure: SyntaxFailure | undefined;
|
|
594
|
-
|
|
618
|
+
sany: SanyReport | undefined;
|
|
619
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
|
|
595
620
|
}
|
|
596
621
|
export declare class TlaConfigError extends TlaError {
|
|
597
622
|
constructor(message: string, cause?: unknown);
|
|
@@ -649,6 +674,18 @@ interface EvaluationFailure {
|
|
|
649
674
|
trace: TraceStep[];
|
|
650
675
|
initialState: Record<string, Value> | undefined;
|
|
651
676
|
exitCode: number;
|
|
677
|
+
replay?: Replay;
|
|
678
|
+
isWithoutStatistics?: boolean;
|
|
679
|
+
}
|
|
680
|
+
interface Replay {
|
|
681
|
+
output: string[];
|
|
682
|
+
callStack: string[] | undefined;
|
|
683
|
+
fingerprint?: Fingerprint;
|
|
684
|
+
isBeforeError?: boolean;
|
|
685
|
+
}
|
|
686
|
+
interface Fingerprint {
|
|
687
|
+
sources: string[];
|
|
688
|
+
reason: string;
|
|
652
689
|
}
|
|
653
690
|
interface CheckResult {
|
|
654
691
|
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
|
}
|
|
@@ -57,6 +60,7 @@ interface OperatorReferenceExpression {
|
|
|
57
60
|
interface LambdaExpression {
|
|
58
61
|
kind: "Lambda";
|
|
59
62
|
params: string[];
|
|
63
|
+
paramRanges?: SourceRange[];
|
|
60
64
|
body: Expression;
|
|
61
65
|
location: SourceLocation;
|
|
62
66
|
}
|
|
@@ -108,9 +112,11 @@ interface LetExpression {
|
|
|
108
112
|
type BoundPattern = {
|
|
109
113
|
kind: "Name";
|
|
110
114
|
name: string;
|
|
115
|
+
ranges?: SourceRange[];
|
|
111
116
|
} | {
|
|
112
117
|
kind: "Tuple";
|
|
113
118
|
names: string[];
|
|
119
|
+
ranges?: SourceRange[];
|
|
114
120
|
};
|
|
115
121
|
interface Bound {
|
|
116
122
|
pattern: BoundPattern;
|
|
@@ -126,6 +132,7 @@ interface UnboundedQuantifierExpression {
|
|
|
126
132
|
kind: "UnboundedQuantifier";
|
|
127
133
|
quantifier: "Forall" | "Exists";
|
|
128
134
|
names: string[];
|
|
135
|
+
nameRanges?: SourceRange[];
|
|
129
136
|
isTemporal?: boolean;
|
|
130
137
|
body: Expression;
|
|
131
138
|
location: SourceLocation;
|
|
@@ -175,6 +182,7 @@ interface FunctionSetExpression {
|
|
|
175
182
|
interface RecordField {
|
|
176
183
|
name: string;
|
|
177
184
|
value: Expression;
|
|
185
|
+
location: SourceLocation;
|
|
178
186
|
}
|
|
179
187
|
interface RecordExpression {
|
|
180
188
|
kind: "Record" | "RecordSet";
|
|
@@ -262,6 +270,7 @@ type Selector = {
|
|
|
262
270
|
interface SubexpressionExpression {
|
|
263
271
|
kind: "Subexpression";
|
|
264
272
|
selectors: Selector[];
|
|
273
|
+
selectorRanges?: SourceRange[];
|
|
265
274
|
location: SourceLocation;
|
|
266
275
|
}
|
|
267
276
|
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 +312,7 @@ interface Assumption {
|
|
|
303
312
|
}
|
|
304
313
|
interface InstanceSubstitution {
|
|
305
314
|
name: string;
|
|
315
|
+
nameRange: SourceRange;
|
|
306
316
|
expression: Expression;
|
|
307
317
|
}
|
|
308
318
|
interface Instance {
|
|
@@ -322,6 +332,7 @@ interface NewSymbol {
|
|
|
322
332
|
arity: number;
|
|
323
333
|
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
324
334
|
set: Expression | undefined;
|
|
335
|
+
nameRange?: SourceRange;
|
|
325
336
|
location: SourceLocation;
|
|
326
337
|
}
|
|
327
338
|
interface AssumeProve {
|
|
@@ -371,6 +382,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
371
382
|
} | {
|
|
372
383
|
kind: "Take";
|
|
373
384
|
names: string[];
|
|
385
|
+
nameRanges?: SourceRange[];
|
|
374
386
|
bounds: Bound[];
|
|
375
387
|
} | {
|
|
376
388
|
kind: "Witness";
|
|
@@ -378,6 +390,7 @@ type StepBody = UseOrHide | Instance | DefineStep | {
|
|
|
378
390
|
} | {
|
|
379
391
|
kind: "Pick";
|
|
380
392
|
names: string[];
|
|
393
|
+
nameRanges?: SourceRange[];
|
|
381
394
|
bounds: Bound[];
|
|
382
395
|
body: Expression;
|
|
383
396
|
} | {
|
|
@@ -395,6 +408,7 @@ interface ProofStep {
|
|
|
395
408
|
token: string;
|
|
396
409
|
body: StepBody;
|
|
397
410
|
head: SourceRange;
|
|
411
|
+
statement: SourceRange;
|
|
398
412
|
proof: Proof | undefined;
|
|
399
413
|
location: SourceLocation;
|
|
400
414
|
}
|
|
@@ -589,9 +603,20 @@ interface SyntaxFailure {
|
|
|
589
603
|
column: number;
|
|
590
604
|
isEnd: boolean;
|
|
591
605
|
}
|
|
606
|
+
interface SanyError {
|
|
607
|
+
location: string;
|
|
608
|
+
message: string;
|
|
609
|
+
}
|
|
610
|
+
interface SanyReport {
|
|
611
|
+
errors: SanyError[];
|
|
612
|
+
warnings: SanyError[];
|
|
613
|
+
isFatal: boolean;
|
|
614
|
+
parseError?: string;
|
|
615
|
+
}
|
|
592
616
|
export declare class TlaSyntaxError extends TlaError {
|
|
593
617
|
failure: SyntaxFailure | undefined;
|
|
594
|
-
|
|
618
|
+
sany: SanyReport | undefined;
|
|
619
|
+
constructor(message: string, cause?: unknown, failure?: SyntaxFailure, sany?: SanyReport);
|
|
595
620
|
}
|
|
596
621
|
export declare class TlaConfigError extends TlaError {
|
|
597
622
|
constructor(message: string, cause?: unknown);
|
|
@@ -649,6 +674,18 @@ interface EvaluationFailure {
|
|
|
649
674
|
trace: TraceStep[];
|
|
650
675
|
initialState: Record<string, Value> | undefined;
|
|
651
676
|
exitCode: number;
|
|
677
|
+
replay?: Replay;
|
|
678
|
+
isWithoutStatistics?: boolean;
|
|
679
|
+
}
|
|
680
|
+
interface Replay {
|
|
681
|
+
output: string[];
|
|
682
|
+
callStack: string[] | undefined;
|
|
683
|
+
fingerprint?: Fingerprint;
|
|
684
|
+
isBeforeError?: boolean;
|
|
685
|
+
}
|
|
686
|
+
interface Fingerprint {
|
|
687
|
+
sources: string[];
|
|
688
|
+
reason: string;
|
|
652
689
|
}
|
|
653
690
|
interface CheckResult {
|
|
654
691
|
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};
|