Lean / Reader
Lean reader

OddPacking.lean

83 lines5 declarationsno sorryimports AdjacentSide

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports AdjacentSide, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import AdjacentSide
  2. namespace TerminalCycles.RootedBlock
  3. open SimpleGraph SimpleGraph.Walk
  4. universe u
  5. variable {U V W : Type u}
  6. structure OddCycle (G : SimpleGraph W) where
  7. base : W
  8. walk : G.Walk base base
  9. simple : walk.IsCycle
  10. odd : walk.length % 2 = 1
  11. def OddCycle.Disjoint {G : SimpleGraph W} (a b : OddCycle G) : Prop :=
  12. ∀ z ∈ a.walk.support, z ∉ b.walk.support
  13. private def copyCycle {B : SimpleGraph V} {G : SimpleGraph W} (f : B ↪g G)
  14. (q : OddCycle B) : OddCycle G :=
  15. ⟨f q.base,q.walk.map f.toHom,q.simple.map (f:=f.toHom) f.injective,by simpa using q.odd⟩
  16. private theorem copy_mem {B : SimpleGraph V} {G : SimpleGraph W} (f : B ↪g G)
  17. (q : OddCycle B) {v : W} (hv : v ∈ (copyCycle f q).walk.support) :
  18. ∃ a : V, f a=v := by
  19. change v ∈ (q.walk.map f.toHom).support at hv
  20. rw [Walk.support_map,List.mem_map] at hv
  21. obtain ⟨a,_,h⟩ := hv
  22. exact ⟨a,h⟩
  23. /-- An adjacent terminal pair on even one side of the cut gives three disjoint odd cycles. -/
  24. theorem three_disjoint_odd [Finite U] [Finite V] [Finite W] (R : SimpleGraph V) (G : SimpleGraph W)
  25. (H : SimpleGraph U) (f : R ↪g G) (g : H ↪g G)
  26. {s t c : W} (st : G.Adj s t) (cs : G.Adj c s) (ct : G.Adj c t)
  27. (outR : ∀ a, f a ≠ c ∧ f a ≠ s ∧ f a ≠ t)
  28. (outH : ∀ a, g a ≠ c ∧ g a ≠ s ∧ g a ≠ t)
  29. (separate : ∀ a b, f a ≠ g b)
  30. {x y : V} (ne : x ≠ y) (missing : ¬ R.Adj x y)
  31. (dx : 2 ≤ valence R x) (dy : 2 ≤ valence R y)
  32. (ordinary : ∀ v, v ≠ x → v ≠ y → 3 ≤ valence R v)
  33. (small : Nat.card V < Nat.card W) (half : 2 * Nat.card V ≤ Nat.card W+1)
  34. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G)
  35. {a b : U} (ab : a ≠ b) (missingH : ¬ H.Adj a b)
  36. (da : 2 ≤ valence H a) (db : 2 ≤ valence H b)
  37. (ordinaryH : ∀ v, v ≠ a → v ≠ b → 3 ≤ valence H v)
  38. (smallH : Nat.card U < Nat.card W) (halfH : 2 * Nat.card U ≤ Nat.card W+1) :
  39. ∃ C D E : OddCycle G, C.Disjoint D ∧ C.Disjoint E ∧ D.Disjoint E := by
  40. have noR : ¬ hasPowerCycle R := by
  41. rintro ⟨k,v,p,hk,hp,len⟩
  42. exact absent ⟨k,_,p.map f.toHom,hk,hp.map (f:=f.toHom) f.injective,by simpa using len⟩
  43. have lens := two_terminal_lengths R G ne missing dx dy ordinary small half noR minimal
  44. obtain ⟨i,r,hr,ro⟩ := odd_cycle_of_lengths lens.1 lens.2
  45. have noH : ¬ hasPowerCycle H := by
  46. rintro ⟨k,v,p,hk,hp,len⟩
  47. exact absent ⟨k,_,p.map g.toHom,hk,hp.map (f:=g.toHom) g.injective,by simpa using len⟩
  48. have lensH := two_terminal_lengths H G ab missingH da db ordinaryH smallH halfH noH minimal
  49. obtain ⟨j,h,hh,ho⟩ := odd_cycle_of_lengths lensH.1 lensH.2
  50. let d : OddCycle R := ⟨i,r,hr,ro⟩
  51. let e : OddCycle H := ⟨j,h,hh,ho⟩
  52. let edge : G.Walk s t := cons st nil
  53. have path : edge.IsPath := by simp [edge,cons_isPath_iff,st.ne]
  54. have unused : c ∉ edge.support := by simp [edge,cs.ne,ct.ne]
  55. let tri : OddCycle G := ⟨c,_,close_internal edge path st.ne unused cs ct.symm,by simp [edge]⟩
  56. have inside {v : W} (hv : v ∈ tri.walk.support) : v=c ∨ v=s ∨ v=t := by
  57. simpa [tri,edge,support_concat,or_assoc,or_comm,or_left_comm] using hv
  58. refine ⟨tri,copyCycle f d,copyCycle g e,?_,?_,?_⟩
  59. · intro v hv other
  60. obtain ⟨z,rfl⟩ := copy_mem f d other
  61. rcases inside hv with h|h|h
  62. · exact (outR z).1 h
  63. · exact (outR z).2.1 h
  64. · exact (outR z).2.2 h
  65. · intro v hv other
  66. obtain ⟨z,rfl⟩ := copy_mem g e other
  67. rcases inside hv with h|h|h
  68. · exact (outH z).1 h
  69. · exact (outH z).2.1 h
  70. · exact (outH z).2.2 h
  71. · intro v hv other
  72. obtain ⟨u,hu⟩ := copy_mem f d hv
  73. obtain ⟨z,hz⟩ := copy_mem g e other
  74. exact separate u z (hu.trans hz.symm)
  75. #print axioms three_disjoint_odd
  76. end TerminalCycles.RootedBlock