AFTD Auto-Formalizing Theoretical Domains

qutrit_rank_four_block_product_from_three_lemmas

theoremverified

The normalized rank-four qutrit PPT block admits four product terms, conditional on phase selection, simultaneous real orthogonal diagonalization, and a fixed-phase spectral expansion.

Statement

theorem qutrit_rank_four_block_product_from_three_lemmas
    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)
    (hB : B.transpose = B)
    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =
      (Bᴴ * B + vecMulVec u (star u)) i j)
    (hphase : ∀ (R S : Matrix (Fin 3) (Fin 3) ℝ) (x y : Fin 3 → ℝ),
      LinearIndependent ℝ ![x, y] →
      ∃ c s a b : ℝ, c*c + s*s = 1 ∧
        ∀ i : Fin 3, (R.mulVec (fun j => s*x j + c*y j)) i -
          (S.mulVec (fun j => c*x j - s*y j)) i +
            b*(c*x i - s*y i) - a*(s*x i + c*y i) = 0)
    (hdiag : ∀ (n : ℕ) (R S : Matrix (Fin n) (Fin n) ℝ),
      R.transpose = R → S.transpose = S → R*S = S*R →
      ∃ (O : Matrix (Fin n) (Fin n) ℝ) (r s : Fin n → ℝ),
        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧
        R = O * Matrix.diagonal r * O.transpose ∧
        S = O * Matrix.diagonal s * O.transpose)
    (hfixed : ∀ (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)
      (O : Matrix (Fin 3) (Fin 3) ℝ) (lam : Fin 3 → ℂ)
      (v0 : Fin 3 → ℝ) (gamma : ℂ),
      O.transpose * O = 1 → O * O.transpose = 1 →
      (∀ i j, B i j = ∑ k, (O i k : ℂ) * lam k * (O j k : ℂ)) →
      (∀ i, u i = gamma * (v0 i : ℂ)) →
      ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),
        (∀ t i, star (v t i) = v t i) ∧
        (1 : Matrix (Fin 3) (Fin 3) ℂ) =
          ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧
        B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧
        Bᴴ * B + vecMulVec u (star u) =
          ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t))) :
    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),
      (∀ t i, star (v t i) = v t i) ∧
      (1 : Matrix (Fin 3) (Fin 3) ℂ) =
        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧
      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧
      Bᴴ * B + vecMulVec u (star u) =
        ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t))
Source
Helper for OP-693, in the rank-four normal-completion route related to https://arxiv.org/abs/0903.0090.
Verified
12 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • VThe ambient space $V = \mathbb{F}_p^n \times \mathbb{F}_p^n$ of pairs of coordinate vectors.

The proof, explained

The proof establishes that a rank-four qutrit block admits a four-term product representation by splitting into two geometric regimes based on whether the real and imaginary parts of the vector u* are linearly independent. In the nondegenerate case, a phase choice and 1x1 scalar border extend the 3x3 block to a 4x4 symmetric normal matrix, which is simultaneously real-orthogonally diagonalized to yield the four product terms. In the degenerate case, u has a fixed complex phase, which forces the 3x3 block B itself to be normal; simultaneously diagonalizing B in dimension 3 and invoking the fixed-phase spectral hypothesis then concludes the result.

  1. Block multiplication reduces normality of the bordered matrix N to its blocks, and the (2,1) block equality follows by conjugate transposition of the (1,2) block equality.

    Multiplying out N* N and N N* in 2x2 block form via Matrix.fromBlocks_multiply and Matrix.fromBlocks_conjTranspose leaves four block equations. Taking the conjugate transpose of the off-diagonal hypothesis h12 yields the (2,1) block equality.

    lines 15–20

    uses Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply, congrArg, Matrix.conjTranspose_add, Matrix.conjTranspose_mul

      dsimp only
      rw [Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply,
        Matrix.fromBlocks_multiply]
      have h21 : Wᴴ * B + Zᴴ * W.transpose = W.transpose * Bᴴ + Z * Wᴴ := by
        have h := congrArg Matrix.conjTranspose h12
        simpa [Matrix.conjTranspose_add, Matrix.conjTranspose_mul] using h
  2. The (2,2) block equation holds entrywise, completing the proof that N is normal.

    Because Fin 1 has a single element, the (2,2) block consists of a 1x1 matrix. Expanding the sum over the single index and applying the commutative ring properties proves the (2,2) block identity. Rewriting all four block identities finishes the proof of normality.

    lines 21–30

    uses Matrix.add_apply, Matrix.mul_apply, Fin.sum_univ_one, Matrix.conjTranspose_apply, Matrix.transpose_apply, Fin.sum_univ_three, Fin.eq_zero

      have h22 : Wᴴ * W + Zᴴ * Z = W.transpose * W.transposeᴴ + Z * Zᴴ := by
        ext i j
        fin_cases i
        fin_cases j
        simp only [Matrix.add_apply, Matrix.mul_apply, Fin.sum_univ_one,
          Matrix.conjTranspose_apply, Matrix.transpose_apply]
        simp only [Fin.sum_univ_three]
        simp only [Fin.eq_zero]
        ring
      rw [h11, h12, h21, h22]
  3. The matrix B is symmetric entrywise: B(a, b) = B(b, a).

    Applying congrArg to the assumption B^T = B at indices (b, a) gives B(a, b) = B(b, a).

    lines 40–44

    uses congrArg, Matrix.transpose_apply

      dsimp only
      ext i j
      have hs (a b : Fin 3) : B a b = B b a := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M b a) hB
        simpa only [Matrix.transpose_apply] using h
  4. The top-left block equality B* B + (W^T)* W^T = B B* + W W* holds.

    Evaluating entry (i, j) of the self-adjointness hypothesis hC for B* B + u u*, and substituting B(k, i) = B(i, k), simplifies the summation. Combining this with |ξ|^2 = 1 via a linear combination cancels the unwanted cross-terms and yields the desired block identity.

    lines 45–60

    uses Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_mul, star_star, Matrix.transpose_apply, Fin.sum_univ_one, Finset.sum_congr

      have hh := hC i j
      simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply,
        Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_mul, star_star] at hh
      simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.transpose_apply, Fin.sum_univ_one]
      dsimp [Matrix.transpose_apply, Matrix.conjTranspose_apply, Matrix.mul_apply]
      change (∑ k, star (B k i) * B k j) + star (ξ * star (u i)) * (ξ * star (u j)) =
        (∑ k, B i k * star (B j k)) + (ξ * star (u i)) * star (ξ * star (u j))
      simp only [hs i, hs j]
      simp only [star_mul, star_star]
      have hsum : (∑ k, star (B k j) * B k i) =
          ∑ k, B k i * star (B k j) := by
        apply Finset.sum_congr rfl
        intro k hk
        ring
      rw [hsum] at hh
      linear_combination -hh + (u i * star (u j) - star (u i) * u j) * hξ
  5. The off-diagonal block identity B* W + (W^T)* Z = B (W^T)* + W Z* holds. automation

    Equating entries (i, 0) of the off-diagonal blocks amounts to verifying real and imaginary parts using the symmetry of R and S and the linear condition hxy. Linear arithmetic over the real and imaginary parts closes both goals.

    lines 70–85

    uses congrArg, Matrix.transpose_apply, Fin.sum_univ_three, Complex.ext, Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_one, Complex.add_re, Complex.add_im, Complex.mul_re, Complex.mul_im

      dsimp only
      ext i j
      fin_cases j
      have hr (k : Fin 3) : R k i = R i k := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i k) hR
        simpa only [Matrix.transpose_apply] using h
      have hs (k : Fin 3) : S k i = S i k := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i k) hS
        simpa only [Matrix.transpose_apply] using h
      have hh := hxy i
      simp only [Matrix.mulVec, dotProduct, Fin.sum_univ_three] at hh
      apply Complex.ext <;>
        simp [Matrix.add_apply, Matrix.mul_apply, Matrix.transpose_apply,
          Matrix.conjTranspose_apply, Fin.sum_univ_three, Fin.sum_univ_one,
          Complex.add_re, Complex.add_im, Complex.mul_re, Complex.mul_im,
          hr, hs] <;> linarith
  6. The bordered matrix N is normal whenever the block identities h11 and h12 hold.

    Applying in767_whole_conditional_bordered_normality reduces the claim to verifying h11 and h12, which are provided by the previous two lemmas after substituting B = R + i S and W = x + i y.

    lines 102–113

    uses in767_whole_conditional_bordered_normality, in767_whole_conditional_bordered_h11, in767_whole_conditional_bordered_h12

      dsimp only
      apply in767_whole_conditional_bordered_normality
      · exact in767_whole_conditional_bordered_h11 B u ξ hB hC hξ
      · have h := in767_whole_conditional_bordered_h12 R S x y a b hR hS hxy
        have hb : B = fun i j => (R i j : ℂ) + Complex.I * (S i j : ℂ) := by
          ext i j
          exact hRS i j
        have hw : (fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i)) =
            (fun (i : Fin 3) (_ : Fin 1) => (x i : ℂ) + Complex.I * (y i : ℂ)) := by
          funext i j
          exact huw i
        simpa only [hb, hw] using h
  7. The real and imaginary parts R and S of B are symmetric matrices, and B = R + i S.

    Entrywise symmetry of B implies symmetry of R = Re(B) and S = Im(B). Expressing B as R + i S reconstructs each entry from its real and imaginary parts.

    lines 134–151

    uses congrArg, Matrix.transpose_apply, mul_comm, Complex.re_add_im

      dsimp only
      let R : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).re
      let S : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).im
      let x : Fin 3 → ℝ := fun i => c * (star (u i)).re - s * (star (u i)).im
      let y : Fin 3 → ℝ := fun i => s * (star (u i)).re + c * (star (u i)).im
      have hsym (i j : Fin 3) : B i j = B j i := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hB
        simpa only [Matrix.transpose_apply] using h
      have hR : R.transpose = R := by
        ext i j
        exact congrArg Complex.re (hsym j i)
      have hS : S.transpose = S := by
        ext i j
        exact congrArg Complex.im (hsym j i)
      have hRS : ∀ i j, B i j = (R i j : ℂ) + Complex.I * (S i j : ℂ) := by
        intro i j
        dsimp [R, S]
        simpa only [mul_comm] using (Complex.re_add_im (B i j)).symm
  8. Under the phase condition, the bordered matrix N is normal.

    The assumption c^2 + s^2 = 1 implies |ξ|^2 = 1, and the definition of x and y matches ξ u*. Invoking in767_whole_conditional_bordered_completion establishes that N is normal.

    lines 152–158

    uses Complex.ext, Complex.mul_re, Complex.mul_im, in767_whole_conditional_bordered_completion

      have hξ : ((c : ℂ) + Complex.I * (s : ℂ)) * star ((c : ℂ) + Complex.I * (s : ℂ)) = 1 := by
        apply Complex.ext <;> simp [Complex.mul_re, Complex.mul_im] <;> linarith
      have huw : ∀ i, ((c : ℂ) + Complex.I * (s : ℂ)) * star (u i) =
          (x i : ℂ) + Complex.I * (y i : ℂ) := by
        intro i
        apply Complex.ext <;> simp [x, y, Complex.mul_re, Complex.mul_im] <;> ring
      exact in767_whole_conditional_bordered_completion B u _ R S x y a b hB hRS hR hS hC hξ huw hphase
  9. The lower-right bordered relation equates B* B + u u* to B B* + W W*.

    Using |ξ|^2 = 1, the product (W^T)* W^T simplifies to the outer product vecMulVec u u*. Substituting this into h11 produces the desired relation.

    lines 168–178

    uses in767_whole_conditional_bordered_h11, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.transpose_apply, Matrix.vecMulVec_apply, Pi.star_apply, Fin.sum_univ_one, star_mul, star_star

      dsimp only
      have h := in767_whole_conditional_bordered_h11 B u ξ hB hC hξ
      dsimp only at h
      have hW : ((fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i))ᵀᴴ *
          (fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i))ᵀ) = vecMulVec u (star u) := by
        ext i j
        simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.transpose_apply,
          Matrix.vecMulVec_apply, Pi.star_apply, Fin.sum_univ_one, star_mul, star_star]
        linear_combination (u i * star (u j)) * hξ
      rw [hW] at h
      exact h
  10. Real-orthogonal diagonalization yields an explicit four-term product frame for I, B, and C.

    Taking the frame vectors to be the columns of O (which are real), a_t = 1, and b_t = star(λ_t), the identity resolution follows from O O^T = 1, while the expansions of B and C match the spectral hypotheses directly.

    lines 192–209

    uses congrArg, Matrix.mul_apply, Matrix.transpose_apply, Matrix.vecMulVec_apply, Matrix.one_apply, Matrix.sum_apply, Matrix.smul_apply, mul_comm, mul_left_comm, mul_assoc

      refine ⟨fun t i => (O i t : ℂ), fun _ => 1, fun t => star (lam t), ?_, ?_, ?_, ?_⟩
      · intro t i
        simp
      · ext i j
        have hr := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hO
        simp only [Matrix.mul_apply, Matrix.transpose_apply] at hr
        have hc : (∑ k, (O i k : ℂ) * (O j k : ℂ)) = ((1 : Matrix (Fin 3) (Fin 3) ℝ) i j : ℂ) := by
          exact_mod_cast hr
        by_cases hij : i = j <;>
          simpa [hij, Matrix.vecMulVec_apply, Matrix.one_apply, Matrix.sum_apply, Matrix.smul_apply,
            mul_comm, mul_left_comm, mul_assoc] using hc.symm
      · ext i j
        simpa [Matrix.vecMulVec_apply, Matrix.sum_apply, Matrix.smul_apply,
          mul_comm, mul_left_comm, mul_assoc] using hB i j
      · ext i j
        simpa [Matrix.vecMulVec_apply, Matrix.sum_apply, Matrix.smul_apply,
          mul_comm, mul_left_comm, mul_assoc] using hC i j
    
  11. A real-orthogonally diagonalized matrix N satisfies N N* = Q |Λ|^2 Q^T.

    Taking the conjugate transpose of N = Q Λ Q^T and using Q* = Q^T and Q^T Q = 1 reduces N N* to Q (Λ star(Λ)) Q^T by diagonal matrix multiplication.

    lines 217–225

    uses Matrix.conjTranspose_conjTranspose, Matrix.conjTranspose_mul, Matrix.diagonal_conjTranspose, Matrix.mul_assoc, Matrix.one_mul, Matrix.diagonal_mul_diagonal

      dsimp only
      have hreal' : Q.transposeᴴ = Q := by
        rw [← hreal, Matrix.conjTranspose_conjTranspose]
      rw [Matrix.conjTranspose_mul, Matrix.conjTranspose_mul, Matrix.diagonal_conjTranspose,
        hreal', hreal]
      simp only [Matrix.mul_assoc, ← Matrix.mul_assoc Q.transpose Q,
        horth, Matrix.one_mul, Matrix.diagonal_mul_diagonal]
      rw [← Matrix.mul_assoc (Matrix.diagonal lam) (Matrix.diagonal (star lam)) Q.transpose, Matrix.diagonal_mul_diagonal]
      rfl
  12. The submatrix V consisting of the first three rows of O satisfies V V^T = 1, and Q is real orthogonal.

    Projecting the orthogonality relation O O^T = 1 to the first three coordinates gives V V^T = 1. Viewing O as a complex matrix Q, reality gives Q* = Q^T and orthogonality follows from O^T O = 1.

    lines 242–262

    uses congrArg, Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply, Matrix.conjTranspose_apply

      let Q : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℂ := fun i j => O i j
      let V : Matrix (Fin 3) (Fin 4) ℝ := fun i j => O (Sum.inl i) j
      have hV : V * V.transpose = 1 := by
        ext i j
        have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℝ =>
          M (Sum.inl i) (Sum.inl j)) hcoorth
        simpa [V, Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply] using hh
      have hQreal : Qᴴ = Q.transpose := by
        ext i j
        simp [Q, Matrix.conjTranspose_apply, Matrix.transpose_apply]
      have hQorth : Q.transpose * Q = 1 := by
        ext i j
        have hh := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) horth
        simp only [Matrix.mul_apply, Matrix.transpose_apply] at hh
        change (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k j : ℂ)) = (1 : Matrix (Fin 4) (Fin 4) ℂ) i j
        by_cases hij : i = j
        · subst j
          have hh' : (∑ k : Fin 3 ⊕ Fin 1, O k i * O k i) = (1 : ℝ) := by simpa [Matrix.one_apply] using hh
          simpa [Matrix.one_apply] using (show (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k i : ℂ)) = 1 by exact_mod_cast hh')
        · have hh' : (∑ k : Fin 3 ⊕ Fin 1, O k i * O k j) = (0 : ℝ) := by simpa [Matrix.one_apply, hij] using hh
          simpa [Matrix.one_apply, hij] using (show (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k j : ℂ)) = 0 by exact_mod_cast hh')
  13. The bordered spectral decomposition induces the four-term product frame on the 3x3 block.

    By the normal square lemma, the (1,1) block of N N* equals B B* + W W* = C. Applying in767_whole_conditional_product_frame_of_diagonal to the submatrix V yields the product frame representation.

    lines 263–284

    uses in767_whole_conditional_real_diagonal_normal_square, Matrix.mul_apply, Matrix.mul_diagonal, Matrix.transpose_apply, in767_whole_conditional_product_frame_of_diagonal, congrArg, Matrix.fromBlocks_apply₁₁, Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply

      change Matrix.fromBlocks B W W.transpose Z = Q * Matrix.diagonal lam * Q.transpose at hN
      have hN2 : (Matrix.fromBlocks B W W.transpose Z) * (Matrix.fromBlocks B W W.transpose Z)ᴴ =
          Q * Matrix.diagonal (fun k => lam k * star (lam k)) * Q.transpose := by
        rw [hN]
        exact in767_whole_conditional_real_diagonal_normal_square Q lam hQreal hQorth
      have hm (f : Fin 4 → ℂ) (i j : Fin 3 ⊕ Fin 1) :
          (Q * Matrix.diagonal f * Q.transpose) i j =
            ∑ k, (O i k : ℂ) * f k * (O j k : ℂ) := by
        rw [Matrix.mul_apply]
        simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Q]
      apply in767_whole_conditional_product_frame_of_diagonal B C V lam hV
      · intro i j
        have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ =>
          M (Sum.inl i) (Sum.inl j)) hN
        simpa only [Matrix.fromBlocks_apply₁₁, hm, V] using hh
      · intro i j
        have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ =>
          M (Sum.inl i) (Sum.inl j)) hN2
        rw [hC]
        simpa only [Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply,
          Matrix.fromBlocks_apply₁₁, hm, V] using hh
    
  14. The spectral decomposition of the bordered matrix produces a four-term product frame for B* B + u u*.

    Combining the lower block identity relating C = B B* + W W* to B* B + u u* with the spectral frame bridge completes the product frame decomposition.

    lines 305–308

    uses in767_whole_conditional_spectral_frame_bridge, in767_whole_conditional_bordered_lower_block

      let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)
      apply in767_whole_conditional_spectral_frame_bridge B (Bᴴ * B + vecMulVec u (star u)) W Z O lam horth hcoorth
      · exact in767_whole_conditional_bordered_lower_block B u ξ hB hC hξ
      · exact hN
  15. The real and imaginary parts R and S of a 4x4 symmetric normal matrix N commute and are symmetric. automation

    Symmetry of N implies symmetry of R and S by taking real and imaginary parts of entries. Normality N* N = N N* means the commutator [R, S] vanishes, which is verified entrywise via linear arithmetic.

    lines 317–334

    uses congrArg, Matrix.transpose_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_four, Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re

      dsimp only
      have hs (i j : Fin 4) : N i j = N j i := by
        have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M j i) hsym
        simpa only [Matrix.transpose_apply] using h
      refine ⟨?_, ?_, ?_⟩
      · ext i j
        exact congrArg Complex.re (hs j i)
      · ext i j
        exact congrArg Complex.im (hs j i)
      · ext i j
        have hn := congrArg Complex.im (congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M i j) hnormal)
        simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_four,
          Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re] at hn
        simp only [Matrix.mul_apply, Fin.sum_univ_four]
        simp only [hs i, hs j] at hn
        simp only [hs i, hs j]
        linarith
    
  16. A 4x4 symmetric normal matrix admits simultaneous real orthogonal diagonalization. automation

    By the commutation lemma, R and S commute and are symmetric. Applying the simultaneous diagonalization hypothesis gives a real orthogonal O diagonalizing both, and assembling the eigenvalues as λ_k = r_k + i s_k diagonalizes N.

    lines 348–361

    uses in767_whole_conditional_normal_symmetric_parts_commute, congrArg, Matrix.mul_apply, Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_four, Complex.ext, Complex.mul_re, Complex.mul_im

      obtain ⟨hR, hS, hRS⟩ := in767_whole_conditional_normal_symmetric_parts_commute N hsym hnormal
      obtain ⟨O, r, s, horth, hcoorth, hr, hi⟩ := hdiag _ _ hR hS hRS
      refine ⟨O, fun k => (r k : ℂ) + Complex.I * (s k : ℂ), horth, hcoorth, ?_⟩
      dsimp only
      ext i j
      have hr' := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) hr
      have hi' := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) hi
      rw [Matrix.mul_apply] at hr' hi'
      simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_four] at hr' hi'
      rw [Matrix.mul_apply]
      apply Complex.ext <;>
        simp [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_four,
          Complex.mul_re, Complex.mul_im] <;> linarith
    
  17. The simultaneous diagonalization extends to matrices indexed by Fin 3 ⊕ Fin 1.

    Using finSumFinEquiv to transport N to a 4x4 matrix N4, N4 inherits symmetry and normality. The resulting 4x4 orthogonal matrix and spectrum are pulled back to Fin 3 ⊕ Fin 1.

    lines 375–408

    uses finSumFinEquiv, Matrix.transpose_submatrix, Matrix.conjTranspose_submatrix, Matrix.submatrix_mul_equiv, in767_whole_conditional_normal_symmetric_spectral_of_real_pair, congrArg, Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply, Matrix.mul_diagonal, Matrix.one_apply

      let e : Fin 3 ⊕ Fin 1 ≃ Fin 4 := finSumFinEquiv
      let N4 : Matrix (Fin 4) (Fin 4) ℂ := N.submatrix e.symm e.symm
      have hs4 : N4.transpose = N4 := by
        dsimp [N4]
        rw [Matrix.transpose_submatrix, hsym]
      have hn4 : N4ᴴ * N4 = N4 * N4ᴴ := by
        dsimp [N4]
        rw [Matrix.conjTranspose_submatrix, Matrix.submatrix_mul_equiv Nᴴ N e.symm e.symm e.symm,
          Matrix.submatrix_mul_equiv N Nᴴ e.symm e.symm e.symm, hnormal]
      obtain ⟨O4, lam, horth, hcoorth, hspec⟩ :=
        in767_whole_conditional_normal_symmetric_spectral_of_real_pair N4 hs4 hn4 hdiag
      let O : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℝ := fun i j => O4 (e i) j
      refine ⟨O, lam, ?_, ?_, ?_⟩
      · ext i j
        have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) horth
        simp only [Matrix.mul_apply, Matrix.transpose_apply] at h ⊢
        change (∑ k : Fin 3 ⊕ Fin 1, O4 (e k) i * O4 (e k) j) = _
        calc
          _ = ∑ k : Fin 4, O4 k i * O4 k j := e.sum_comp (fun k => O4 k i * O4 k j)
          _ = _ := h
      · ext i j
        have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M (e i) (e j)) hcoorth
        simp only [Matrix.mul_apply, Matrix.transpose_apply] at h ⊢
        change (∑ k : Fin 4, O4 (e i) k * O4 (e j) k) = _
        simpa only [Matrix.one_apply, e.injective.eq_iff] using h
      · dsimp only
        ext i j
        have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M (e i) (e j)) hspec
        change N i j = _
        have hN4 : N4 (e i) (e j) = N i j := by simp [N4]
        rw [hN4] at h
        rw [Matrix.mul_apply] at h ⊢
        simpa only [Matrix.mul_diagonal, Matrix.transpose_apply, O] using h
    
  18. In the nondegenerate case, phase completion and 4x4 diagonalization yield the four product terms.

    Under linear independence of Re(u*) and Im(u*), hphase provides phase parameters making the bordered matrix N normal and symmetric. Applying the 4x4 spectral lemma and bordered spectrum bridge produces the product terms.

    lines 436–457

    uses in767_whole_conditional_bordered_phase_completion, Matrix.fromBlocks_transpose, Matrix.transpose_transpose, in767_whole_conditional_normal_spectrum_sum_index, Complex.ext, Complex.mul_re, Complex.mul_im, in767_whole_conditional_four_products_of_bordered_spectrum

      obtain ⟨c, s, a, b, hunit, hxy⟩ := hphase (fun i j => (B i j).re)
        (fun i j => (B i j).im) (fun i => (star (u i)).re) (fun i => (star (u i)).im) hli
      let ξ : ℂ := (c : ℂ) + Complex.I * (s : ℂ)
      let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)
      let Z : Matrix (Fin 1) (Fin 1) ℂ := fun _ _ => (a : ℂ) + Complex.I * (b : ℂ)
      let N : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ := Matrix.fromBlocks B W W.transpose Z
      have hn : Nᴴ * N = N * Nᴴ := by
        exact in767_whole_conditional_bordered_phase_completion B u c s a b hB hC hunit hxy
      have hz : Z.transpose = Z := by
        ext i j
        fin_cases i
        fin_cases j
        rfl
      have hs : N.transpose = N := by
        dsimp [N]
        rw [Matrix.fromBlocks_transpose, hB, Matrix.transpose_transpose, hz]
      obtain ⟨O, lam, ho, hoc, hspec⟩ := in767_whole_conditional_normal_spectrum_sum_index N hs hn hdiag
      have hξ : ξ * star ξ = 1 := by
        dsimp [ξ]
        apply Complex.ext <;> simp [Complex.mul_re, Complex.mul_im] <;> linarith
      exact in767_whole_conditional_four_products_of_bordered_spectrum B u ξ Z O lam hB hC hξ ho hoc hspec
    
  19. When Re(u*) and Im(u*) are linearly dependent, u has a fixed complex phase.

    If Re(u*) = 0, taking γ = -i gives u = γ Im(u*). If Re(u*) ≠ 0, linear dependence implies Im(u*) is a real scalar multiple of Re(u*), so u = (1 - i t) Re(u*).

    lines 463–483

    uses Complex.ext, Complex.mul_re, Complex.mul_im, LinearIndependent.pair_iff'

      let x : Fin 3 → ℝ := fun i => (star (u i)).re
      let y : Fin 3 → ℝ := fun i => (star (u i)).im
      by_cases hx : x = 0
      · refine ⟨y, -Complex.I, ?_⟩
        intro i
        have hi := congrFun hx i
        dsimp [x] at hi
        apply Complex.ext <;> simp [y, Complex.mul_re, Complex.mul_im] at hi ⊢ <;> linarith
      · have hex : ∃ t : ℝ, t • x = y := by
          by_contra h
          apply hdep
          apply (LinearIndependent.pair_iff' hx).2
          intro t ht
          exact h ⟨t, ht⟩
        obtain ⟨t, ht⟩ := hex
        refine ⟨x, 1 - Complex.I * (t : ℂ), ?_⟩
        intro i
        have hi := congrFun ht i
        dsimp [x, y] at hi
        apply Complex.ext <;> simp [x, Complex.mul_re, Complex.mul_im] at hi ⊢ <;> linarith
    
  20. A fixed-phase vector u combined with self-adjointness of B* B + u u* implies B is normal.

    When u has a fixed phase, u_i star(u_j) is symmetric in i and j. Combining this with the entrywise self-adjointness of B* B + u u* cancels the outer product terms, proving B* B = B B*.

    lines 491–511

    uses congrArg, Matrix.transpose_apply, star_mul, Complex.star_def, Complex.conj_ofReal, Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_star, Finset.sum_congr

      have hs (i j : Fin 3) : B i j = B j i := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hB
        simpa only [Matrix.transpose_apply] using h
      have hup (i j : Fin 3) : u i * star (u j) = u j * star (u i) := by
        rw [hu i, hu j]
        simp only [star_mul, Complex.star_def, Complex.conj_ofReal]
        ring
      ext i j
      have hh := hC i j
      simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply,
        Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_mul, star_star] at hh
      simp only [Matrix.mul_apply, Matrix.conjTranspose_apply]
      simp only [hs i, hs j]
      have hsum : (∑ k, star (B k j) * B k i) = ∑ k, B k i * star (B k j) := by
        apply Finset.sum_congr rfl
        intro k hk
        ring
      rw [hsum] at hh
      have huij := hup i j
      linear_combination -hh - huij
    
  21. The real and imaginary parts of a 3x3 symmetric normal matrix commute and are symmetric. automation

    Identical to the 4x4 case: taking real and imaginary parts gives symmetry, and normality implies that the commutator [Re(N), Im(N)] vanishes.

    lines 519–535

    uses congrArg, Matrix.transpose_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_three, Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re

      dsimp only
      have hs (i j : Fin 3) : N i j = N j i := by
        have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hsym
        simpa only [Matrix.transpose_apply] using h
      refine ⟨?_, ?_, ?_⟩
      · ext i j
        exact congrArg Complex.re (hs j i)
      · ext i j
        exact congrArg Complex.im (hs j i)
      · ext i j
        have hn := congrArg Complex.im (congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M i j) hnormal)
        simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_three,
          Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re] at hn
        simp only [Matrix.mul_apply, Fin.sum_univ_three]
        simp only [hs i, hs j] at hn
        simp only [hs i, hs j]
        linarith
  22. A 3x3 symmetric normal matrix admits simultaneous real orthogonal diagonalization. automation

    Its real and imaginary parts are symmetric and commute, so the simultaneous diagonalization hypothesis in dimension 3 yields a real orthogonal matrix diagonalizing both parts.

    lines 550–563

    uses in767_whole_conditional_normal_symmetric_parts_commute_three, congrArg, Matrix.mul_apply, Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_three, Complex.ext, Complex.mul_re, Complex.mul_im

      obtain ⟨hR, hS, hRS⟩ := in767_whole_conditional_normal_symmetric_parts_commute_three N hsym hnormal
      obtain ⟨O, r, s, horth, hcoorth, hr, hi⟩ := hdiag _ _ hR hS hRS
      refine ⟨O, fun k => (r k : ℂ) + Complex.I * (s k : ℂ), horth, hcoorth, ?_⟩
      dsimp only
      ext i j
      have hr' := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hr
      have hi' := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hi
      rw [Matrix.mul_apply] at hr' hi'
      simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_three] at hr' hi'
      rw [Matrix.mul_apply]
      apply Complex.ext <;>
        simp [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_three,
          Complex.mul_re, Complex.mul_im] <;> linarith
    
  23. In the linearly independent case, the four-product decomposition follows from rank-4 bordered completion.

    Branching on linear independence of Re(u*) and Im(u*), the true branch is dispatched directly by in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum.

    lines 601–603

    uses in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum

      by_cases hli : LinearIndependent ℝ ![(fun i : Fin 3 => (star (u i)).re),
                                            (fun i : Fin 3 => (star (u i)).im)]
      · exact in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum B u hB hC hli hphase (hdiag 4)
  24. In the linearly dependent case, fixed-phase reduction and 3x3 spectral expansion yield the four product terms.

    When the real and imaginary parts are dependent, u has a fixed phase u = γ v0, which forces B to be normal. Diagonalizing B in dimension 3 and applying the fixed-phase spectral hypothesis hfixed produces the four product terms.

    lines 604–613

    uses in767_whole_conditional_dependent_re_im_fixed_phase, in767_whole_conditional_fixed_phase_block_normal, in767_whole_conditional_normal_symmetric_spectral_of_real_pair_three, congrArg, Matrix.mul_apply, Matrix.mul_diagonal, Matrix.transpose_apply

      · obtain ⟨v0, gamma, hu⟩ := in767_whole_conditional_dependent_re_im_fixed_phase u hli
        have hnorm : Bᴴ * B = B * Bᴴ := in767_whole_conditional_fixed_phase_block_normal B u v0 gamma hB hu hC
        obtain ⟨O, lam, ho, hoc, hspec⟩ :=
          in767_whole_conditional_normal_symmetric_spectral_of_real_pair_three B hB hnorm (hdiag 3)
        apply hfixed B u O lam v0 gamma ho hoc
        · intro i j
          have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M i j) hspec
          rw [Matrix.mul_apply] at h
          simpa only [Matrix.mul_diagonal, Matrix.transpose_apply] using h
        · exact hu
Matrix.fromBlocks_conjTranspose
The conjugate transpose of a 2x2 block matrix is the block matrix of conjugate transposes with off-diagonal blocks swapped.
Matrix.fromBlocks_multiply
The product of two 2x2 block matrices is given by block matrix multiplication.
congrArg
Applying a function preserves equality.
Matrix.conjTranspose_add
Conjugate transpose of a sum is the sum of conjugate transposes.
Matrix.conjTranspose_mul
Conjugate transpose of a product is the reversed product of conjugate transposes.
Fin.sum_univ_one
A sum over Fin 1 evaluates to the single term at index 0.
Matrix.conjTranspose_apply
Entry of conjugate transpose is the complex conjugate of the transposed entry.
Matrix.transpose_apply
Entry of transpose is the transposed entry.
Fin.sum_univ_three
A sum over Fin 3 is the sum of terms at indices 0, 1, and 2.
Fin.eq_zero
Any element of Fin 1 equals 0.
Matrix.add_apply
Entry of matrix sum is the sum of entries.
Matrix.mul_apply
Entry of matrix product is the inner product of row and column.
Matrix.vecMulVec_apply
Entry of outer product of two vectors is their product.
Pi.star_apply
Complex conjugate of a vector evaluated at an index is the conjugate of the entry.
star_add
Conjugation distributes over addition.
star_sum
Conjugation distributes over finite sums.
star_mul
Conjugation reverses multiplication.
star_star
Conjugation is an involution.
Finset.sum_congr
Sums of pointwise equal functions over the same finite set are equal.
Complex.ext
Two complex numbers are equal if their real and imaginary parts are equal.
Complex.add_re
Real part of a sum of complex numbers.
Complex.add_im
Imaginary part of a sum of complex numbers.
Complex.mul_re
Real part of a product of complex numbers.
Complex.mul_im
Imaginary part of a product of complex numbers.
in767_whole_conditional_bordered_normality
Normality of a symmetric bordered block matrix reduces to its first row/column block relations.
in767_whole_conditional_bordered_h11
Top-left block normality identity holds given symmetry and unimodular phase.
in767_whole_conditional_bordered_h12
Off-diagonal block normality identity holds from real-imaginary linear system.
mul_comm
Multiplication in commutative magmas is commutative.
Complex.re_add_im
A complex number equals its real part plus I times its imaginary part.
in767_whole_conditional_bordered_completion
A symmetric bordered block matrix is normal under phase and bordered scalar conditions.
Matrix.one_apply
Diagonal entries of identity matrix are 1 and off-diagonal entries are 0.
Matrix.sum_apply
Entry of a sum of matrices is the sum of their entries.
Matrix.smul_apply
Entry of scalar multiplication of a matrix is the scalar multiple of the entry.
mul_left_comm
Left commutativity of multiplication in commutative semigroups.
mul_assoc
Associativity of multiplication.
Matrix.conjTranspose_conjTranspose
Conjugate transpose is an involution on matrices.
Matrix.diagonal_conjTranspose
Conjugate transpose of a diagonal matrix conjugates its diagonal entries.
Matrix.mul_assoc
Matrix multiplication is associative.
Matrix.one_mul
Identity matrix is a left identity for matrix multiplication.
Matrix.diagonal_mul_diagonal
Product of two diagonal matrices has entries given by pointwise multiplication.
in767_whole_conditional_real_diagonal_normal_square
A real-orthogonally diagonalized matrix squared with its conjugate transpose has squared diagonal values.
Matrix.mul_diagonal
Multiplying a matrix on the right by a diagonal matrix scales its columns.
in767_whole_conditional_product_frame_of_diagonal
A matrix pair diagonalized by real orthogonal matrices yields a 4-term product frame.
Matrix.fromBlocks_apply₁₁
Top-left block entry of a block matrix.
in767_whole_conditional_spectral_frame_bridge
Spectral decomposition of a 4x4 bordered normal matrix induces a product frame on the 3x3 block.
in767_whole_conditional_bordered_lower_block
Lower-right bordered block identity equates B* B + u u* to B B* + W W*.
Fin.sum_univ_four
A sum over Fin 4 evaluates to the sum of terms at indices 0, 1, 2, 3.
Complex.star_def
Conjugate of complex number equals star definition.
Complex.conj_im
Imaginary part of complex conjugate.
Complex.conj_re
Real part of complex conjugate.
in767_whole_conditional_normal_symmetric_parts_commute
Real and imaginary parts of a symmetric normal matrix commute and are symmetric.
finSumFinEquiv
Equivalence between Fin 3 + Fin 1 and Fin 4.
Matrix.transpose_submatrix
Transpose of a submatrix.
Matrix.conjTranspose_submatrix
Conjugate transpose of a submatrix.
Matrix.submatrix_mul_equiv
Multiplication of submatrices via index equivalence.
in767_whole_conditional_normal_symmetric_spectral_of_real_pair
Real orthogonal simultaneous diagonalization of parts of a 4x4 symmetric normal matrix.
in767_whole_conditional_bordered_phase_completion
Normality of bordered matrix under phase selection and bordering scalar.
Matrix.fromBlocks_transpose
Transpose of a 2x2 block matrix.
Matrix.transpose_transpose
Transpose is an involution on matrices.
in767_whole_conditional_normal_spectrum_sum_index
Diagonalization of a 4x4 symmetric normal matrix indexed by Fin 3 + Fin 1.
in767_whole_conditional_four_products_of_bordered_spectrum
Product frame of four terms from bordered spectral decomposition.
LinearIndependent.pair_iff'
Two vectors with non-zero first vector are linearly independent iff the second is not a multiple of the first.
Complex.conj_ofReal
Complex conjugate of a real number viewed as complex is itself.
in767_whole_conditional_normal_symmetric_parts_commute_three
Real and imaginary parts of a 3x3 symmetric normal matrix commute and are symmetric.
in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum
Nondegenerate rank-4 case admits four product terms from phase selection and simultaneous diagonalization.
in767_whole_conditional_dependent_re_im_fixed_phase
Linearly dependent real and imaginary parts of u imply u has a fixed complex phase.
in767_whole_conditional_fixed_phase_block_normal
Fixed phase vector u and Hermiticity of B* B + u u* imply B is normal.
in767_whole_conditional_normal_symmetric_spectral_of_real_pair_three
Simultaneous real orthogonal diagonalization of a 3x3 symmetric normal matrix.

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 Matrixopen scoped BigOperators Matrix ComplexOrderset_option backward.isDefEq.respectTransparency falseset_option linter.unusedSimpArgs falseset_option linter.unnecessarySeqFocus false-- The normality of a symmetric bordered block reduces to its first row.private lemma in767_whole_conditional_bordered_normality    (B : Matrix (Fin 3) (Fin 3) ℂ)    (W : Matrix (Fin 3) (Fin 1) ℂ)    (Z : Matrix (Fin 1) (Fin 1) ℂ)    (h11 : Bᴴ * B + W.transposeᴴ * W.transpose = B * Bᴴ + W * Wᴴ)    (h12 : Bᴴ * W + W.transposeᴴ * Z = B * W.transposeᴴ + W * Zᴴ) :    let N := Matrix.fromBlocks B W W.transpose Z    Nᴴ * N = N * Nᴴ := by  dsimp only  rw [Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply,    Matrix.fromBlocks_multiply]  have h21 : Wᴴ * B + Zᴴ * W.transpose = W.transpose * Bᴴ + Z * Wᴴ := by    have h := congrArg Matrix.conjTranspose h12    simpa [Matrix.conjTranspose_add, Matrix.conjTranspose_mul] using h  have h22 : Wᴴ * W + Zᴴ * Z = W.transpose * W.transposeᴴ + Z * Zᴴ := by    ext i j    fin_cases i    fin_cases j    simp only [Matrix.add_apply, Matrix.mul_apply, Fin.sum_univ_one,      Matrix.conjTranspose_apply, Matrix.transpose_apply]    simp only [Fin.sum_univ_three]    simp only [Fin.eq_zero]    ring  rw [h11, h12, h21, h22]private lemma in767_whole_conditional_bordered_h11    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ) (ξ : ℂ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hξ : ξ * star ξ = 1) :    let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)    Bᴴ * B + W.transposeᴴ * W.transpose = B * Bᴴ + W * Wᴴ := by  dsimp only  ext i j  have hs (a b : Fin 3) : B a b = B b a := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M b a) hB    simpa only [Matrix.transpose_apply] using h  have hh := hC i j  simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply,    Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_mul, star_star] at hh  simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.transpose_apply, Fin.sum_univ_one]  dsimp [Matrix.transpose_apply, Matrix.conjTranspose_apply, Matrix.mul_apply]  change (∑ k, star (B k i) * B k j) + star (ξ * star (u i)) * (ξ * star (u j)) =    (∑ k, B i k * star (B j k)) + (ξ * star (u i)) * star (ξ * star (u j))  simp only [hs i, hs j]  simp only [star_mul, star_star]  have hsum : (∑ k, star (B k j) * B k i) =      ∑ k, B k i * star (B k j) := by    apply Finset.sum_congr rfl    intro k hk    ring  rw [hsum] at hh  linear_combination -hh + (u i * star (u j) - star (u i) * u j) * hξprivate lemma in767_whole_conditional_bordered_h12    (R S : Matrix (Fin 3) (Fin 3) ℝ) (x y : Fin 3 → ℝ) (a b : ℝ)    (hR : R.transpose = R) (hS : S.transpose = S)    (hxy : ∀ i, (R.mulVec y) i - (S.mulVec x) i + b*x i - a*y i = 0) :    let B : Matrix (Fin 3) (Fin 3) ℂ := fun i j => (R i j : ℂ) + Complex.I * (S i j : ℂ)    let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => (x i : ℂ) + Complex.I * (y i : ℂ)    let Z : Matrix (Fin 1) (Fin 1) ℂ := fun _ _ => (a : ℂ) + Complex.I * (b : ℂ)    Bᴴ * W + W.transposeᴴ * Z = B * W.transposeᴴ + W * Zᴴ := by  dsimp only  ext i j  fin_cases j  have hr (k : Fin 3) : R k i = R i k := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i k) hR    simpa only [Matrix.transpose_apply] using h  have hs (k : Fin 3) : S k i = S i k := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i k) hS    simpa only [Matrix.transpose_apply] using h  have hh := hxy i  simp only [Matrix.mulVec, dotProduct, Fin.sum_univ_three] at hh  apply Complex.ext <;>    simp [Matrix.add_apply, Matrix.mul_apply, Matrix.transpose_apply,      Matrix.conjTranspose_apply, Fin.sum_univ_three, Fin.sum_univ_one,      Complex.add_re, Complex.add_im, Complex.mul_re, Complex.mul_im,      hr, hs] <;> linarithprivate lemma in767_whole_conditional_bordered_completion    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ) (ξ : ℂ)    (R S : Matrix (Fin 3) (Fin 3) ℝ) (x y : Fin 3 → ℝ) (a b : ℝ)    (hB : B.transpose = B)    (hRS : ∀ i j, B i j = (R i j : ℂ) + Complex.I * (S i j : ℂ))    (hR : R.transpose = R) (hS : S.transpose = S)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hξ : ξ * star ξ = 1)    (huw : ∀ i, ξ * star (u i) = (x i : ℂ) + Complex.I * (y i : ℂ))    (hxy : ∀ i, (R.mulVec y) i - (S.mulVec x) i + b*x i - a*y i = 0) :    let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)    let Z : Matrix (Fin 1) (Fin 1) ℂ := fun _ _ => (a : ℂ) + Complex.I * (b : ℂ)    let N := Matrix.fromBlocks B W W.transpose Z    Nᴴ * N = N * Nᴴ := by  dsimp only  apply in767_whole_conditional_bordered_normality  · exact in767_whole_conditional_bordered_h11 B u ξ hB hC hξ  · have h := in767_whole_conditional_bordered_h12 R S x y a b hR hS hxy    have hb : B = fun i j => (R i j : ℂ) + Complex.I * (S i j : ℂ) := by      ext i j      exact hRS i j    have hw : (fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i)) =        (fun (i : Fin 3) (_ : Fin 1) => (x i : ℂ) + Complex.I * (y i : ℂ)) := by      funext i j      exact huw i    simpa only [hb, hw] using hprivate lemma in767_whole_conditional_bordered_phase_completion    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ) (c s a b : ℝ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hunit : c*c + s*s = 1)    (hphase : let R : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).re      let S : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).im      let x0 : Fin 3 → ℝ := fun i => (star (u i)).re      let y0 : Fin 3 → ℝ := fun i => (star (u i)).im      ∀ i, (R.mulVec (fun j => s*x0 j + c*y0 j)) i -        (S.mulVec (fun j => c*x0 j - s*y0 j)) i +          b*(c*x0 i - s*y0 i) - a*(s*x0 i + c*y0 i) = 0) :    let ξ : ℂ := (c : ℂ) + Complex.I * (s : ℂ)    let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)    let Z : Matrix (Fin 1) (Fin 1) ℂ := fun _ _ => (a : ℂ) + Complex.I * (b : ℂ)    let N := Matrix.fromBlocks B W W.transpose Z    Nᴴ * N = N * Nᴴ := by  dsimp only  let R : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).re  let S : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (B i j).im  let x : Fin 3 → ℝ := fun i => c * (star (u i)).re - s * (star (u i)).im  let y : Fin 3 → ℝ := fun i => s * (star (u i)).re + c * (star (u i)).im  have hsym (i j : Fin 3) : B i j = B j i := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hB    simpa only [Matrix.transpose_apply] using h  have hR : R.transpose = R := by    ext i j    exact congrArg Complex.re (hsym j i)  have hS : S.transpose = S := by    ext i j    exact congrArg Complex.im (hsym j i)  have hRS : ∀ i j, B i j = (R i j : ℂ) + Complex.I * (S i j : ℂ) := by    intro i j    dsimp [R, S]    simpa only [mul_comm] using (Complex.re_add_im (B i j)).symm  have hξ : ((c : ℂ) + Complex.I * (s : ℂ)) * star ((c : ℂ) + Complex.I * (s : ℂ)) = 1 := by    apply Complex.ext <;> simp [Complex.mul_re, Complex.mul_im] <;> linarith  have huw : ∀ i, ((c : ℂ) + Complex.I * (s : ℂ)) * star (u i) =      (x i : ℂ) + Complex.I * (y i : ℂ) := by    intro i    apply Complex.ext <;> simp [x, y, Complex.mul_re, Complex.mul_im] <;> ring  exact in767_whole_conditional_bordered_completion B u _ R S x y a b hB hRS hR hS hC hξ huw hphaseprivate lemma in767_whole_conditional_bordered_lower_block    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ) (ξ : ℂ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hξ : ξ * star ξ = 1) :    let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)    Bᴴ * B + vecMulVec u (star u) = B * Bᴴ + W * Wᴴ := by  dsimp only  have h := in767_whole_conditional_bordered_h11 B u ξ hB hC hξ  dsimp only at h  have hW : ((fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i))ᵀᴴ *      (fun (i : Fin 3) (_ : Fin 1) => ξ * star (u i))ᵀ) = vecMulVec u (star u) := by    ext i j    simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.transpose_apply,      Matrix.vecMulVec_apply, Pi.star_apply, Fin.sum_univ_one, star_mul, star_star]    linear_combination (u i * star (u j)) * hξ  rw [hW] at h  exact hprivate lemma in767_whole_conditional_product_frame_of_diagonal    (B C : Matrix (Fin 3) (Fin 3) ℂ) (O : Matrix (Fin 3) (Fin 4) ℝ) (lam : Fin 4 → ℂ)    (hO : O * O.transpose = 1)    (hB : ∀ i j, B i j = ∑ k, (O i k : ℂ) * lam k * (O j k : ℂ))    (hC : ∀ i j, C i j = ∑ k, (O i k : ℂ) * (lam k * star (lam k)) * (O j k : ℂ)) :    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),      (∀ t i, star (v t i) = v t i) ∧      (1 : Matrix (Fin 3) (Fin 3) ℂ) =        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧      C = ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t)) := by  refine ⟨fun t i => (O i t : ℂ), fun _ => 1, fun t => star (lam t), ?_, ?_, ?_, ?_⟩  · intro t i    simp  · ext i j    have hr := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hO    simp only [Matrix.mul_apply, Matrix.transpose_apply] at hr    have hc : (∑ k, (O i k : ℂ) * (O j k : ℂ)) = ((1 : Matrix (Fin 3) (Fin 3) ℝ) i j : ℂ) := by      exact_mod_cast hr    by_cases hij : i = j <;>      simpa [hij, Matrix.vecMulVec_apply, Matrix.one_apply, Matrix.sum_apply, Matrix.smul_apply,        mul_comm, mul_left_comm, mul_assoc] using hc.symm  · ext i j    simpa [Matrix.vecMulVec_apply, Matrix.sum_apply, Matrix.smul_apply,      mul_comm, mul_left_comm, mul_assoc] using hB i j  · ext i j    simpa [Matrix.vecMulVec_apply, Matrix.sum_apply, Matrix.smul_apply,      mul_comm, mul_left_comm, mul_assoc] using hC i jprivate lemma in767_whole_conditional_real_diagonal_normal_square    {m : Type} [Fintype m] [DecidableEq m]    (Q : Matrix m (Fin 4) ℂ) (lam : Fin 4 → ℂ)    (hreal : Qᴴ = Q.transpose) (horth : Q.transpose * Q = 1) :    let N := Q * Matrix.diagonal lam * Q.transpose    N * Nᴴ = Q * Matrix.diagonal (fun k => lam k * star (lam k)) * Q.transpose := by  dsimp only  have hreal' : Q.transposeᴴ = Q := by    rw [← hreal, Matrix.conjTranspose_conjTranspose]  rw [Matrix.conjTranspose_mul, Matrix.conjTranspose_mul, Matrix.diagonal_conjTranspose,    hreal', hreal]  simp only [Matrix.mul_assoc, ← Matrix.mul_assoc Q.transpose Q,    horth, Matrix.one_mul, Matrix.diagonal_mul_diagonal]  rw [← Matrix.mul_assoc (Matrix.diagonal lam) (Matrix.diagonal (star lam)) Q.transpose, Matrix.diagonal_mul_diagonal]  rflprivate lemma in767_whole_conditional_spectral_frame_bridge    (B C : Matrix (Fin 3) (Fin 3) ℂ)    (W : Matrix (Fin 3) (Fin 1) ℂ) (Z : Matrix (Fin 1) (Fin 1) ℂ)    (O : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℝ) (lam : Fin 4 → ℂ)    (horth : O.transpose * O = 1) (hcoorth : O * O.transpose = 1)    (hC : C = B*Bᴴ + W*Wᴴ)    (hN : let Q : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℂ := fun i j => O i j      Matrix.fromBlocks B W W.transpose Z = Q * Matrix.diagonal lam * Q.transpose) :    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),      (∀ t i, star (v t i) = v t i) ∧      (1 : Matrix (Fin 3) (Fin 3) ℂ) =        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧      C = ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t)) := by  let Q : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℂ := fun i j => O i j  let V : Matrix (Fin 3) (Fin 4) ℝ := fun i j => O (Sum.inl i) j  have hV : V * V.transpose = 1 := by    ext i j    have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℝ =>      M (Sum.inl i) (Sum.inl j)) hcoorth    simpa [V, Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply] using hh  have hQreal : Qᴴ = Q.transpose := by    ext i j    simp [Q, Matrix.conjTranspose_apply, Matrix.transpose_apply]  have hQorth : Q.transpose * Q = 1 := by    ext i j    have hh := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) horth    simp only [Matrix.mul_apply, Matrix.transpose_apply] at hh    change (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k j : ℂ)) = (1 : Matrix (Fin 4) (Fin 4) ℂ) i j    by_cases hij : i = j    · subst j      have hh' : (∑ k : Fin 3 ⊕ Fin 1, O k i * O k i) = (1 : ℝ) := by simpa [Matrix.one_apply] using hh      simpa [Matrix.one_apply] using (show (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k i : ℂ)) = 1 by exact_mod_cast hh')    · have hh' : (∑ k : Fin 3 ⊕ Fin 1, O k i * O k j) = (0 : ℝ) := by simpa [Matrix.one_apply, hij] using hh      simpa [Matrix.one_apply, hij] using (show (∑ k : Fin 3 ⊕ Fin 1, (O k i : ℂ) * (O k j : ℂ)) = 0 by exact_mod_cast hh')  change Matrix.fromBlocks B W W.transpose Z = Q * Matrix.diagonal lam * Q.transpose at hN  have hN2 : (Matrix.fromBlocks B W W.transpose Z) * (Matrix.fromBlocks B W W.transpose Z)ᴴ =      Q * Matrix.diagonal (fun k => lam k * star (lam k)) * Q.transpose := by    rw [hN]    exact in767_whole_conditional_real_diagonal_normal_square Q lam hQreal hQorth  have hm (f : Fin 4 → ℂ) (i j : Fin 3 ⊕ Fin 1) :      (Q * Matrix.diagonal f * Q.transpose) i j =        ∑ k, (O i k : ℂ) * f k * (O j k : ℂ) := by    rw [Matrix.mul_apply]    simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Q]  apply in767_whole_conditional_product_frame_of_diagonal B C V lam hV  · intro i j    have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ =>      M (Sum.inl i) (Sum.inl j)) hN    simpa only [Matrix.fromBlocks_apply₁₁, hm, V] using hh  · intro i j    have hh := congrArg (fun M : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ =>      M (Sum.inl i) (Sum.inl j)) hN2    rw [hC]    simpa only [Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply,      Matrix.fromBlocks_apply₁₁, hm, V] using hhprivate lemma in767_whole_conditional_four_products_of_bordered_spectrum    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ) (ξ : ℂ)    (Z : Matrix (Fin 1) (Fin 1) ℂ)    (O : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℝ) (lam : Fin 4 → ℂ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hξ : ξ * star ξ = 1)    (horth : O.transpose * O = 1) (hcoorth : O * O.transpose = 1)    (hN : let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)      let Q : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℂ := fun i j => O i j      Matrix.fromBlocks B W W.transpose Z = Q * Matrix.diagonal lam * Q.transpose) :    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),      (∀ t i, star (v t i) = v t i) ∧      (1 : Matrix (Fin 3) (Fin 3) ℂ) =        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧      Bᴴ * B + vecMulVec u (star u) =        ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t)) := by  let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)  apply in767_whole_conditional_spectral_frame_bridge B (Bᴴ * B + vecMulVec u (star u)) W Z O lam horth hcoorth  · exact in767_whole_conditional_bordered_lower_block B u ξ hB hC hξ  · exact hNprivate lemma in767_whole_conditional_normal_symmetric_parts_commute    (N : Matrix (Fin 4) (Fin 4) ℂ) (hsym : N.transpose = N)    (hnormal : Nᴴ * N = N * Nᴴ) :    let R : Matrix (Fin 4) (Fin 4) ℝ := fun i j => (N i j).re    let S : Matrix (Fin 4) (Fin 4) ℝ := fun i j => (N i j).im    R.transpose = R ∧ S.transpose = S ∧ R*S=S*R := by  dsimp only  have hs (i j : Fin 4) : N i j = N j i := by    have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M j i) hsym    simpa only [Matrix.transpose_apply] using h  refine ⟨?_, ?_, ?_⟩  · ext i j    exact congrArg Complex.re (hs j i)  · ext i j    exact congrArg Complex.im (hs j i)  · ext i j    have hn := congrArg Complex.im (congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M i j) hnormal)    simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_four,      Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re] at hn    simp only [Matrix.mul_apply, Fin.sum_univ_four]    simp only [hs i, hs j] at hn    simp only [hs i, hs j]    linarithprivate lemma in767_whole_conditional_normal_symmetric_spectral_of_real_pair    (N : Matrix (Fin 4) (Fin 4) ℂ) (hsym : N.transpose = N)    (hnormal : Nᴴ * N = N * Nᴴ)    (hdiag : ∀ (R S : Matrix (Fin 4) (Fin 4) ℝ),      R.transpose = R → S.transpose = S → R*S = S*R →      ∃ (O : Matrix (Fin 4) (Fin 4) ℝ) (r s : Fin 4 → ℝ),        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧        R = O * Matrix.diagonal r * O.transpose ∧        S = O * Matrix.diagonal s * O.transpose) :    ∃ (O : Matrix (Fin 4) (Fin 4) ℝ) (lam : Fin 4 → ℂ),      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧      let Q : Matrix (Fin 4) (Fin 4) ℂ := fun i j => O i j      N = Q * Matrix.diagonal lam * Q.transpose := by  obtain ⟨hR, hS, hRS⟩ := in767_whole_conditional_normal_symmetric_parts_commute N hsym hnormal  obtain ⟨O, r, s, horth, hcoorth, hr, hi⟩ := hdiag _ _ hR hS hRS  refine ⟨O, fun k => (r k : ℂ) + Complex.I * (s k : ℂ), horth, hcoorth, ?_⟩  dsimp only  ext i j  have hr' := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) hr  have hi' := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) hi  rw [Matrix.mul_apply] at hr' hi'  simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_four] at hr' hi'  rw [Matrix.mul_apply]  apply Complex.ext <;>    simp [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_four,      Complex.mul_re, Complex.mul_im] <;> linarithprivate lemma in767_whole_conditional_normal_spectrum_sum_index    (N : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ) (hsym : N.transpose = N)    (hnormal : Nᴴ * N = N * Nᴴ)    (hdiag : ∀ (R S : Matrix (Fin 4) (Fin 4) ℝ),      R.transpose = R → S.transpose = S → R*S = S*R →      ∃ (O : Matrix (Fin 4) (Fin 4) ℝ) (r s : Fin 4 → ℝ),        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧        R = O * Matrix.diagonal r * O.transpose ∧        S = O * Matrix.diagonal s * O.transpose) :    ∃ (O : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℝ) (lam : Fin 4 → ℂ),      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧      let Q : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℂ := fun i j => O i j      N = Q * Matrix.diagonal lam * Q.transpose := by  let e : Fin 3 ⊕ Fin 1 ≃ Fin 4 := finSumFinEquiv  let N4 : Matrix (Fin 4) (Fin 4) ℂ := N.submatrix e.symm e.symm  have hs4 : N4.transpose = N4 := by    dsimp [N4]    rw [Matrix.transpose_submatrix, hsym]  have hn4 : N4ᴴ * N4 = N4 * N4ᴴ := by    dsimp [N4]    rw [Matrix.conjTranspose_submatrix, Matrix.submatrix_mul_equiv Nᴴ N e.symm e.symm e.symm,      Matrix.submatrix_mul_equiv N Nᴴ e.symm e.symm e.symm, hnormal]  obtain ⟨O4, lam, horth, hcoorth, hspec⟩ :=    in767_whole_conditional_normal_symmetric_spectral_of_real_pair N4 hs4 hn4 hdiag  let O : Matrix (Fin 3 ⊕ Fin 1) (Fin 4) ℝ := fun i j => O4 (e i) j  refine ⟨O, lam, ?_, ?_, ?_⟩  · ext i j    have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M i j) horth    simp only [Matrix.mul_apply, Matrix.transpose_apply] at h ⊢    change (∑ k : Fin 3 ⊕ Fin 1, O4 (e k) i * O4 (e k) j) = _    calc      _ = ∑ k : Fin 4, O4 k i * O4 k j := e.sum_comp (fun k => O4 k i * O4 k j)      _ = _ := h  · ext i j    have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℝ => M (e i) (e j)) hcoorth    simp only [Matrix.mul_apply, Matrix.transpose_apply] at h ⊢    change (∑ k : Fin 4, O4 (e i) k * O4 (e j) k) = _    simpa only [Matrix.one_apply, e.injective.eq_iff] using h  · dsimp only    ext i j    have h := congrArg (fun M : Matrix (Fin 4) (Fin 4) ℂ => M (e i) (e j)) hspec    change N i j = _    have hN4 : N4 (e i) (e j) = N i j := by simp [N4]    rw [hN4] at h    rw [Matrix.mul_apply] at h ⊢    simpa only [Matrix.mul_diagonal, Matrix.transpose_apply, O] using hprivate lemma in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hli : LinearIndependent ℝ ![(fun i : Fin 3 => (star (u i)).re),                                  (fun i : Fin 3 => (star (u i)).im)])    (hphase : ∀ (R S : Matrix (Fin 3) (Fin 3) ℝ) (x y : Fin 3 → ℝ),      LinearIndependent ℝ ![x, y] →      ∃ c s a b : ℝ, c*c + s*s = 1 ∧        ∀ i : Fin 3, (R.mulVec (fun j => s*x j + c*y j)) i -          (S.mulVec (fun j => c*x j - s*y j)) i +            b*(c*x i - s*y i) - a*(s*x i + c*y i) = 0)    (hdiag : ∀ (R S : Matrix (Fin 4) (Fin 4) ℝ),      R.transpose = R → S.transpose = S → R*S = S*R →      ∃ (O : Matrix (Fin 4) (Fin 4) ℝ) (r s : Fin 4 → ℝ),        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧        R = O * Matrix.diagonal r * O.transpose ∧        S = O * Matrix.diagonal s * O.transpose) :    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),      (∀ t i, star (v t i) = v t i) ∧      (1 : Matrix (Fin 3) (Fin 3) ℂ) =        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧      Bᴴ * B + vecMulVec u (star u) =        ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t)) := by  obtain ⟨c, s, a, b, hunit, hxy⟩ := hphase (fun i j => (B i j).re)    (fun i j => (B i j).im) (fun i => (star (u i)).re) (fun i => (star (u i)).im) hli  let ξ : ℂ := (c : ℂ) + Complex.I * (s : ℂ)  let W : Matrix (Fin 3) (Fin 1) ℂ := fun i _ => ξ * star (u i)  let Z : Matrix (Fin 1) (Fin 1) ℂ := fun _ _ => (a : ℂ) + Complex.I * (b : ℂ)  let N : Matrix (Fin 3 ⊕ Fin 1) (Fin 3 ⊕ Fin 1) ℂ := Matrix.fromBlocks B W W.transpose Z  have hn : Nᴴ * N = N * Nᴴ := by    exact in767_whole_conditional_bordered_phase_completion B u c s a b hB hC hunit hxy  have hz : Z.transpose = Z := by    ext i j    fin_cases i    fin_cases j    rfl  have hs : N.transpose = N := by    dsimp [N]    rw [Matrix.fromBlocks_transpose, hB, Matrix.transpose_transpose, hz]  obtain ⟨O, lam, ho, hoc, hspec⟩ := in767_whole_conditional_normal_spectrum_sum_index N hs hn hdiag  have hξ : ξ * star ξ = 1 := by    dsimp [ξ]    apply Complex.ext <;> simp [Complex.mul_re, Complex.mul_im] <;> linarith  exact in767_whole_conditional_four_products_of_bordered_spectrum B u ξ Z O lam hB hC hξ ho hoc hspecprivate lemma in767_whole_conditional_dependent_re_im_fixed_phase (u : Fin 3 → ℂ)    (hdep : ¬ LinearIndependent ℝ ![(fun i : Fin 3 => (star (u i)).re),                                    (fun i : Fin 3 => (star (u i)).im)]) :    ∃ (v : Fin 3 → ℝ) (gamma : ℂ), ∀ i, u i = gamma * (v i : ℂ) := by  let x : Fin 3 → ℝ := fun i => (star (u i)).re  let y : Fin 3 → ℝ := fun i => (star (u i)).im  by_cases hx : x = 0  · refine ⟨y, -Complex.I, ?_⟩    intro i    have hi := congrFun hx i    dsimp [x] at hi    apply Complex.ext <;> simp [y, Complex.mul_re, Complex.mul_im] at hi ⊢ <;> linarith  · have hex : ∃ t : ℝ, t • x = y := by      by_contra h      apply hdep      apply (LinearIndependent.pair_iff' hx).2      intro t ht      exact h ⟨t, ht⟩    obtain ⟨t, ht⟩ := hex    refine ⟨x, 1 - Complex.I * (t : ℂ), ?_⟩    intro i    have hi := congrFun ht i    dsimp [x, y] at hi    apply Complex.ext <;> simp [x, Complex.mul_re, Complex.mul_im] at hi ⊢ <;> linarithprivate lemma in767_whole_conditional_fixed_phase_block_normal    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)    (v : Fin 3 → ℝ) (gamma : ℂ)    (hB : B.transpose = B) (hu : ∀ i, u i = gamma * (v i : ℂ))    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j) :    Bᴴ * B = B * Bᴴ := by  have hs (i j : Fin 3) : B i j = B j i := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hB    simpa only [Matrix.transpose_apply] using h  have hup (i j : Fin 3) : u i * star (u j) = u j * star (u i) := by    rw [hu i, hu j]    simp only [star_mul, Complex.star_def, Complex.conj_ofReal]    ring  ext i j  have hh := hC i j  simp only [Matrix.add_apply, Matrix.mul_apply, Matrix.conjTranspose_apply,    Matrix.vecMulVec_apply, Pi.star_apply, star_add, star_sum, star_mul, star_star] at hh  simp only [Matrix.mul_apply, Matrix.conjTranspose_apply]  simp only [hs i, hs j]  have hsum : (∑ k, star (B k j) * B k i) = ∑ k, B k i * star (B k j) := by    apply Finset.sum_congr rfl    intro k hk    ring  rw [hsum] at hh  have huij := hup i j  linear_combination -hh - huijprivate lemma in767_whole_conditional_normal_symmetric_parts_commute_three    (N : Matrix (Fin 3) (Fin 3) ℂ) (hsym : N.transpose = N)    (hnormal : Nᴴ * N = N * Nᴴ) :    let R : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (N i j).re    let S : Matrix (Fin 3) (Fin 3) ℝ := fun i j => (N i j).im    R.transpose = R ∧ S.transpose = S ∧ R*S=S*R := by  dsimp only  have hs (i j : Fin 3) : N i j = N j i := by    have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M j i) hsym    simpa only [Matrix.transpose_apply] using h  refine ⟨?_, ?_, ?_⟩  · ext i j    exact congrArg Complex.re (hs j i)  · ext i j    exact congrArg Complex.im (hs j i)  · ext i j    have hn := congrArg Complex.im (congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M i j) hnormal)    simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_three,      Complex.add_im, Complex.mul_im, Complex.star_def, Complex.conj_im, Complex.conj_re] at hn    simp only [Matrix.mul_apply, Fin.sum_univ_three]    simp only [hs i, hs j] at hn    simp only [hs i, hs j]    linarithprivate lemma in767_whole_conditional_normal_symmetric_spectral_of_real_pair_three    (N : Matrix (Fin 3) (Fin 3) ℂ) (hsym : N.transpose = N)    (hnormal : Nᴴ * N = N * Nᴴ)    (hdiag : ∀ (R S : Matrix (Fin 3) (Fin 3) ℝ),      R.transpose = R → S.transpose = S → R*S = S*R →      ∃ (O : Matrix (Fin 3) (Fin 3) ℝ) (r s : Fin 3 → ℝ),        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧        R = O * Matrix.diagonal r * O.transpose ∧        S = O * Matrix.diagonal s * O.transpose) :    ∃ (O : Matrix (Fin 3) (Fin 3) ℝ) (lam : Fin 3 → ℂ),      O.transpose * O = 1 ∧ O * O.transpose = 1 ∧      let Q : Matrix (Fin 3) (Fin 3) ℂ := fun i j => O i j      N = Q * Matrix.diagonal lam * Q.transpose := by  obtain ⟨hR, hS, hRS⟩ := in767_whole_conditional_normal_symmetric_parts_commute_three N hsym hnormal  obtain ⟨O, r, s, horth, hcoorth, hr, hi⟩ := hdiag _ _ hR hS hRS  refine ⟨O, fun k => (r k : ℂ) + Complex.I * (s k : ℂ), horth, hcoorth, ?_⟩  dsimp only  ext i j  have hr' := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hr  have hi' := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℝ => M i j) hi  rw [Matrix.mul_apply] at hr' hi'  simp only [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_three] at hr' hi'  rw [Matrix.mul_apply]  apply Complex.ext <;>    simp [Matrix.mul_diagonal, Matrix.transpose_apply, Fin.sum_univ_three,      Complex.mul_re, Complex.mul_im] <;> linariththeorem qutrit_rank_four_block_product_from_three_lemmas    (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)    (hB : B.transpose = B)    (hC : ∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j)    (hphase : ∀ (R S : Matrix (Fin 3) (Fin 3) ℝ) (x y : Fin 3 → ℝ),      LinearIndependent ℝ ![x, y] →      ∃ c s a b : ℝ, c*c + s*s = 1 ∧        ∀ i : Fin 3, (R.mulVec (fun j => s*x j + c*y j)) i -          (S.mulVec (fun j => c*x j - s*y j)) i +            b*(c*x i - s*y i) - a*(s*x i + c*y i) = 0)    (hdiag : ∀ (n : ℕ) (R S : Matrix (Fin n) (Fin n) ℝ),      R.transpose = R → S.transpose = S → R*S = S*R →      ∃ (O : Matrix (Fin n) (Fin n) ℝ) (r s : Fin n → ℝ),        O.transpose * O = 1 ∧ O * O.transpose = 1 ∧        R = O * Matrix.diagonal r * O.transpose ∧        S = O * Matrix.diagonal s * O.transpose)    (hfixed : ∀ (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ)      (O : Matrix (Fin 3) (Fin 3) ℝ) (lam : Fin 3 → ℂ)      (v0 : Fin 3 → ℝ) (gamma : ℂ),      O.transpose * O = 1 → O * O.transpose = 1 →      (∀ i j, B i j = ∑ k, (O i k : ℂ) * lam k * (O j k : ℂ)) →      (∀ i, u i = gamma * (v0 i : ℂ)) →      ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),        (∀ t i, star (v t i) = v t i) ∧        (1 : Matrix (Fin 3) (Fin 3) ℂ) =          ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧        B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧        Bᴴ * B + vecMulVec u (star u) =          ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t))) :    ∃ (v : Fin 4 → Fin 3 → ℂ) (a b : Fin 4 → ℂ),      (∀ t i, star (v t i) = v t i) ∧      (1 : Matrix (Fin 3) (Fin 3) ℂ) =        ∑ t, (a t * star (a t)) • vecMulVec (v t) (star (v t)) ∧      B = ∑ t, (a t * star (b t)) • vecMulVec (v t) (star (v t)) ∧      Bᴴ * B + vecMulVec u (star u) =        ∑ t, (b t * star (b t)) • vecMulVec (v t) (star (v t)) := by  by_cases hli : LinearIndependent ℝ ![(fun i : Fin 3 => (star (u i)).re),                                        (fun i : Fin 3 => (star (u i)).im)]  · exact in767_whole_conditional_rank_four_nondegenerate_from_phase_and_spectrum B u hB hC hli hphase (hdiag 4)  · obtain ⟨v0, gamma, hu⟩ := in767_whole_conditional_dependent_re_im_fixed_phase u hli    have hnorm : Bᴴ * B = B * Bᴴ := in767_whole_conditional_fixed_phase_block_normal B u v0 gamma hB hu hC    obtain ⟨O, lam, ho, hoc, hspec⟩ :=      in767_whole_conditional_normal_symmetric_spectral_of_real_pair_three B hB hnorm (hdiag 3)    apply hfixed B u O lam v0 gamma ho hoc    · intro i j      have h := congrArg (fun M : Matrix (Fin 3) (Fin 3) ℂ => M i j) hspec      rw [Matrix.mul_apply] at h      simpa only [Matrix.mul_diagonal, Matrix.transpose_apply] using h    · exact hu
See it in the graphDiscuss this resultChallenge it