Metadata-Version: 2.4
Name: tanny
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Dist: temporal-typing>=0.5.0
License-File: LICENSE
Summary: Check Python's temporal typing: a model checker for temporal-typing specifications, in Rust, on Manyan.
Keywords: tla+,formal-methods,model-checking,verification,typing
Author-email: Ju Lin <soasme@gmail.com>
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/soasme/tanny

# tanny

`tanny` checks Python's temporal typing. [temporal-typing](https://github.com/soasme/temporal-typing)
declares how a program's state may change, as ordinary Python annotations;
`tanny` reads them from source, without running it, gives each model its
meaning in TLA⁺, and model checks it with [Manyan](https://github.com/soasme/manyan),
in process. It is written in Rust.

```sh
uv tool install tanny   # or: pip install tanny
tanny check examples/
```

```
PASS bank_account.py::small_account_model  884 states; deposit.amount ∈ 1..3, withdraw.amount ∈ 1..3; bounded by state_constraint
FAIL die_hard.py::impl_model  invariant not_solved
    1. init: small=0, big=0
    2. fill_big(): small=0, big=5
    3. pour_big_to_small(): small=3, big=2
    ...
```

Each `Model(...)` in the files gets one verdict, as
[the checker specification](https://github.com/soasme/temporal-typing/blob/main/docs/checker.md)
says: PASS with what was checked, FAIL with its kind (`invariant`,
`conformance`, `refinement`, `assertion`, `runtime`, ...) and a trace in
Python terms, or ERROR with a diagnostic at a `file:line`. It exits 0 when
every verdict is PASS, 1 on a FAIL, 2 on an ERROR; `--json` gives the
verdicts as JSON.

```sh
tanny check --root src/ tests/specs/    # search src/ for imports first
tanny check -m impl_model die_hard.py   # one model
tanny translate die_hard.py impl_model  # the TLA⁺ it is checked as
```

## How

| Crate | Does |
| --- | --- |
| [`tanny`](crates/tanny) | the executable: a verdict per model |
| [`tanny-cli`](crates/tanny-cli) | its command line |
| [`tanny-frontend`](crates/tanny-frontend) | checker.md §1–3, §6: reads the declarations from source with ruff's parser |
| [`tanny-translate`](crates/tanny-translate) | §4–5: Python, with Python's meaning, as TLA⁺ |
| [`manyan`](crates/manyan) | checks TLA⁺ with Manyan in process, and gives what it found as values |
| [`manyan-sys`](crates/manyan-sys) | Manyan's C API, built from its source (a submodule) |

A method body runs on a record of the state and its locals; a loop is a
recursive operator. Every obligation that is not an invariant or property
(conformance of a body to its `Action`, `Ensures`, the frame, `assert`, a
contract, an index out of range) is an `Assert` whose message names its
kind, so a FAIL says which one failed. A refinement is an `INSTANCE` of the
abstract specification's module under the mapping, checked part by part:
init, step, each fairness clause, invariants and properties.

## Development

```sh
git clone --recursive https://github.com/soasme/tanny
make check        # cargo test, clippy, fmt, and the conformance suite
make conformance  # the verdicts temporal-typing's suite and examples state
uv run tanny check tests/temporal-typing/examples
```

The conformance suite is temporal-typing's own (`tests/checker` and
`examples`, a submodule at the release checked against).

## License

MIT; see [LICENSE](LICENSE).

