> ## Documentation Index
> Fetch the complete documentation index at: https://b01t.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Algorithm Zoo: pre-built quantum modules for b01t

> The b01t algorithm zoo is a collection of certified-safe, composable quantum algorithm modules built on top of the core DSL and kit utilities.

The algorithm zoo gives you production-ready implementations of well-known quantum algorithms as first-class b01t modules. Every zoo module follows the same ancilla discipline as hand-written `@coherent` code, so you get structural safety certificates without having to implement the details yourself. You can use zoo components as drop-in building blocks inside your own `@coherent`, `@parametric`, or `@adaptive` programs, composing them the same way you would any other b01t function.

## Available modules

<CardGroup cols={2}>
  <Card title="grover" icon="magnifying-glass" href="/zoo/grover">
    Phase oracle and diffusion operator for Grover's search algorithm. Use `make_phase_oracle` to target any basis state, or compose the pre-built `phase_oracle` and `diffusion_operator` directly.
  </Card>

  <Card title="qft" icon="wave-sine" href="/zoo/qft">
    Quantum Fourier Transform and its inverse. Used as a subroutine in QPE, Shor's algorithm, and any algorithm that needs to read out a frequency from a quantum register.
  </Card>

  <Card title="qpe" icon="ruler">
    Quantum Phase Estimation. Takes a controlled-unitary oracle and estimates its eigenvalue to `t` bits of precision using the inverse QFT on a counting register.
  </Card>

  <Card title="amplitude_amplification" icon="chart-line">
    Generalized Grover search. Accepts any `@coherent` state-preparation function `A` and predicate oracle `O_chi`, and amplifies the amplitude of "good" states over repeated iterations.
  </Card>

  <Card title="modular" icon="calculator">
    Modular arithmetic primitives for Shor-class algorithms: controlled modular addition, inplace modular multiplication, and controlled modular exponentiation. All gates are permutation gates (`@coherent`/`@primitive`).
  </Card>

  <Card title="rank_select" icon="list-ol">
    Coherent legal-action indexing. Maps a superposition of selector indices to the corresponding empty cell in an occupancy register. Used in rollout oracles for sequential decision problems.
  </Card>

  <Card title="qae" icon="percent">
    Quantum Amplitude Estimation. Provides both iterative (measurement-based) and coherent (QPE-based) amplitude estimation, plus classical MLE post-processing utilities.
  </Card>

  <Card title="max_finding" icon="trophy">
    Quantum maximum finding via the Dürr–Høyer algorithm. Composes coherent amplitude estimation with Grover search to identify the highest-payoff arm in O(√k/ε) oracle calls.
  </Card>
</CardGroup>

## Importing from the zoo

Each module lives under `b01t.zoo` and exports its public API directly from its package:

```python theme={null}
from b01t.zoo.grover import make_phase_oracle, phase_oracle, diffusion_operator
from b01t.zoo.qft import qft, inverse_qft
from b01t.zoo.qpe import make_qpe
from b01t.zoo.amplitude_amplification import (
    zero_state_reflection,
    make_amplification_step,
    make_amplitude_amplifier,
)
from b01t.zoo.modular import (
    ctrl_modular_add_wires,
    make_inplace_modular_mul,
    make_controlled_modular_exp,
)
from b01t.zoo.rank_select import rank_select, rank_select_binary
from b01t.zoo.qae import make_qae_round, make_qae_schedule, make_coherent_ae
from b01t.zoo.max_finding import make_comparison_oracle, DurrHoyerRunner
```

## Composing zoo modules

Zoo functions are ordinary b01t DSL functions — you call them inside `@coherent`, `@parametric`, or `@adaptive` bodies the same way you call any gate or kit utility. The following example builds a QPE circuit by combining the QFT module with a custom unitary oracle:

```python theme={null}
from b01t import QReg, parametric, h
from b01t.zoo.qft import inverse_qft

def my_controlled_unitary(counting: QReg, work: QReg):
    # your controlled-U^(2^k) implementation here
    ...

@parametric
def my_qpe(counting: QReg, work: QReg):
    for i in range(len(counting)):
        h(counting[i])
    my_controlled_unitary(counting, work)
    inverse_qft(counting)
```

<Note>
  Zoo modules that use continuous rotation gates (QFT, QPE, QAE) are decorated `@parametric`. Modules that use only permutation and diagonal gates (Grover oracle, diffusion, modular arithmetic) are `@coherent`. Check each module's documentation for its decorator so you know which host context it can run in.
</Note>

<Tip>
  You can inspect any zoo function's IR with `from b01t import dump_ir` and `dump_ir(fn.build(...))` to understand the gate-level structure before compiling to Qiskit.
</Tip>
