everystate 0.0.0-stage → 0.1.0
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/CONFORMANCE.md +64 -0
- package/LICENSE +21 -0
- package/README.md +124 -2
- package/dist/bundled.d.ts +1 -0
- package/dist/bundled.js +2 -0
- package/dist/cfg.d.ts +24 -0
- package/dist/cfg.js +252 -0
- package/dist/checker.d.ts +96 -0
- package/dist/checker.js +520 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +4 -0
- package/dist/community.d.ts +17 -0
- package/dist/community.js +1381 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.js +39 -0
- package/dist/eval.d.ts +119 -0
- package/dist/eval.js +1533 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +24 -0
- package/dist/java.d.ts +2 -0
- package/dist/java.js +6 -0
- package/dist/lexer.d.ts +17 -0
- package/dist/lexer.js +255 -0
- package/dist/liveness.d.ts +80 -0
- package/dist/liveness.js +855 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +494 -0
- package/dist/model.d.ts +56 -0
- package/dist/model.js +582 -0
- package/dist/modules.d.ts +91 -0
- package/dist/modules.js +649 -0
- package/dist/node-host.d.ts +2 -0
- package/dist/node-host.js +25 -0
- package/dist/parser.d.ts +30 -0
- package/dist/parser.js +1114 -0
- package/dist/pprint.d.ts +7 -0
- package/dist/pprint.js +647 -0
- package/dist/stdlib.d.ts +14 -0
- package/dist/stdlib.js +588 -0
- package/dist/values.d.ts +150 -0
- package/dist/values.js +822 -0
- package/package.json +51 -4
package/CONFORMANCE.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Conformance
|
|
2
|
+
|
|
3
|
+
Real TLC is the specification. Numbers below are from 2026-11-13, commit `3c73470`, against
|
|
4
|
+
`tla2tools.jar` 1.8.0 (and TLC 2.19 output for the statechart corpus).
|
|
5
|
+
|
|
6
|
+
## tlaplus/Examples manifest
|
|
7
|
+
|
|
8
|
+
`npm run conformance:examples -- /path/to/Examples --max-runtime 5`
|
|
9
|
+
|
|
10
|
+
Models whose upstream runtime is 5 seconds or less, exhaustive mode: **121 of 122** match on result
|
|
11
|
+
kind and on exact generated and distinct state counts.
|
|
12
|
+
|
|
13
|
+
- The one failure, `ewd998/EWD998ChanTrace.cfg`, reads a data file by a path relative to the
|
|
14
|
+
Examples checkout; it passes when the script is run from that directory.
|
|
15
|
+
- State depth is not compared: the upstream numbers were recorded with several workers, which makes
|
|
16
|
+
depth nondeterministic. Single-worker TLC agrees with everystate on the cases checked by hand.
|
|
17
|
+
- The manifest labels action-property violations "liveness failure" (TLC exit code 13); the script
|
|
18
|
+
maps them the same way.
|
|
19
|
+
|
|
20
|
+
Larger models (upstream runtime up to 120 seconds, 15-minute timeout each): **161 of 164** match;
|
|
21
|
+
the other three (`MCCheckpointCoordination`, `DijkstraMutex` Safety-4-processors, `MCInnerSerial`)
|
|
22
|
+
hit the timeout rather than disagreeing. Run before the lazy-set description fix below, which only
|
|
23
|
+
made things faster.
|
|
24
|
+
|
|
25
|
+
## TLC's own `test-model` directory
|
|
26
|
+
|
|
27
|
+
`npm run conformance:tlc -- /path/to/tlaplus/tlatools/org.lamport.tlatools/test-model`
|
|
28
|
+
|
|
29
|
+
Every `X.tla` with an `X.cfg` is run through real TLC and through everystate; outcome class, violated
|
|
30
|
+
invariant name, generated/distinct counts and trace length are compared.
|
|
31
|
+
|
|
32
|
+
**377 of 414 match.** 8 are skipped because TLC itself does not finish in the time limit.
|
|
33
|
+
The 29 mismatches:
|
|
34
|
+
|
|
35
|
+
| Reason | Count | Specs |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| Result depends on a random seed | 4 | `RandomElement`, `RandomSubsetNext`, `SpanTreeRandom`, `RandomElementXandY` |
|
|
38
|
+
| Out of scope: fingerprint-collision tests, Java module override | 4 | `Unicode*Fingerprint` (3), `UserModuleOverride` |
|
|
39
|
+
| Deliberate: TLC rejects `\cdot` unless a flag is set, everystate implements it | 3 | `cdot/*` |
|
|
40
|
+
| Labels and the full subexpression-selector syntax | 4 | `suite/test206`, `test209`, `test219`, `test219a` |
|
|
41
|
+
| Errors only SANY reports (non-Leibniz substitution, level errors, `HIDE`) | 4 | `suite/test212`–`214`, `test217` |
|
|
42
|
+
| Suites of hundreds of assumptions on exact TLC internals and message text | 4 | `EmptySetEqAssume`, `ValueSemanticsAssume`, `NormalizationAssume`, `KSubsetAssume` |
|
|
43
|
+
| TLC keeps mixed-type sets unsorted until needed | 2 | `NormalizationLiveness`, `NormalizationTLCSet` |
|
|
44
|
+
| TLC checks some temporal properties during the search, everystate only at the end | 3 | `InitialLivenessEvaluationError`, `Github710b`, `Github710d` |
|
|
45
|
+
| `ALIAS` trace formatting | 1 | `PrintTraceException` |
|
|
46
|
+
|
|
47
|
+
## pstack `statechart` corpus
|
|
48
|
+
|
|
49
|
+
`npm run conformance:statechart -- /path/to/pstack/skills/statechart/scripts`
|
|
50
|
+
|
|
51
|
+
The unmodified script, with `everystate-java` in place of Java and no `tla2tools.jar`:
|
|
52
|
+
**33 of 33** cases produce a byte-identical `chart.mmd` and `report.md`.
|
|
53
|
+
|
|
54
|
+
## Self-contained tests
|
|
55
|
+
|
|
56
|
+
`npm test` — 34 pass, 0 fail, 4 todo. No Java needed.
|
|
57
|
+
|
|
58
|
+
## Known behavioural differences from TLC
|
|
59
|
+
|
|
60
|
+
- Liveness is checked once, after the state space is complete (TLC's `-lncheck final`).
|
|
61
|
+
- Fingerprints are 64-bit but not TLC's, so node ids in `-dump dot` output differ.
|
|
62
|
+
- Sets are kept sorted from construction; TLC sorts lazily. A set mixing incomparable values fails
|
|
63
|
+
earlier than in TLC.
|
|
64
|
+
- `\cdot` (action composition) works without a flag.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Carey
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# everystate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TLA+ model checker written in pure TypeScript. No Java, no native code, no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
It reads ordinary TLA+ modules and TLC configuration files, explores the state space the way TLC
|
|
6
|
+
does, and prints results in TLC's format, so tools written against TLC keep working.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npx everystate Spec.tla # uses Spec.cfg next to the spec
|
|
10
|
+
npx everystate -config MC.cfg -deadlock Spec.tla
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Error: Invariant NotSolved is violated.
|
|
15
|
+
Error: The behavior up to this point is:
|
|
16
|
+
State 1: <Initial predicate>
|
|
17
|
+
/\ big = 0
|
|
18
|
+
/\ small = 0
|
|
19
|
+
|
|
20
|
+
State 2: <FillBig line 16, col 12 to line 16, col 37 of module DieHard>
|
|
21
|
+
/\ big = 5
|
|
22
|
+
/\ small = 0
|
|
23
|
+
...
|
|
24
|
+
73 states generated, 14 distinct states found, 1 states left on queue.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Runs on Node 20+ and Bun. It uses only `node:fs`, `node:path`, `node:worker_threads` and
|
|
28
|
+
`node:child_process` in its CLI host; the checker itself (`import { check } from 'everystate'`) needs
|
|
29
|
+
no host APIs at all and runs anywhere JavaScript does.
|
|
30
|
+
|
|
31
|
+
## What it does
|
|
32
|
+
|
|
33
|
+
- **Language**: the full TLA+ expression language as TLC supports it — modules, `EXTENDS`,
|
|
34
|
+
`INSTANCE ... WITH` (named, parameterised, `LOCAL`, inside `LET`), recursive operators and
|
|
35
|
+
functions, higher-order operators, `LAMBDA`, `CASE`, `CHOOSE`, `EXCEPT`, junction lists, action
|
|
36
|
+
operators (`'`, `UNCHANGED`, `ENABLED`, `[A]_v`, `<<A>>_v`, `\cdot`), temporal operators, proofs
|
|
37
|
+
(parsed and ignored).
|
|
38
|
+
- **Checking**: invariants, deadlock, state and action constraints, `[][A]_v` action properties,
|
|
39
|
+
refinement (`PROPERTY OtherSpec`), and liveness under weak and strong fairness
|
|
40
|
+
(`[]<>`, `<>[]`, `~>`, `WF_`, `SF_`) with lasso counterexamples.
|
|
41
|
+
- **Configuration**: `SPECIFICATION`, `INIT`/`NEXT`, `CONSTANT(S)` (values, model values, `<-`
|
|
42
|
+
substitution), `INVARIANT(S)`, `PROPERTY/PROPERTIES`, `CONSTRAINT(S)`, `ACTION_CONSTRAINT(S)`,
|
|
43
|
+
`SYMMETRY`, `VIEW`, `CHECK_DEADLOCK`.
|
|
44
|
+
- **Standard modules**, implemented natively: `Naturals`, `Integers`, `Reals` (integers only),
|
|
45
|
+
`Sequences`, `FiniteSets`, `Bags`, `TLC`, `TLCExt`, `Randomization`.
|
|
46
|
+
- **Community modules**, bundled: `FiniteSetsExt`, `SequencesExt`, `Functions`, `Folds`, `Graphs`,
|
|
47
|
+
`UndirectedGraphs`, `Relation`, `BagsExt`, `Bitwise`, `Combinatorics`, `Json`, `CSV`, `IOUtils`,
|
|
48
|
+
`VectorClocks`, `DyadicRationals`, `Statistics`, and the TLAPS library modules (`TLAPS`,
|
|
49
|
+
`FiniteSetTheorems`, `NaturalsInduction`, ...) so that specs with proofs load.
|
|
50
|
+
- **Output**: TLC's messages, `-tool` framing, exit codes, trace format with action names and
|
|
51
|
+
source locations, 80-column value wrapping, and `-dump dot,actionlabels`.
|
|
52
|
+
|
|
53
|
+
## Using it where a tool expects Java + TLC
|
|
54
|
+
|
|
55
|
+
`everystate-java` accepts the command line of `java -cp tla2tools.jar tlc2.TLC ...` (and of
|
|
56
|
+
`tla2sany.xml.XMLExporter`). Point a TLC-driving script at it instead of a JVM:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
JAVA="$(npm root)/everystate/dist/java.js" TLA2TOOLS=unused some-tool-that-runs-tlc Spec.tla
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The pstack `statechart` skill script runs unmodified this way.
|
|
63
|
+
|
|
64
|
+
## API
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { check, fmt } from 'everystate';
|
|
68
|
+
|
|
69
|
+
const { result, model } = check({
|
|
70
|
+
root: 'Spec',
|
|
71
|
+
modules: { Spec: tlaSource }, // plus any modules it imports that are not bundled
|
|
72
|
+
config: 'SPECIFICATION Spec\nINVARIANT TypeOK',
|
|
73
|
+
});
|
|
74
|
+
result.status; // 'ok' | 'invariant' | 'deadlock' | 'liveness' | 'action-property' | ...
|
|
75
|
+
result.distinct; // distinct states found
|
|
76
|
+
result.trace; // counterexample: [{ state, action }]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## How it is verified
|
|
80
|
+
|
|
81
|
+
Real TLC is the specification. Three suites compare against it:
|
|
82
|
+
|
|
83
|
+
| Suite | What is compared | Command |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| [tlaplus/Examples](https://github.com/tlaplus/Examples) manifest | result kind and exact generated / distinct state counts recorded upstream | `npm run conformance:examples -- /path/to/Examples` |
|
|
86
|
+
| TLC's own `test-model` directory | outcome, state counts and trace length against a live run of `tla2tools.jar` | `npm run conformance:tlc -- /path/to/test-model` |
|
|
87
|
+
| pstack `statechart` corpus | byte-identical charts and reports produced by the real script with everystate standing in for Java | `npm run conformance:statechart -- /path/to/statechart/scripts` |
|
|
88
|
+
|
|
89
|
+
`npm test` runs the self-contained tests (no Java needed): the checker API, the value
|
|
90
|
+
pretty-printer against 337 outputs recorded from the Java implementation, and the community-module
|
|
91
|
+
operators against fixtures validated with real TLC.
|
|
92
|
+
|
|
93
|
+
Current results are in [CONFORMANCE.md](CONFORMANCE.md).
|
|
94
|
+
|
|
95
|
+
## Not supported (yet)
|
|
96
|
+
|
|
97
|
+
- Simulation / generation mode (`-simulate`, `-generate`), depth-first iterative deepening.
|
|
98
|
+
- Multiple workers, disk-backed state queues and fingerprint sets, checkpointing: everything is in
|
|
99
|
+
memory, so the practical limit is a few million distinct states.
|
|
100
|
+
- The PlusCal translator (specs that already contain their translation work).
|
|
101
|
+
- Trace-explorer spec generation, the debugger, coverage statistics, Java module overrides.
|
|
102
|
+
- TLAPS proofs are parsed and skipped, not checked.
|
|
103
|
+
|
|
104
|
+
## Rust port
|
|
105
|
+
|
|
106
|
+
`rust/` holds `verify-rs`, a Rust port of the safety checker (no liveness, `-tool` or `-dump`),
|
|
107
|
+
built to compare speed. It is about 2x faster than this TypeScript engine on Node and roughly level
|
|
108
|
+
with single-worker Java TLC; see `rust/BENCHMARK.md`. The TypeScript engine is the complete one.
|
|
109
|
+
|
|
110
|
+
## Layout
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
src/lexer.ts, parser.ts TLA+ front end
|
|
114
|
+
src/modules.ts module loading, name resolution, expression levels
|
|
115
|
+
src/values.ts values and TLC's ordering
|
|
116
|
+
src/eval.ts evaluator and next-state enumeration
|
|
117
|
+
src/stdlib.ts, community.ts native standard and community module operators
|
|
118
|
+
src/model.ts, cfg.ts configuration -> checkable model
|
|
119
|
+
src/checker.ts, liveness.ts breadth-first search, liveness (tableau + SCC)
|
|
120
|
+
src/main.ts CLI, TLC-compatible output, java shim
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT. Bundled TLA+ library modules keep their own (MIT / BSD) licenses.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BUNDLED: Record<string, string>;
|