Repository navigation
Expand file tree
/
Copy pathChallenge.lean
More file actions
190 lines (135 loc) · 6.18 KB
/
Copy pathChallenge.lean
File metadata and controls
190 lines (135 loc) · 6.18 KB
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
import Mathlib
namespace OAI
noncomputable section
open scoped BigOperators Topology
open Filter
universe uV uE uIndex uι
namespace MatchingEntropyBounds
structure LooplessGraph (V : Type uV) (E : Type uE) where
left : E → V
right : E → V
loopless : ∀ e, left e ≠ right e
variable {V : Type uV} {E : Type uE}
[Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E]
namespace LooplessGraph
def Incident (G : LooplessGraph V E) (v : V) (e : E) : Prop :=
G.left e = v ∨ G.right e = v
instance incidentDecidable (G : LooplessGraph V E) (v : V) (e : E) :
Decidable (G.Incident v e) := inferInstanceAs (Decidable (G.left e = v ∨ G.right e = v))
def IsPerfectMatching (G : LooplessGraph V E) (M : Finset E) : Prop :=
∀ v, ∃! e, e ∈ M ∧ G.Incident v e
abbrev Matching (G : LooplessGraph V E) := {M : Finset E // G.IsPerfectMatching M}
instance matchingFintype (G : LooplessGraph V E) : Fintype G.Matching :=
Fintype.ofFinite _
def indicator (G : LooplessGraph V E) (M : G.Matching) (e : E) : ℝ :=
if e ∈ M.val then 1 else 0
def polytope (G : LooplessGraph V E) : Set (E → ℝ) :=
convexHull ℝ (Set.range G.indicator)
end LooplessGraph
end MatchingEntropyBounds
end
noncomputable section
open scoped BigOperators Topology
open Filter
universe uV uE uI uJ uA uB uC uW uF uD uι
namespace MatchingEntropyBounds.LooplessGraph
variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E]
def Crosses (G : LooplessGraph V E) (S : Finset V) (e : E) : Prop :=
(G.left e ∈ S ∧ G.right e ∉ S) ∨ (G.left e ∉ S ∧ G.right e ∈ S)
instance crossesDecidable (G : LooplessGraph V E) (S : Finset V) (e : E) :
Decidable (G.Crosses S e) := inferInstanceAs (Decidable
((G.left e ∈ S ∧ G.right e ∉ S) ∨ (G.left e ∉ S ∧ G.right e ∈ S)))
def cut (G : LooplessGraph V E) (S : Finset V) : Finset E :=
Finset.univ.filter (G.Crosses S)
def degree (G : LooplessGraph V E) (x : E → ℝ) (v : V) : ℝ :=
∑ e, if G.Incident v e then x e else 0
def cutMass (G : LooplessGraph V E) (x : E → ℝ) (S : Finset V) : ℝ :=
∑ e ∈ G.cut S, x e
end MatchingEntropyBounds.LooplessGraph
end
noncomputable section
open scoped BigOperators Topology
open Filter
universe uV uE uI uJ uA uB uC uW uF uD uι
namespace MatchingEntropyBounds.Refined
section TriangleExpansion
variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E]
def triangleTip (v : V) (i : Fin 3) : V ⊕ Fin 2 := ![Sum.inl v, Sum.inr 0, Sum.inr 1] i
def triangleCollapse (v : V) : V ⊕ Fin 2 → V := Sum.elim id (fun _ => v)
def reattach (v : V) (i : Fin 3) (w : V) : V ⊕ Fin 2 :=
if w = v then triangleTip v i else Sum.inl w
omit [Fintype V] [Fintype E] [DecidableEq E] in
theorem collapse_reattach (v : V) (i : Fin 3) (w : V) :
triangleCollapse v (reattach v i w) = w := by
by_cases h : w = v
· subst w
fin_cases i <;> simp [reattach,triangleTip,triangleCollapse]
· simp [reattach,h,triangleCollapse]
def triangleExpansion (G : LooplessGraph V E) (c : E → Fin 3) (v : V) :
LooplessGraph (V ⊕ Fin 2) (E ⊕ Fin 3) where
left := Sum.elim (fun e => reattach v (c e) (G.left e)) (fun i => triangleTip v (i + 1))
right := Sum.elim (fun e => reattach v (c e) (G.right e)) (fun i => triangleTip v (i + 2))
loopless := by
intro e h
rcases e with e | i
· have hh := congrArg (triangleCollapse v) h
exact G.loopless e ((collapse_reattach v (c e) (G.left e)).symm.trans
(hh.trans (collapse_reattach v (c e) (G.right e))))
· fin_cases i <;> simp [triangleTip] at h
def triangleVertices (v : V) : Finset (V ⊕ Fin 2) := Finset.univ.image (triangleTip v)
end TriangleExpansion
end MatchingEntropyBounds.Refined
end
namespace CanonicalFace198
variable {A B : Type*} [AddCommGroup A] [Module ℝ A]
[AddCommGroup B] [Module ℝ B]
def facesThrough (P : Set A) (x : A) : Set (Set A) :=
{F | Convex ℝ F ∧ IsExtreme ℝ P F ∧ x ∈ F}
def minFace (P : Set A) (x : A) : Set A := ⋂₀ facesThrough P x
end CanonicalFace198
noncomputable section
open scoped BigOperators
open MatchingEntropyBounds MatchingEntropyBounds.Refined
namespace TriangleFace198
variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E]
def LocalLabels (G : LooplessGraph V E) (v : V) (c : E → Fin 3) : Prop :=
∀ i, ∃! e, G.Incident v e ∧ c e = i
def localEdge (G : LooplessGraph V E) (c : E → Fin 3) (v : V)
(hc : LocalLabels G v c) (i : Fin 3) : E := Classical.choose (hc i)
def localExtension (G : LooplessGraph V E) (c : E → Fin 3) (v : V)
(hc : LocalLabels G v c) : (E → ℝ) →ₗ[ℝ] (E ⊕ Fin 3 → ℝ) where
toFun x := Sum.elim x (fun i => x (localEdge G c v hc i))
map_add' x y := by ext e; cases e <;> rfl
map_smul' a x := by ext e; cases e <;> rfl
def oldRestriction : (E ⊕ Fin 3 → ℝ) →ₗ[ℝ] (E → ℝ) where
toFun y e := y (Sum.inl e)
map_add' _ _ := rfl
map_smul' _ _ := rfl
end TriangleFace198
end
noncomputable section
open scoped BigOperators
open MatchingEntropyBounds MatchingEntropyBounds.Refined
namespace TriangleFace198
universe uV uE
variable {V : Type uV} {E : Type uE} [instFintypeV : Fintype V] [Fintype E] [DecidableEq V] [instDecidableEqE : DecidableEq E]
theorem triangle_expansion_face {V : Type uV} {E : Type uE}
[Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] (G : LooplessGraph V E) (v : V)
(hdeg : Fintype.card {e : E // G.Incident v e} = 3)
(_hmatching : Nonempty G.Matching) :
∃ (c : E → Fin 3) (hc : LocalLabels G v c),
let H := triangleExpansion G c v
let f := localExtension G c v hc
let Q := {y | y ∈ H.polytope ∧ H.cutMass y (triangleVertices v) = 1}
f '' G.polytope = Q ∧
Convex ℝ Q ∧ IsExtreme ℝ H.polytope Q ∧
(∀ x, oldRestriction (f x) = x) ∧
(∀ y ∈ Q, f (oldRestriction y) = y) ∧
(∀ x e, f x (Sum.inl e) = x e) ∧
(∀ x i, f x (Sum.inr i) = x (localEdge G c v hc i)) ∧
(∀ x, (∀ e, x e = (1/3 : ℝ)) → ∀ e, f x e = (1/3 : ℝ)) ∧
(∀ x ∈ G.polytope, CanonicalFace198.minFace H.polytope (f x) = f '' CanonicalFace198.minFace G.polytope x) := by
sorry
end TriangleFace198
end
end OAI