Skip to main content

b01t: Safe Quantum Programming

Quantum code has its own class of bugs: dirty ancillae, bad uncomputation, silent decoherence. These pass type checks and compile fine in every existing framework. You only discover them by simulating the density matrix.

b01t is a Python DSL that catches these at build time. Every well-typed safe program is a proven unitary channel (the Hero Theorem, machine-checked in Lean 4).

Example

A phase oracle in six lines:

from b01t import coherent, QReg, cx, z, Certification
from b01t.kit import ancilla, compute, phase, uncompute

@coherent
def oracle(sys: QReg):
    with ancilla(1) as anc:
        compute(lambda: cx(sys[0], anc[0]))
        phase(lambda: z(anc[0]))
        uncompute()

prog = oracle.build_exact(("sys", 1))
assert prog.certification == Certification.SAFE  # proven unitary, no simulation

The compute block copies system information into the ancilla using only classical-reversible gates. The phase block applies a diagonal rotation. The uncompute auto-generates the inverse. b01t proves at build time that the ancilla returns to |0> and the whole program is a unitary channel.

Now the mistake every quantum programmer makes at least once:

@coherent
def broken(sys: QReg):
    with ancilla(1) as anc:
        compute(lambda: h(anc[0]))  # "just put it in superposition"
        phase(lambda: z(anc[0]))
        uncompute()

# DSLValidationError: gate 'h' is not allowed in compute blocks

Qiskit, Cirq, and Q# all accept this. It compiles, it runs, it looks fine. But since H is not a permutation gate, it creates superposition, which means the ancilla can end up entangled with the system after "uncomputation." The program silently becomes a mixed channel instead of a unitary.

b01t rejects it: compute blocks allow only permutation gates (X, CX, CCX, MCX), phase blocks allow only diagonal gates (Z, S, T, CZ, CCZ, MCZ). If your program passes these rules, it is a unitary channel.

Install

uv sync
uv run pytest

Metadata

Release files for b01t-lang 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for b01t-lang 0.1.0
File Size Uploaded Provenance
b01t_lang-0.1.0.tar.gz 89.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for b01t-lang 0.1.0
File Interpreter ABI Platform
b01t_lang-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 165.3 kB

Release files / b01t_lang-0.1.0.tar.gz

Download URL b01t_lang-0.1.0.tar.gz
Size 89.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e58bfa6780204fd576d523c3faa39e616a0c263cb923c652f7b41d12a0aa5842
BLAKE2b-256 checksum
How to use checksums
5d7ae060ed588f0b1245e95189a7dfd5d0fb1e7c89d0a0dbfc9c03ee0cf80141
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / b01t_lang-0.1.0-py3-none-any.whl

Download URL b01t_lang-0.1.0-py3-none-any.whl
Size 76.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5283b60e3db59ff327332a1da86cdfcea445194f064ddad6ecc1ed5ed7ce974b
BLAKE2b-256 checksum
How to use checksums
c194e78811db875ee5ab244feb84b0e19143606374871e05b7f19cbd913f2c27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for b01t-lang 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page