The bra-ket primitives
daitai-algebra v1.4 includes a small set of bra-ket primitives that let you write quantum and classical state in the same vocabulary. This page is the conceptual introduction; for the full operator catalogue, see Step semantics.
Why bra-ket in a general-purpose algebra?
Bra-ket notation is not exotic. It is the cleanest way to talk about:
- a state vector that may be a superposition of possibilities;
- the dual of that vector;
- the inner product that asks "how aligned are these two states?";
- the projection that asks "what is the probability of observing this outcome?".
Every one of these questions also appears in classical machine learning, statistics, and information theory — just disguised. Naming them once, with one notation, removes a class of bugs that comes from translating between notations.
The primitives
| Symbol | Sort | Meaning |
|--------|------|---------|
| |ψ⟩ | Ket | state vector |
| ⟨ψ| | Bra | dual of a ket |
| ⟨φ|ψ⟩ | Scalar | inner product |
| |ψ⟩⟨φ| | Operator | outer product (rank-1 operator) |
| A ⊗ B | Operator × Operator → Operator | tensor product |
A worked example: the Bell state
type Register = Tensor<Qubit, Qubit>
fn bell() -> Register {
let q0 = |0⟩
let q1 = |0⟩
let h = H(q0) # superposition
let r = CNOT(h ⊗ q1) # entangle
r
}
# Classical observation collapses the state.
let step : Register × Measure -> Distribution<Bit × Bit> = observe
The observe function returns a Distribution, not a value. This is the algebra forcing you to be honest: measurement is non-deterministic, and the type system insists you handle the resulting distribution rather than silently sampling.
Reading next
- Step semantics — the canonical
State × Event → Staterelation. - The principles — why these primitives are constitutional and not "syntax sugar".