Skip to content

Commit b90d0b5

Browse files
committed
chore(CategoryTheory/FiberedCategory/HomLift): Unify IsHomLift and IsHomLiftAux (#31125)
The definition `IsHomLiftAux` is not necessary, as inductives can be classes themselves. (see for example `Decidable`). This PR makes `Functor.IsHomLift` itself an inductive, taking out the middle man. Co-authored-by: Edward van de Meent <edwardvdmeent@gmail.com>
1 parent a1f5e9b commit b90d0b5

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

Mathlib/CategoryTheory/FiberedCategory/Cartesian.lean

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ morphisms `φ' : a' ⟶ b`, also lying over `f`, there exists a unique morphism
5454
`𝟙 R` such that `φ' = χ ≫ φ`.
5555
5656
See SGA 1 VI 5.1. -/
57-
class IsCartesian : Prop extends IsHomLift p f φ where
57+
class IsCartesian : Prop where
58+
[toIsHomLift : IsHomLift p f φ]
5859
universal_property {a' : 𝒳} (φ' : a' ⟶ b) [IsHomLift p f φ'] :
5960
∃! χ : a' ⟶ a, IsHomLift p (𝟙 R) χ ∧ χ ≫ φ = φ'
61+
attribute [instance] IsCartesian.toIsHomLift
6062

6163
/-- A morphism `φ : a ⟶ b` in `𝒳` lying over `f : R ⟶ S` in `𝒮` is strongly Cartesian if for
6264
all morphisms `φ' : a' ⟶ b` and all diagrams of the form
@@ -68,9 +70,11 @@ R' --g--> R --f--> S
6870
```
6971
such that `φ'` lifts `g ≫ f`, there exists a lift `χ` of `g` such that `φ' = χ ≫ φ`. -/
7072
@[stacks 02XK]
71-
class IsStronglyCartesian : Prop extends IsHomLift p f φ where
73+
class IsStronglyCartesian : Prop where
74+
[toIsHomLift : IsHomLift p f φ]
7275
universal_property' {a' : 𝒳} (g : p.obj a' ⟶ R) (φ' : a' ⟶ b) [IsHomLift p (g ≫ f) φ'] :
7376
∃! χ : a' ⟶ a, IsHomLift p g χ ∧ χ ≫ φ = φ'
77+
attribute [instance] IsStronglyCartesian.toIsHomLift
7478

7579
end
7680

Mathlib/CategoryTheory/FiberedCategory/Cocartesian.lean

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b)
4949
/-- A morphism `φ : a ⟶ b` in `𝒳` lying over `f : R ⟶ S` in `𝒮` is co-Cartesian if for all
5050
morphisms `φ' : a ⟶ b'`, also lying over `f`, there exists a unique morphism `χ : b ⟶ b'` lifting
5151
`𝟙 S` such that `φ' = φ ≫ χ`. -/
52-
class IsCocartesian : Prop extends IsHomLift p f φ where
52+
class IsCocartesian : Prop where
53+
[toIsHomLift : IsHomLift p f φ]
5354
universal_property {b' : 𝒳} (φ' : a ⟶ b') [IsHomLift p f φ'] :
5455
∃! χ : b ⟶ b', IsHomLift p (𝟙 S) χ ∧ φ ≫ χ = φ'
5556

57+
attribute [instance] IsCocartesian.toIsHomLift
5658
/-- A morphism `φ : a ⟶ b` in `𝒳` lying over `f : R ⟶ S` in `𝒮` is strongly co-Cartesian if for
5759
all morphisms `φ' : a ⟶ b'` and all diagrams of the form
5860
```
@@ -63,9 +65,11 @@ R --f--> S --g--> S'
6365
```
6466
such that `φ'` lifts `f ≫ g`, there exists a lift `χ` of `g` such that `φ' = χ ≫ φ`. -/
6567
@[stacks 02XK]
66-
class IsStronglyCocartesian : Prop extends IsHomLift p f φ where
68+
class IsStronglyCocartesian : Prop where
69+
[toIsHomLift : IsHomLift p f φ]
6770
universal_property' {b' : 𝒳} (g : S ⟶ p.obj b') (φ' : a ⟶ b') [IsHomLift p (f ≫ g) φ'] :
6871
∃! χ : b ⟶ b', IsHomLift p g χ ∧ φ ≫ χ = φ'
72+
attribute [instance] IsStronglyCocartesian.toIsHomLift
6973

7074
end
7175

Mathlib/CategoryTheory/FiberedCategory/HomLift.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ does not make sense when the domain and/or codomain of `φ` and `f` are not defi
1717
1818
## Main definition
1919
20-
Given morphism `φ : a ⟶ b` in `𝒳` and `f : R ⟶ S` in `𝒮`, `p.IsHomLift f φ` is a class, defined
21-
using the auxiliary inductive type `IsHomLiftAux` which expresses the fact that `f = p(φ)`.
20+
Given morphism `φ : a ⟶ b` in `𝒳` and `f : R ⟶ S` in `𝒮`, `p.IsHomLift f φ` is a class
21+
which expresses the fact that `f = p(φ)`.
2222
2323
We also define a macro `subst_hom_lift p f φ` which can be used to substitute `f` with `p(φ)` in a
24-
goal, this tactic is just short for `obtain ⟨⟩ := Functor.IsHomLift.cond (p:=p) (f:=f) (φ:=φ)`, and
24+
goal, this tactic is just short for `obtain ⟨⟩ := inferInstanceAs (p.IsHomLift f φ)`, and
2525
it is used to make the code more readable.
2626
27+
## Implementation
28+
The class `IsHomLift` is defined as an inductive with the single constructor
29+
`.map (φ : a ⟶ b) : IsHomLift p (p.map φ) φ`, similar to how `Eq a b` has the single constructor
30+
`.rfl (a : α) : Eq a a`.
31+
2732
-/
2833

2934
universe u₁ v₁ u₂ v₂
@@ -34,10 +39,6 @@ variable {𝒮 : Type u₁} {𝒳 : Type u₂} [Category.{v₁} 𝒳] [Category.
3439

3540
namespace CategoryTheory
3641

37-
/-- Helper-type for defining `IsHomLift`. -/
38-
inductive IsHomLiftAux : ∀ {R S : 𝒮} {a b : 𝒳} (_ : R ⟶ S) (_ : a ⟶ b), Prop
39-
| map {a b : 𝒳} (φ : a ⟶ b) : IsHomLiftAux (p.map φ) φ
40-
4142
/-- Given a functor `p : 𝒳 ⥤ 𝒮`, an arrow `φ : a ⟶ b` in `𝒳` and an arrow `f : R ⟶ S` in `𝒮`,
4243
`p.IsHomLift f φ` expresses the fact that `φ` lifts `f` through `p`.
4344
This is often drawn as:
@@ -48,19 +49,18 @@ This is often drawn as:
4849
v v
4950
R --f--> S
5051
``` -/
51-
class Functor.IsHomLift {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) : Prop where
52-
cond : IsHomLiftAux p f φ
52+
class inductive Functor.IsHomLift : ∀ {R S : 𝒮} {a b : 𝒳} (_ : R ⟶ S) (_ : a ⟶ b), Prop
53+
| map {a b : 𝒳} (φ : a ⟶ b) : IsHomLift (p.map φ) φ
5354

5455
/-- `subst_hom_lift p f φ` tries to substitute `f` with `p(φ)` by using `p.IsHomLift f φ` -/
5556
macro "subst_hom_lift" p:term:max f:term:max φ:term:max : tactic =>
56-
`(tactic| obtain ⟨⟩ := Functor.IsHomLift.cond (p := $p) (f := $f) (φ := $φ))
57+
`(tactic| obtain ⟨⟩ := inferInstanceAs (Functor.IsHomLift $p $f $φ))
5758

5859
namespace IsHomLift
5960

6061
/-- For any arrow `φ : a ⟶ b` in `𝒳`, `φ` lifts the arrow `p.map φ` in the base `𝒮`. -/
6162
@[simp]
62-
instance map {a b : 𝒳} (φ : a ⟶ b) : p.IsHomLift (p.map φ) φ where
63-
cond := by constructor
63+
instance map {a b : 𝒳} (φ : a ⟶ b) : p.IsHomLift (p.map φ) φ := .map φ
6464

6565
@[simp]
6666
instance (a : 𝒳) : p.IsHomLift (𝟙 (p.obj a)) (𝟙 a) := by

0 commit comments

Comments
 (0)