|
| 1 | +/- |
| 2 | +Copyright (c) 2024 Calle Sönne. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Paul Lezeau, Calle Sönne |
| 5 | +-/ |
| 6 | + |
| 7 | +import Mathlib.CategoryTheory.Functor.Category |
| 8 | +import Mathlib.CategoryTheory.CommSq |
| 9 | + |
| 10 | +/-! |
| 11 | +
|
| 12 | +# HomLift |
| 13 | +
|
| 14 | +Given a functor `p : 𝒳 ⥤ 𝒮`, this file provides API for expressing the fact that `p(φ) = f` |
| 15 | +for given morphisms `φ` and `f`. The reason this API is needed is because, in general, `p.map φ = f` |
| 16 | +does not make sense when the domain and/or codomain of `φ` and `f` are not definitionally equal. |
| 17 | +
|
| 18 | +## Main definition |
| 19 | +
|
| 20 | +Given morphism `φ : a ⟶ b` in `𝒳` and `f : R ⟶ S` in `𝒮`, `p.IsHomLift f φ` is a class, defined |
| 21 | +using the auxillary inductive type `IsHomLiftAux` which expresses the fact that `f = p(φ)`. |
| 22 | +
|
| 23 | +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 |
| 25 | +it is used to make the code more readable. |
| 26 | +
|
| 27 | +-/ |
| 28 | + |
| 29 | +universe u₁ v₁ u₂ v₂ |
| 30 | + |
| 31 | +open CategoryTheory Category |
| 32 | + |
| 33 | +variable {𝒮 : Type u₁} {𝒳 : Type u₂} [Category.{v₁} 𝒳] [Category.{v₂} 𝒮] (p : 𝒳 ⥤ 𝒮) |
| 34 | + |
| 35 | +namespace CategoryTheory |
| 36 | + |
| 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 | + |
| 41 | +/-- Given a functor `p : 𝒳 ⥤ 𝒮`, an arrow `φ : a ⟶ b` in `𝒳` and an arrow `f : R ⟶ S` in `𝒮`, |
| 42 | +`p.IsHomLift f φ` expresses the fact that `φ` lifts `f` through `p`. |
| 43 | +This is often drawn as: |
| 44 | +``` |
| 45 | + a --φ--> b |
| 46 | + - - |
| 47 | + | | |
| 48 | + v v |
| 49 | + R --f--> S |
| 50 | +``` -/ |
| 51 | +class Functor.IsHomLift {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) : Prop where |
| 52 | + cond : IsHomLiftAux p f φ |
| 53 | + |
| 54 | +/-- `subst_hom_lift p f φ` tries to substitute `f` with `p(φ)` by using `p.IsHomLift f φ` -/ |
| 55 | +macro "subst_hom_lift" p:ident f:ident φ:ident : tactic => |
| 56 | + `(tactic| obtain ⟨⟩ := Functor.IsHomLift.cond (p:=$p) (f:=$f) (φ:=$φ)) |
| 57 | + |
| 58 | +/-- For any arrow `φ : a ⟶ b` in `𝒳`, `φ` lifts the arrow `p.map φ` in the base `𝒮`-/ |
| 59 | +@[simp] |
| 60 | +instance {a b : 𝒳} (φ : a ⟶ b) : p.IsHomLift (p.map φ) φ where |
| 61 | + cond := by constructor |
| 62 | + |
| 63 | +@[simp] |
| 64 | +instance (a : 𝒳) : p.IsHomLift (𝟙 (p.obj a)) (𝟙 a) := by |
| 65 | + rw [← p.map_id]; infer_instance |
| 66 | + |
| 67 | +namespace IsHomLift |
| 68 | + |
| 69 | +protected lemma id {p : 𝒳 ⥤ 𝒮} {R : 𝒮} {a : 𝒳} (ha : p.obj a = R) : p.IsHomLift (𝟙 R) (𝟙 a) := by |
| 70 | + cases ha; infer_instance |
| 71 | + |
| 72 | +section |
| 73 | + |
| 74 | +variable {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] |
| 75 | + |
| 76 | +lemma domain_eq : p.obj a = R := by |
| 77 | + subst_hom_lift p f φ; rfl |
| 78 | + |
| 79 | +lemma codomain_eq : p.obj b = S := by |
| 80 | + subst_hom_lift p f φ; rfl |
| 81 | + |
| 82 | +lemma fac : f = eqToHom (domain_eq p f φ).symm ≫ p.map φ ≫ eqToHom (codomain_eq p f φ) := by |
| 83 | + subst_hom_lift p f φ; simp |
| 84 | + |
| 85 | +lemma fac' : p.map φ = eqToHom (domain_eq p f φ) ≫ f ≫ eqToHom (codomain_eq p f φ).symm := by |
| 86 | + subst_hom_lift p f φ; simp |
| 87 | + |
| 88 | +lemma commSq : CommSq (p.map φ) (eqToHom (domain_eq p f φ)) (eqToHom (codomain_eq p f φ)) f where |
| 89 | + w := by simp only [fac p f φ, eqToHom_trans_assoc, eqToHom_refl, id_comp] |
| 90 | + |
| 91 | +end |
| 92 | + |
| 93 | +lemma eq_of_isHomLift {a b : 𝒳} (f : p.obj a ⟶ p.obj b) (φ : a ⟶ b) [p.IsHomLift f φ] : |
| 94 | + f = p.map φ := by |
| 95 | + simp only [fac p f φ, eqToHom_refl, comp_id, id_comp] |
| 96 | + |
| 97 | +lemma of_fac {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S) |
| 98 | + (h : f = eqToHom ha.symm ≫ p.map φ ≫ eqToHom hb) : p.IsHomLift f φ := by |
| 99 | + subst ha hb h; simp |
| 100 | + |
| 101 | +lemma of_fac' {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S) |
| 102 | + (h : p.map φ = eqToHom ha ≫ f ≫ eqToHom hb.symm) : p.IsHomLift f φ := by |
| 103 | + subst ha hb |
| 104 | + obtain rfl : f = p.map φ := by simpa using h.symm |
| 105 | + infer_instance |
| 106 | + |
| 107 | +lemma of_commSq {R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (ha : p.obj a = R) (hb : p.obj b = S) |
| 108 | + (h : CommSq (p.map φ) (eqToHom ha) (eqToHom hb) f) : p.IsHomLift f φ := by |
| 109 | + subst ha hb |
| 110 | + obtain rfl : f = p.map φ := by simpa using h.1.symm |
| 111 | + infer_instance |
| 112 | + |
| 113 | +instance comp {R S T : 𝒮} {a b c : 𝒳} (f : R ⟶ S) (g : S ⟶ T) (φ : a ⟶ b) |
| 114 | + (ψ : b ⟶ c) [p.IsHomLift f φ] [p.IsHomLift g ψ] : p.IsHomLift (f ≫ g) (φ ≫ ψ) := by |
| 115 | + apply of_commSq |
| 116 | + rw [p.map_comp] |
| 117 | + apply CommSq.horiz_comp (commSq p f φ) (commSq p g ψ) |
| 118 | + |
| 119 | +/-- If `φ : a ⟶ b` and `ψ : b ⟶ c` lift `𝟙 R`, then so does `φ ≫ ψ` -/ |
| 120 | +instance lift_id_comp (R : 𝒮) {a b c : 𝒳} (φ : a ⟶ b) (ψ : b ⟶ c) |
| 121 | + [p.IsHomLift (𝟙 R) φ] [p.IsHomLift (𝟙 R) ψ] : p.IsHomLift (𝟙 R) (φ ≫ ψ) := |
| 122 | + comp_id (𝟙 R) ▸ comp p (𝟙 R) (𝟙 R) φ ψ |
| 123 | + |
| 124 | +/-- If `φ : a ⟶ b` lifts `f` and `ψ : b ⟶ c` lifts `𝟙 T`, then `φ ≫ ψ` lifts `f` -/ |
| 125 | +lemma comp_lift_id_right {R S : 𝒮} {a b c : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] |
| 126 | + (T : 𝒮) (ψ : b ⟶ c) [p.IsHomLift (𝟙 T) ψ] : p.IsHomLift f (φ ≫ ψ) := by |
| 127 | + obtain rfl : S = T := by rw [← codomain_eq p f φ, domain_eq p (𝟙 T) ψ] |
| 128 | + simpa using inferInstanceAs (p.IsHomLift (f ≫ 𝟙 S) (φ ≫ ψ)) |
| 129 | + |
| 130 | +/-- If `φ : a ⟶ b` lifts `𝟙 T` and `ψ : b ⟶ c` lifts `f`, then `φ ≫ ψ` lifts `f` -/ |
| 131 | +lemma comp_lift_id_left {a b c : 𝒳} (R : 𝒮) (φ : a ⟶ b) [p.IsHomLift (𝟙 R) φ] |
| 132 | + {S T : 𝒮} (f : S ⟶ T) (ψ : b ⟶ c) [p.IsHomLift f ψ] : p.IsHomLift f (φ ≫ ψ) := by |
| 133 | + obtain rfl : R = S := by rw [← codomain_eq p (𝟙 R) φ, domain_eq p f ψ] |
| 134 | + simpa using inferInstanceAs (p.IsHomLift (𝟙 R ≫ f) (φ ≫ ψ)) |
| 135 | + |
| 136 | +lemma eqToHom_domain_lift_id {p : 𝒳 ⥤ 𝒮} {a b : 𝒳} (hab : a = b) {R : 𝒮} (hR : p.obj a = R) : |
| 137 | + p.IsHomLift (𝟙 R) (eqToHom hab) := by |
| 138 | + subst hR hab; simp |
| 139 | + |
| 140 | +lemma eqToHom_codomain_lift_id {p : 𝒳 ⥤ 𝒮} {a b : 𝒳} (hab : a = b) {S : 𝒮} (hS : p.obj b = S) : |
| 141 | + p.IsHomLift (𝟙 S) (eqToHom hab) := by |
| 142 | + subst hS hab; simp |
| 143 | + |
| 144 | +lemma id_lift_eqToHom_domain {p : 𝒳 ⥤ 𝒮} {R S : 𝒮} (hRS : R = S) {a : 𝒳} (ha : p.obj a = R) : |
| 145 | + p.IsHomLift (eqToHom hRS) (𝟙 a) := by |
| 146 | + subst hRS ha; simp |
| 147 | + |
| 148 | +lemma id_lift_eqToHom_codomain {p : 𝒳 ⥤ 𝒮} {R S : 𝒮} (hRS : R = S) {b : 𝒳} (hb : p.obj b = S) : |
| 149 | + p.IsHomLift (eqToHom hRS) (𝟙 b) := by |
| 150 | + subst hRS hb; simp |
| 151 | + |
| 152 | +instance comp_eqToHom_lift {R S : 𝒮} {a' a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : a' = a) |
| 153 | + [p.IsHomLift f φ] : p.IsHomLift f (eqToHom h ≫ φ) := by |
| 154 | + subst h; simp_all |
| 155 | + |
| 156 | +instance eqToHom_comp_lift {R S : 𝒮} {a b b' : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : b = b') |
| 157 | + [p.IsHomLift f φ] : p.IsHomLift f (φ ≫ eqToHom h) := by |
| 158 | + subst h; simp_all |
| 159 | + |
| 160 | +instance lift_eqToHom_comp {R' R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : R' = R) |
| 161 | + [p.IsHomLift f φ] : p.IsHomLift (eqToHom h ≫ f) φ := by |
| 162 | + subst h; simp_all |
| 163 | + |
| 164 | +instance lift_comp_eqToHom {R S S': 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : S = S') |
| 165 | + [p.IsHomLift f φ] : p.IsHomLift (f ≫ eqToHom h) φ := by |
| 166 | + subst h; simp_all |
| 167 | + |
| 168 | +@[simp] |
| 169 | +lemma comp_eqToHom_lift_iff {R S : 𝒮} {a' a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : a' = a) : |
| 170 | + p.IsHomLift f (eqToHom h ≫ φ) ↔ p.IsHomLift f φ where |
| 171 | + mp := fun hφ' => by subst h; simpa using hφ' |
| 172 | + mpr := fun hφ => inferInstance |
| 173 | + |
| 174 | +@[simp] |
| 175 | +lemma eqToHom_comp_lift_iff {R S : 𝒮} {a b b' : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : b = b') : |
| 176 | + p.IsHomLift f (φ ≫ eqToHom h) ↔ p.IsHomLift f φ where |
| 177 | + mp := fun hφ' => by subst h; simpa using hφ' |
| 178 | + mpr := fun hφ => inferInstance |
| 179 | + |
| 180 | +@[simp] |
| 181 | +lemma lift_eqToHom_comp_iff {R' R S : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : R' = R) : |
| 182 | + p.IsHomLift (eqToHom h ≫ f) φ ↔ p.IsHomLift f φ where |
| 183 | + mp := fun hφ' => by subst h; simpa using hφ' |
| 184 | + mpr := fun hφ => inferInstance |
| 185 | + |
| 186 | +@[simp] |
| 187 | +lemma lift_comp_eqToHom_iff {R S S' : 𝒮} {a b : 𝒳} (f : R ⟶ S) (φ : a ⟶ b) (h : S = S') : |
| 188 | + p.IsHomLift (f ≫ eqToHom h) φ ↔ p.IsHomLift f φ where |
| 189 | + mp := fun hφ' => by subst h; simpa using hφ' |
| 190 | + mpr := fun hφ => inferInstance |
| 191 | + |
| 192 | +section |
| 193 | + |
| 194 | +variable {R S : 𝒮} {a b : 𝒳} |
| 195 | + |
| 196 | +/-- Given a morphism `f : R ⟶ S`, and an isomorphism `φ : a ≅ b` lifting `f`, `isoOfIsoLift f φ` is |
| 197 | +the isomorphism `Φ : R ≅ S` with `Φ.hom = f` induced from `φ` -/ |
| 198 | +@[simps hom] |
| 199 | +def isoOfIsoLift (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] : |
| 200 | + R ≅ S where |
| 201 | + hom := f |
| 202 | + inv := eqToHom (codomain_eq p f φ.hom).symm ≫ (p.mapIso φ).inv ≫ eqToHom (domain_eq p f φ.hom) |
| 203 | + hom_inv_id := by subst_hom_lift p f φ.hom; simp [← p.map_comp] |
| 204 | + inv_hom_id := by subst_hom_lift p f φ.hom; simp [← p.map_comp] |
| 205 | + |
| 206 | +@[simp] |
| 207 | +lemma isoOfIsoLift_inv_hom_id (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] : |
| 208 | + (isoOfIsoLift p f φ).inv ≫ f = 𝟙 S := |
| 209 | + (isoOfIsoLift p f φ).inv_hom_id |
| 210 | + |
| 211 | +@[simp] |
| 212 | +lemma isoOfIsoLift_hom_inv_id (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] : |
| 213 | + f ≫ (isoOfIsoLift p f φ).inv = 𝟙 R := |
| 214 | + (isoOfIsoLift p f φ).hom_inv_id |
| 215 | + |
| 216 | +/-- If `φ : a ⟶ b` lifts `f : R ⟶ S` and `φ` is an isomorphism, then so is `f`. -/ |
| 217 | +lemma isIso_of_lift_isIso (f : R ⟶ S) (φ : a ⟶ b) [p.IsHomLift f φ] [IsIso φ] : IsIso f := |
| 218 | + (fac p f φ) ▸ inferInstance |
| 219 | + |
| 220 | +/-- Given `φ : a ≅ b` and `f : R ≅ S`, such that `φ.hom` lifts `f.hom`, then `φ.inv` lifts |
| 221 | +`f.inv`. -/ |
| 222 | +protected instance inv_lift_inv (f : R ≅ S) (φ : a ≅ b) [p.IsHomLift f.hom φ.hom] : |
| 223 | + p.IsHomLift f.inv φ.inv := by |
| 224 | + apply of_commSq |
| 225 | + apply CommSq.horiz_inv (f:=p.mapIso φ) (commSq p f.hom φ.hom) |
| 226 | + |
| 227 | +/-- Given `φ : a ≅ b` and `f : R ⟶ S`, such that `φ.hom` lifts `f`, then `φ.inv` lifts the |
| 228 | +inverse of `f` given by `isoOfIsoLift`. -/ |
| 229 | +protected instance inv_lift (f : R ⟶ S) (φ : a ≅ b) [p.IsHomLift f φ.hom] : |
| 230 | + p.IsHomLift (isoOfIsoLift p f φ).inv φ.inv := by |
| 231 | + apply of_commSq |
| 232 | + apply CommSq.horiz_inv (f:=p.mapIso φ) (by apply commSq p f φ.hom) |
| 233 | + |
| 234 | +/-- If `φ : a ⟶ b` lifts `f : R ⟶ S` and both are isomorphisms, then `φ⁻¹` lifts `f⁻¹`. -/ |
| 235 | +protected instance inv (f : R ⟶ S) (φ : a ⟶ b) [IsIso f] [IsIso φ] [p.IsHomLift f φ] : |
| 236 | + p.IsHomLift (inv f) (inv φ) := |
| 237 | + have : p.IsHomLift (asIso f).hom (asIso φ).hom := by simp_all |
| 238 | + IsHomLift.inv_lift_inv p (asIso f) (asIso φ) |
| 239 | + |
| 240 | +end |
| 241 | + |
| 242 | +/-- If `φ : a ⟶ b` is an isomorphism, and lifts `𝟙 S` for some `S : 𝒮`, then `φ⁻¹` also |
| 243 | +lifts `𝟙 S` -/ |
| 244 | +instance lift_id_inv (S : 𝒮) {a b : 𝒳} (φ : a ⟶ b) [IsIso φ] [p.IsHomLift (𝟙 S) φ] : |
| 245 | + p.IsHomLift (𝟙 S) (inv φ) := |
| 246 | + (IsIso.inv_id (X := S)) ▸ (IsHomLift.inv p _ φ) |
| 247 | + |
| 248 | +end IsHomLift |
| 249 | + |
| 250 | +end CategoryTheory |
0 commit comments