Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 706d88f

Browse files
committed
feat(combinatorics/quiver/*): More edge reversal constructions (#17665)
Move * `quiver.symmetrify`, * `quiver.has_reverse`, * `quiver.has_involutive_reverse`, * `quiver.reverse`, * `quiver.path.reverse`, * `quiver.symmetrify.of`, * `quiver.lift`, * associated lemmas, from `combinatorics/quiver/connected_component.lean` to `combinatorics/quiver/symmetrify.lean`. Add * the class `prefunctor.map_reverse` witnessing that a prefunctor maps reverses to reverses, and change the lemmas taking this property as an explicit argument. * `prefunctor.symmetrify` mapping a prefunctor to the prefunctor between symmetrifications, * associated lemmas, to `combinatorics/quiver/symmetrify.lean`. Move `quiver.hom.to_pos` and `quiver.hom.to_neg` from `category_theory/groupoid/free_groupoid.lean` to `combinatorics/quiver/symmetrify.lean`. Add `map_reverse` instance for functors between groupoids. Co-authored-by: Rémi Bottinelli <bottine@users.noreply.github.com>
1 parent 11bb0c9 commit 706d88f

5 files changed

Lines changed: 235 additions & 120 deletions

File tree

src/category_theory/groupoid.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ instance groupoid_has_involutive_reverse : quiver.has_involutive_reverse C :=
7575

7676
@[simp] lemma groupoid.reverse_eq_inv (f : X ⟶ Y) : quiver.reverse f = groupoid.inv f := rfl
7777

78+
instance functor_map_reverse {D : Type*} [groupoid D] (F : C ⥤ D) :
79+
F.to_prefunctor.map_reverse :=
80+
{ map_reverse' := λ X Y f, by
81+
simp only [quiver.reverse, quiver.has_reverse.reverse', groupoid.inv_eq_inv,
82+
functor.to_prefunctor_map, functor.map_inv], }
83+
7884
variables (X Y)
7985

8086
/-- In a groupoid, isomorphisms are equivalent to morphisms. -/

src/category_theory/groupoid/free_groupoid.lean

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import category_theory.groupoid
99
import tactic.nth_rewrite
1010
import category_theory.path_category
1111
import category_theory.quotient
12+
import combinatorics.quiver.symmetric
1213

1314
/-!
1415
# Free groupoid on a quiver
@@ -45,14 +46,6 @@ universes u v u' v' u'' v''
4546

4647
variables {V : Type u} [quiver.{v+1} V]
4748

48-
/-- Shorthand for the "forward" arrow corresponding to `f` in `symmetrify V` -/
49-
abbreviation quiver.hom.to_pos {X Y : V} (f : X ⟶ Y) :
50-
(quiver.symmetrify_quiver V).hom X Y := sum.inl f
51-
52-
/-- Shorthand for the "backward" arrow corresponding to `f` in `symmetrify V` -/
53-
abbreviation quiver.hom.to_neg {X Y : V} (f : X ⟶ Y) :
54-
(quiver.symmetrify_quiver V).hom Y X := sum.inr f
55-
5649
/-- Shorthand for the "forward" arrow corresponding to `f` in `paths $ symmetrify V` -/
5750
abbreviation quiver.hom.to_pos_path {X Y : V} (f : X ⟶ Y) :
5851
((category_theory.paths.category_paths $ quiver.symmetrify V).hom X Y) := f.to_pos.to_path
@@ -168,9 +161,9 @@ lemma lift_unique (φ : V ⥤q V') (Φ : free_groupoid V ⥤ V')
168161
begin
169162
apply quotient.lift_unique,
170163
apply paths.lift_unique,
171-
apply quiver.symmetrify.lift_unique,
164+
fapply @quiver.symmetrify.lift_unique _ _ _ _ _ _ _ _ _,
172165
{ rw ←functor.to_prefunctor_comp, exact hΦ, },
173-
{ rintros X Y f,
166+
{ constructor, rintros X Y f,
174167
simp only [←functor.to_prefunctor_comp,prefunctor.comp_map, paths.of_map, inv_eq_inv],
175168
change Φ.map (inv ((quotient.functor red_step).to_prefunctor.map f.to_path)) =
176169
inv (Φ.map ((quotient.functor red_step).to_prefunctor.map f.to_path)),

src/combinatorics/quiver/connected_component.lean

Lines changed: 7 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -5,129 +5,26 @@ Authors: David Wärn
55
-/
66
import combinatorics.quiver.subquiver
77
import combinatorics.quiver.path
8-
import data.sum.basic
9-
8+
import combinatorics.quiver.symmetric
109
/-!
1110
## Weakly connected components
1211
1312
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
1413
> https://github.com/leanprover-community/mathlib4/pull/836
1514
> Any changes to this file require a corresponding PR to mathlib4.
1615
17-
For a quiver `V`, we build a quiver `symmetrify V` by adding a reversal of every edge.
18-
Informally, a path in `symmetrify V` corresponds to a 'zigzag' in `V`. This lets us
19-
define the type `weakly_connected_component V` as the quotient of `V` by the relation which
20-
identifies `a` with `b` if there is a path from `a` to `b` in `symmetrify V`. (These
21-
zigzags can be seen as a proof-relevant analogue of `eqv_gen`.)
16+
17+
For a quiver `V`, we define the type `weakly_connected_component V` as the quotient of `V`
18+
by the relation which identifies `a` with `b` if there is a path from `a` to `b` in `symmetrify V`.
19+
(These zigzags can be seen as a proof-relevant analogue of `eqv_gen`.)
2220
2321
Strongly connected components have not yet been defined.
2422
-/
25-
universes v u
23+
universes u
2624

2725
namespace quiver
2826

29-
/-- A type synonym for the symmetrized quiver (with an arrow both ways for each original arrow).
30-
NB: this does not work for `Prop`-valued quivers. It requires `[quiver.{v+1} V]`. -/
31-
@[nolint has_nonempty_instance]
32-
def symmetrify (V) : Type u := V
33-
34-
instance symmetrify_quiver (V : Type u) [quiver V] : quiver (symmetrify V) :=
35-
⟨λ a b : V, (a ⟶ b) ⊕ (b ⟶ a)⟩
36-
37-
variables (V : Type u) [quiver.{v+1} V]
38-
39-
/-- A quiver `has_reverse` if we can reverse an arrow `p` from `a` to `b` to get an arrow
40-
`p.reverse` from `b` to `a`.-/
41-
class has_reverse :=
42-
(reverse' : Π {a b : V}, (a ⟶ b) → (b ⟶ a))
43-
44-
/-- Reverse the direction of an arrow. -/
45-
def reverse {V} [quiver.{v+1} V] [has_reverse V] {a b : V} : (a ⟶ b) → (b ⟶ a) :=
46-
has_reverse.reverse'
47-
48-
/-- A quiver `has_involutive_reverse` if reversing twice is the identity.`-/
49-
class has_involutive_reverse extends has_reverse V :=
50-
(inv' : Π {a b : V} (f : a ⟶ b), reverse (reverse f) = f)
51-
52-
@[simp] lemma reverse_reverse {V} [quiver.{v+1} V] [h : has_involutive_reverse V]
53-
{a b : V} (f : a ⟶ b) : reverse (reverse f) = f := by apply h.inv'
54-
55-
variables {V}
56-
57-
instance : has_reverse (symmetrify V) := ⟨λ a b e, e.swap⟩
58-
instance : has_involutive_reverse (symmetrify V) :=
59-
{ to_has_reverse := ⟨λ a b e, e.swap⟩,
60-
inv' := λ a b e, congr_fun sum.swap_swap_eq e }
61-
62-
63-
/-- Reverse the direction of a path. -/
64-
@[simp] def path.reverse [has_reverse V] {a : V} : Π {b}, path a b → path b a
65-
| a path.nil := path.nil
66-
| b (path.cons p e) := (reverse e).to_path.comp p.reverse
67-
68-
@[simp] lemma path.reverse_to_path [has_reverse V] {a b : V} (f : a ⟶ b) :
69-
f.to_path.reverse = (reverse f).to_path := rfl
70-
71-
@[simp] lemma path.reverse_comp [has_reverse V] {a b c : V} (p : path a b) (q : path b c) :
72-
(p.comp q).reverse = q.reverse.comp p.reverse := by
73-
{ induction q, { simp, }, { simp [q_ih], }, }
74-
75-
@[simp] lemma path.reverse_reverse [h : has_involutive_reverse V] {a b : V} (p : path a b) :
76-
p.reverse.reverse = p := by
77-
{ induction p,
78-
{ simp, },
79-
{ simp only [path.reverse, path.reverse_comp, path.reverse_to_path, reverse_reverse, p_ih],
80-
refl, }, }
81-
82-
/-- The inclusion of a quiver in its symmetrification -/
83-
def symmetrify.of : prefunctor V (symmetrify V) :=
84-
{ obj := id,
85-
map := λ X Y f, sum.inl f }
86-
87-
/-- Given a quiver `V'` with reversible arrows, a prefunctor to `V'` can be lifted to one from
88-
`symmetrify V` to `V'` -/
89-
def symmetrify.lift {V' : Type*} [quiver V'] [has_reverse V'] (φ : prefunctor V V') :
90-
prefunctor (symmetrify V) V' :=
91-
{ obj := φ.obj,
92-
map := λ X Y f, sum.rec (λ fwd, φ.map fwd) (λ bwd, reverse (φ.map bwd)) f }
93-
94-
lemma symmetrify.lift_spec (V' : Type*) [quiver V'] [has_reverse V'] (φ : prefunctor V V') :
95-
symmetrify.of.comp (symmetrify.lift φ) = φ :=
96-
begin
97-
fapply prefunctor.ext,
98-
{ rintro X, refl, },
99-
{ rintros X Y f, refl, },
100-
end
101-
102-
lemma symmetrify.lift_reverse (V' : Type*) [quiver V'] [h : has_involutive_reverse V']
103-
(φ : prefunctor V V')
104-
{X Y : symmetrify V} (f : X ⟶ Y) :
105-
(symmetrify.lift φ).map (quiver.reverse f) = quiver.reverse ((symmetrify.lift φ).map f) :=
106-
begin
107-
dsimp [symmetrify.lift], cases f,
108-
{ simp only, refl, },
109-
{ simp only, rw h.inv', refl, }
110-
end
111-
112-
/-- `lift φ` is the only prefunctor extending `φ` and preserving reverses. -/
113-
lemma symmetrify.lift_unique (V' : Type*) [quiver V'] [has_reverse V']
114-
(φ : prefunctor V V')
115-
(Φ : prefunctor (symmetrify V) V')
116-
(hΦ : symmetrify.of.comp Φ = φ)
117-
(hΦinv : ∀ {X Y : V} (f : X ⟶ Y), Φ.map (reverse f) = reverse (Φ.map f)) :
118-
Φ = symmetrify.lift φ :=
119-
begin
120-
subst_vars,
121-
fapply prefunctor.ext,
122-
{ rintro X, refl, },
123-
{ rintros X Y f,
124-
cases f,
125-
{ refl, },
126-
{ dsimp [symmetrify.lift,symmetrify.of],
127-
convert hΦinv (sum.inl f), }, },
128-
end
129-
130-
variables (V)
27+
variables (V : Type*) [quiver.{u+1} V]
13128

13229
/-- Two vertices are related in the zigzag setoid if there is a
13330
zigzag of arrows from one to the other. -/

src/combinatorics/quiver/push.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ universes v v₁ v₂ u u₁ u₂
2121

2222
variables {V : Type*} [quiver V] {W : Type*} (σ : V → W)
2323

24+
namespace quiver
25+
2426
/-- The `quiver` instance obtained by pushing arrows of `V` along the map `σ : V → W` -/
2527
@[nolint unused_arguments]
2628
def push (σ : V → W) := W
@@ -80,3 +82,5 @@ begin
8082
end
8183

8284
end push
85+
86+
end quiver

0 commit comments

Comments
 (0)