mirror of
https://github.com/blackboxprogramming/quantum-math-lab.git
synced 2026-03-17 08:57:24 -05:00
- GitHub Actions CI: Python 3.10/3.11/3.12 matrix, pytest with coverage, ruff linting - Test suite: Hadamard, Pauli-X, CNOT, Bell states, GHZ states, custom unitaries (Z, SWAP, identity), measurement statistics, state collapse, error handling, probability normalization - README with badges, architecture docs, usage examples - Makefile with test/lint/coverage targets Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> RoadChain-SHA2048: 3885eee6bf8b29cc RoadChain-Identity: alexa@sovereign RoadChain-Full: 3885eee6bf8b29ccd8d9f6c36377ccad48894592f56de0c0eed26cf27c4f58636378cb9a2839a1d98d24713a36dbc036a57b24e01470c353763b5c6ee0437068cfebb487d690ebd8fd62b25c1fcf4b50ffa7a9f8d77d49e270c45ba0872d6181a0f08754c57a7e75e11bb9563da5f691c2868f4e49ef49fdee0633afcdc2b91c7d1ba3dde5e6f152b586112b6428298121f56c05c860c9c322e410bdfbc5aa406974bfd32423306bee9f15ebd87de1e4046ced5fc92d09e4b88dc6632483aec463256705298864657dc196445aef65a7c724f7c12acfd75a80f506aed1e426d032c066d0e950ce13d47c2fb7ca8a80315cee29bd7ab613e0154786f1c42c771a
3.3 KiB
3.3 KiB
Quantum Math Lab
Pure-Python quantum circuit simulator with a companion catalog of unsolved problems in mathematics.
Simulator
The QuantumCircuit class implements a state-vector simulator that stores the full 2^n complex amplitude vector and applies gates as matrix operations. No external quantum framework required — just NumPy.
Supported Gates
| Gate | Method | Matrix |
|---|---|---|
| Hadamard | hadamard(q) |
(1/sqrt(2)) 1,1],[1,-1 |
| Pauli-X | pauli_x(q) |
0,1],[1,0 |
| CNOT | cnot(c, t) |
4x4 controlled-NOT |
| Custom | apply_custom(U, qubits) |
Any unitary matrix |
Quick Start
pip install numpy
from quantum_simulator import QuantumCircuit
import numpy as np
# Create a Bell state: (|00> + |11>) / sqrt(2)
circuit = QuantumCircuit(2)
circuit.hadamard(0)
circuit.cnot(0, 1)
print(circuit.probabilities())
# {'00': 0.5, '01': 0.0, '10': 0.0, '11': 0.5}
result = circuit.measure(shots=1000, rng=np.random.default_rng(42))
print(result.counts)
# {'00': 494, '01': 0, '10': 0, '11': 506}
3-Qubit GHZ State
circuit = QuantumCircuit(3)
circuit.hadamard(0)
circuit.cnot(0, 1)
circuit.cnot(0, 2)
# |000> + |111> with equal probability, all other states zero
Custom Unitaries
# Pauli-Z gate
Z = np.array([[1, 0], [0, -1]], dtype=complex)
circuit = QuantumCircuit(1)
circuit.apply_custom(Z, [0])
# SWAP gate
SWAP = np.array([[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]], dtype=complex)
circuit = QuantumCircuit(2)
circuit.apply_custom(SWAP, [0, 1])
Architecture
QuantumCircuit(n)
|
|-- _state: np.ndarray[complex128] # 2^n amplitude vector
|-- hadamard(q) / pauli_x(q) # Single-qubit gates
|-- cnot(c, t) # Two-qubit gate
|-- apply_custom(U, qubits) # Arbitrary unitary
|-- probabilities(qubits?) # |amplitude|^2 distribution
|-- measure(qubits?, shots, rng) # Sample + collapse
|
+-- MeasurementResult
|-- counts: {bitstring: int}
|-- most_likely() -> str
|-- total_shots() -> int
State is stored as a dense vector reshaped into a tensor for gate application via permutation and matrix multiplication. Measurement collapses the state vector by projecting onto the observed subspace and renormalizing.
Unsolved Problems
problems.md covers ten influential open problems:
- Riemann Hypothesis
- P vs NP
- Navier-Stokes regularity
- Hodge Conjecture
- Yang-Mills mass gap
- Birch and Swinnerton-Dyer
- Goldbach's Conjecture
- Twin Prime Conjecture
- Collatz Conjecture
- abc Conjecture
Each entry includes a problem statement, known progress, and references.
Development
# Install
pip install -r requirements.txt
# Run tests (35+ tests)
make test
# Lint
make lint
# Coverage report
make coverage
License
Proprietary — BlackRoad OS, Inc. See LICENSE.