File: Mathlib/Combinatorics/SimpleGraph/Turan.lean

full_name: SimpleGraph.IsTuranMaximal
code: /-- An `r + 1`-cliquefree graph is `r`-Turán-maximal if any other `r + 1`-cliquefree graph on
the same vertex set has the same or fewer number of edges. -/
def IsTuranMaximal (r : ℕ) : Prop 
goal: Prop

full_name: SimpleGraph.IsTuranMaximal.le_iff_eq
code: lemma IsTuranMaximal.le_iff_eq (hG : G.IsTuranMaximal r) (hH : H.CliqueFree (r + 1)) :
    G ≤ H ↔ G = H 
goal: G ≤ H ↔ G = H

full_name: SimpleGraph.turanGraph
code: /-- The canonical `r + 1`-cliquefree Turán graph on `n` vertices. -/
def turanGraph (n r : ℕ) : SimpleGraph (Fin n) 
goal: SimpleGraph (Fin n)

full_name: SimpleGraph.turanGraph.instDecidableRelAdj
code: instance turanGraph.instDecidableRelAdj : DecidableRel (turanGraph n r).Adj 
goal: DecidableRel (SimpleGraph.turanGraph n r).Adj

full_name: SimpleGraph.turanGraph_zero
code: @[simp]
lemma turanGraph_zero : turanGraph n 0 = ⊤ 
goal: SimpleGraph.turanGraph n 0 = ⊤

full_name: SimpleGraph.turanGraph_eq_top
code: @[simp]
theorem turanGraph_eq_top : turanGraph n r = ⊤ ↔ r = 0 ∨ n ≤ r 
goal: SimpleGraph.turanGraph n r = ⊤ ↔ r = 0 ∨ n ≤ r

full_name: SimpleGraph.turanGraph_cliqueFree
code: theorem turanGraph_cliqueFree : (turanGraph n r).CliqueFree (r + 1) 
goal: (SimpleGraph.turanGraph n r).CliqueFree (r + 1)

full_name: SimpleGraph.not_cliqueFree_of_isTuranMaximal
code: /-- An `r + 1`-cliquefree Turán-maximal graph is _not_ `r`-cliquefree
if it can accommodate such a clique. -/
theorem not_cliqueFree_of_isTuranMaximal (hn : r ≤ Fintype.card V) (hG : G.IsTuranMaximal r) :
    ¬G.CliqueFree r 
goal: ¬G.CliqueFree r

full_name: SimpleGraph.exists_isTuranMaximal
code: lemma exists_isTuranMaximal :
    ∃ H : SimpleGraph V, ∃ _ : DecidableRel H.Adj, H.IsTuranMaximal r 
goal: ∃ H x, H.IsTuranMaximal r

full_name: SimpleGraph.IsTuranMaximal.degree_eq_of_not_adj
code: /-- In a Turán-maximal graph, non-adjacent vertices have the same degree. -/
lemma degree_eq_of_not_adj (h : G.IsTuranMaximal r) (hn : ¬G.Adj s t) :
    G.degree s = G.degree t 
goal: G.degree s = G.degree t

full_name: SimpleGraph.IsTuranMaximal.not_adj_trans
code: /-- In a Turán-maximal graph, non-adjacency is transitive. -/
lemma not_adj_trans (h : G.IsTuranMaximal r) (hts : ¬G.Adj t s) (hsu : ¬G.Adj s u) :
    ¬G.Adj t u 
goal: ¬G.Adj t u

full_name: SimpleGraph.IsTuranMaximal.equivalence_not_adj
code: /-- In a Turán-maximal graph, non-adjacency is an equivalence relation. -/
theorem equivalence_not_adj : Equivalence (¬G.Adj · ·) 
goal: Equivalence fun x x_1 => ¬G.Adj x x_1

full_name: SimpleGraph.IsTuranMaximal.setoid
code: /-- The non-adjacency setoid over the vertices of a Turán-maximal graph
induced by `equivalence_not_adj`. -/
def setoid : Setoid V 
goal: Setoid V

full_name: SimpleGraph.IsTuranMaximal.instDecidableRelR
code: instance : DecidableRel h.setoid.r 
goal: DecidableRel Setoid.r

full_name: SimpleGraph.IsTuranMaximal.finpartition
code: /-- The finpartition derived from `h.setoid`. -/
def finpartition : Finpartition (univ : Finset V) 
goal: Finpartition Finset.univ

full_name: SimpleGraph.IsTuranMaximal.not_adj_iff_part_eq
code: lemma not_adj_iff_part_eq : ¬G.Adj s t ↔ h.finpartition.part s = h.finpartition.part t 
goal: ¬G.Adj s t ↔ h.finpartition.part s = h.finpartition.part t

full_name: SimpleGraph.IsTuranMaximal.degree_eq_card_sub_part_card
code: lemma degree_eq_card_sub_part_card : G.degree s = Fintype.card V - (h.finpartition.part s).card 
goal: G.degree s = Fintype.card V - (h.finpartition.part s).card

full_name: SimpleGraph.IsTuranMaximal.isEquipartition
code: /-- The parts of a Turán-maximal graph form an equipartition. -/
theorem isEquipartition : h.finpartition.IsEquipartition 
goal: h.finpartition.IsEquipartition

full_name: SimpleGraph.IsTuranMaximal.card_parts_le
code: lemma card_parts_le : h.finpartition.parts.card ≤ r 
goal: h.finpartition.parts.card ≤ r

full_name: SimpleGraph.IsTuranMaximal.card_parts
code: /-- There are `min n r` parts in a graph on `n` vertices satisfying `G.IsTuranMaximal r`.
`min` handles the `n < r` case, when `G` is complete but still `r + 1`-cliquefree
for having insufficiently many vertices. -/
theorem card_parts : h.finpartition.parts.card = min (Fintype.card V) r 
goal: h.finpartition.parts.card = min (Fintype.card V) r

full_name: SimpleGraph.IsTuranMaximal.nonempty_iso_turanGraph
code: /-- **Turán's theorem**, forward direction.

Any `r + 1`-cliquefree Turán-maximal graph on `n` vertices is isomorphic to `turanGraph n r`. -/
theorem nonempty_iso_turanGraph (h : G.IsTuranMaximal r) :
    Nonempty (G ≃g turanGraph (Fintype.card V) r) 
goal: Nonempty (G ≃g SimpleGraph.turanGraph (Fintype.card V) r)

full_name: SimpleGraph.isTuranMaximal_of_iso
code: /-- **Turán's theorem**, reverse direction.

Any graph isomorphic to `turanGraph n r` is itself Turán-maximal if `0 < r`. -/
theorem isTuranMaximal_of_iso (f : G ≃g turanGraph n r) (hr : 0 < r) : G.IsTuranMaximal r 
goal: G.IsTuranMaximal r

full_name: SimpleGraph.IsTuranMaximal.iso
code: /-- Turán-maximality with `0 < r` transfers across graph isomorphisms. -/
theorem IsTuranMaximal.iso {W : Type*} [Fintype W] [DecidableEq W] {H : SimpleGraph W}
    [DecidableRel H.Adj] (h : G.IsTuranMaximal r) (f : G ≃g H) (hr : 0 < r) : H.IsTuranMaximal r 
goal: H.IsTuranMaximal r

full_name: SimpleGraph.isTuranMaximal_turanGraph
code: /-- For `0 < r`, `turanGraph n r` is Turán-maximal. -/
theorem isTuranMaximal_turanGraph (hr : 0 < r) : (turanGraph n r).IsTuranMaximal r 
goal: (SimpleGraph.turanGraph n r).IsTuranMaximal r

full_name: SimpleGraph.isTuranMaximal_iff_nonempty_iso_turanGraph
code: /-- **Turán's theorem**. `turanGraph n r` is, up to isomorphism, the unique
`r + 1`-cliquefree Turán-maximal graph on `n` vertices. -/
theorem isTuranMaximal_iff_nonempty_iso_turanGraph (hr : 0 < r) :
    G.IsTuranMaximal r ↔ Nonempty (G ≃g turanGraph (Fintype.card V) r) 
goal: G.IsTuranMaximal r ↔ Nonempty (G ≃g SimpleGraph.turanGraph (Fintype.card V) r)