Ket.normalize
defimported Lean
Create a ket out of a vector given it has a nonzero component
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open Classical in open BigOperators in open ComplexConjugate in open Kronecker in open scoped Matrix ComplexOrder in variable {d : Type*} [Fintype d] in noncomputable def Ket.normalize (v : d → ℂ) (h : ∃ x, v x ≠ 0) : Ket d
- Defined in
- QuantumInfo, `Ket.normalize`
- Lean proof
- By Alex Meiburg, Rodolfo Soldati, from github.com/leanprover-community/physlib at
e411c6e89692(Copyright (c) 2025 Alex Meiburg. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.34.1.Ket.normalize← Ket.normalize (QuantumInfo/States/Pure/Braket.lean:151): verbatim
- Verified
- 17 Oct 2026
- Axioms
- none listed
- Built on 5
- instKetOfBrainstKetOfBra
- instBraOfKetinstBraOfKet
- KetA ket as a vector of unit norm. We follow the convention in
Matrixof vectors as simple functions from a Fintype. Kets are distinctly… - Ket.applyKet.apply
- Braket.instFunLikeKetBraket.instFunLikeKet
- Used by 2
- Ket.prodThe outer product of two kets, creating an unentangled state.
- uniform_superpositionKet form by the superposition of all elements in
d. Commonly denoted by |+⟩, especially for qubits
Lean source view module on GitHub
set_option quotPrecheck false open Braket local notation "〈" ξ:90 "‖" ψ:90 "〉" => dot (ξ : Bra _) (ψ : Ket _) set_option autoImplicit true in set_option relaxedAutoImplicit true in open Classical in open BigOperators in open ComplexConjugate in open Kronecker in open scoped Matrix ComplexOrder in variable {d : Type*} [Fintype d] in /-- Create a ket out of a vector given it has a nonzero component -/ noncomputable def Ket.normalize (v : d → ℂ) (h : ∃ x, v x ≠ 0) : Ket d := { vec := fun x ↦ v x / √(∑ x : d, ‖v x‖ ^ 2), normalized' := by simp only [← Complex.normSq_eq_norm_sq, Complex.normSq_div, Complex.normSq_ofReal, ←sq] have hnonneg : ∑ x : d, Complex.normSq (v x) ≥ 0 := Fintype.sum_nonneg (fun x => Complex.normSq_nonneg (v x)) simp only [Real.sq_sqrt hnonneg, div_eq_inv_mul, ←Finset.mul_sum] apply inv_mul_cancel₀ by_contra hzero rw [Fintype.sum_eq_zero_iff_of_nonneg (fun x => Complex.normSq_nonneg (v x))] at hzero obtain ⟨a, ha⟩ := h have h₁ : (fun x => Complex.normSq (v x)) a ≠ 0 := by simp only [ne_eq, map_eq_zero]; exact ha exact h₁ (congrFun hzero a) }