Definitions for Exact synthesis of single-qubit unitaries over Clifford-cyclotomic gate sets
DefinitionQAlgorithms_Papers_Independent_Intakenext100_P03The objects the formalized statements of Exact synthesis of single-qubit unitaries over Clifford-cyclotomic gate sets (arXiv:1501.04944) are stated in. Each was checked against the paper by a blind read-back and a moderator.
BlochMathZero: The paper's H0, including its absolute phase, equation (2), PDF p.4.cliffordGroup: Exactly <H0,S>, using each generator and its adjoint, PDF p.4. The monoid closure is the group generated by these unitary matrices.cyclotomicZRotation: Uz(theta)=diag(1,exp(i theta)), equation (4), PDF p.4.cyclotomicRoot: The root zeta_m=exp(2 pi i/m), PDF p.4; only positive m occurs in results.cyclotomicSynthesisRing: R_n as an actual subring of C, PDF p.4.integerRing: Z[zeta_(2n)], PDF pp.19,21.cyclotomicGroup: G_n=<C,Uz(pi/n)>, equation (3), PDF p.4. Adjoint generators implement inverses.ringUnitaries: Actual U_2(R_n), with no quotient by scalar phase, PDF pp.3,12.positiveAxisRotation: Positive-axis rotations, equation before (6), PDF p.5.homomorphicBloch: Homomorphic Bloch representation. Printed (9) has transposed indices; changed to Re tr(P_i U P_j U†)/2 because pp.11,17 use left cancellation and row patterns. This source correction requires independent moderation.blochCliffords: Image of the specifically generated Clifford group, PDF p.6.PhaseEquivalent: Equality up to a single global phase, PDF p.5.SynthesisLetter: Gate words for Definition 2.1, PDF p.5. A rotation letter has positive unit cost; any member of the source's precise Clifford group has cost zero.synthesisWordMatrix: A word is multiplied in the source's printed left-to-right order, PDF p.5.synthesisWordCost: Actual number of elementary Uz(pi/n) occurrences, PDF p.5.minimumRotationCost: T_n(U), the least achievable word cost modulo global phase, PDF p.5. The fallback 0 is off-domain only: all uses below assume U in G_n, where a positive-letter word exists (inverse rotations have finite order 2n).canonicalProduct: Product of canonical rotations in printed order, equation (14), PDF p.7.IsCyclotomicCanonical: Precisely the canonical-form constraints; optimality is not a premise, Lemma 3.1, PDF p.7. The empty list is allowed.canonicalCost: The canonical non-Clifford cost, equation (24), PDF p.10.IsTwoPower: Power-of-two test, equations (23),(32), PDF pp.10,15.denominatorWeight: q_a, equation (23), PDF p.10, verified in the PDF. The quotient is n/gcd(a,n). For valid a and n=2^k s, a power-of-two quotient has 2<=j<=k, so both natural subtractions here agree with integer subtraction.denominatorBeta: beta, equation (23), PDF p.10; k is positive in every use.denominatorAlpha: alpha=2^(2^(1-k))=2^(1/2^(k-1)), PDF p.15; no natural negative power.cosineNumerator: c_a, equivalently equation (33), PDF p.15. This is exactly the piecewise normalization (32), with exponent 1-2^(1-j) in its power-of-two branch.sineNumerator: s_a with the same normalization, equations (32),(33), PDF p.15.realCyclotomicField: Frac(R_n intersect R), realized inside C, PDF pp.10,18. The smallest subfield containing the real subring is its fraction field.numeratorField: The larger field K=Q({c_a,s_a},alpha), PDF p.15.InIntegers: Algebraic integrality in the named field, Appendix A, PDF pp.28-29.IntegerDivides: Divisibility requires nonzero divisor and integral quotient in F, Definition A.2, PDF pp.9,28. This is not divisibility in C.IntegerCoprime: Principal-ideal coprimality, expressed by the equivalent Bezout identity in O_F, Definition A.5, PDF p.29.IntegerUnit: Unit in O_F, rather than a nonzero element of C, PDF p.15.ReducedDenominator: A nonzero entry and a beta/alpha-reduced numerator, PDF pp.10,16.RowHasExponent: Row contains an entry with reduced exponent r, PDF p.10.RowHasCoprime: Row contains an entry whose normalized numerator is coprime to the base, PDF pp.10,17. Zero entries are explicitly excluded.DenominatorPattern: All three clauses of Theorems 4.1 and 6.3, PDF pp.10,16-17. Every comparison ranges over reduced nonzero entries. Row coprimality and attainment of both maxima are retained, not just a row upper bound.canonicalTotalWeight: N=sum q_ai, PDF p.10.MinusOneIsTwoPower: Positive t with 2^t=-1 modulo the odd part s; add 1 avoids natural negative integers. For s=1 this is true, as required, PDF p.13.zRotationsIn: Actual z-rotations inside a matrix group, PDF p.12.finiteZRotations: Equation (27), with endpoint represented by Fin(2n), PDF p.12.finitePhases: Equation (30), actual roots of unity, PDF p.13.unitPhases: Elements of R_n of complex modulus one, PDF p.13.equalityFraction: f_N, PDF pp.13-14. N is cast before division. All uses have N positive even.SmallParameter: Exactly the five parameters of Section 7 Parts 2-3, PDF pp.19-23.twoPrime: The unique prime above 2 on the five parameters, PDF p.19. Intersection of all primes containing 2 specifies it without choosing a prime or assuming the source's uniqueness result as an input. Outside those parameters no theorem uses this helper.integralValuation: Exponent of the prime ideal in an integral principal ideal, Definition 7.2, PDF p.19. emultiplicity uses ideal multiplication, not element divisibility.extendedOrder: Extended embedding that preserves infinity, PDF p.19.primeValuation: Additive ideal-normalized valuation on R_n, Definition 7.2, PDF p.19. A least dyadic denominator clears z, then its contribution to the valuation is subtracted. Both integral valuations are finite for nonzero arguments on the five parameters. Zero stays +infinity. The off-ring value is -infinity and is never used by the source statements.columnComplexity: mu(x,y)=-min(v_p(x),v_p(y)), Definition 7.3, PDF p.20. Normalized pairs have finite complexity even when one coordinate is zero.smallComplexity: mu_n=v_p(1+i), PDF p.20.IsBinaryRepresentative: Literal binary integral-basis representative of Z[zeta_(2n)] mod 2, PDF pp.21-22. It is an actual complex number, not an abstract residue class.NormSumEven: Mod 2 of the whole squared-modulus sum is zero, Lemma 7.5, PDF p.22.reducedColumn: The constructed pair (c_k,d_k), with order H0*Uz essential, PDF p.22.
import Definitions.Def_QAlgorithms_Defs_Gates
import Definitions.Def_QAlgorithms_Defs_QubitBlochMaps
/-!
Statement targets from Forest--Gosset--Kliuchnikov--McKinnon,
arXiv:1501.04944v2. Two encoding-level algorithm targets are explicitly deferred.
The frozen ordered Pauli basis is imported from QAlgorithms.Defs.QubitBlochMaps.
Paper-specific names distinguish concepts from unrelated frozen short names.
The Bloch map uses the homomorphic trace convention required by the source proof;
this transposes printed equation (9) and the printed elementary rotations.
Compilation and independent moderation are pending the batch handoff.
-/
noncomputable section
namespace QAlgorithms.Papers.Independent.Intakenext100.P03
open scoped BigOperators Classical
-- Reuse the Mathlib matrix type without declaring a second Mat.
local notation "Mat" => Matrix Bool Bool ℂ
abbrev BlochMat := Matrix (Fin 3) (Fin 3) ℝ
/-- The paper's H0, including its absolute phase, equation (2), PDF p.4. -/
def hZero : Mat :=
fun a b => if a && b then -(1 + Complex.I) / 2 else (1 + Complex.I) / 2
/-- Exactly <H0,S>, using each generator and its adjoint, PDF p.4.
The monoid closure is the group generated by these unitary matrices. -/
def cliffordGroup : Submonoid Mat :=
Submonoid.closure ({hZero, QAlgorithms.phaseS, star hZero,
star QAlgorithms.phaseS} : Set Mat)
/-- Uz(theta)=diag(1,exp(i theta)), equation (4), PDF p.4. -/
def cyclotomicZRotation (theta : ℝ) : Mat :=
Matrix.diagonal fun b => if b then Complex.exp (Complex.I * (theta : ℂ)) else 1
/-- The root zeta_m=exp(2 pi i/m), PDF p.4; only positive m occurs in results. -/
def cyclotomicRoot (m : ℕ) : ℂ := Complex.exp (2 * Real.pi * Complex.I / (m : ℂ))
/-- R_n as an actual subring of C, PDF p.4. -/
def cyclotomicSynthesisRing (n : ℕ) : Subring ℂ :=
Subring.closure ({cyclotomicRoot (2 * n), (2 : ℂ)⁻¹} : Set ℂ)
/-- Z[zeta_(2n)], PDF pp.19,21. -/
def integerRing (n : ℕ) : Subring ℂ :=
Subring.closure ({cyclotomicRoot (2 * n)} : Set ℂ)
/-- G_n=<C,Uz(pi/n)>, equation (3), PDF p.4. Adjoint generators implement inverses. -/
def cyclotomicGroup (n : ℕ) : Submonoid Mat :=
Submonoid.closure ((cliffordGroup : Set Mat) ∪
{cyclotomicZRotation (Real.pi / n), star (cyclotomicZRotation (Real.pi / n))})
/-- Actual U_2(R_n), with no quotient by scalar phase, PDF pp.3,12. -/
def ringUnitaries (n : ℕ) : Set Mat :=
{U | U ∈ Matrix.unitaryGroup Bool ℂ ∧ ∀ i j, U i j ∈ cyclotomicSynthesisRing n}
-- Ordered X,Y,Z coordinates (PDF p.4) reuse frozen QubitChannels.sigma.
/-- Positive-axis rotations, equation before (6), PDF p.5. -/
def positiveAxisRotation (p : Fin 3) (theta : ℝ) : Mat :=
((1 + Complex.exp (Complex.I * (theta : ℂ))) / 2) • (1 : Mat) +
((1 - Complex.exp (Complex.I * (theta : ℂ))) / 2) • QAlgorithms.QubitChannels.sigma p
/-- Homomorphic Bloch representation. Printed (9) has transposed indices;
changed to Re tr(P_i U P_j U†)/2 because pp.11,17 use left cancellation and
row patterns. This source correction requires independent moderation. -/
def homomorphicBloch (U : Mat) : BlochMat :=
fun i j => (Matrix.trace (QAlgorithms.QubitChannels.sigma i * U * QAlgorithms.QubitChannels.sigma j * star U)).re / 2
/-- Image of the specifically generated Clifford group, PDF p.6. -/
def blochCliffords : Set BlochMat := {M | ∃ C ∈ cliffordGroup, homomorphicBloch C = M}
/-- Equality up to a single global phase, PDF p.5. -/
def PhaseEquivalent (U V : Mat) : Prop :=
∃ phi : ℝ, U = Complex.exp (Complex.I * (phi : ℂ)) • V
/-- Gate words for Definition 2.1, PDF p.5. A rotation letter has positive unit
cost; any member of the source's precise Clifford group has cost zero. -/
inductive SynthesisLetter where
| clifford : {C : Mat // C ∈ cliffordGroup} → SynthesisLetter
| rotation : SynthesisLetter
/-- A word is multiplied in the source's printed left-to-right order, PDF p.5. -/
def synthesisWordMatrix (n : ℕ) (w : List SynthesisLetter) : Mat :=
(w.map fun g => match g with
| .clifford C => C.val
| .rotation => cyclotomicZRotation (Real.pi / n)).prod
/-- Actual number of elementary Uz(pi/n) occurrences, PDF p.5. -/
def synthesisWordCost (w : List SynthesisLetter) : ℕ :=
(w.map fun g => match g with
| .clifford _ => 0
| .rotation => 1).sum
/-- T_n(U), the least achievable word cost modulo global phase, PDF p.5.
The fallback 0 is off-domain only: all uses below assume U in G_n, where a
positive-letter word exists (inverse rotations have finite order 2n). -/
def minimumRotationCost (n : ℕ) (U : Mat) : ℕ :=
if h : ∃ c : ℕ, ∃ w : List SynthesisLetter,
synthesisWordCost w = c ∧ PhaseEquivalent U (synthesisWordMatrix n w)
then Nat.find h else 0
/-- Canonical data: the axis/exponent list and the actual residual matrix D,
not a nonunique phase/Clifford witness pair, PDF pp.6-7. -/
local notation "CanonicalData" => List (Fin 3 × ℕ) × Matrix Bool Bool ℂ
/-- Product of canonical rotations in printed order, equation (14), PDF p.7. -/
def canonicalProduct (n : ℕ) (d : CanonicalData) : Mat :=
(d.1.map fun pa => positiveAxisRotation pa.1 (pa.2 * Real.pi / n)).prod
/-- Precisely the canonical-form constraints; optimality is not a premise,
Lemma 3.1, PDF p.7. The empty list is allowed. -/
def IsCyclotomicCanonical (n : ℕ) (U : Mat) (d : CanonicalData) : Prop :=
(∀ pa ∈ d.1, 1 ≤ pa.2 ∧ pa.2 < n / 2) ∧
(∀ i : ℕ, ∀ x y : Fin 3 × ℕ,
d.1[i]? = some x → d.1[i + 1]? = some y → x.1 ≠ y.1) ∧
(∃ phi : ℝ, Complex.exp (Complex.I * (phi : ℂ)) • d.2 ∈ cliffordGroup) ∧
U = canonicalProduct n d * d.2
/-- The canonical non-Clifford cost, equation (24), PDF p.10. -/
def canonicalCost (n : ℕ) (d : CanonicalData) : ℕ :=
(d.1.map fun pa => min pa.2 (n / 2 - pa.2)).sum
/-- Power-of-two test, equations (23),(32), PDF pp.10,15. -/
def IsTwoPower (d : ℕ) : Prop := ∃ j : ℕ, d = 2 ^ j
/-- q_a, equation (23), PDF p.10, verified in the PDF. The quotient is
n/gcd(a,n). For valid a and n=2^k s, a power-of-two quotient has 2<=j<=k,
so both natural subtractions here agree with integer subtraction. -/
def denominatorWeight (n k a : ℕ) : ℕ :=
if IsTwoPower (n / Nat.gcd a n) then
2 ^ (k - 1) - 2 ^ (k - Nat.log 2 (n / Nat.gcd a n))
else 2 ^ (k - 1)
/-- beta, equation (23), PDF p.10; k is positive in every use. -/
def denominatorBeta (k : ℕ) : ℂ :=
if k = 1 then 2 else ((2 * Real.cos (Real.pi / (2 : ℝ) ^ k) : ℝ) : ℂ)
/-- alpha=2^(2^(1-k))=2^(1/2^(k-1)), PDF p.15; no natural negative power. -/
def denominatorAlpha (k : ℕ) : ℂ := ((2 : ℝ) ^ (1 / (2 : ℝ) ^ (k - 1)) : ℝ)
/-- c_a, equivalently equation (33), PDF p.15. This is exactly the piecewise
normalization (32), with exponent 1-2^(1-j) in its power-of-two branch. -/
def cosineNumerator (n k a : ℕ) : ℂ :=
denominatorAlpha k ^ denominatorWeight n k a * (Real.cos (Real.pi * a / n) : ℂ)
/-- s_a with the same normalization, equations (32),(33), PDF p.15. -/
def sineNumerator (n k a : ℕ) : ℂ :=
denominatorAlpha k ^ denominatorWeight n k a * (Real.sin (Real.pi * a / n) : ℂ)
/-- Frac(R_n intersect R), realized inside C, PDF pp.10,18. The smallest
subfield containing the real subring is its fraction field. -/
def realCyclotomicField (n : ℕ) : Subfield ℂ :=
Subfield.closure {z | z ∈ cyclotomicSynthesisRing n ∧ z.im = 0}
/-- The larger field K=Q({c_a,s_a},alpha), PDF p.15. -/
def numeratorField (n k : ℕ) : Subfield ℂ :=
Subfield.closure {z | z = denominatorAlpha k ∨ ∃ a : ℕ, 1 ≤ a ∧ a < n / 2 ∧
(z = cosineNumerator n k a ∨ z = sineNumerator n k a)}
/-- Algebraic integrality in the named field, Appendix A, PDF pp.28-29. -/
def InIntegers (F : Subfield ℂ) (z : ℂ) : Prop := z ∈ F ∧ IsIntegral ℤ z
/-- Divisibility requires nonzero divisor and integral quotient in F,
Definition A.2, PDF pp.9,28. This is not divisibility in C. -/
def IntegerDivides (F : Subfield ℂ) (b w : ℂ) : Prop :=
InIntegers F b ∧ InIntegers F w ∧ b ≠ 0 ∧
∃ q : ℂ, InIntegers F q ∧ w = b * q
/-- Principal-ideal coprimality, expressed by the equivalent Bezout identity
in O_F, Definition A.5, PDF p.29. -/
def IntegerCoprime (F : Subfield ℂ) (w b : ℂ) : Prop :=
InIntegers F w ∧ InIntegers F b ∧ ∃ u v : ℂ,
InIntegers F u ∧ InIntegers F v ∧ u * w + v * b = 1
/-- Unit in O_F, rather than a nonzero element of C, PDF p.15. -/
def IntegerUnit (F : Subfield ℂ) (w : ℂ) : Prop :=
InIntegers F w ∧ ∃ v : ℂ, InIntegers F v ∧ w * v = 1
/-- A nonzero entry and a beta/alpha-reduced numerator, PDF pp.10,16. -/
def ReducedDenominator (F : Subfield ℂ) (b : ℂ) (z : ℝ) (r : ℕ) : Prop :=
z ≠ 0 ∧ ∃ w : ℂ, InIntegers F w ∧ ¬ IntegerDivides F b w ∧
(z : ℂ) = w / b ^ r
/-- Row contains an entry with reduced exponent r, PDF p.10. -/
def RowHasExponent (F : Subfield ℂ) (b : ℂ) (M : BlochMat)
(i : Fin 3) (r : ℕ) : Prop := ∃ j, ReducedDenominator F b (M i j) r
/-- Row contains an entry whose normalized numerator is coprime to the base,
PDF pp.10,17. Zero entries are explicitly excluded. -/
def RowHasCoprime (F : Subfield ℂ) (b : ℂ) (M : BlochMat)
(i : Fin 3) (r : ℕ) : Prop :=
∃ j : Fin 3, M i j ≠ 0 ∧ ∃ w : ℂ, IntegerCoprime F w b ∧
(M i j : ℂ) = w / b ^ r
/-- All three clauses of Theorems 4.1 and 6.3, PDF pp.10,16-17.
Every comparison ranges over reduced nonzero entries. Row coprimality and
attainment of both maxima are retained, not just a row upper bound. -/
def DenominatorPattern (F : Subfield ℂ) (b : ℂ) (M : BlochMat)
(N q : ℕ) (p : Fin 3) : Prop :=
(∀ i j, M i j ≠ 0 → ∃ r, ReducedDenominator F b (M i j) r) ∧
(∀ i j r, ReducedDenominator F b (M i j) r → r ≤ N) ∧
(∃ i, RowHasExponent F b M i N) ∧
({i : Fin 3 | RowHasCoprime F b M i N} : Set (Fin 3)).ncard = 2 ∧
(∃! i : Fin 3, ¬ RowHasExponent F b M i N) ∧
(∀ i : Fin 3, ¬ RowHasExponent F b M i N →
(∀ j r, ReducedDenominator F b (M i j) r → r ≤ N - q) ∧
RowHasExponent F b M i (N - q) ∧ RowHasCoprime F b M i (N - q) ∧ i = p)
/-- N=sum q_ai, PDF p.10. -/
def canonicalTotalWeight (n k : ℕ) (d : CanonicalData) : ℕ :=
(d.1.map fun pa => denominatorWeight n k pa.2).sum
/-- Positive t with 2^t=-1 modulo the odd part s; add 1 avoids natural
negative integers. For s=1 this is true, as required, PDF p.13. -/
def MinusOneIsTwoPower (s : ℕ) : Prop :=
∃ t : ℕ, 0 < t ∧ Nat.ModEq s (2 ^ t + 1) 0
/-- Actual z-rotations inside a matrix group, PDF p.12. -/
def zRotationsIn (G : Set Mat) : Set Mat :=
{U | U ∈ G ∧ ∃ theta : ℝ, U = cyclotomicZRotation theta}
/-- Equation (27), with endpoint represented by Fin(2n), PDF p.12. -/
def finiteZRotations (n : ℕ) : Set Mat :=
{U | ∃ j : Fin (2 * n), U = cyclotomicZRotation (Real.pi * j.val / n)}
/-- Equation (30), actual roots of unity, PDF p.13. -/
def finitePhases (n : ℕ) : Set ℂ :=
{z | ∃ j : Fin (2 * n), z = cyclotomicRoot (2 * n) ^ j.val}
/-- Elements of R_n of complex modulus one, PDF p.13. -/
def unitPhases (n : ℕ) : Set ℂ := {z | z ∈ cyclotomicSynthesisRing n ∧ ‖z‖ = 1}
/-- f_N, PDF pp.13-14. N is cast before division. All uses have N positive even. -/
def equalityFraction (N : ℕ) : ℝ :=
(2 / (N : ℝ)) * (((Finset.range (N + 1)).filter fun n =>
0 < n ∧ Even n ∧ (cyclotomicGroup n : Set Mat) = ringUnitaries n).card : ℝ)
/-- Exactly the five parameters of Section 7 Parts 2-3, PDF pp.19-23. -/
def SmallParameter (n : ℕ) : Prop := n ∈ ({2, 4, 6, 8, 12} : Finset ℕ)
/-- The unique prime above 2 on the five parameters, PDF p.19.
Intersection of all primes containing 2 specifies it without choosing a
prime or assuming the source's uniqueness result as an input. Outside those
parameters no theorem uses this helper. -/
def twoPrime (n : ℕ) : Ideal (integerRing n) :=
sInf {p : Ideal (integerRing n) | p.IsPrime ∧ (2 : integerRing n) ∈ p}
/-- Exponent of the prime ideal in an integral principal ideal, Definition 7.2,
PDF p.19. emultiplicity uses ideal multiplication, not element divisibility. -/
def integralValuation (n : ℕ) (z : integerRing n) : ℕ∞ :=
emultiplicity (twoPrime n) (Ideal.span ({z} : Set (integerRing n)))
/-- Extended embedding that preserves infinity, PDF p.19. -/
def extendedOrder (v : ℕ∞) : EReal :=
if v = ⊤ then ⊤ else (v.toNat : EReal)
/-- Additive ideal-normalized valuation on R_n, Definition 7.2, PDF p.19.
A least dyadic denominator clears z, then its contribution to the valuation
is subtracted. Both integral valuations are finite for nonzero arguments
on the five parameters. Zero stays +infinity. The off-ring value is -infinity
and is never used by the source statements. -/
def primeValuation (n : ℕ) (z : ℂ) : EReal :=
if z = 0 then ⊤
else if h : ∃ d : ℕ, z * (2 : ℂ) ^ d ∈ integerRing n then
extendedOrder (integralValuation n
⟨z * (2 : ℂ) ^ Nat.find h, Nat.find_spec h⟩) -
(Nat.find h : EReal) * extendedOrder (integralValuation n 2)
else ⊥
/-- mu(x,y)=-min(v_p(x),v_p(y)), Definition 7.3, PDF p.20.
Normalized pairs have finite complexity even when one coordinate is zero. -/
def columnComplexity (n : ℕ) (x y : ℂ) : EReal :=
-min (primeValuation n x) (primeValuation n y)
/-- mu_n=v_p(1+i), PDF p.20. -/
def smallComplexity (n : ℕ) : EReal := primeValuation n (1 + Complex.I)
/-- Literal binary integral-basis representative of Z[zeta_(2n)] mod 2,
PDF pp.21-22. It is an actual complex number, not an abstract residue class. -/
def IsBinaryRepresentative (n : ℕ) (z : ℂ) : Prop :=
∃ a : Fin (Nat.totient (2 * n)) → Fin 2,
z = ∑ i, ((a i).val : ℂ) * cyclotomicRoot (2 * n) ^ i.val
/-- Mod 2 of the whole squared-modulus sum is zero, Lemma 7.5, PDF p.22. -/
def NormSumEven (n : ℕ) (a b : ℂ) : Prop :=
∃ q : integerRing n,
((Complex.normSq a + Complex.normSq b : ℝ) : ℂ) = 2 * (q : ℂ)
/-- The constructed pair (c_k,d_k), with order H0*Uz essential, PDF p.22. -/
def reducedColumn (n : ℕ) (x y : ℂ) (k : ℤ) : Bool → ℂ :=
(hZero * cyclotomicZRotation (Real.pi * (k : ℝ) / n)).mulVec (fun b => if b then y else x)
/-! Small sanity examples pin conventions and off-domain behavior. -/
example : hZero false false = (1 + Complex.I) / 2 := rfl
example : QAlgorithms.QubitChannels.sigma 0 = QAlgorithms.pauliX := by simp [QAlgorithms.QubitChannels.sigma]
example : cyclotomicZRotation 0 = 1 := by ext a b; cases a <;> cases b <;> simp [cyclotomicZRotation]
example : synthesisWordMatrix 4 [] = 1 := rfl
example : synthesisWordCost [.rotation, .rotation] = 2 := rfl
example (D : Mat) : canonicalProduct 2 ([], D) = 1 := rfl
example : canonicalCost 2 ([], (1 : Mat)) = 0 := rfl
example (n : ℕ) : (0 : ℂ) ∈ cyclotomicSynthesisRing n := (cyclotomicSynthesisRing n).zero_mem
example (n : ℕ) : primeValuation n 0 = ⊤ := by simp [primeValuation]
example : extendedOrder ⊤ = ⊤ := by simp [extendedOrder]
example : MinusOneIsTwoPower 1 := by
exact ⟨1, by decide, by decide⟩
example (theta : ℝ) : cyclotomicZRotation theta false false = 1 := rfl
example (theta : ℝ) : cyclotomicZRotation theta false true = 0 := by simp [cyclotomicZRotation]
example : hZero ∈ cliffordGroup := Submonoid.subset_closure (by simp)
example (n : ℕ) : cyclotomicZRotation (Real.pi / n) ∈ cyclotomicGroup n :=
Submonoid.subset_closure (Or.inr (by simp))
example (U : Mat) : PhaseEquivalent U U := by
exact ⟨0, by simp⟩
example (n : ℕ) : synthesisWordMatrix n [.rotation, .rotation] =
cyclotomicZRotation (Real.pi / n) * cyclotomicZRotation (Real.pi / n) := by simp [synthesisWordMatrix]
example (F : Subfield ℂ) (b : ℂ) (r : ℕ) :
¬ ReducedDenominator F b 0 r := by simp [ReducedDenominator]
example (F : Subfield ℂ) (b : ℂ) (i : Fin 3) (r : ℕ) :
¬ RowHasExponent F b (0 : BlochMat) i r := by
simp [RowHasExponent, ReducedDenominator]
example (n : ℕ) : IsBinaryRepresentative n 0 := by
exact ⟨fun _ => 0, by simp⟩
example (n : ℕ) : NormSumEven n 0 0 := by
exact ⟨0, by simp⟩
example : equalityFraction 0 = 0 := by simp [equalityFraction]
end QAlgorithms.Papers.Independent.Intakenext100.P03
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
QAlgorithms.Papers.Independent.Intakenext100.P03.BlochMat
is an abbreviation for the type of real matrices, with rows and columns indexed by .
QAlgorithms.Papers.Independent.Intakenext100.P03.DenominatorPattern
For any subfield of , complex number , real matrix , natural numbers , and row index , let be the elements of integral over . For row and column indices and , define the local condition
where the equality is in ; write for , and write for the condition that there exist and with , , , and in . The defined predicate is the conjunction of the following requirements: every nonzero entry satisfies for some natural number ; every satisfying any obeys ; at least one row satisfies ; exactly two rows satisfy ; exactly one row fails ; and every row failing has all its exponents bounded by , satisfies both and , and equals . Here is truncated natural-number subtraction, and no hypothesis is imposed. Exponent zero is included, , and division by zero is zero. The conjunction cannot hold when or , since the exceptional row would then be required both to fail and to satisfy .
QAlgorithms.Papers.Independent.Intakenext100.P03.InIntegers
For any subfield of and any , this predicate means that and is integral over , meaning that is a root of a monic polynomial with integer coefficients.
QAlgorithms.Papers.Independent.Intakenext100.P03.IntegerCoprime
For any subfield of and any , this predicate means that are integral over and that there exist , also integral over , such that
There is no separate nonzero requirement on either or ; if either is zero, the equation requires the other to have an inverse in that is integral over .
QAlgorithms.Papers.Independent.Intakenext100.P03.IntegerDivides
For any subfield of and any , this predicate means that and both belong to and are integral over , that , and that there exists , integral over , with . Thus the predicate is false when , including when .
QAlgorithms.Papers.Independent.Intakenext100.P03.IntegerUnit
For any subfield of and any , this predicate means that is integral over and that there exists , integral over , satisfying . In particular, the equation excludes .
QAlgorithms.Papers.Independent.Intakenext100.P03.IsBinaryRepresentative
For every natural number and complex number , being a binary representative means that there exist coefficients , each equal to or , such that
where is Euler’s totient function and the coefficients are regarded as complex numbers in the sum. Neither uniqueness of the coefficients nor any additional restriction on is required. This includes : since , the coefficient family and sum are empty, so precisely satisfies the condition.
QAlgorithms.Papers.Independent.Intakenext100.P03.IsCyclotomicCanonical
For every natural number , complex matrix , and datum consisting of a finite list of pairs and a complex matrix , this predicate requires all four of the following: every pair in satisfies ; for every natural index and pairs , if these occupy positions and of , then ; there exists a real such that belongs to the multiplicative submonoid generated by , where and ; and
The adjacency requirement applies only when both indexed entries exist. An empty list satisfies the first two requirements and makes the product the identity, so the last equality becomes . For , the exponent bounds force the list to be empty. All divisions by in the displayed factors take the value zero when .
QAlgorithms.Papers.Independent.Intakenext100.P03.IsTwoPower
For a natural number , this predicate means that there exists a natural number , including , such that . Thus is included and is excluded.
QAlgorithms.Papers.Independent.Intakenext100.P03.MinusOneIsTwoPower
For any natural number , this predicate means that there exists a natural number such that
equivalently, divides . The exponent must be strictly positive. The predicate holds for and fails for , since congruence modulo zero is equality and is positive.
QAlgorithms.Papers.Independent.Intakenext100.P03.NormSumEven
For every natural number and complex numbers , the condition means that there exists an element of the smallest subring of containing such that
as an equality in , with the real quantity on the left embedded into . No separate integrality or nonzero assumptions are imposed on . The case satisfies the condition with . The parameter is included: division by zero makes , so in that case the condition says that is twice an integer.
QAlgorithms.Papers.Independent.Intakenext100.P03.PhaseEquivalent
For complex matrices and , this predicate means that there exists a real number such that , where the scalar multiplies every entry of . Neither matrix is required to be unitary or nonzero; in particular, the zero matrix is phase equivalent to itself.
QAlgorithms.Papers.Independent.Intakenext100.P03.ReducedDenominator
For any subfield of , any , any real number , and any natural number , write . This predicate means that and there exists such that
No assumption that is nonzero or integral is imposed separately. The exponent may be zero, in which case even for ; when and , division by zero gives zero, so the required nonzero makes the predicate impossible.
QAlgorithms.Papers.Independent.Intakenext100.P03.RowHasCoprime
For any subfield of , complex number , real matrix , row index , and natural number , let consist of the elements of integral over . This predicate means that there exist a column index and , with , such that
There is no separate requirement that be nonzero. The exponent is allowed, including for ; if and , the nonzero-entry requirement is impossible because division by zero gives zero.
QAlgorithms.Papers.Independent.Intakenext100.P03.RowHasExponent
For any subfield of , complex number , real matrix , row index , and natural number , let consist of the elements of integral over . This predicate means that there exist a column index and such that
The exponent is allowed, with ; for and , this predicate is impossible because division by zero gives zero.
QAlgorithms.Papers.Independent.Intakenext100.P03.SmallParameter
For any natural number , this predicate means exactly
QAlgorithms.Papers.Independent.Intakenext100.P03.SynthesisLetter
This defines a type of letters with two forms: a Clifford letter carrying a complex matrix belonging to the multiplicative submonoid generated by , where , , and denotes conjugate transpose; or a rotation letter carrying no additional data. The generated submonoid consists of finite products of these generators, including the identity as the empty product.
QAlgorithms.Papers.Independent.Intakenext100.P03.blochCliffords
is the set of real matrices for which there exists a complex matrix that is a finite product of , allowing the empty product , and satisfies
where
All displayed matrices use Boolean order false, true, and denotes conjugate transpose.
QAlgorithms.Papers.Independent.Intakenext100.P03.canonicalCost
For every natural number and datum , where is a finite list of pairs and is a complex matrix, this defines
The axis and matrix do not affect the value. No canonicality assumption or exponent bounds are required. The empty list has cost , and any entry with contributes , because subtraction of natural numbers is truncated at zero.
QAlgorithms.Papers.Independent.Intakenext100.P03.canonicalProduct
For every natural number and datum , where is a finite list of pairs with and , and is a complex matrix, this defines the product in list order of the matrices
The component is unused, and no bounds on the exponents or conditions on consecutive axes are imposed. The empty product is . At , division by zero makes every angle zero and every factor .
QAlgorithms.Papers.Independent.Intakenext100.P03.canonicalTotalWeight
For any natural numbers and any data whose first component is a finite list of axis indices and natural numbers , this defines
Here the quotient and logarithm are natural-number operations, with the logarithm being the integer base-two logarithm, and every subtraction is truncated at zero, including the subtraction between the two powers. Natural-number division by zero and the logarithm of zero both return zero. The power-of-two condition includes . No canonical-form conditions on are required; the axis indices and the second component of are ignored, repeated entries are counted repeatedly, and an empty list gives zero. The definition also applies when or .
QAlgorithms.Papers.Independent.Intakenext100.P03.cliffordGroup
is the smallest multiplicative submonoid of complex matrices containing , where Boolean indices are ordered false, true,
and denotes conjugate transpose. Thus its elements are exactly the finite products of these four matrices, including the empty product ; the closure used here is closure under multiplication and inclusion of the identity.
QAlgorithms.Papers.Independent.Intakenext100.P03.columnComplexity
For every natural number and complex numbers , the column complexity is the extended real number
Here is defined as follows. Put , let be the smallest subring of containing , and let be the intersection of all prime ideals of containing . For , take the multiplicity of in the principal ideal , valued in , and regard it as an extended real number, sending infinite multiplicity to ; denote the result by . Then . For nonzero , if there is a natural number with , choose the least such and set , using extended real arithmetic; if no such exists, set . No positivity assumption on or nonzero assumption on is imposed. In particular, the complexity of is , and it is if either nonzero coordinate has no such . When , division by zero in the exponential is interpreted as zero, so and is the integer subring of .
QAlgorithms.Papers.Independent.Intakenext100.P03.cosineNumerator
For any natural numbers , this defines the complex number
Here and the cosine are real numbers embedded in ; the power defining is a real power. The division defining is natural-number division, is the natural-number logarithm, and every subtraction in the definition of and in is truncated at zero. Natural-number division by zero and are both zero. There are no positivity or range restrictions on ; in particular, when , real division by zero makes the cosine factor , so the result is .
QAlgorithms.Papers.Independent.Intakenext100.P03.cyclotomicGroup
For every natural number , is the smallest multiplicative submonoid of complex matrices containing every finite product of , together with and , where, in Boolean order false, true,
and denotes conjugate transpose. Its elements are exactly finite products of these six generators, including the empty product . Natural numbers are included: real division gives , so and this case is the submonoid generated by .
QAlgorithms.Papers.Independent.Intakenext100.P03.cyclotomicRoot
For every natural number , including , is the complex number
Division is the total complex division operation, so at the exponent is and the defined value is .
QAlgorithms.Papers.Independent.Intakenext100.P03.cyclotomicSynthesisRing
For every natural number , is the smallest unital subring of containing and . Equivalently, it consists of polynomial expressions in these two complex numbers with integer coefficients. The definition includes : since division by zero gives , this case is the subring .
QAlgorithms.Papers.Independent.Intakenext100.P03.cyclotomicZRotation
For every real , is the diagonal complex matrix indexed by Booleans, with diagonal entry at false and at true, and zero off the diagonal:
QAlgorithms.Papers.Independent.Intakenext100.P03.denominatorAlpha
For every natural number , this defines the complex number with zero imaginary part whose real value is
The outer exponentiation is real exponentiation, while is natural-number subtraction truncated at zero. In particular, both and give .
QAlgorithms.Papers.Independent.Intakenext100.P03.denominatorBeta
For every natural number , this defines the complex number
with the real value in the second branch regarded as a complex number with zero imaginary part. The definition includes , for which .
QAlgorithms.Papers.Independent.Intakenext100.P03.denominatorWeight
For arbitrary natural numbers , set , using natural-number division, whose value is when the divisor is . This defines the natural number
where every subtraction, both in the exponents and between the powers, is natural-number subtraction truncated at zero, and the natural-number logarithm takes value at . No positivity assumptions are imposed. In particular, satisfies the first condition and gives weight ; gives and weight ; and at , the weight is in the first branch and in the second.
QAlgorithms.Papers.Independent.Intakenext100.P03.equalityFraction
For every natural number , this defines the real number
Here is the smallest subring of containing and , and is the set of all complex unitary matrices whose entries lie in . To define , put
Let be the submonoid generated by , where denotes conjugate transpose; then is the submonoid generated by all elements of together with and . Generated submonoids consist of finite products and include the empty product, the identity matrix. The counted equality is equality of the complete sets of matrices. The cardinality is converted to a real number before multiplication; when , real division by zero gives zero and the defined value is zero.
QAlgorithms.Papers.Independent.Intakenext100.P03.extendedOrder
For any , this defines an extended real number by
Thus finite natural values are embedded into the real numbers, and the infinite value is sent to positive infinity; the output is never negative infinity.
QAlgorithms.Papers.Independent.Intakenext100.P03.finitePhases
For any natural number , this defines the set
When , the index set is empty, so this set is empty, even though complex division by zero is defined to return zero and hence the expression itself equals .
QAlgorithms.Papers.Independent.Intakenext100.P03.finiteZRotations
For any natural number , this defines the set of complex matrices
with Boolean rows and columns ordered as false, true. Membership requires the existence of such an index . When , there are no eligible indices, so the set is empty.
QAlgorithms.Papers.Independent.Intakenext100.P03.hZero
is the complex matrix indexed by Boolean row and column labels whose entry is when both labels are true, and otherwise, where . In the order false, true, it is
QAlgorithms.Papers.Independent.Intakenext100.P03.homomorphicBloch
For every complex matrix indexed by Booleans, with no unitarity hypothesis, is the real matrix whose entries, for all , are
Here denotes conjugate transpose, and the Boolean matrix indices are ordered false, true.
QAlgorithms.Papers.Independent.Intakenext100.P03.integerRing
For every natural number , is the smallest unital subring of containing , equivalently the set of polynomial expressions in that number with integer coefficients. The definition includes , when the exponential is because complex division by zero is zero, and the resulting subring is embedded in .
QAlgorithms.Papers.Independent.Intakenext100.P03.integralValuation
For every natural number and every element of the smallest subring containing , let be the intersection of all prime ideals of containing , with the empty intersection interpreted as the whole-ring ideal. This defines an element of by
where is the ideal generated by and divisibility is multiplication-based ideal divisibility: means that for some ideal of . The value is if these exponents are unbounded; in particular, gives . No positivity assumption on or nonzero assumption on is required, and no primality of the intersection is assumed.
QAlgorithms.Papers.Independent.Intakenext100.P03.minimumRotationCost
For every natural number and complex matrix , this defines the least natural number for which there exist a finite word containing exactly rotation letters and a real number such that , where is the product in word order obtained by interpreting each rotation letter as and each Clifford letter as its carried matrix. The allowed carried matrices form the multiplicative submonoid generated by , with and . Empty products are identities. If no such word exists, the defined value is ; thus a value of also occurs when no representation exists. There is no restriction on or assumption on ; at , division by zero makes every rotation factor the identity.
QAlgorithms.Papers.Independent.Intakenext100.P03.numeratorField
For any natural numbers , this defines the smallest subfield of containing and all the numbers
where real numbers are embedded in , uses real exponentiation, and, with ,
The quotient defining is natural-number division, is the natural-number logarithm with , and all natural-number subtractions are truncated at zero. Natural-number division by zero is zero. There are no restrictions on or ; for there are no eligible values of , so only is required as a generator.
QAlgorithms.Papers.Independent.Intakenext100.P03.positiveAxisRotation
For every and every real , is the complex matrix
where the rows and columns of the displayed matrices are ordered false, true.
QAlgorithms.Papers.Independent.Intakenext100.P03.primeValuation
For any natural number and any complex number , let be the smallest subring of containing , and let be the intersection of all prime ideals of containing , with an empty intersection equal to the whole-ring ideal. For , define as the supremum in of the natural numbers for which for some ideal of . Let be the corresponding extended real number, sending finite natural values to those real numbers and to . The declaration defines
The minimum may be zero. No finiteness assumptions on either order in the middle branch are imposed, so its arithmetic uses the total multiplication and subtraction operations on extended real numbers even when an order is infinite. The definition also includes , where complex division by zero makes .
QAlgorithms.Papers.Independent.Intakenext100.P03.realCyclotomicField
For every natural number , let be the smallest subring of containing and . This defines the smallest subfield of containing every whose imaginary part is zero:
The parameter may be zero; division by zero in is zero, so the exponential generator is then .
QAlgorithms.Papers.Independent.Intakenext100.P03.reducedColumn
For every natural number , complex numbers , and integer , the reduced column is the function on the two Boolean values whose components, ordered as false and true, are
Equivalently, it is obtained by multiplying first by and then by . There are no normalization or nonzero assumptions on the column, and may be negative. When , the angle is defined to be zero, so the exponential factor is .
QAlgorithms.Papers.Independent.Intakenext100.P03.ringUnitaries
For every natural number , is the set of complex matrices , indexed by Booleans, such that is unitary and every entry , for all Boolean row and column labels , belongs to the smallest unital subring of containing and . Here unitarity means . The parameter is included; in that case the entry ring is , since the exponential defined using division by zero is .
QAlgorithms.Papers.Independent.Intakenext100.P03.sineNumerator
For any natural numbers , this defines the complex number
Here and the sine are real numbers embedded in ; the power defining is a real power. The division defining is natural-number division, is the natural-number logarithm, and all displayed subtractions involving natural numbers are truncated at zero. Natural-number division by zero and are both zero. No positivity or range restrictions are imposed on ; when , real division by zero makes the sine factor zero, so the result is zero.
QAlgorithms.Papers.Independent.Intakenext100.P03.smallComplexity
For every natural number , the small complexity is the extended real number . To define this value, put , let be the smallest subring of containing , and let be the intersection of all prime ideals of containing . For , let be the extended real value of the multiplicity of in the principal ideal , with infinite multiplicity represented by . If some natural number satisfies , choose the least such ; the small complexity is
If no such exists, it is . These operations use extended real arithmetic. The definition includes : then the exponential uses division by zero equal to zero, is the integer subring of , and no such exists, so the small complexity is .
QAlgorithms.Papers.Independent.Intakenext100.P03.synthesisWordCost
For every finite list of letters, this defines its cost as the sum of for each Clifford letter and for each rotation letter, hence the number of rotation letters in the list. A Clifford letter carries a complex matrix in the multiplicative submonoid generated by , where and ; a rotation letter has no payload. The empty list has cost .
QAlgorithms.Papers.Independent.Intakenext100.P03.synthesisWordMatrix
For every natural number , including , and every finite list of letters, this defines a complex matrix by replacing each Clifford letter by its carried matrix and each rotation letter by , then multiplying the resulting matrices in list order. A carried Clifford matrix must belong to the multiplicative submonoid generated by , where and ; this submonoid includes the empty product. An empty word evaluates to the identity matrix. Division by zero is defined to be zero here, so when , every rotation letter also evaluates to the identity matrix.
QAlgorithms.Papers.Independent.Intakenext100.P03.twoPrime
For any natural number , let be the smallest subring of containing . This defines the ideal
Thus it takes the infimum, under ideal inclusion, of all prime ideals containing ; the definition imposes no additional condition that this intersection itself be prime. If the indexing collection is empty, its intersection is the whole-ring ideal. The definition includes , for which division by zero makes the exponential generator equal to and .
QAlgorithms.Papers.Independent.Intakenext100.P03.unitPhases
For any natural number , let be the smallest subring of containing and . This defines
The parameter need not be positive. For , division by zero makes the exponential generator equal to , so and the defined set is .
QAlgorithms.Papers.Independent.Intakenext100.P03.zRotationsIn
For any set of complex matrices indexed by Boolean values, this defines the set
where rows and columns are ordered as false, true. The angle is unrestricted and need not be unique; no assumptions on are imposed.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.