AFTD Auto-Formalizing Theoretical Domains

rank_four_ppt_block_four_product_decomposition

theoremverified

A normalized 3-by-2 rank-four partial-transpose-invariant positive block has a four-term real-qutrit product decomposition.

Statement

theorem rank_four_ppt_block_four_product_decomposition :
  ∀ (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ),
    B.transpose = B →
    (∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =
      (Bᴴ * B + vecMulVec u (star u)) i j) →
    ∃ (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, using the rank-four PPT source from https://arxiv.org/abs/1405.4502 and the normal-completion context https://arxiv.org/abs/0903.0090.
Verified
12 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4

The proof, explained

To show that a normalized rank-four block admits a four-term real-qutrit product decomposition, the proof splits into two cases based on whether the real and imaginary parts of the bordering vector are linearly independent over ℝ. In the nondegenerate case, a phase factor and scalar corner complete the block into a 4x4 complex symmetric normal matrix, which is simultaneously diagonalized by a real orthogonal matrix whose top 3x4 submatrix yields the product states. In the degenerate case, the vector has a fixed phase, which forces the 3x3 block itself to be normal and reduces the problem to an established fixed-phase decomposition theorem.

  1. Normality of a symmetric bordered block matrix reduces to its (1,1) and (1,2) block equations.

    We expand Nᴴ * N and N * Nᴴ using block multiplication. The (1,1) block equality is hypothesis `h11`, the (1,2) block equality is `h12`, the (2,1) block equality is obtained by conjugate-transposing `h12`, and the (2,2) block equality holds automatically because Fin 1 has a single element and complex multiplication is commutative.

    lines 15–30

    uses Matrix.fromBlocks_conjTranspose, Matrix.fromBlocks_multiply, 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
      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]
  2. The (1,1) block condition for normality holds when W is defined with unit phase.

    Since B is symmetric (Bᵀ = B), B * Bᴴ is the entrywise complex conjugate of Bᴴ * B. Hypothesis `hC` states that Bᴴ * B + u uᴴ is entrywise real. Since ξ has unit modulus (ξ * star ξ = 1), (Wᵀ)ᴴ * Wᵀ equals u uᴴ, while W * Wᴴ equals its conjugate. Combining these shows that Bᴴ * B + (Wᵀ)ᴴ * Wᵀ = B * Bᴴ + W * Wᴴ.

    lines 40–60

    uses Finset.sum_congr

      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ξ
  3. The (1,2) block condition for normality holds whenever the real linear system is satisfied.

    Express B = R + i S, W = x + i y, and Z = a + i b in terms of their real and imaginary parts. The (1,2) block equation Bᴴ * W + (Wᵀ)ᴴ * Z = B * (Wᵀ)ᴴ + W * Zᴴ expands entrywise into real and imaginary parts, each of which reduces to the assumed linear equation `hxy`.

    lines 70–85

    uses Complex.ext

      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
  4. The bordered block matrix N is normal whenever the (1,1) and (1,2) block conditions are met.

    Apply `in773_rk4_bordered_normality`, supplying `in773_rk4_bordered_h11` for the (1,1) block and `in773_rk4_bordered_h12` for the (1,2) block after identifying B, W, and Z with their real and imaginary components.

    lines 102–113

    uses in773_rk4_bordered_normality, in773_rk4_bordered_h11, in773_rk4_bordered_h12

      dsimp only
      apply in773_rk4_bordered_normality
      · exact in773_rk4_bordered_h11 B u ξ hB hC hξ
      · have h := in773_rk4_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
  5. Given phase parameters (c, s) and corner entries (a, b) satisfying the phase equation, the bordered matrix N is normal.

    We set R and S as the real and imaginary parts of B, and x and y as the real and imaginary parts of ξ * star(u) with ξ = c + i s. The condition c² + s² = 1 gives ξ * star(ξ) = 1, and the hypothesis `hphase` matches the linear condition in `in773_rk4_bordered_completion`.

    lines 134–158

    uses Complex.re_add_im, Complex.ext, in773_rk4_bordered_completion

      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 in773_rk4_bordered_completion B u _ R S x y a b hB hRS hR hS hC hξ huw hphase
  6. The lower block B * Bᴴ + W * Wᴴ equals Bᴴ * B + vecMulVec u (star u).

    From `in773_rk4_bordered_h11`, Bᴴ * B + (Wᵀ)ᴴ * Wᵀ = B * Bᴴ + W * Wᴴ. Expanding (Wᵀ)ᴴ * Wᵀ for W = ξ * star(u) with |ξ|² = 1 shows that it equals vecMulVec u (star u).

    lines 168–178

    uses in773_rk4_bordered_h11

      dsimp only
      have h := in773_rk4_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
  7. Simultaneous orthogonal diagonalization of B and C by a 3x4 real frame yields a four-term real-vector product decomposition.

    We choose the four vectors v t to be the columns of the real matrix O, which are real because O is real. Setting a t = 1 and b t = star(lam t), the relation O * Oᵀ = 1 implies the identity decomposition ∑ v t v tᵀ = 1, while the bilinear expansions of B and C match the required outer product sums.

    lines 192–209

      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
    
  8. The product N * Nᴴ for N = Q diag(λ) Qᵀ with real orthogonal Q equals Q diag(|λ|²) Qᵀ.

    Since Q is real and orthogonal, Qᴴ = Qᵀ and Qᵀ * Q = 1. Therefore Nᴴ = Q diag(star λ) Qᵀ. Multiplying N and Nᴴ and using Qᵀ * Q = 1 collapses the inner factor, leaving Q diag(λ * star λ) Qᵀ.

    lines 217–225

    uses Matrix.conjTranspose_conjTranspose, Matrix.conjTranspose_mul, Matrix.diagonal_conjTranspose, 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
  9. Orthogonal diagonalization of the bordered 4x4 normal matrix yields the product frame decomposition of B and C.

    Let V be the top 3x4 block of O. Since O * Oᵀ = 1, we have V * Vᵀ = 1. Matching the (1,1) blocks of N = Q diag(λ) Qᵀ and N * Nᴴ = Q diag(|λ|²) Qᵀ gives B = V diag(λ) Vᵀ and C = B * Bᴴ + W * Wᴴ = V diag(|λ|²) Vᵀ. Applying `in773_rk4_product_frame_of_diagonal` completes the step.

    lines 242–284

    uses in773_rk4_real_diagonal_normal_square, in773_rk4_product_frame_of_diagonal

      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 in773_rk4_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 in773_rk4_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
    
  10. A spectral decomposition of the bordered matrix yields the four-product decomposition for B and Bᴴ * B + vecMulVec u (star u).

    Apply `in773_rk4_spectral_frame_bridge` with C = Bᴴ * B + vecMulVec u (star u), where the required equality C = B * Bᴴ + W * Wᴴ is provided by `in773_rk4_bordered_lower_block`.

    lines 305–309

    uses in773_rk4_spectral_frame_bridge, in773_rk4_bordered_lower_block

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

    Symmetry Nᵀ = N implies that both the real part R and imaginary part S are symmetric. Normality Nᴴ * N = N * Nᴴ equates (R - i S)(R + i S) with (R + i S)(R - i S). Taking the imaginary part shows 2(R S - S R) = 0, so R S = S R.

    lines 317–333

      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
  12. A complex symmetric normal 4x4 matrix has a real orthogonal spectral decomposition.

    By `in773_rk4_normal_symmetric_parts_commute`, R and S are commuting real symmetric matrices. By hypothesis `hdiag`, they are simultaneously diagonalized by a real orthogonal matrix O: R = O diag(r) Oᵀ and S = O diag(s) Oᵀ. Then N = R + i S = O diag(r + i s) Oᵀ.

    lines 348–361

    uses in773_rk4_normal_symmetric_parts_commute, Complex.ext

      obtain ⟨hR, hS, hRS⟩ := in773_rk4_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
    
  13. A complex symmetric normal matrix indexed by Fin 3 ⊕ Fin 1 has a real orthogonal spectral decomposition.

    We reindex the matrix via the equivalence `finSumFinEquiv` between Fin 3 ⊕ Fin 1 and Fin 4, apply `in773_rk4_normal_symmetric_spectral_of_real_pair` on Fin 4, and pull the orthogonal matrix O back along the equivalence.

    lines 375–408

    uses finSumFinEquiv, Matrix.transpose_submatrix, Matrix.conjTranspose_submatrix, Matrix.submatrix_mul_equiv, in773_rk4_normal_symmetric_spectral_of_real_pair

      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⟩ :=
        in773_rk4_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
    
  14. When Re(star u) and Im(star u) are linearly independent, the four-term product decomposition exists.

    By `hphase`, we find phase parameters (c, s) and corner entries (a, b). The bordered matrix N is normal by `in773_rk4_bordered_phase_completion` and symmetric. By `in773_rk4_normal_spectrum_sum_index`, N has a real orthogonal spectral decomposition, from which `in773_rk4_four_products_of_bordered_spectrum` yields the product decomposition.

    lines 436–456

    uses in773_rk4_bordered_phase_completion, Matrix.fromBlocks_transpose, in773_rk4_normal_spectrum_sum_index, in773_rk4_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 in773_rk4_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⟩ := in773_rk4_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 in773_rk4_four_products_of_bordered_spectrum B u ξ Z O lam hB hC hξ ho hoc hspec
  15. If Re(star u) and Im(star u) are linearly dependent over ℝ, then u has a fixed phase.

    Let x = Re(star u) and y = Im(star u). If x = 0, then u = -i y, which is a fixed phase. If x ≠ 0, linear dependence implies y = t x for some real t, so u = (1 - i t) x, meaning u is a complex scalar multiple of a real vector.

    lines 463–482

    uses LinearIndependent.pair_iff', Complex.ext

      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
  16. When u has a fixed phase, B is normal.

    Since u = γ v with v real, u i * star(u j) = |γ|² v i * v j is real and symmetric in i and j. Subtracting this from the entrywise real matrix Bᴴ * B + vecMulVec u (star u) implies that Bᴴ * B is entrywise real, which combined with Bᵀ = B forces Bᴴ * B = B * Bᴴ.

    lines 491–510

    uses Complex.conj_ofReal, 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
  17. The real and imaginary parts of a complex symmetric normal 3x3 matrix are symmetric and commute.

    As in the 4x4 case, symmetry of N implies symmetry of its real and imaginary parts R and S, and normality Nᴴ * N = N * Nᴴ implies that the commutator R S - S R vanishes.

    lines 517–535

        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]
        linarith
  18. A complex symmetric normal 3x3 matrix has a real orthogonal spectral decomposition.

    By `in773_rk4_normal_symmetric_parts_commute_three`, R and S are commuting real symmetric 3x3 matrices. Applying simultaneous orthogonal diagonalization `hdiag` gives N = O diag(r + i s) Oᵀ for a real orthogonal 3x3 matrix O.

    lines 550–563

    uses in773_rk4_normal_symmetric_parts_commute_three, Complex.ext

      obtain ⟨hR, hS, hRS⟩ := in773_rk4_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
    
  19. The product decomposition holds in general assuming phase completion, simultaneous diagonalization, and fixed-phase decomposition.

    We case split on whether Re(star u) and Im(star u) are linearly independent. In the independent case, we apply `in773_rk4_rank_four_nondegenerate_from_phase_and_spectrum`. In the dependent case, u has a fixed phase by `in773_rk4_dependent_re_im_fixed_phase`, making B normal by `in773_rk4_fixed_phase_block_normal`; we then orthogonally diagonalize B and invoke the fixed-phase hypothesis `hfixed`.

    lines 602–614

    uses in773_rk4_rank_four_nondegenerate_from_phase_and_spectrum, in773_rk4_dependent_re_im_fixed_phase, in773_rk4_fixed_phase_block_normal, in773_rk4_normal_symmetric_spectral_of_real_pair_three

      by_cases hli : LinearIndependent ℝ ![(fun i : Fin 3 => (star (u i)).re),
                                            (fun i : Fin 3 => (star (u i)).im)]
      · exact in773_rk4_rank_four_nondegenerate_from_phase_and_spectrum B u hB hC hli hphase (hdiag 4)
      · obtain ⟨v0, gamma, hu⟩ := in773_rk4_dependent_re_im_fixed_phase u hli
        have hnorm : Bᴴ * B = B * Bᴴ := in773_rk4_fixed_phase_block_normal B u v0 gamma hB hu hC
        obtain ⟨O, lam, ho, hoc, hspec⟩ :=
          in773_rk4_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
  20. A normalized 3-by-2 rank-four partial-transpose-invariant positive block has a four-term real-qutrit product decomposition.

    We instantiate `in773_rk4_rank_four_from_phase_spectrum_and_fixed` with the three imported theorems: `rank_four_ppt_normal_completion_phase` for the phase solution, `real_symmetric_commuting_pair_orthogonal_diagonalization` for simultaneous diagonalization, and `qutrit_fixed_phase_schur_four_product_decomposition` for the fixed-phase case.

    lines 628–632

    uses in773_rk4_rank_four_from_phase_spectrum_and_fixed, rank_four_ppt_normal_completion_phase, real_symmetric_commuting_pair_orthogonal_diagonalization, qutrit_fixed_phase_schur_four_product_decomposition

      intro B u hB hC
      exact in773_rk4_rank_four_from_phase_spectrum_and_fixed B u hB hC
        rank_four_ppt_normal_completion_phase
        real_symmetric_commuting_pair_orthogonal_diagonalization
        qutrit_fixed_phase_schur_four_product_decomposition
Matrix.fromBlocks_conjTranspose
The conjugate transpose of a 2x2 block matrix is obtained by conjugate-transposing each block and swapping the off-diagonal blocks.
Matrix.fromBlocks_multiply
Block multiplication formula for 2x2 block matrices.
Matrix.conjTranspose_add
Conjugate transpose distributes over matrix addition.
Matrix.conjTranspose_mul
Conjugate transpose of a matrix product is the product of conjugate transposes in reverse order.
Finset.sum_congr
Sums over the same set of equal terms are equal.
Complex.ext
Two complex numbers are equal if and only if their real and imaginary parts are equal.
in773_rk4_bordered_normality
A symmetric bordered block matrix is normal if its (1,1) and (1,2) block commutativity conditions hold.
in773_rk4_bordered_h11
The (1,1) block normality condition holds when W is phase-rotated from star(u) and the PPT block condition holds.
in773_rk4_bordered_h12
The (1,2) block normality condition reduces to a linear system on the real and imaginary parts.
Complex.re_add_im
Every complex number equals its real part plus I times its imaginary part.
in773_rk4_bordered_completion
The bordered matrix N is normal if the (1,1) and (1,2) conditions are satisfied.
Matrix.conjTranspose_conjTranspose
The double conjugate transpose of a matrix is the original matrix.
Matrix.diagonal_conjTranspose
The conjugate transpose of a diagonal matrix is the diagonal matrix of the conjugates.
Matrix.diagonal_mul_diagonal
The product of two diagonal matrices is the diagonal matrix of their entrywise products.
in773_rk4_real_diagonal_normal_square
For a real orthogonal matrix Q, (Q diag(λ) Qᵀ)(Q diag(λ) Qᵀ)ᴴ equals Q diag(|λ|²) Qᵀ.
in773_rk4_product_frame_of_diagonal
A 3x4 real frame simultaneously diagonalizing B and C yields a four-term real-vector product decomposition.
in773_rk4_spectral_frame_bridge
Orthogonal diagonalization of the 4x4 bordered normal matrix restricts to the 3x3 block decomposition.
in773_rk4_bordered_lower_block
The lower block B*Bᴴ + W*Wᴴ equals Bᴴ*B + vecMulVec u (star u) when W has unit phase.
in773_rk4_normal_symmetric_parts_commute
The real and imaginary parts of a complex symmetric normal 4x4 matrix are symmetric and commute.
finSumFinEquiv
Canonical equivalence between Fin 3 ⊕ Fin 1 and Fin 4.
Matrix.transpose_submatrix
The transpose of a submatrix is obtained by swapping index maps and transposing the matrix.
Matrix.conjTranspose_submatrix
The conjugate transpose of a submatrix is obtained by swapping index maps and conjugate-transposing the matrix.
Matrix.submatrix_mul_equiv
Matrix multiplication commutes with reindexing along an equivalence of the inner dimension.
in773_rk4_normal_symmetric_spectral_of_real_pair
A complex symmetric normal 4x4 matrix is diagonalized by a real orthogonal matrix.
in773_rk4_bordered_phase_completion
Under the phase equation, the bordered matrix N is normal.
Matrix.fromBlocks_transpose
The transpose of a 2x2 block matrix swaps off-diagonal blocks and transposes each block.
in773_rk4_normal_spectrum_sum_index
A complex symmetric normal matrix indexed by Fin 3 ⊕ Fin 1 has a real orthogonal spectral decomposition.
in773_rk4_four_products_of_bordered_spectrum
A spectral decomposition of the bordered matrix yields the four-product decomposition for B and the lower block.
LinearIndependent.pair_iff'
For a nonzero vector x, the pair [x, y] is linearly independent if and only if y is not a scalar multiple of x.
Complex.conj_ofReal
Complex conjugation fixes real numbers embedded in the complex field.
in773_rk4_normal_symmetric_parts_commute_three
The real and imaginary parts of a complex symmetric normal 3x3 matrix are symmetric and commute.
in773_rk4_normal_symmetric_spectral_of_real_pair_three
A complex symmetric normal 3x3 matrix has a real orthogonal spectral decomposition.
in773_rk4_rank_four_nondegenerate_from_phase_and_spectrum
In the linearly independent case, the four-term product decomposition exists via bordered phase completion and spectral theory.
in773_rk4_dependent_re_im_fixed_phase
If Re(star u) and Im(star u) are linearly dependent, u is a complex scalar multiple of a real vector.
in773_rk4_fixed_phase_block_normal
When u has a fixed phase and the block condition holds, B is normal.
in773_rk4_rank_four_from_phase_spectrum_and_fixed
The block decomposition holds in general, combining the nondegenerate and fixed-phase cases.
rank_four_ppt_normal_completion_phase
For linearly independent vectors x, y, there exist a unit phase (c, s) and real numbers a, b solving the phase equation.
real_symmetric_commuting_pair_orthogonal_diagonalization
Commuting real symmetric matrices can be simultaneously diagonalized by a real orthogonal matrix.
qutrit_fixed_phase_schur_four_product_decomposition
A normalized rank-four block with fixed-phase vector u admits a four-term real-vector product decomposition.

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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_bordered_normality  · exact in773_rk4_bordered_h11 B u ξ hB hC hξ  · have h := in773_rk4_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 in773_rk4_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 in773_rk4_bordered_completion B u _ R S x y a b hB hRS hR hS hC hξ huw hphaseprivate lemma in773_rk4_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 := in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_spectral_frame_bridge B (Bᴴ * B + vecMulVec u (star u)) W Z O lam horth hcoorth  · exact in773_rk4_bordered_lower_block B u ξ hB hC hξ  · exact hNprivate lemma in773_rk4_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 in773_rk4_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⟩ := in773_rk4_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 in773_rk4_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⟩ :=    in773_rk4_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 in773_rk4_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 in773_rk4_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⟩ := in773_rk4_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 in773_rk4_four_products_of_bordered_spectrum B u ξ Z O lam hB hC hξ ho hoc hspecprivate lemma in773_rk4_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 in773_rk4_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 in773_rk4_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 in773_rk4_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⟩ := in773_rk4_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] <;> linarithprivate lemma in773_rk4_rank_four_from_phase_spectrum_and_fixed    (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 in773_rk4_rank_four_nondegenerate_from_phase_and_spectrum B u hB hC hli hphase (hdiag 4)  · obtain ⟨v0, gamma, hu⟩ := in773_rk4_dependent_re_im_fixed_phase u hli    have hnorm : Bᴴ * B = B * Bᴴ := in773_rk4_fixed_phase_block_normal B u v0 gamma hB hu hC    obtain ⟨O, lam, ho, hoc, hspec⟩ :=      in773_rk4_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 hutheorem rank_four_ppt_block_four_product_decomposition :  ∀ (B : Matrix (Fin 3) (Fin 3) ℂ) (u : Fin 3 → ℂ),    B.transpose = B →    (∀ i j, star ((Bᴴ * B + vecMulVec u (star u)) i j) =      (Bᴴ * B + vecMulVec u (star u)) i j) →    ∃ (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  intro B u hB hC  exact in773_rk4_rank_four_from_phase_spectrum_and_fixed B u hB hC    rank_four_ppt_normal_completion_phase    real_symmetric_commuting_pair_orthogonal_diagonalization    qutrit_fixed_phase_schur_four_product_decomposition
See it in the graphDiscuss this resultChallenge it