Tanny
A static model checker for Python specifications.
Tanny reads the Temporal Typing declarations on your Python classes,
translates each Model into TLA⁺ with Python's semantics, and checks it in process with
Manyan.
- Nothing executed. Tanny parses source with Ruff's parser: your modules are never imported or run.
- Python-level counterexamples. A failing trace names Python actions, arguments and state variables.
- No JVM. One Rust binary with Manyan linked in, on PyPI for Linux and macOS.
Quick Start → · Interactive Tour (WASM) ↗ · Manual · Architecture
Installation#
bash
uv tool install tanny # or: pip install tannyAt a Glance#
The hour clock of Lamport's Specifying Systems, written with Temporal Typing:
hour_clock.py
from dataclasses import dataclass
from typing import Annotated
from temporal_typing import Action, Init, Invariant, Model, State, prime, spec
@spec(
init=Init(lambda s: s.hr in range(1, 13)),
type_ok=Invariant(lambda s: s.hr in range(1, 13)),
)
@dataclass
class HourClock:
hr: State[int]
def tick(self) -> Annotated[None, Action(lambda s: prime(s.hr) == (s.hr + 1 if s.hr != 12 else 1))]:
self.hr = self.hr + 1 if self.hr != 12 else 1
hour_clock_model = Model(HourClock)Tanny gives each model one verdict. A FAIL comes with the shortest trace that breaks the specification, in Python terms:
bash
$ tanny check examples/
PASS examples/hour_clock.py::hour_clock_model 12 states
FAIL examples/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
4. empty_small(): small=0, big=2
5. pour_big_to_small(): small=2, big=0
6. fill_big(): small=2, big=5
7. pour_big_to_small(): small=3, big=4What Tanny Checks#
| Failure kind | What failed |
|---|---|
invariant, action-invariant | An Invariant or ActionInvariant in a reachable state or step |
property | A temporal Property, under weak and strong fairness |
assumption | An Assume clause on the constants |
conformance | A method body that does not do what its Action, Ensures, frame or return Where says |
contract | A function contract, for some argument in its domain |
refinement | A Refines[A] mapping that does not implement A |
deadlock, assertion, runtime | A state with no action enabled, a failing assert, or a Python runtime error |
Where to Start#
- New to Temporal Typing? Take A Tour of Temporal Typing: its lessons run Tanny in your browser.
- Ready to install? Follow Installation and the Quick Start.
- Wiring it into CI? Read Exit Codes, JSON Output and CI Integration.