File size: 8,246 Bytes
67aee1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import Mathlib

namespace OAI

/-! Closed gradient subspaces of connected oriented multigraphs. -/

open scoped lp

noncomputable section

namespace SingerFour

structure OrientedGraph (V E : Type*) where
  tail : E → V
  head : E → V

namespace OrientedGraph

variable {V E : Type*} (G : OrientedGraph V E)

inductive Walk : V → V → Type _
  | nil (v : V) : Walk v v
  | forward {v : V} (e : E) (p : Walk v (G.tail e)) : Walk v (G.head e)
  | backward {v : V} (e : E) (p : Walk v (G.head e)) : Walk v (G.tail e)

def Connected : Prop := ∀ v w : V, Nonempty (G.Walk v w)

def gradients : Submodule ℝ (ℓ²(E, ℝ)) where
  carrier := {c | ∃ f : V → ℝ, ∀ e, c e = f (G.head e) - f (G.tail e)}
  zero_mem' := ⟨0, by intro e; simp⟩
  add_mem' := by
    rintro c d ⟨f, hf⟩ ⟨g, hg⟩
    refine ⟨f + g, ?_⟩
    intro e
    change c e + d e = (f (G.head e) + g (G.head e)) -
      (f (G.tail e) + g (G.tail e))
    rw [hf e, hg e]
    ring
  smul_mem' := by
    rintro r c ⟨f, hf⟩
    refine ⟨r • f, ?_⟩
    intro e
    change r * c e = r * f (G.head e) - r * f (G.tail e)
    rw [hf e, mul_sub]

@[simp]
theorem mem_gradients (c : ℓ²(E, ℝ)) :
    c ∈ G.gradients ↔ ∃ f : V → ℝ, ∀ e, c e = f (G.head e) - f (G.tail e) := Iff.rfl

def Walk.integral {G : OrientedGraph V E} {v w : V} : G.Walk v w → (ℓ²(E, ℝ) →L[ℝ] ℝ)
  | .nil _ => 0
  | .forward e p => p.integral + lp.evalCLM ℝ (fun _ : E => ℝ) 2 e
  | .backward e p => p.integral - lp.evalCLM ℝ (fun _ : E => ℝ) 2 e

theorem Walk.integral_gradient {G : OrientedGraph V E} {c : ℓ²(E, ℝ)} {f : V → ℝ}
    (hf : ∀ e, c e = f (G.head e) - f (G.tail e)) {v w : V}
    (p : G.Walk v w) : p.integral c = f w - f v := by
  induction p with
  | nil => simp [Walk.integral]
  | forward e p ih =>
    change p.integral c + c e = f (G.head e) - f v
    rw [ih, hf e]
    ring
  | backward e p ih =>
    change p.integral c - c e = f (G.tail e) - f v
    rw [ih, hf e]
    ring

theorem eq_of_zero_differences (hG : G.Connected) {f : V → ℝ}
    (hf : ∀ e, f (G.head e) = f (G.tail e)) (v w : V) : f v = f w := by
  have hgrad : ∀ e, (0 : ℓ²(E, ℝ)) e = f (G.head e) - f (G.tail e) := by
    intro e
    simp [hf e]
  have h := (Classical.choice (hG v w)).integral_gradient hgrad
  simpa only [map_zero, eq_comm, sub_eq_zero] using h.symm

theorem potential_unique (hG : G.Connected) (o : V) {f g : V → ℝ}
    (hedges : ∀ e, f (G.head e) - f (G.tail e) = g (G.head e) - g (G.tail e))
    (ho : f o = g o) : f = g := by
  funext v
  have hzero : ∀ e, (f - g) (G.head e) = (f - g) (G.tail e) := by
    intro e
    have := hedges e
    dsimp
    linarith
  have h := G.eq_of_zero_differences hG hzero o v
  dsimp at h
  linarith

theorem l2_eq_zero_of_constant [Infinite V] (f : ℓ²(V, ℝ)) {r : ℝ}
    (hf : ∀ v, f v = r) : f = 0 := by
  have hs : Summable (fun v : V => ‖r‖ ^ (2 : ℕ)) := by
    simpa only [hf, ENNReal.toReal_ofNat, Real.rpow_two] using
      (lp.memℓp f).summable (by norm_num : 0 < (2 : ENNReal).toReal)
  have hr : r = 0 := by
    have h := (summable_const_iff (β := V) (‖r‖ ^ (2 : ℕ))).mp hs
    simpa using h
  apply lp.ext
  funext v
  simpa only [lp.coeFn_zero, Pi.zero_apply, hr] using hf v

theorem l2_eq_zero_of_zero_differences [Infinite V] (hG : G.Connected)
    (f : ℓ²(V, ℝ)) (hf : ∀ e, f (G.head e) = f (G.tail e)) : f = 0 := by
  let o : V := Classical.choice (inferInstance : Nonempty V)
  exact l2_eq_zero_of_constant f (fun v => G.eq_of_zero_differences hG hf v o)

noncomputable def normalizedPotential (hG : G.Connected) (o v : V) :
    ℓ²(E, ℝ) →L[ℝ] ℝ :=
  (Classical.choice (hG o v)).integral

theorem normalizedPotential_gradient (hG : G.Connected) (o v : V)
    {c : ℓ²(E, ℝ)} {f : V → ℝ}
    (hf : ∀ e, c e = f (G.head e) - f (G.tail e)) :
    G.normalizedPotential hG o v c = f v - f o :=
  Walk.integral_gradient hf _

theorem mem_gradients_iff_normalized (hG : G.Connected) (o : V) (c : ℓ²(E, ℝ)) :
    c ∈ G.gradients ↔ ∀ e,
      c e = G.normalizedPotential hG o (G.head e) c -
        G.normalizedPotential hG o (G.tail e) c := by
  constructor
  · rintro ⟨f, hf⟩ e
    rw [G.normalizedPotential_gradient hG o (G.head e) hf,
      G.normalizedPotential_gradient hG o (G.tail e) hf, hf e]
    ring
  · intro hc
    exact ⟨fun v => G.normalizedPotential hG o v c, hc⟩

theorem isClosed_gradients (hG : G.Connected) (o : V) :
    IsClosed (G.gradients : Set (ℓ²(E, ℝ))) := by
  have hset : (G.gradients : Set (ℓ²(E, ℝ))) =
      ⋂ e : E, {c : ℓ²(E, ℝ) | c e =
        G.normalizedPotential hG o (G.head e) c -
          G.normalizedPotential hG o (G.tail e) c} := by
    ext c
    simp only [SetLike.mem_coe, Set.mem_iInter, Set.mem_ofPred,
      G.mem_gradients_iff_normalized hG o c]
  rw [hset]
  apply isClosed_iInter
  intro e
  exact isClosed_eq (lp.evalCLM ℝ (fun _ : E => ℝ) 2 e).continuous
    ((G.normalizedPotential hG o (G.head e)).continuous.sub
      (G.normalizedPotential hG o (G.tail e)).continuous)

theorem completeSpace_gradients (hG : G.Connected) (o : V) :
    CompleteSpace G.gradients :=
  (G.isClosed_gradients hG o).completeSpace_coe

def finiteSupportGradients : Submodule ℝ (ℓ²(E, ℝ)) where
  carrier := {c | ∃ f : V →₀ ℝ, ∀ e, c e = f (G.head e) - f (G.tail e)}
  zero_mem' := ⟨0, by intro e; simp⟩
  add_mem' := by
    rintro c d ⟨f, hf⟩ ⟨g, hg⟩
    refine ⟨f + g, ?_⟩
    intro e
    change c e + d e = (f (G.head e) + g (G.head e)) -
      (f (G.tail e) + g (G.tail e))
    rw [hf e, hg e]
    ring
  smul_mem' := by
    rintro r c ⟨f, hf⟩
    refine ⟨r • f, ?_⟩
    intro e
    change r * c e = r * f (G.head e) - r * f (G.tail e)
    rw [hf e, mul_sub]

def LocallyFinite : Prop :=
  ∀ v : V, Set.Finite {e : E | G.tail e = v ∨ G.head e = v}

theorem hasFiniteSupport_differential (hG : G.LocallyFinite) (f : V →₀ ℝ) :
    (Function.support (fun e => f (G.head e) - f (G.tail e))).Finite := by
  classical
  have hfinite : (⋃ v ∈ (f.support : Set V),
      {e : E | G.tail e = v ∨ G.head e = v}).Finite :=
    f.support.finite_toSet.biUnion (fun v _ => hG v)
  apply hfinite.subset
  intro e he
  change f (G.head e) - f (G.tail e) ≠ 0 at he
  have hside : G.head e ∈ f.support ∨ G.tail e ∈ f.support := by
    by_contra h
    push Not at h
    simp [Finsupp.notMem_support_iff.mp h.1, Finsupp.notMem_support_iff.mp h.2] at he
  rcases hside with hh | ht
  · exact Set.mem_iUnion₂.mpr ⟨G.head e, hh, Or.inr rfl⟩
  · exact Set.mem_iUnion₂.mpr ⟨G.tail e, ht, Or.inl rfl⟩

def finiteSupportDifferential (hG : G.LocallyFinite) :
    (V →₀ ℝ) →ₗ[ℝ] ℓ²(E, ℝ) where
  toFun f := ⟨fun e => f (G.head e) - f (G.tail e),
    (memℓp_zero (G.hasFiniteSupport_differential hG f)).of_exponent_ge (by positivity)⟩
  map_add' f g := by
    apply lp.ext
    funext e
    change f (G.head e) + g (G.head e) - (f (G.tail e) + g (G.tail e)) =
      (f (G.head e) - f (G.tail e)) + (g (G.head e) - g (G.tail e))
    ring
  map_smul' r f := by
    apply lp.ext
    funext e
    exact mul_sub r (f (G.head e)) (f (G.tail e)) |>.symm

@[simp]
theorem finiteSupportDifferential_apply (hG : G.LocallyFinite) (f : V →₀ ℝ) (e : E) :
    G.finiteSupportDifferential hG f e = f (G.head e) - f (G.tail e) := rfl

theorem range_finiteSupportDifferential (hG : G.LocallyFinite) :
    LinearMap.range (G.finiteSupportDifferential hG) = G.finiteSupportGradients := by
  ext c
  constructor
  · rintro ⟨f, rfl⟩
    exact ⟨f, fun e => rfl⟩
  · rintro ⟨f, hf⟩
    refine ⟨f, ?_⟩
    apply lp.ext
    funext e
    exact (hf e).symm

def zeroBoundaryGradients : Submodule ℝ (ℓ²(E, ℝ)) :=
  G.finiteSupportGradients.topologicalClosure

theorem finiteSupportGradients_le : G.finiteSupportGradients ≤ G.gradients := by
  rintro c ⟨f, hf⟩
  exact ⟨f, hf⟩

theorem zeroBoundaryGradients_le (hG : G.Connected) (o : V) :
    G.zeroBoundaryGradients ≤ G.gradients :=
  G.finiteSupportGradients.topologicalClosure_minimal G.finiteSupportGradients_le
    (G.isClosed_gradients hG o)

end OrientedGraph
end SingerFour

end

end OAI