Skip to main content

Crate qleisli

Crate qleisli 

Source
Expand description

Qleisli: an experimental quantum language with independently checked finite IR.

The frontend checks a finite .qli subset and lowers it to IR. Every generated function is submitted to interchange::native::Kernel. Raw IR is untrusted regardless of its producer. Lean is the only acceptance authority. Cargo builds and documents this library without Lean; checking requires a separately built, compatible native checker. Set QLEISLI_KERNEL to its executable or use the explicit *_with_kernel APIs. Missing, incompatible or failing checkers reject; no runtime download or Rust fallback exists.

§Start with a verified circuit

The package name is qleisli; Rust imports use qleisli. Import the supported OpenQASM 3 terminal subset and inspect its numerical reference distribution. Qubits must be explicitly initialized with reset.

use qleisli::{interop::import_openqasm3, sim};

let program = import_openqasm3(r#"
OPENQASM 3.0;
include "stdgates.inc";
qubit q;
bit c;
reset q;
h q;
c = measure q;
"#)?;
let distribution = sim::run_closed(&program, sim::SimulationLimits::default())?;
assert_eq!(distribution.len(), 2);
for bits in [vec![false], vec![true]] {
    assert!((distribution[&bits] - 0.5).abs() < 1e-12);
}

§API guide

§Scope and compatibility

Sized Bits<n> / CBits<m> source experiments are not production frontend APIs. General Soundness, Physical Realizability and Resource Safety theorems remain proof goals. Successful checking is not an algorithm or hardware proof. Simulated probabilities are approximate and may contain tiny rounding residues. The first-registry-release name migration replaces the earlier Git/path qleisli-core package and qleisli_core import with qleisli. Existing clients must migrate dependency/import names or use a Cargo dependency alias. Version 0.2.9 is an explicitly approved breaking verifier migration: use AcceptedProgram and Kernel::accept_raw in place of the removed Rust verifier and its handles. The 0.3.0 type-system work remains separate. See the language quick reference, trust boundary and versioning policy.

Re-exports§

pub use interchange::native::AcceptedProgram;

Modules§

contract
Bounded, exact semantic evidence for finite pure circuit implementations.
frontend
Syntax, module resolution, and checked lowering of a finite .qli subset.
host
Classical postprocessing, separate from .qli quantum operations. These routines cannot create or bypass a crate::AcceptedProgram.
interchange
Bounded QIRF1/2 transport. All imported evidence is reconstructed by the ordinary finite checker; labels and embedded source text are never executed.
interop
Bounded, untrusted OpenQASM 3 / QIR adapters for closed terminal circuits.
ir
Untrusted, finite Qleisli IR. All public fields must be accepted by the native Lean kernel.
sim
A finite reference interpreter for already verified, closed IR programs.