File size: 6,575 Bytes
e82fac3 | 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 | import OAI.Combinatorics.PortMatching.Basic
namespace OAI
/-! Perfect-matching-preserving port-path degree reduction for finite simple graphs. -/
noncomputable section
namespace Matching205.Forward
universe u
def Pair (c i j : ℕ) : Prop :=
(i < c ∧ i % 2 = 0 ∧ j = i + 1) ∨
(j < c ∧ j % 2 = 0 ∧ i = j + 1) ∨
(c < i ∧ i % 2 = 1 ∧ j = i + 1) ∨
(c < j ∧ j % 2 = 1 ∧ i = j + 1)
lemma pair_symm {c i j : ℕ} (h : Pair c i j) : Pair c j i := by
rcases h with h | h | h | h
· exact Or.inr (Or.inl h)
· exact Or.inl h
· exact Or.inr (Or.inr (Or.inr h))
· exact Or.inr (Or.inr (Or.inl h))
lemma pair_consecutive {c i j : ℕ} (h : Pair c i j) :
i + 1 = j ∨ j + 1 = i := by
dsimp [Pair] at h
omega
lemma pair_not_center {k i j : ℕ} (h : Pair (2 * k) i j) : i ≠ 2 * k := by
dsimp [Pair] at h
omega
lemma pair_completion (r k : ℕ) (hk : k < r)
(i : Fin (2 * r - 1)) (hi : i.val ≠ 2 * k) :
∃! j : Fin (2 * r - 1), Pair (2 * k) i.val j.val := by
have hib := i.isLt
by_cases hl : i.val < 2 * k
· by_cases hp : i.val % 2 = 0
· refine ⟨⟨i.val + 1, by omega⟩, ?_, ?_⟩
· dsimp [Pair]; omega
· intro j hj; apply Fin.ext; dsimp [Pair] at hj; dsimp; omega
· refine ⟨⟨i.val - 1, by omega⟩, ?_, ?_⟩
· dsimp [Pair]; omega
· intro j hj; apply Fin.ext; dsimp [Pair] at hj; dsimp; omega
· by_cases hp : i.val % 2 = 0
· refine ⟨⟨i.val - 1, by omega⟩, ?_, ?_⟩
· dsimp [Pair]; omega
· intro j hj; apply Fin.ext; dsimp [Pair] at hj; dsimp; omega
· refine ⟨⟨i.val + 1, by omega⟩, ?_, ?_⟩
· dsimp [Pair]; omega
· intro j hj; apply Fin.ext; dsimp [Pair] at hj; dsimp; omega
variable {V : Type u} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj]
variable (M : G.Subgraph) (hM : M.IsPerfectMatching)
omit [Fintype V] [DecidableRel G.Adj] in
include hM in
private lemma unique_neighbor (v : V) : ∃! w, M.Adj v w :=
SimpleGraph.Subgraph.isPerfectMatching_iff.mp hM v
def neighbor (v : V) : G.neighborSet v :=
⟨(unique_neighbor G M hM v).choose,
M.adj_sub (unique_neighbor G M hM v).choose_spec.1⟩
omit [Fintype V] [DecidableRel G.Adj] in
lemma neighbor_adj (v : V) : M.Adj v (neighbor G M hM v).val :=
(unique_neighbor G M hM v).choose_spec.1
def center (v : V) : ℕ :=
2 * ((Fintype.equivFin (G.neighborSet v)) (neighbor G M hM v)).val
def selected (v : V) : Vertex G := port G v (neighbor G M hM v)
lemma port_eq_selected {v w : V} (h : M.Adj v w) :
port G v ⟨w, M.adj_sub h⟩ = selected G M hM v := by
have hw : w = (neighbor G M hM v).val :=
(unique_neighbor G M hM v).choose_spec.2 w h
have hn : (⟨w, M.adj_sub h⟩ : G.neighborSet v) = neighbor G M hM v :=
Subtype.ext hw
exact congrArg (port G v) hn
def Local (x y : Vertex G) : Prop :=
x.1 = y.1 ∧ Pair (center G M hM x.1) x.2.val y.2.val
def Across (x y : Vertex G) : Prop :=
External G x y ∧ M.Adj x.1 y.1
lemma local_symm {x y : Vertex G} (h : Local G M hM x y) : Local G M hM y x := by
refine ⟨h.1.symm, ?_⟩
have hc : center G M hM x.1 = center G M hM y.1 :=
congrArg (center G M hM) h.1
have hp : Pair (center G M hM x.1) y.2.val x.2.val =
Pair (center G M hM y.1) y.2.val x.2.val :=
congrArg (fun c : ℕ => Pair c y.2.val x.2.val) hc
exact hp.mp (pair_symm h.2)
lemma across_symm {x y : Vertex G} (h : Across G M x y) : Across G M y x :=
⟨external_symm G h.1, h.2.symm⟩
lemma across_selected {x y : Vertex G} (h : Across G M x y) :
x = selected G M hM x.1 := by
obtain ⟨hg, hx, _⟩ := h.1
exact hx.trans (port_eq_selected G M hM h.2)
include hM in
lemma across_unique {x y z : Vertex G}
(hy : Across G M x y) (hz : Across G M x z) : y = z := by
have hv : y.1 = z.1 := hM.1.eq_of_adj_left hy.2 hz.2
calc
y = selected G M hM y.1 := across_selected G M hM (across_symm G M hy)
_ = selected G M hM z.1 := congrArg (selected G M hM) hv
_ = z := (across_selected G M hM (across_symm G M hz)).symm
lemma selected_across (v : V) : ∃ y, Across G M (selected G M hM v) y := by
let w := neighbor G M hM v
let h : G.Adj v w.val := w.property
refine ⟨port G w.val ⟨v, h.symm⟩, ?_⟩
exact ⟨⟨h, rfl, rfl⟩, neighbor_adj G M hM v⟩
lemma local_not_selected {x y : Vertex G} (h : Local G M hM x y) :
x ≠ selected G M hM x.1 := by
intro hx
have hp := pair_not_center h.2
apply hp
have hv := congrArg (fun z : Vertex G => z.2.val) hx
exact hv
lemma local_completion (x : Vertex G) (hx : x ≠ selected G M hM x.1) :
∃! y, Local G M hM x y := by
rcases x with ⟨v, i⟩
let k := (Fintype.equivFin (G.neighborSet v)) (neighbor G M hM v)
have hi : i.val ≠ 2 * k.val := by
intro hi
apply hx
have hfin : i = (selected G M hM v).2 := Fin.ext hi
cases hfin
rfl
obtain ⟨j, hj, hu⟩ := pair_completion (arity G v) k.val k.isLt i hi
refine ⟨⟨v, j⟩, ⟨rfl, hj⟩, ?_⟩
rintro ⟨w, l⟩ ⟨hw, hl⟩
dsimp at hw
subst w
have hlj : l = j := hu l hl
cases hlj
rfl
def extend : (graph G).Subgraph where
verts := Set.univ
Adj x y := Local G M hM x y ∨ Across G M x y
adj_sub := by
intro x y h
rcases h with h | h
· exact Or.inl ⟨h.1, pair_consecutive h.2⟩
· exact Or.inr h.1
edge_vert := fun _ => Set.mem_univ _
symm := ⟨by
intro x y h
exact h.elim (fun h => Or.inl (local_symm G M hM h))
(fun h => Or.inr (across_symm G M h))⟩
theorem extend_perfect : (extend G M hM).IsPerfectMatching := by
classical
apply SimpleGraph.Subgraph.isPerfectMatching_iff.mpr
intro x
by_cases hx : x = selected G M hM x.1
· obtain ⟨y, hy⟩ := selected_across G M hM x.1
have hy' : Across G M x y := hx.symm ▸ hy
refine ⟨y, Or.inr hy', ?_⟩
intro z hz
rcases hz with hz | hz
· exact False.elim (local_not_selected G M hM hz hx)
· exact across_unique G M hM hz hy'
· obtain ⟨y, hy, hu⟩ := local_completion G M hM x hx
refine ⟨y, Or.inl hy, ?_⟩
intro z hz
rcases hz with hz | hz
· exact hu z hz
· exact False.elim (hx (across_selected G M hM hz))
theorem decode_extend_adj (v w : V) :
(decode G (extend G M hM)).Adj v w ↔ M.Adj v w := by
constructor
· rintro ⟨h, hm⟩
rcases hm with hi | he
· have hvw : v = w := hi.1
subst w
exact False.elim (G.irrefl h)
· exact he.2
· intro h
exact ⟨M.adj_sub h, Or.inr ⟨⟨M.adj_sub h, rfl, rfl⟩, h⟩⟩
end Matching205.Forward
end
end OAI
|