symop.ccr.algebra.ket¶
Symbolic ket algebra for bosonic CCR systems.
This package implements purely symbolic manipulations of ket polynomials of the form
where each \(\lvert M_i \rangle\) is a normally ordered ladder-operator monomial acting on the vacuum. All computations are performed using canonical commutation relations (CCR) and symbolic normal ordering. No matrix representations or Hilbert-space truncations are constructed.
Functionality provided in this package includes:
Construction from creators/annihilators or arbitrary operator words.
Symbolic normal ordering of operator products.
Linear combination and canonicalization (combining like terms).
Scalar multiplication and ket–ket multiplication.
Symbolic inner products
\[\langle \phi \mid \psi \rangle,\]computed as identity coefficients of normal-ordered products.
Application of operator words
\[W \lvert \psi \rangle,\]including linear combinations of words.
All routines operate purely at the algebraic level using commutator relations
where the mode overlap may be non-orthogonal.
The module-level API is functional and stateless. The class
KetPoly provides a thin immutable wrapper exposing these
operations in object-oriented form while delegating the algebra to
the underlying functional implementations.
Design principles¶
Fully symbolic CCR-based manipulation.
Support for non-orthogonal modes via overlap factors.
Deterministic canonical ordering using monomial signatures.
Separation of algebraic logic and representation.
Public API¶
- class KetPoly(terms: tuple[KetTerm, ...] = ()) None¶
Bases:
objectSymbolic ket polynomial.
- Parameters:
terms (
tuple[KetTerm,...]) – Tuple of ket terms. Terms are not automatically canonicalized on construction; callcombine_like_terms()when needed.
Notes
The class is intentionally logic-only. It provides algebraic operations and structural queries, but no string/latex rendering.
- apply_word(word: Iterable[LadderOp], *, eps: float = 1e-12) KetPoly¶
Apply an operator word on the left:
word * self.
- apply_words(terms: Iterable[tuple[complex, Iterable[LadderOp]]], *, eps: float = 1e-12) KetPoly¶
Apply a linear combination of operator words on the left.
Interprets
termsas an operator polynomial\[\left(\sum_i c_i W_i\right)\lvert \psi \rangle.\]
- combine_like_terms(*, eps: float = 1e-12, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Return a canonicalized polynomial by merging identical monomials.
- static from_ops(*, creators: Iterable[LadderOp] = (), annihilators: Iterable[LadderOp] = (), coeff: complex = 1.0, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Construct from explicit creators and annihilators.
- static from_word(*, ops: Iterable[LadderOp], eps: float = 1e-12) KetPoly¶
Construct by normal-ordering an operator word.
- inner(other: KetPoly, *, eps: float = 1e-12) complex¶
Return the symbolic inner product
<self|other>.
- is_normalized(*, eps: float = 1e-14) bool¶
Return True if the polynomial has unit norm within tolerance.
- multiply(other: KetPoly, *, eps: float = 1e-12, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) KetPoly¶
Return the symbolic product
self * other.
Modules
Apply operator words to symbolic kets. |
|
Canonicalization helpers for CCR ket terms. |
|
Construct ket terms directly from creators and annihilators. |
|
Symbolic normal ordering of ladder-operator words for ket expansions. |
|
Identity-coefficient extraction for CCR ket expansions. |
|
Symbolic inner products for CCR ket expansions. |
|
Symbolic multiplication of CCR ket expansions. |
|
Symbolic ket polynomials for CCR algebra. |
|
Scalar multiplication for CCR ket expansions. |