tla-ts 0.0.1 → 0.0.3-dev.763cc71
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 +81 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +215 -30
- package/dist/index.d.ts +215 -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 +20 -1
- package/dist/run-cli.js +20 -1
- package/dist/transfer.cjs +388 -39
- package/dist/transfer.js +388 -39
- package/package.json +6 -2
- package/src/ast.ts +122 -5
- package/src/bags.ts +161 -71
- package/src/builtins.ts +203 -23
- package/src/bundled-modules.ts +63 -32
- package/src/check.ts +945 -238
- package/src/cli-options.ts +58 -0
- package/src/codegen.ts +52 -18
- package/src/config.ts +39 -11
- package/src/environment.ts +485 -140
- package/src/errors.ts +59 -1
- package/src/evaluate.ts +489 -137
- package/src/exit-codes.ts +75 -0
- package/src/fingerprints.ts +2 -2
- package/src/index.ts +9 -4
- package/src/instances.ts +221 -66
- package/src/java-overrides.ts +241 -0
- package/src/json.ts +153 -72
- package/src/levels.ts +850 -0
- package/src/lexer.ts +103 -28
- package/src/liveness.ts +47 -91
- 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 +78 -30
- package/src/parallel.ts +116 -62
- package/src/parser.ts +958 -205
- package/src/pretty-print.ts +259 -0
- package/src/randomization.ts +24 -113
- package/src/resolve.ts +472 -41
- package/src/run-cli.ts +427 -61
- package/src/runtime.ts +63 -28
- package/src/spec-description.ts +509 -0
- package/src/standard-levels.ts +105 -0
- package/src/standard-modules.ts +223 -92
- package/src/subexpressions.ts +21 -35
- package/src/substitution-levels.ts +184 -0
- package/src/successors.ts +261 -46
- package/src/symmetry.ts +65 -21
- package/src/tableau.ts +43 -37
- package/src/tlc-ext.ts +120 -33
- package/src/tlc-module.ts +71 -47
- package/src/tlc-modules.ts +1022 -0
- package/src/tlc-order.ts +497 -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 +1231 -176
package/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
[](https://npmjs.com/package/tla-ts)
|
|
4
4
|
[](https://npmjs.com/package/tla-ts)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
tla-ts is a drop-in replacement for [TLC](https://github.com/tlaplus/tlaplus) that's **2× faster**.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
TLA+ lets you write formal models of a system, and TLC model checks them. But TLC is written in Java and needs the JVM. tla-ts runs anywhere JavaScript runs, such as the browser, Node, and Bun. Try it in the [playground](https://tla-ts.aidenybai.com).
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
import { check } from "tla-ts";
|
|
12
12
|
|
|
13
|
-
const result = check({
|
|
13
|
+
const result = await check({
|
|
14
14
|
source: `---- MODULE Counter ----
|
|
15
15
|
EXTENDS Naturals
|
|
16
16
|
VARIABLE x
|
|
@@ -30,34 +30,76 @@ result.status; // "invariant-violation"
|
|
|
30
30
|
npm install tla-ts
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Command line
|
|
34
|
+
|
|
35
|
+
The `tla-ts` command takes TLC's options and prints TLC's output. `tla-ts prove` takes tlapm's options and prints tlapm's output.
|
|
36
|
+
|
|
37
|
+
### Check a spec
|
|
38
|
+
|
|
39
|
+
To check a spec, pass its path:
|
|
34
40
|
|
|
35
41
|
```shell
|
|
36
42
|
npx tla-ts Spec.tla
|
|
37
|
-
npx tla-ts Spec.tla -config Other.cfg -deadlock
|
|
38
|
-
npx tla-ts Spec.tla -workers auto
|
|
39
43
|
```
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
tla-ts reads the configuration from `Spec.cfg` next to the spec. It exits with the exit code TLC uses for the same result.
|
|
46
|
+
|
|
47
|
+
You can pass several paths, or a glob such as `"specs/*.tla"`. tla-ts checks each spec in turn and exits with the exit code of the first spec that fails. A glob skips each module that has no `.cfg` next to it, so it doesn't check helper modules that other specs import. tla-ts never skips a path that you pass by name. If you pass a `.cfg` path, tla-ts checks the `.tla` file with the same name.
|
|
48
|
+
|
|
49
|
+
The options are:
|
|
50
|
+
|
|
51
|
+
- `-config <Spec.cfg>`: read the configuration from this file. You can use it only when you check one spec.
|
|
52
|
+
- `-deadlock`: don't report deadlocks.
|
|
53
|
+
- `-lncheck final`: check liveness once, after the search ends.
|
|
54
|
+
- `-seed <num>`: seed `RandomElement` and the `Randomization` module. The default is 0.
|
|
55
|
+
- `-workers <count|auto>`: search with this number of worker threads. `auto` uses one thread per core. The default is 1.
|
|
56
|
+
|
|
57
|
+
TLC can replace a module's operators with Java methods, and tla-ts reads the same files. If the spec's directory has `Module.class`, tla-ts replaces each operator in `Module` with the public static method that has the same name and arity.
|
|
58
|
+
|
|
59
|
+
### Generate proof obligations
|
|
60
|
+
|
|
61
|
+
A proof obligation is one claim that a backend prover must prove. `tla-ts prove -N` prints the obligations of a module, as `tlapm -N` does. It doesn't run a prover. For example, this command prints every obligation in `Module.tla` with its text:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
npx tla-ts prove -N --toolbox 0 0 --printallobs Module.tla
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
With `--toolbox` or `--line`, tla-ts writes the messages of the TLA+ Toolbox protocol to stderr, as tlapm does. If you pass a tlapm option that isn't in this list, tla-ts prints an error:
|
|
68
|
+
|
|
69
|
+
- `--toolbox <start> <end>`: print Toolbox messages for the proofs from line `start` to line `end`. `0 0` selects the whole module.
|
|
70
|
+
- `--line <num>`: print Toolbox messages for the proof at this line.
|
|
71
|
+
- `--printallobs`: print the text of each obligation.
|
|
72
|
+
- `--summary`: print the number of obligations in each module, and list its missing and omitted proofs. You don't need `-N` with `--summary`.
|
|
73
|
+
- `--strict`: report missing proofs, omitted proofs and a selected range with no obligations as errors.
|
|
74
|
+
- `-I <directory>`: search this directory for modules.
|
|
75
|
+
|
|
76
|
+
tla-ts searches for modules in the same order as tlapm:
|
|
42
77
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
78
|
+
1. The directory of each module you pass, the last one first.
|
|
79
|
+
2. The current directory.
|
|
80
|
+
3. The standard library of tlapm, which has the `TLAPS` module. tla-ts searches it only if `tlapm` is on your `PATH`.
|
|
81
|
+
4. The `-I` directories, the last one first.
|
|
82
|
+
|
|
83
|
+
### Prove with tlapm
|
|
84
|
+
|
|
85
|
+
tla-ts doesn't include a prover. Without `-N` or `--summary`, `tla-ts prove` runs [tlapm](https://github.com/tlaplus/tlapm) from your `PATH`:
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
npx tla-ts prove Module.tla
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
tla-ts expands the globs and passes every argument to tlapm, so all of tlapm's options work. tlapm sends the obligations to its provers, and tla-ts exits with the exit code of tlapm. If `tlapm` isn't on your `PATH`, tla-ts prints an error and exits with code 1.
|
|
50
92
|
|
|
51
93
|
## API reference
|
|
52
94
|
|
|
53
95
|
### `check`
|
|
54
96
|
|
|
55
|
-
Checks a spec against a TLC configuration and
|
|
97
|
+
Checks a spec against a TLC configuration and resolves to the result.
|
|
56
98
|
|
|
57
99
|
```ts
|
|
58
100
|
import { check } from "tla-ts";
|
|
59
101
|
|
|
60
|
-
const result = check({
|
|
102
|
+
const result = await check({
|
|
61
103
|
source: specSource,
|
|
62
104
|
config: configSource,
|
|
63
105
|
loadModule: (name) => modules[name],
|
|
@@ -65,36 +107,33 @@ const result = check({
|
|
|
65
107
|
});
|
|
66
108
|
```
|
|
67
109
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
110
|
+
| Option | Description |
|
|
111
|
+
| ----------------------- | ---------------------------------------------------------------------------------------- |
|
|
112
|
+
| `source` | The TLA+ module to check |
|
|
113
|
+
| `config` | A TLC configuration, as text or as the result of `parseConfig` |
|
|
114
|
+
| `loadModule` | Returns the source of a module that isn't a standard module |
|
|
115
|
+
| `loadClass` | Returns a compiled Java class that overrides a module's operators with constants |
|
|
116
|
+
| `onPrint` | Receives the output of `Print` and `PrintT`. Defaults to `console.log` |
|
|
117
|
+
| `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
|
+
| `seed` | A `bigint` seed. Defaults to `0n`, and matches TLC run with the same `-seed` and `-fp 0` |
|
|
120
|
+
| `workers` | The number of worker threads. Defaults to 1 |
|
|
75
121
|
|
|
76
|
-
The result has
|
|
122
|
+
The result has these fields:
|
|
77
123
|
|
|
78
|
-
`
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
- **Configuration**: `INIT`, `NEXT`, `SPECIFICATION`, `CONSTANTS`, `INVARIANTS`, `PROPERTIES`, `CONSTRAINTS`, `ACTION_CONSTRAINTS`, `SYMMETRY`, `VIEW`, `POSTCONDITION`, `CHECK_DEADLOCK`, and `_POSSIBLE` properties
|
|
83
|
-
- **Properties**: invariants, `[][A]_v`, and every temporal formula TLC accepts, checked through TLC's tableau construction under the fairness and temporal conjuncts of the specification
|
|
84
|
-
- **Subexpression references**: selectors such as `F(2)!3`, `Op!<<`, `Op!>>`, `Op!:`, `Op!@`, and `Op!(x)`, labels such as `Op!lab`, and names of `THEOREM` formulas
|
|
85
|
-
- **TLC semantics**: 32-bit integer overflow errors, `ENABLED`, `TLCGet` and `TLCSet` with TLC's counters and registers, and TLC's enumeration order for `CHOOSE` and quantifiers
|
|
124
|
+
- `status`: `"success"`, `"deadlock"`, `"assumption-violation"`, `"invariant-violation"`, `"property-violation"`, `"liveness-violation"`, `"postcondition-violation"`, or `"error"`.
|
|
125
|
+
- `violation`: the `name` of what failed and the `trace` that reaches it. `loopStart` marks where a liveness counterexample loops back.
|
|
126
|
+
- `failure`: the message and trace when `status` is `"error"`.
|
|
127
|
+
- `generatedStates`, `distinctStates`, and `depth`: TLC's state counts.
|
|
86
128
|
|
|
87
|
-
|
|
129
|
+
Workers run in Node, Bun, Deno, and the browser, and deduplicate states by 64-bit fingerprint as TLC does. `check` runs on the calling thread for specs with liveness properties or impure operators such as `Print`. After a violation, it reruns there to return the exact trace.
|
|
88
130
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { checkInParallel } from "tla-ts";
|
|
93
|
-
|
|
94
|
-
const result = await checkInParallel({ source: specSource, config: configSource, workers: 4 });
|
|
95
|
-
```
|
|
131
|
+
`check` supports:
|
|
96
132
|
|
|
97
|
-
|
|
133
|
+
- **Modules**: the standard modules, TLCExt, Json, and Randomization, plus `EXTENDS`, `INSTANCE`, and `LAMBDA`.
|
|
134
|
+
- **Configuration**: `CONSTANTS`, `INIT`, `NEXT`, `SPECIFICATION`, invariants, properties, constraints, `SYMMETRY`, `VIEW`, `ALIAS`, `POSTCONDITION`, `CHECK_DEADLOCK`, and `_POSSIBLE`.
|
|
135
|
+
- **Properties**: invariants and every temporal formula TLC accepts, checked through TLC's tableau construction.
|
|
136
|
+
- **TLC semantics**: 32-bit integer overflow, `TLCGet` and `TLCSet`, subexpression references such as `Op!2`, and TLC's enumeration order for `CHOOSE` and quantifiers.
|
|
98
137
|
|
|
99
138
|
### `parseModule`
|
|
100
139
|
|
|
@@ -116,7 +155,7 @@ import { check, parseConfig } from "tla-ts";
|
|
|
116
155
|
|
|
117
156
|
const config = parseConfig(configSource);
|
|
118
157
|
config.checkDeadlock = false;
|
|
119
|
-
check({ source: specSource, config });
|
|
158
|
+
await check({ source: specSource, config });
|
|
120
159
|
```
|
|
121
160
|
|
|
122
161
|
### `formatValue`
|
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.k,exports.TlaError=e.A,exports.TlaEvaluationError=e.j,exports.TlaSyntaxError=e.N,exports.TlaUnsupportedError=e.P,exports.check=t.t,exports.formatValue=e.C,exports.parseConfig=e.D,exports.parseModule=e._;
|
package/dist/index.d.cts
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;
|
|
302
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;
|
|
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,39 @@ 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;
|
|
361
523
|
}
|
|
362
524
|
interface SetValue {
|
|
363
525
|
kind: "Set";
|
|
@@ -365,12 +527,17 @@ interface SetValue {
|
|
|
365
527
|
hash: number;
|
|
366
528
|
fingerprint: number;
|
|
367
529
|
}
|
|
530
|
+
interface MixedSetValue {
|
|
531
|
+
kind: "MixedSet";
|
|
532
|
+
elements: Value[];
|
|
533
|
+
}
|
|
368
534
|
interface FunctionValue {
|
|
369
535
|
kind: "Function";
|
|
370
536
|
domain: Value[];
|
|
371
537
|
range: Value[];
|
|
372
538
|
hash: number;
|
|
373
539
|
fingerprint: number;
|
|
540
|
+
writtenKeys: Value[] | undefined;
|
|
374
541
|
}
|
|
375
542
|
interface IntervalValue {
|
|
376
543
|
kind: "Interval";
|
|
@@ -414,58 +581,76 @@ interface FilteredSetValue {
|
|
|
414
581
|
base: Value;
|
|
415
582
|
test: (element: Value) => boolean;
|
|
416
583
|
}
|
|
584
|
+
interface UnionValue {
|
|
585
|
+
kind: "Union";
|
|
586
|
+
base: Value;
|
|
587
|
+
}
|
|
588
|
+
interface LazyFunctionParameter {
|
|
589
|
+
name: string;
|
|
590
|
+
domain: Value;
|
|
591
|
+
}
|
|
592
|
+
interface LazyFunctionSource {
|
|
593
|
+
parameters: LazyFunctionParameter[];
|
|
594
|
+
body: string;
|
|
595
|
+
}
|
|
417
596
|
interface LazyFunctionValue {
|
|
418
597
|
kind: "LazyFunction";
|
|
419
598
|
domain: Value;
|
|
420
599
|
apply: (argument: Value) => Value;
|
|
600
|
+
source?: LazyFunctionSource;
|
|
421
601
|
}
|
|
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,
|
|
602
|
+
type Value = boolean | number | string | ModelValue | SetValue | MixedSetValue | FunctionValue | IntervalValue | InfiniteSetValue | SubsetValue | FunctionSetValue | RecordSetValue | ProductSetValue | SequenceSetValue | SetOperationValue | FilteredSetValue | UnionValue | LazyFunctionValue;
|
|
603
|
+
export declare const formatValue: (value: Value, isStrict?: boolean, isNormalized?: boolean) => string;
|
|
424
604
|
interface CheckOptions {
|
|
425
605
|
source: string;
|
|
426
606
|
config: string | ModelConfig;
|
|
427
607
|
loadModule?: (name: string) => string | undefined;
|
|
608
|
+
loadClass?: (name: string) => Uint8Array | undefined;
|
|
428
609
|
onPrint?: (text: string) => void;
|
|
610
|
+
onPause?: () => void;
|
|
429
611
|
readFile?: (path: string) => string | undefined;
|
|
430
612
|
writeFile?: (path: string, content: string) => void;
|
|
613
|
+
seed?: bigint;
|
|
614
|
+
workers?: number;
|
|
615
|
+
livenessCheck?: "default" | "final";
|
|
431
616
|
}
|
|
432
|
-
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock";
|
|
617
|
+
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
433
618
|
interface TraceStep {
|
|
434
619
|
action: string | undefined;
|
|
620
|
+
label: string | undefined;
|
|
435
621
|
state: Record<string, Value>;
|
|
436
622
|
}
|
|
437
623
|
interface Violation {
|
|
438
624
|
name: string;
|
|
439
625
|
trace: TraceStep[];
|
|
440
626
|
loopStart: number | undefined;
|
|
627
|
+
loopLabel?: string;
|
|
441
628
|
message?: string;
|
|
629
|
+
counts?: string;
|
|
630
|
+
unwitnessed?: Postcondition;
|
|
631
|
+
}
|
|
632
|
+
interface Postcondition {
|
|
633
|
+
name: string;
|
|
634
|
+
message: string;
|
|
635
|
+
counts?: string;
|
|
636
|
+
}
|
|
637
|
+
interface EvaluationFailure {
|
|
638
|
+
message: string;
|
|
639
|
+
trace: TraceStep[];
|
|
640
|
+
initialState: Record<string, Value> | undefined;
|
|
641
|
+
exitCode: number;
|
|
442
642
|
}
|
|
443
643
|
interface CheckResult {
|
|
444
644
|
status: CheckStatus;
|
|
445
645
|
violation: Violation | undefined;
|
|
646
|
+
failure: EvaluationFailure | undefined;
|
|
446
647
|
generatedStates: number;
|
|
447
648
|
distinctStates: number;
|
|
649
|
+
queuedStates: number;
|
|
448
650
|
depth: number;
|
|
651
|
+
outDegrees: number[] | undefined;
|
|
652
|
+
fingerprintDistance: bigint | undefined;
|
|
449
653
|
}
|
|
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>;
|
|
654
|
+
export declare const check: (options: CheckOptions) => Promise<CheckResult>;
|
|
470
655
|
export declare const parseModule: (source: string) => Module;
|
|
471
|
-
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, ModelConfig, Module,
|
|
656
|
+
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
|