cd /news/developer-tools/bringing-formal-verification-to-pyth… · home › topics › developer-tools › article
[ARTICLE · art-180872] src=julin.ai ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Bringing Formal Verification to Python with Temporal Typing

Developer Julin launched Temporal Typing, a Python library that expresses formal specifications through standard type annotations using Pure, Requires, Ensures and Model, and verifies implementations against them. Its default checker, Tanny, statically analyzes Python source, translates both the specification and the implementation into TLA+, and model-checks them with Manyan without executing the Python code. The annotations remain compatible with Pyright, mypy and ty 1.0, released by Astral this week, and the tool catches bugs that conventional type checkers accept, such as a bill-splitting function that returns a tuple of integers but violates its specification when the total is not evenly divisible.

key takeaway

Temporal Typing lets Python developers attach Requires, Ensures and Pure annotations to functions and have Tanny translate them to TLA+ for model checking, catching behavioral bugs like a bill-splitting function that passes type checks but violates its spec when the total isn't evenly divisible.

read3 min views2 publishedDec 2, 2026

Before the rise of coding agents, I used to hand-craft TLA+ specs for my beloved projects and write implementations based on those models. However, that workflow was fragile. I could get the implementation wrong, and whenever I updated the specs or the implementation, I had to keep both in mind to stop them from drifting apart.

With state-of-the-art models, such a translation now costs almost nothing (okay, except for tokens). Nonetheless, the process is still fragile. I’ve run into several cases where Claude Code translated TLA+ specs into Python code incorrectly, making the same mistakes I used to make in the old days.

To tackle the drift problem, I need a tool that can:

  1. Understand the semantics of both Python and TLA+.
  2. Check that the implementation conforms to its specification.
  3. Model-check the specification itself.

With such a tool, we can formally model our code, verify its correctness within defined model bounds, and detect drift automatically.

There are a few interesting projects in other languages, such as LemmaScript (TypeScript) and Kani (Rust). But I couldn’t find quite what I wanted in the Python world.

You know what that means. It’s token-burning time.

After a week of iteration, Temporal Typing is live!

https://temporal-typing.julin.ai/

Check out this example:

from typing import Annotated
from temporal_typing import (
    Ensures, Model, Pure, Requires)

def split_bill(total: int, n: int) -> Annotated[
    Pure[tuple[int, ...]],
    Requires(lambda n: n > 0),
    Ensures(lambda total, n, result:
        len(result) == n
        and sum(result) == total
        and max(result) - min(result) <= 1),
]:
    share, extra = total // n, total % n
    return tuple(
        share + 1 if i < extra else share
        for i in range(n))

model = Model(
    split_bill, domains={int: range(10)})

The code uses Annotated, introduced in PEP 593. The declarations Pure, Requires, Ensures, and Model express formal specifications through ordinary Python type annotations.

Under the hood, the default checker, Tanny, statically analyzes the Python source code, translates both the specification and the implementation into TLA+, and model-checks them with Manyan. It does all of this without executing the Python code.

The interesting part is that both the correct and the buggy implementations are valid from a conventional type checker’s perspective. Both return a tuple of integers. But the buggy one violates the specification whenever the bill cannot be divided evenly.

The annotations are compatible with existing type checkers such as Pyright, mypy, and even ty 1.0, released by the Astral team this week. Temporal Typing adds another layer of semantics to these annotations, so model checkers can verify the behaviour of the code, not just its types.

Type checkers check types. Temporal Typing checkers check behaviour.

With coding agents making code ever cheaper to produce, I believe formal verification should become part of our everyday development workflow, just like type checking, linting, and testing.

If you care about the correctness of your Python code, give Temporal Typing a try today!

── more in #developer-tools 4 stories · sorted by recency
── more on @temporal typing 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/bringing-formal-veri…] indexed:0 read:3min 2026-12-02 · —