Skip to content

Commit 18f1ef5

Browse files
committed
chore(Combinatorics.SimpleGraph.Copy): replace file-wide @[expose] with selective exposure
Replace `@[expose] public section` with a plain `public section` and restore selective `@[expose]` on only the declarations that need cross-module reduction: * `Copy.toEmbedding`, `Copy.id`, `Copy.ofLE`, `Copy.topEmbedding` — the small constructive copy `def`s, kept transparent so consumers can elaborate against them by reducing. * `copyCount`, `subCount` — the noncomputable counts. These need to be exposed so downstream files (e.g. the upcoming `InducedCopy.lean` in feat/ind-copy-count) can prove bridging inequalities like `embCount_le_copyCount` and `indSubCount_le_subCount` directly via `Nat.card_le_card_of_injective`. Also: * Inline the `@[simps!]` projections of `Copy.topEmbedding` into a manual `@[simp] lemma topEmbedding_apply` (and similarly for `Copy.toEmbedding`). The auto-generated `simps` form attached to `@[simps!]` was opaque to cross-module simp; the manual form is small enough to ship as a one-line named lemma. The body of `topEmbedding` is also tightened from `fun {v w} ↦ ⟨fun h ↦ by simpa using h.ne, _⟩` to `fun {_ _} ↦ ⟨fun h ↦ f.injective.ne_iff.mp h.ne, _⟩`. * `IsIndContained` switches from `def` to `abbrev`, since the body `Nonempty (G ↪g H)` is small and downstream Lean elaboration benefits from automatic unfolding here.
1 parent 02acb7d commit 18f1ef5

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Copy.lean

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Argument *order* follows mathlib's two conventions, one for each category:
7575
* Add densities `copyDensity G H`, `subDensity G H`, and `homDensity G H`.
7676
-/
7777

78-
@[expose] public section
78+
public section
7979

8080
open Finset Function
8181
open Fintype (card)
@@ -139,10 +139,12 @@ def mapNeighborSet (f : Copy G H) (a : V) :
139139
exact f.injective h
140140

141141
/-- A copy gives rise to an embedding of vertex types. -/
142-
def toEmbedding (f : Copy G H) : V ↪ W := ⟨f, f.injective⟩
142+
@[expose] def toEmbedding (f : Copy G H) : V ↪ W := ⟨f, f.injective⟩
143+
144+
@[simp] lemma toEmbedding_apply (f : Copy G H) (a : V) : f.toEmbedding a = f a := rfl
143145

144146
/-- The identity copy from a simple graph to itself. -/
145-
@[refl] def id (G : SimpleGraph V) : Copy G G := ⟨Hom.id, Function.injective_id⟩
147+
@[expose, refl] def id (G : SimpleGraph V) : Copy G G := ⟨Hom.id, Function.injective_id⟩
146148

147149
@[simp, norm_cast] lemma coe_id : ⇑(id G) = _root_.id := rfl
148150

@@ -157,7 +159,8 @@ theorem comp_apply (g : Copy H I) (f : Copy G H) (a : V) : g.comp f a = g (f a)
157159
RelHom.comp_apply g.toHom f.toHom a
158160

159161
/-- The copy from a subgraph to the supergraph. -/
160-
def ofLE (G₁ G₂ : SimpleGraph V) (h : G₁ ≤ G₂) : Copy G₁ G₂ := ⟨Hom.ofLE h, Function.injective_id⟩
162+
@[expose] def ofLE (G₁ G₂ : SimpleGraph V) (h : G₁ ≤ G₂) : Copy G₁ G₂ :=
163+
⟨Hom.ofLE h, Function.injective_id⟩
161164

162165
@[simp, norm_cast]
163166
theorem coe_comp (g : Copy H I) (f : Copy G H) : ⇑(g.comp f) = g ∘ f := by ext; simp
@@ -214,10 +217,12 @@ instance [Fintype {f : G →g H // Injective f}] : Fintype (G.Copy H) :=
214217
}
215218

216219
/-- A copy of `⊤` gives rise to an embedding of `⊤`. -/
217-
@[simps!]
218-
def topEmbedding (f : Copy (⊤ : SimpleGraph V) H) : (⊤ : SimpleGraph V) ↪g H :=
220+
@[expose] def topEmbedding (f : Copy (⊤ : SimpleGraph V) H) : (⊤ : SimpleGraph V) ↪g H :=
219221
{ f.toEmbedding with
220-
map_rel_iff' := fun {v w} ↦ ⟨fun h ↦ by simpa using h.ne, f.toHom.map_adj⟩}
222+
map_rel_iff' := fun {_ _} ↦ ⟨fun h ↦ f.injective.ne_iff.mp h.ne, f.toHom.map_adj⟩ }
223+
224+
@[simp] lemma topEmbedding_apply (f : Copy (⊤ : SimpleGraph V) H) (v : V) :
225+
f.topEmbedding v = f v := rfl
221226

222227
end Copy
223228

@@ -404,7 +409,7 @@ We denote "`G` is inducingly contained in `H`" by `G ⊴ H` (`\trianglelefteq`).
404409

405410
/-- A simple graph `G` is inducingly contained in a simple graph `H` if there exists an induced
406411
subgraph of `H` isomorphic to `G`. This is denoted by `G ⊴ H`. -/
407-
def IsIndContained (G : SimpleGraph V) (H : SimpleGraph W) : Prop := Nonempty (G ↪g H)
412+
abbrev IsIndContained (G : SimpleGraph V) (H : SimpleGraph W) : Prop := Nonempty (G ↪g H)
408413

409414
@[inherit_doc] scoped infixl:50 " ⊴ " => SimpleGraph.IsIndContained
410415

@@ -497,7 +502,7 @@ variable [Fintype V] [Fintype W]
497502
/-- `H.copyCount G` is the number of labeled copies of `G` in `H`, i.e. the number of injective
498503
graph homomorphisms from `G` to `H`. See `SimpleGraph.subCount` for the number of unlabeled
499504
copies. -/
500-
noncomputable def copyCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
505+
@[expose] noncomputable def copyCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
501506
classical exact Fintype.card (Copy G H)
502507

503508
@[deprecated (since := "2026-04-30")] alias labelledCopyCount := copyCount
@@ -532,7 +537,7 @@ abbrev Sub (G : SimpleGraph V) (H : SimpleGraph W) : Type _ :=
532537

533538
/-- `H.subCount G` is the number of `SimpleGraph.Subgraph`s of `H` isomorphic to `G`. See
534539
`SimpleGraph.copyCount` for the number of labeled copies. -/
535-
noncomputable def subCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
540+
@[expose] noncomputable def subCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
536541
classical exact Fintype.card (G.Sub H)
537542

538543
@[simp] lemma subCount_eq_zero : H.subCount G = 0 ↔ G.Free H := by

0 commit comments

Comments
 (0)