ろくろのホームページ · personal site
final year project · living research
Analytical Spectral Modelling & Formal Verification of Heisenberg Matrix Mechanics Using Lean 4
Machine-checking finite-dimensional quantum mechanics, complex linear algebra, and operator commutators using the Lean 4 interactive theorem prover.
- Lean 4
- Mathlib
- Quantum Mechanics
- Complex Linear Algebra
- Formal Logic
- Python · NumPy
- Mathematical Modelling
-
Status
● In progress · Sem 1 baseline
-
Degree program
BSc (Hons) Mathematical Modelling & Analytics · CS267
-
Institution
UiTM Kuala Terengganu
-
Prover kernel
Lean 4 · 100% machine-checked
A living undergraduate research project — this page grows every semester as the formalization does. Repo link drops here once the first module lands.
Why formalize quantum mechanics?
Pen-and-paper derivations in mathematical physics are beautiful, but they hide things: a silent assumption that an operator is self-adjoint, an implicit interchange of limits, a trace cyclicity that quietly fails when dimensions diverge. A formal proof exposes every one of those steps and refuses to compile until each is justified.
The problem
Traditional derivations can contain subtle, unverified logical gaps or implicit physical assumptions that no one catches until they matter.
The solution
Encode Heisenberg's matrix mechanics in Lean 4. Every definition, axiom, and proof step is validated by Lean's dependent type system and logical kernel — guaranteeing 100% mathematical correctness.
Key focus: restricting the scope to finite-dimensional systems — qubits and general \(n\)-level systems — lets me rigorously formalize complex matrix adjoints, self-adjoint observables, and Pauli spin algebra without the measure-theoretic overhead of infinite-dimensional Hilbert spaces.
The 4-layer formalization stack
The project maps directly onto my curriculum. Each layer is both a course and a rung on the ladder from classical intuition to machine-checked certainty.
- Machine-checked proofs & 100% logical certainty
- Every theorem reduced to kernel-checked inference rules
- Interactive proof steps:
intro,cases,rw,decide - Turning insight into reproducible tactic scripts
- State vectors \(|\psi\rangle \in \mathbb{C}^n\)
- Hermitian observables, adjoints, eigenvalues & spectra
- Poisson brackets → matrix commutators
- \([A, B] = AB - BA\) as the quantum shadow of classical mechanics
Interactive proof showcase
A side-by-side of the classical statement against its Lean 4 formalization. The math column is rendered live with KaTeX; the code column is hand-tuned Lean syntax. Proofs marked sorry are the active frontier — the parts still being filled in this semester.
Highlight 1 — The Wigner–Inönü trace contradiction
The canonical commutation relation \([X, P] = i\hbar I\) cannot hold exactly for finite \(n \times n\) matrices: the trace of any commutator is zero, yet the trace of \(i\hbar I_n\) is \(n i\hbar \neq 0\). This contradiction is exactly why quantum mechanics needs an infinite-dimensional Hilbert space — and it is one of the first things my formalization pins down.
Mathematics
\[\operatorname{Tr}([X, P]) = \operatorname{Tr}(XP - PX) = 0\]
\[\operatorname{Tr}(i\hbar I_n) = n\, i\hbar \neq 0\]
So \([X, P] = i\hbar I\) has no finite-matrix solution.
Lean 4 · conceptual
-- Exact canonical commutation is impossible
-- for finite n × n complex matrices.
theorem finite_commutation_contradiction
(X P : Matrix (Fin n) (Fin n) ℂ)
(h_pos : n > 0) :
Matrix.trace (X * P - P * X)
≠ Matrix.trace (Complex.I • (1 : Matrix (Fin n) (Fin n) ℂ))
:= by
sorry -- machine-checked proof in Lean 4
Highlight 2 — Pauli spin matrix commutation
For the concrete \(2 \times 2\) case, the commutator collapses to a fixed matrix, so Lean's decide tactic can close it by brute-force computation over the complex entries — a fully machine-checked result with no sorry.
Mathematics
\[[\sigma_x, \sigma_y] = 2i\,\sigma_z\]
\[\sigma_x \sigma_y - \sigma_y \sigma_x = \begin{pmatrix} 2i & 0 \\ 0 & -2i \end{pmatrix}\]
The angular-momentum algebra of spin-½, verified term by term.
Lean 4 · decision procedure
-- Mechanically verified by Lean's decide tactic
theorem pauli_comm_xy :
Matrix.commutator Pauli.sigma_x Pauli.sigma_y
= 2 * Complex.I • Pauli.sigma_z := by
decide
Project roadmap & semester milestones
This is a multi-year formalization journey, not a one-off assignment. Tracking it publicly keeps me honest and shows the long game to anyone reading.
- Part 01now Curriculum foundation. Linear Algebra 1 (MAT 423), Calculus 1 (MAT 421), and Problem Solving (CSC 415) — building the mathematical bedrock the formalization will rest on.
- Part 02–03next Tooling & prototyping. Lean 4 setup, exploring Mathlib's complex inner-product spaces, and Python/NumPy prototyping (DSC551) to sanity-check spectra numerically before proving them.
-
Part 04–05planned
Pre-FYP proposal (MSP660) and formalizing the core state-vector modules —
State.lean,Operator.lean. -
Part 06planned
Full execution.
Pauli.lean, the Wigner–Inönü trace-contradiction proof, thesis completion, and viva defense. - Part 07planned Open-source release on GitHub and paper dissemination.
Proposal draft & how to follow along
The formal proposal is in progress for the MSP660 pre-FYP milestone. The public-facing pieces land here first:
- This page — a living write-up, updated as modules compile.
- GitHub repository — the Lean 4 project, linked here once the first module (
State.lean) is public. - Dev log — progress notes live on the today and September archive pages.
Interested in the mathematics behind it? Start with my Foundational Mathematics textbook, or browse the topics I keep circling back to.