Lean / Reader
Lean readerOddPacking.lean
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.
import AdjacentSidenamespace TerminalCycles.RootedBlockopen SimpleGraph SimpleGraph.Walkuniverse uvariable {U V W : Type u}structure OddCycle (G : SimpleGraph W) wherebase : Wwalk : G.Walk base basesimple : walk.IsCycleodd : walk.length % 2 = 1def OddCycle.Disjoint {G : SimpleGraph W} (a b : OddCycle G) : Prop :=∀ z ∈ a.walk.support, z ∉ b.walk.supportprivate def copyCycle {B : SimpleGraph V} {G : SimpleGraph W} (f : B ↪g G)(q : OddCycle B) : OddCycle G :=⟨f q.base,q.walk.map f.toHom,q.simple.map (f:=f.toHom) f.injective,by simpa using q.odd⟩private theorem copy_mem {B : SimpleGraph V} {G : SimpleGraph W} (f : B ↪g G)(q : OddCycle B) {v : W} (hv : v ∈ (copyCycle f q).walk.support) :∃ a : V, f a=v := bychange v ∈ (q.walk.map f.toHom).support at hvrw [Walk.support_map,List.mem_map] at hvobtain ⟨a,_,h⟩ := hvexact ⟨a,h⟩/-- An adjacent terminal pair on even one side of the cut gives three disjoint odd cycles. -/theorem three_disjoint_odd [Finite U] [Finite V] [Finite W] (R : SimpleGraph V) (G : SimpleGraph W)(H : SimpleGraph U) (f : R ↪g G) (g : H ↪g G){s t c : W} (st : G.Adj s t) (cs : G.Adj c s) (ct : G.Adj c t)(outR : ∀ a, f a ≠ c ∧ f a ≠ s ∧ f a ≠ t)(outH : ∀ a, g a ≠ c ∧ g a ≠ s ∧ g a ≠ t)(separate : ∀ a b, f a ≠ g b){x y : V} (ne : x ≠ y) (missing : ¬ R.Adj x y)(dx : 2 ≤ valence R x) (dy : 2 ≤ valence R y)(ordinary : ∀ v, v ≠ x → v ≠ y → 3 ≤ valence R v)(small : Nat.card V < Nat.card W) (half : 2 * Nat.card V ≤ Nat.card W+1)(absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G){a b : U} (ab : a ≠ b) (missingH : ¬ H.Adj a b)(da : 2 ≤ valence H a) (db : 2 ≤ valence H b)(ordinaryH : ∀ v, v ≠ a → v ≠ b → 3 ≤ valence H v)(smallH : Nat.card U < Nat.card W) (halfH : 2 * Nat.card U ≤ Nat.card W+1) :∃ C D E : OddCycle G, C.Disjoint D ∧ C.Disjoint E ∧ D.Disjoint E := byhave noR : ¬ hasPowerCycle R := byrintro ⟨k,v,p,hk,hp,len⟩exact absent ⟨k,_,p.map f.toHom,hk,hp.map (f:=f.toHom) f.injective,by simpa using len⟩have lens := two_terminal_lengths R G ne missing dx dy ordinary small half noR minimalobtain ⟨i,r,hr,ro⟩ := odd_cycle_of_lengths lens.1 lens.2have noH : ¬ hasPowerCycle H := byrintro ⟨k,v,p,hk,hp,len⟩exact absent ⟨k,_,p.map g.toHom,hk,hp.map (f:=g.toHom) g.injective,by simpa using len⟩have lensH := two_terminal_lengths H G ab missingH da db ordinaryH smallH halfH noH minimalobtain ⟨j,h,hh,ho⟩ := odd_cycle_of_lengths lensH.1 lensH.2let d : OddCycle R := ⟨i,r,hr,ro⟩let e : OddCycle H := ⟨j,h,hh,ho⟩let edge : G.Walk s t := cons st nilhave path : edge.IsPath := by simp [edge,cons_isPath_iff,st.ne]have unused : c ∉ edge.support := by simp [edge,cs.ne,ct.ne]let tri : OddCycle G := ⟨c,_,close_internal edge path st.ne unused cs ct.symm,by simp [edge]⟩have inside {v : W} (hv : v ∈ tri.walk.support) : v=c ∨ v=s ∨ v=t := bysimpa [tri,edge,support_concat,or_assoc,or_comm,or_left_comm] using hvrefine ⟨tri,copyCycle f d,copyCycle g e,?_,?_,?_⟩· intro v hv otherobtain ⟨z,rfl⟩ := copy_mem f d otherrcases inside hv with h|h|h· exact (outR z).1 h· exact (outR z).2.1 h· exact (outR z).2.2 h· intro v hv otherobtain ⟨z,rfl⟩ := copy_mem g e otherrcases inside hv with h|h|h· exact (outH z).1 h· exact (outH z).2.1 h· exact (outH z).2.2 h· intro v hv otherobtain ⟨u,hu⟩ := copy_mem f d hvobtain ⟨z,hz⟩ := copy_mem g e otherexact separate u z (hu.trans hz.symm)#print axioms three_disjoint_oddend TerminalCycles.RootedBlock