File size: 8,716 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import OAI.LinearAlgebra.Moore.Basic
import OAI.Analysis.PDE.Energy.Algebra

/-! Rank-one affineness of the signed quaternionic determinant polynomial. -/

namespace OAI.LinearAlgebra.Moore

open Matrix

/-- A product is affine in a perturbation supported at at most one factor. -/
theorem prod_affine_of_sparse {I R : Type*} [Fintype I] [DecidableEq I]
    [CommRing R] (f g : I β†’ R)
    (hg : βˆ€ i j, i β‰  j β†’ g i = 0 ∨ g j = 0) (t : R) :
    (∏ i, (f i + t * g i)) =
      (∏ i, f i) + t * ((∏ i, (f i + g i)) - ∏ i, f i) := by
  classical
  by_cases hz : βˆ€ i, g i = 0
  Β· simp [hz]
  · obtain ⟨k, hk⟩ := not_forall.mp hz
    have hzero (i : I) (hi : i β‰  k) : g i = 0 := (hg i k hi).resolve_right hk
    have hp (s : R) : (∏ i, (f i + s * g i)) =
        (f k + s * g k) * ∏ i ∈ Finset.univ.erase k, f i := by
      rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ k)]
      congr 1
      apply Finset.prod_congr rfl
      intro i hi
      rw [hzero i (Finset.ne_of_mem_erase hi), mul_zero, add_zero]
    have hbase : (∏ i, f i) = f k * ∏ i ∈ Finset.univ.erase k, f i :=
      (Finset.mul_prod_erase _ _ (Finset.mem_univ k)).symm
    have hone := hp 1
    simp only [one_mul] at hone
    rw [hp, hone, hbase]
    ring

/-- The skew matrix corresponding to a real unit diagonal quaternionic entry. -/
def pairedPerturbation (n : β„•) (k : Fin n) :
    Matrix (Fin n Γ— Fin 2) (Fin n Γ— Fin 2) β„‚ :=
  fun i j => if i = (k, 0) ∧ j = (k, 1) then 1
    else if i = (k, 1) ∧ j = (k, 0) then -1 else 0

theorem pairedPerturbation_support (n : β„•) (k : Fin n)
    (i j : Fin n Γ— Fin 2) (h : pairedPerturbation n k i j β‰  0) :
    i = (k, 0) ∨ j = (k, 0) := by
  by_contra hh
  simp only [not_or] at hh
  simp [pairedPerturbation, hh.1, hh.2] at h

theorem pairedPerturbation_sparse (n : β„•) (k : Fin n)
    (Οƒ : Equiv.Perm (Fin n Γ— Fin 2)) (i j : Fin n) (hij : i β‰  j) :
    pairedPerturbation n k (Οƒ (i, 0)) (Οƒ (i, 1)) = 0 ∨
      pairedPerturbation n k (Οƒ (j, 0)) (Οƒ (j, 1)) = 0 := by
  by_contra hh
  simp only [not_or] at hh
  have hi := pairedPerturbation_support n k _ _ hh.1
  have hj := pairedPerturbation_support n k _ _ hh.2
  rcases hi with hi | hi <;> rcases hj with hj | hj
  all_goals
    have he := Οƒ.injective (hi.trans hj.symm)
    exact hij (congrArg Prod.fst he)

/-- Affine dependence of the Pfaffian on one distinguished skew pair. -/
theorem pfaffian_add_paired (n : β„•)
    (M : Matrix (Fin n Γ— Fin 2) (Fin n Γ— Fin 2) β„‚) (k : Fin n) (t : β„‚) :
    pfaffian n (M + t β€’ pairedPerturbation n k) =
      pfaffian n M + t * (pfaffian n (M + pairedPerturbation n k) - pfaffian n M) := by
  unfold pfaffian
  simp only [Matrix.add_apply, Matrix.smul_apply, smul_eq_mul]
  simp_rw [prod_affine_of_sparse _ _ (pairedPerturbation_sparse n k _)]
  simp only [mul_add, mul_sub, Finset.sum_add_distrib, Finset.sum_sub_distrib]
  simp_rw [mul_left_comm _ t]
  rw [← Finset.mul_sum, ← Finset.mul_sum]
  ring

/-- Unit quaternionic rank-one diagonal projector. -/
def coordinateProjector (n : β„•) (k : Fin n) : Matrix (Fin n) (Fin n) (Quaternion ℝ) :=
  fun i j => if i = k ∧ j = k then 1 else 0

theorem skewComplexify_coordinateProjector (n : β„•) (k : Fin n) :
    skewComplexify (coordinateProjector n k) = pairedPerturbation n k := by
  ext ⟨i, a⟩ ⟨j, b⟩
  by_cases hi : i = k <;> by_cases hj : j = k <;>
    fin_cases a <;> fin_cases b <;>
    simp [coordinateProjector, pairedPerturbation, skewComplexify, skewQuaternion,
      quaternionMatrix, symplecticUnit, Matrix.mul_apply, Fin.sum_univ_two, hi, hj] <;> rfl

theorem skewComplexify_add {I : Type*} (A B : Matrix I I (Quaternion ℝ)) :
    skewComplexify (A + B) = skewComplexify A + skewComplexify B := by
  ext ⟨i, a⟩ ⟨j, b⟩
  change ((quaternionMatrix (A i j + B i j)) * symplecticUnit) a b = _
  rw [quaternionMatrix_add, Matrix.add_mul]
  rfl

theorem skewComplexify_real_smul {I : Type*} (A : Matrix I I (Quaternion ℝ)) (s : ℝ) :
    skewComplexify (s β€’ A) = (s : β„‚) β€’ skewComplexify A := by
  ext ⟨i, a⟩ ⟨j, b⟩
  exact congrArg (fun M : Matrix (Fin 2) (Fin 2) β„‚ => M a b)
    (skewQuaternion_smul s (A i j))

/-- The signed Moore determinant is affine in each real diagonal coordinate. -/
theorem mooreDet_add_coordinate (n : β„•) (A : Matrix (Fin n) (Fin n) (Quaternion ℝ))
    (k : Fin n) (t : ℝ) :
    mooreDet n (A + t β€’ coordinateProjector n k) =
      mooreDet n A + t * (mooreDet n (A + coordinateProjector n k) - mooreDet n A) := by
  unfold mooreDet
  rw [skewComplexify_add, skewComplexify_real_smul, skewComplexify_coordinateProjector,
    pfaffian_add_paired]
  rw [skewComplexify_add, skewComplexify_coordinateProjector]
  simp

theorem pfaffian_paired_zero (n : β„•) (k : Fin (n + 2)) :
    pfaffian (n + 2) (pairedPerturbation (n + 2) k) = 0 := by
  have hp (Οƒ : Equiv.Perm (Fin (n + 2) Γ— Fin 2)) :
      (∏ i : Fin (n + 2), pairedPerturbation (n + 2) k (Οƒ (i, 0)) (Οƒ (i, 1))) = 0 := by
    rcases pairedPerturbation_sparse (n + 2) k Οƒ 0 1 (by simp) with h | h
    Β· exact Finset.prod_eq_zero (Finset.mem_univ 0) h
    Β· exact Finset.prod_eq_zero (Finset.mem_univ 1) h
  simp [pfaffian, hp]

theorem mooreDet_coordinateProjector_zero (n : β„•) (k : Fin (n + 2)) :
    mooreDet (n + 2) (coordinateProjector (n + 2) k) = 0 := by
  rw [mooreDet, skewComplexify_coordinateProjector, pfaffian_paired_zero]
  rfl

/-- Exact two-parameter rank-one formula, valid in arbitrary quaternionic dimension
at least two, for the signed Moore polynomial. -/
theorem mooreDet_rankOne_pencil (n : β„•)
    (A : Matrix (Fin (n + 2)) (Fin (n + 2)) (Quaternion ℝ))
    (k : Fin (n + 2)) (t s : ℝ) :
    mooreDet (n + 2) (t β€’ A + s β€’ coordinateProjector (n + 2) k) =
      t ^ (n + 2) * mooreDet (n + 2) A +
      s * t ^ (n + 1) *
        (mooreDet (n + 2) (A + coordinateProjector (n + 2) k) - mooreDet (n + 2) A) := by
  by_cases ht : t = 0
  Β· simp [ht, mooreDet_smul, mooreDet_coordinateProjector_zero]
  Β· have hm : t β€’ A + s β€’ coordinateProjector (n + 2) k =
        t β€’ (A + (s / t) β€’ coordinateProjector (n + 2) k) := by
      rw [smul_add, smul_smul]
      congr 1
      rw [mul_div_cancelβ‚€ s ht]
    rw [hm, mooreDet_smul, mooreDet_add_coordinate]
    have hpow : t ^ (n + 2) = t ^ (n + 1) * t := pow_succ t (n + 1)
    rw [hpow]
    field_simp

/-- The determinant polynomial on the time-projector segment has only its
top two powers, with the correct signed cofactor coefficient. -/
theorem mooreDet_rankOne_segment (n : β„•)
    (A : Matrix (Fin (n + 2)) (Fin (n + 2)) (Quaternion ℝ))
    (k : Fin (n + 2)) (t : ℝ) :
    mooreDet (n + 2) (t β€’ A + (1 - t) β€’ coordinateProjector (n + 2) k) =
      t ^ (n + 2) * mooreDet (n + 2) A +
      (1 - t) * t ^ (n + 1) *
        (mooreDet (n + 2) (A + coordinateProjector (n + 2) k) - mooreDet (n + 2) A) :=
  mooreDet_rankOne_pencil n A k t (1 - t)

/-- The diagonal cofactor is the genuine derivative of the Moore polynomial. -/
theorem hasDerivAt_mooreDet_coordinate (n : β„•)
    (A : Matrix (Fin n) (Fin n) (Quaternion ℝ)) (k : Fin n) (t : ℝ) :
    HasDerivAt (fun s : ℝ => mooreDet n (A + s β€’ coordinateProjector n k))
      (mooreDet n (A + coordinateProjector n k) - mooreDet n A) t := by
  have hf : (fun s : ℝ => mooreDet n (A + s β€’ coordinateProjector n k)) =
      fun s => mooreDet n A + s *
        (mooreDet n (A + coordinateProjector n k) - mooreDet n A) := by
    funext s
    exact mooreDet_add_coordinate n A k s
  rw [hf]
  convert! ((hasDerivAt_id t).mul_const
    (mooreDet n (A + coordinateProjector n k) - mooreDet n A)).const_add
      (mooreDet n A) using 1
  simp

/-- Exact integral of the rank-one segment, the algebraic identity behind the
determinant energy in `sections/energy.tex`. -/
theorem integral_mooreDet_rankOne_segment (n : β„•)
    (A : Matrix (Fin (n + 2)) (Fin (n + 2)) (Quaternion ℝ))
    (k : Fin (n + 2)) :
    (∫ t in (0 : ℝ)..1,
      mooreDet (n + 2) (t β€’ A + (1 - t) β€’ coordinateProjector (n + 2) k)) =
      mooreDet (n + 2) A / ((n : ℝ) + 3) +
      (mooreDet (n + 2) (A + coordinateProjector (n + 2) k) - mooreDet (n + 2) A) /
        (((n : ℝ) + 2) * ((n : ℝ) + 3)) := by
  have hf : (fun t : ℝ =>
      mooreDet (n + 2) (t β€’ A + (1 - t) β€’ coordinateProjector (n + 2) k)) =
      fun t => t ^ ((n + 1) + 1) * mooreDet (n + 2) A +
        t ^ (n + 1) * (1 - t) *
          (mooreDet (n + 2) (A + coordinateProjector (n + 2) k) - mooreDet (n + 2) A) := by
    funext t
    rw [mooreDet_rankOne_segment]
    ring
  rw [hf, OAI.Analysis.PDE.Energy.integral_segment]
  norm_num [Nat.cast_add, Nat.cast_one]
  congr 2 <;> ring

end OAI.LinearAlgebra.Moore