tla-ts 0.0.1 → 0.0.3-dev.3cf2ad0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -40
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +216 -30
- package/dist/index.d.ts +216 -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 +48 -13
- 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 +183 -202
- package/src/parallel.ts +163 -84
- 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 +70 -22
- 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 +1234 -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.
|
|
42
75
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
tla-ts searches for modules in the same order as tlapm:
|
|
77
|
+
|
|
78
|
+
1. The directory of each module you pass, the last one first.
|
|
79
|
+
2. The current directory.
|
|
80
|
+
3. The standard library of tlapm, which has the `TLAPS` module. tla-ts searches it only if `tlapm` is on your `PATH`.
|
|
81
|
+
4. The `-I` directories, the last one first.
|
|
82
|
+
|
|
83
|
+
### Prove with tlapm
|
|
84
|
+
|
|
85
|
+
tla-ts doesn't include a prover. Without `-N` or `--summary`, `tla-ts prove` runs [tlapm](https://github.com/tlaplus/tlapm) from your `PATH`:
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
npx tla-ts prove Module.tla
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
tla-ts expands the globs and passes every argument to tlapm, so all of tlapm's options work. tlapm sends the obligations to its provers, and tla-ts exits with the exit code of tlapm. If `tlapm` isn't on your `PATH`, tla-ts prints an error and exits with code 1.
|
|
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,39 @@ const result = check({
|
|
|
65
107
|
});
|
|
66
108
|
```
|
|
67
109
|
|
|
68
|
-
|
|
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 |
|
|
69
121
|
|
|
70
|
-
|
|
71
|
-
- `config`: a TLC configuration, as source text or as the result of `parseConfig`
|
|
72
|
-
- `loadModule`: maps a module name to its source, for modules other than the standard modules
|
|
73
|
-
- `onPrint`: receives the output of `Print` and `PrintT`, which defaults to `console.log`
|
|
74
|
-
- `readFile` and `writeFile`: let the Json module read and write files. Without them, it has no file access
|
|
122
|
+
The result has these fields:
|
|
75
123
|
|
|
76
|
-
|
|
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.
|
|
77
128
|
|
|
78
|
-
`check`
|
|
79
|
-
|
|
80
|
-
- **Standard modules**: Naturals, Integers, Sequences, FiniteSets, TLC, Bags, Reals, RealTime, Toolbox, and the community modules TLCExt, Json, and Randomization
|
|
81
|
-
- **Modules**: `EXTENDS`, nested modules, and `INSTANCE` with `WITH` substitutions, `LAMBDA` substitutions for operator parameters, named instances, parameterized instances, and instances inside `LET`
|
|
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
|
|
86
|
-
|
|
87
|
-
### `checkInParallel`
|
|
129
|
+
Workers run in Node, Bun, Deno, and cross-origin isolated pages in the browser. Like TLC's workers, they share one table of 64-bit fingerprints. `check` runs on the calling thread in these cases:
|
|
88
130
|
|
|
89
|
-
|
|
131
|
+
- `SharedArrayBuffer` is unavailable, as on a page without cross-origin isolation.
|
|
132
|
+
- The spec has liveness properties.
|
|
133
|
+
- The spec uses impure operators such as `Print`.
|
|
90
134
|
|
|
91
|
-
|
|
92
|
-
import { checkInParallel } from "tla-ts";
|
|
135
|
+
After a violation, `check` reruns on the calling thread to return the exact trace.
|
|
93
136
|
|
|
94
|
-
|
|
95
|
-
```
|
|
137
|
+
`check` supports:
|
|
96
138
|
|
|
97
|
-
|
|
139
|
+
- **Modules**: the standard modules, TLCExt, Json, and Randomization, plus `EXTENDS`, `INSTANCE`, and `LAMBDA`.
|
|
140
|
+
- **Configuration**: `CONSTANTS`, `INIT`, `NEXT`, `SPECIFICATION`, invariants, properties, constraints, `SYMMETRY`, `VIEW`, `ALIAS`, `POSTCONDITION`, `CHECK_DEADLOCK`, and `_POSSIBLE`.
|
|
141
|
+
- **Properties**: invariants and every temporal formula TLC accepts, checked through TLC's tableau construction.
|
|
142
|
+
- **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
143
|
|
|
99
144
|
### `parseModule`
|
|
100
145
|
|
|
@@ -116,7 +161,7 @@ import { check, parseConfig } from "tla-ts";
|
|
|
116
161
|
|
|
117
162
|
const config = parseConfig(configSource);
|
|
118
163
|
config.checkDeadlock = false;
|
|
119
|
-
check({ source: specSource, config });
|
|
164
|
+
await check({ source: specSource, config });
|
|
120
165
|
```
|
|
121
166
|
|
|
122
167
|
### `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.M,exports.TlaError=e.N,exports.TlaEvaluationError=e.P,exports.TlaSyntaxError=e.I,exports.TlaUnsupportedError=e.L,exports.check=t.t,exports.formatValue=e.E,exports.parseConfig=e.A,exports.parseModule=e.b;
|
package/dist/index.d.cts
CHANGED
|
@@ -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,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,76 @@ 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;
|
|
421
602
|
}
|
|
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,
|
|
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;
|
|
424
605
|
interface CheckOptions {
|
|
425
606
|
source: string;
|
|
426
607
|
config: string | ModelConfig;
|
|
427
608
|
loadModule?: (name: string) => string | undefined;
|
|
609
|
+
loadClass?: (name: string) => Uint8Array | undefined;
|
|
428
610
|
onPrint?: (text: string) => void;
|
|
611
|
+
onPause?: () => void;
|
|
429
612
|
readFile?: (path: string) => string | undefined;
|
|
430
613
|
writeFile?: (path: string, content: string) => void;
|
|
614
|
+
seed?: bigint;
|
|
615
|
+
workers?: number;
|
|
616
|
+
livenessCheck?: "default" | "final";
|
|
431
617
|
}
|
|
432
|
-
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock";
|
|
618
|
+
type CheckStatus = "success" | "assumption-violation" | "invariant-violation" | "property-violation" | "liveness-violation" | "postcondition-violation" | "deadlock" | "error";
|
|
433
619
|
interface TraceStep {
|
|
434
620
|
action: string | undefined;
|
|
621
|
+
label: string | undefined;
|
|
435
622
|
state: Record<string, Value>;
|
|
436
623
|
}
|
|
437
624
|
interface Violation {
|
|
438
625
|
name: string;
|
|
439
626
|
trace: TraceStep[];
|
|
440
627
|
loopStart: number | undefined;
|
|
628
|
+
loopLabel?: string;
|
|
441
629
|
message?: string;
|
|
630
|
+
counts?: string;
|
|
631
|
+
unwitnessed?: Postcondition;
|
|
632
|
+
}
|
|
633
|
+
interface Postcondition {
|
|
634
|
+
name: string;
|
|
635
|
+
message: string;
|
|
636
|
+
counts?: string;
|
|
637
|
+
}
|
|
638
|
+
interface EvaluationFailure {
|
|
639
|
+
message: string;
|
|
640
|
+
trace: TraceStep[];
|
|
641
|
+
initialState: Record<string, Value> | undefined;
|
|
642
|
+
exitCode: number;
|
|
442
643
|
}
|
|
443
644
|
interface CheckResult {
|
|
444
645
|
status: CheckStatus;
|
|
445
646
|
violation: Violation | undefined;
|
|
647
|
+
failure: EvaluationFailure | undefined;
|
|
446
648
|
generatedStates: number;
|
|
447
649
|
distinctStates: number;
|
|
650
|
+
queuedStates: number;
|
|
448
651
|
depth: number;
|
|
652
|
+
outDegrees: number[] | undefined;
|
|
653
|
+
fingerprintDistance: bigint | undefined;
|
|
449
654
|
}
|
|
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>;
|
|
655
|
+
export declare const check: (options: CheckOptions) => Promise<CheckResult>;
|
|
470
656
|
export declare const parseModule: (source: string) => Module;
|
|
471
|
-
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, ModelConfig, Module,
|
|
657
|
+
export type { CheckOptions, CheckResult, CheckStatus, ConfigValue, ConstantAssignment, EvaluationFailure, ModelConfig, Module, Substitution, TraceStep, Value, Violation };
|