/-Copyright (c) 2026 Carles Marín. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles Marín-/module public import Mathlib.Combinatorics.Compactnesspublic import Mathlib.Combinatorics.SimpleGraph.Coloring.Vertexpublic import Mathlib.Combinatorics.SimpleGraph.Maps /-!# The de Bruijn–Erdős theorem A simple graph is `n`-colorable iff each of its finite induced subgraphs is. The nontrivialdirection is a compactness argument through Rado's selection principle(`Finset.rado_selection`). ## Main results * `SimpleGraph.colorable_iff_forall_finite_induce`. ## References * N. G. de Bruijn, P. Erdős, *A colour problem for infinite graphs and a problem in the theory of relations*, Indag. Math. (Proceedings) 54 (1951) 371–373.-/ @[expose] public section open SimpleGraph Finset variable {V : Type*} (G : SimpleGraph V) (n : ℕ) /-- **De Bruijn–Erdős colouring theorem** (1951). A graph `G` is `n`-colourable iff every finiteinduced subgraph is `n`-colourable. The forward direction is restriction; the backward direction isa compactness argument, here via Rado's selection lemma (`Finset.rado_selection`). -/theorem SimpleGraph.colorable_iff_forall_finite_induce : G.Colorable n ↔ ∀ s : Finset V, (G.induce (↑s : Set V)).Colorable n := by classical constructor · -- (→) restrict a global colouring to each finite induced subgraph rintro ⟨C⟩ s exact ⟨Coloring.mk (fun v => C ↑v) (fun {a b} hab => C.valid (induce_adj.mp hab))⟩ · -- (←) stitch the finite colourings into a global one by compactness intro h -- a chosen colouring of each finite induced subgraph let col : (s : Finset V) → (G.induce (↑s : Set V)).Coloring (Fin n) := fun s => (h s).some -- the local data fed to Rado's lemma let g : Finset V → V → Fin n := fun s x => if hx : x ∈ s then col s ⟨x, Finset.mem_coe.2 hx⟩ else col {x} ⟨x, Finset.mem_coe.2 (Finset.mem_singleton_self x)⟩ obtain ⟨χ, hχ⟩ := Finset.rado_selection g refine ⟨Coloring.mk χ (fun {u v} huv => ?_)⟩ obtain ⟨t, hst, hagree⟩ := hχ {u, v} have hu : u ∈ t := hst (by simp) have hv : v ∈ t := hst (by simp) have eu : χ u = col t ⟨u, Finset.mem_coe.2 hu⟩ := (hagree u (by simp)).trans (dite_eq_left hu) have ev : χ v = col t ⟨v, Finset.mem_coe.2 hv⟩ := (hagree v (by simp)).trans (dite_eq_left hv) rw [eu, ev] exact (col t).valid (induce_adj.mpr huv)