tla-checker 0.3.2
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 +262 -0
- package/package.json +28 -0
- package/tla_checker.d.ts +46 -0
- package/tla_checker.js +305 -0
- package/tla_checker_bg.wasm +0 -0
- package/tla_checker_bg.wasm.d.ts +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# tla-rs
|
|
2
|
+
|
|
3
|
+
A TLA+ model checker and interactive exploration tool written in Rust.
|
|
4
|
+
|
|
5
|
+
tla-rs verifies TLA+ specifications by exploring all reachable states, checking invariants, and reporting counterexamples. Beyond pass/fail checking, it provides an interactive TUI for stepping through state spaces, scenario-driven exploration, property satisfaction analytics with depth breakdowns, and parameter sweeps for sensitivity analysis. The core library compiles to WebAssembly, so it can be embedded in browser applications. It's designed as a lightweight alternative to the official TLC model checker for specs that fit its supported subset.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cargo build --release
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The binary will be at `target/release/tla`.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
tla spec.tla
|
|
19
|
+
tla spec.tla -c 'N=5' -c 'Procs={"p1","p2","p3"}'
|
|
20
|
+
tla spec.tla -c 'Proc={"a","b","c"}' --symmetry Proc
|
|
21
|
+
tla spec.tla --config model.cfg
|
|
22
|
+
tla spec.tla --quick # limit to 10,000 states
|
|
23
|
+
tla spec.tla -i # interactive TUI
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Constants accept integers (`42`), booleans (`TRUE`), strings (`"hello"`), and sets (`{1,2,3}`).
|
|
27
|
+
|
|
28
|
+
## Options
|
|
29
|
+
|
|
30
|
+
| Option | Description |
|
|
31
|
+
|--------|-------------|
|
|
32
|
+
| `-c NAME=VALUE` | Set a constant value |
|
|
33
|
+
| `-s CONST` | Enable symmetry reduction for a constant |
|
|
34
|
+
| `--config PATH` | Load TLC-style cfg file (auto-discovers `Spec.cfg` next to `Spec.tla`) |
|
|
35
|
+
| `--max-states N` | Maximum states to explore (default: 1000000) |
|
|
36
|
+
| `--max-depth N` | Maximum trace depth (default: 100) |
|
|
37
|
+
| `-q` | Quick exploration (limit: 10,000 states) |
|
|
38
|
+
| `--export-dot FILE` | Export state graph to DOT format |
|
|
39
|
+
| `--dot-mode MODE` | DOT mode: `full`, `trace`, `clean` (default), `choices` |
|
|
40
|
+
| `--allow-deadlock` | Allow states with no successors |
|
|
41
|
+
| `--check-liveness` | Check liveness and fairness properties |
|
|
42
|
+
| `--continue` | Continue past invariant violations |
|
|
43
|
+
| `--count-satisfying NAME` | Count states satisfying a definition (repeatable) |
|
|
44
|
+
| `--sweep NAME=V1;V2;...` | Sweep a constant across values, compare results |
|
|
45
|
+
| `--scenario TEXT` | Explore a specific scenario (or `@file`) |
|
|
46
|
+
| `-i` | Interactive TUI exploration mode |
|
|
47
|
+
| `--json` | JSON output |
|
|
48
|
+
| `-v` | Verbose output (depth breakdowns, etc.) |
|
|
49
|
+
|
|
50
|
+
## Configuration Files
|
|
51
|
+
|
|
52
|
+
tla-rs supports TLC-compatible `.cfg` files. If `Spec.cfg` exists next to `Spec.tla`, it is loaded automatically. Use `--config PATH` to specify an explicit path.
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
CONSTANT RM = {rm1, rm2, rm3}
|
|
56
|
+
INIT TPInit
|
|
57
|
+
NEXT TPNext
|
|
58
|
+
INVARIANT TPTypeOK
|
|
59
|
+
CHECK_DEADLOCK TRUE
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Supported directives: `INIT`/`NEXT`, `SPECIFICATION` (temporal formula in `Init /\ [][Next]_vars` form), `CONSTANT`/`CONSTANTS`, `INVARIANT`/`INVARIANTS`, `PROPERTY`/`PROPERTIES`, `SYMMETRY`, and `CHECK_DEADLOCK`. CLI flags override cfg values.
|
|
63
|
+
|
|
64
|
+
## Scenarios
|
|
65
|
+
|
|
66
|
+
Drive the checker along specific execution paths using TLA+ expressions:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
tla spec.tla --scenario "step: count' = count + 1
|
|
70
|
+
step: count' = count + 1
|
|
71
|
+
step: count' = count + 1"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or load from a file with `--scenario @scenario.txt`. Each `step:` line is a TLA+ predicate over current (unprimed) and next (primed) state variables.
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
step: x' > x # x increases
|
|
78
|
+
step: "s1" \in active' # s1 becomes active
|
|
79
|
+
step: pc'["p1"] = "critical" # p1 enters critical section
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Analytics
|
|
83
|
+
|
|
84
|
+
These flags are for understanding *how* a protocol fails, not just *whether* it fails.
|
|
85
|
+
|
|
86
|
+
Without `--continue`, the checker stops at the first violation. With it, all violations are collected and counted per-invariant across the full state space:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
tla spec.tla --allow-deadlock --continue
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`--count-satisfying` measures what fraction of reachable states satisfy a predicate. Add `--verbose` to get per-depth breakdowns showing at which exploration depth violations start appearing:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
tla spec.tla --allow-deadlock --continue \
|
|
96
|
+
--count-satisfying InvSafety --verbose
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`--sweep` varies a constant across multiple values and produces a comparison table, useful for sensitivity analysis:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
tla spec.tla --sweep 'N=2;3;4;5' --count-satisfying Inv --allow-deadlock
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`--json` returns structured data including `properties` array with `depth_breakdown` per property.
|
|
106
|
+
|
|
107
|
+
### The C-3PO Example
|
|
108
|
+
|
|
109
|
+
C-3PO famously calculates "the possibility of successfully navigating an asteroid field is approximately 3,720 to 1." The spec `examples/c3po_asteroid_field.tla` models the Empire Strikes Back asteroid chase: variable-damage asteroid impacts, TIE fighter attacks, TIEs getting destroyed by asteroids, hiding in the space slug's cave, mynock damage, escaping the exogorth's mouth, and the only real escape — attaching to a Star Destroyer's hull and floating away with the garbage. No hyperspace: the hyperdrive is dead.
|
|
110
|
+
|
|
111
|
+
The `Density` constant controls asteroid damage range (1..Density). Higher values create more damage variants per action, biasing the state space toward destruction.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
tla examples/c3po_asteroid_field.tla -c 'Density=3' \
|
|
115
|
+
--allow-deadlock --continue \
|
|
116
|
+
--count-satisfying InvNeverTellMeTheOdds \
|
|
117
|
+
--count-satisfying Escaped --verbose
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The depth breakdown shows destruction starting early and escape requiring a long sequence of correct decisions — surviving asteroids, hiding in the cave, taking mynock damage, escaping the slug, then waiting for all TIE fighters to be destroyed before drifting onto a Star Destroyer's hull.
|
|
121
|
+
|
|
122
|
+
## Interactive Mode
|
|
123
|
+
|
|
124
|
+
Launch the TUI with `-i` to step through state spaces manually. You can select and take transitions, backtrack, evaluate expressions in a REPL, trace variable changes across history, test hypotheses against all visited states, and toggle guard condition display. Actions with many variable changes expand inline so you can see exactly what each transition does.
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
Key bindings: `↑`/`↓` select actions, `Enter` takes the selected action, `→`/`Space` expands grouped changes, `←` collapses, `b` backtracks, `e` opens the REPL, `t` shows variable trace, `h` tests a hypothesis, `g` toggles guards, `w` random walks N steps, `u` steps until a condition holds, `s`/`l` save/load traces, `r` resets to initial state, `q` quits.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
tla examples/c3po_asteroid_field.tla -c 'Density=3' --allow-deadlock -i
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Supported TLA+ Subset
|
|
135
|
+
|
|
136
|
+
tla-rs implements the Naturals, Integers, Sequences, FiniteSets, TLC, Bags, and Bits standard modules. See `SYNTAX_STATUS.md` for the full operator-by-operator coverage table.
|
|
137
|
+
|
|
138
|
+
The supported operator categories: logic (`/\`, `\/`, `~`, `=>`), comparison, arithmetic, sets (`\in`, `\union`, `\intersect`, `SUBSET`, `UNION`), functions (`[x \in S |-> e]`, `DOMAIN`, `EXCEPT`, `@@`), quantifiers (`\E`, `\A`, `CHOOSE`), records, tuples/sequences, `IF-THEN-ELSE`, `CASE`, `LET-IN`, primed variables, `UNCHANGED`, transitive closure, module instances (`INSTANCE` with qualified calls), and Unicode equivalents for all operators.
|
|
139
|
+
|
|
140
|
+
### Module Instances
|
|
141
|
+
|
|
142
|
+
Specs can use `INSTANCE` to import and compose modules:
|
|
143
|
+
|
|
144
|
+
```tla
|
|
145
|
+
---- MODULE pingpong ----
|
|
146
|
+
LOCAL INSTANCE Naturals
|
|
147
|
+
|
|
148
|
+
VARIABLES server_to_client, client_to_server
|
|
149
|
+
|
|
150
|
+
Data == [message: {"ping"}] \cup [message: {"pong"}]
|
|
151
|
+
|
|
152
|
+
ServerToClientChannel(Id) == INSTANCE MChannel WITH channels <- server_to_client
|
|
153
|
+
ClientToServerChannel(Id) == INSTANCE MChannel WITH channels <- client_to_server
|
|
154
|
+
|
|
155
|
+
Next ==
|
|
156
|
+
\/ \E id \in ClientIds: ServerToClientChannel(id)!Send([message |-> "ping"])
|
|
157
|
+
\/ \E id \in ClientIds: ClientToServerChannel(id)!Recv([message |-> "pong"])
|
|
158
|
+
====
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Both static (`Alias == INSTANCE M WITH ...`) and parameterized (`Alias(p) == INSTANCE M WITH ...`) instances are supported. Library modules without Init/Next work as expected. The module file must be in the same directory as the spec.
|
|
162
|
+
|
|
163
|
+
### Spec Structure
|
|
164
|
+
|
|
165
|
+
```tla
|
|
166
|
+
---- MODULE Example ----
|
|
167
|
+
EXTENDS Naturals
|
|
168
|
+
|
|
169
|
+
CONSTANT N
|
|
170
|
+
VARIABLES x, y
|
|
171
|
+
|
|
172
|
+
Init == x = 0 /\ y = 0
|
|
173
|
+
|
|
174
|
+
Next ==
|
|
175
|
+
\/ (x < N /\ x' = x + 1 /\ y' = y)
|
|
176
|
+
\/ (y < N /\ x' = x /\ y' = y + 1)
|
|
177
|
+
|
|
178
|
+
TypeOK == x \in 0..N /\ y \in 0..N
|
|
179
|
+
Inv == x + y <= 2 * N
|
|
180
|
+
====
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Invariants are detected by naming convention: definitions starting with `Inv`, `TypeOK`, or `NotSolved` are automatically checked.
|
|
184
|
+
|
|
185
|
+
## Output
|
|
186
|
+
|
|
187
|
+
On success:
|
|
188
|
+
```
|
|
189
|
+
Model checking complete. No errors found.
|
|
190
|
+
|
|
191
|
+
States explored: 1331
|
|
192
|
+
Transitions: 3630
|
|
193
|
+
Max depth: 31
|
|
194
|
+
Time: 0.019s
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
On invariant violation, you get a counterexample trace with state diffs marking changed variables. On deadlock, a trace to the deadlock state with a suggestion to use `--allow-deadlock`. Parse errors show source locations, and undefined variables suggest similar names.
|
|
198
|
+
|
|
199
|
+
## State Graph Visualization
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
tla spec.tla --export-dot graph.dot
|
|
203
|
+
tla spec.tla --export-dot graph.dot --dot-mode full
|
|
204
|
+
dot -Tpng graph.dot -o graph.png
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Four export modes are available via `--dot-mode`:
|
|
208
|
+
|
|
209
|
+
| Mode | Description |
|
|
210
|
+
|------|-------------|
|
|
211
|
+
| `clean` (default) | All nodes, no self-loops, parallel edges merged into single labeled edges |
|
|
212
|
+
| `full` | All nodes and all edges including self-loops, each edge separate |
|
|
213
|
+
| `trace` | Only counterexample trace nodes and edges (falls back to full if no trace) |
|
|
214
|
+
| `choices` | Trace path plus alternative transitions at each trace state; non-trace nodes shown dashed, alternative edges gray/dashed (falls back to full if no trace) |
|
|
215
|
+
|
|
216
|
+
Error states are highlighted in red. Trace edges are red and thick in all modes.
|
|
217
|
+
|
|
218
|
+
## WebAssembly
|
|
219
|
+
|
|
220
|
+
The core library compiles to WASM for browser embedding:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
cargo make wasm
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
This produces a `pkg/` directory with the WASM module and JS bindings. The WASM API provides `check_spec`, `check_spec_with_config`, `check_spec_with_cfg`, and `check_spec_with_options` — all returning JSON results with success status, state count, error traces, and optional DOT graph output.
|
|
227
|
+
|
|
228
|
+
The `check_spec_with_options` API accepts a JSON options object:
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
const result = JSON.parse(check_spec_with_options(specSource, JSON.stringify({
|
|
232
|
+
constants: { N: 3 },
|
|
233
|
+
max_states: 10000,
|
|
234
|
+
max_depth: 50,
|
|
235
|
+
allow_deadlock: true,
|
|
236
|
+
export_dot: true,
|
|
237
|
+
dot_mode: "choices", // "full", "trace", "clean" (default), "choices"
|
|
238
|
+
cfg_source: "INIT Init\nNEXT Next\n"
|
|
239
|
+
})));
|
|
240
|
+
|
|
241
|
+
if (result.dot) {
|
|
242
|
+
// DOT graph string: "digraph StateGraph { ... }"
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
| Option | Type | Description |
|
|
247
|
+
|--------|------|-------------|
|
|
248
|
+
| `constants` | object | Constant values (`{"N": 3, "Procs": ["a","b"]}`) |
|
|
249
|
+
| `cfg_source` | string | TLC-style cfg file contents |
|
|
250
|
+
| `max_states` | number | Maximum states to explore |
|
|
251
|
+
| `max_depth` | number | Maximum trace depth |
|
|
252
|
+
| `allow_deadlock` | bool | Allow states with no successors |
|
|
253
|
+
| `export_dot` | bool | Include DOT graph in result |
|
|
254
|
+
| `dot_mode` | string | DOT export mode: `full`, `trace`, `clean` (default), `choices` |
|
|
255
|
+
|
|
256
|
+
## Limitations
|
|
257
|
+
|
|
258
|
+
`Nat` and `Int` are bounded (-100 to 100 by default). Temporal operators `[]`, `<>`, `~>` are parsed but cannot be evaluated directly — use `--check-liveness` for fairness/liveness properties via SCC analysis. Unbounded quantifiers (`\E x : P` without `\in S`) and `Seq(S)` enumeration are not supported. Recursive operators must be declared with `RECURSIVE`.
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tla-checker",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A TLA+ model checker compiled to WebAssembly",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/fabracht/tla-rs.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "tla_checker.js",
|
|
12
|
+
"types": "tla_checker.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"tla_checker_bg.wasm",
|
|
15
|
+
"tla_checker.js",
|
|
16
|
+
"tla_checker.d.ts",
|
|
17
|
+
"tla_checker_bg.wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"tla",
|
|
21
|
+
"model-checking",
|
|
22
|
+
"formal-verification",
|
|
23
|
+
"wasm"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": [
|
|
26
|
+
"./snippets/*"
|
|
27
|
+
]
|
|
28
|
+
}
|
package/tla_checker.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function check_spec(spec_source: string, constants_json: string): string;
|
|
5
|
+
|
|
6
|
+
export function check_spec_with_cfg(spec_source: string, cfg_source: string, constants_json: string, max_states: number, max_depth: number, allow_deadlock: boolean, export_dot: boolean): string;
|
|
7
|
+
|
|
8
|
+
export function check_spec_with_config(spec_source: string, constants_json: string, max_states: number, max_depth: number, allow_deadlock: boolean, export_dot: boolean): string;
|
|
9
|
+
|
|
10
|
+
export function check_spec_with_options(spec_source: string, options_json: string): string;
|
|
11
|
+
|
|
12
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
13
|
+
|
|
14
|
+
export interface InitOutput {
|
|
15
|
+
readonly memory: WebAssembly.Memory;
|
|
16
|
+
readonly check_spec: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
17
|
+
readonly check_spec_with_cfg: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
18
|
+
readonly check_spec_with_config: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
19
|
+
readonly check_spec_with_options: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
20
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
21
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
22
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
23
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
30
|
+
* a precompiled `WebAssembly.Module`.
|
|
31
|
+
*
|
|
32
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
33
|
+
*
|
|
34
|
+
* @returns {InitOutput}
|
|
35
|
+
*/
|
|
36
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
40
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<InitOutput>}
|
|
45
|
+
*/
|
|
46
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/tla_checker.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/* @ts-self-types="./tla_checker.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} spec_source
|
|
5
|
+
* @param {string} constants_json
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function check_spec(spec_source, constants_json) {
|
|
9
|
+
let deferred3_0;
|
|
10
|
+
let deferred3_1;
|
|
11
|
+
try {
|
|
12
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13
|
+
const ptr0 = passStringToWasm0(spec_source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
14
|
+
const len0 = WASM_VECTOR_LEN;
|
|
15
|
+
const ptr1 = passStringToWasm0(constants_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
16
|
+
const len1 = WASM_VECTOR_LEN;
|
|
17
|
+
wasm.check_spec(retptr, ptr0, len0, ptr1, len1);
|
|
18
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
19
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
20
|
+
deferred3_0 = r0;
|
|
21
|
+
deferred3_1 = r1;
|
|
22
|
+
return getStringFromWasm0(r0, r1);
|
|
23
|
+
} finally {
|
|
24
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
25
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} spec_source
|
|
31
|
+
* @param {string} cfg_source
|
|
32
|
+
* @param {string} constants_json
|
|
33
|
+
* @param {number} max_states
|
|
34
|
+
* @param {number} max_depth
|
|
35
|
+
* @param {boolean} allow_deadlock
|
|
36
|
+
* @param {boolean} export_dot
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
export function check_spec_with_cfg(spec_source, cfg_source, constants_json, max_states, max_depth, allow_deadlock, export_dot) {
|
|
40
|
+
let deferred4_0;
|
|
41
|
+
let deferred4_1;
|
|
42
|
+
try {
|
|
43
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
+
const ptr0 = passStringToWasm0(spec_source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
45
|
+
const len0 = WASM_VECTOR_LEN;
|
|
46
|
+
const ptr1 = passStringToWasm0(cfg_source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
47
|
+
const len1 = WASM_VECTOR_LEN;
|
|
48
|
+
const ptr2 = passStringToWasm0(constants_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
49
|
+
const len2 = WASM_VECTOR_LEN;
|
|
50
|
+
wasm.check_spec_with_cfg(retptr, ptr0, len0, ptr1, len1, ptr2, len2, max_states, max_depth, allow_deadlock, export_dot);
|
|
51
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
52
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
53
|
+
deferred4_0 = r0;
|
|
54
|
+
deferred4_1 = r1;
|
|
55
|
+
return getStringFromWasm0(r0, r1);
|
|
56
|
+
} finally {
|
|
57
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
58
|
+
wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} spec_source
|
|
64
|
+
* @param {string} constants_json
|
|
65
|
+
* @param {number} max_states
|
|
66
|
+
* @param {number} max_depth
|
|
67
|
+
* @param {boolean} allow_deadlock
|
|
68
|
+
* @param {boolean} export_dot
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
export function check_spec_with_config(spec_source, constants_json, max_states, max_depth, allow_deadlock, export_dot) {
|
|
72
|
+
let deferred3_0;
|
|
73
|
+
let deferred3_1;
|
|
74
|
+
try {
|
|
75
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
76
|
+
const ptr0 = passStringToWasm0(spec_source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
77
|
+
const len0 = WASM_VECTOR_LEN;
|
|
78
|
+
const ptr1 = passStringToWasm0(constants_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
79
|
+
const len1 = WASM_VECTOR_LEN;
|
|
80
|
+
wasm.check_spec_with_config(retptr, ptr0, len0, ptr1, len1, max_states, max_depth, allow_deadlock, export_dot);
|
|
81
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
82
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
83
|
+
deferred3_0 = r0;
|
|
84
|
+
deferred3_1 = r1;
|
|
85
|
+
return getStringFromWasm0(r0, r1);
|
|
86
|
+
} finally {
|
|
87
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
88
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} spec_source
|
|
94
|
+
* @param {string} options_json
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
export function check_spec_with_options(spec_source, options_json) {
|
|
98
|
+
let deferred3_0;
|
|
99
|
+
let deferred3_1;
|
|
100
|
+
try {
|
|
101
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
102
|
+
const ptr0 = passStringToWasm0(spec_source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
106
|
+
wasm.check_spec_with_options(retptr, ptr0, len0, ptr1, len1);
|
|
107
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
108
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
109
|
+
deferred3_0 = r0;
|
|
110
|
+
deferred3_1 = r1;
|
|
111
|
+
return getStringFromWasm0(r0, r1);
|
|
112
|
+
} finally {
|
|
113
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
114
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function __wbg_get_imports() {
|
|
119
|
+
const import0 = {
|
|
120
|
+
__proto__: null,
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
__proto__: null,
|
|
124
|
+
"./tla_checker_bg.js": import0,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let cachedDataViewMemory0 = null;
|
|
129
|
+
function getDataViewMemory0() {
|
|
130
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
131
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
132
|
+
}
|
|
133
|
+
return cachedDataViewMemory0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function getStringFromWasm0(ptr, len) {
|
|
137
|
+
ptr = ptr >>> 0;
|
|
138
|
+
return decodeText(ptr, len);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let cachedUint8ArrayMemory0 = null;
|
|
142
|
+
function getUint8ArrayMemory0() {
|
|
143
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
144
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
145
|
+
}
|
|
146
|
+
return cachedUint8ArrayMemory0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
150
|
+
if (realloc === undefined) {
|
|
151
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
152
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
153
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
154
|
+
WASM_VECTOR_LEN = buf.length;
|
|
155
|
+
return ptr;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let len = arg.length;
|
|
159
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
160
|
+
|
|
161
|
+
const mem = getUint8ArrayMemory0();
|
|
162
|
+
|
|
163
|
+
let offset = 0;
|
|
164
|
+
|
|
165
|
+
for (; offset < len; offset++) {
|
|
166
|
+
const code = arg.charCodeAt(offset);
|
|
167
|
+
if (code > 0x7F) break;
|
|
168
|
+
mem[ptr + offset] = code;
|
|
169
|
+
}
|
|
170
|
+
if (offset !== len) {
|
|
171
|
+
if (offset !== 0) {
|
|
172
|
+
arg = arg.slice(offset);
|
|
173
|
+
}
|
|
174
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
175
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
176
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
177
|
+
|
|
178
|
+
offset += ret.written;
|
|
179
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
WASM_VECTOR_LEN = offset;
|
|
183
|
+
return ptr;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
187
|
+
cachedTextDecoder.decode();
|
|
188
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
189
|
+
let numBytesDecoded = 0;
|
|
190
|
+
function decodeText(ptr, len) {
|
|
191
|
+
numBytesDecoded += len;
|
|
192
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
193
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
194
|
+
cachedTextDecoder.decode();
|
|
195
|
+
numBytesDecoded = len;
|
|
196
|
+
}
|
|
197
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const cachedTextEncoder = new TextEncoder();
|
|
201
|
+
|
|
202
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
203
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
204
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
205
|
+
view.set(buf);
|
|
206
|
+
return {
|
|
207
|
+
read: arg.length,
|
|
208
|
+
written: buf.length
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let WASM_VECTOR_LEN = 0;
|
|
214
|
+
|
|
215
|
+
let wasmModule, wasm;
|
|
216
|
+
function __wbg_finalize_init(instance, module) {
|
|
217
|
+
wasm = instance.exports;
|
|
218
|
+
wasmModule = module;
|
|
219
|
+
cachedDataViewMemory0 = null;
|
|
220
|
+
cachedUint8ArrayMemory0 = null;
|
|
221
|
+
return wasm;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function __wbg_load(module, imports) {
|
|
225
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
226
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
227
|
+
try {
|
|
228
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
229
|
+
} catch (e) {
|
|
230
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
231
|
+
|
|
232
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
233
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
234
|
+
|
|
235
|
+
} else { throw e; }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const bytes = await module.arrayBuffer();
|
|
240
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
241
|
+
} else {
|
|
242
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
243
|
+
|
|
244
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
245
|
+
return { instance, module };
|
|
246
|
+
} else {
|
|
247
|
+
return instance;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function expectedResponseType(type) {
|
|
252
|
+
switch (type) {
|
|
253
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function initSync(module) {
|
|
260
|
+
if (wasm !== undefined) return wasm;
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
if (module !== undefined) {
|
|
264
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
265
|
+
({module} = module)
|
|
266
|
+
} else {
|
|
267
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const imports = __wbg_get_imports();
|
|
272
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
273
|
+
module = new WebAssembly.Module(module);
|
|
274
|
+
}
|
|
275
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
276
|
+
return __wbg_finalize_init(instance, module);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function __wbg_init(module_or_path) {
|
|
280
|
+
if (wasm !== undefined) return wasm;
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
if (module_or_path !== undefined) {
|
|
284
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
285
|
+
({module_or_path} = module_or_path)
|
|
286
|
+
} else {
|
|
287
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (module_or_path === undefined) {
|
|
292
|
+
module_or_path = new URL('tla_checker_bg.wasm', import.meta.url);
|
|
293
|
+
}
|
|
294
|
+
const imports = __wbg_get_imports();
|
|
295
|
+
|
|
296
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
297
|
+
module_or_path = fetch(module_or_path);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
301
|
+
|
|
302
|
+
return __wbg_finalize_init(instance, module);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const check_spec: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
5
|
+
export const check_spec_with_cfg: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
6
|
+
export const check_spec_with_config: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
7
|
+
export const check_spec_with_options: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
9
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
10
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
11
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|