Skip to content

Commit 5833af8

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 3cf2b13 commit 5833af8

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
@@ -65,7 +65,7 @@ The following notation is declared in scope `SimpleGraph`:
6565
* Add densities `copyDensity G H`, `subDensity G H`, and `homDensity G H`.
6666
-/
6767

68-
@[expose] public section
68+
public section
6969

7070
open Finset Function
7171
open Fintype (card)
@@ -128,10 +128,12 @@ def mapNeighborSet (f : Copy G H) (a : V) :
128128
exact f.injective h
129129

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

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

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

@@ -146,7 +148,8 @@ theorem comp_apply (g : Copy H I) (f : Copy G H) (a : V) : g.comp f a = g (f a)
146148
RelHom.comp_apply g.toHom f.toHom a
147149

148150
/-- The copy from a subgraph to the supergraph. -/
149-
def ofLE (G₁ G₂ : SimpleGraph V) (h : G₁ ≤ G₂) : Copy G₁ G₂ := ⟨Hom.ofLE h, Function.injective_id⟩
151+
@[expose] def ofLE (G₁ G₂ : SimpleGraph V) (h : G₁ ≤ G₂) : Copy G₁ G₂ :=
152+
⟨Hom.ofLE h, Function.injective_id⟩
150153

151154
@[simp, norm_cast]
152155
theorem coe_comp (g : Copy H I) (f : Copy G H) : ⇑(g.comp f) = g ∘ f := by ext; simp
@@ -203,10 +206,12 @@ instance [Fintype {f : G →g H // Injective f}] : Fintype (G.Copy H) :=
203206
}
204207

205208
/-- A copy of `⊤` gives rise to an embedding of `⊤`. -/
206-
@[simps!]
207-
def topEmbedding (f : Copy (⊤ : SimpleGraph V) H) : (⊤ : SimpleGraph V) ↪g H :=
209+
@[expose] def topEmbedding (f : Copy (⊤ : SimpleGraph V) H) : (⊤ : SimpleGraph V) ↪g H :=
208210
{ f.toEmbedding with
209-
map_rel_iff' := fun {v w} ↦ ⟨fun h ↦ by simpa using h.ne, f.toHom.map_adj⟩}
211+
map_rel_iff' := fun {_ _} ↦ ⟨fun h ↦ f.injective.ne_iff.mp h.ne, f.toHom.map_adj⟩ }
212+
213+
@[simp] lemma topEmbedding_apply (f : Copy (⊤ : SimpleGraph V) H) (v : V) :
214+
f.topEmbedding v = f v := rfl
210215

211216
end Copy
212217

@@ -381,7 +386,7 @@ end Free
381386

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

386391
@[inherit_doc] scoped infixl:50 " ⊴ " => SimpleGraph.IsIndContained
387392

@@ -471,7 +476,7 @@ variable [Fintype V] [Fintype W]
471476
/-- `H.copyCount G` is the number of labeled copies of `G` in `H`, i.e. the number of injective
472477
graph homomorphisms from `G` to `H`. See `SimpleGraph.subCount` for the number of unlabeled
473478
copies. -/
474-
noncomputable def copyCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
479+
@[expose] noncomputable def copyCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
475480
classical exact Fintype.card (Copy G H)
476481

477482
@[deprecated (since := "2026-04-30")] alias labelledCopyCount := copyCount
@@ -506,7 +511,7 @@ abbrev Sub (G : SimpleGraph V) (H : SimpleGraph W) : Type _ :=
506511

507512
/-- `H.subCount G` is the number of `SimpleGraph.Subgraph`s of `H` isomorphic to `G`. See
508513
`SimpleGraph.copyCount` for the number of labeled copies. -/
509-
noncomputable def subCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
514+
@[expose] noncomputable def subCount (H : SimpleGraph W) (G : SimpleGraph V) : ℕ := by
510515
classical exact Fintype.card (G.Sub H)
511516

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

0 commit comments

Comments
 (0)