Skip to content

Commit c6d766d

Browse files
committed
refactor(Combinatorics/SimpleGraph/InducedCopy): hoist Embedding.toSubgraph API to the top
Moves the `namespace Embedding` block (containing `toSubgraph`, `toSubgraph_isInduced`, and `range_toSubgraph`) out of `section UnlabeledEmbeddingCount` to its own block immediately after the `SimpleGraph` namespace opens, with a section heading `Embedding to subgraph`. This mirrors `Copy.lean`'s structure (where `Copy.toSubgraph` and `range_toSubgraph` live in the early `section Copy` / `namespace Copy` block alongside the type's core API, separately from the count sections). The previous placement nested the core embedding-image API inside the unlabelled count section, which made it harder to find when navigating the file. Pure code motion: no statement, proof, or attribute changes.
1 parent 97c26fb commit c6d766d

1 file changed

Lines changed: 32 additions & 24 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/InducedCopy.lean

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,38 @@ variable {V V' W W' X : Type*}
5757
{H : SimpleGraph W} {H' : SimpleGraph W'}
5858
{I : SimpleGraph X}
5959

60+
/-!
61+
### Embedding to subgraph
62+
63+
For a graph embedding `f : G ↪g H`, the image is an induced subgraph of `H` isomorphic to `G`.
64+
This packages the image as a `H.Subgraph`, together with the inducedness and isomorphism
65+
characterisations needed downstream.
66+
-/
67+
68+
namespace Embedding
69+
70+
/-- The induced subgraph corresponding to an embedding. -/
71+
abbrev toSubgraph (f : G ↪g H) : H.Subgraph := f.toCopy.toSubgraph
72+
73+
@[simp] lemma toSubgraph_isInduced (f : G ↪g H) : (toSubgraph f).IsInduced := by
74+
simp [toSubgraph, Copy.toSubgraph, Subgraph.IsInduced, Relation.map_apply_apply, f.injective]
75+
76+
@[simp] lemma range_toSubgraph :
77+
Set.range (toSubgraph : (G ↪g H) → H.Subgraph) =
78+
{H' : H.Subgraph | H'.IsInduced ∧ Nonempty (G ≃g H'.coe)} := by
79+
ext H'
80+
simp only [Set.mem_range, Set.mem_setOf_eq]
81+
constructor
82+
· rintro ⟨f, rfl⟩
83+
exact ⟨toSubgraph_isInduced f, ⟨f.toCopy.isoToSubgraph⟩⟩
84+
· rintro ⟨hInd, ⟨e⟩⟩
85+
refine ⟨(ofIsInduced H' hInd).comp e.toEmbedding, ?_⟩
86+
have h : ((ofIsInduced H' hInd).comp e.toEmbedding).toHom =
87+
H'.hom.comp e.toHom := by ext; simp
88+
simp [toSubgraph, Copy.toSubgraph, h, Subgraph.map_comp]
89+
90+
end Embedding
91+
6092
/-!
6193
### Induced containment
6294
@@ -249,30 +281,6 @@ abbrev UnlabeledEmbedding (G : SimpleGraph V) (H : SimpleGraph W) : Type _ :=
249281

250282
instance [Finite W] : Finite (G.UnlabeledEmbedding H) := Subtype.finite
251283

252-
namespace Embedding
253-
254-
/-- The induced subgraph corresponding to an embedding. -/
255-
abbrev toSubgraph (f : G ↪g H) : H.Subgraph := f.toCopy.toSubgraph
256-
257-
@[simp] lemma toSubgraph_isInduced (f : G ↪g H) : (toSubgraph f).IsInduced := by
258-
simp [toSubgraph, Copy.toSubgraph, Subgraph.IsInduced, Relation.map_apply_apply, f.injective]
259-
260-
@[simp] lemma range_toSubgraph :
261-
Set.range (toSubgraph : (G ↪g H) → H.Subgraph) =
262-
{H' : H.Subgraph | H'.IsInduced ∧ Nonempty (G ≃g H'.coe)} := by
263-
ext H'
264-
simp only [Set.mem_range, Set.mem_setOf_eq]
265-
constructor
266-
· rintro ⟨f, rfl⟩
267-
exact ⟨toSubgraph_isInduced f, ⟨f.toCopy.isoToSubgraph⟩⟩
268-
· rintro ⟨hInd, ⟨e⟩⟩
269-
refine ⟨(ofIsInduced H' hInd).comp e.toEmbedding, ?_⟩
270-
have h : ((ofIsInduced H' hInd).comp e.toEmbedding).toHom =
271-
H'.hom.comp e.toHom := by ext; simp
272-
simp [toSubgraph, Copy.toSubgraph, h, Subgraph.map_comp]
273-
274-
end Embedding
275-
276284
/-- `H.unlabeledEmbeddingCount G` is the number of induced `SimpleGraph.Subgraph`s of `H`
277285
isomorphic to `G`.
278286
See `SimpleGraph.embeddingCount` for the number of induced labeled copies. -/

0 commit comments

Comments
 (0)