Skip to content

Commit 8c8e5d6

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 d900069 commit 8c8e5d6

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

67-
@[expose] public section
67+
public section
6868

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

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

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

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

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

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

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

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

210215
end Copy
211216

@@ -380,7 +385,7 @@ end Free
380385

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

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

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

476481
@[deprecated (since := "2026-04-30")] alias labelledCopyCount := copyCount
@@ -505,7 +510,7 @@ abbrev Sub (G : SimpleGraph V) (H : SimpleGraph W) : Type _ :=
505510

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

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

0 commit comments

Comments
 (0)