AFTD Auto-Formalizing Theoretical Domains

phase_query_gram_psd_nonneg

theoremverified

Pairing a real positive-semidefinite matrix with a complex Gram matrix has a nonnegative real value.

Statement

theorem phase_query_gram_psd_nonneg {X B : Type} [Fintype X] [Fintype B] (A : Matrix X X ℝ)
    (hA : A.PosSemidef) (v : B → X → ℂ) :
    0 ≤ ∑ b, ∑ x, ∑ y, A x y * ((v b x).re * (v b y).re + (v b x).im * (v b y).im)
Source
Elementary positive-semidefinite matrix inequality for the query Gram SDP, https://arxiv.org/abs/quant-ph/0703141.
Verified
17 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The theorem states that contracting a real positive-semidefinite matrix $A$ with a complex Gram-like matrix is nonnegative. The proof first reduces the inequality to each index $b \in B$. For a fixed $b$, the summand decomposes into the real and imaginary components of $v(b, \cdot)$, yielding a sum of two real quadratic forms $u^T A u + w^T A w$. Since $A$ is positive semidefinite, both quadratic forms are nonnegative, and their sum is therefore nonnegative.

  1. It suffices to show that for every $b \in B$, the inner sum $\sum_{x, y} A_{x, y} (\operatorname{Re}(v(b, x))\operatorname{Re}(v(b, y)) + \operatorname{Im}(v(b, x))\operatorname{Im}(v(b, y)))$ is nonnegative.

    Since a finite sum of nonnegative terms is nonnegative (`Finset.sum_nonneg`), it suffices to prove the inequality for each term in the outer sum over $b \in B$. We fix an arbitrary index $b$.

    lines 7–8

    uses Finset.sum_nonneg

      apply Finset.sum_nonneg
      intro b hb
  2. The quadratic forms $\sum_{x, y} \operatorname{Re}(v(b, x)) (A_{x, y} \operatorname{Re}(v(b, y)))$ and $\sum_{x, y} \operatorname{Im}(v(b, x)) (A_{x, y} \operatorname{Im}(v(b, y)))$ are both nonnegative.

    Because $A$ is positive semidefinite, the quadratic form $u^* A u$ is nonnegative for any vector $u$. Applying this to the real part $x \mapsto \operatorname{Re}(v(b, x))$ and imaginary part $x \mapsto \operatorname{Im}(v(b, x))$, and expanding the matrix-vector multiplication (`Matrix.mulVec`) and dot product (`dotProduct`) with trivial conjugation on $\mathbb{R}$ (`star_trivial`) and distributivity (`Finset.mul_sum`), shows that both expanded double sums are nonnegative.

    lines 9–11

    uses star_trivial, dotProduct, Matrix.mulVec, Finset.mul_sum

      have hr := hA.dotProduct_mulVec_nonneg (fun x => (v b x).re)
      have hi := hA.dotProduct_mulVec_nonneg (fun x => (v b x).im)
      simp only [star_trivial, dotProduct, Matrix.mulVec, Finset.mul_sum] at hr hi
  3. The inner sum $\sum_{x, y} A_{x, y} (\operatorname{Re}(v(b, x))\operatorname{Re}(v(b, y)) + \operatorname{Im}(v(b, x))\operatorname{Im}(v(b, y)))$ is nonnegative.

    Adding the two inequalities gives that the sum of the real and imaginary quadratic forms is nonnegative (`add_nonneg`). Rewriting by combining the double sums (`Finset.sum_add_distrib`) and rearranging terms via commutativity and distributivity of multiplication (`mul_add`, `mul_comm`, `mul_left_comm`, `mul_assoc`) shows that this sum matches the target double sum, closing the goal.

    lines 12–13

    uses add_nonneg, Finset.sum_add_distrib, mul_add, mul_comm, mul_left_comm, mul_assoc

      have h := add_nonneg hr hi
      simpa only [← Finset.sum_add_distrib, mul_add, mul_comm, mul_left_comm, mul_assoc] using h
Finset.sum_nonneg
A finite sum of nonnegative terms is nonnegative.
star_trivial
For types with trivial involution, such as the real numbers, the star operation (conjugation) is the identity.
dotProduct
The standard dot product of two vectors, defined by $(u \cdot w) = \sum_i u_i w_i$.
Matrix.mulVec
Matrix-vector multiplication, defining the vector $(M v)_i = \sum_j M_{i, j} v_j$.
Finset.mul_sum
Left multiplication distributes over finite sums: $a \sum_i f(i) = \sum_i a f(i)$.
add_nonneg
The sum of two nonnegative elements is nonnegative.
Finset.sum_add_distrib
The sum of two functions over a finite set equals the sum of their individual sums: $\sum_i (f(i) + g(i)) = \sum_i f(i) + \sum_i g(i)$.
mul_add
Multiplication distributes over addition from the left: $a(b + c) = ab + ac$.
mul_comm
Multiplication is commutative: $ab = ba$.
mul_left_comm
In a commutative semigroup, factors associate and commute on the left: $a(bc) = b(ac)$.
mul_assoc
Multiplication is associative: $(ab)c = a(bc)$.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

open scoped BigOperators/-- Real Gram pairings with positive-semidefinite matrices are nonnegative. -/theorem phase_query_gram_psd_nonneg {X B : Type} [Fintype X] [Fintype B] (A : Matrix X X ℝ)    (hA : A.PosSemidef) (v : B → X → ℂ) :    0 ≤ ∑ b, ∑ x, ∑ y, A x y * ((v b x).re * (v b y).re + (v b x).im * (v b y).im) := by  apply Finset.sum_nonneg  intro b hb  have hr := hA.dotProduct_mulVec_nonneg (fun x => (v b x).re)  have hi := hA.dotProduct_mulVec_nonneg (fun x => (v b x).im)  simp only [star_trivial, dotProduct, Matrix.mulVec, Finset.mul_sum] at hr hi  have h := add_nonneg hr hi  simpa only [← Finset.sum_add_distrib, mul_add, mul_comm, mul_left_comm, mul_assoc] using h
See it in the graphDiscuss this resultChallenge it