Skip to content

Commit c34f0e3

Browse files
committed
feat(CategoryTheory/Bicategory): Spans with left and right legs satisfying given morphism properties (#39536)
In this PR, we define a structure `Span Wₗ Wᵣ c c'` which bundles the data of spans in `C` from `c` to `c'` where the left map satisfies `Wₗ` and the right map satisfies `Wᵣ`. When `Wₗ` and `Wᵣ` are adequate, we define the identity span and the composition of compatible spans. In a later pull request, this will be extended to be the 1-morphisms of a bicategory structure on a type alias of `C`. From [SymmMonCoherence](https://github.com/robin-carlier/SymmMonCoherence)
1 parent 1c2b90b commit c34f0e3

2 files changed

Lines changed: 152 additions & 0 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,7 @@ public import Mathlib.CategoryTheory.Bicategory.NaturalTransformation.Pseudo
25282528
public import Mathlib.CategoryTheory.Bicategory.Opposites
25292529
public import Mathlib.CategoryTheory.Bicategory.Product
25302530
public import Mathlib.CategoryTheory.Bicategory.SingleObj
2531+
public import Mathlib.CategoryTheory.Bicategory.Span.Basic
25312532
public import Mathlib.CategoryTheory.Bicategory.Strict.Basic
25322533
public import Mathlib.CategoryTheory.Bicategory.Strict.Pseudofunctor
25332534
public import Mathlib.CategoryTheory.Bicategory.Yoneda
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/-
2+
Copyright (c) 2025 Robin Carlier. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Robin Carlier
5+
-/
6+
module
7+
8+
public import Mathlib.CategoryTheory.MorphismProperty.Limits
9+
public import Mathlib.CategoryTheory.LocallyCartesianClosed.ChosenPullbacksAlong
10+
11+
/-! # Bicategories of spans in a category
12+
13+
In this file, given a category `C` and two morphism properties
14+
Wₗ and Wᵣ in C that are stable under compositions, contain identities and
15+
such that for any morphism `b : x₃ ⟶ x₄` in Wₗ and any morphism `r : x₂ → x₃` in Wᵣ,
16+
there exists a pullback square
17+
```
18+
t
19+
x₁ --> x₂
20+
| |
21+
l | | r
22+
v v
23+
x₃ --> x₄
24+
b
25+
```
26+
in `C` such that `t` satisfies `Wₗ` and `l` satisfies `Wᵣ`,
27+
we construct the bicategory of spans in C with left morphism in Wₗ and right morphism
28+
in Wᵣ (TODO @robin-carlier).
29+
30+
-/
31+
32+
@[expose] public section
33+
34+
namespace CategoryTheory
35+
36+
variable {C : Type*} [Category* C]
37+
(Wₗ : MorphismProperty C)
38+
(Wᵣ : MorphismProperty C)
39+
40+
/-- A (Wₗ, Wᵣ)-span from c to c' is the data of an
41+
object `a : C`, together with a morphism `a ⟶ c` in Wₗ,
42+
and a morphism `a ⟶ c'` in Wᵣ. -/
43+
structure Span (c c' : C) where
44+
/-- the apex of the span -/
45+
apex : C
46+
/-- the left map -/
47+
l : apex ⟶ c
48+
/-- the right map -/
49+
r : apex ⟶ c'
50+
wl : Wₗ l
51+
wr : Wᵣ r
52+
53+
namespace Span
54+
55+
variable {Wₗ Wᵣ} {c c' : C}
56+
57+
/-- A morphism of spans is a morphism between the apices compatible
58+
with the projections. -/
59+
structure Hom (S₁ S₂ : Span Wₗ Wᵣ c c') : Type _ where
60+
/-- the map between the apices -/
61+
hom : S₁.apex ⟶ S₂.apex
62+
hom_l : hom ≫ S₂.l = S₁.l := by cat_disch
63+
hom_r : hom ≫ S₂.r = S₁.r := by cat_disch
64+
65+
attribute [reassoc (attr := simp)] Hom.hom_l Hom.hom_r
66+
attribute [grind =] Hom.hom_l Hom.hom_r
67+
68+
@[simps!]
69+
instance : Category (Span Wₗ Wᵣ c c') where
70+
Hom := Hom
71+
comp φ φ' := { hom := φ.hom ≫ φ'.hom }
72+
id S := { hom := 𝟙 _ }
73+
74+
attribute [grind =] id_hom comp_hom
75+
76+
@[ext, grind ext]
77+
lemma hom_ext {S S' : Span Wₗ Wᵣ c c'} {f g : S ⟶ S'} (h : f.hom = g.hom) :
78+
f = g := by
79+
cases f
80+
cases g
81+
grind
82+
83+
set_option mathlib.tactic.category.grind true in
84+
/-- Construct an isomorphism of spans from an isomorphism between the
85+
apices that is compatible with the projections. -/
86+
@[simps (attr := grind =)]
87+
def mkIso {S S' : Span Wₗ Wᵣ c c'} (e : S.apex ≅ S'.apex)
88+
(hₗ : e.hom ≫ S'.l = S.l := by cat_disch)
89+
(hᵣ : e.hom ≫ S'.r = S.r := by cat_disch) :
90+
S ≅ S' where
91+
hom.hom := e.hom
92+
inv.hom := e.inv
93+
94+
variable [Wₗ.ContainsIdentities] [Wᵣ.ContainsIdentities] [Wₗ.HasPullbacksAgainst Wᵣ]
95+
[Wₗ.IsStableUnderBaseChangeAgainst Wᵣ] [Wᵣ.IsStableUnderBaseChangeAgainst Wₗ]
96+
[Wₗ.IsStableUnderComposition] [Wᵣ.IsStableUnderComposition]
97+
98+
open Limits in
99+
instance {c c' c'' : C} (S₁ : Span Wₗ Wᵣ c c') (S₂ : Span Wₗ Wᵣ c' c'') : HasPullback S₁.r S₂.l :=
100+
letI : HasPullback S₂.l S₁.r := hasPullback_ofHasPullbacksAgainst S₂.wl S₁.wr
101+
hasPullback_symmetry _ _
102+
103+
instance (S₁ : Span Wₗ Wᵣ c c') : Wₗ.IsStableUnderBaseChangeAlong S₁.r :=
104+
MorphismProperty.IsStableUnderBaseChangeAgainst.isStableUnderBaseChangeAlong _ S₁.wr
105+
106+
instance (S₁ : Span Wₗ Wᵣ c c') : Wᵣ.IsStableUnderBaseChangeAlong S₁.l :=
107+
MorphismProperty.IsStableUnderBaseChangeAgainst.isStableUnderBaseChangeAlong _ S₁.wl
108+
109+
/-- The identity span, where both legs are identity morphisms. -/
110+
@[simps (attr := grind =)]
111+
def id (c : C) :
112+
Span Wₗ Wᵣ c c where
113+
apex := c
114+
l := 𝟙 _
115+
r := 𝟙 _
116+
wl := MorphismProperty.ContainsIdentities.id_mem _
117+
wr := MorphismProperty.ContainsIdentities.id_mem _
118+
119+
open Limits MorphismProperty in
120+
/-- The composition of two spans: if the relevant pullback exists and if the
121+
morphism properties are stable under the relevant base change, it is given by the
122+
total span
123+
```
124+
P
125+
/ \
126+
/ \
127+
X₁ X₂
128+
/ \ / \
129+
c c' c''
130+
```
131+
where the top diamond is a pullback square
132+
-/
133+
@[simps (attr := grind =)]
134+
noncomputable def comp {c c' c'' : C}
135+
(S₁ : Span Wₗ Wᵣ c c') (S₂ : Span Wₗ Wᵣ c' c'') :
136+
Span Wₗ Wᵣ c c'' where
137+
apex := pullback S₁.r S₂.l
138+
l := pullback.fst S₁.r S₂.l ≫ S₁.l
139+
r := pullback.snd S₁.r S₂.l ≫ S₂.r
140+
wl :=
141+
IsStableUnderComposition.comp_mem
142+
_ _ (IsStableUnderBaseChangeAlong.of_isPullback
143+
(.flip <| .of_hasPullback S₁.r S₂.l) S₂.wl) S₁.wl
144+
wr :=
145+
IsStableUnderComposition.comp_mem
146+
_ _ (IsStableUnderBaseChangeAlong.of_isPullback
147+
(.of_hasPullback S₁.r S₂.l) S₁.wr) S₂.wr
148+
149+
end Span
150+
151+
end CategoryTheory

0 commit comments

Comments
 (0)