Skip to content

Commit 0be21dc

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 constructive copy `def`s that need cross-module reduction: `Copy.toEmbedding`, `Copy.id`, `Copy.ofLE`, `Copy.topEmbedding`. The noncomputable counting defs `copyCount`/`subCount` remain non-exposed; the cross-module unfolding API they need is added in the immediately following `chore/copy-nat-card` PR, paired with the switch from `Fintype.card` to `Nat.card` which makes the unfolding lemmas trivial. 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 0be21dc

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Copy.lean

Lines changed: 13 additions & 8 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

0 commit comments

Comments
 (0)