from pathlib import Path source = Path(__file__).resolve().parent / 'source' project = source / 'RequestProject' basic = (project / 'Basic.lean').read_text().split('\n', 1)[1] main_proof = (project / 'MainProof.lean').read_text() iso = main_proof.split('namespace Erdos550\n', 1)[1].split('\n/-\n**Red-profile lower bound', 1)[0] finite = '\n' + main_proof[main_proof.index('theorem ramsey_symm '):].split('\n/-\n**Ramsey witness on an induced set', 1)[0] main = (project / 'Main.lean').read_text() two = main[main.index(' · -- `k = 2`'):main.index(' · -- `k ≥ 3`')] two = two[two.index(' have hcast'):] two = '\n'.join(line[2:] if line.startswith(' ') else line for line in two.splitlines()) imports = '''import Mathlib.Combinatorics.SimpleGraph.Coloring import Mathlib.Tactic.Cases import Mathlib.Combinatorics.SimpleGraph.Clique import Mathlib.Combinatorics.SimpleGraph.Copy import Mathlib.Data.Nat.Lattice import Mathlib.Tactic.FinCases import Mathlib.Tactic.Linarith import Mathlib.Tactic.NormNum ''' checks = ''' /-- The part projection colors the graph, and one vertex from each part gives a k-clique. -/ theorem desk_chromatic (k : ℕ) (m : Fin k → ℕ) (hm : ∀ i, 0 < m i) : (Kmult k m).chromaticNumber = k := by apply le_antisymm · exact Colorable.chromaticNumber_le ⟨Coloring.mk (fun v => v.1) (fun h => h)⟩ · let choosePart : (⊤ : SimpleGraph (Fin k)) →g Kmult k m := { toFun := fun i => ⟨i, ⟨0, hm i⟩⟩ map_rel' := fun h => h } simpa only [chromaticNumber_top, Fintype.card_fin] using chromaticNumber_mono_of_hom choosePart /-- The exact final arithmetic and part restriction in the k = 2 proof branch. -/ theorem desk_two {V : Type} (T : SimpleGraph V) (hk : 2 ≤ 2) (m : Fin 2 → ℕ) (hpos : 1 ≤ m (0 : Fin 2)) : ramsey T (Kmult 2 m) ≤ (2 - 1) * (ramsey T (Kmult 2 (fun j => m (Fin.castLE hk j))) - 1) + m ⟨0, by omega⟩ := by ''' prints = ''' #print axioms ramsey_symm #print axioms ramsey_Kmult2_Kbip #print axioms ramseyGood_nonempty #print axioms desk_chromatic #print axioms desk_two end Erdos550 ''' (source / 'DeskStatementAudit.lean').write_text(imports + basic + '\nopen SimpleGraph Finset\nnamespace Erdos550\n' + iso + finite + '\n' + checks + two + '\n' + prints)