Header menu logo Encodings

Encodings Namespace

Modules Description

Bosonic

Bosonic ladder-operator expressions and normal-ordering utilities.

BosonicEncoding

Bosonic-to-qubit encodings: Unary, Binary, and Gray code.

BravyiKitaev

 Bravyi-Kitaev encoding for fermion-to-qubit mappings.

 The BK transform uses a Fenwick tree structure to achieve O(log n) Pauli
 weight per ladder operator, compared to O(n) for the Jordan-Wigner transform.

 This module delegates to MajoranaEncoding with Fenwick-tree index sets.

 Reference:
   Seeley, Richard, Love — "The Bravyi-Kitaev transformation for quantum
   computation of electronic structure" (arXiv:1208.5986)

CircuitOutput

Renders Gate arrays into OpenQASM (2.0 and 3.0), Q#, and JSON circuit formats.

CombiningAlgebra

Algebra interface for combining operator terms during normal ordering.

CostAnalysis

Unified cost metrics for encoded Hamiltonians, including qubitization resource estimation.

Fcidump

FCIDUMP file parser and coefficient factory builder.

FenwickTree

 A purely functional Fenwick tree (binary indexed tree) parameterized by
 an associative combining operation.

 The tree stores partial aggregates over an array of n values, supporting:
   - point update   : O(log n)
   - prefix query   : O(log n)
   - range query    : via prefix difference when the combine has an inverse

 The index sets used by the Bravyi-Kitaev encoding (update, parity,
 occupation, remainder) all fall out naturally from the Fenwick tree
 structure, making this a good foundation for the BK transform.

Hamiltonian

Hamiltonian construction from one-body and two-body integrals.

IndexedLadderOperator

Fermionic ladder operators with index tracking and ordering predicates.

IndexedPauli

Defines the fundamental Pauli algebra types: Phase and Pauli operators.

IndexedTerms

Indexed operator types for tracking qubit/mode assignments.

JordanWigner

The Jordan-Wigner fermion-to-qubit encoding (1928).

LadderOperatorSequence

Normal ordering of fermionic operator products.

MajoranaEncoding

 Generic fermion-to-qubit encoding via Majorana decomposition.

 Every encoding in this family maps a single fermionic ladder operator
 to a pair of Majorana operators (c, d) built from three index sets:

   U(j, n)  — update set:     qubits that flip when occupation of mode j changes
   P(j)     — parity set:     qubits encoding the parity n₀ ⊕ … ⊕ n_{j−1}
   Occ(j)   — occupation set: qubits encoding whether mode j is occupied

 The Majorana operators are:
   c_j = X_{U(j)∪{j}} · Z_{P(j)}
   d_j = Y_j · X_{U(j)} · Z_{(P(j)⊕Occ(j))∖{j}}

 And the ladder operators follow:
   a†_j = ½(c_j − i·d_j)     a_j = ½(c_j + i·d_j)

 Different choices of index-set functions yield different encodings:
   Jordan-Wigner :  U = ∅,              P = {0…j−1},     Occ = {j}
   Parity        :  U = {j+1…n−1},      P = {j−1}?,      Occ = {j−1,j}?
   Bravyi-Kitaev :  U, P, Occ from Fenwick tree structure

MixedSystems

Sector-aware symbolic utilities for mixed bosonic and fermionic systems.

Optimization

Pluggable optimisation framework for selecting the best encoding.

PauliRegister

Multi-qubit Pauli strings with phase tracking and symbolic multiplication.

SwapTrackingSort

Swap-tracking selection sort for computing fermionic phase factors.

Tapering

Symbolic qubit tapering utilities for Pauli Hamiltonians.

Terms

Core algebraic types for representing quantum operator expressions.

TreeEncoding

 General tree-based fermion-to-qubit encodings.

 This module implements two approaches:

 (1) Index-set approach (Havlíček et al. arXiv:1701.07072):
     Works correctly ONLY for Fenwick trees (where all ancestors > j).
     Uses Update/Parity/Occupation sets with the generic MajoranaEncoding.

 (2) Path-based ternary-tree approach (Bonsai: arXiv:2212.09731,
     Jiang et al.: arXiv:1910.10746):
     Works for ANY ternary tree. Constructs Majorana strings directly
     from root-to-leg paths. Each node has 3 descending links labeled
     X, Y, Z.  Each leg yields a Pauli string by collecting the labels
     along its root-to-leg path. Paired legs give the two Majoranas
     for each fermionic mode.

 Different tree shapes yield different encodings:
   - Chain (linear tree):   recovers Jordan-Wigner
   - Fenwick tree:          recovers Bravyi-Kitaev
   - Balanced ternary tree: achieves O(log₃ n) Pauli weight (optimal)

Trotterization

Symbolic Trotter decomposition of Pauli Hamiltonians.

TypeExtensions

General-purpose utility functions and type extensions used throughout the encoding library.

VariationalCircuits

Symbolic support for VQE measurement programs and QPE resource estimation.

Type something to start searching.