Skip to content

Commit 42e558f

Browse files
committed
refactor(SimpleGraph): make completeGraph and emptyGraph abbrevs for and (#23838)
define Top and Bot in-line for SimpleGraph and set completeGraph and emptyGraph as abbrev Co-authored-by: FordUniver <61389961+FordUniver@users.noreply.github.com>
1 parent b40998f commit 42e558f

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

Mathlib/Combinatorics/SimpleGraph/Basic.lean

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ theorem SimpleGraph.fromRel_adj {V : Type u} (r : V → V → Prop) (v w : V) :
137137
attribute [aesop safe (rule_sets := [SimpleGraph])] Ne.symm
138138
attribute [aesop safe (rule_sets := [SimpleGraph])] Ne.irrefl
139139

140-
/-- The complete graph on a type `V` is the simple graph with all pairs of distinct vertices
141-
adjacent. In `Mathlib`, this is usually referred to as `⊤`. -/
142-
def completeGraph (V : Type u) : SimpleGraph V where Adj := Ne
143-
144-
/-- The graph with no edges on a given vertex type `V`. `Mathlib` prefers the notation `⊥`. -/
145-
def emptyGraph (V : Type u) : SimpleGraph V where Adj _ _ := False
146-
147140
/-- Two vertices are adjacent in the complete bipartite graph on two vertex types
148141
if and only if they are not from the same side.
149142
Any bipartite graph may be regarded as a subgraph of one of these. -/
@@ -307,8 +300,8 @@ instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (SimpleGrap
307300
inf := (· ⊓ ·)
308301
compl := HasCompl.compl
309302
sdiff := (· \ ·)
310-
top := completeGraph V
311-
bot := emptyGraph V
303+
top.Adj := Ne
304+
bot.Adj _ _ := False
312305
le_top := fun x _ _ h => x.ne_of_adj h
313306
bot_le := fun _ _ _ h => h.elim
314307
sdiff_eq := fun x y => by
@@ -331,6 +324,12 @@ instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (SimpleGrap
331324
le_sInf := fun _ _ hG _ _ hab => ⟨fun _ hH => hG _ hH hab, hab.ne⟩
332325
iInf_iSup_eq := fun f => by ext; simp [Classical.skolem] }
333326

327+
/-- The complete graph on a type `V` is the simple graph with all pairs of distinct vertices. -/
328+
abbrev completeGraph (V : Type u) : SimpleGraph V := ⊤
329+
330+
/-- The graph with no edges on a given vertex type `V`. -/
331+
abbrev emptyGraph (V : Type u) : SimpleGraph V := ⊥
332+
334333
@[simp]
335334
theorem top_adj (v w : V) : (⊤ : SimpleGraph V).Adj v w ↔ v ≠ w :=
336335
Iff.rfl

Mathlib/Combinatorics/SimpleGraph/Clique.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ noncomputable def topEmbeddingOfNotCliqueFree {n : ℕ} (h : ¬G.CliqueFree n) :
342342
convert (Embedding.induce ↑h.choose.toSet).comp this.toEmbedding
343343
exact hb.symm
344344

345-
theorem not_cliqueFree_iff (n : ℕ) : ¬G.CliqueFree n ↔ Nonempty ((⊤ : SimpleGraph (Fin n)) ↪g G) :=
345+
theorem not_cliqueFree_iff (n : ℕ) : ¬G.CliqueFree n ↔ Nonempty (completeGraph (Fin n) ↪g G) :=
346346
fun h ↦ ⟨topEmbeddingOfNotCliqueFree h⟩, fun ⟨f⟩ ↦ not_cliqueFree_of_top_embedding f⟩
347347

348-
theorem cliqueFree_iff {n : ℕ} : G.CliqueFree n ↔ IsEmpty ((⊤ : SimpleGraph (Fin n)) ↪g G) := by
348+
theorem cliqueFree_iff {n : ℕ} : G.CliqueFree n ↔ IsEmpty (completeGraph (Fin n) ↪g G) := by
349349
rw [← not_iff_not, not_cliqueFree_iff, not_isEmpty_iff]
350350

351351
theorem not_cliqueFree_card_of_top_embedding [Fintype α] (f : (⊤ : SimpleGraph α) ↪g G) :

Mathlib/Combinatorics/SimpleGraph/Coloring.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ variable {V : Type u} (G : SimpleGraph V) {n : ℕ}
6565
/-- An `α`-coloring of a simple graph `G` is a homomorphism of `G` into the complete graph on `α`.
6666
This is also known as a proper coloring.
6767
-/
68-
abbrev Coloring (α : Type v) := G →g (⊤ : SimpleGraph α)
68+
abbrev Coloring (α : Type v) := G →g completeGraph α
6969

7070
variable {G}
7171
variable {α β : Type*} (C : G.Coloring α)
@@ -116,7 +116,7 @@ theorem Coloring.color_classes_independent (c : α) : IsAntichain G.Adj (C.color
116116
-- TODO make this computable
117117
noncomputable instance [Fintype V] [Fintype α] : Fintype (Coloring G α) := by
118118
classical
119-
change Fintype (RelHom G.Adj (⊤ : SimpleGraph α).Adj)
119+
change Fintype (RelHom G.Adj (completeGraph α).Adj)
120120
apply Fintype.ofInjective _ RelHom.coe_fn_injective
121121

122122
variable (G)

Mathlib/Combinatorics/SimpleGraph/Finite.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ theorem neighborFinset_compl [DecidableEq V] [DecidableRel G.Adj] (v : V) :
275275

276276
@[simp]
277277
theorem complete_graph_degree [DecidableEq V] (v : V) :
278-
(⊤ : SimpleGraph V).degree v = Fintype.card V - 1 := by
278+
(completeGraph V).degree v = Fintype.card V - 1 := by
279279
simp_rw [degree, neighborFinset_eq_filter, top_adj, filter_ne]
280280
rw [card_erase_of_mem (mem_univ v), card_univ]
281281

Mathlib/Combinatorics/SimpleGraph/Maps.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ protected abbrev spanningCoe {s : Set V} (G : SimpleGraph s) : G ↪g G.spanning
390390
SimpleGraph.Embedding.map (Function.Embedding.subtype _) G
391391

392392
/-- Embeddings of types induce embeddings of complete graphs on those types. -/
393-
protected def completeGraph {α β : Type*} (f : α ↪ β) :
394-
(⊤ : SimpleGraph α) ↪g (⊤ : SimpleGraph β) :=
393+
protected def completeGraph {α β : Type*} (f : α ↪ β) : completeGraph α ↪g completeGraph β :=
395394
{ f with map_rel_iff' := by simp }
396395

397396
@[simp] lemma coe_completeGraph {α β : Type*} (f : α ↪ β) : ⇑(Embedding.completeGraph f) = f := rfl
@@ -570,8 +569,7 @@ lemma map_symm_apply (f : V ≃ W) (G : SimpleGraph V) (w : W) :
570569
(SimpleGraph.Iso.map f G).symm w = f.symm w := rfl
571570

572571
/-- Equivalences of types induce isomorphisms of complete graphs on those types. -/
573-
protected def completeGraph {α β : Type*} (f : α ≃ β) :
574-
(⊤ : SimpleGraph α) ≃g (⊤ : SimpleGraph β) :=
572+
protected def completeGraph {α β : Type*} (f : α ≃ β) : completeGraph α ≃g completeGraph β :=
575573
{ f with map_rel_iff' := by simp }
576574

577575
theorem toEmbedding_completeGraph {α β : Type*} (f : α ≃ β) :

Mathlib/Combinatorics/SimpleGraph/Subgraph.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def topEquiv : (⊤ : Subgraph G).coe ≃g G where
590590

591591
/-- The bottom of the `Subgraph G` lattice is equivalent to the empty graph on the empty
592592
vertex type. -/
593-
def botEquiv : (⊥ : Subgraph G).coe ≃g (⊥ : SimpleGraph Empty) where
593+
def botEquiv : (⊥ : Subgraph G).coe ≃g emptyGraph Empty where
594594
toFun v := v.property.elim
595595
invFun v := v.elim
596596
left_inv := fun ⟨_, h⟩ ↦ h.elim

Mathlib/Combinatorics/SimpleGraph/Triangle/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ lemma FarFromTriangleFree.lt_half (hG : G.FarFromTriangleFree ε) : ε < 2⁻¹
266266
rw [mul_assoc, mul_lt_mul_left hε₀]
267267
norm_cast
268268
calc
269-
_ ≤ 2 * (⊤ : SimpleGraph α).edgeFinset.card := by gcongr; exact le_top
269+
_ ≤ 2 * (completeGraph α).edgeFinset.card := by gcongr; exact le_top
270270
_ < card α ^ 2 := ?_
271271
rw [edgeFinset_top, filter_not, card_sdiff (subset_univ _), Finset.card_univ, Sym2.card]
272272
simp_rw [choose_two_right, Nat.add_sub_cancel, Nat.mul_comm _ (card α),

0 commit comments

Comments
 (0)