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/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,77 @@ 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
|
+
- `-dump [dot[,colorize][,actionlabels][,snapshot]] <file>`: write every reachable state to `<file>.dump`, or with `dot`, the state graph to `<file>.dot`. The output matches TLC run with `-fp 0`. tla-ts doesn't support the `constrained`, `stuttering`, or `strict` formats.
|
|
54
|
+
- `-lncheck final`: check liveness once, after the search ends.
|
|
55
|
+
- `-seed <num>`: seed `RandomElement` and the `Randomization` module. The default is 0.
|
|
56
|
+
- `-workers <count|auto>`: search with this number of worker threads. `auto` uses one thread per core. The default is 1.
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
### Generate proof obligations
|
|
61
|
+
|
|
62
|
+
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:
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
npx tla-ts prove -N --toolbox 0 0 --printallobs Module.tla
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
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:
|
|
69
|
+
|
|
70
|
+
- `--toolbox <start> <end>`: print Toolbox messages for the proofs from line `start` to line `end`. `0 0` selects the whole module.
|
|
71
|
+
- `--line <num>`: print Toolbox messages for the proof at this line.
|
|
72
|
+
- `--printallobs`: print the text of each obligation.
|
|
73
|
+
- `--summary`: print the number of obligations in each module, and list its missing and omitted proofs. You don't need `-N` with `--summary`.
|
|
74
|
+
- `--strict`: report missing proofs, omitted proofs and a selected range with no obligations as errors.
|
|
75
|
+
- `-I <directory>`: search this directory for modules.
|
|
42
76
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
77
|
+
tla-ts searches for modules in the same order as tlapm:
|
|
78
|
+
|
|
79
|
+
1. The directory of each module you pass, the last one first.
|
|
80
|
+
2. The current directory.
|
|
81
|
+
3. The standard library of tlapm, which has the `TLAPS` module. tla-ts searches it only if `tlapm` is on your `PATH`.
|
|
82
|
+
4. The `-I` directories, the last one first.
|
|
83
|
+
|
|
84
|
+
### Prove with tlapm
|
|
85
|
+
|
|
86
|
+
tla-ts doesn't include a prover. Without `-N` or `--summary`, `tla-ts prove` runs [tlapm](https://github.com/tlaplus/tlapm) from your `PATH`:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
npx tla-ts prove Module.tla
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
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
93
|
|
|
51
94
|
## API reference
|
|
52
95
|
|
|
53
96
|
### `check`
|
|
54
97
|
|
|
55
|
-
Checks a spec against a TLC configuration and
|
|
98
|
+
Checks a spec against a TLC configuration and resolves to the result.
|
|
56
99
|
|
|
57
100
|
```ts
|
|
58
101
|
import { check } from "tla-ts";
|
|
59
102
|
|
|
60
|
-
const result = check({
|
|
103
|
+
const result = await check({
|
|
61
104
|
source: specSource,
|
|
62
105
|
config: configSource,
|
|
63
106
|
loadModule: (name) => modules[name],
|
|
@@ -65,36 +108,43 @@ const result = check({
|
|
|
65
108
|
});
|
|
66
109
|
```
|
|
67
110
|
|
|
68
|
-
|
|
111
|
+
| Option | Description |
|
|
112
|
+
| ----------------------- | ---------------------------------------------------------------------------------------- |
|
|
113
|
+
| `source` | The TLA+ module to check |
|
|
114
|
+
| `config` | A TLC configuration, as text or as the result of `parseConfig` |
|
|
115
|
+
| `loadModule` | Returns the source of a module that isn't a standard module |
|
|
116
|
+
| `loadClass` | Returns a compiled Java class that overrides a module's operators with constants |
|
|
117
|
+
| `onPrint` | Receives the output of `Print` and `PrintT`. Defaults to `console.log` |
|
|
118
|
+
| `onPause` | Runs when `TLCSet("pause", TRUE)` pauses checking, which resumes when it returns |
|
|
119
|
+
| `readFile`, `writeFile` | Read and write files for the Json module and `dump` |
|
|
120
|
+
| `seed` | A `bigint` seed. Defaults to `0n`, and matches TLC run with the same `-seed` and `-fp 0` |
|
|
121
|
+
| `workers` | The number of worker threads. Defaults to 1 |
|
|
122
|
+
| `dump` | Writes the reachable states or the state graph, as TLC's `-dump` does |
|
|
69
123
|
|
|
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
|
|
124
|
+
`dump` takes the `path` that `check` passes to `writeFile` before it returns. Set `dot` to write the state graph in the DOT language of Graphviz, and `colorize`, `actionLabels`, or `snapshot` for TLC's formats of the same names. A dump checks the spec on the calling thread, as one TLC worker does.
|
|
75
125
|
|
|
76
|
-
The result has
|
|
126
|
+
The result has these fields:
|
|
77
127
|
|
|
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
|
|
128
|
+
- `status`: `"success"`, `"deadlock"`, `"assumption-violation"`, `"invariant-violation"`, `"property-violation"`, `"liveness-violation"`, `"postcondition-violation"`, or `"error"`.
|
|
129
|
+
- `violation`: the `name` of what failed and the `trace` that reaches it. `loopStart` marks where a liveness counterexample loops back.
|
|
130
|
+
- `failure`: the message and trace when `status` is `"error"`.
|
|
131
|
+
- `generatedStates`, `distinctStates`, and `depth`: TLC's state counts.
|
|
86
132
|
|
|
87
|
-
|
|
133
|
+
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
134
|
|
|
89
|
-
|
|
135
|
+
- `SharedArrayBuffer` is unavailable, as on a page without cross-origin isolation.
|
|
136
|
+
- The spec has liveness properties.
|
|
137
|
+
- The spec uses impure operators such as `Print`.
|
|
138
|
+
- The configuration has `VIEW`, `POSTCONDITION`, or `_POSSIBLE`.
|
|
90
139
|
|
|
91
|
-
|
|
92
|
-
import { checkInParallel } from "tla-ts";
|
|
140
|
+
After a violation or an error, `check` reruns on the calling thread to return TLC's exact trace.
|
|
93
141
|
|
|
94
|
-
|
|
95
|
-
```
|
|
142
|
+
`check` supports:
|
|
96
143
|
|
|
97
|
-
|
|
144
|
+
- **Modules**: the standard modules, TLCExt, Json, and Randomization, plus `EXTENDS`, `INSTANCE`, and `LAMBDA`.
|
|
145
|
+
- **Configuration**: `CONSTANTS`, `INIT`, `NEXT`, `SPECIFICATION`, invariants, properties, constraints, `SYMMETRY`, `VIEW`, `ALIAS`, `POSTCONDITION`, `CHECK_DEADLOCK`, and `_POSSIBLE`.
|
|
146
|
+
- **Properties**: invariants and every temporal formula TLC accepts, checked through TLC's tableau construction.
|
|
147
|
+
- **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
148
|
|
|
99
149
|
### `parseModule`
|
|
100
150
|
|
|
@@ -116,7 +166,7 @@ import { check, parseConfig } from "tla-ts";
|
|
|
116
166
|
|
|
117
167
|
const config = parseConfig(configSource);
|
|
118
168
|
config.checkDeadlock = false;
|
|
119
|
-
check({ source: specSource, config });
|
|
169
|
+
await check({ source: specSource, config });
|
|
120
170
|
```
|
|
121
171
|
|
|
122
172
|
### `formatValue`
|
|
@@ -151,6 +201,15 @@ Wall time on one worker, including JVM and Node startup. Both checkers report th
|
|
|
151
201
|
| [Bounded queue](packages/tla-ts/benchmarks/queue) | 44,044 | 0.37 s | 0.17 s | 2.2× |
|
|
152
202
|
| 542 conformance models | | 986.6 s | 403.3 s | 2.4× |
|
|
153
203
|
|
|
204
|
+
Wall time on 8 workers, also including startup. Each time is the median of 3 runs on an Apple M4 Pro.
|
|
205
|
+
|
|
206
|
+
| Spec | Distinct states | TLC | tla-ts | Speedup |
|
|
207
|
+
| --------------------------------------------------------------------------------------------------------------------- | --------------: | ------: | -----: | ------: |
|
|
208
|
+
| [Raft with reconfiguration](https://github.com/will62794/tla-web/blob/8193eb0/specs/RaftWithReconfigSingleServer.tla) | 298,493 | 10.50 s | 8.96 s | 1.2× |
|
|
209
|
+
| [Sailfish](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/dag-consensus) | 109,604 | 4.34 s | 4.07 s | 1.1× |
|
|
210
|
+
| [Fast Paxos](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/SimplifiedFastPaxos) | 25,617 | 3.91 s | 2.57 s | 1.5× |
|
|
211
|
+
| [Buffered random access file](https://github.com/tlaplus/Examples/tree/0cab2b3/specifications/braf) | 3,316 | 4.70 s | 3.61 s | 1.3× |
|
|
212
|
+
|
|
154
213
|
## Development
|
|
155
214
|
|
|
156
215
|
```shell
|
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.D,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;
|
|
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 };
|