Lean / Reader
Lean readerRingObstruction.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports TwoCopy, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import TwoCopyimport Mathlib.Data.Nat.Logimport Mathlib.Tactic.Linarithopen SimpleGraph SimpleGraph.Walkopen scoped Sym2namespace TerminalCyclesuniverse u/-- A two-terminal graph together with uniform bounds on path length plusone. The added unit accounts for one joining edge per copy in a ring. -/structure PathBlock (lo hi n : ℕ) whereVertex : Type ufinite : Finite Vertexgraph : SimpleGraph Vertexstart : Vertexfinish : VertexrootDegree : 2 ≤ valence graph startside : TerminalSide graph start finishorder : Nat.card Vertex = nwindow : ∀ p : graph.Walk start finish, p.IsPath → lo ≤ p.length+1 ∧ p.length+1 ≤ hinamespace PathBlock/-- Join two blocks in series by a single bridge. Cycles stay in theiroriginal blocks, and the shifted path-length intervals add. -/def series {l h n l' h' n' : ℕ} (X : PathBlock.{u} l h n) (Y : PathBlock.{u} l' h' n') :PathBlock.{u} (l+l') (h+h') (n+n') := byletI : Finite X.Vertex := X.finiteletI : Finite Y.Vertex := Y.finitelet y : ExceptRoot Y.start := ⟨Y.finish,Y.side.distinct⟩let L := LeafGraph Y.graph Y.startlet leaf := leafVertex (b:=Y.start)let term := leafEnd ylet ls : TerminalSide L leaf term := (leaf_side Y.graph Y.side Y.rootDegree).1have one : 1 ≤ valence L leaf := (leaf_side Y.graph Y.side Y.rootDegree).2let yt : ExceptRoot leaf := ⟨term,ls.distinct⟩let K := wedge X.graph L X.finish leaflet a : WedgeVertex X.Vertex leaf := .inl X.startlet b : WedgeVertex X.Vertex leaf := .inr ythave dx := X.side.targethave degs := wedge_terminal_degrees X.graph L X.finish leaf X.start yt (by omega)X.rootDegree ls.target (fun z hx ha => X.side.others z ha hx) ls.othersrefine ⟨WedgeVertex X.Vertex leaf,inferInstance,K,a,b,degs.1,⟨Sum.inr_ne_inl,degs.2.1,degs.2.2,?_⟩,?_,?_⟩· intro yesexact (wedge_cycle_from_side X.graph L X.finish leaf yes).elim X.side.noCycle ls.noCycle· have aSize := wedge_order (V:=X.Vertex) leafhave bSize := leaf_order Y.starthave cSize := X.orderhave dSize := Y.orderchange Nat.card (WedgeVertex X.Vertex leaf) = n+n'omega· intro p hpobtain ⟨r,q,hr,hq,sum⟩ := wedge_terminal_split X.graph L X.finish leaf X.start yt p hpobtain ⟨s',hs',add⟩ := leaf_path Y.graph y q hqhave hX := X.window r.reverse hr.reversehave hY := Y.window s' hs'simp only [length_reverse] at hXomega/-- A chain of r+1 copies, retaining all original vertices. -/def chain {lo hi n : ℕ} (X : PathBlock.{u} lo hi n) (r : ℕ) :PathBlock.{u} ((r+1)*lo) ((r+1)*hi) ((r+1)*n) := byinduction r with| zero => simpa using X| succ r ih => simpa only [Nat.succ_mul] using series ih X/-- A shifted interval that misses all dyadic lengths gives an actualfinite counterexample, on the same vertices as the chain being closed. -/theorem close_without_power {lo hi n : ℕ} (X : PathBlock.{u} lo hi n) (long : 2 < lo)(gap : ∀ k ≥ 2, ¬ (lo ≤ 2^k ∧ 2^k ≤ hi)) :∃ (T : Type u) (_ : Finite T) (G : SimpleGraph T), Nat.card T=n ∧Nonempty T ∧ (∀ v, 3 ≤ valence G v) ∧ ¬ hasPowerCycle G := byletI : Finite X.Vertex := X.finitelet a := X.startlet b := X.finishhave diff : a ≠ b := X.side.distinct.symmhave missing : ¬ X.graph.Adj a b := byintro edgelet p : X.graph.Walk a b := cons edge nilhave good : p.IsPath := by simp [p,cons_isPath_iff,diff]have low := (X.window p good).1change lo ≤ 2 at lowomegalet K := completeEdge X.graph a brefine ⟨X.Vertex,X.finite,K,X.order,⟨a⟩,completed_minimum X.graph a b diff missing X.rootDegree X.side.target X.side.others,?_⟩intro yesobtain ⟨k,hk,p,hp,len⟩ := path_after_completion X.graph a b missing yes X.side.noCycleexact gap k hk (len ▸ X.window p hp)/-- Scale an integral interval of multiplicative width strictly below twoso that it lies strictly between consecutive powers of two. -/theorem dyadic_gap_multiplier (lo hi : ℕ) (positive : 0 < lo) (ordered : lo ≤ hi) (narrow : hi < 2*lo) :∃ q j : ℕ, hi ≤ q ∧ q ≤ 2*hi ∧ 2^j < (q+1)*lo ∧ (q+1)*hi < 2^(j+1) := bylet j := Nat.log 2 (hi*lo) + 1let d := 2^jlet q := d/lohave pos : hi*lo ≠ 0 := Nat.mul_ne_zero (by omega) (by omega)have below : hi*lo < d := Nat.lt_pow_succ_log_self (by decide) _have above : d ≤ 2*(hi*lo) := byhave bound := Nat.pow_log_le_self 2 posdsimp [d,j]rw [pow_succ]omegahave lower : hi ≤ q := (Nat.le_div_iff_mul_le positive).mpr below.lehave upper : q ≤ 2*hi := Nat.div_le_of_le_mul (by nlinarith only [above] : d ≤ lo*(2*hi))have strictLow : d < (q+1)*lo := (Nat.div_lt_iff_lt_mul positive).mp (Nat.lt_succ_self q)have qsize : q*lo ≤ d := Nat.div_mul_le_self d lohave cap := Nat.mul_le_mul_left q (show hi+1 ≤ 2*lo by omega)have strictHigh : (q+1)*hi < 2*d := byby_cases eq : q=hi· nlinarith only [cap,below,eq,show q*lo=hi*lo from congrArg (·*lo) eq]· have hlt : hi < q := by omeganlinarith only [cap,qsize,hlt]exact ⟨q,j,lower,upper,strictLow,by simpa only [pow_succ,Nat.mul_comm 2] using strictHigh⟩/-- A single finite block with all terminal path lengths between m and M,where 1 ≤ m ≤ M ≤ 2m, gives an actual counterexample on rn vertices with2 ≤ r ≤ 2M+3. This is a sufficient certificate to disprove Erdős #64. -/theorem narrow_window_counterexample {m M n : ℕ} (X : PathBlock.{u} (m+1) (M+1) n)(positive : 1 ≤ m) (ordered : m ≤ M) (narrow : M ≤ 2*m) :∃ r : ℕ, 2 ≤ r ∧ r ≤ 2*M+3 ∧ ∃ (T : Type u) (_ : Finite T) (G : SimpleGraph T),Nat.card T=r*n ∧ Nonempty T ∧ (∀ v, 3 ≤ valence G v) ∧ ¬ hasPowerCycle G := byobtain ⟨q,j,lower,upper,left,right⟩ := dyadic_gap_multiplier (m+1) (M+1) (by omega) (by omega) (by omega)have long : 2 < (q+1)*(m+1) := by nlinarith only [lower,positive,ordered,Nat.zero_le (q*m)]have gap (k : ℕ) (_ : k ≥ 2) : ¬ ((q+1)*(m+1) ≤ 2^k ∧ 2^k ≤ (q+1)*(M+1)) := byrintro ⟨a,b⟩rcases le_or_gt k j with small | big· exact (not_lt_of_ge (Nat.pow_le_pow_right (by decide : 0<2) small)) (left.trans_le a)· have monotone := Nat.pow_le_pow_right (by decide : 0<2) (show j+1 ≤ k by omega)omegaexact ⟨q+1,by omega,by omega,(chain X q).close_without_power long gap⟩theorem narrow_window_refutes_erdos64 {m M n : ℕ} (X : PathBlock.{u} (m+1) (M+1) n)(positive : 1 ≤ m) (ordered : m ≤ M) (narrow : M ≤ 2*m) : ¬ erdos64Statement.{u} := byclassicalintro conjectureobtain ⟨_,_,_,T,fin,G,_,nonempty,degree,no⟩ := X.narrow_window_counterexample positive ordered narrowletI : Finite T := finletI : Fintype T := Fintype.ofFinite TletI : Nonempty T := nonemptyexact no (conjecture T G (G.le_minDegree_of_forall_le_degree 3 (fun v => by simpa only [← valence_eq_degree] using degree v)))end PathBlockend TerminalCycles