qleisli 0.2.9

Experimental quantum language with linear ownership, exact contracts and independent finite IR verification
Documentation
# Qleisli Python connections

Copyright 2026 Masahiko G. Yamada. Licensed under Apache-2.0.

This development host package calls the separately installed Qleisli 0.2.9 Rust
executable built from the same checkout. The version denotes this development
checkout; Rust and Python registry publications are separate.
It does not embed Rust or require an LLVM installation. Install a local wheel,
then select `Client(executable="/path/to/qleisli")`, set `QLEISLI_BIN`, or put
`qleisli` on PATH. Prebuilt all-in-one platform wheels are not provided yet.

```python
from qleisli import Client

client = Client(executable="target/debug/qleisli", lean_kernel="/path/to/qleisli-kernel")
program = client.from_openqasm('''OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q; bit[2] c; reset q;
h q[0]; cx q[0], q[1]; c = measure q;
''')
print(program.run())
print(program.sample(shots=8, seed=0))
print(program.to_qir())
```

Use `compile_project(path)` for a `.qli` project and `from_ir(bytes)` for a
QIRF artifact. `from_qir(text_or_bitcode)` requires the optional `qir` extra
(PyQIR 0.12.5, MIT, with its LLVM dependency notices). It supports the declared
QIR 2.0 Base terminal subset, not arbitrary LLVM or adaptive programs. The
reader runs in a separate process and never executes imported code. All inputs
then pass the native Lean verifier. `QleisliError.diagnostics` retains structured Rust
diagnostics. Result bit lists keep declared output order; probabilities are
numerical diagnostics and samples are local simulations, not device results.

`python -m qleisli INPUT --input=qasm|qir|qirf|qli --action=check|run|sample|emit-qasm|emit-qir|emit-ir`
provides a JSON command-line host. Sampling requires `--shots` and `--seed`.
Each operation rechecks the actual artifact. Mutating a Python object or its
serialized IR cannot create a trusted evidence handle.

To select an independently built and audited Lean kernel, use
`Client(executable="target/debug/qleisli", lean_kernel="/path/to/qleisli-kernel")`
or add `--lean-kernel=/path/to/qleisli-kernel` to the Python CLI. Every input path
(including QIR text/bitcode) and every subsequent `Program` method then requires
fresh native acceptance. Missing executables, rejection and malformed responses fail;
there is no fallback. Output IR is the exact checked artifact, and execution or
foreign emission uses its reconstructed program. Clients without an explicit path require `QLEISLI_KERNEL`. Cargo and the Python
wheel do not install or download the checker. A prebuilt native bundle needs no
Lean development installation. Missing and incompatible product versions reject.

For a checkout, install into a virtual environment (QIR support is optional):

```sh
cargo build --bin qleisli
(cd lean-kernel && lake build)
export QLEISLI_KERNEL="$PWD/lean-kernel/.lake/build/bin/qleisli-kernel"
python3 -m venv /tmp/qleisli-python
/tmp/qleisli-python/bin/pip install --only-binary=pyqir './python[qir]'
```

This builds only the pure Python host wheel; the separate Cargo step builds the
Rust executable. `--only-binary=pyqir` fails explicitly on platforms without a
reader wheel, instead of attempting a local LLVM build. Omit `[qir]` when only
OpenQASM/QIRF and QIR output are needed. PyQIR retains its own MIT license and
bundled LLVM/transitive notices; none of that binary code is included in this
host wheel.