Imports
/- Copyright (c) 2026 Bjørn Kjos-Hanssen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bjørn Kjos-Hanssen -/ module public import Mathlib.Data.Matrix.PEquiv public import Mathlib.Probability.Distributions.Poisson.Basic public import Mathlib.Analysis.Normed.Lp.lpSpace

Quantum harmonic oscillator

Annihilation operator.

def a (x : ) : := fun n => (n + 1) * x (n + 1)
def aLin : ( ) →ₗ[] ( ) := { toFun := a map_add' := (x y : ), a (x + y) = a x + a y (x y : ), (fun n => (n + 1) * (x + y) (n + 1)) = (fun n => (n + 1) * x (n + 1)) + fun n => (n + 1) * y (n + 1) x: y: (fun n => (n + 1) * (x + y) (n + 1)) = (fun n => (n + 1) * x (n + 1)) + fun n => (n + 1) * y (n + 1) x: y: n:(n + 1) * (x + y) (n + 1) = ((fun n => (n + 1) * x (n + 1)) + fun n => (n + 1) * y (n + 1)) n x: y: n:(n + 1) * (x (n + 1) + y (n + 1)) = (n + 1) * x (n + 1) + (n + 1) * y (n + 1) All goals completed! 🐙 map_smul' := (m : ) (x : ), a (m x) = (RingHom.id ) m a x m:x: a (m x) = (RingHom.id ) m a x m:x: (fun n => (n + 1) * (m x) (n + 1)) = (RingHom.id ) m fun n => (n + 1) * x (n + 1) m:x: n:(n + 1) * (m x) (n + 1) = ((RingHom.id ) m fun n => (n + 1) * x (n + 1)) n m:x: n:(n + 1) * (m * x (n + 1)) = m * ((n + 1) * x (n + 1)) All goals completed! 🐙 }

Creation operator.

def a_dag (x : ) : := fun n => ite (n = 0) 0 (n * x (n - 1))
def a_dagLin : ( ) →ₗ[] ( ) := { toFun := a_dag map_add' := (x y : ), a_dag (x + y) = a_dag x + a_dag y (x y : ), (fun n => if n = 0 then 0 else n * (x + y) (n - 1)) = (fun n => if n = 0 then 0 else n * x (n - 1)) + fun n => if n = 0 then 0 else n * y (n - 1) x: y: (fun n => if n = 0 then 0 else n * (x + y) (n - 1)) = (fun n => if n = 0 then 0 else n * x (n - 1)) + fun n => if n = 0 then 0 else n * y (n - 1) x: y: n:(if n = 0 then 0 else n * (x + y) (n - 1)) = ((fun n => if n = 0 then 0 else n * x (n - 1)) + fun n => if n = 0 then 0 else n * y (n - 1)) n x: y: n:(if n = 0 then 0 else n * (x (n - 1) + y (n - 1))) = (if n = 0 then 0 else n * x (n - 1)) + if n = 0 then 0 else n * y (n - 1) x: y: n:(if n = 0 then 0 else n * x (n - 1) + n * y (n - 1)) = (if n = 0 then 0 else n * x (n - 1)) + if n = 0 then 0 else n * y (n - 1) x: y: n:h✝:n = 00 = 0 + 0x: y: n:h✝:¬n = 0n * x (n - 1) + n * y (n - 1) = n * x (n - 1) + n * y (n - 1) x: y: n:h✝:n = 00 = 0 + 0x: y: n:h✝:¬n = 0n * x (n - 1) + n * y (n - 1) = n * x (n - 1) + n * y (n - 1) All goals completed! 🐙 map_smul' := (m : ) (x : ), a_dag (m x) = (RingHom.id ) m a_dag x m:x: a_dag (m x) = (RingHom.id ) m a_dag x m:x: (fun n => if n = 0 then 0 else n * (m x) (n - 1)) = (RingHom.id ) m fun n => if n = 0 then 0 else n * x (n - 1) m:x: n:(if n = 0 then 0 else n * (m x) (n - 1)) = ((RingHom.id ) m fun n => if n = 0 then 0 else n * x (n - 1)) n m:x: n:(if n = 0 then 0 else n * (m * x (n - 1))) = if n = 0 then 0 else m * (n * x (n - 1)) All goals completed! 🐙 }def ε (n : ) (c : ) : := fun i => ite (i = n) c 0

Verify that a_dag really is the transpose of a.

i:j:_✝:¬j = 0_:j - 1 = ig₃:i + 1 = j(i + 1) = (starRingEnd ) (i + 1);All goals completed! 🐙

Verify that a |n + 1⟩ = √(n + 1) |n ⟩

All goals completed! 🐙 n:i:g₀:¬i = n0 = 0 All goals completed! 🐙

Verify that a† ∣n⟩ = √(n+1) ∣n+1⟩.

n:i:_✝:¬i = 0_:i - 1 = nh:i = n + 1(n + 1) * 1 = (n + 1); All goals completed! 🐙 n:i:_✝:¬i = 0_:¬i - 1 = nh✝:¬i = n + 1i * 0 = 0 All goals completed! 🐙
n:x: g:¬n = 0h:n - 1 + 1 = nn * n * x n = n * x n n:x: g:¬n = 0h:n - 1 + 1 = nn * n = n n:x: g:¬n = 0h:n - 1 + 1 = nn * n = n n:x: g:¬n = 0h:n - 1 + 1 = n0 n All goals completed! 🐙n:x: (n + 1) * (n + 1) * x n = (n + 1) * x n n:x: (n + 1) * (n + 1) = n + 1 n:x: (n + 1) * (n + 1) = (n + 1) n:x: 0 (n + 1) n:x: 0 n + 1 All goals completed! 🐙x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i(i + 1) * (i + 1) * ((i + 1) * x i - i * x i) - i * i * ((i + 1) * x i - i * x i) = (i + 1) * x i - i * x i x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i(i + 1) * (i + 1) = i + 1x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x ii * i = i x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i(i + 1) * (i + 1) = i + 1 x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i(i + 1) * (i + 1) = (i + 1) x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i0 (i + 1) All goals completed! 🐙 x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x ii * i = i x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x ii * i = i x: i:g₀:¬i = 0this✝:i - 1 + 1 = ithis:(i + 1) * x i - i * x i = x i0 i All goals completed! 🐙def coherentState (α : ) : := fun n : => Real.exp (-α^2 / 2) * α ^ n / (n.factorial)def probabilityOf (n : ) (α : ) : NNReal := coherentState α n^2, n:α:0 coherentState α n ^ 2 All goals completed! 🐙

Coherent state has a Poisson distribution.

n:α:this✝²:|n.factorial| = n.factorialthis✝¹:n.factorial ^ 2 = n.factorialthis✝: (a b : ), a = b a / n.factorial = b / n.factorialthis: (a b c d : ), a = b c = d a * c = b * d(α ^ 2) ^ n = (α ^ 2, ^ n) All goals completed! 🐙 n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 Real.exp (-α ^ 2, ) * α ^ 2, ^ n / n.factorial n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 Real.exp (-α ^ 2, ) * α ^ 2, ^ nn:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 n.factorial n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 Real.exp (-α ^ 2, ) * α ^ 2, ^ n n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 Real.exp (-α ^ 2, )n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 α ^ 2, ^ n n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 Real.exp (-α ^ 2, ) All goals completed! 🐙 n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 α ^ 2, ^ n All goals completed! 🐙 n:α:this✝:|n.factorial| = n.factorialthis:n.factorial ^ 2 = n.factorial0 n.factorial All goals completed! 🐙

The only eigenvectors of a are the coherent states.

α:v: h:v = (Complex.exp (α ^ 2 / 2) * v 0) coherentState αn:this✝:Complex.exp (α ^ 2 / 2) 0this:(n + 1).factorial = (n + 1) * n.factorial(n + 1) * v 0 * (α * α ^ n) / ((n + 1) * n.factorial) = v 0 * α * α ^ n / n.factorial α:v: h:v = (Complex.exp (α ^ 2 / 2) * v 0) coherentState αn:this✝:Complex.exp (α ^ 2 / 2) 0this:(n + 1).factorial = (n + 1) * n.factorial(n + 1) * v 0 * (α * α ^ n) / ((n + 1) * n.factorial) = v 0 * α * α ^ n / n.factorial All goals completed! 🐙
α:this:Complex.exp (α ^ 2 / 2) * coherentState α 0 = 1coherentState α = 1 coherentState α All goals completed! 🐙

None of the coherentState eigenvectors are proportional.

lemma distinct_eigenvectors_a (α β c : ) (hc : coherentState α = c coherentState β) : α = β := α:β:c:hc:coherentState α = c coherentState βα = β α:β:c:hc:coherentState α = c coherentState βh₀:coherentState α 0 = (c coherentState β) 0α = β α:β:c:hc:coherentState α = c coherentState βh₀:coherentState α 0 = (c coherentState β) 0h₁:coherentState α 1 = (c coherentState β) 1α = β α:β:c:hc:coherentState α = c coherentState βh₀:Complex.exp (-α ^ 2 / 2) = c * Complex.exp (-β ^ 2 / 2)h₁:Complex.exp (-α ^ 2 / 2) * α = c * (Complex.exp (-β ^ 2 / 2) * β)α = β α:β:c:hc:coherentState α = c coherentState βh₀:Complex.exp (-α ^ 2 / 2) = c * Complex.exp (-β ^ 2 / 2)h₁:Complex.exp (-α ^ 2 / 2) * α = c * (Complex.exp (-β ^ 2 / 2) * β)hc₀:c = 0α = βα:β:c:hc:coherentState α = c coherentState βh₀:Complex.exp (-α ^ 2 / 2) = c * Complex.exp (-β ^ 2 / 2)h₁:Complex.exp (-α ^ 2 / 2) * α = c * (Complex.exp (-β ^ 2 / 2) * β)hc₀:¬c = 0α = β α:β:c:hc:coherentState α = c coherentState βh₀:Complex.exp (-α ^ 2 / 2) = c * Complex.exp (-β ^ 2 / 2)h₁:Complex.exp (-α ^ 2 / 2) * α = c * (Complex.exp (-β ^ 2 / 2) * β)hc₀:c = 0α = β α:β:hc:coherentState α = 0 coherentState βh₀:Complex.exp (-α ^ 2 / 2) = 0 * Complex.exp (-β ^ 2 / 2)h₁:Complex.exp (-α ^ 2 / 2) * α = 0 * (Complex.exp (-β ^ 2 / 2) * β)α = β All goals completed! 🐙 α:β:c:hc:coherentState α = c coherentState βhc₀:¬c = 0A:h₀:A = c * Complex.exp (-β ^ 2 / 2)h₁:A * α = c * (Complex.exp (-β ^ 2 / 2) * β)α = β α:β:c:hc:coherentState α = c coherentState βhc₀:¬c = 0h₁:c * Complex.exp (-β ^ 2 / 2) * α = c * (Complex.exp (-β ^ 2 / 2) * β)α = β α:β:c:hc:coherentState α = c coherentState βhc₀:¬c = 0h₁:α = βα = β All goals completed! 🐙

Formal eigenvectors for a_dag (not in ℓ²(ℂ)) (fails at n=0) .

α::α 0n:hn:n 0g₀:¬n = 0this✝:(n - 1).factorial 0this:α ^ n = α * α ^ (n - 1)n * (α * α ^ (n - 1)) = n * α ^ (n - 1) * α All goals completed! 🐙
lemma a_dag_nullspace {v : } (hv : a_dag v = 0) : v = 0 := v: hv:a_dag v = 0v = 0 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0v = 0 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:v n = 0 n induction n with v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0v 0 = 0 0 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0this:(if 1 = 0 then 0 else 1 * v (1 - 1)) = 0 1v 0 = 0 0 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0this:v 0 = 0v 0 = 0 All goals completed! 🐙 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0 nv (n + 1) = 0 (n + 1) v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0 nthis:(if n + 2 = 0 then 0 else (n + 2) * v (n + 2 - 1)) = 0 (n + 2)v (n + 1) = 0 (n + 1) v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0this:(n + 2) = 0 v (n + 1) = 0v (n + 1) = 0 cases this with v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0h:(n + 2) = 0v (n + 1) = 0 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0h:(n + 2) = 0False v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0(n + 2) = 0 False v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 00 < n + 2 All goals completed! 🐙 v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = 0n:hn:v n = 0h:v (n + 1) = 0v (n + 1) = 0 All goals completed! 🐙v: hv:a_dag v = 0 v0 v = 0; All goals completed! 🐙 α:v: hv:a_dag v = α v:¬α = 0this:a_dag v 0 = (α v) 0v = 0 α:v: hv:a_dag v = α v:¬α = 0this:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0v = 0 α:v: hv:a_dag v = α v:¬α = 0this:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0n:v n = 0 n induction n with α:v: hv:a_dag v = α v:¬α = 0this:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0v 0 = 0 0 α:v: hv:a_dag v = α v:¬α = 0this:α = 0 v 0 = 0v 0 = 0;All goals completed! 🐙 α:v: hv:a_dag v = α v:¬α = 0this:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0n:hn:v n = 0 nv (n + 1) = 0 (n + 1) α:v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = α v:¬α = 0this:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0n:hn:v n = 0 nv (n + 1) = 0 (n + 1) α:v: hv:(fun n => if n = 0 then 0 else n * v (n - 1)) = α v:¬α = 0this✝:(if 0 = 0 then 0 else 0 * v (0 - 1)) = (α v) 0n:hn:v n = 0 nthis:(if n + 1 = 0 then 0 else (n + 1) * v (n + 1 - 1)) = (α v) (n + 1)v (n + 1) = 0 (n + 1) All goals completed! 🐙 α:v: a✝:v = 0a_dag v = α v α:a_dag 0 = α 0 α:(fun n => if n = 0 then 0 else n * 0 (n - 1)) = α 0 α:(fun n => 0) = 0 All goals completed! 🐙x: i:({ toFun := a, map_add' := aLin._proof_1, map_smul' := aLin._proof_2 } * { toFun := a_dag, map_add' := a_dagLin._proof_1, map_smul' := a_dagLin._proof_2 } - { toFun := a_dag, map_add' := a_dagLin._proof_1, map_smul' := a_dagLin._proof_2 } * { toFun := a, map_add' := aLin._proof_1, map_smul' := aLin._proof_2 }) x i = (a a_dag - a_dag a) x i All goals completed! 🐙n:g₀:¬n = 0(Real.exp (-0 ^ 2 / 2)) * 0 / n.factorial = 0 All goals completed! 🐙

The coherent state belongs to ℓ²(ℂ).

α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iHasSum (fun i => (α ^ 2) ^ i / i.factorial ^ 2) Complex.exp (α ^ 2) α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:HasSum (fun i => A ^ i / i.factorial ^ 2) Complex.exp A α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:HasSum (fun i => A ^ i / i.factorial) (Real.exp A) α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:x✝:A ^ x✝ / x✝.factorial = (NormedSpace.expSeries x✝) fun x => Aα:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:Real.exp = NormedSpace.exp α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:x✝:A ^ x✝ / x✝.factorial = (NormedSpace.expSeries x✝) fun x => A α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:x✝:A ^ x✝ / x✝.factorial = (↑x✝.factorial)⁻¹ * A ^ x✝ All goals completed! 🐙 α:this✝: (r : ), |r| = rthis: (i : ), (α ^ i) ^ 2 = (α ^ 2) ^ iA:Real.exp = NormedSpace.exp All goals completed! 🐙 }