tla-ts 0.0.1 → 0.0.3-dev.19c763f
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 +98 -39
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +225 -30
- package/dist/index.d.ts +225 -30
- 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 +21 -1
- package/dist/run-cli.js +21 -1
- package/dist/transfer.cjs +400 -39
- package/dist/transfer.js +400 -39
- package/package.json +6 -2
- package/src/ast.ts +213 -6
- package/src/bags.ts +161 -71
- package/src/builtins.ts +203 -23
- package/src/bundled-modules.ts +63 -32
- package/src/check.ts +1086 -244
- package/src/cli-options.ts +64 -0
- package/src/codegen.ts +58 -34
- package/src/config.ts +39 -11
- package/src/dependencies.ts +2 -2
- package/src/environment.ts +557 -153
- package/src/errors.ts +66 -1
- package/src/evaluate.ts +547 -255
- package/src/exit-codes.ts +53 -0
- package/src/fingerprints.ts +48 -13
- package/src/index.ts +9 -4
- package/src/instances.ts +235 -79
- package/src/java-overrides.ts +241 -0
- package/src/json.ts +153 -72
- package/src/levels.ts +850 -0
- package/src/lexer.ts +108 -29
- package/src/live-check.ts +710 -0
- package/src/liveness.ts +37 -599
- 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 +186 -201
- package/src/parallel.ts +179 -84
- package/src/parser.ts +970 -206
- package/src/pretty-print.ts +259 -0
- package/src/randomization.ts +24 -113
- package/src/resolve.ts +483 -51
- package/src/run-cli.ts +473 -62
- package/src/runtime.ts +65 -28
- package/src/spec-description.ts +521 -0
- package/src/standard-levels.ts +105 -0
- package/src/standard-modules.ts +223 -92
- package/src/state-graph.ts +157 -0
- package/src/subexpressions.ts +31 -45
- package/src/substitution-levels.ts +184 -0
- package/src/successors.ts +276 -53
- package/src/symmetry.ts +79 -23
- package/src/tableau.ts +43 -37
- package/src/tlc-ext.ts +148 -44
- package/src/tlc-module.ts +71 -66
- package/src/tlc-modules.ts +1022 -0
- package/src/tlc-order.ts +511 -0
- package/src/tlc-random.ts +411 -0
- package/src/tlc-summary.ts +109 -0
- package/src/transfer.ts +26 -5
- package/src/values.ts +1245 -176
package/dist/index.d.ts
CHANGED
|
@@ -12,10 +12,22 @@ interface LocalResolution {
|
|
|
12
12
|
interface SourceLocation {
|
|
13
13
|
line: number;
|
|
14
14
|
column: number;
|
|
15
|
+
range?: SourceRange;
|
|
16
|
+
}
|
|
17
|
+
interface SourceRange {
|
|
18
|
+
module: string;
|
|
19
|
+
start: SourceLocation;
|
|
20
|
+
end: SourceLocation;
|
|
15
21
|
}
|
|
16
22
|
interface NumberExpression {
|
|
17
23
|
kind: "Number";
|
|
18
24
|
value: number;
|
|
25
|
+
text?: string;
|
|
26
|
+
location: SourceLocation;
|
|
27
|
+
}
|
|
28
|
+
interface DecimalExpression {
|
|
29
|
+
kind: "Decimal";
|
|
30
|
+
text: string;
|
|
19
31
|
location: SourceLocation;
|
|
20
32
|
}
|
|
21
33
|
interface StringExpression {
|
|
@@ -33,6 +45,7 @@ interface ApplyExpression {
|
|
|
33
45
|
kind: "Apply";
|
|
34
46
|
operator: string;
|
|
35
47
|
args: Expression[];
|
|
48
|
+
argumentCounts?: number[];
|
|
36
49
|
location: SourceLocation;
|
|
37
50
|
resolution?: LocalResolution;
|
|
38
51
|
}
|
|
@@ -50,6 +63,7 @@ interface LambdaExpression {
|
|
|
50
63
|
interface JunctionExpression {
|
|
51
64
|
kind: "And" | "Or";
|
|
52
65
|
operands: Expression[];
|
|
66
|
+
isBulleted?: boolean;
|
|
53
67
|
location: SourceLocation;
|
|
54
68
|
}
|
|
55
69
|
interface PrimeExpression {
|
|
@@ -110,6 +124,7 @@ interface QuantifierExpression {
|
|
|
110
124
|
}
|
|
111
125
|
interface UnboundedQuantifierExpression {
|
|
112
126
|
kind: "UnboundedQuantifier";
|
|
127
|
+
quantifier: "Forall" | "Exists";
|
|
113
128
|
names: string[];
|
|
114
129
|
isTemporal?: boolean;
|
|
115
130
|
body: Expression;
|
|
@@ -249,16 +264,18 @@ interface SubexpressionExpression {
|
|
|
249
264
|
selectors: Selector[];
|
|
250
265
|
location: SourceLocation;
|
|
251
266
|
}
|
|
252
|
-
type Expression = NumberExpression | 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;
|
|
267
|
+
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;
|
|
253
268
|
interface OperatorParam {
|
|
254
269
|
name: string;
|
|
255
270
|
arity: number;
|
|
271
|
+
location?: SourceLocation;
|
|
256
272
|
}
|
|
257
273
|
interface OperatorDefinition {
|
|
258
274
|
kind: "Operator";
|
|
259
275
|
name: string;
|
|
260
276
|
params: OperatorParam[];
|
|
261
277
|
body: Expression;
|
|
278
|
+
bodyRange?: SourceRange;
|
|
262
279
|
isLocal: boolean;
|
|
263
280
|
isRecursive: boolean;
|
|
264
281
|
location: SourceLocation;
|
|
@@ -276,6 +293,7 @@ type Definition = OperatorDefinition | FunctionDefinition;
|
|
|
276
293
|
interface Declaration {
|
|
277
294
|
name: string;
|
|
278
295
|
arity: number;
|
|
296
|
+
location: SourceLocation;
|
|
279
297
|
}
|
|
280
298
|
interface Assumption {
|
|
281
299
|
name: string | undefined;
|
|
@@ -295,21 +313,139 @@ interface Instance {
|
|
|
295
313
|
substitutions: InstanceSubstitution[];
|
|
296
314
|
isLocal: boolean;
|
|
297
315
|
location: SourceLocation;
|
|
316
|
+
instanceRange: SourceRange;
|
|
317
|
+
definitionRange?: SourceRange;
|
|
298
318
|
}
|
|
299
|
-
interface
|
|
300
|
-
|
|
301
|
-
|
|
319
|
+
interface NewSymbol {
|
|
320
|
+
kind: "NewSymbol";
|
|
321
|
+
name: string;
|
|
322
|
+
arity: number;
|
|
323
|
+
level: "Constant" | "Variable" | "State" | "Action" | "Temporal";
|
|
324
|
+
set: Expression | undefined;
|
|
325
|
+
location: SourceLocation;
|
|
326
|
+
}
|
|
327
|
+
interface AssumeProve {
|
|
328
|
+
kind: "AssumeProve";
|
|
329
|
+
assumptions: (Expression | NewSymbol | AssumeProve)[];
|
|
330
|
+
conclusion: Expression;
|
|
331
|
+
location: SourceLocation;
|
|
332
|
+
}
|
|
333
|
+
type Fact = Expression | {
|
|
334
|
+
kind: "ModuleFact";
|
|
335
|
+
name: string;
|
|
336
|
+
location: SourceLocation;
|
|
337
|
+
};
|
|
338
|
+
interface UseOrHide {
|
|
339
|
+
kind: "Use" | "Hide";
|
|
340
|
+
isOnly: boolean;
|
|
341
|
+
facts: Fact[];
|
|
342
|
+
defs: Fact[];
|
|
343
|
+
keyword: SourceRange;
|
|
344
|
+
location: SourceLocation;
|
|
345
|
+
}
|
|
346
|
+
type Proof = {
|
|
347
|
+
kind: "Obvious" | "Omitted";
|
|
348
|
+
keyword: SourceRange;
|
|
349
|
+
location: SourceLocation;
|
|
350
|
+
} | {
|
|
351
|
+
kind: "By";
|
|
352
|
+
isOnly: boolean;
|
|
353
|
+
facts: Fact[];
|
|
354
|
+
defs: Fact[];
|
|
355
|
+
keyword: SourceRange;
|
|
356
|
+
location: SourceLocation;
|
|
357
|
+
} | {
|
|
358
|
+
kind: "Steps";
|
|
359
|
+
level: number;
|
|
360
|
+
steps: ProofStep[];
|
|
361
|
+
location: SourceLocation;
|
|
362
|
+
};
|
|
363
|
+
interface DefineStep {
|
|
364
|
+
kind: "Define";
|
|
365
|
+
definitions: (Definition | Instance)[];
|
|
366
|
+
location: SourceLocation;
|
|
367
|
+
}
|
|
368
|
+
type StepBody = UseOrHide | Instance | DefineStep | {
|
|
369
|
+
kind: "Have";
|
|
370
|
+
expression: Expression;
|
|
371
|
+
} | {
|
|
372
|
+
kind: "Take";
|
|
373
|
+
names: string[];
|
|
374
|
+
bounds: Bound[];
|
|
375
|
+
} | {
|
|
376
|
+
kind: "Witness";
|
|
377
|
+
expressions: Expression[];
|
|
378
|
+
} | {
|
|
379
|
+
kind: "Pick";
|
|
380
|
+
names: string[];
|
|
381
|
+
bounds: Bound[];
|
|
382
|
+
body: Expression;
|
|
383
|
+
} | {
|
|
384
|
+
kind: "Case";
|
|
385
|
+
expression: Expression;
|
|
386
|
+
} | {
|
|
387
|
+
kind: "Assert";
|
|
388
|
+
isSuffices: boolean;
|
|
389
|
+
statement: Expression | AssumeProve;
|
|
390
|
+
} | {
|
|
391
|
+
kind: "Qed";
|
|
392
|
+
};
|
|
393
|
+
interface ProofStep {
|
|
394
|
+
name: string | undefined;
|
|
395
|
+
token: string;
|
|
396
|
+
body: StepBody;
|
|
397
|
+
head: SourceRange;
|
|
398
|
+
proof: Proof | undefined;
|
|
399
|
+
location: SourceLocation;
|
|
400
|
+
}
|
|
401
|
+
interface Theorem {
|
|
402
|
+
name: string | undefined;
|
|
403
|
+
statement: Expression | AssumeProve;
|
|
404
|
+
proof: Proof | undefined;
|
|
405
|
+
location: SourceLocation;
|
|
302
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
|
+
};
|
|
303
435
|
interface Module {
|
|
304
436
|
name: string;
|
|
305
|
-
outer: OuterScope | undefined;
|
|
306
437
|
modules: Module[];
|
|
307
438
|
extends: string[];
|
|
439
|
+
extendsRanges: SourceRange[];
|
|
308
440
|
constants: Declaration[];
|
|
309
|
-
variables:
|
|
441
|
+
variables: Declaration[];
|
|
310
442
|
definitions: Definition[];
|
|
311
443
|
instances: Instance[];
|
|
312
444
|
assumptions: Assumption[];
|
|
445
|
+
location: SourceLocation;
|
|
446
|
+
theorems: Theorem[];
|
|
447
|
+
uses: UseOrHide[];
|
|
448
|
+
units: ModuleUnit[];
|
|
313
449
|
}
|
|
314
450
|
type ConfigValue = {
|
|
315
451
|
kind: "Number";
|
|
@@ -351,13 +487,40 @@ interface ModelConfig {
|
|
|
351
487
|
checkDeadlock: boolean;
|
|
352
488
|
symmetry: string | undefined;
|
|
353
489
|
view: string | undefined;
|
|
490
|
+
alias: string | undefined;
|
|
354
491
|
postconditions: string[];
|
|
355
492
|
possible: string[];
|
|
493
|
+
periodic: string | undefined;
|
|
494
|
+
rlReward: string | undefined;
|
|
356
495
|
}
|
|
357
496
|
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
|
+
}
|
|
358
519
|
interface ModelValue {
|
|
359
520
|
kind: "ModelValue";
|
|
360
521
|
name: string;
|
|
522
|
+
type: string | undefined;
|
|
523
|
+
rank: number;
|
|
361
524
|
}
|
|
362
525
|
interface SetValue {
|
|
363
526
|
kind: "Set";
|
|
@@ -365,12 +528,17 @@ interface SetValue {
|
|
|
365
528
|
hash: number;
|
|
366
529
|
fingerprint: number;
|
|
367
530
|
}
|
|
531
|
+
interface MixedSetValue {
|
|
532
|
+
kind: "MixedSet";
|
|
533
|
+
elements: Value[];
|
|
534
|
+
}
|
|
368
535
|
interface FunctionValue {
|
|
369
536
|
kind: "Function";
|
|
370
537
|
domain: Value[];
|
|
371
538
|
range: Value[];
|
|
372
539
|
hash: number;
|
|
373
540
|
fingerprint: number;
|
|
541
|
+
writtenKeys: Value[] | undefined;
|
|
374
542
|
}
|
|
375
543
|
interface IntervalValue {
|
|
376
544
|
kind: "Interval";
|
|
@@ -414,58 +582,85 @@ interface FilteredSetValue {
|
|
|
414
582
|
base: Value;
|
|
415
583
|
test: (element: Value) => boolean;
|
|
416
584
|
}
|
|
585
|
+
interface UnionValue {
|
|
586
|
+
kind: "Union";
|
|
587
|
+
base: Value;
|
|
588
|
+
}
|
|
589
|
+
interface LazyFunctionParameter {
|
|
590
|
+
name: string;
|
|
591
|
+
domain: Value;
|
|
592
|
+
}
|
|
593
|
+
interface LazyFunctionSource {
|
|
594
|
+
parameters: LazyFunctionParameter[];
|
|
595
|
+
body: string;
|
|
596
|
+
}
|
|
417
597
|
interface LazyFunctionValue {
|
|
418
598
|
kind: "LazyFunction";
|
|
419
599
|
domain: Value;
|
|
420
600
|
apply: (argument: Value) => Value;
|
|
601
|
+
source?: LazyFunctionSource;
|
|
602
|
+
}
|
|
603
|
+
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
604
|
+
export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
|
|
605
|
+
interface StateDump {
|
|
606
|
+
path: string;
|
|
607
|
+
dot?: boolean;
|
|
608
|
+
colorize?: boolean;
|
|
609
|
+
actionLabels?: boolean;
|
|
610
|
+
snapshot?: boolean;
|
|
421
611
|
}
|
|
422
|
-
type Value = boolean | number | string | ModelValue | SetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | LazyFunctionValue;
|
|
423
|
-
export declare const formatValue: (value: Value, isExpanded?: boolean) => string;
|
|
424
612
|
interface CheckOptions {
|
|
425
613
|
source: string;
|
|
426
614
|
config: string | ModelConfig;
|
|
427
615
|
loadModule?: (name: string) => string | undefined;
|
|
616
|
+
loadClass?: (name: string) => Uint8Array | undefined;
|
|
428
617
|
onPrint?: (text: string) => void;
|
|
618
|
+
onPause?: () => void;
|
|
429
619
|
readFile?: (path: string) => string | undefined;
|
|
430
620
|
writeFile?: (path: string, content: string) => void;
|
|
621
|
+
seed?: bigint;
|
|
622
|
+
workers?: number;
|
|
623
|
+
livenessCheck?: "default" | "final";
|
|
624
|
+
dump?: StateDump;
|
|
431
625
|
}
|
|
432
|
-
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock";
|
|
626
|
+
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
433
627
|
interface TraceStep {
|
|
434
628
|
action: string | undefined;
|
|
629
|
+
label: string | undefined;
|
|
435
630
|
state: Record<string, Value>;
|
|
436
631
|
}
|
|
437
632
|
interface Violation {
|
|
438
633
|
name: string;
|
|
634
|
+
properties?: string[];
|
|
439
635
|
trace: TraceStep[];
|
|
440
636
|
loopStart: number | undefined;
|
|
637
|
+
loopLabel?: string;
|
|
441
638
|
message?: string;
|
|
639
|
+
counts?: string;
|
|
640
|
+
unwitnessed?: Postcondition;
|
|
641
|
+
}
|
|
642
|
+
interface Postcondition {
|
|
643
|
+
name: string;
|
|
644
|
+
message: string;
|
|
645
|
+
counts?: string;
|
|
646
|
+
}
|
|
647
|
+
interface EvaluationFailure {
|
|
648
|
+
message: string;
|
|
649
|
+
trace: TraceStep[];
|
|
650
|
+
initialState: Record<string, Value> | undefined;
|
|
651
|
+
exitCode: number;
|
|
442
652
|
}
|
|
443
653
|
interface CheckResult {
|
|
444
654
|
status: CheckStatus;
|
|
445
655
|
violation: Violation | undefined;
|
|
656
|
+
failure: EvaluationFailure | undefined;
|
|
446
657
|
generatedStates: number;
|
|
447
658
|
distinctStates: number;
|
|
659
|
+
queuedStates: number;
|
|
448
660
|
depth: number;
|
|
661
|
+
outDegrees: number[] | undefined;
|
|
662
|
+
fingerprintDistance: bigint | undefined;
|
|
449
663
|
}
|
|
450
|
-
export declare const check: (options: CheckOptions) => CheckResult
|
|
451
|
-
export declare class TlaError extends Error {
|
|
452
|
-
constructor(message: string, cause?: unknown);
|
|
453
|
-
}
|
|
454
|
-
export declare class TlaSyntaxError extends TlaError {
|
|
455
|
-
constructor(message: string, cause?: unknown);
|
|
456
|
-
}
|
|
457
|
-
export declare class TlaConfigError extends TlaError {
|
|
458
|
-
constructor(message: string, cause?: unknown);
|
|
459
|
-
}
|
|
460
|
-
export declare class TlaEvaluationError extends TlaError {
|
|
461
|
-
constructor(message: string, cause?: unknown);
|
|
462
|
-
}
|
|
463
|
-
export declare class TlaUnsupportedError extends TlaError {
|
|
464
|
-
constructor(message: string, cause?: unknown);
|
|
465
|
-
}
|
|
466
|
-
interface ParallelCheckOptions extends CheckOptions {
|
|
467
|
-
workers: number;
|
|
468
|
-
}
|
|
469
|
-
export declare const checkInParallel: (options: ParallelCheckOptions) => Promise<CheckResult>;
|
|
664
|
+
export declare const check: (options: CheckOptions) => Promise<CheckResult>;
|
|
470
665
|
export declare const parseModule: (source: string) => Module;
|
|
471
|
-
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, ModelConfig, Module,
|
|
666
|
+
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
|
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{A as e,D 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.k(e._(t.source,t.config,i));let o=e.O(),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)){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.O()===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{O as e,T as t,_ as n,c as r,k 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,
|
|
12
|
+
`node:worker_threads`)).parentPort,h=(m,h)=>{let g=new Map(m.modules),_=e=>g.get(e),v=new Map(m.classes);i(n(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=t(),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 i=n[e.index];if(x.findViolatedActionProperty(t,i.state))return;if(!x.satisfiesActionConstraints(t,i.state)){if(x.findViolatedInvariant(i.state,t))return;continue}if(k&&(r(i.state,A),!k.insert(A[0],A[1])))continue;w(i.state);let a=x.getFingerprintState(i.state);if(r(a,A),o(E.fingerprints,A[0],A[1])){if(x.findViolatedInvariant(i.state,t))return;x.satisfiesConstraints(i.state,t)&&(e.next.push(i.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`,
|
|
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=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.k(e._(n.source,r,l));let f=e.O(),p=e.y(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));if(e.d(p.assumptions,m)||!h||h.spec.init===void 0||h.spec.next===void 0||h.properties.liveness.length>0||e.S(m))return o();let g=e.T(),_={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.C(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.P))throw t;return o()}if(e.O()!==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{
|
|
9
|
+
import{A as e,C as t,O as n,P as r,S as i,T as a,_ as o,a as s,c,d as l,i as ee,k as te,l as u,m as d,n as f,o as ne,s as p,u as m,v 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`,
|
|
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`?e(v.config):v.config,b=v.onPrint??console.log,x={count:0},S=()=>{let e={count:x.count};return u({...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};te(o(v.source,y,T));let O=n(),k=g(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=m(y,A,()=>h(v.source,T));if(l(k.assumptions,A)||!j||j.spec.init===void 0||j.spec.next===void 0||j.properties.liveness.length>0||i(A))return S();let M=a(),N={fingerprints:ee()},P=/* @__PURE__ */ new Int32Array(2),F=Array.from({length:C},f),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:d(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),p(N.fingerprints)&&(N.fingerprints=s(N.fingerprints)),ne(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 r))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},()=>_(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=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{v as t};
|