lemmaports_reachable {a b : V} (ha : G.degree a = 1)
(other : ∀ v, v ≠ a → v ≠ b →Even (G.degree v)) : G.Reachable a b :=by
proof · 19
lines
classical
letS : SetV:= {v | G.Reachable a v}
letA : S:= ⟨a, SimpleGraph.Reachable.rfl⟩
have deg (v : S) : (G.induce S).degree v = G.degree v :=by
apply G.degree_induce_of_neighborSet_subset
intro w hw
exact v.property.trans hw.reachable
havehA : Odd ((G.induce S).degree A) :=by rw [deg, ha]; decide
obtain ⟨v, hvA, hv⟩ := (G.induce S).exists_ne_odd_degree_of_exists_odd_degree A hA
havehva : (v : V) ≠ a :=by
intro e
apply hvA
exact Subtype.ext e
havehvb : (v : V) = b :=by
by_contra e
have he := other v hva e
rw [deg] at hv
exact (Nat.not_even_iff_odd.mpr hv) he
exact hvb ▸ v.property
lemmapath_neighbor_eq {a b v : V} (hab : a ≠ b)
(ha : G.degree a = 1) (hb : G.degree b = 1)
(upper : ∀ v, G.degree v ≤2)
(p : G.Walk a b) (hp : p.IsPath) (hv : v ∈ p.support) :
p.toSubgraph.neighborSet v = G.neighborSet v :=by
proof · 20
lines
classical
apply Set.eq_of_subset_of_ncard_le (p.toSubgraph.neighborSet_subset v)
rw [ncard_neighbors]
by_cases h : v = a
· subst v
rw [ha, hp.neighborSet_toSubgraph_startpoint (Walk.not_nil_of_ne hab)]
simp
by_cases h' : v = b
· subst v
rw [hb, hp.neighborSet_toSubgraph_endpoint (Walk.not_nil_of_ne hab)]
simp
obtain ⟨i, hi, hil⟩ :=Walk.mem_support_iff_exists_getVert.mp hv
havehi0 : i ≠0:=by intro e; subst i; exact h (hi.symm.trans p.getVert_zero)
havehil' : i < p.length :=by
apply lt_of_le_of_ne hil
intro e
subst i
exact h' (hi.symm.trans p.getVert_length)
rw [← hi, hp.ncard_neighborSet_toSubgraph_internal_eq_two hi0 hil']
exact upper _
lemmapath_closed {a b v w : V} (hab : a ≠ b)
(ha : G.degree a = 1) (hb : G.degree b = 1)
(upper : ∀ v, G.degree v ≤2)
(p : G.Walk a b) (hp : p.IsPath) (hv : v ∈ p.support) (hvw : G.Adj v w) :
w ∈ p.support :=by
proof · 5
lines
havehn : p.toSubgraph.Adj v w :=by
change w ∈ p.toSubgraph.neighborSet v
rw [path_neighbor_eq G hab ha hb upper p hp hv]
exact hvw
exact p.mem_verts_toSubgraph.mp (p.toSubgraph.edge_vert hn.symm)
lemmaresidual_isCycles {a b : V} (hab : a ≠ b)
(ha : G.degree a = 1) (hb : G.degree b = 1)
(other : ∀ v, v ≠ a → v ≠ b →G.degree v = 0∨G.degree v = 2)
(p : G.Walk a b) (hp : p.IsPath) :
(G \ p.toSubgraph.spanningCoe).IsCycles:=by
proof · 37
lines
classical
have upper (v : V) : G.degree v ≤2:=byby_cases h : v = a
· subst v; rw [ha]; decide
by_cases h' : v = b
· subst v; rw [hb]; decide
rcases other v h h' with h | h <;> omega
intro v hv
havehvnot : v ∉ p.support :=by
intro hvp
obtain ⟨w, hw⟩ := hv
have h := path_neighbor_eq G hab ha hb upper p hp hvp
simp only [SimpleGraph.mem_neighborSet, SimpleGraph.sdiff_adj,
SimpleGraph.Subgraph.spanningCoe_adj] at hw
apply hw.2
change w ∈ p.toSubgraph.neighborSet v
rw [h]
exact hw.1haveheq : (G \ p.toSubgraph.spanningCoe).neighborSet v = G.neighborSet v :=by
ext w
simp only [SimpleGraph.mem_neighborSet, SimpleGraph.sdiff_adj,
SimpleGraph.Subgraph.spanningCoe_adj]
constructor
· exact And.left
· intro hw
refine ⟨hw, ?_⟩
intro hf
exact hvnot (p.mem_verts_toSubgraph.mp (p.toSubgraph.edge_vert hf))
rw [heq, ncard_neighbors]
havehva : v ≠ a :=by intro e; subst v; exact hvnot p.start_mem_support
havehvb : v ≠ b :=by intro e; subst v; exact hvnot p.end_mem_support
rcases other v hva hvb with h | h
· rw [heq] at hv
have hn := hv.ncard_pos (Set.toFinite _)
rw [ncard_neighbors, h] at hn
omega
· exact h
Every finite nonbranching two-port configuration is a path plus cycles. The
path has no edge to the residual cycle graph.
theorempath_and_cycles {a b : V} (hab : a ≠ b)
(ha : G.degree a = 1) (hb : G.degree b = 1)
(other : ∀ v, v ≠ a → v ≠ b →G.degree v = 0∨G.degree v = 2) :
∃p : G.Walk a b, p.IsPath∧ (G \ p.toSubgraph.spanningCoe).IsCycles∧∀ v ∈ p.support, p.toSubgraph.neighborSet v = G.neighborSet v :=by
proof · 11
lines
have upper (v : V) : G.degree v ≤2:=byby_cases h : v = a
· subst v; rw [ha]; decide
by_cases h' : v = b
· subst v; rw [hb]; decide
rcases other v h h' with h | h <;> omega
have hr := ports_reachable G ha (fun v h h' =>by
rcases other v h h' with e | e <;> rw [e] <;> decide)
obtain ⟨p, hp⟩ := hr.exists_isPath
exact ⟨p, hp, residual_isCycles G hab ha hb other p hp,
fun v hv => path_neighbor_eq G hab ha hb upper p hp hv⟩
The hard-wall two-port graph: the two exterior markers have only their
prescribed incident edge; internal adjacency remains unchanged.
lemmachain_snoc_ports (R : α → α →Prop) (a b : α) (xs : List α) :
(xs.map Sum.inl ++ [Sum.inr true]).IsChain (portRel R a b) ↔
xs.IsChainR∧∀ z ∈ xs.getLast?, z=b :=by
lemmachain_ports (R : α → α →Prop) (a b : α) (xs : List α) :
(Sum.inr false :: (xs.map Sum.inl ++ [Sum.inr true])).IsChain (portRel R a b) ↔
xs.IsChainR∧ xs.head?=some a ∧ xs.getLast?=some b :=by
proof · 13
lines
cases xs with
| nil => simp [portRel]
| cons x xs =>
rw [List.isChain_cons,chain_snoc_ports]
havehh : (∀ y ∈ ((x::xs).map Sum.inl ++ [Sum.inr true]).head?,
portRel R a b (.inr false) y) ↔ x=a :=by
simp [portRel]
havehl : (∀ z ∈ (x::xs).getLast?, z=b) ↔ (x::xs).getLast?=some b :=by
rw [List.getLast?_eq_some_getLast (by simp)]
simp
rw [hh,hl]
simp only [List.head?_cons,Option.some.injEq]
tauto
lemmalist_all_inl (l : List (α ⊕ Bool))
(h : ∀ t ∈ l, ∀b : Bool, t ≠Sum.inr b) :
∃xs : List α, xs.map Sum.inl=l :=by
proof · 8
lines
induction l with
| nil => exact ⟨[],rfl⟩
| cons t l ih =>
cases t with
| inr b => exact (h _ (by simp) b rfl).elim
| inl x =>
obtain ⟨xs,hxs⟩ := ih (by aesop)
exact ⟨x::xs,by simp [hxs]⟩