Skip to content

Add single-qubit quantum system (kata qat6) - #54

Open
ellisonbg wants to merge 1 commit into
mainfrom
qubit
Open

ellisonbg wants to merge 1 commit into
mainfrom
qubit

Conversation

@ellisonbg

Copy link
Copy Markdown
Owner

Implements the single-qubit quantum system from kata #qat6 — a
quantum-information-framed single (non-composite) qubit.

What's here

  • Rust core (crates/uhlenbeck/src/qubit.rs): Qubit (a Namespace
    impl with dual-cased gate accessors — lowercase default + uppercase
    physics alias returning the same interned atom) and qubit_system /
    qubit_system_for(ns) builders, re-exported from lib.rs. Gates:
    Pauli X/Y/Z, H, S/T + Sdag/Tdag, rotations
    Rx/Ry/Rz, phase P; states qubit(b), zero(), one().
  • Symbolic action rules written once over a single wildcard bit fire
    on concrete (X|0>=|1>), symbolic (X|a>=|¬a>), and boolean
    (X|a⊕b>=|¬(a⊕b)>) labels. Plus <b'|b>=δ inner products,
    Hermitian/dagger rules, Pauli commutators (canonical order), and
    completeness Σ|b><b|.
  • Python (python/uhlenbeck/systems/qubit.py): Qubit(Namespace)
    mirroring the Rust accessors, builds + registers on init (idempotent
    reuse). New uhlenbeck.systems subpackage.
  • Notebook (notebooks/systems/qubit.ipynb): tutorial authored +
    executed clean via nb execute --uv.
  • Tests: crates/uhlenbeck/tests/qubit.rs (Rust) and
    tests/test_qubit.py (Python).

Design note — boolean ↔ {0,1} coercion

The issue's central design question resolves to no special machinery
needed
: boolean true/false are the integers 1/0, so a
concrete-bit label folds automatically inside pow/exp
((−1)^1=−1, i^1=i, exp(iπ·0/4)=1) while a symbolic or
boolean-expression label leaves the phase symbolic ((−1)^a,
(−1)^(a⊕b)). One rule handles all three label kinds.

Verification

  • cargo test -p uhlenbeck green (full suite); cargo fmt --all --check
    and clippy clean.
  • uv run pytest tests/ — full suite green.
  • Notebook executes with no errors (H·H|0>=|0>, HZH|0>=|1>, etc.).

Follow-ups (filed)

  • #8agy — Inner-product evaluation API: no Python/evaluate path
    fires inner_product_rules today (IP evaluation is Rust-only via
    eval_inner_product_once).
  • #nyxn — Triggering API for commutator_rules/anticommutator_rules
    (declarative data with no user-facing trigger).
  • #p7er — Qubit(register=False) can build a malformed system on an
    already-registered namespace (build-before-register dagger hazard).

🤖 Generated with Claude Code

A quantum-information-framed single (non-composite) qubit: the standard
single-qubit gate set acting on the symbolic computational basis |b>,
where the bit label may be a concrete bit, a symbol, or a boolean
expression.

- Rust: `Qubit` (Namespace impl, dual-cased gate accessors) and
  `qubit_system` / `qubit_system_for` builders in `crates/uhlenbeck/src/qubit.rs`;
  gates X/Y/Z/H/S/T, Sdag/Tdag, Rx/Ry/Rz, P; action rules over a wildcard
  bit fire on concrete, symbolic, and boolean labels; Pauli commutators,
  Hermitian/dagger rules, <b'|b>=δ inner products, completeness Σ|b><b|.
- Python: `Qubit(Namespace)` mirror in a new `uhlenbeck.systems` subpackage,
  builds + registers on init (idempotent reuse).
- Notebook: `notebooks/systems/qubit.ipynb` (authored + executed via nb).
- Tests: `crates/uhlenbeck/tests/qubit.rs` (Rust) and `tests/test_qubit.py`.

The boolean<->{0,1} coercion (the issue's main design question) needs no
special machinery: boolean true/false are integers 1/0, so concrete bits
fold inside pow/exp while symbolic/boolean labels stay symbolic.

Follow-ups filed as kata #8agy (Python/evaluate path for inner-product
rules) and #nyxn (triggering API for commutator_rules).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant