@@ -50,23 +50,28 @@ variable {V W X : Type*} (G : SimpleGraph V) (G' : SimpleGraph W) {u v : V}
5050/-! ## Map and comap -/
5151
5252
53- /-- Given an injective function, there is a covariant induced map on graphs by pushing forward
53+ /-- Given a function, there is a covariant induced map on graphs by pushing forward
5454the adjacency relation.
5555
56- This is injective (see `SimpleGraph.map_injective`). -/
57- protected def map (f : V ↪ W) (G : SimpleGraph V) : SimpleGraph W where
58- Adj := Relation.Map G.Adj f f
56+ This is injective when the function is (see `SimpleGraph.map_injective`). -/
57+ protected def map (f : V → W) (G : SimpleGraph V) : SimpleGraph W where
58+ Adj := Ne ⊓ Relation.Map G.Adj f f
5959 symm a b := by
6060 rintro ⟨v, w, h, _⟩
6161 aesop (add norm unfold Relation.Map) (add forward safe Adj.symm)
62- loopless := ⟨fun a ↦ by aesop (add norm unfold Relation.Map)⟩
6362
64- instance instDecidableMapAdj {f : V ↪ W} {a b} [Decidable (Relation.Map G.Adj f f a b)] :
65- Decidable ((G.map f).Adj a b) := ‹Decidable (Relation.Map G.Adj f f a b)›
63+ instance instDecidableMapAdj [DecidableEq W] {f : V → W} {a b}
64+ [Decidable (Relation.Map G.Adj f f a b)] : Decidable ((G.map f).Adj a b) := by
65+ dsimp [SimpleGraph.map]; infer_instance
6666
6767@[simp]
6868theorem map_adj (f : V ↪ W) (G : SimpleGraph V) (u v : W) :
69- (G.map f).Adj u v ↔ ∃ u' v' : V, G.Adj u' v' ∧ f u' = u ∧ f v' = v :=
69+ (G.map f).Adj u v ↔ ∃ u' v' : V, G.Adj u' v' ∧ f u' = u ∧ f v' = v := by
70+ dsimp [SimpleGraph.map, Relation.Map]
71+ grind [SimpleGraph.Adj.ne]
72+
73+ theorem map_adj' (f : V → W) (G : SimpleGraph V) (u v : W) :
74+ (G.map f).Adj u v ↔ u ≠ v ∧ ∃ u' v' : V, G.Adj u' v' ∧ f u' = u ∧ f v' = v :=
7075 Iff.rfl
7176
7277theorem edgeSet_map (f : V ↪ W) (G : SimpleGraph V) :
@@ -86,15 +91,19 @@ theorem edgeSet_map (f : V ↪ W) (G : SimpleGraph V) :
8691lemma map_adj_apply {G : SimpleGraph V} {f : V ↪ W} {a b : V} :
8792 (G.map f).Adj (f a) (f b) ↔ G.Adj a b := by simp
8893
89- theorem map_monotone (f : V ↪ W) : Monotone (SimpleGraph.map f) := by
90- rintro G G' h _ _ ⟨ u, v, ha, rfl, rfl⟩
91- exact ⟨_, _, h ha, rfl, rfl⟩
94+ theorem map_monotone (f : V → W) : Monotone (SimpleGraph.map f) := by
95+ rintro G G' h z1 z2 ⟨huv, u, v, ha, rfl, rfl⟩
96+ exact ⟨huv, _, _, h ha, rfl, rfl⟩
9297
93- @[simp] lemma map_id : G.map (Function.Embedding.refl _) = G :=
94- SimpleGraph.ext <| Relation.map_id_id _
98+ @[simp] lemma map_id : G.map id = G := by
99+ ext
100+ dsimp [SimpleGraph.map, Relation.Map]
101+ grind [SimpleGraph.Adj.ne]
95102
96- @[simp] lemma map_map (f : V ↪ W) (g : W ↪ X) : (G.map f).map g = G.map (f.trans g) :=
97- SimpleGraph.ext <| Relation.map_map _ _ _ _ _
103+ @[simp] lemma map_map (f : V → W) (g : W → X) : (G.map f).map g = G.map (g ∘ f) := by
104+ ext
105+ dsimp [SimpleGraph.map, Relation.Map]
106+ grind [SimpleGraph.Adj.ne]
98107
99108theorem support_map (f : V ↪ W) (G : SimpleGraph V) :
100109 (G.map f).support = f '' G.support := by
@@ -154,8 +163,8 @@ theorem comap_surjective (f : V ↪ W) : Function.Surjective (SimpleGraph.comap
154163
155164theorem map_le_iff_le_comap (f : V ↪ W) (G : SimpleGraph V) (G' : SimpleGraph W) :
156165 G.map f ≤ G' ↔ G ≤ G'.comap f :=
157- ⟨fun h _ _ ha => h ⟨_, _, ha, rfl, rfl⟩, by
158- rintro h _ _ ⟨u, v, ha, rfl, rfl⟩
166+ ⟨fun h _ _ ha => h ⟨f.injective.ne ha.ne, _, _, ha, rfl, rfl⟩, by
167+ rintro h _ _ ⟨-, u, v, ha, rfl, rfl⟩
159168 exact h ha⟩
160169
161170set_option backward.isDefEq.respectTransparency false in
@@ -578,15 +587,15 @@ protected def comap (f : V ≃ W) (G : SimpleGraph W) : G.comap f.toEmbedding
578587lemma comap_apply (f : V ≃ W) (G : SimpleGraph W) (v : V) :
579588 SimpleGraph.Iso.comap f G v = f v := rfl
580589
590+ -- Porting note: `@[simps]` does not work here anymore since `f` is not a constructor application.
591+ -- `@[simps toEmbedding]` could work, but Floris suggested writing `map_apply` for now.
581592@[simp]
582593lemma comap_symm_apply (f : V ≃ W) (G : SimpleGraph W) (w : W) :
583594 (SimpleGraph.Iso.comap f G).symm w = f.symm w := rfl
584595
585- /-- Given an injective function, there is an embedding from a graph into the mapped graph. -/
586- -- Porting note: `@[simps]` does not work here anymore since `f` is not a constructor application.
587- -- `@[simps toEmbedding]` could work, but Floris suggested writing `map_apply` for now.
596+ /-- Given a bijective function, there is an isomorphism from a graph into the mapped graph. -/
588597protected def map (f : V ≃ W) (G : SimpleGraph V) : G ≃g G.map f.toEmbedding :=
589- { f with map_rel_iff' := by simp }
598+ { f with map_rel_iff' := by aesop (add simp map_adj') }
590599
591600@[simp]
592601lemma map_apply (f : V ≃ W) (G : SimpleGraph V) (v : V) :
0 commit comments