diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index eba1e6f1..02941bc6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -14,22 +14,25 @@ jobs: name: Lint style runs-on: ubuntu-latest steps: + - name: Checkout project + uses: actions/checkout@v4 + - name: Check for long lines if: always() run: | - ! (find HoTTLean -name "*.lean" -type f -exec grep -E -H -n '^.{101,}$' {} \; | grep -v -E 'https?://') + ! (grep -E -H -n '^.{101,}$' HoTTLean.lean HoTTLeanTest.lean lakefile.lean $(find HoTTLean HoTTLeanTest -name '*.lean') | grep -v -E 'https?://') - name: Don't 'import Mathlib', use precise imports if: always() run: | - ! (find HoTTLean -name "*.lean" -type f -print0 | xargs -0 grep -E -n '^import Mathlib$') + ! grep -E -H -n '^import Mathlib$' HoTTLean.lean HoTTLeanTest.lean lakefile.lean $(find HoTTLean HoTTLeanTest -name '*.lean') build_project: runs-on: ubuntu-latest name: Build project steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index a38a4eb1..8dc19568 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -2,12 +2,29 @@ on: pull_request: jobs: + style_lint: + name: Lint style + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Check for long lines + if: always() + run: | + ! (grep -E -H -n '^.{101,}$' HoTTLean.lean HoTTLeanTest.lean lakefile.lean $(find HoTTLean HoTTLeanTest -name '*.lean') | grep -v -E 'https?://') + + - name: Don't 'import Mathlib', use precise imports + if: always() + run: | + ! grep -E -H -n '^import Mathlib$' HoTTLean.lean HoTTLeanTest.lean lakefile.lean $(find HoTTLean HoTTLeanTest -name '*.lean') + build_project: runs-on: ubuntu-latest name: Build project steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.gitignore b/.gitignore index 193bae23..2d5201a5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ blueprint/src/chapter/auto blueprint/lean_decls blueprint/print/ home_page/blueprint +home_page/_site/ *.pdf ## Docs docs/_includes/sorries.md diff --git a/HoTTLean/ForMathlib.lean b/HoTTLean/ForMathlib.lean index 0d1cd8c9..9482daad 100644 --- a/HoTTLean/ForMathlib.lean +++ b/HoTTLean/ForMathlib.lean @@ -1,10 +1,10 @@ import Mathlib.CategoryTheory.Limits.Shapes.Pullback.PullbackCone import Mathlib.CategoryTheory.Groupoid.Discrete -import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq +import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic import Mathlib.CategoryTheory.Category.ULift import Mathlib.Logic.Function.ULift import Mathlib.CategoryTheory.Category.Cat -import Mathlib.CategoryTheory.Category.Grpd +import Mathlib.CategoryTheory.Groupoid.Grpd.Basic import Mathlib.Data.Part import Mathlib.CategoryTheory.Monoidal.Cartesian.Basic import Mathlib.CategoryTheory.Core @@ -19,8 +19,10 @@ to be upstreamed. -/ This comment space is for notes about mathlib definitions/theorems that should be fixed, refactored, or redesigned. -- AsSmall.down and AsSmall.up should have their universe level order changed so that the third value comes first. -- currently I often write AsSmall.{_,_,w} because the first two can be inferred but not the max universe. +- AsSmall.down and AsSmall.up should have their universe level order changed + so that the third value comes first. +- currently I often write AsSmall.{_,_,w} because the first two can be inferred + but not the max universe. -/ @@ -35,8 +37,13 @@ theorem Limits.PullbackCone.IsLimit.comp_lift {C : Type*} [Category C] (σ : W' ⟶ W) (ht : Limits.IsLimit t) (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : σ ≫ ht.lift (PullbackCone.mk h k w) = ht.lift (PullbackCone.mk (σ ≫ h) (σ ≫ k) (by simp [w])) := by - refine ht.hom_ext fun j => ?_ - rcases j with _ | _ | _ <;> simp + apply PullbackCone.IsLimit.hom_ext ht + · change (σ ≫ PullbackCone.IsLimit.lift ht h k w) ≫ t.fst = + PullbackCone.IsLimit.lift ht (σ ≫ h) (σ ≫ k) _ ≫ t.fst + simp [Category.assoc] + · change (σ ≫ PullbackCone.IsLimit.lift ht h k w) ≫ t.snd = + PullbackCone.IsLimit.lift ht (σ ≫ h) (σ ≫ k) _ ≫ t.snd + simp [Category.assoc] end CategoryTheory @@ -101,29 +108,29 @@ namespace CategoryTheory.Cat /-- This is the proof of equality used in the eqToHom in `Cat.eqToHom_hom` -/ theorem eqToHom_hom_aux {C1 C2 : Cat.{v,u}} (x y: C1) (eq : C1 = C2) : - (x ⟶ y) = ((eqToHom eq).obj x ⟶ (eqToHom eq).obj y) := by + (x ⟶ y) = ((eqToHom eq).toFunctor.obj x ⟶ (eqToHom eq).toFunctor.obj y) := by cases eq simp[CategoryStruct.id] /-- This is the turns the hom part of eqToHom functors into a cast-/ theorem eqToHom_hom {C1 C2 : Cat.{v,u}} {x y: C1} (f : x ⟶ y) (eq : C1 = C2) : - (eqToHom eq).map f = (cast (Cat.eqToHom_hom_aux x y eq) f) := by + (eqToHom eq).toFunctor.map f = (cast (Cat.eqToHom_hom_aux x y eq) f) := by cases eq simp[CategoryStruct.id] /-- This turns the object part of eqToHom functors into casts -/ theorem eqToHom_obj {C1 C2 : Cat.{v,u}} (x : C1) (eq : C1 = C2) : - (eqToHom eq).obj x = cast (congrArg Bundled.α eq) x := by + (eqToHom eq).toFunctor.obj x = cast (congrArg Bundled.α eq) x := by cases eq simp[CategoryStruct.id] abbrev homOf {C D : Type u} [Category.{v} C] [Category.{v} D] (F : C ⥤ D) : - Cat.of C ⟶ Cat.of D := F + Cat.of C ⟶ Cat.of D := F.toCatHom @[simps] def ULift_lte_iso_self {C : Type (max u u₁)} [Category.{v} C] : Cat.of (ULift.{u} C) ≅ Cat.of C where - hom := ULift.downFunctor - inv := ULift.upFunctor + hom := ULift.downFunctor.toCatHom + inv := ULift.upFunctor.toCatHom @[simp] def ULift_succ_iso_self {C : Type (u + 1)} [Category.{v} C] : of (ULift.{u, u + 1} C) ≅ of C := ULift_lte_iso_self.{v,u,u+1} @@ -136,7 +143,7 @@ def ofULift (C : Type u) [Category.{v} C] : Cat.{v, max u w} := def uLiftFunctor : Cat.{v,u} ⥤ Cat.{v, max u w} where obj X := Cat.ofULift.{w} X - map F := Cat.homOf $ ULift.downFunctor ⋙ F ⋙ ULift.upFunctor + map F := Cat.homOf $ ULift.downFunctor ⋙ F.toFunctor ⋙ ULift.upFunctor end CategoryTheory.Cat @@ -171,7 +178,7 @@ variable {C : Type u₁} [Category.{v₁} C] variable {P X Y Z : C} {fst : P ⟶ X} {snd : P ⟶ Y} {f : X ⟶ Z} {g : Y ⟶ Z} theorem of_iso_isPullback (h : IsPullback fst snd f g) {Q} (i : Q ≅ P) : - IsPullback (i.hom ≫ fst) (i.hom ≫ snd) f g := by + IsPullback (i.hom ≫ fst) (i.hom ≫ snd) f g := by have : HasPullback f g := ⟨ h.cone , h.isLimit ⟩ refine IsPullback.of_iso_pullback (by simp [h.w]) (i ≪≫ h.isoPullback) (by simp) (by simp) @@ -210,26 +217,19 @@ namespace AsSmall AsSmall.up.map (AsSmall.down.map f) = f := rfl theorem comp_up_inj {C : Type u} [Category.{v} C] - {D : Type u₁} [Category.{v₁} D] + {D : Type u₁} [Category.{v₁} D] {F G : C ⥤ D} (h : F ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) = - G ⋙ AsSmall.up) - : F = G := by - convert_to F ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) - ⋙ AsSmall.down - = G ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) - ⋙ AsSmall.down - simp only [← Functor.assoc, h] + G ⋙ AsSmall.up) : + F = G := by + exact congrArg (fun K => K ⋙ AsSmall.down) h theorem comp_down_inj {C : Type u} [Category.{v} C] - {D : Type u₁} [Category.{v₁} D] + {D : Type u₁} [Category.{v₁} D] {F G : C ⥤ AsSmall.{w} D} - (h : F ⋙ AsSmall.down = G ⋙ AsSmall.down) - : F = G := by - convert_to F ⋙ AsSmall.down - ⋙ AsSmall.up - = G ⋙ AsSmall.down ⋙ AsSmall.up - simp only [← Functor.assoc, h] + (h : F ⋙ AsSmall.down = G ⋙ AsSmall.down) : + F = G := by + exact congrArg (fun K => K ⋙ AsSmall.up) h @[simp] theorem up_comp_down {C : Type u₁} [Category.{v₁, u₁} C] : @@ -250,6 +250,14 @@ namespace Groupoid instance asSmallGroupoid (Γ : Type u) [Groupoid.{v} Γ] : Groupoid (AsSmall.{w} Γ) where inv f := AsSmall.up.map (inv (AsSmall.down.map f)) + inv_comp f := by + apply ULift.ext + change inv f.down ≫ f.down = 𝟙 _ + simp + comp_inv f := by + apply ULift.ext + change f.down ≫ inv f.down = 𝟙 _ + simp end Groupoid @@ -330,9 +338,9 @@ def isLimitProdCone (X Y : D) : IsLimit (e.prodCone X Y) := BinaryFan.isLimitCompLeftIso _ (e.counit.app _) ( isLimitCartesianMonoidalCategoryOfPreservesLimits e.functor (e.inverse.obj X) (e.inverse.obj Y)))) - (BinaryFan.ext (eqToIso rfl) (by aesop_cat) (by aesop_cat)) + (BinaryFan.ext (eqToIso rfl) (by simp [prodCone]) (by simp [prodCone])) -def chosenFiniteProducts [CartesianMonoidalCategory C] : CartesianMonoidalCategory D := +abbrev chosenFiniteProducts : CartesianMonoidalCategory D := .ofChosenFiniteProducts { cone := asEmptyCone e.chosenTerminal isLimit := e.chosenTerminalIsTerminal } @@ -345,8 +353,8 @@ end Equivalence section equivalence -def functorToAsSmallEquiv {D : Type u₁} [Category.{v₁} D] {C : Type u} [Category.{v} C] - : D ⥤ AsSmall.{w} C ≃ D ⥤ C where +def functorToAsSmallEquiv {D : Type u₁} [Category.{v₁} D] {C : Type u} [Category.{v} C] : + D ⥤ AsSmall.{w} C ≃ D ⥤ C where toFun A := A ⋙ AsSmall.down invFun A := A ⋙ AsSmall.up left_inv _ := rfl @@ -376,7 +384,7 @@ lemma functorToAsSmallEquiv_symm_apply_comp_right (F : C ⥤ E) : end -open ULift +open CategoryTheory.ULift instance (C : Type u) [Category.{v} C] : (downFunctor : ULift.{w} C ⥤ C).ReflectsIsomorphisms := @@ -401,16 +409,16 @@ variable {Γ : Type u₂} [Category.{v₂} Γ] {A : Γ ⥤ Grpd.{v₁,u₁}} @[simp] theorem Cat.map_id_obj {A : Γ ⥤ Cat.{v₁,u₁}} {x : Γ} {a : A.obj x} : - (A.map (𝟙 x)).obj a = a := by + (A.map (𝟙 x)).toFunctor.obj a = a := by have : A.map (𝟙 x) = 𝟙 (A.obj x) := by simp - exact Functor.congr_obj this a + exact Functor.congr_obj (congrArg Cat.Hom.toFunctor this) a theorem Cat.map_id_map {A : Γ ⥤ Cat.{v₁,u₁}} {x : Γ} {a b : A.obj x} {f : a ⟶ b} : - (A.map (𝟙 x)).map f = eqToHom Cat.map_id_obj + (A.map (𝟙 x)).toFunctor.map f = eqToHom Cat.map_id_obj ≫ f ≫ eqToHom Cat.map_id_obj.symm := by have : A.map (𝟙 x) = 𝟙 (A.obj x) := by simp - exact Functor.congr_hom this f + exact Functor.congr_hom (congrArg Cat.Hom.toFunctor this) f end @@ -442,9 +450,9 @@ def psigmaCongrProp {α₁ α₂} {β₁ : α₁ → Prop} {β₂ : α₂ → Pr (F : ∀ a, β₁ a ≃ β₂ (f a)) (x : Sigma β₁) : (sigmaCongr f F x).fst = f x.fst := by simp [sigmaCongr] -@[simp] def sigmaCongr_apply_snd {α₁ α₂} {β₁ : α₁ → Sort _} {β₂ : α₂ → Sort _} (f : α₁ ≃ α₂) +@[simp] theorem sigmaCongr_apply_snd {α₁ α₂} {β₁ : α₁ → Sort _} {β₂ : α₂ → Sort _} (f : α₁ ≃ α₂) (F : ∀ a, β₁ a ≃ β₂ (f a)) (x : Sigma β₁) : (sigmaCongr f F x).snd = F x.fst x.snd := by - simp [sigmaCongr] + rfl end Equiv @@ -457,8 +465,8 @@ noncomputable def pullbackHomEquiv {A B C: 𝒞} {Γ : 𝒞} {f : A ⟶ C} {g : (fst : Γ ⟶ A) × (snd : Γ ⟶ B) ×' (fst ≫ f = snd ≫ g) where toFun h := ⟨h ≫ pullback.fst f g, h ≫ pullback.snd f g, by simp[pullback.condition]⟩ invFun x := pullback.lift x.1 x.2.1 x.2.2 - left_inv _ := pullback.hom_ext (by simp) (by simp) - right_inv := by rintro ⟨_,_,_⟩; congr!; simp; simp + left_inv _ := pullback.hom_ext (by simp [pullback.lift_fst]) (by simp [pullback.lift_snd]) + right_inv := by rintro ⟨_,_,_⟩; congr! <;> simp [pullback.lift_fst, pullback.lift_snd] end CategoryTheory.Limits @@ -524,12 +532,14 @@ lemma ofYoneda_isPullback {C : Type u} [Category.{v} C] {TL TR BL BR : C} apply IsPullback.of_isLimit (c := c) apply c.isLimitAux (fun s => lift (PullbackCone.fst s) (PullbackCone.snd s) (by simp [PullbackCone.condition s])) - · simp [c, top_lift] - · simp [c, lift_comp_left] + · intro s; change lift s.fst s.snd _ ≫ ofYoneda top top_comp = s.fst + simp only [ofYoneda_comp_left, top_lift] + · intro s; exact lift_comp_left _ _ _ · intro s m h apply lift_uniq · specialize h (some .left) - simpa [c] using h + change m ≫ ofYoneda top top_comp = s.fst at h + exact (ofYoneda_comp_left top top_comp m).symm.trans h · specialize h (some .right) exact h @@ -545,11 +555,11 @@ variable (F) in -/ def yonedaIso : yoneda.op ⋙ yoneda.obj F ≅ F := NatIso.ofComponents (fun _ => Equiv.toIso yonedaEquiv) - (fun f => by ext : 1; dsimp; rw [yonedaEquiv_naturality']) + (fun f => by ext α; exact (yonedaEquiv_naturality' _ _).symm) def yonedaIsoMap : yoneda.op ⋙ yoneda.obj F ⟶ yoneda.op ⋙ yoneda.obj G where - app _ := app - naturality _ _ _ := by ext : 1; apply naturality + app _ := ↾app + naturality _ _ f := by ext α; exact naturality f.unop α /-- Build natural transformations between presheaves on a small category by defining their action when precomposing by a morphism with @@ -564,7 +574,8 @@ theorem NatTrans.yonedaMk_app {X : C} (α : yoneda.obj X ⟶ F) : namespace Functor -theorem precomp_heq_of_heq_id {A B : Type u} {C : Type*} [Category.{v} A] [Category.{v} B] [Category C] +theorem precomp_heq_of_heq_id {A B : Type u} {C : Type*} + [Category.{v} A] [Category.{v} B] [Category C] (hAB : A = B) (h0 : HEq (inferInstance : Category A) (inferInstance : Category B)) {F : A ⥤ B} (h : HEq F (𝟭 B)) (G : B ⥤ C) : HEq (F ⋙ G) G := by subst hAB @@ -620,17 +631,10 @@ lemma Discrete.functor_eq {X C : Type*} [Category C] {F : Discrete X ⥤ C} : fapply CategoryTheory.Functor.ext · aesop · intro x y f - cases x ; rcases f with ⟨⟨h⟩⟩ - cases h - simp - -lemma Discrete.functor_ext {X C : Type*} [Category C] (F G : Discrete X ⥤ C) - (h : ∀ x : X, F.obj ⟨x⟩ = G.obj ⟨x⟩) : - F = G := - calc F - _ = Discrete.functor (fun x => F.obj ⟨x⟩) := Discrete.functor_eq - _ = Discrete.functor (fun x => G.obj ⟨x⟩) := Discrete.functor_ext' h - _ = G := Discrete.functor_eq.symm + cases x + cases y + cases f with + | mk h => cases h; simp lemma Discrete.hext {X Y : Type u} (a : Discrete X) (b : Discrete Y) (hXY : X ≍ Y) (hab : a.1 ≍ b.1) : a ≍ b := by @@ -640,7 +644,7 @@ lemma Discrete.Hom.hext {α β : Type u} {x y : Discrete α} (x' y' : Discrete (hx : x ≍ x') (hy : y ≍ y') (f : x ⟶ y) (f' : x' ⟶ y') : f ≍ f' := by aesop_cat -open Prod in +open CategoryTheory.Prod in lemma Prod.sectR_comp_snd {C : Type u₁} [Category.{v₁} C] (Z : C) (D : Type u₂) [Category.{v₂} D] : sectR Z D ⋙ snd C D = 𝟭 D := rfl diff --git a/HoTTLean/ForMathlib/CategoryTheory/Bicategory/Grothendieck.lean b/HoTTLean/ForMathlib/CategoryTheory/Bicategory/Grothendieck.lean index 3f256088..1edbf328 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Bicategory/Grothendieck.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Bicategory/Grothendieck.lean @@ -45,33 +45,53 @@ Angelo Vistoli -/ +set_option backward.isDefEq.respectTransparency false + +namespace CategoryTheory.Cat + +abbrev Hom.obj {C D : Cat} (F : C ⟶ D) := F.toFunctor.obj +abbrev Hom.map {C D : Cat} (F : C ⟶ D) := @F.toFunctor.map +abbrev Hom₂.app {C D : Cat} {F G : C ⟶ D} (α : F ⟶ G) := α.toNatTrans.app + +end CategoryTheory.Cat + namespace CategoryTheory.Pseudofunctor universe w v₁ v₂ v₃ u₁ u₂ u₃ open Category Opposite Discrete Bicategory StrongTrans +local instance {C D : Cat} : Coe (C ⟶ D) (C ⥤ D) := ⟨Cat.Hom.toFunctor⟩ + +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + section variable {B : Type u₁} [Bicategory B] variable (F : Pseudofunctor B Cat) {a b : B} @[simp] lemma _root_.CategoryTheory.LocallyDiscrete.Iso.hom_inv {C : Type u₁} [Category C] - (X Y : LocallyDiscrete C) (e : X ≅ Y) : e.hom.toLoc ≫ e.inv.toLoc = 𝟙 _ := - LocallyDiscrete.eq_of_hom ⟨⟨by simp⟩⟩ + (X Y : LocallyDiscrete C) (e : X ≅ Y) : e.hom.toLoc ≫ e.inv.toLoc = 𝟙 _ := by + apply Discrete.ext + simp -attribute [reassoc] StrongTrans.naturality_comp_inv_app end -lemma _root_.CategoryTheory.Functor.toPseudofunctor'_map₂ {C : Type u₁} [Category.{v₁} C] (F : C ⥤ Cat) +lemma _root_.CategoryTheory.Functor.toPseudofunctor'_map₂ {C : Type u₁} [Category.{v₁} C] + (F : C ⥤ Cat) {a b : LocallyDiscrete C} {f g : a ⟶ b} (η : f ⟶ g) : - F.toPseudoFunctor'.map₂ η = eqToHom (by simp [eq_of_hom η]) := by - simp [Functor.toPseudoFunctor', pseudofunctorOfIsLocallyDiscrete] + F.toPseudofunctor'.map₂ η = eqToHom (by rw [LocallyDiscrete.eq_of_hom η]) := by + have h := LocallyDiscrete.eq_of_hom η + subst g + cases f + simp [Functor.toPseudofunctor', pseudofunctorOfIsLocallyDiscrete] @[simps] -def _root_.CategoryTheory.NatTrans.toStrongTrans' {C : Type u₁} [Category.{v₁} C] (F G : C ⥤ Cat) (α : F ⟶ G) : - F.toPseudoFunctor' ⟶ G.toPseudoFunctor' where +def _root_.CategoryTheory.NatTrans.toStrongTrans' {C : Type u₁} [Category.{v₁} C] + (F G : C ⥤ Cat) (α : F ⟶ G) : + F.toPseudofunctor' ⟶ G.toPseudofunctor' where app x := α.app x.as naturality _ := eqToIso (α.naturality _) naturality_naturality η := by simp [Functor.toPseudofunctor'_map₂] @@ -80,7 +100,7 @@ def _root_.CategoryTheory.NatTrans.toStrongTrans' {C : Type u₁} [Category.{v /-- An `eqToHom` in the category `Cat` is a functor that acts on maps by casts. -/ theorem _root_.CategoryTheory.Cat.map_eqToHom {C1 C2 : Cat} {x y : C1} (f : x ⟶ y) (eq : C1 = C2) : - (eqToHom eq).map f = (cast (by subst eq; rfl) f) := by + (eqToHom eq).toFunctor.map f = (cast (by subst eq; rfl) f) := by cases eq simp [CategoryStruct.id] @@ -202,13 +222,17 @@ def map (α : F ⟶ G) : ∫ F ⥤ ∫ G where · dsimp · simp only [categoryStruct_comp_base, Quiver.Hom.comp_toLoc, StrongTrans.naturality_comp_inv_app_assoc, ← Functor.map_comp] - have := (α.naturality g.base.toLoc).inv.naturality_assoc - simp only [Cat.comp_map] at this + have := (α.naturality g.base.toLoc).inv.toNatTrans.naturality_assoc + simp only [Cat.Hom.comp_map] at this simp [this] @[simp] lemma map_id_map {x y : ∫ F} (f : x ⟶ y) : (map (𝟙 F)).map f = f := by - ext <;> simp + ext + · simp + · simp [map] + change 𝟙 _ ≫ f.fiber = f.fiber + exact Category.id_comp _ @[simp] theorem map_comp_forget (α : F ⟶ G) : map α ⋙ forget G = forget F := rfl @@ -231,7 +255,7 @@ def mapCompIso (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) ≅ map α ⋙ ma NatIso.ofComponents (fun _ ↦ eqToIso (by aesop_cat)) (fun f ↦ by dsimp simp only [comp_id, id_comp] - ext <;> simp) + ext <;> simp [map]) lemma map_comp_eq (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) = map α ⋙ map β := Functor.ext_of_iso (mapCompIso α β) (fun _ ↦ by simp [map]) (fun _ ↦ by simp [mapCompIso]) @@ -311,6 +335,10 @@ universe w u v u₁ v₁ u₂ v₂ namespace CategoryTheory +local instance {C D : Cat} : Coe (C ⟶ D) (C ⥤ D) := ⟨Cat.Hom.toFunctor⟩ +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + namespace Functor variable {C : Type u} [Category.{v} C] @@ -413,14 +441,14 @@ instance : Category (∫ F) where ext · simp [Hom.comp, Hom.id] · dsimp [Hom.comp, Hom.id] - rw [← NatIso.naturality_2 (eqToIso (F.map_id Y.base)) f.fiber] + rw [← NatIso.naturality_2 (eqToIso (congrArg Cat.Hom.toFunctor (F.map_id Y.base))) f.fiber] simp id_comp f := by ext <;> simp [Hom.comp, Hom.id] assoc f g h := by ext · simp [Hom.comp] · dsimp [Hom.comp, Hom.id] - rw [← NatIso.naturality_2 (eqToIso (F.map_comp _ _)) f.fiber] + rw [← NatIso.naturality_2 (eqToIso (congrArg Cat.Hom.toFunctor (F.map_comp _ _))) f.fiber] simp namespace Hom @@ -520,8 +548,8 @@ theorem Hom.hext' (h : F = F') {X Y : ∫ F} {X' Y' : ∫ F'} (hX : HEq X X') (h theorem FunctorTo.hext (G H : D ⥤ ∫ F) (hbase : G ⋙ forget _ = H ⋙ forget _) (hfiber_obj : ∀ x : D, HEq (G.obj x).fiber (H.obj x).fiber) - (hfiber_map : ∀ {x y : D} (f : x ⟶ y), HEq (G.map f).fiber (H.map f).fiber) - : G = H := by + (hfiber_map : ∀ {x y : D} (f : x ⟶ y), HEq (G.map f).fiber (H.map f).fiber) : + G = H := by fapply CategoryTheory.Functor.ext · intro x apply Grothendieck.hext @@ -533,8 +561,9 @@ theorem FunctorTo.hext (G H : D ⥤ ∫ F) exact Functor.congr_hom hbase f · simp only [Hom.comp_fiber, fiber_eqToHom, eqToHom_map, heq_eqToHom_comp_iff, heq_comp_eqToHom_iff] - rw! [base_eqToHom, eqToHom_map, hfiber_map f, Cat.map_eqToHom] - simp + rw! [base_eqToHom, eqToHom_map, hfiber_map f] + simp only [Cat.Hom.map, Cat.eqToHom_hom] + exact (cast_heq _ _).trans (cast_heq _ _).symm end ext section Transport @@ -547,11 +576,11 @@ def transport (x : ∫ F) {c : C} (t : x.base ⟶ c) : ∫ F := mk c ((F.map t).obj x.fiber) @[simp] -def transport_base (x : ∫ F) {c : C} (t : x.base ⟶ c) : (transport x t).base = c := +theorem transport_base (x : ∫ F) {c : C} (t : x.base ⟶ c) : (transport x t).base = c := rfl @[simp] -def transport_fiber (x : ∫ F) {c : C} (t : x.base ⟶ c) : +theorem transport_fiber (x : ∫ F) {c : C} (t : x.base ⟶ c) : (transport x t).fiber = (F.map t).obj x.fiber := rfl @@ -565,11 +594,11 @@ def toTransport (x : ∫ F) {c : C} (t : x.base ⟶ c) : x ⟶ x.transport t := Hom.mk t (𝟙 _) @[simp] -def toTransport_base (x : ∫ F) {c : C} (t : x.base ⟶ c) : (toTransport x t).base = t := +theorem toTransport_base (x : ∫ F) {c : C} (t : x.base ⟶ c) : (toTransport x t).base = t := rfl @[simp] -def toTransport_fiber (x : ∫ F) {c : C} (t : x.base ⟶ c) : +theorem toTransport_fiber (x : ∫ F) {c : C} (t : x.base ⟶ c) : (toTransport x t).fiber = 𝟙 _ := rfl @@ -592,7 +621,7 @@ lemma toTransport_eqToHom {X: C} {X' : ∫ F} (hX': (forget F).obj X' = X): simp [toTransport_id] lemma transport_comp (x : ∫ F) {c d: C} (t : x.base ⟶ c) (t': c ⟶ d): - transport x (t ≫ t') = transport (c:= d) (transport x t) t' := by + transport x (t ≫ t') = transport (c:= d) (transport x t) t' := by simp [transport] lemma toTransport_comp (x : ∫ F) {c d: C} (t : x.base ⟶ c) (t': c ⟶ d): @@ -618,12 +647,12 @@ def isoMk {X Y : ∫ F} (e₁ : X.base ≅ Y.base) X ≅ Y where hom := Hom.mk e₁.hom e₂.hom inv := Hom.mk e₁.inv ((F.map e₁.inv).map e₂.inv ≫ - eqToHom (Functor.congr_obj (F.mapIso e₁).hom_inv_id X.fiber)) + eqToHom (Functor.congr_obj (congrArg Cat.Hom.toFunctor (F.mapIso e₁).hom_inv_id) X.fiber)) hom_inv_id := by apply Hom.ext; all_goals simp inv_hom_id := by apply Hom.ext - · have := Functor.congr_hom (F.mapIso e₁).inv_hom_id e₂.inv - simp only [mapIso_inv, mapIso_hom, Cat.comp_map] at this + · have := Functor.congr_hom (congrArg Cat.Hom.toFunctor (F.mapIso e₁).inv_hom_id) e₂.inv + simp only [mapIso_inv, mapIso_hom, Cat.Hom.comp_map] at this simp [this] · simp @@ -668,8 +697,8 @@ lemma transportIso_hom_base (x : ∫ F) {c : C} (α : x.base ≅ c) : lemma transportIso_hom_fiber (x : ∫ F) {c : C} (α : x.base ≅ c) : (x.transportIso α).hom.fiber = eqToHom (by simp [transportIso, ← Functor.comp_obj, ← Cat.comp_eq_comp]) := by - simp only [transportIso, CategoryTheory.Iso.symm_hom, isoMk_inv_fiber, CategoryTheory.Iso.refl_inv] - erw [Functor.map_id] + simp only [transportIso, CategoryTheory.Iso.symm_hom, isoMk_inv_fiber, + CategoryTheory.Iso.refl_inv] simp @[simp] @@ -738,9 +767,9 @@ def map (α : F ⟶ G) : Grothendieck F ⥤ Grothendieck G := (by intro x; simp) (by intro x y z f g - have := Functor.congr_hom (α.naturality g.base).symm f.fiber + have := Functor.congr_hom (congrArg Cat.Hom.toFunctor (α.naturality g.base).symm) f.fiber simp at this - simp [this]) + simp [Grothendieck.forget, this, Category.assoc]) /-- The functor `Grothendieck.map α : ∫ F ⥤ ∫ G` lies over `C`. -/ @[simp] @@ -748,18 +777,19 @@ theorem map_comp_forget {α : F ⟶ G} : Grothendieck.map α ⋙ Grothendieck.forget G = Grothendieck.forget F := rfl -theorem map_id_eq : map (𝟙 F) = 𝟙 (Cat.of <| Grothendieck <| F) := by +theorem map_id_eq : map (𝟙 F) = 𝟭 (Grothendieck F) := by apply FunctorTo.hext - all_goals simp [Cat.id_eq_id, Functor.id_comp] + all_goals simp [Functor.id_comp] /-- Making the equality of functors into an isomorphism. Note: we should avoid equality of functors if possible, and we should prefer `mapIdIso` to `map_id_eq` whenever we can. -/ -def mapIdIso : map (𝟙 F) ≅ 𝟙 (Cat.of <| Grothendieck <| F) := eqToIso map_id_eq +def mapIdIso : map (𝟙 F) ≅ 𝟭 (Grothendieck F) := eqToIso map_id_eq theorem map_comp_eq (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) = map α ⋙ map β := by apply FunctorTo.hext - all_goals simp [Functor.assoc] + all_goals simp [Functor.assoc, map, functorTo, forget] + all_goals rfl /-- Making the equality of functors into an isomorphism. Note: we should avoid equality of functors if possible, and we should prefer `map_comp_iso` to `map_comp_eq` whenever we can. -/ @@ -770,8 +800,10 @@ end /-- The Grothendieck construction as a functor from the functor category `E ⥤ Cat` to the over category `Over E`. -/ def functor {E : Cat.{v, u}} : (E ⥤ Cat.{v,u}) ⥤ Over (T := Cat.{v,u}) E where - obj F := Over.mk (X := E) (Y := Cat.of (∫ F)) (Grothendieck.forget F) - map {_ _} α := Over.homMk (X:= E) (Grothendieck.map α) Grothendieck.map_comp_forget + obj F := Over.mk (X := E) (Y := Cat.of (∫ F)) (Grothendieck.forget F).toCatHom + map {_ _} α := Over.homMk (X:= E) (Grothendieck.map α).toCatHom (by + apply Cat.Hom.ext + exact Grothendieck.map_comp_forget) map_id F := by ext exact Grothendieck.map_id_eq (F := F) @@ -785,13 +817,13 @@ variable (G : C ⥤ Type w) /-- Auxiliary definition for `grothendieckTypeToCat`, to speed up elaboration. -/ @[simps!] def grothendieckTypeToCatFunctor : ∫(G ⋙ typeToCat) ⥤ G.Elements where - obj X := ⟨X.1, X.2.as⟩ - map f := ⟨f.1, f.2.1.1⟩ + obj X := ⟨X.2.as⟩ + map f := ⟨f.1, f.2.1⟩ /-- Auxiliary definition for `grothendieckTypeToCat`, to speed up elaboration. -/ def grothendieckTypeToCatInverse : G.Elements ⥤ ∫(G ⋙ typeToCat) where obj X := mk X.1 ⟨X.2⟩ - map f := Hom.mk f.1 ⟨⟨f.2⟩⟩ + map f := Hom.mk f.1 ⟨f.2⟩ @[simp] lemma grothendieckTypeToCatInverse_obj_base (X : G.Elements) : @@ -822,7 +854,7 @@ def grothendieckTypeToCat : ∫(G ⋙ typeToCat) ≌ G.Elements where rcases X with ⟨_, ⟨⟩⟩ exact CategoryTheory.Iso.refl _) (by - rintro ⟨_, ⟨⟩⟩ ⟨_, ⟨⟩⟩ ⟨base, ⟨⟨f⟩⟩⟩ + rintro ⟨_, ⟨⟩⟩ ⟨_, ⟨⟩⟩ ⟨base, ⟨f⟩⟩ dsimp at * simp rfl) @@ -839,7 +871,6 @@ def grothendieckTypeToCat : ∫(G ⋙ typeToCat) ≌ G.Elements where functor_unitIso_comp := by rintro ⟨_, ⟨⟩⟩ simp - rfl end Elements @@ -848,24 +879,28 @@ section Pseudofunctor variable (F) @[simps!] -def toPseudoFunctor'Iso.hom : ∫ F ⥤ F.toPseudoFunctor'.Grothendieck where +def toPseudoFunctor'Iso.hom : ∫ F ⥤ F.toPseudofunctor'.Grothendieck where obj x := ⟨ x.base, x.fiber ⟩ map f := ⟨ f.base, f.fiber ⟩ map_id x := by apply Pseudofunctor.Grothendieck.Hom.ext <;> simp - map_comp f g := by apply Pseudofunctor.Grothendieck.Hom.ext <;> simp + map_comp f g := by + apply Pseudofunctor.Grothendieck.Hom.ext <;> + simp [Functor.toPseudofunctor', pseudofunctorOfIsLocallyDiscrete, Quiver.Hom.toLoc] @[simps!] -def toPseudoFunctor'Iso.inv : F.toPseudoFunctor'.Grothendieck ⥤ ∫ F where +def toPseudoFunctor'Iso.inv : F.toPseudofunctor'.Grothendieck ⥤ ∫ F where obj x := ⟨ x.base, x.fiber ⟩ map f := ⟨ f.base, f.fiber ⟩ map_id x := by apply Hom.ext <;> simp - map_comp f g := by apply Hom.ext <;> simp + map_comp f g := by + apply Hom.ext <;> + simp [Functor.toPseudofunctor', pseudofunctorOfIsLocallyDiscrete, Quiver.Hom.toLoc] -def toPseudoFunctor'Iso : ∫ F ≅≅ F.toPseudoFunctor'.Grothendieck where +def toPseudoFunctor'Iso : ∫ F ≅≅ F.toPseudofunctor'.Grothendieck where hom := toPseudoFunctor'Iso.hom F inv := toPseudoFunctor'Iso.inv F -def toPseudoFunctor'Equivalence : ∫ F ≌ F.toPseudoFunctor'.Grothendieck := +def toPseudoFunctor'Equivalence : ∫ F ≌ F.toPseudofunctor'.Grothendieck := (toPseudoFunctor'Iso F).toEquivalence lemma toPseudoFunctor'Iso.hom_comp_forget : toPseudoFunctor'Iso.hom F ⋙ @@ -917,14 +952,9 @@ def preNatIso : pre F G ≅ map (whiskerRight α.hom F) ⋙ (pre F H) := (fun X => (transportIso (mk (G.obj X.base) X.fiber) (α.app X.base)).symm) (fun {X Y} f => by fapply Hom.ext - · simp - · simp only [comp_obj, Iso.app_hom, comp_map, Hom.comp_base, - Hom.comp_fiber, pre_map_fiber, - eqToHom_trans_assoc, map_map_fiber, whiskerRight_app] - erw [Category.comp_id, Functor.map_id, - Functor.congr_hom (F.congr_map (transportIso_inv_base (mk (G.obj Y.base) Y.fiber) - (α.app Y.base)))] - simp) + · dsimp [pre, functorTo] + exact α.hom.naturality f.base + · simp [pre, functorTo, map]) @[simp] theorem preNatIso_hom_app_base (x) : ((preNatIso F α).hom.app x).base = α.hom.app x.base := by @@ -932,7 +962,7 @@ def preNatIso : pre F G ≅ map (whiskerRight α.hom F) ⋙ (pre F H) := @[simp] theorem preNatIso_hom_app_fiber (x) : ((preNatIso F α).hom.app x).fiber = 𝟙 _ := by - simp [preNatIso] + simp [preNatIso, pre, functorTo] theorem preNatIso_congr {G H : D ⥤ C} {α β : G ≅ H} (h : α = β) : preNatIso F α = preNatIso F β ≪≫ eqToIso (by subst h; simp) := by @@ -941,21 +971,22 @@ theorem preNatIso_congr {G H : D ⥤ C} {α β : G ≅ H} (h : α = β) : @[simp] theorem preNatIso_eqToIso {G H : D ⥤ C} {h : G = H} : preNatIso F (eqToIso h) = - eqToIso (by subst h; simp [map_id_eq, Cat.id_eq_id, Functor.id_comp]) := by + eqToIso (by subst h; simp [map_id_eq, Functor.id_comp]) := by subst h ext fapply Hom.ext - · simp + · simp [pre, functorTo, forget] · simp only [eqToIso_refl, comp_obj, eqToIso.hom, preNatIso_hom_app_fiber, Category.comp_id] rw! [eqToHom_app, fiber_eqToHom] + rfl theorem preNatIso_comp {G1 G2 G3 : D ⥤ C} (α : G1 ≅ G2) (β : G2 ≅ G3) : preNatIso F (α ≪≫ β) = preNatIso F α ≪≫ isoWhiskerLeft _ (preNatIso F β) ≪≫ eqToIso (by simp [map_comp_eq, Functor.assoc]) := by ext fapply Hom.ext - · simp + · simp [map, functorTo, forget] · simp only [CategoryTheory.Iso.trans_hom, eqToIso.hom, NatTrans.comp_app] rw! [eqToHom_app] simp @@ -1014,7 +1045,7 @@ def preEquivalence (G : D ≌ C) : ∫ (G.functor ⋙ F) ≌ ∫ F where functor_unitIso_comp X := by simp only [preInv, Grothendieck.preUnitIso, pre_id, CategoryTheory.Iso.trans_hom, eqToIso.hom, eqToHom_app, eqToHom_refl, isoWhiskerLeft_hom, NatTrans.comp_app] - fapply Hom.ext <;> simp [preNatIso, transportIso] + fapply Hom.ext <;> simp [preNatIso, transportIso, pre, functorTo, map, forget] variable {F} in /-- @@ -1044,7 +1075,7 @@ construction. -/ @[simps!] def ι : F.obj c ⥤ ∫ F := functorTo ((const (F.obj c)).obj c) id (fun f => eqToHom (by simp) ≫ f) (by simp) - (by simp [Functor.congr_hom (F.map_id _)]) + (by simp [Functor.congr_hom (congrArg Cat.Hom.toFunctor (F.map_id _))]) instance faithful_ι (c : C) : (ι F c).Faithful where map_injective f := by @@ -1054,8 +1085,8 @@ instance faithful_ι (c : C) : (ι F c).Faithful where theorem ι_comp_forget : ι F c ⋙ forget _ = (const (F.obj c)).obj c := rfl -@[simp] theorem ι_comp_pre (G : D ⥤ C) (x : D) - : ι (G ⋙ F) x ⋙ pre F G = ι F (G.obj x) := by +@[simp] theorem ι_comp_pre (G : D ⥤ C) (x : D) : + ι (G ⋙ F) x ⋙ pre F G = ι F (G.obj x) := by apply Grothendieck.FunctorTo.hext · rw [ι_comp_forget, Functor.assoc, pre_comp_forget, ← Functor.assoc, ι_comp_forget] apply Functor.ext <;> simp @@ -1073,18 +1104,20 @@ inclusion `ι F X` to the composition `F.map f ⋙ ι F Y`. -/ @[simps!] def ιNatTrans : ι F X ⟶ F.map f ⋙ ι F Y where app _ := Hom.mk f (𝟙 _) - naturality _ _ _ := Hom.ext _ _ (by simp) (by simp [eqToHom_map]) + naturality _ _ _ := Hom.ext _ _ (by simp [ι, functorTo]) + (by simp [eqToHom_map, ι, functorTo]) @[simp] theorem ιNatTrans_id_app {X : C} {a : F.obj X} : (@ιNatTrans _ _ F _ _ (𝟙 X)).app a = eqToHom (by simp) := - Hom.ext _ _ (by simp) (by simp) + Hom.ext _ _ (by simp [ι, functorTo]) (by simp [ι, functorTo]; exact Category.comp_id _) lemma ιNatTrans_comp_app {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {a} : (@ιNatTrans _ _ F _ _ (f ≫ g)).app a = (@ιNatTrans _ _ F _ _ f).app a ≫ (@ιNatTrans _ _ F _ _ g).app ((F.map f).obj a) ≫ eqToHom (by simp) := - Hom.ext _ _ (by simp) (by simp) + Hom.ext _ _ (by simp [ι, functorTo, ιNatTrans]) + (by simp [ι, functorTo, ιNatTrans]) end ιNatTrans @@ -1100,7 +1133,8 @@ section variable (fib : ∀ c, F.obj c ⥤ E) (hom : ∀ {c c' : C} (f : c ⟶ c'), fib c ⟶ F.map f ⋙ fib c') variable (hom_id : ∀ c, hom (𝟙 c) = eqToHom (by simp only [Functor.map_id]; rfl)) variable (hom_comp : ∀ c₁ c₂ c₃ (f : c₁ ⟶ c₂) (g : c₂ ⟶ c₃), hom (f ≫ g) = - hom f ≫ whiskerLeft (F.map f) (hom g) ≫ eqToHom (by simp only [Functor.map_comp]; rfl)) + (hom f ≫ whiskerLeft (F.map f).toFunctor (hom g)) ≫ + eqToHom (by simp [Functor.map_comp, Functor.assoc])) /-- Construct a functor from `∫ F` to another category `E` by providing a family of functors on the fibers of `∫ F`, a family of natural transformations on morphisms in the @@ -1115,12 +1149,12 @@ def functorFrom : ∫ F ⥤ E where theorem map_eqToHom_base_pf {G1 G2 : Grothendieck F} (eq : G1 = G2) : F.obj G1.base = F.obj G2.base := by subst eq; rfl -theorem map_eqToHom_base {G1 G2 : Grothendieck F} (eq : G1 = G2) - : F.map (eqToHom eq).base = eqToHom (map_eqToHom_base_pf eq) := by +theorem map_eqToHom_base {G1 G2 : Grothendieck F} (eq : G1 = G2) : + F.map (eqToHom eq).base = eqToHom (map_eqToHom_base_pf eq) := by simp [eqToHom_map] theorem map_eqToHom_obj_base {F G : C ⥤ Cat.{v,u}} (h : F = G) - (x) : ((Grothendieck.map (eqToHom h)).obj x).base = x.base := rfl + (x) : ((Grothendieck.map (eqToHom h)).obj x).base = x.base := rfl theorem map_forget {F G : C ⥤ Cat.{v,u}} (α : F ⟶ G) : Grothendieck.map α ⋙ Grothendieck.forget G = @@ -1146,8 +1180,8 @@ lemma asFunctorFromHom_id (c : C) : asFunctorFromHom K (𝟙 c) = lemma asFunctorFromHom_comp (c₁ c₂ c₃ : C) (f : c₁ ⟶ c₂) (g: c₂ ⟶ c₃) : asFunctorFromHom K (f ≫ g) = - asFunctorFromHom K f ≫ Functor.whiskerLeft (F.map f) (asFunctorFromHom K g) ≫ eqToHom - (by simp[← Functor.assoc]; congr) := by + (asFunctorFromHom K f ≫ Functor.whiskerLeft (F.map f).toFunctor + (asFunctorFromHom K g)) ≫ eqToHom (by simp [Functor.assoc]) := by ext p simp [asFunctorFromHom, eqToHom_map, ιNatTrans_comp_app] @@ -1157,13 +1191,17 @@ theorem asFunctorFrom : Grothendieck.functorFrom (asFunctorFromFib K) (asFunctor · intro X rfl · intro x y f - simp only [functorFrom_obj, asFunctorFromFib, Functor.comp_obj, functorFrom_map, + simp only [asFunctorFromFib, Functor.comp_obj, functorFrom_map, asFunctorFromHom, Functor.whiskerRight_app, Functor.comp_map, ← Functor.map_comp, eqToHom_refl, Category.comp_id, Category.id_comp] congr fapply Hom.ext - · simp - · simp + · simp [ι, functorTo] + · dsimp [ι, functorTo, ιNatTrans] + simp only [Functor.map_id, + Category.id_comp] + rw! [eqToHom_trans_assoc, eqToHom_trans_assoc] + simp section @@ -1177,16 +1215,16 @@ def functorFromCompHom {c c' : C} (f : c ⟶ c') : include hom_id in lemma functorFromCompHom_id (c : C) : functorFromCompHom fib hom G (𝟙 c) - = eqToHom (by simp [Cat.id_eq_id, Functor.id_comp]) := by + = eqToHom (by simp [Functor.id_comp]) := by ext x simp [hom_id, functorFromCompHom] include hom_comp in lemma functorFromCompHom_comp (c₁ c₂ c₃ : C) (f : c₁ ⟶ c₂) (g : c₂ ⟶ c₃): functorFromCompHom fib hom G (f ≫ g) - = functorFromCompHom fib hom G f ≫ - Functor.whiskerLeft (F.map f) (functorFromCompHom fib hom G g) ≫ - eqToHom (by simp[Cat.comp_eq_comp, Functor.map_comp, Functor.assoc]) := by + = (functorFromCompHom fib hom G f ≫ + Functor.whiskerLeft (F.map f).toFunctor (functorFromCompHom fib hom G g)) ≫ + eqToHom (by simp [Functor.map_comp, Functor.assoc]) := by ext simp [functorFromCompHom, hom_comp] @@ -1206,7 +1244,8 @@ section variable (fib' : ∀ c, F.obj c ⥤ E) (hom' : ∀ {c c' : C} (f : c ⟶ c'), fib' c ⟶ F.map f ⋙ fib' c') variable (hom_id' : ∀ c, hom' (𝟙 c) = eqToHom (by simp only [Functor.map_id]; rfl)) variable (hom_comp' : ∀ c₁ c₂ c₃ (f : c₁ ⟶ c₂) (g : c₂ ⟶ c₃), hom' (f ≫ g) = - hom' f ≫ Functor.whiskerLeft (F.map f) (hom' g) ≫ eqToHom (by simp only [Functor.map_comp]; rfl)) + (hom' f ≫ Functor.whiskerLeft (F.map f).toFunctor (hom' g)) ≫ + eqToHom (by simp [Functor.map_comp, Functor.assoc])) theorem functorFrom_eq_of (ef : fib = fib') (hhom : ∀ {c c' : C} (f : c ⟶ c'), hom f ≫ eqToHom (by rw[ef]) = eqToHom (by rw[ef]) ≫ hom' f) : @@ -1236,8 +1275,8 @@ theorem functorFrom_ext {K K' : Grothendieck F ⥤ E} theorem functorFrom_hext {K K' : Grothendieck F ⥤ E} (hfib : ∀ c, ι F c ⋙ K = ι F c ⋙ K') (hhom : ∀ {c c' : C} (f : c ⟶ c'), Functor.whiskerRight (ιNatTrans f) K ≍ - Functor.whiskerRight (ιNatTrans f) K') - : K = K' := by + Functor.whiskerRight (ιNatTrans f) K') : + K = K' := by fapply functorFrom_ext · assumption · intros @@ -1250,7 +1289,7 @@ end /-- `Grothendieck.ι F c` composed with `Grothendieck.functorFrom` is isomorphic a functor on a fiber on `F` supplied as the first argument to `Grothendieck.functorFrom`. -/ def ιCompFunctorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) ≅ fib c := - NatIso.ofComponents (fun _ => CategoryTheory.Iso.refl _) (fun f => by simp [hom_id]) + NatIso.ofComponents (fun _ => CategoryTheory.Iso.refl _) (fun f => by simp [hom_id, ι, functorTo]) @[simp] lemma ι_comp_functorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) = fib c := @@ -1260,7 +1299,7 @@ lemma whiskerRight_ιNatTrans_functorFrom {x y} (f : x ⟶ y) : Functor.whiskerRight (ιNatTrans f) (functorFrom fib hom hom_id hom_comp) = eqToHom (ι_comp_functorFrom ..) ≫ hom f ≫ eqToHom (by rw [Functor.assoc, ι_comp_functorFrom]) := by - ext; simp + ext; simp [ι, ιNatTrans, functorTo] section variable (A : E ⥤ C) (fibObj : (x : E) → (A ⋙ F).obj x) @@ -1292,14 +1331,14 @@ def functorIsoFrom (fib_comp : ∀ c, fib c ⋙ A = ι F c ⋙ forget F) · simp only [Functor.assoc, functorTo_forget, Functor.id_comp, fib_comp] · apply fibObj_fib_obj · intro x y f - simp only [comp_obj, functorTo_obj_base, comp_map, functorTo_map_base, functorTo_obj_fiber, - functorTo_map_fiber, id_obj, ι_obj_base, id_map, ι_map_base, ι_obj_fiber, ι_map_fiber] + simp only [comp_obj, comp_map, + functorTo_map_fiber, id_obj, id_map, ι_map_fiber] rw! [eqToHom_comp_heq, heq_cast_iff_heq] apply fibMap_fib_map · intro c c' f apply NatTrans.ext ext x - simp only [comp_obj, functorFrom_obj, ι_obj_base, ι_obj_fiber, id_obj, comp_whiskerRight, + simp only [comp_obj, id_obj, comp_whiskerRight, whiskerRight_ιNatTrans_functorFrom, whiskerRight_comp, eqToHom_whiskerRight, Category.assoc, eqToHom_trans, NatTrans.comp_app, eqToHom_app, eqToHom_refl, whiskerRight_app, Category.id_comp, id_whiskerRight, ← heq_eq_eq, heq_eqToHom_comp_iff, comp_eqToHom_heq_iff] @@ -1309,9 +1348,9 @@ def functorIsoFrom (fib_comp : ∀ c, fib c ⋙ A = ι F c ⋙ forget F) inv_hom_id := by fapply Functor.ext · intro x - simp [fib_obj_fibObj] + simp [functorTo, functorFrom, fib_obj_fibObj] · intro x y f - simp [← heq_eq_eq, hom_map_app_fibObj] + simp [functorTo, functorFrom, ← heq_eq_eq, hom_map_app_fibObj] end end @@ -1323,7 +1362,7 @@ end FunctorFrom def ιCompMap {F' : C ⥤ Cat} (α : F ⟶ F') (c : C) : ι F c ⋙ map α ≅ α.app c ⋙ ι F' c := NatIso.ofComponents (fun X => CategoryTheory.Iso.refl _) (fun f => by simp only [CategoryTheory.Iso.refl_hom, Category.comp_id] - apply Hom.ext <;> simp) + apply Hom.ext <;> simp [ι, functorTo, map]) lemma ι_comp_map {F' : C ⥤ Cat} (α : F ⟶ F') (c : C) : ι F c ⋙ map α = α.app c ⋙ ι F' c := Functor.ext_of_iso (ιCompMap ..) (by intro; rfl) @@ -1336,7 +1375,7 @@ attribute [-simp] AsSmall.down_obj AsSmall.down_map @[simp] def compAsSmallFunctorEquivalenceInverse : ∫ F ⥤ ∫(F ⋙ Cat.asSmallFunctor.{w}) := functorTo (forget _) (fun X => (AsSmall.up.obj X.fiber)) (fun f => (AsSmall.up.map f.fiber)) - (by simp) (by intros; simp) + (by simp) (by intros; simp [Cat.asSmallFunctor, forget]) /-- The functor to build the equivalence `compAsSmallFunctorEquivalence`. -/ @[simp] def compAsSmallFunctorEquivalenceFunctor : @@ -1345,7 +1384,7 @@ attribute [-simp] AsSmall.down_obj AsSmall.down_map (by intros; simp; apply eqToHom_map) -- FIXME: eqToHom_map does not fire under simp (by intros - simp [Functor.map_comp]) + simp [Functor.map_comp, Cat.asSmallFunctor, forget]) -- FIXME: these AsSmall goals are awful. Need to add some evil lemmas for AsSmall.up, AsSmall.down /-- Taking the Grothendieck construction on `F ⋙ asSmallFunctor`, where @@ -1371,23 +1410,16 @@ namespace AsSmall AsSmall.up.map (AsSmall.down.map f) = f := rfl theorem comp_up_inj {C : Type u} [Category.{v} C] - {D : Type u₁} [Category.{v₁} D] {F G : C ⥤ D} + {D : Type u₁} [Category.{v₁} D] {F G : C ⥤ D} (h : F ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) = G ⋙ AsSmall.up) : F = G := by - convert_to F ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) - ⋙ AsSmall.down - = G ⋙ (AsSmall.up : D ⥤ AsSmall.{w} D) - ⋙ AsSmall.down - rw [← Functor.assoc, h, Functor.assoc] + exact congrArg (fun K => K ⋙ AsSmall.down) h theorem comp_down_inj {C : Type u} [Category.{v} C] - {D : Type u₁} [Category.{v₁} D] + {D : Type u₁} [Category.{v₁} D] {F G : C ⥤ AsSmall.{w} D} - (h : F ⋙ AsSmall.down = G ⋙ AsSmall.down) - : F = G := by - convert_to F ⋙ AsSmall.down - ⋙ AsSmall.up - = G ⋙ AsSmall.down ⋙ AsSmall.up - rw [← Functor.assoc, h, Functor.assoc] + (h : F ⋙ AsSmall.down = G ⋙ AsSmall.down) : + F = G := by + exact congrArg (fun K => K ⋙ AsSmall.up) h @[simp] theorem up_comp_down {C : Type u₁} [Category.{v₁, u₁} C] : @@ -1414,11 +1446,13 @@ def mapWhiskerRightAsSmallFunctor (α : F ⟶ G) : NatIso.ofComponents (fun X => CategoryTheory.Iso.refl _) (fun f => by - simp only [compAsSmallFunctorEquivalence_functor, compAsSmallFunctorEquivalenceFunctor, - comp_obj, forget_obj, comp_map, forget_map, compAsSmallFunctorEquivalence_inverse, - compAsSmallFunctorEquivalenceInverse, CategoryTheory.Iso.refl_hom, Category.comp_id, + simp only [ + comp_obj, comp_map, + CategoryTheory.Iso.refl_hom, Category.comp_id, Category.id_comp] - apply Hom.ext <;> simp + apply Hom.ext <;> simp [compAsSmallFunctorEquivalence, + compAsSmallFunctorEquivalenceFunctor, compAsSmallFunctorEquivalenceInverse, + Cat.asSmallFunctor, functorTo, map, forget] ) end AsSmall @@ -1441,9 +1475,10 @@ def invFiber : y.fiber ⟶ (F.map f.base).obj x.fiber := lemma fiber_comp_invFiber : f.fiber ≫ invFiber f = 𝟙 ((F.map f.base).obj x.fiber) := by have h := Functor.Grothendieck.Hom.comp_fiber f (CategoryTheory.inv f) rw! [IsIso.hom_inv_id] at h - have h0 : F.map (CategoryTheory.inv f).base ⋙ F.map f.base = 𝟭 _ := by - simp [← Cat.comp_eq_comp, ← Functor.map_comp, ← Grothendieck.Hom.comp_base, Cat.id_eq_id] - have h1 := Functor.congr_map (F.map f.base) h + have h0 : (F.map (CategoryTheory.inv f).base).toFunctor ⋙ + (F.map f.base).toFunctor = 𝟭 _ := by + simp [← Cat.comp_eq_comp, ← Functor.map_comp, ← Grothendieck.Hom.comp_base] + have h1 := Functor.congr_map (F.map f.base).toFunctor h simp [← heq_eq_eq, eqToHom_map, ← Functor.comp_map, Functor.congr_hom h0] at h1 dsimp [invFiber] rw! [← h1] diff --git a/HoTTLean/ForMathlib/CategoryTheory/Core.lean b/HoTTLean/ForMathlib/CategoryTheory/Core.lean index bd136ad0..fce58bce 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Core.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Core.lean @@ -22,15 +22,13 @@ variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] subst h rfl -def comp_inclusion_injective {l0 l1 : D ⥤ Core C} (hl : l0 ⋙ inclusion C = l1 ⋙ inclusion C) : l0 = l1 := by - fapply Functor.ext - · intro x - ext - exact Functor.congr_obj hl x - · intro x y f - ext - convert Functor.congr_hom hl f - simp +theorem comp_inclusion_injective {l0 l1 : D ⥤ Core C} + (hl : l0 ⋙ inclusion C = l1 ⋙ inclusion C) : l0 = l1 := by + exact Functor.ext (fun x => Core.obj_ext (Functor.congr_obj hl x)) + (by + intro x y f + apply Core.hom_ext + simpa [Core.inclusion] using Functor.congr_hom hl f) lemma core_comp_inclusion (F : C ⥤ D) : F.core ⋙ inclusion D = inclusion C ⋙ F := @@ -38,7 +36,7 @@ lemma core_comp_inclusion (F : C ⥤ D) : def map : Cat.{v,u} ⥤ Grpd.{v,u} where obj C := Grpd.of (Core C) - map F := Grpd.homOf (F.core) + map F := Grpd.homOf (F.toFunctor.core) variable {Γ : Type u} [Groupoid.{v} Γ] @@ -50,9 +48,8 @@ def functorToCoreEquiv : Γ ⥤ D ≃ Γ ⥤ Core D where invFun := forgetFunctorToCore.obj left_inv _ := rfl right_inv _ := by - fapply Functor.ext - · aesop_cat - · aesop_cat + apply comp_inclusion_injective + rfl variable {C : Type u₁} [Category.{v₁} C] variable {G : Type u₂} [Groupoid.{v₂} G] @@ -61,18 +58,7 @@ variable {C' : Type u₃} [Category.{v₃} C'] @[simp] theorem functorToCore_comp_inclusion (H : G ⥤ C) : - functorToCore H ⋙ inclusion _ = H := rfl - -theorem functorToCore_comp_left (H : G ⥤ C) (F : G' ⥤ G) : - functorToCore (F ⋙ H) = F ⋙ functorToCore H := by - apply Functor.ext - · simp [functorToCore] - · intro - rfl - -theorem functorToCore_comp_right (H : G ⥤ C) (F : C ⥤ C') : - functorToCore (H ⋙ F) = functorToCore H ⋙ F.core := by - rfl + functorToCore H ⋙ inclusion _ = H := rfl theorem functorToCoreEquiv_symm_apply_comp_left (H : G ⥤ Core C) (F : G' ⥤ G) : functorToCoreEquiv.symm (F ⋙ H) = F ⋙ functorToCoreEquiv.symm H := @@ -83,7 +69,7 @@ theorem functorToCoreEquiv_symm_apply_comp_right (H : G ⥤ Core C) (F : C ⥤ C rfl theorem eqToIso_iso_hom {a b : Core C} (h1 : a = b) - (h2 : (inclusion C).obj a = (inclusion C).obj b) : + (h2 : (inclusion C).obj a = (inclusion C).obj b) : (eqToHom h1).iso.hom = eqToHom h2 := by cases h1 rfl @@ -94,23 +80,13 @@ def adjunction : Grpd.forgetToCat ⊣ Core.map where unit := { app G := Grpd.homOf (Core.functorToCore (Functor.id _)) naturality _ _ F := by - simp [Core.map, Grpd.comp_eq_comp, - ← functorToCore_comp_left, - ← functorToCore_comp_right, - Functor.id_comp, Functor.comp_id, Grpd.forgetToCat]} + change F ⋙ Core.functorToCore (Functor.id _) = + Core.functorToCore (Functor.id _) ⋙ F.core + apply comp_inclusion_injective + rfl} counit := {app C := Cat.homOf (Core.inclusion C)} /-- Mildly evil. -/ -theorem inclusion_comp_functorToCore : inclusion G ⋙ functorToCore (𝟭 G) = Functor.id (Core G) := by - apply Functor.ext - · intro x y f - simp only [Core.inclusion, Core.functorToCore, Functor.id_map, - Functor.comp_map, Groupoid.inv_eq_inv, IsIso.Iso.inv_hom, - eqToHom_refl, Category.comp_id, Category.id_comp] - rfl - · intro - rfl - theorem functorToCore_inclusion_apply {C : Type u} [Category.{v} C] : Core.functorToCore (Core.inclusion C) = Functor.id (Core C) := rfl @@ -129,7 +105,7 @@ instance {G : Type u} [Groupoid.{v} G] : end Adjunction -open Functor +open _root_.CategoryTheory.Functor instance : IsLeftAdjoint Grpd.forgetToCat := IsLeftAdjoint.mk ⟨ Core.map , ⟨ adjunction ⟩ ⟩ @@ -152,28 +128,24 @@ def lift : E ⥤ Core C where let f' : F.obj (En.obj x) ≅ F.obj (En.obj y) := (eqToIso hE).app x ≪≫ (Ew.map f).iso ≪≫ (eqToIso hE.symm).app y have hnat : F.map (En.map f) ≫ _ - = _ ≫ (inclusion D).map (Ew.map f) - := (eqToHom hE).naturality f - have h : F.map (En.map f) = f'.hom := by + = _ ≫ (inclusion D).map (Ew.map f) := + (eqToHom hE).naturality f + have h : F.map (En.map f) = f'.hom := + set_option backward.isDefEq.respectTransparency false in by simp only [eqToHom_app, comp_eqToHom_iff] at hnat - simp [hnat, f', Core.inclusion] + simpa [f', Core.inclusion, eqToIso.hom, eqToHom_app] using hnat have : IsIso (F.map (En.map f)) := by rw [h]; exact Iso.isIso_hom f' exact Functor.ReflectsIsomorphisms.reflects F (En.map f) ⟩ -def fac_left : lift F En Ew hE ⋙ inclusion C = En := rfl +theorem fac_left : lift F En Ew hE ⋙ inclusion C = En := rfl -def fac_right : lift F En Ew hE ⋙ F.core = Ew := by - fapply Functor.ext - · intro x - ext - exact Functor.congr_obj hE x - · intro x y f - ext - convert Functor.congr_hom hE f - simp +theorem fac_right : lift F En Ew hE ⋙ F.core = Ew := by + apply comp_inclusion_injective + exact hE def universal : (lift : E ⥤ Core C) ×' lift ⋙ inclusion C = En ∧ lift ⋙ F.core = Ew ∧ - ∀ {l0 l1 : E ⥤ Core C}, l0 ⋙ inclusion C = l1 ⋙ inclusion C → l0 ⋙ F.core = l1 ⋙ F.core → l0 = l1 := + ∀ {l0 l1 : E ⥤ Core C}, l0 ⋙ inclusion C = l1 ⋙ inclusion C → + l0 ⋙ F.core = l1 ⋙ F.core → l0 = l1 := ⟨ lift F En Ew hE, fac_left _ _ _ _, fac_right _ _ _ _, fun hl _ => comp_inclusion_injective hl ⟩ @@ -182,7 +154,7 @@ end IsPullback variable {C : Type u} [Category.{v} C] {D : Type u} [Category.{v} D] (F : C ⥤ D) [F.ReflectsIsomorphisms] -open IsPullback +open _root_.CategoryTheory.Core.IsPullback /-- In the category of categories, diff --git a/HoTTLean/ForMathlib/CategoryTheory/FreeGroupoid.lean b/HoTTLean/ForMathlib/CategoryTheory/FreeGroupoid.lean index e853e0c4..90c77b35 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/FreeGroupoid.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/FreeGroupoid.lean @@ -3,229 +3,118 @@ Copyright (c) 2025 Joseph Hua. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Hua -/ -import Mathlib.CategoryTheory.Groupoid.FreeGroupoid -import Mathlib.CategoryTheory.Category.Grpd -import Mathlib.CategoryTheory.Adjunction.Reflective -import Mathlib.CategoryTheory.Localization.Predicate +import Mathlib.CategoryTheory.Groupoid.FreeGroupoidOfCategory import Mathlib.CategoryTheory.Monad.Limits import Mathlib.CategoryTheory.Category.Cat.Limit -import HoTTLean.ForMathlib.CategoryTheory.Localization.Predicate - /-! # Free groupoid on a category -This file defines the free groupoid on a category, the lifting of a functor to its unique -extension as a functor from the free groupoid, and proves uniqueness of this extension. - -## Main results - -Given a type `C` and a category instance on `C`: - -- `CategoryTheory.Category.FreeGroupoid C`: the underlying type of the free groupoid on `C`. -- `CategoryTheory.Category.FreeGroupoid.instGroupoid`: the `Groupoid` instance on `FreeGroupoid C`. -- `CategoryTheory.Category.FreeGroupoid.lift`: the lifting of a functor `C ⥤ G` where `G` is a - groupoid, to a functor `CategoryTheory.Category.FreeGroupoid C ⥤ G`. -- `CategoryTheory.Category.FreeGroupoid.lift_spec` and - `CategoryTheory.Category.FreeGroupoid.lift_unique`: - the proofs that, respectively, `CategoryTheory.Category.FreeGroupoid.lift` indeed is a lifting - and is the unique one. -- `CategoryTheory.Category.Grpd.free`: the free functor from `Grpd` to `Cat` -- `CategoryTheory.Category.Grpd.freeForgetAdjunction`: that `free` is left adjoint to - `Grpd.forgetToCat`. - -## Implementation notes - -The free groupoid on a category `C` is first defined by taking the free groupoid `G` -on the underlying *quiver* of `C`. Then the free groupoid on the *category* `C` is defined as -the quotient of `G` by the relation that makes the inclusion prefunctor `C ⥤q G` a functor. - -## TODO - -Place the original definition `CategoryTheory.FreeGroupoid` into the namespace -`Quiver.FreeGroupoid`. - +Mathlib provides the free groupoid construction and its universal property. +This module keeps the names previously exported by HoTTLean as compatibility +aliases. The implementation now lives in `CategoryTheory.FreeGroupoid` and +`CategoryTheory.Grpd`. -/ noncomputable section -namespace CategoryTheory +namespace CategoryTheory.Category universe v u v₁ u₁ v₂ u₂ -namespace Category - variable (C : Type u) [Category.{v} C] -open Quiver in -/-- The relation on the free groupoid on the underlying *quiver* of C that -promotes the prefunctor `C ⥤q FreeGroupoid C` into a functor -`C ⥤ Quotient (FreeGroupoid.homRel C)`. -/ -inductive FreeGroupoid.homRel : HomRel (Quiver.FreeGroupoid C) where -| map_id (X : C) : homRel ((FreeGroupoid.of C).map (𝟙 X)) (𝟙 ((FreeGroupoid.of C).obj X)) -| map_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : homRel ((FreeGroupoid.of C).map (f ≫ g)) - ((FreeGroupoid.of C).map f ≫ (FreeGroupoid.of C).map g) - -/-- The underlying type of the free groupoid on a category, -defined by quotienting the free groupoid on the underlying quiver of `C` -by the relation that promotes the prefunctor `C ⥤q FreeGroupoid C` into a functor -`C ⥤ Quotient (FreeGroupoid.homRel C)`. -/ -protected def FreeGroupoid := Quotient (FreeGroupoid.homRel C) - -variable {C} in -instance [Nonempty C] : Nonempty (Category.FreeGroupoid C) := by - have : Inhabited (Quiver.FreeGroupoid C) := by - inhabit Quiver.FreeGroupoid C - exact ⟨@default (Quiver.FreeGroupoid C) _⟩ - have : Inhabited (Category.FreeGroupoid C) := inferInstanceAs (Inhabited <| Quotient _) - inhabit Category.FreeGroupoid C - exact ⟨@default (Category.FreeGroupoid C) _⟩ - -variable {C} in -instance : Groupoid (Category.FreeGroupoid C) := - Quotient.groupoid (Category.FreeGroupoid.homRel C) +/-- Compatibility alias for the relation defining the free groupoid. -/ +abbrev FreeGroupoid.homRel := _root_.CategoryTheory.FreeGroupoid.homRel C -namespace FreeGroupoid +namespace FreeGroupoid.homRel -@[simp] -lemma of.map_id (X : C) : (Quotient.functor (FreeGroupoid.homRel C)).map - ((Quiver.FreeGroupoid.of C).map (𝟙 X)) = 𝟙 _:= by - simp [Quotient.sound _ (Category.FreeGroupoid.homRel.map_id X)] +/-- Compatibility alias for the identity relation constructor. -/ +abbrev map_id (X : C) := _root_.CategoryTheory.FreeGroupoid.homRel.map_id X -@[simp] -lemma of.map_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : - (Quotient.functor (FreeGroupoid.homRel C)).map ((Quiver.FreeGroupoid.of C).map (f ≫ g)) = - (Quotient.functor (FreeGroupoid.homRel C)).map ((Quiver.FreeGroupoid.of C).map f) ≫ - (Quotient.functor (FreeGroupoid.homRel C)).map ((Quiver.FreeGroupoid.of C).map g) := by - simp [Quotient.sound _ (Category.FreeGroupoid.homRel.map_comp f g)] +/-- Compatibility alias for the composition relation constructor. -/ +abbrev map_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) := + _root_.CategoryTheory.FreeGroupoid.homRel.map_comp f g -/-- The localization map from the category `C` to the groupoid `Category.FreeGroupoid C` -/ -def of : C ⥤ Category.FreeGroupoid C where - __ := Quiver.FreeGroupoid.of C ⋙q (Quotient.functor (FreeGroupoid.homRel C)).toPrefunctor - map_id X := by simp - map_comp {X Y Z} f g := by simp +end FreeGroupoid.homRel -section UniversalProperty +/-- Compatibility alias for the free groupoid on a category. -/ +abbrev FreeGroupoid := _root_.CategoryTheory.FreeGroupoid C -variable {C} {G : Type u₁} [Groupoid.{v₁} G] +namespace FreeGroupoid -/-- The lift of a functor from `C` to a groupoid to a functor from -`FreeGroupoid C` to the groupoid -/ -def lift (φ : C ⥤ G) : Category.FreeGroupoid C ⥤ G := - Quotient.lift (FreeGroupoid.homRel C) (Quiver.FreeGroupoid.lift φ.toPrefunctor) (by - intros X Y f g r - rcases r with X | ⟨ f , g ⟩ - · simpa using Prefunctor.congr_hom (Quiver.FreeGroupoid.lift_spec φ.toPrefunctor) (𝟙 X) - · have hf := Prefunctor.congr_hom (Quiver.FreeGroupoid.lift_spec φ.toPrefunctor) f - have hg := Prefunctor.congr_hom (Quiver.FreeGroupoid.lift_spec φ.toPrefunctor) g - have hfg := Prefunctor.congr_hom (Quiver.FreeGroupoid.lift_spec φ.toPrefunctor) (f ≫ g) - simp only [Functor.toPrefunctor_obj, Prefunctor.comp_obj, Prefunctor.comp_map, - Functor.toPrefunctor_map, Quiver.homOfEq_rfl, Functor.map_comp] at * - rw [hf, hg, hfg]) - -theorem lift_spec (φ : C ⥤ G) : of C ⋙ lift φ = φ := by - have : Quiver.FreeGroupoid.of C ⋙q (Quotient.functor (FreeGroupoid.homRel C)).toPrefunctor ⋙q - (lift φ).toPrefunctor = φ.toPrefunctor := by - simp [lift, Quotient.lift_spec, Quiver.FreeGroupoid.lift_spec] - fapply Functor.ext - · apply Prefunctor.congr_obj this - · intro _ _ - simpa using Prefunctor.congr_hom this - -theorem lift_unique (φ : C ⥤ G) (Φ : Category.FreeGroupoid C ⥤ G) (hΦ : of C ⋙ Φ = φ) : - Φ = lift φ := by - apply Quotient.lift_unique - apply Quiver.FreeGroupoid.lift_unique - exact congr_arg Functor.toPrefunctor hΦ +variable {C} {G : Type u₁} [Groupoid.{v₁} G] +/-- The localization functor from `C` to its free groupoid. -/ +abbrev of (C : Type u) [Category.{v} C] := + _root_.CategoryTheory.FreeGroupoid.of C + +/-- Compatibility alias for the free groupoid's identity relation. -/ +@[simp] theorem of.map_id (X : C) : + (Quotient.functor (FreeGroupoid.homRel C)).map + ((Quiver.FreeGroupoid.of C).map (𝟙 X)) = 𝟙 _ := by + exact Functor.map_id (_root_.CategoryTheory.FreeGroupoid.of C) X + +/-- Compatibility alias for the free groupoid's composition relation. -/ +@[simp] theorem of.map_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : + (Quotient.functor (FreeGroupoid.homRel C)).map + ((Quiver.FreeGroupoid.of C).map (f ≫ g)) = + (Quotient.functor (FreeGroupoid.homRel C)).map + ((Quiver.FreeGroupoid.of C).map f) ≫ + (Quotient.functor (FreeGroupoid.homRel C)).map + ((Quiver.FreeGroupoid.of C).map g) := by + exact Functor.map_comp (_root_.CategoryTheory.FreeGroupoid.of C) f g + +/-- Extend a functor from `C` to a groupoid. -/ +abbrev lift (φ : C ⥤ G) := _root_.CategoryTheory.FreeGroupoid.lift φ + +/-- The localization property of the free groupoid. -/ +abbrev strictUniversalPropertyFixedTarget {G : Type u₁} + [Groupoid.{v₁} G] := + _root_.CategoryTheory.FreeGroupoid.strictUniversalPropertyFixedTarget + (C := C) (G := G) + +/-- The free groupoid lift restricts to the original functor. -/ +theorem lift_spec (φ : C ⥤ G) : of C ⋙ lift φ = φ := + _root_.CategoryTheory.FreeGroupoid.lift_spec φ + +/-- The free groupoid lift is unique. -/ +theorem lift_unique (φ : C ⥤ G) (Φ : FreeGroupoid C ⥤ G) + (hΦ : of C ⋙ Φ = φ) : Φ = lift φ := + _root_.CategoryTheory.FreeGroupoid.lift_unique φ Φ hΦ + +/-- Lifting commutes with postcomposition. -/ theorem lift_comp {H : Type u₂} [Groupoid.{v₂} H] (φ : C ⥤ G) (ψ : G ⥤ H) : - lift (φ ⋙ ψ) = lift φ ⋙ ψ := by - symm - apply lift_unique - rw [← Functor.assoc, lift_spec] - -/-- The universal property of the free groupoid. -/ -def strictUniversalPropertyFixedTarget : - Localization.StrictUniversalPropertyFixedTarget (of C) ⊤ G where - inverts _ := inferInstance - lift F _ := lift F - fac _ _ := lift_spec .. - uniq F G h := by rw [lift_unique (of C ⋙ G) F h, ← lift_unique (of C ⋙ G) G rfl] - -attribute [local instance] Localization.groupoid - -instance : (of C).IsLocalization ⊤ := - .mk' _ _ strictUniversalPropertyFixedTarget strictUniversalPropertyFixedTarget + lift (φ ⋙ ψ) = lift φ ⋙ ψ := + _root_.CategoryTheory.FreeGroupoid.lift_comp φ ψ -end UniversalProperty +end FreeGroupoid -section Functoriality +namespace FreeGroupoid variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] {E : Type u₂} [Category.{v₂} E] -/-- The functor of free groupoid induced by a prefunctor of quivers -/ -def map (φ : C ⥤ D) : Category.FreeGroupoid C ⥤ Category.FreeGroupoid D := - lift (φ ⋙ of D) - -theorem map_id : map (𝟭 C) = 𝟭 (Category.FreeGroupoid C) := by - dsimp only [map]; symm - apply lift_unique; rfl +/-- The induced functor between free groupoids. -/ +abbrev map (φ : C ⥤ D) : FreeGroupoid C ⥤ FreeGroupoid D := + _root_.CategoryTheory.FreeGroupoid.map φ -theorem map_comp (φ : C ⥤ D) (φ' : D ⥤ E) : map (φ ⋙ φ') = map φ ⋙ map φ' := by - dsimp only [map]; symm - apply lift_unique; rfl +theorem map_id : map (𝟭 C) = 𝟭 (FreeGroupoid C) := by + apply _root_.CategoryTheory.FreeGroupoid.map_id -end Functoriality +theorem map_comp (φ : C ⥤ D) (φ' : D ⥤ E) : + map (φ ⋙ φ') = map φ ⋙ map φ' := + _root_.CategoryTheory.FreeGroupoid.map_comp φ φ' end FreeGroupoid -end Category - -namespace Grpd - -open Category.FreeGroupoid - -/-- The free groupoid construction on a category as a functor. -/ -@[simps] -def free : Cat.{u,u} ⥤ Grpd.{u,u} where - obj C := Grpd.of <| Category.FreeGroupoid C - map {C D} F := map F - map_id C := by simp [Grpd.id_eq_id, ← map_id]; rfl - map_comp F G := by simp [Grpd.comp_eq_comp, ← map_comp]; rfl - -/-- The unit of the free-forgetful adjunction between `Grpd` and `Cat`. -/ -@[simps] -def freeForgetAdjunction.unit : 𝟭 Cat ⟶ free ⋙ forgetToCat where - app C := Category.FreeGroupoid.of C - naturality C D F := by simp [forgetToCat, Cat.comp_eq_comp, map, lift_spec] - -/-- The counit of the free-forgetful adjunction between `Grpd` and `Cat`. -/ -@[simps] -def freeForgetAdjunction.counit : forgetToCat ⋙ free ⟶ 𝟭 Grpd where - app G := lift (𝟭 G) - naturality G H φ := by - simp [map, Grpd.comp_eq_comp, ← lift_comp, forgetToCat, Functor.id_comp, Functor.assoc, - lift_spec, Functor.comp_id] - -/-- The free-forgetful adjunction between `Grpd` and `Cat`. -/ -def freeForgetAdjunction : free ⊣ Grpd.forgetToCat where - unit := freeForgetAdjunction.unit - counit := freeForgetAdjunction.counit - left_triangle_components C := by - simp only [free_obj, free_map, map, coe_of, comp_eq_comp, ← lift_comp] - symm - apply lift_unique - simp [Functor.assoc, lift_spec, Grpd.id_eq_id] - right_triangle_components G := by - simp [forgetToCat, Cat.comp_eq_comp, lift_spec, Cat.id_eq_id] - -instance : Reflective Grpd.forgetToCat where - L := free - adj := freeForgetAdjunction +end CategoryTheory.Category + +namespace CategoryTheory.Grpd + +universe u instance : Limits.HasLimits Grpd.{u,u} := hasLimits_of_reflective forgetToCat -end Grpd -end CategoryTheory +end CategoryTheory.Grpd end diff --git a/HoTTLean/ForMathlib/CategoryTheory/Functor/IsPullback.lean b/HoTTLean/ForMathlib/CategoryTheory/Functor/IsPullback.lean index 0dc8f53e..efebb67c 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Functor/IsPullback.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Functor/IsPullback.lean @@ -61,16 +61,19 @@ end ChosenObjects whose two components are sent to equal maps in the base category `Sudan`. -/ def morphismProperty : MorphismProperty (ChosenObjects east south) := - fun {x y} f => east.map f.1 - = eqToHom x.property ≫ south.map f.2 ≫ eqToHom y.property.symm + fun {x y} f => east.map f.hom.1 + = eqToHom x.property ≫ south.map f.hom.2 ≫ eqToHom y.property.symm instance : MorphismProperty.IsMultiplicative (morphismProperty east south) where id_mem x := by - simp [morphismProperty, ChosenObjects, ObjectProperty.FullSubcategory.id_def] + rcases x with ⟨⟨a, b⟩, h⟩ + change east.map (𝟙 a) = eqToHom h ≫ south.map (𝟙 b) ≫ eqToHom h.symm + simp comp_mem f g hf hg := by - simp only [morphismProperty, ChosenObjects, - ObjectProperty.FullSubcategory.comp_def] at * - simp [hg, hf] + change east.map (f.hom.1 ≫ g.hom.1) = + eqToHom _ ≫ south.map (f.hom.2 ≫ g.hom.2) ≫ eqToHom _ + rw [Functor.map_comp, hf, Functor.map_comp, hg] + simp [Category.assoc] /-- The chosen pullback category `Chosen` is a wide subcategory @@ -114,6 +117,8 @@ theorem comm_sq : @north _ _ _ _ _ _ east south ⋙ east = west ⋙ south := by · intro x exact x.obj.property · intro x y f + change east.map f.hom.hom.1 = + eqToHom _ ≫ south.map f.hom.hom.2 ≫ eqToHom _ exact f.property end @@ -130,25 +135,30 @@ The universal lift of the chosen pullback `Chosen`. -/ def lift : C ⥤ Chosen east south where obj x := ⟨ ⟨ Cn.obj x , Cw.obj x ⟩ , congr_obj hC x ⟩ - map f := ⟨ ⟨ Cn.map f , Cw.map f ⟩ , congr_hom hC f ⟩ + map f := { + hom := ⟨(Cn.map f, Cw.map f)⟩ + property := by + change east.map (Cn.map f) = + eqToHom _ ≫ south.map (Cw.map f) ≫ eqToHom _ + exact congr_hom hC f + } /-- The universal lift of the chosen pullback `Chosen` commutes with projections. -/ -theorem fac_left : lift Cn Cw hC ⋙ north = Cn := - rfl +theorem fac_left : lift Cn Cw hC ⋙ north = Cn := by rfl /-- The universal lift of the chosen pullback `Chosen` commutes with projections. -/ -theorem fac_right : lift Cn Cw hC ⋙ west = Cw := - rfl +theorem fac_right : lift Cn Cw hC ⋙ west = Cw := by rfl /-- Lifts of the chosen pullback `Chosen` are unique. -/ theorem hom_ext {l0 l1 : C ⥤ Chosen east south} (hnorth : l0 ⋙ north = l1 ⋙ north) - (hwest : l0 ⋙ west = l1 ⋙ west) : l0 = l1 := by + (hwest : l0 ⋙ west = l1 ⋙ west) : l0 = l1 := + set_option backward.isDefEq.respectTransparency false in by fapply Functor.ext · intro x apply WideSubcategory.ext @@ -159,20 +169,22 @@ theorem hom_ext {l0 l1 : C ⥤ Chosen east south} (hnorth : l0 ⋙ north = l1 · intro x y f apply (wideSubcategory.faithful _).map_injective apply (ObjectProperty.faithful_ι _).map_injective - apply prod.hom_ext - · convert congr_hom hnorth f - simp only [Functor.map_comp, eqToHom_map] - simp [north] - · convert congr_hom hwest f - simp only [Functor.map_comp, eqToHom_map] - simp [west] + apply _root_.CategoryTheory.Prod.hom_ext + · change north.map (l0.map f) = + north.map (eqToHom _ ≫ l1.map f ≫ eqToHom _) + simpa only [Functor.map_comp, eqToHom_map, Functor.comp_map] using + congr_hom hnorth f + · change west.map (l0.map f) = + west.map (eqToHom _ ≫ l1.map f ≫ eqToHom _) + simpa only [Functor.map_comp, eqToHom_map, Functor.comp_map] using + congr_hom hwest f end Chosen end IsPullback -open IsPullback +open _root_.CategoryTheory.Functor.IsPullback /-- A pullback structure on a type `Libya` over a pair of functors @@ -387,7 +399,7 @@ variable {Libya Egypt Chad Sudan : Type*} [Category Libya] variable {north} in lemma Iso.inv_comp_eq_comp_inv {north'} (lib : Iso Chad Libya) (egy : Iso Sudan Egypt) -(hnorth : north' ⋙ egy.hom = lib.hom ⋙ north): lib.inv ⋙ north' = north ⋙ egy.inv + (hnorth : north' ⋙ egy.hom = lib.hom ⋙ north): lib.inv ⋙ north' = north ⋙ egy.inv ↔ north' ⋙ egy.hom = lib.hom ⋙ north := by rw [lib.inv_comp_eq, ← Functor.assoc, egy.eq_comp_inv, hnorth] @@ -420,16 +432,15 @@ def ofIso'Lift {C : Type*} [Category C] (Cn : C ⥤ Egypt') (Cw : C ⥤ Chad') ⋙ lib.inv def ofIso'Universal {C : Type*} [Category C] - (Cn : C ⥤ Egypt') (Cw : C ⥤ Chad') (hC : Cn ⋙ east' = Cw ⋙ south') - : (lift : C ⥤ Libya') ×' lift ⋙ north' = Cn ∧ lift ⋙ west' = Cw ∧ + (Cn : C ⥤ Egypt') (Cw : C ⥤ Chad') (hC : Cn ⋙ east' = Cw ⋙ south') : + (lift : C ⥤ Libya') ×' lift ⋙ north' = Cn ∧ lift ⋙ west' = Cw ∧ ∀ {l0 l1 : C ⥤ Libya'}, l0 ⋙ north' = l1 ⋙ north' → l0 ⋙ west' = l1 ⋙ west' → l0 = l1 := ⟨ ofIso'Lift north west east south pb east' south' lib egy cha sud heast hsouth Cn Cw hC, by rw [ofIso'Lift, Functor.assoc, (Iso.inv_comp_eq_comp_inv lib egy hnorth).mpr hnorth, ← Functor.assoc, pb.fac_left, Functor.assoc, egy.hom_inv_id, Functor.comp_id], by rw [ofIso'Lift, Functor.assoc, (Iso.inv_comp_eq_comp_inv lib cha hwest.symm).mpr hwest.symm, - ← Functor.assoc, pb.fac_right, Functor.assoc, cha.hom_inv_id, Functor.comp_id], - by + ← Functor.assoc, pb.fac_right, Functor.assoc, cha.hom_inv_id, Functor.comp_id], by intro l0 l1 hn hw have : l0 ⋙ lib.hom = l1 ⋙ lib.hom := by apply pb.hom_ext @@ -593,8 +604,7 @@ def universal : (lift : C ⥤ Algeria) ×' l0 ⋙ west = l1 ⋙ west → l0 = l1 := ⟨ lift wsah_pb esah_pb Cn Cw hC, by rw [lift, ← Functor.assoc, wsah_pb.fac_left, esah_pb.fac_left], - wsah_pb.fac_right _ _ _, - by + wsah_pb.fac_right _ _ _, by intro l0 l1 hnorth hwest apply wsah_pb.hom_ext · apply esah_pb.hom_ext @@ -647,8 +657,9 @@ namespace ofRight variable {C : Type u} [Category.{v} C] (Cn : C ⥤ Libya) (Cw : C ⥤ Niger) (hC : Cn ⋙ sah = Cw ⋙ so) -def hCLeft : (Cn ⋙ rth) ⋙ east = Cw ⋙ so ⋙ uth := - by calc +include esah hC in +theorem hCLeft : (Cn ⋙ rth) ⋙ east = Cw ⋙ so ⋙ uth := by + calc (Cn ⋙ rth) ⋙ east = Cn ⋙ (sah ⋙ uth) := by rw [Functor.assoc, esah] _ = (Cn ⋙ sah) ⋙ uth := by rw[← Functor.assoc] _ = (Cw ⋙ so) ⋙ uth := by rw [hC] @@ -705,7 +716,7 @@ end no_rth section north /- north - ⌐-------------------------¬ + +-------------------------¬ | rth V Algeria Libya ----> Egypt | | | @@ -731,7 +742,7 @@ variable {C : Type u} [Category.{v} C] (Cn : C ⥤ Libya) (Cw : C ⥤ Niger) (hC : Cn ⋙ sah = Cw ⋙ so) def universal : (lift : C ⥤ Algeria) ×' - lift ⋙ esah_pb.lift north (west ⋙ so) outer = Cn ∧ + lift ⋙ esah_pb.lift north (west ⋙ so) outer = Cn ∧ lift ⋙ west = Cw ∧ ∀ {l0 l1 : C ⥤ Algeria}, l0 ⋙ esah_pb.lift north (west ⋙ so) outer = l1 ⋙ esah_pb.lift north (west ⋙ so) outer → @@ -740,23 +751,30 @@ def universal : (lift : C ⥤ Algeria) ×' by constructor . apply esah_pb.hom_ext . calc - (outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ esah_pb.lift north (west ⋙ so) outer) ⋙ rth = - outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ esah_pb.lift north (west ⋙ so) outer ⋙ rth := by rw[Functor.assoc] - _ = outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ north := by rw[esah_pb.fac_left north (west ⋙ so) outer] + (outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ + esah_pb.lift north (west ⋙ so) outer) ⋙ rth = + outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ + esah_pb.lift north (west ⋙ so) outer ⋙ rth := by rw[Functor.assoc] + _ = outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ north := by + rw[esah_pb.fac_left north (west ⋙ so) outer] _ = Cn ⋙ rth := by rw[outer_pb.fac_left (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC)] . calc - (outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ esah_pb.lift north (west ⋙ so) outer) ⋙ sah = - outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ esah_pb.lift north (west ⋙ so) outer ⋙ sah := by rw[Functor.assoc] - _ = outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ (west ⋙ so) := by rw[esah_pb.fac_right north (west ⋙ so) outer] - _ = Cw ⋙ so := by rw[← Functor.assoc, outer_pb.fac_right (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC)] + (outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ + esah_pb.lift north (west ⋙ so) outer) ⋙ sah = + outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ + esah_pb.lift north (west ⋙ so) outer ⋙ sah := by rw[Functor.assoc] + _ = outer_pb.lift (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC) ⋙ (west ⋙ so) := by + rw[esah_pb.fac_right north (west ⋙ so) outer] + _ = Cw ⋙ so := by + rw[← Functor.assoc, outer_pb.fac_right (Cn ⋙ rth) Cw (ofRight.hCLeft esah Cn Cw hC)] _ = Cn ⋙ sah := by rw[hC] . constructor . exact outer_pb.fac_right (Cn⋙rth) Cw (ofRight.hCLeft esah Cn Cw hC) . intro l0 l1 hll hlw apply outer_pb.hom_ext . calc - l0 ⋙ north = l0 ⋙ (esah_pb.lift north (west ⋙ so) outer ⋙ rth) := - by rw [esah_pb.fac_left north (west ⋙ so) outer ] + l0 ⋙ north = l0 ⋙ (esah_pb.lift north (west ⋙ so) outer ⋙ rth) := by + rw [esah_pb.fac_left north (west ⋙ so) outer ] _ = (l0 ⋙ esah_pb.lift north (west ⋙ so) outer) ⋙ rth := by rw [Functor.assoc] _ = (l1 ⋙ esah_pb.lift north (west ⋙ so) outer) ⋙ rth := by rw [hll] _ = l1 ⋙ north := by rw [Functor.assoc, esah_pb.fac_left north (west ⋙ so) outer] @@ -772,7 +790,7 @@ and the top map `north : Algberia ⥤ Egypt`. The left square is a pullback when the right and outer squares are both pullbacks. north - ⌐-------------------------¬ + +-------------------------¬ | rth V Algeria Libya ----> Egypt | | | @@ -783,16 +801,15 @@ are both pullbacks. so uth -/ def ofRight' {north : Algeria ⥤ Egypt} {rth : Libya ⥤ Egypt} - {west : Algeria ⥤ Niger} {sah : Libya ⥤ Chad} {east : Egypt ⥤ Sudan} + {west : Algeria ⥤ Niger} {sah : Libya ⥤ Chad} {east : Egypt ⥤ Sudan} {so : Niger ⥤ Chad} {uth : Chad ⥤ Sudan} (outer : north ⋙ east = west ⋙ so ⋙ uth) (outer_pb : IsPullback north west east (so ⋙ uth)) (esah : rth ⋙ east = sah ⋙ uth) (esah_pb : IsPullback rth sah east uth) (no : Algeria ⥤ Libya := esah_pb.lift north (west ⋙ so) outer) - (no_eq : no = esah_pb.lift north (west ⋙ so) outer) - : - IsPullback no west sah so := + (no_eq : no = esah_pb.lift north (west ⋙ so) outer) : + IsPullback no west sah so := no_eq ▸ IsPullback.ofUniversal (esah_pb.lift north (west ⋙ so) outer) west sah so (esah_pb.fac_right _ _ _) @@ -829,8 +846,7 @@ def ofHorizIso.universal {C : Type*} [Category C] (Cn : C ⥤ Egypt) (Cw : C ⥤ _ = (Cw ⋙ south.hom) ⋙ south.inv := by rw [← hC, Functor.assoc, ofHorizIso.inv_comm_sq _ _ _ _ comm_sq, lift, Functor.assoc] _ = Cw := by - simp [Functor.assoc, Functor.comp_id], - by + simp [Functor.assoc, Functor.comp_id], by intro _ _ h0 _ simpa [Functor.Iso.cancel_iso_hom_right] using h0 ⟩ @@ -848,7 +864,7 @@ end CategoryTheory namespace CategoryTheory.Cat -open Functor Limits +open _root_.CategoryTheory.Functor Limits section variable {Libya Egypt Chad Sudan : Type u} [Category.{v} Libya] @@ -859,25 +875,42 @@ variable {Libya Egypt Chad Sudan : Type u} [Category.{v} Libya] (h : Functor.IsPullback north west east south) (s : Limits.PullbackCone (homOf east) (homOf south)) -def lift : s.pt ⟶ of Libya := h.lift s.fst s.snd s.condition +def lift : s.pt ⟶ of Libya := + _root_.CategoryTheory.Functor.IsPullback.lift h s.fst.toFunctor + s.snd.toFunctor (by simpa using congrArg Cat.Hom.toFunctor s.condition) |>.toCatHom -def fac_left : lift h s ≫ (homOf north) = s.fst := - h.fac_left _ _ _ +theorem fac_left : lift h s ≫ (homOf north) = s.fst := by + apply Cat.ext + exact _root_.CategoryTheory.Functor.IsPullback.fac_left h _ _ _ -def fac_right : lift h s ≫ (homOf west) = s.snd := - h.fac_right _ _ _ +theorem fac_right : lift h s ≫ (homOf west) = s.snd := by + apply Cat.ext + exact _root_.CategoryTheory.Functor.IsPullback.fac_right h _ _ _ -def uniq (m : s.pt ⟶ of Libya) (hl : m ≫ homOf north = s.fst) +theorem uniq (m : s.pt ⟶ of Libya) (hl : m ≫ homOf north = s.fst) (hr : m ≫ homOf west = s.snd) : m = lift h s := by - apply h.hom_ext - · convert (fac_left h s).symm - · convert (fac_right h s).symm + apply Cat.ext + apply _root_.CategoryTheory.Functor.IsPullback.hom_ext h + · calc + m.toFunctor ⋙ north = s.fst.toFunctor := by + exact congrArg Cat.Hom.toFunctor hl + _ = (lift h s).toFunctor ⋙ north := by + exact congrArg Cat.Hom.toFunctor (fac_left h s).symm + · calc + m.toFunctor ⋙ west = s.snd.toFunctor := by + exact congrArg Cat.Hom.toFunctor hr + _ = (lift h s).toFunctor ⋙ west := by + exact congrArg Cat.Hom.toFunctor (fac_right h s).symm variable (comm_sq) in -def isPullback : IsPullback (homOf north) (homOf west) (homOf east) - (homOf south) := - IsPullback.of_isLimit (PullbackCone.IsLimit.mk - comm_sq (lift h) (fac_left _) (fac_right _) (uniq _)) +include comm_sq h in +theorem isPullback : IsPullback (homOf north) (homOf west) (homOf east) + (homOf south) := by + have hc : homOf north ≫ homOf east = homOf west ≫ homOf south := by + apply Cat.ext + exact comm_sq + exact IsPullback.of_isLimit (PullbackCone.IsLimit.mk + hc (lift h) (fac_left _) (fac_right _) (uniq _)) noncomputable def functorIsPullback (h : IsPullback (homOf north) (homOf west) (homOf east) (homOf south)) : @@ -885,22 +918,27 @@ noncomputable def functorIsPullback have hChosen : IsPullback (P := Cat.of (Functor.IsPullback.Chosen east south)) (homOf IsPullback.Chosen.north) (homOf IsPullback.Chosen.west) (homOf east) (homOf south) := - isPullback Functor.IsPullback.Chosen.comm_sq (Functor.IsPullback.Chosen.isPullback east south) + Cat.isPullback Functor.IsPullback.Chosen.comm_sq + (Functor.IsPullback.Chosen.isPullback east south) let i := IsPullback.isoIsPullback _ _ h hChosen - convert Functor.IsPullback.ofIsoChosen east south i.hom i.inv ?_ ?_ - · symm - exact IsPullback.isoIsPullback_hom_fst _ _ h hChosen - · symm - exact IsPullback.isoIsPullback_hom_snd _ _ h hChosen - · exact i.hom_inv_id - · exact i.inv_hom_id + have hF0 := Functor.IsPullback.ofIsoChosen east south + i.hom.toFunctor i.inv.toFunctor + (congrArg Cat.Hom.toFunctor i.hom_inv_id) + (congrArg Cat.Hom.toFunctor i.inv_hom_id) + have hN : i.hom.toFunctor ⋙ Functor.IsPullback.Chosen.north = north := by + exact congrArg Cat.Hom.toFunctor + (IsPullback.isoIsPullback_hom_fst _ _ h hChosen) + have hW : i.hom.toFunctor ⋙ Functor.IsPullback.Chosen.west = west := by + exact congrArg Cat.Hom.toFunctor + (IsPullback.isoIsPullback_hom_snd _ _ h hChosen) + simpa only [hN, hW] using hF0 end end Cat namespace Grpd -open Functor Limits +open _root_.CategoryTheory.Functor Limits variable {Libya Egypt Chad Sudan : Type u} [Groupoid.{v} Libya] [Groupoid.{v} Egypt] [Groupoid.{v} Chad] [Groupoid.{v} Sudan] @@ -909,21 +947,25 @@ variable {Libya Egypt Chad Sudan : Type u} [Groupoid.{v} Libya] (h : Functor.IsPullback north west east south) (s : Limits.PullbackCone (homOf east) (homOf south)) -def lift : s.pt ⟶ of Libya := h.lift s.fst s.snd s.condition +def lift : s.pt ⟶ of Libya := + _root_.CategoryTheory.Functor.IsPullback.lift h s.fst s.snd s.condition -def fac_left : lift h s ≫ (homOf north) = s.fst := - h.fac_left _ _ _ +theorem fac_left : lift h s ≫ (homOf north) = s.fst := + _root_.CategoryTheory.Functor.IsPullback.fac_left h _ _ _ -def fac_right : lift h s ≫ (homOf west) = s.snd := - h.fac_right _ _ _ +theorem fac_right : lift h s ≫ (homOf west) = s.snd := + _root_.CategoryTheory.Functor.IsPullback.fac_right h _ _ _ -def uniq (m : s.pt ⟶ of Libya) (hl : m ≫ homOf north = s.fst) +theorem uniq (m : s.pt ⟶ of Libya) (hl : m ≫ homOf north = s.fst) (hr : m ≫ homOf west = s.snd) : m = lift h s := by - apply h.hom_ext - · convert (fac_left h s).symm - · convert (fac_right h s).symm - -def isPullback : IsPullback (homOf north) (homOf west) (homOf east) (homOf south) := + apply _root_.CategoryTheory.Functor.IsPullback.hom_ext h + · change m ≫ homOf north = lift h s ≫ homOf north + exact hl.trans (fac_left h s).symm + · change m ≫ homOf west = lift h s ≫ homOf west + exact hr.trans (fac_right h s).symm + +include h in +theorem isPullback : IsPullback (homOf north) (homOf west) (homOf east) (homOf south) := IsPullback.of_isLimit (PullbackCone.IsLimit.mk h.comm_sq (lift h) (fac_left _) (fac_right _) (uniq _)) diff --git a/HoTTLean/ForMathlib/CategoryTheory/Groupoid.lean b/HoTTLean/ForMathlib/CategoryTheory/Groupoid.lean index 0f73aff6..f67c7015 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Groupoid.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Groupoid.lean @@ -1,17 +1 @@ import Mathlib.CategoryTheory.Groupoid -import Mathlib.CategoryTheory.MorphismProperty.Basic - -namespace CategoryTheory - -open MorphismProperty in -lemma isGroupoid_iff_isomorphisms_eq_top (C : Type*) [Category C] : - IsGroupoid C ↔ isomorphisms C = ⊤ := by - constructor - · rw [eq_top_iff] - intro _ _ - simp only [isomorphisms.iff, top_apply] - infer_instance - · intro h - exact ⟨of_eq_top h⟩ - -end CategoryTheory diff --git a/HoTTLean/ForMathlib/CategoryTheory/Grpd.lean b/HoTTLean/ForMathlib/CategoryTheory/Grpd.lean index 5d3d85cc..db1db87d 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Grpd.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Grpd.lean @@ -40,7 +40,7 @@ instance : CartesianMonoidalCategory Grpd := isLimit := isLimitProdCone X Y }) theorem eqToHom_obj - {C1 C2 : Grpd.{v,u}} (x : C1) (eq : C1 = C2) : + {C1 C2 : Grpd.{v,u}} (x : C1) (eq : C1 = C2) : (eqToHom eq).obj x = cast (congrArg Bundled.α eq) x := by cases eq simp [id_eq_id] @@ -80,8 +80,7 @@ variable {Γ : Type u₂} [Category.{v₂} Γ] {A : Γ ⥤ Grpd.{v₁,u₁}} theorem map_comp_map' {x y z : Γ} {f : x ⟶ y} {g : y ⟶ z} {a b : A.obj x} {φ : a ⟶ b} : (A.map g).map ((A.map f).map φ) - = eqToHom Grpd.map_comp_obj.symm ≫ (A.map (f ≫ g)).map φ ≫ eqToHom Grpd.map_comp_obj - := by + = eqToHom Grpd.map_comp_obj.symm ≫ (A.map (f ≫ g)).map φ ≫ eqToHom Grpd.map_comp_obj := by simp [Grpd.map_comp_map] end @@ -110,7 +109,7 @@ theorem eqToHom_hom_aux {C1 C2 : Grpd.{v,u}} (x y: C1) (eq : C1 = C2) : theorem eqToHom_hom {C1 C2 : Grpd.{v,u}} {x y: C1} (f : x ⟶ y) (eq : C1 = C2) : (eqToHom eq).map f = (cast (Grpd.eqToHom_hom_aux x y eq) f) := by cases eq - simp only [eqToHom_refl, id_eq_id, Functor.id_map, cast_eq] + simp [CategoryStruct.id] @[simp] theorem map_eqToHom_map {x y : Γ} (h : x = y) {t s} (f : t ⟶ s) : (F.map (eqToHom h)).map f = @@ -150,12 +149,12 @@ def Grpd.Functor.iso (A : Γ ⥤ Grpd) {x y : Γ} (f : x ⟶ y) : A.obj x ≅≅ -- Note: this should not be a simp lemma, because we want simp to -- see the Functor.Iso structure -def Grpd.Functor.iso_hom (A : Γ ⥤ Grpd) {x y : Γ} (f : x ⟶ y) : +theorem Grpd.Functor.iso_hom (A : Γ ⥤ Grpd) {x y : Γ} (f : x ⟶ y) : (iso A f).hom = A.map f := rfl -- Note: this should not be a simp lemma, because we want simp to -- see the Functor.Iso structure -def Grpd.Functor.iso_inv (A : Γ ⥤ Grpd) {x y : Γ} (f : x ⟶ y) : +theorem Grpd.Functor.iso_inv (A : Γ ⥤ Grpd) {x y : Γ} (f : x ⟶ y) : (iso A f).inv = A.map (inv f) := rfl @[simp] @@ -191,8 +190,8 @@ lemma Grpd.whiskerLeft_hcongr_right {C D : Type*} [Category C] [Category D] lemma Grpd.comp_hcongr {C C' D D' E E' : Grpd.{v,u}} (hC : C ≍ C') (hD : D ≍ D') (hE : E ≍ E') {F : C ⥤ D} {F' : C' ⥤ D'} {G : D ⥤ E} {G' : D' ⥤ E'} - (hF : F ≍ F') (hG : G ≍ G') - : F ⋙ G ≍ F' ⋙ G' := by + (hF : F ≍ F') (hG : G ≍ G') : + F ⋙ G ≍ F' ⋙ G' := by subst hC hD hE hF hG rfl @@ -228,8 +227,8 @@ attribute [simp] comp_eq_comp id_eq_id in def mkIso {Δ Γ : Grpd} (F : Δ ≅≅ Γ) : Δ ≅ Γ where hom := F.hom inv := F.inv - hom_inv_id := by simp - inv_hom_id := by simp + hom_inv_id := F.hom_inv_id + inv_hom_id := F.inv_hom_id attribute [simp] comp_eq_comp id_eq_id in @[simps] @@ -237,8 +236,8 @@ def mkIso' {Δ Γ : Type u} [Groupoid.{v} Δ] [Groupoid.{v} Γ] (F : Δ ≅≅ Grpd.of Δ ≅ Grpd.of Γ where hom := F.hom inv := F.inv - hom_inv_id := by simp - inv_hom_id := by simp + hom_inv_id := F.hom_inv_id + inv_hom_id := F.inv_hom_id open MonoidalCategory diff --git a/HoTTLean/ForMathlib/CategoryTheory/Localization/Predicate.lean b/HoTTLean/ForMathlib/CategoryTheory/Localization/Predicate.lean index 70dc3771..76cc129c 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/Localization/Predicate.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/Localization/Predicate.lean @@ -2,55 +2,3 @@ import Mathlib.CategoryTheory.Localization.Predicate import HoTTLean.ForMathlib.CategoryTheory.Groupoid import HoTTLean.ForMathlib.CategoryTheory.MorphismProperty.Basic - -noncomputable section - -namespace CategoryTheory.Localization -open Category Functor - -variable {C D : Type*} [Category C] [Category D] (L : C ⥤ D) (W : MorphismProperty C) (E : Type*) - [Category E] - -variable {D₁ D₂ : Type _} [Category D₁] [Category D₂] (L₁ : C ⥤ D₁) (L₂ : C ⥤ D₂) - (W' : MorphismProperty C) [L₁.IsLocalization W'] [L₂.IsLocalization W'] - -lemma morphismProperty_eq_top [L.IsLocalization W] (P : MorphismProperty D) [P.RespectsIso] - [P.IsMultiplicative] (h₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (L.map f)) - (h₂ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y) (hf : W f), P (isoOfHom L W f hf).inv) : - P = ⊤ := by - let P' : MorphismProperty W.Localization := - P.inverseImage (Construction.lift L Functor.IsLocalization.inverts) - have hP' : P' = ⊤ := by - apply Construction.morphismProperty_is_top - · intros - simp only [MorphismProperty.inverseImage_iff, Construction.lift_obj, ← Functor.comp_map, - Functor.congr_hom (Construction.fac L Functor.IsLocalization.inverts), Functor.comp_obj, - eqToHom_refl, Category.comp_id, Category.id_comp, h₁, P'] - · intro X Y w hw - simp only [P', MorphismProperty.inverseImage_iff] - convert h₂ w hw - convert Functor.map_inv (Construction.lift L Functor.IsLocalization.inverts) - (Construction.wIso w hw).hom - · simp - · have : (Construction.wIso w hw).hom = W.Q.map w := rfl - simp only [this, ← Functor.comp_map, - Functor.congr_hom (Construction.fac L Functor.IsLocalization.inverts)] - simp [isoOfHom] - have : P'.map _ = P := MorphismProperty.map_inverseImage_eq_of_isEquivalence .. - simp [← this, hP'] - -lemma isGroupoid [L.IsLocalization ⊤] : - IsGroupoid D := by - rw [isGroupoid_iff_isomorphisms_eq_top] - exact morphismProperty_eq_top L ⊤ _ - (fun _ _ f ↦ inverts L ⊤ _ (by simp)) - (fun _ _ f hf ↦ Iso.isIso_inv _) - -instance : IsGroupoid (⊤ : MorphismProperty C).Localization := - isGroupoid <| MorphismProperty.Q ⊤ - -/-- Localization of a category with respect to all morphisms results in a groupoid. -/ -def groupoid : Groupoid (⊤ : MorphismProperty C).Localization := - Groupoid.ofIsGroupoid - -end CategoryTheory.Localization diff --git a/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/Basic.lean b/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/Basic.lean index 8773745c..2828a0c0 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/Basic.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/Basic.lean @@ -1,19 +1 @@ import Mathlib.CategoryTheory.MorphismProperty.Basic - -universe u v - -namespace CategoryTheory.MorphismProperty - -variable {C : Type u} [Category.{v} C] {D : Type*} [Category D] - -@[simp] -lemma map_top_eq_top_of_essSurj_of_full (F : C ⥤ D) [F.EssSurj] [F.Full] : - (⊤ : MorphismProperty C).map F = ⊤ := by - rw [eq_top_iff] - intro X Y f _ - refine ⟨F.objPreimage X, F.objPreimage Y, F.preimage ?_, ⟨⟨⟩, ⟨?_⟩⟩⟩ - · exact (Functor.objObjPreimageIso F X).hom ≫ f ≫ (Functor.objObjPreimageIso F Y).inv - · exact Arrow.isoMk' _ _ (Functor.objObjPreimageIso F X) (Functor.objObjPreimageIso F Y) - (by simp) - -end CategoryTheory.MorphismProperty diff --git a/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/WideSubcategory.lean b/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/WideSubcategory.lean index d9792de1..616bf4b8 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/WideSubcategory.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/MorphismProperty/WideSubcategory.lean @@ -135,7 +135,7 @@ lemma WideSubcategory.hext {X X' : P.WideSubcategory} (hX : X.1 ≍ X'.1) : X lemma WideSubcategory.hom_hext {X X' Y Y' : P.WideSubcategory} (hX : X.1 ≍ X'.1) (hY : Y.1 ≍ Y'.1) (f : X ⟶ Y) (f' : X' ⟶ Y') (hf : f.1 ≍ f'.1) : f ≍ f' := by cases X; cases X'; cases Y; cases Y'; subst hX hY - simp only [Set.mem_setOf_eq, heq_eq_eq] at * + simp only [heq_eq_eq] at * apply hom_ext assumption diff --git a/HoTTLean/ForMathlib/CategoryTheory/NatTrans.lean b/HoTTLean/ForMathlib/CategoryTheory/NatTrans.lean index aee6e9a4..9dddc8f3 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/NatTrans.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/NatTrans.lean @@ -1,6 +1,6 @@ import Mathlib.CategoryTheory.NatTrans import Mathlib.CategoryTheory.Functor.TwoSquare -import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq +import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic import HoTTLean.ForMathlib universe w v u v₁ u₁ v₂ u₂ v₃ u₃ @@ -29,7 +29,7 @@ def inv : G ⟶ F := h.isoOfCodGroupoid.inv end -open Functor +open CategoryTheory.Functor lemma hext {A : Type u} [Category.{v} A] {B : Type u₁} [Category.{v₁} B] {F F' G G' : A ⥤ B} (α : F ⟶ G) (β : F' ⟶ G') diff --git a/HoTTLean/ForMathlib/CategoryTheory/RepPullbackCone.lean b/HoTTLean/ForMathlib/CategoryTheory/RepPullbackCone.lean index acffbd24..67e9a165 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/RepPullbackCone.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/RepPullbackCone.lean @@ -1,7 +1,7 @@ import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction import Mathlib.CategoryTheory.Limits.Preserves.Finite -import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq +import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic import HoTTLean.ForMathlib.CategoryTheory.WeakPullback /-! @@ -9,6 +9,8 @@ import HoTTLean.ForMathlib.CategoryTheory.WeakPullback by its universal property among representable cones. -/ +set_option backward.isDefEq.respectTransparency false + universe u v u₁ v₁ u₂ v₂ namespace CategoryTheory @@ -20,7 +22,7 @@ variable {J : Type u₁} [Category.{v₁} J] {K : Type u₂} [Category.{v₂} K] variable {C : Type u₃} [Category.{v₃} C] open CategoryTheory -open Functor +open CategoryTheory.Functor /-- A `c : RepCone F` is: * an object `c.pt` and @@ -78,8 +80,8 @@ def lift' (c : C) (x' : yoneda.obj c ⟶ s.pt) : yoneda.obj c ⟶ t.pt := rfl def lift''_app (s : Cone F) (c : C) : - s.pt.obj (Opposite.op c) → t.pt.obj (Opposite.op c) := - yonedaEquiv ∘ lift' P c ∘ yonedaEquiv.symm + s.pt.obj (Opposite.op c) ⟶ t.pt.obj (Opposite.op c) := + ↾(yonedaEquiv ∘ lift' P c ∘ yonedaEquiv.symm) theorem lift''_app_naturality {c d : C} (f : c ⟶ d) : s.pt.map (f.op) ≫ lift''_app P s c @@ -170,7 +172,8 @@ lemma snd_mk (W : C) (fst : yoneda.obj W ⟶ X) (snd : yoneda.obj W ⟶ Y) theorem condition : t.fst ≫ f = t.snd ≫ g := t.pullbackCone.condition -open WalkingSpan.Hom WalkingCospan.Hom WidePullbackShape.Hom WidePushoutShape.Hom Limits.PullbackCone +open WalkingSpan.Hom WalkingCospan.Hom WidePullbackShape.Hom WidePushoutShape.Hom + Limits.PullbackCone def repIsLimitAux (t : PullbackCone f g) (lift : ∀ s : RepPullbackCone f g, yoneda.obj s.pt ⟶ t.pt) (fac_left : ∀ s : RepPullbackCone f g, lift s ≫ t.fst = s.fst) @@ -185,7 +188,8 @@ def repIsLimitAux (t : PullbackCone f g) (lift : ∀ s : RepPullbackCone f g, yo fun j' => WalkingPair.casesOn j' (fac_left s) (fac_right s) uniq := uniq } -/-- To show that a `PullbackCone` in a presheaf category constructed using `PullbackCone.mk` is a limit cone, +/-- To show that a `PullbackCone` in a presheaf category constructed using `PullbackCone.mk` +is a limit cone, it suffices to show its universal property among representable cones. -/ def RepIsLimit.mk {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g) @@ -229,23 +233,25 @@ open Opposite def repPullbackCone (c : C) (x : G.obj (op c)) : RepPullbackCone f g := .mk c (yonedaEquiv.symm $ a.app (op c) x) (yonedaEquiv.symm $ b.app (op c) x) (by - simpa [yonedaEquiv_symm_naturality_right] using congr_fun (NatTrans.congr_app hab (op c)) x) + simpa [yonedaEquiv_symm_naturality_right] using + ConcreteCategory.congr_hom (NatTrans.congr_app hab (op c)) x) def lift'.app (c : C) : G.obj (op c) ⟶ W.obj (op c) := - fun x => yonedaEquiv (lift (repPullbackCone a b hab c x)) + ↾fun x => yonedaEquiv (lift (repPullbackCone a b hab c x)) include lift_naturality in lemma lift'.naturality ⦃c d : C⦄ (σ : c ⟶ d) : G.map σ.op ≫ lift'.app lift a b hab c = lift'.app lift a b hab d ≫ W.map σ.op := by ext x - dsimp only [types_comp_apply, app] + change yonedaEquiv (lift (repPullbackCone a b hab c (G.map σ.op x))) = + W.map σ.op (yonedaEquiv (lift (repPullbackCone a b hab d x))) rw [yonedaEquiv_naturality, lift_naturality (repPullbackCone a b hab d x) σ] dsimp only [repPullbackCone, π_app_left, fst_mk, π_app_right, snd_mk] congr 3 · rw [yonedaEquiv_symm_naturality_left σ] - simpa using congr_fun (a.naturality σ.op) x + simp · rw [yonedaEquiv_symm_naturality_left σ] - simpa using congr_fun (b.naturality σ.op) x + simp include lift_naturality in def lift' : G ⟶ W where diff --git a/HoTTLean/ForMathlib/CategoryTheory/WeakPullback.lean b/HoTTLean/ForMathlib/CategoryTheory/WeakPullback.lean index 90acf3dd..86e3c910 100644 --- a/HoTTLean/ForMathlib/CategoryTheory/WeakPullback.lean +++ b/HoTTLean/ForMathlib/CategoryTheory/WeakPullback.lean @@ -33,17 +33,19 @@ def coherentLift [HasPullbacks C] : W ⟶ P := @[simp] lemma coherentLift_fst [HasPullbacks C] : wp.coherentLift a b h ≫ fst = a := by - simp [coherentLift] + simp [coherentLift, pullback.lift_fst] @[simp] lemma coherentLift_snd [HasPullbacks C] : wp.coherentLift a b h ≫ snd = b := by - simp [coherentLift] + simp [coherentLift, pullback.lift_snd] lemma coherentLift_comp_left [HasPullbacks C] {W'} (σ : W' ⟶ W) : σ ≫ wp.coherentLift a b h = wp.coherentLift (σ ≫ a) (σ ≫ b) (by simp [h]) := by - simp only [coherentLift, ← Category.assoc] - congr 1; ext <;> simp + dsimp [coherentLift] + rw [← Category.assoc] + congr 1 + apply pullback.hom_ext <;> simp [Category.assoc, pullback.lift_fst, pullback.lift_snd] end WeakPullback end CategoryTheory diff --git a/HoTTLean/ForMathlib/Tactic/CategoryTheory/FunctorMap.lean b/HoTTLean/ForMathlib/Tactic/CategoryTheory/FunctorMap.lean index d03c7c5b..422e3c11 100644 --- a/HoTTLean/ForMathlib/Tactic/CategoryTheory/FunctorMap.lean +++ b/HoTTLean/ForMathlib/Tactic/CategoryTheory/FunctorMap.lean @@ -56,24 +56,24 @@ def functorMapExpr (e : Expr) (lvl_params : Bool) : MetaM (Expr × List Level) : let some (hom, _, _) := eTp.eq? | throwError "expected an equality, got{indentD eTp}" if !hom.isAppOf ``Quiver.Hom then throwError "expected an equality of morphisms, got{indentD eTp}" - let [.succ v₁, u₁] := hom.getAppFn.constLevels! | + let [v₁, u₁] := hom.getAppFn.constLevels! | throwError "unexpected universe levels in{indentD hom.getAppFn}" let e' ← mkAppM' (.const ``eq_functor_map [v₁, u₁, v₂, u₂]) #[e] simpType categorySimp' e' return (e, [v₂, u₂]) -syntax (name := functor_map) "functor_map" (" (" &"attr" ":=" Parser.Term.attrInstance,* ")")? : attr +syntax (name := functor_map) "functor_map" optAttrArg : attr initialize registerBuiltinAttribute { name := `functor_map descr := "" applicationTime := .afterCompilation add := fun src ref kind => match ref with - | `(attr| functor_map $[(attr := $stx?,*)]?) => MetaM.run' do + | `(attr| functor_map $optAttr) => MetaM.run' do if (kind != AttributeKind.global) then throwError "`functor_map` can only be used as a global attribute" - addRelatedDecl src "_functor_map" ref stx? fun type value levels => do - let (e, levels') ← functorMapExpr (← mkExpectedTypeHint value type) true + addRelatedDecl src (src.appendAfter "_functor_map") ref optAttr fun value levels => do + let (e, levels') ← functorMapExpr value true pure (e, levels ++ levels'.map fun | .param n => n | _ => panic! "") | _ => throwUnsupportedSyntax } diff --git a/HoTTLean/ForPoly.lean b/HoTTLean/ForPoly.lean index b9a44a91..6090a18d 100644 --- a/HoTTLean/ForPoly.lean +++ b/HoTTLean/ForPoly.lean @@ -5,6 +5,12 @@ open CategoryTheory Limits noncomputable section +-- Use the earlier elaboration transparency for the polynomial functor definitions. +set_option backward.isDefEq.respectTransparency false + +attribute [local simp] pullback.map pullback.lift_fst pullback.lift_snd + pullback.lift_fst_assoc pullback.lift_snd_assoc + namespace CategoryTheory.UvPoly open Limits PartialProduct @@ -22,6 +28,9 @@ theorem η_naturality {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} ext X simp [pullbackMapIsoSquare, ← pullback_map_eq_eqToHom rfl hp.w.symm, Over.pullbackComp] ext <;> simp [pullback.condition] + dsimp only [PullbackCone.mk] + simp only [Category.id_comp, Category.assoc, pullback.lift_fst_assoc, + pullback.lift_fst] theorem η_naturality' {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} (e : E ⟶ E') (b : B ⟶ B') @@ -40,22 +49,7 @@ theorem η_naturality' {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} Functor.whiskerRight α.hom ebk ≫ Functor.whiskerLeft bmap bb.inv = Functor.whiskerRight (Over.mapPullbackAdj b).unit pbk := by - intro bmap emap pbk ebk bbk p'bk α bb - ext X - simp[bb,α,pullbackMapIsoSquare,pbk,bmap,ebk,emap,bbk,Category.assoc] - ext - · simp[← Category.assoc,← pullback_map_eq_eqToHom rfl hp.w.symm] - simp[Over.pullbackComp] - slice_lhs 2 3 => apply pullback.lift_fst - simp[← Category.assoc] - · rw[← pullback_map_eq_eqToHom rfl hp.w.symm] - simp[Over.pullbackComp] - slice_lhs 2 3 => apply pullback.lift_snd - simp[← Category.assoc,pullback.condition] - rw[← Category.assoc,← pullback_map_eq_eqToHom rfl hp.w.symm] - simp[Over.pullbackComp,pullback.map] - slice_lhs 2 3 => apply pullback.lift_snd - simp + exact η_naturality e b hp open ExponentiableMorphism in @@ -71,7 +65,7 @@ theorem pushforwardPullbackIsoSquare_eq {C} [Category C] [HasPullbacks C] {X Y Z simp [pushforwardPullbackIsoSquare, Over.pushforwardPullbackTwoSquare] ext1; simp -open ExponentiableMorphism Functor in +open ExponentiableMorphism CategoryTheory.Functor in theorem ev_naturality {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} (e : E ⟶ E') (b : B ⟶ B') (hp : IsPullback P.p e b P'.p) : @@ -127,24 +121,24 @@ theorem ev_naturality {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} theorem associator_eq_id {C D E E'} [Category C] [Category D] [Category E] [Category E'] (F : C ⥤ D) (G : D ⥤ E) (H : E ⥤ E') : Functor.associator F G H = Iso.refl (F ⋙ G ⋙ H) := rfl -open Functor in +open CategoryTheory.Functor in theorem whiskerRight_left' {C D E B} [Category C] [Category D] [Category E] [Category B] (F : B ⥤ C) {G H : C ⥤ D} (α : G ⟶ H) (K : D ⥤ E) : whiskerRight (whiskerLeft F α) K = whiskerLeft F (whiskerRight α K) := by aesop_cat -open Functor in +open CategoryTheory.Functor in theorem id_whiskerLeft' {C D} [Category C] [Category D] {G H : C ⥤ D} (α : G ⟶ H) : whiskerLeft (𝟭 C) α = α := by aesop_cat -open Functor in +open CategoryTheory.Functor in theorem whiskerLeft_twice' {C D E B} [Category C] [Category D] [Category E] [Category B] (F : B ⥤ C) (G : C ⥤ D) {H K : D ⥤ E} (α : H ⟶ K) : whiskerLeft F (whiskerLeft G α) = whiskerLeft (F ⋙ G) α := by aesop_cat -open Functor in +open CategoryTheory.Functor in theorem whiskerRight_twice' {C D E B} [Category C] [Category D] [Category E] [Category B] {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ⟶ K) : whiskerRight (whiskerRight α F) G = whiskerRight α (F ⋙ G) := by @@ -152,7 +146,7 @@ theorem whiskerRight_twice' {C D E B} [Category C] [Category D] [Category E] [Ca variable [HasTerminal C] -open Over ExponentiableMorphism Functor in +open Over ExponentiableMorphism CategoryTheory.Functor in @[simp] lemma cartesianNatTrans_fstProj {E B E' B' : C} (P : UvPoly E B) (P' : UvPoly E' B') (e : E ⟶ E') (b : B ⟶ B') (pb : IsPullback P.p e b P'.p) (X : C) : @@ -163,9 +157,9 @@ lemma cartesianNatTrans_fstProj {E B E' B' : C} (P : UvPoly E B) (P' : UvPoly E' rw [← Category.assoc] change (m.app X).left ≫ pullback.fst (P'.fstProj X) b ≫ P'.fstProj X = P.fstProj X ≫ b rw [pullback.condition, ← Category.assoc]; congr 1 - simpa using Over.w (m.app X) + simpa [UvPoly.fstProj] using Over.w (m.app X) -open ExponentiableMorphism Functor in +open ExponentiableMorphism CategoryTheory.Functor in set_option maxHeartbeats 300000 in theorem fan_snd_map' {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} (e : E ⟶ E') (b : B ⟶ B') (A : C) (hp : IsPullback P.p e b P'.p) : @@ -213,11 +207,11 @@ theorem fan_snd_map' {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} slice_lhs 10 10 => enter [2,2,2,2]; apply Category.comp_id ext <;> simp · conv_rhs => apply pullback.lift_fst - slice_lhs 1 2 => apply pullback.lift_fst + dsimp only [PullbackCone.mk] + simp only [Category.id_comp, pullback.lift_fst_assoc, pullback.lift_fst] simp [← p_eq, UB, bγ, p'fwd, pfwd, Over.pullbackForgetTriangle, Over.pullbackForgetTwoSquare, Adjunction.id, TwoSquare.natTrans, Over.mapForget] - congr 2 - symm; apply Category.id_comp + simp [sE, sE', bbk, Category.assoc, fstProj] · slice_lhs 1 2 => apply pullback.lift_snd symm; apply pullback.lift_snd let Z : sE ⋙ pfwd ⋙ pbk ⋙ UE ⟶ sE ⋙ UE := @@ -256,8 +250,7 @@ theorem fan_snd_map' {E B E' B' : C} {P : UvPoly E B} {P' : UvPoly E' B'} slice_lhs 1 2 => rw [← this] slice_lhs 2 3 => apply Category.comp_id simp [α, Over.starPullbackIsoStar] - slice_lhs 5 6 => apply pullback.lift_fst - simp [Over.mapForget] + simp [sE, sE'] open ExponentiableMorphism in theorem fan_snd_map {E B A E' B' A' : C} {P : UvPoly E B} {P' : UvPoly E' B'} @@ -348,7 +341,7 @@ theorem fst_comp_right (pair : Γ ⟶ P @ X) : fst P Y (pair ≫ P.functor.map f simp [fst_eq] lemma snd'_eq (pair : Γ ⟶ P @ X) {R f g} (H : IsPullback (P := R) f g (fst P X pair) P.p) : - snd' P X pair H = pullback.lift (f ≫ pair) g (by simpa using H.w) ≫ (fan P X).snd := by + snd' P X pair H = pullback.lift (f ≫ pair) g (by simpa [fst_eq] using H.w) ≫ (fan P X).snd := by simp [snd', snd] simp only [← Category.assoc]; congr! 2 ext <;> simp @@ -432,16 +425,14 @@ lemma ext' {pair₁ pair₂ : Γ ⟶ P @ X} simp [fst_eq] at h1 H apply partialProd.hom_ext ⟨fan P X, isLimitFan P X⟩ h1 refine (cancel_epi H.isoPullback.hom).1 ?_ - convert h2 using 1 <;> ( - simp [snd'_eq, comparison_pullback.map, partialProd.snd, partialProd.cone] - simp only [← Category.assoc]; congr! 2 - ext <;> simp) - · slice_lhs 2 3 => apply pullback.lift_fst - slice_lhs 1 2 => apply H.isoPullback_hom_fst - simp - · slice_lhs 2 3 => apply pullback.lift_snd - slice_lhs 1 2 => apply H.isoPullback_hom_snd - simp + convert h2 using 1 <;> + simp [snd'_eq, comparison_pullback.map, partialProd.snd, partialProd.cone, + partialProd.fst, fan] + all_goals + simp only [← Category.assoc] + congr 2 + apply pullback.hom_ext <;> + simp [Category.assoc, H.isoPullback_hom_snd] /-- Switch the selected pullback `R` used in `UvPoly.Equiv.mk'` with a different pullback `R'`. -/ theorem mk'_eq_mk' (b : Γ ⟶ B) {R f g} (H : IsPullback (P := R) f g b P.p) (x : R ⟶ X) @@ -505,7 +496,7 @@ lemma mk'_comp_cartesianNatTrans_app {E' B' Γ X : C} {P' : UvPoly E' B'} have := snd'_mk' P X y H x rw [snd'_eq, ← fan_snd_map' _ _ X hp] at this refine .trans ?_ this - simp only [← Category.assoc]; congr 1; ext <;> simp + simp only [← Category.assoc]; congr 1; ext <;> simp [fan, Category.assoc] end Equiv @@ -552,7 +543,7 @@ def compP {E B D A : C} (P : UvPoly E B) (Q : UvPoly D A) : compDom P Q ⟶ P @ (h : β ≫ Q.p = pullback.lift AB α w ≫ (PartialProduct.fan P A).snd) : compDomEquiv.symm ⟨AB, α, β, w, h⟩ ≫ P.compP Q = AB := by simp [compDomEquiv, compP, Equiv.psigmaCongrProp, Equiv.sigmaCongrRight_symm, - Equiv.coe_fn_symm_mk, pullbackHomEquiv] + pullbackHomEquiv, fan] def compDomMap {E B D A E' B' D' A' : 𝒞} {P : UvPoly E B} {Q : UvPoly D A} {P' : UvPoly E' B'} {Q' : UvPoly D' A'} @@ -578,7 +569,7 @@ theorem compDomMap_isPullback {E B D A E' B' D' A' : 𝒞} {P : UvPoly E B} {Q : · refine hq.flip.back_face_of_comm_cube _ _ _ _ _ _ _ _ _ _ _ _ (by simp [compDomMap]) ?_ ?_ (.of_hasPullback ..) (.of_hasPullback ..) · exact ⟨fan_snd_map _ _ a hp⟩ - · constructor; simp [compDomMap]; ext <;> simp [p] + · constructor; simp [compDomMap]; ext <;> simp [p, fan, Category.assoc] · exact hp.flip.back_face_of_comm_cube _ _ _ _ _ _ _ _ _ _ _ _ (by simp) (by simp [p]) (by simp) (.flip (.of_hasPullback ..)) (.flip (.of_hasPullback ..)) @@ -623,7 +614,7 @@ instance preservesConnectedLimitsOfShape_of_hasLimitsOfShape {J : Type v₁} [Sm unfold UvPoly.functor infer_instance -instance preservesPullbacks (P : UvPoly E B) +theorem preservesPullbacks (P : UvPoly E B) {Pb X Y Z : C} (fst : Pb ⟶ X) (snd : Pb ⟶ Y) (f : X ⟶ Z) (g : Y ⟶ Z) (h: IsPullback fst snd f g) : diff --git a/HoTTLean/Frontend/Commands.lean b/HoTTLean/Frontend/Commands.lean index 2f349ac6..e21e24be 100644 --- a/HoTTLean/Frontend/Commands.lean +++ b/HoTTLean/Frontend/Commands.lean @@ -21,16 +21,15 @@ def envDiff (old new : Environment) : Array ConstantInfo := Id.run do and return them as an axiom environment. Assumes that all such axioms are present in the ambient environment as definitions of type `CheckedAx _` under the same name. -/ -def computeAxioms (thyEnv : Environment) (constNm : Name) : MetaM ((E : Q(Axioms Name)) × Q(($E).Wf)) := do - let (_, st) ← (CollectAxioms.collect constNm).run thyEnv |>.run {} - let axioms := st.axioms +def computeAxioms (thyEnv : Environment) (constNm : Name) : + MetaM ((E : Q(Axioms Name)) × Q(($E).Wf)) := do + let axioms ← withEnv thyEnv <| collectAxioms constNm -- The output includes `constNm` if it is itself an axiom. let axioms := axioms.filter (· != constNm) -- Order the axioms by '`a` uses `b`'. let mut axiomAxioms : Std.HashMap Name (Array Name) := {} for axNm in axioms do - let (_, st) ← (CollectAxioms.collect axNm).run thyEnv |>.run {} - let axioms := st.axioms.filter (· != axNm) + let axioms := (← withEnv thyEnv <| collectAxioms axNm).filter (· != axNm) axiomAxioms := axiomAxioms.insert axNm axioms let mut axioms := axioms.qsort (fun a b => axiomAxioms[b]!.contains a) -- HACK: replace `sorryAx` with our universe-monomorphic versions. diff --git a/HoTTLean/Frontend/EnvExt.lean b/HoTTLean/Frontend/EnvExt.lean index 3d71ccf3..237f7145 100644 --- a/HoTTLean/Frontend/EnvExt.lean +++ b/HoTTLean/Frontend/EnvExt.lean @@ -26,7 +26,7 @@ namespace SynthLean open Lean Qq variable {m : Type → Type} [Monad m] [MonadLiftT IO m] - [MonadOptions m] [MonadEnv m] [MonadError m] [MonadQuotation m] + [MonadOptions m] [MonadEnv m] [MonadError m] /-- A theory-updating entry. @@ -70,6 +70,7 @@ For the initial shallow environment, we pull in a custom prelude with `Type`-valued identity types. -/ def mkInitTheoryData (modNm mainModule : Name) : m TheoryData := do -- TODO: check if the `.olean` exists and print a better error if not. + liftM (m := IO) <| unsafe enableInitializersExecution let mut thyEnv ← importModules #[{ module := `HoTTLean.Prelude }] (← getOptions) (leakEnv := true) (loadExts := true) thyEnv := thyEnv.setMainModule mainModule @@ -107,7 +108,7 @@ private initialize theoryExt : TheoryExt ← | .axiomInfo i => pure <| .axiomDecl i | .defnInfo i => pure <| .defnDecl i | _ => throwThe IO.Error s!"unsupported constant kind at '{ci.name}'" -- Q: no extension entries added after the prelude; will this break elaboration? - let .ok thyEnv := thyData.env.addDeclCore 0 decl none (doCheck := false) + let .ok thyEnv := thyData.env.addDeclCore 0 0 decl none (doCheck := false) | throwThe IO.Error "internal error" /- cannot happen with `doCheck := false` -/ thyMap := thyMap.insert thyNm { thyData with env := thyEnv } return ([], thyMap) @@ -116,7 +117,7 @@ private initialize theoryExt : TheoryExt ← -- Note: because we `cons` local entries onto the list, -- this array has the latest entry first -- and has to be read in reverse order when imported. - exportEntriesFnEx _ s _ := s.1.toArray + exportEntriesFnEx _ s := .uniform s.1.toArray -- TODO: statsFn, asyncMode, replay? } diff --git a/HoTTLean/Grothendieck/Groupoidal/Basic.lean b/HoTTLean/Grothendieck/Groupoidal/Basic.lean index 5103064e..853afdd1 100644 --- a/HoTTLean/Grothendieck/Groupoidal/Basic.lean +++ b/HoTTLean/Grothendieck/Groupoidal/Basic.lean @@ -73,7 +73,7 @@ def comp {x y z : ∫(F)} (f : Hom x y) (g : Hom y z) : Hom x z := Grothendieck. attribute [local simp] eqToHom_map instance : Category (∫ F) := { - (inferInstanceAs $ Category (Grothendieck (F ⋙ Grpd.forgetToCat))) with + (inferInstance : Category (Grothendieck (F ⋙ Grpd.forgetToCat))) with Hom := Hom id := id comp := comp @@ -126,8 +126,8 @@ def objMk (c : C) (x : F.obj c) : ∫(F) where making a path in the fiber so that it does not show the composition with `Grpd.forgetToCat` -/ -def homMk {X Y : ∫(F)} (fb : X.base ⟶ Y.base) (ff : (F.map fb).obj X.fiber ⟶ Y.fiber) - : X ⟶ Y where +def homMk {X Y : ∫(F)} (fb : X.base ⟶ Y.base) (ff : (F.map fb).obj X.fiber ⟶ Y.fiber) : + X ⟶ Y where base := fb fiber := ff @@ -187,6 +187,8 @@ variable {C : Type u₁} [Groupoid.{v₁,u₁} C] {F : C ⥤ Grpd.{v₂,u₂}} instance (X : C) : Groupoid (F ⋙ Grpd.forgetToCat |>.obj X) where inv f := ((F.obj X).str').inv f + inv_comp f := (F.obj X).str'.inv_comp f + comp_inv f := (F.obj X).str'.comp_inv f /-- If `F : C ⥤ Grpd` is a functor and `t : c ⟶ d` is a morphism in `C`, @@ -236,7 +238,7 @@ lemma toTransport_id {X : ∫ F} : apply Grothendieck.toTransport_id lemma toTransport_eqToHom {X: C} {X' : ∫ F} (hX': forget.obj X' = X): - toTransport X' (eqToHom hX') = eqToHom (by subst hX'; simp [transport_id]) := by + toTransport X' (eqToHom hX') = eqToHom (by subst hX'; exact transport_id.symm) := by apply Grothendieck.toTransport_eqToHom lemma transport_comp (x : ∫ F) {c d : C} (t : x.base ⟶ c) (t' : c ⟶ d): @@ -378,8 +380,8 @@ variable {D : Type*} [Category D] theorem FunctorTo.hext (G H : D ⥤ ∫ F) (hbase : G ⋙ forget = H ⋙ forget) (hfiber_obj : ∀ x : D, HEq (G.obj x).fiber (H.obj x).fiber) - (hfiber_map : ∀ {x y : D} (f : x ⟶ y), HEq (G.map f).fiber (H.map f).fiber) - : G = H := + (hfiber_map : ∀ {x y : D} (f : x ⟶ y), HEq (G.map f).fiber (H.map f).fiber) : + G = H := Grothendieck.FunctorTo.hext _ _ hbase hfiber_obj hfiber_map end ext @@ -466,7 +468,9 @@ variable (hom_comp : ∀ c₁ c₂ c₃ (f : c₁ ⟶ c₂) (g : c₂ ⟶ c₃), functors on the fibers of `Groupoidal F`, a family of natural transformations on morphisms in the base of `Groupoidal F` and coherence data for this family of natural transformations. -/ def functorFrom : ∫(F) ⥤ E := - Grothendieck.functorFrom fib hom hom_id hom_comp + Grothendieck.functorFrom fib hom hom_id (by + intro c₁ c₂ c₃ f g + exact (hom_comp c₁ c₂ c₃ f g).trans (Category.assoc _ _ _).symm) @[simp] theorem functorFrom_obj (X : ∫(F)) : (functorFrom fib hom hom_id hom_comp).obj X = (fib X.base).obj X.fiber := by @@ -482,7 +486,7 @@ on `F` supplied as the first argument to `Groupoidal.functorFrom`. -/ def ιCompFunctorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) ≅ fib c := Grothendieck.ιCompFunctorFrom _ _ _ _ _ -def ι_comp_functorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) = fib c := +theorem ι_comp_functorFrom (c : C) : ι F c ⋙ (functorFrom fib hom hom_id hom_comp) = fib c := Grothendieck.ι_comp_functorFrom _ _ _ _ _ lemma whiskerRight_ιNatTrans_functorFrom {x y} (f : x ⟶ y) : @@ -498,7 +502,8 @@ variable {D : Type*} [Category D] def fib' (c) : (F ⋙ Grpd.forgetToCat).obj c ⥤ E := fib c variable {fib} in -def hom' {c c' : C} (f : c ⟶ c') : fib' fib c ⟶ (F ⋙ Grpd.forgetToCat).map f ⋙ fib' fib c' := +def hom' {c c' : C} (f : c ⟶ c') : + fib' fib c ⟶ ((F ⋙ Grpd.forgetToCat).map f).toFunctor ⋙ fib' fib c' := hom f variable (G : E ⥤ D) @@ -510,7 +515,8 @@ def functorFromCompFib (c : C) : F.obj c ⥤ D := functorFromCompFib' fib G c def functorFromCompHom' {c c' : C} (f : c ⟶ c') : - functorFromCompFib' fib G c ⟶ (F ⋙ Grpd.forgetToCat).map f ⋙ functorFromCompFib' fib G c' := + functorFromCompFib' fib G c ⟶ + ((F ⋙ Grpd.forgetToCat).map f).toFunctor ⋙ functorFromCompFib' fib G c' := Grothendieck.functorFromCompHom (fib' fib) (hom' hom) _ _ def functorFromCompHom {c c' : C} (f : c ⟶ c') : @@ -527,8 +533,10 @@ lemma functorFromCompHom_comp (c₁ c₂ c₃ : C) (f : c₁ ⟶ c₂) (g : c₂ functorFromCompHom fib (fun {c c'} ↦ hom) G (f ≫ g) = functorFromCompHom fib (fun {c c'} ↦ hom) G f ≫ Functor.whiskerLeft (F.map f) (functorFromCompHom fib hom G g) ≫ - eqToHom (by simp) := - Grothendieck.functorFromCompHom_comp _ _ hom_comp _ _ _ _ _ _ + eqToHom (by simp; exact (Functor.assoc _ _ _).symm) := + (Grothendieck.functorFromCompHom_comp (fib' fib) (hom' hom) + (fun c₁ c₂ c₃ f g => (hom_comp c₁ c₂ c₃ f g).trans (Category.assoc _ _ _).symm) + G c₁ c₂ c₃ f g).trans (Category.assoc _ _ _) lemma functorFromCompHom_eq {c c' : C} (f : c ⟶ c') : @@ -539,13 +547,14 @@ theorem functorFrom_comp' : functorFrom (fib' fib) (hom' hom) hom_id hom_comp ⋙ G = functorFrom (functorFromCompFib' fib G) (functorFromCompHom' fib hom G) (functorFromCompHom_id _ _ hom_id _) (functorFromCompHom_comp _ _ hom_comp _) := - Grothendieck.functorFrom_comp (fib' fib) (hom' hom) hom_id hom_comp G + Grothendieck.functorFrom_comp (fib' fib) (hom' hom) hom_id + (fun c₁ c₂ c₃ f g => (hom_comp c₁ c₂ c₃ f g).trans (Category.assoc _ _ _).symm) G theorem functorFrom_comp : functorFrom fib hom hom_id hom_comp ⋙ G = functorFrom (functorFromCompFib fib G) (functorFromCompHom fib hom G) (Grothendieck.functorFromCompHom_id _ _ hom_id _) - (Grothendieck.functorFromCompHom_comp _ _ hom_comp _) := + (functorFromCompHom_comp _ _ hom_comp _) := functorFrom_comp' fib hom hom_id hom_comp G variable (K : ∫(F) ⥤ E) @@ -564,7 +573,7 @@ lemma asFunctorFromFib_functorFrom : rw [ι_comp_functorFrom] lemma asFunctorFromHom' {c c' : C} (f: c ⟶ c') : - asFunctorFromHom K f = whiskerRight (ιNatTrans f) K := rfl + asFunctorFromHom K f = whiskerRight (ιNatTrans f) K := rfl lemma asFunctorFromHom_app {c c' : C} (f: c ⟶ c') (p : F.obj c) : (asFunctorFromHom K f).app p = K.map ((ιNatTrans f).app p) := @@ -578,7 +587,7 @@ lemma asFunctorFromHom_comp (c₁ c₂ c₃ : C) (f : c₁ ⟶ c₂) (g: c₂ asFunctorFromHom K (f ≫ g) = asFunctorFromHom K f ≫ Functor.whiskerLeft (F.map f) (asFunctorFromHom K g) ≫ eqToHom (by simp) := - Grothendieck.asFunctorFromHom_comp _ _ _ _ _ _ + (Grothendieck.asFunctorFromHom_comp K c₁ c₂ c₃ f g).trans (Category.assoc _ _ _) /-- Groupoidal version of `Grothendieck.asFunctorFrom` -/ theorem asFunctorFrom : functorFrom (asFunctorFromFib K) (asFunctorFromHom K) @@ -589,15 +598,15 @@ theorem functorFrom_ext {K K' : ∫(F) ⥤ E} (hfib : ∀ c, ι F c ⋙ K = ι F c ⋙ K') (hhom : ∀ {c c' : C} (f : c ⟶ c'), Functor.whiskerRight (ιNatTrans f) K ≫ eqToHom (by simp [Functor.assoc, hfib]) - = eqToHom (by rw[hfib]) ≫ Functor.whiskerRight (ιNatTrans f) K') - : K = K' := + = eqToHom (by rw[hfib]) ≫ Functor.whiskerRight (ιNatTrans f) K') : + K = K' := Grothendieck.functorFrom_ext hfib hhom theorem functorFrom_hext {K K' : ∫(F) ⥤ E} (hfib : ∀ c, ι F c ⋙ K = ι F c ⋙ K') (hhom : ∀ {c c' : C} (f : c ⟶ c'), Functor.whiskerRight (ιNatTrans f) K ≍ - Functor.whiskerRight (ιNatTrans f) K') - : K = K' := + Functor.whiskerRight (ιNatTrans f) K') : + K = K' := Grothendieck.functorFrom_hext hfib hhom section @@ -620,7 +629,9 @@ def functorIsoFrom (fib_comp : ∀ c, fib c ⋙ A = ι F c ⋙ forget) (map_hom_app : ∀ {c c'} (f : c ⟶ c') x, A.map ((hom f).app x) ≍ f) (fibMap_hom_app : ∀ {c c'} (f : c ⟶ c') x, fibMap ((hom f).app x) ≍ 𝟙 ((F.map f).obj x)) : ∫ F ≅≅ E := - Grothendieck.functorIsoFrom fib hom hom_id hom_comp A fibObj fibMap map_id map_comp + Grothendieck.functorIsoFrom fib hom hom_id + (fun c₁ c₂ c₃ f g => (hom_comp c₁ c₂ c₃ f g).trans (Category.assoc _ _ _).symm) + A fibObj fibMap map_id map_comp fib_comp fibObj_fib_obj fibMap_fib_map fib_obj_fibObj hom_map_app_fibObj obj_fib_obj map_hom_app fibMap_hom_app @@ -659,8 +670,8 @@ theorem map_forget (α : F ⟶ G) : map α ⋙ forget = forget := variable {X} {Y : ∫(F)} (f : X ⟶ Y) -@[simp] theorem map_map_base : ((Groupoidal.map α).map f).base = f.base - := Grothendieck.map_map_base _ _ +@[simp] theorem map_map_base : ((Groupoidal.map α).map f).base = f.base := + Grothendieck.map_map_base _ _ @[simp] theorem map_map_fiber : ((Groupoidal.map α).map f).fiber = @@ -760,14 +771,19 @@ lemma pre_comp (G : D ⥤ C) (H : E ⥤ D) : pre F (H ⋙ G) = pre (G ⋙ F) H theorem pre_comp_forget (α : D ⥤ C) (A : C ⥤ Grpd) : pre A α ⋙ forget = forget ⋙ α := rfl -@[simp] theorem ι_comp_pre {D : Type*} [Category D] (G : D ⥤ C) (x : D) - : ι (G ⋙ F) x ⋙ pre F G = ι F (G.obj x) := by +set_option backward.isDefEq.respectTransparency false in +@[simp] theorem ι_comp_pre {D : Type*} [Category D] (G : D ⥤ C) (x : D) : + ι (G ⋙ F) x ⋙ pre F G = ι F (G.obj x) := by apply FunctorTo.hext · rw [ι_comp_forget, Functor.assoc, pre_comp_forget, ← Functor.assoc, ι_comp_forget] apply Functor.ext <;> simp - · intro - simp - · simp + · intro; rfl + · intro _ _ f + dsimp only [ι, pre, functorTo] + change HEq ((Grothendieck.ι (G ⋙ (F ⋙ Grpd.forgetToCat)) x ⋙ + Grothendieck.pre (F ⋙ Grpd.forgetToCat) G).map f).fiber _ + rw [Grothendieck.ι_comp_pre] + rfl noncomputable section @@ -783,6 +799,7 @@ def invFiber : y.fiber ⟶ (F.map f.base).obj x.fiber := ← Groupoidal.comp_base]) ≫ (F.map f.base).map (CategoryTheory.inv f).fiber +set_option backward.isDefEq.respectTransparency false in @[simp] lemma fiber_comp_invFiber : f.fiber ≫ invFiber f = 𝟙 ((F.map f.base).obj x.fiber) := by have h := comp_fiber f (CategoryTheory.inv f) @@ -833,22 +850,17 @@ lemma comp_forget_naturality {α : F ⟶ G} {X Y : Γ} (f : X ⟶ Y) : lemma map_map_eqToHom {α : F ⟶ G} {X Y : ∫(F)} (f : X ⟶ Y) : ((G ⋙ Grpd.forgetToCat).map f.base).obj ((map α).obj X).fiber = (α.app Y.base).obj (((F ⋙ Grpd.forgetToCat).map f.base).obj X.fiber) := by - apply Eq.symm - have equ1 : - (α.app Y.base).obj ((Grpd.forgetToCat.map (F.map f.base)).obj X.fiber) = - ((Grpd.forgetToCat.map (F.map f.base)) ⋙ (α.app Y.base)).obj X.fiber := by simp - have equ2 : - (Grpd.forgetToCat.map (G.map f.base)).obj ((α.app X.base).obj X.fiber) = - ((α.app X.base) ⋙ (Grpd.forgetToCat.map (G.map f.base))).obj X.fiber := by simp - simp only [Functor.comp_obj, Functor.comp_map, map_obj_fiber] - rw[equ1, equ2] - refine Functor.congr_obj ?_ X.fiber - apply comp_forget_naturality + change (G.map f.base).obj ((α.app X.base).obj X.fiber) = + (α.app Y.base).obj ((F.map f.base).obj X.fiber) + exact (Functor.congr_obj (α.naturality f.base) X.fiber).symm @[simp] theorem eqToHom_comp_fiber {C : Type u} [Category.{v} C] {A : C ⥤ Grpd.{v₁, u₁}} {p q r : ∫(A)} (h : p = q) {f : q ⟶ r} : (eqToHom h ≫ f).fiber = eqToHom (by subst h; simp) ≫ f.fiber := by - simp [eqToHom_map] + subst h + simp only [eqToHom_refl] + rw! [Category.id_comp] + simp end @@ -866,6 +878,7 @@ variable {C : Type u} [Category.{v} C] {D : Type u₁} [Category.{v₁} D] theorem map_comp_eq {G H : C ⥤ Grpd.{v₂,u₂}} (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) = map α ⋙ map β := by simp [map, Grothendieck.map_comp_eq] + rfl theorem preNatIso_comp {G1 G2 G3 : D ⥤ C} (α : G1 ≅ G2) (β : G2 ≅ G3) : preNatIso F (α ≪≫ β) = preNatIso F α ≪≫ Functor.isoWhiskerLeft _ (preNatIso F β) ≪≫ @@ -877,66 +890,33 @@ end section variable {Γ : Type u} [Groupoid.{v} Γ] (A : Γ ⥤ Grpd.{v₁,u₁}) -theorem map_eqToHom_base {G1 G2 : ∫(A)} (eq : G1 = G2) - : A.map (eqToHom eq).base = eqToHom (by subst eq; simp) := by +theorem map_eqToHom_base {G1 G2 : ∫(A)} (eq : G1 = G2) : + A.map (eqToHom eq).base = eqToHom (by subst eq; simp) := by aesop_cat open CategoryTheory.Functor in /-- Every morphism `f : X ⟶ Y` in the base category induces a natural transformation from the fiber inclusion `ι F X` to the composition `F.map f ⋙ ι F Y`. -/ -def ιNatIso {X Y : Γ} (f : X ⟶ Y) : ι A X ≅ A.map f ⋙ ι A Y where - hom := ιNatTrans f - inv := whiskerLeft (A.map f) (ιNatTrans (Groupoid.inv f)) ≫ eqToHom (by - convert_to A.map (f ≫ Groupoid.inv f) ⋙ ι A X = ι A X - · simp only [Functor.map_comp, Grpd.comp_eq_comp, Functor.assoc] - · simp) - hom_inv_id := by - ext a - apply Groupoidal.Hom.hext - · simp - . simp only [NatTrans.comp_app, whiskerLeft_app, comp_base, comp_fiber, Grpd.map_comp_map, - Category.assoc, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, - NatTrans.id_app, id_fiber, eqToHom_comp_heq_iff] - -- FIXME: `transparency := default` is like `erw` and should be avoided - rw! (castMode := .all) (transparency := .default) - [eqToHom_app, map_eqToHom_base, Category.id_comp] - -- FIXME: `occs` is fragile - rw! (transparency := .default) (occs := .pos [4]) [Functor.map_id] - rw! (transparency := .default) [Category.id_comp] - simp only [eqToHom_refl, fiber_eqToHom, eqRec_heq_iff_heq] - -- these should be automated - apply HEq.trans (eqToHom_heq_id_cod _ _ _) - apply HEq.symm (eqToHom_heq_id_cod _ _ _) - inv_hom_id := by - ext a - apply Groupoidal.Hom.hext - · simp - . simp only [NatTrans.comp_app, whiskerLeft_app, comp_fiber, ιNatTrans_app_fiber, - map_comp, eqToHom_map, Category.assoc, eqToHom_trans_assoc, NatTrans.id_app, - id_fiber, eqToHom_comp_heq_iff] - -- FIXME: `transparency := default` is like `erw` and should be avoided - -- FIXME: `occs` is fragile - rw! (transparency := .default) (occs := .pos [6]) [Functor.map_id] - rw! (transparency := .default) (occs := .pos [4]) [Functor.map_id] - rw! (transparency := .default) [eqToHom_app] - simp only [comp_obj, fiber_eqToHom, eqToHom_map, Category.id_comp, id_base, - eqToHom_comp_heq_iff] - exact (eqToHom_heq_id_cod _ _ _).symm +def ιNatIso {X Y : Γ} (f : X ⟶ Y) : ι A X ≅ A.map f ⋙ ι A Y := + NatIso.ofComponents (fun a => isoMk ((ιNatTrans f).app a)) + (fun g => (ιNatTrans f).naturality g) theorem ιNatIso_hom {x y : Γ} (f : x ⟶ y) : (ιNatIso A f).hom = ιNatTrans f := by - simp [ιNatIso] + rfl @[simp] theorem ιNatIso_id (x : Γ) : ιNatIso A (𝟙 x) = eqToIso (by simp) := by ext simp [ιNatIso] + rfl theorem ιNatIso_comp {x y z : Γ} (f : x ⟶ y) (g : y ⟶ z) : ιNatIso A (f ≫ g) = ιNatIso A f ≪≫ Functor.isoWhiskerLeft (A.map f) (ιNatIso A g) ≪≫ eqToIso (by simp) := by ext simp [ιNatIso] + rfl end @@ -946,14 +926,9 @@ section lemma eqToHom_eq_homOf_map {Γ : Type*} [Groupoid Γ] {F G : Γ ⥤ Grpd} (h : F = G) : eqToHom (by rw [h]) = Grpd.homOf (map (eqToHom h)) := by subst h - fapply CategoryTheory.Functor.ext - · intro x - apply hext - · simp - · simp - · intro x y f - simp only [eqToHom_refl, Category.id_comp] - apply Hom.ext <;> simp + simp only [eqToHom_refl] + rw [map_id_eq] + rfl -- TODO factor through Grothendieck theorem map_eqToHom_heq_id_dom {Γ : Type*} [Category Γ] {A A' : Γ ⥤ Grpd} @@ -996,19 +971,25 @@ lemma fiber_eqToHom_comp_heq {Γ : Type*} [Category Γ] {F : Γ ⥤ Grpd} {x' x y : ∫ F} (h : x' = x) (f : x ⟶ y) : (eqToHom h ≫ f).fiber ≍ f.fiber := by subst h - simp [eqToHom_map] + simp only [eqToHom_refl] + rw! [Category.id_comp] + rfl lemma fiber_eq_eqToHom_comp_heq {Γ : Type*} [Category Γ] {F : Γ ⥤ Grpd} {x' x y : ∫ F} (g : x' ⟶ x) (h : x' = x) (hg : g = eqToHom h) (f : x ⟶ y) : (eqToHom h ≫ f).fiber ≍ f.fiber := by subst h - simp [eqToHom_map] + simp only [eqToHom_refl] + rw! [Category.id_comp] + rfl lemma fiber_comp_eqToHom_heq {Γ : Type*} [Category Γ] {F : Γ ⥤ Grpd} {x y y' : ∫ F} (h : y = y') (f : x ⟶ y) : (f ≫ eqToHom h).fiber ≍ f.fiber := by subst h - simp + simp only [eqToHom_refl] + rw! [Category.comp_id] + rfl end diff --git a/HoTTLean/Grothendieck/Groupoidal/IsPullback.lean b/HoTTLean/Grothendieck/Groupoidal/IsPullback.lean index 20f2df7c..99c1c8db 100644 --- a/HoTTLean/Grothendieck/Groupoidal/IsPullback.lean +++ b/HoTTLean/Grothendieck/Groupoidal/IsPullback.lean @@ -1,6 +1,8 @@ import HoTTLean.Pointed.IsPullback import HoTTLean.Grothendieck.Groupoidal.Basic +set_option backward.isDefEq.respectTransparency false + /-! # The Grothendieck construction as a pullback of categories @@ -27,6 +29,7 @@ universe v u v₁ u₁ v₂ u₂ v₃ u₃ namespace CategoryTheory attribute [local simp] eqToHom_map Grpd.id_eq_id Grpd.comp_eq_comp Functor.id_comp + Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor namespace Functor @@ -170,7 +173,7 @@ def sec : Γ ⥤ ∫(A) := ((sec A α h).map f).fiber = PGrpd.mapFiber' h f := rfl -@[simp] def sec_toPGrpd : sec A α h ⋙ toPGrpd _ = α := by +@[simp] theorem sec_toPGrpd : sec A α h ⋙ toPGrpd _ = α := by apply Grothendieck.FunctorTo.hext · rw [Functor.assoc, toPGrpd_forgetToGrpd, sec, ← Functor.assoc, h] rfl @@ -183,7 +186,7 @@ def sec : Γ ⥤ ∫(A) := rw! [eqToHom_comp_heq] simp -@[simp] def sec_forget : sec A α h ⋙ forget = 𝟭 _ := +@[simp] theorem sec_forget : sec A α h ⋙ forget = 𝟭 _ := rfl theorem sec_eq_lift : sec A α h = (isPullback A).lift α (𝟭 _) (by simp [h, Functor.id_comp]) := by diff --git a/HoTTLean/Grothendieck/IsPullback.lean b/HoTTLean/Grothendieck/IsPullback.lean index 7b02d643..68eb148e 100644 --- a/HoTTLean/Grothendieck/IsPullback.lean +++ b/HoTTLean/Grothendieck/IsPullback.lean @@ -1,11 +1,13 @@ import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.CategoryTheory.Limits.Preserves.Finite -import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq +import Mathlib.CategoryTheory.Limits.Shapes.Pullback.IsPullback.Basic import HoTTLean.Pointed.Basic import HoTTLean.ForMathlib import HoTTLean.ForMathlib.CategoryTheory.Functor.IsPullback +set_option backward.isDefEq.respectTransparency false + universe v u v₁ u₁ v₂ u₂ v₃ u₃ namespace CategoryTheory @@ -14,6 +16,9 @@ namespace Functor.Grothendieck open Functor.IsPullback +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + section @@ -23,7 +28,7 @@ variable (A) def toPCat : ∫ A ⥤ PCat.{v₁,u₁} := functorTo (forget _ ⋙ A) (fun x => x.fiber) (fun f => f.fiber) - (by simp) (by intros; simp) + (by simp) (by intros; simp; rfl) @[simp] theorem toPCat_obj_base (x) : ((toPCat A).obj x).base = A.obj x.base := by @@ -43,7 +48,7 @@ def toPCat : ∫ A ⥤ PCat.{v₁,u₁} := -- formerly duplicated as `toPCat_comp_forgetPoint` and `comm_sq` theorem toPCat_forgetToCat : toPCat A ⋙ PCat.forgetToCat - = Grothendieck.forget A ⋙ A := + = Grothendieck.forget A ⋙ A := rfl namespace IsPullback @@ -80,11 +85,12 @@ theorem liftMapFiber_comp {x y z} (f : x ⟶ y) (g : y ⟶ z) : eqToHom (by simp) ≫ (A.map (snd.map g)).map (liftMapFiber w f) ≫ liftMapFiber w g := by - have hgNatNatF := (eqToHom ((eqToHom w).naturality g).symm).naturality (fst.map f).fiber + have hgNatNatF := (eqToHom ((eqToHom w).naturality g).symm).toNatTrans.naturality + (fst.map f).fiber have h := congr_arg (λ x ↦ x ≫ ((eqToHom w).app z).map (fst.map g).fiber) hgNatNatF dsimp at h - simp only [Category.assoc, eqToHom_app ((eqToHom w).naturality g).symm] at h - simp [eqToHom_map, h] + simp only [Category.assoc, Cat.eqToHom_app] at h + simp [eqToHom_map, h, point] variable (fst) (snd) @@ -120,7 +126,7 @@ def lift : C ⥤ Grothendieck A := functorTo snd · intro x y f apply Grothendieck.Hom.ext · simp [eqToHom_map, PCat.eqToHom_base_map, - Functor.congr_hom (eqToHom_app w y) (point fst f)] + Functor.congr_hom (congrArg Cat.Hom.toFunctor (eqToHom_app w y)) (point fst f)] · have h := Functor.congr_hom w f simp only [PCat.forgetToCat_map, Functor.comp_map] at h simp [h] @@ -144,13 +150,15 @@ theorem hom_ext {m n : C ⥤ Grothendieck A} (hl : m ⋙ Grothendieck.toPCat A = n ⋙ Grothendieck.toPCat A) (hr : m ⋙ Grothendieck.forget A = n ⋙ Grothendieck.forget A) : m = n := by - rw [lift_uniq (m ⋙ toPCat A) (m ⋙ forget A) ?_ m rfl rfl, - lift_uniq (n ⋙ toPCat A) (n ⋙ forget A) ?_ n rfl rfl] - rw! [hl, hr] - . show n ⋙ (toPCat A ⋙ PCat.forgetToCat) = _ - rw [toPCat_forgetToCat, Functor.assoc] - . show m ⋙ (toPCat A ⋙ PCat.forgetToCat) = _ - rw [toPCat_forgetToCat, Functor.assoc] + have wm : (m ⋙ toPCat A) ⋙ PCat.forgetToCat = (m ⋙ forget A) ⋙ A := by + rw [Functor.assoc, toPCat_forgetToCat, ← Functor.assoc] + have wn : (n ⋙ toPCat A) ⋙ PCat.forgetToCat = (n ⋙ forget A) ⋙ A := by + rw [Functor.assoc, toPCat_forgetToCat, ← Functor.assoc] + calc + m = lift _ _ wm := lift_uniq _ _ wm m rfl rfl + _ = lift _ _ wn := by simp only [hl, hr] + _ = n := (lift_uniq _ _ wn n rfl rfl).symm + def aux {C : Type*} [inst : Category C] (Cn : C ⥤ PCat) (Cw : C ⥤ Γ) (hC : Cn ⋙ forget (𝟭 Cat) = Cw ⋙ A) : @@ -163,7 +171,7 @@ def aux {C : Type*} [inst : Category C] (Cn : C ⥤ PCat) (Cw : C ⥤ Γ) end IsPullback -open IsPullback +open CategoryTheory.Functor.Grothendieck.IsPullback /-- The following square is a (meta-theoretic) pullback of functors @@ -288,14 +296,16 @@ end -- (s.snd ⋙ downFunctor) -- condition' --- theorem lift_uniq (s : PullbackCone uLiftPCatForgetToCat.{v,u} (uLiftA.{v,u} A)) (m : s.pt ⥤ Grothendieck A) +-- theorem lift_uniq (s : PullbackCone uLiftPCatForgetToCat.{v,u} (uLiftA.{v,u} A)) +-- (m : s.pt ⥤ Grothendieck A) -- (hl : m ⋙ Grothendieck.toPCat A = s.fst ⋙ downFunctor) -- (hr : m ⋙ Grothendieck.forget A = s.snd ⋙ downFunctor) : -- m = lift s := -- IsMegaPullback.lift_uniq -- (s.fst ⋙ downFunctor) (s.snd ⋙ downFunctor) condition' m hl hr --- theorem lift_uniq' (s : PullbackCone uLiftPCatForgetToCat.{v,u} (uLiftA.{v,u} A)) (m : s.pt ⟶ uLiftGrothendieck A) +-- theorem lift_uniq' (s : PullbackCone uLiftPCatForgetToCat.{v,u} (uLiftA.{v,u} A)) +-- (m : s.pt ⟶ uLiftGrothendieck A) -- (hl : m ≫ uLiftToPCat A = s.fst) (hr : m ≫ uLiftGrothendieckForget A = s.snd) : -- m = lift' s := by -- unfold lift' @@ -312,7 +322,7 @@ end -- end IsPullback --- open IsPullback +-- open CategoryTheory.Functor.Grothendieck.IsPullback -- /- -- The following square is a pullback diff --git a/HoTTLean/Groupoids/Basic.lean b/HoTTLean/Groupoids/Basic.lean index c5dedf2c..6ad5655e 100644 --- a/HoTTLean/Groupoids/Basic.lean +++ b/HoTTLean/Groupoids/Basic.lean @@ -11,6 +11,8 @@ import HoTTLean.ForMathlib.CategoryTheory.FreeGroupoid Here we construct universes for the groupoid natural model. -/ +set_option backward.isDefEq.respectTransparency false + universe w v u v₁ u₁ v₂ u₂ v₃ u₃ noncomputable section @@ -21,7 +23,7 @@ namespace CategoryTheory.PGrpd def pGrpdToGroupoidalAsSmallFunctor : PGrpd.{v, v} ⥤ ∫(Grpd.asSmallFunctor.{w, v, v}) := Grothendieck.functorTo PGrpd.forgetToGrpd - (fun x => AsSmall.up.obj.{v, v, w} x.fiber) + (fun x => AsSmall.up.obj x.fiber) (fun f => AsSmall.up.map f.fiber) (by aesop_cat) (by aesop_cat) @@ -29,20 +31,20 @@ def pGrpdToGroupoidalAsSmallFunctor : PGrpd.{v, v} ⥤ def groupoidalAsSmallFunctorToPGrpd : ∫(Grpd.asSmallFunctor.{w, v, v}) ⥤ PGrpd.{v,v} := PGrpd.functorTo Groupoidal.forget - (fun x => AsSmall.down.obj.{v, v, w} x.fiber) + (fun x => AsSmall.down.obj x.fiber) (fun f => AsSmall.down.map f.fiber) (by aesop_cat) (by aesop_cat) -@[simp] def pGrpdToGroupoidalAsSmallFunctor_groupoidalAsSmallFunctorToPGrpd : +@[simp] theorem pGrpdToGroupoidalAsSmallFunctor_groupoidalAsSmallFunctorToPGrpd : groupoidalAsSmallFunctorToPGrpd ⋙ pGrpdToGroupoidalAsSmallFunctor = 𝟭 _ := rfl -@[simp] def groupoidalAsSmallFunctorToPGrpd_pGrpdToGroupoidalAsSmallFunctor : +@[simp] theorem groupoidalAsSmallFunctorToPGrpd_pGrpdToGroupoidalAsSmallFunctor : pGrpdToGroupoidalAsSmallFunctor ⋙ groupoidalAsSmallFunctorToPGrpd = 𝟭 _ := rfl -@[simp] def pGrpdToGroupoidalAsSmallFunctor_forget : pGrpdToGroupoidalAsSmallFunctor +@[simp] theorem pGrpdToGroupoidalAsSmallFunctor_forget : pGrpdToGroupoidalAsSmallFunctor ⋙ Groupoidal.forget = PGrpd.forgetToGrpd := rfl diff --git a/HoTTLean/Groupoids/ClovenIsofibration.lean b/HoTTLean/Groupoids/ClovenIsofibration.lean index e78e16d8..6294050a 100644 --- a/HoTTLean/Groupoids/ClovenIsofibration.lean +++ b/HoTTLean/Groupoids/ClovenIsofibration.lean @@ -2,12 +2,14 @@ import Mathlib.CategoryTheory.FiberedCategory.HomLift import Mathlib.CategoryTheory.FiberedCategory.Fiber import HoTTLean.Grothendieck.Groupoidal.IsPullback import HoTTLean.Grothendieck.Groupoidal.Basic -import HoTTLean.Groupoids.Pi +import HoTTLean.Groupoids.UnstructuredModel universe w v u v₁ u₁ v₂ u₂ v₃ u₃ noncomputable section +set_option backward.isDefEq.respectTransparency false + namespace CategoryTheory namespace Functor @@ -26,8 +28,8 @@ lemma functor_obj_fiberInclusion_obj (a : Fiber p S) : lemma functor_map_fiberInclusion_map {a b : Fiber p S} (f : a ⟶ b) : p.map (Fiber.fiberInclusion.map f) = eqToHom (by simp) := by - have H := f.2 - simpa using IsHomLift.fac' p (𝟙 S) f.1 + have : IsHomLift p (𝟙 S) f.1 := f.2 + simpa [Fiber.fiberInclusion] using IsHomLift.fac' p (𝟙 S) f.1 lemma hext {S'} (hS : S' ≍ S) {a : Fiber p S} {a' : Fiber p S'} (h : Fiber.fiberInclusion.obj a ≍ Fiber.fiberInclusion.obj a') : a ≍ a' := by @@ -152,8 +154,9 @@ def classifier.map.map {X Y} (f: X ⟶ Y) {a b : F.Fiber X} (m : a ⟶ b) : let i2 := I.liftIso f b.2 let i := Groupoid.inv i1 ≫ Fiber.fiberInclusion.map m ≫ i2 have e :𝟙 Y = eqToHom (by simp[obj_liftObj]) ≫ - F.map (CategoryTheory.inv i1 ≫ Fiber.fiberInclusion.map m ≫ i2) ≫ eqToHom (by simp[obj_liftObj]) - := by simp[i1, i2, Fiber.functor_map_fiberInclusion_map, Functor.map_inv,map_liftIso'] + F.map (CategoryTheory.inv i1 ≫ Fiber.fiberInclusion.map m ≫ i2) ≫ + eqToHom (by simp[obj_liftObj]) := by + simp[i1, i2, Fiber.functor_map_fiberInclusion_map, Functor.map_inv,map_liftIso'] have : F.IsHomLift (𝟙 Y) i := by simp only[i, e] apply IsHomLift.of_fac _ _ _ (ClovenIsofibration.obj_liftObj ..) @@ -162,14 +165,14 @@ def classifier.map.map {X Y} (f: X ⟶ Y) {a b : F.Fiber X} (m : a ⟶ b) : Fiber.homMk F _ i lemma classifier.map.map_id {X Y} (f : X ⟶ Y) (a: F.Fiber X): - map.map I f (𝟙 a) = 𝟙 (map.obj I f a) := by + map.map I f (𝟙 a) = 𝟙 (map.obj I f a) := by ext simp only [map, Fiber.fiberInclusion_homMk, Groupoid.inv_eq_inv, Functor.map_id, IsIso.inv_comp_eq] simp [Fiber.fiberInclusion, classifier.map.obj] lemma classifier.map.map_comp {X Y} (f: X ⟶ Y) {a b c: F.Fiber X} (m1 : a ⟶ b) (m2: b ⟶ c): - map.map I f (m1 ≫ m2) = map.map I f m1 ≫ map.map I f m2 := by + map.map I f (m1 ≫ m2) = map.map I f m1 ≫ map.map I f m2 := by ext simp[classifier.map.map] @@ -193,7 +196,7 @@ lemma classifier.map_id (X : Γ) : classifier.map I (𝟙 X) = 𝟙 (Grpd.of (F. simp [map.map, liftIso_id, eqToHom_map] lemma classifier.map_comp {X Y Z: Γ} (f : X⟶ Y) (g : Y ⟶ Z): - classifier.map I (f ≫ g) = classifier.map I f ⋙ classifier.map I g := by + classifier.map I (f ≫ g) = classifier.map I f ⋙ classifier.map I g := by fapply Functor.ext · intro a simp[map.obj, liftObj_comp] @@ -226,7 +229,7 @@ lemma grothendieckClassifierIso.hom.map_aux {X Y: Γ} (f: X ⟶ Y) (a: I.classif simp[classifier,classifier.map.obj] lemma grothendieckClassifierIso.hom.map_aux2 - (X: Γ) (a: I.classifier.obj X) : F.obj a.1 = X := by + (X: Γ) (a: I.classifier.obj X) : F.obj a.1 = X := by simp[classifier] at a simp[a.2] @@ -243,8 +246,11 @@ def grothendieckClassifierIso.hom.map' {p1 p2: ∫ I.classifier} (h: p1 ⟶ p2) lemma grothendieckClassifierIso.hom.map_id (X : ∫ I.classifier) : hom.map I (𝟙 X) = 𝟙 _ := by - convert_to _ ≫ _ ≫ Fiber.fiberInclusion.map (Hom.fiber (𝟙 X)) = _ - simp [liftIso_id, eqToHom_map] + have hmap {a b : F.Fiber X.base} (h : a = b) : + (eqToHom h : a ⟶ b).1 = eqToHom (congrArg Subtype.val h) := by + subst h + rfl + simp [grothendieckClassifierIso.hom.map, id_fiber, liftIso_id, hmap] lemma grothendieckClassifierIso.hom.map_comp {X Y Z: ∫ I.classifier} (f : X ⟶ Y) (g : Y ⟶ Z) : hom.map' I (f ≫ g) = hom.map' I f ≫ hom.map' I g := by @@ -265,7 +271,7 @@ def grothendieckClassifierIso.hom : ∫ I.classifier ⥤ E := (by intro X Y Z f g; ext; simp[hom.hom,liftIso_comp]) def grothendieckClassifierIso.inv.fibMap {X Y}(f : X ⟶ Y) : - ((F ⋙ I.classifier).map f).obj ⟨X,rfl⟩ ⟶ ⟨Y, rfl⟩ := by + ((F ⋙ I.classifier).map f).obj ⟨X,rfl⟩ ⟶ ⟨Y, rfl⟩ := by refine @Fiber.homMk _ _ _ _ F (F.obj Y) _ _ ?_ ?_ · exact CategoryTheory.inv (I.liftIso (F.map f) rfl) ≫ f · simp @@ -304,6 +310,7 @@ lemma liftObj_map_fiberInclusion_map {S} {X Y : Fiber F S} {X' : E} (f : X ⟶ Y I.liftObj (F.map (Fiber.fiberInclusion.map f)) (X' := X') (by simp [hX']) = Fiber.fiberInclusion.obj X := by rw! [Fiber.functor_map_fiberInclusion_map, liftObj_eqToHom, hX'] + rfl @[simp] lemma liftIso_map_fiberInclusion_map {S} {X Y : Fiber F S} {X' : E} (f : X ⟶ Y) @@ -311,6 +318,7 @@ lemma liftIso_map_fiberInclusion_map {S} {X Y : Fiber F S} {X' : E} (f : X ⟶ Y I.liftIso (F.map (Fiber.fiberInclusion.map f)) (X' := X') (by simp [hX']) = eqToHom (by simp [hX']) := by rw! [Fiber.functor_map_fiberInclusion_map, liftIso_eqToHom] + rfl open grothendieckClassifierIso in /-- A split isofibration `F : E ⥤ Γ` is classified by the functor `I.classifier : Γ ⥤ Grpd`. @@ -348,7 +356,9 @@ def grothendieckClassifierIso : ∫ I.classifier ≅≅ E := any_goals simp · rw! [map_liftIso', liftObj_comp _ _ _ rfl, liftObj_comp _ _ _ rfl] simp [liftObj_eqToHom] - · rw! [map_liftIso', liftIso_comp _ _ _ rfl, liftIso_comp _ _ _ rfl] + · simp only [grothendieckClassifierIso.hom.hom] + rw! (castMode := .all) [map_liftIso', liftIso_comp _ _ _ rfl, + liftIso_comp _ _ _ rfl] simp only [liftIso_eqToHom, eqToHom_refl, eqToHom_trans, Category.id_comp, Category.assoc, IsIso.inv_comp, inv_eqToHom, eqToHom_comp_liftIso, IsIso.inv_hom_id_assoc] rw! [eqToHom_heq_id_cod] @@ -382,7 +392,8 @@ def iso {A : Type u} [Category.{v} A] {B : Type u₁} [Category.{v₁} B] (F : A intro X Y f i X' hX' apply IsIso.comp_isIso -instance {A : Type u} [Category.{v} A] {B : Type u₁} [Category.{v₁} B] (F : A ≅≅ B) : IsSplit (iso F) where +instance {A : Type u} [Category.{v} A] {B : Type u₁} [Category.{v₁} B] + (F : A ≅≅ B) : IsSplit (iso F) where liftObj_id h := by simp [← h, ← Functor.comp_obj] liftIso_id := by simp liftObj_comp := by simp @@ -405,7 +416,7 @@ lemma forget.isHomLift {X Y: C} (f : X ⟶ Y) {X' : F.Groupoidal} apply IsHomLift.of_fac' (ha := hX') (hb := by simp[liftObj]) simp[liftIso] -def toTransport_IsIso (x : F.Groupoidal) {c : C} (t : x.base ⟶ c) : +theorem toTransport_IsIso (x : F.Groupoidal) {c : C} (t : x.base ⟶ c) : IsIso (Groupoidal.toTransport x t) := inferInstance @@ -421,15 +432,15 @@ instance {X Y: C} (f : X ⟶ Y) [IsIso f] {X' : F.Groupoidal} (hX': Groupoidal.forget.obj X' = X) : IsIso (forget.liftIso f hX') := by apply toTransport_IsIso -def forget.liftObj_id {X: C} {X' : F.Groupoidal} (hX': Groupoidal.forget.obj X' = X) : +theorem forget.liftObj_id {X: C} {X' : F.Groupoidal} (hX': Groupoidal.forget.obj X' = X) : forget.liftObj (𝟙 X) hX' = X' := by simp [liftObj, Groupoidal.transport_eqToHom] -def forget.liftIso_id {X: C} {X' : F.Groupoidal} (hX': Groupoidal.forget.obj X' = X) : +theorem forget.liftIso_id {X: C} {X' : F.Groupoidal} (hX': Groupoidal.forget.obj X' = X) : forget.liftIso (𝟙 X) hX' = eqToHom (by simp [forget.liftObj_id]) := by dsimp [liftIso] rw! (castMode :=.all)[Category.comp_id] - simp only [Groupoidal.toTransport_eqToHom, ← heq_eq_eq, eqRec_heq_iff_heq] + simp only [Groupoidal.toTransport_eqToHom, ← heq_eq_eq, eqRec_heq_iff] congr! lemma forget.liftObj_comp {X Y Z: C} (f : X ⟶ Y) (g : Y ⟶ Z) @@ -440,13 +451,14 @@ lemma forget.liftObj_comp {X Y Z: C} (f : X ⟶ Y) (g : Y ⟶ Z) simp only [Groupoidal.transport, Grothendieck.transport, comp_obj, comp_map] fapply Grothendieck.ext · simp - simp only [Grpd.forgetToCat, Cat.of_α, id_eq, comp_obj, eqToHom_refl, comp_map, map_id, - Grpd.id_eq_id, id_obj] + simp only [Grpd.forgetToCat, Cat.of_α, comp_obj, eqToHom_refl, comp_map, map_id, + Grpd.id_eq_id, id_obj, Cat.Hom.obj, Functor.toCatHom_toFunctor] congr! - simp only [← comp_obj,← Grpd.comp_eq_comp,← Functor.map_comp] + simp only [← comp_obj, ← Grpd.comp_eq_comp, ← Functor.map_comp] rw! [eqToHom_map] subst hY' simp [liftObj,Groupoidal.transport] + rfl lemma forget.liftIso_comp {X Y Z: C} (f : X ⟶ Y) (g : Y ⟶ Z) {X' : F.Groupoidal} (hX' : X'.base = X) {Y' : F.Groupoidal} (hY' : forget.liftObj f hX' = Y') : @@ -534,7 +546,7 @@ lemma comp.liftIso_id {X : C} {X' : A} (hX' : (F ⋙ G).obj X' = X) : comp.liftIso IF IG (𝟙 X) hX' = eqToHom (by simp[comp.liftObj_id]) := by dsimp [comp.liftIso] rw! (castMode := .all) [IsSplit.liftIso_id] - simp only [liftIso_eqToHom, ← heq_eq_eq, eqRec_heq_iff_heq] + simp only [liftIso_eqToHom, ← heq_eq_eq, eqRec_heq_iff] apply HEq.trans (eqToHom_heq_id_dom _ _ _) (eqToHom_heq_id_dom _ _ _).symm lemma comp.liftObj_comp {X Y Z : C} (f : X ⟶ Y) [IsIso f] (g : Y ⟶ Z) [IsIso g] {X' : A} diff --git a/HoTTLean/Groupoids/Id.lean b/HoTTLean/Groupoids/Id.lean index 6b418552..2d9dcd83 100644 --- a/HoTTLean/Groupoids/Id.lean +++ b/HoTTLean/Groupoids/Id.lean @@ -8,8 +8,16 @@ universe w v u v₁ u₁ v₂ u₂ noncomputable section +set_option backward.isDefEq.respectTransparency false + open CategoryTheory +attribute [local implicit_reducible] Grpd Grpd.Interval + CategoryTheory.Functor.Groupoidal CategoryTheory.Prod.sectR +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + PGrpd.forgetToGrpd_map + namespace FunctorOperation variable {Γ : Type u} [Groupoid.{v} Γ] {Δ : Type u₂} [Groupoid.{v₂} Δ] (σ : Δ ⥤ Γ) @@ -38,11 +46,11 @@ lemma IdMap_comp {X Y Z : Γ} (f1 : X ⟶ Y) (f2 : Y ⟶ Z) : IdMap a0_tp a1_tp apply Discrete.functor_ext intro g apply Discrete.ext - simp only [Functor.comp_obj, Functor.Grothendieck.forget_obj, PGrpd.objFiber'_rfl, IdMap, - Functor.comp_map, Functor.Grothendieck.forget_map, PGrpd.mapFiber'_rfl, + simp only [Functor.comp_obj, PGrpd.objFiber'_rfl, IdMap, + Functor.comp_map, PGrpd.mapFiber'_rfl, Discrete.functor_obj_eq_as, Functor.map_comp, Functor.map_inv, Category.assoc, IsIso.eq_inv_comp] - simp only [PGrpd.mapFiber, PGrpd.map_comp_fiber, Functor.Grothendieck.forget_obj, + simp only [PGrpd.mapFiber, PGrpd.map_comp_fiber, Functor.Grothendieck.forget_map, ← Category.assoc, IsIso.inv_comp, inv_eqToHom, PGrpd.mapFiber', Functor.comp_obj, Functor.comp_map, PGrpd.objFiber'EqToHom, PGrpd.mapFiber'EqToHom, Functor.map_comp, eqToHom_map, eqToHom_trans, IsIso.hom_inv_id, @@ -50,15 +58,17 @@ lemma IdMap_comp {X Y Z : Γ} (f1 : X ⟶ Y) (f2 : Y ⟶ Z) : IdMap a0_tp a1_tp Category.comp_id, ← heq_eq_eq] congr 1 rw! [Functor.map_comp] - simp only [Functor.Grothendieck.Hom.comp_base, Grpd.comp_eq_comp, Functor.comp_obj, - eqToHom_refl, Functor.comp_map, Category.id_comp, Category.assoc, ← heq_eq_eq] + simp only [ + eqToHom_refl, Category.id_comp, Category.assoc, ← heq_eq_eq] congr 1 have h := Functor.congr_hom a1_tp f2 - simp only [Functor.comp_obj, Functor.Grothendieck.forget_obj, Functor.comp_map, + simp only [Functor.comp_obj, Functor.comp_map, Functor.Grothendieck.forget_map, Grpd.comp_eq_comp] at h - rw! [h] + rw! (castMode := .all) [h] simp only [← Grpd.comp_eq_comp, Grpd.comp_obj, ← Functor.comp_map, ← heq_eq_eq, - heq_eqToHom_comp_iff, heq_comp_eqToHom_iff, eqToHom_comp_heq_iff] + eqToHom_comp_heq_iff] + simp [Grpd.eqToHom_hom, PGrpd.forgetToGrpd_map] at * + rw! (castMode := .all) [h] simp [Grpd.eqToHom_hom] @[simps!] @@ -68,6 +78,8 @@ def Id : Γ ⥤ Grpd where map_id := IdMap_id a0_tp a1_tp map_comp := IdMap_comp a0_tp a1_tp +attribute [local implicit_reducible] Id + lemma Id_comp : Id (A := σ ⋙ A) (a0 := σ ⋙ a0) (a1 := σ ⋙ a1) (by simp[Functor.assoc, a0_tp]) (by simp[Functor.assoc, a1_tp]) = σ ⋙ Id a0_tp a1_tp := @@ -107,6 +119,7 @@ lemma path1_comp_forgetToGrpd : path1 p ⋙ PGrpd.forgetToGrpd = A := by lemma objFiber'_path0 (x) : PGrpd.objFiber' (path0_comp_forgetToGrpd p_tp) x = PGrpd.objFiber' p_tp (ff x) := by dsimp [PGrpd.objFiber', PGrpd.objFiber] + rfl @[simp] abbrev pathId : Γ ⥤ Grpd := @@ -122,9 +135,10 @@ lemma pathFibObj_comp (x : Δ) : pathFibObj (A := σ ⋙ A) (p := Functor.prod ( (by simp [Functor.assoc, p_tp]; rfl) x = pathFibObj p_tp (σ.obj x) := by apply Discrete.ext simp only [Functor.comp_obj, pathFibObj_as, Functor.comp_map, PGrpd.mapFiber', snd_obj, snd_map, - Functor.prod_obj, Functor.id_obj, Functor.Grothendieck.forget_obj, PGrpd.objFiber'EqToHom, + Functor.prod_obj, Functor.id_obj, PGrpd.objFiber'EqToHom, Functor.prod_map, Functor.id_map, PGrpd.mapFiber'EqToHom, Grpd.eqToHom_hom, eqToHom_trans_assoc] rw! [CategoryTheory.Functor.map_id] + rfl lemma IdMap_path {x y} (f : x ⟶ y) : ((IdMap (path0_comp_forgetToGrpd p_tp) (path1_comp_forgetToGrpd p_tp) f).obj @@ -136,16 +150,18 @@ lemma IdMap_path {x y} (f : x ⟶ y) : simp only [Functor.comp_obj, snd_obj, prod_comp, Functor.comp_map, snd_map, Grpd.map_id_map, Category.assoc, eqToHom_trans_assoc, ← heq_eq_eq, heq_eqToHom_comp_iff, eqToHom_comp_heq_iff] at h1 - simp only [PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.false⟩⟩ _), sectR_obj, sectR_map, - Functor.map_comp, eqToHom_map, PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.true⟩⟩ _), - Category.assoc, IsIso.inv_comp_eq] - rw! [h1] - simp + simp only [PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.false⟩⟩ _), + PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.true⟩⟩ _), + IsIso.inv_comp_eq] + dsimp only [pathFibObj, ffm, ttm, ft, CategoryTheory.Prod.sectR] at h1 ⊢ + apply eq_of_heq + simp only [Functor.map_comp, eqToHom_map, Category.assoc] + exact (eqToHom_comp_heq ..).trans h1 def pathFibMap {x y : Γ} (f : x ⟶ y) : (IdMap (path0_comp_forgetToGrpd p_tp) (path1_comp_forgetToGrpd p_tp) f).obj (pathFibObj p_tp x) ⟶ pathFibObj p_tp y := - ⟨⟨IdMap_path ..⟩⟩ + ⟨IdMap_path ..⟩ lemma pathFibMap_id (x : Γ) : pathFibMap p_tp (𝟙 x) = eqToHom (by simp [IdMap_id]) := by aesop_cat @@ -158,7 +174,7 @@ lemma pathFibMap_comp {x y z : Γ} (f1 : x ⟶ y) (f2 : y ⟶ z) : def path : Γ ⥤ PGrpd := PGrpd.functorTo (pathId p_tp) (pathFibObj p_tp) (pathFibMap p_tp) - (pathFibMap_id p_tp) (fun f1 f2 => by dsimp only; aesop_cat) + (pathFibMap_id p_tp) (pathFibMap_comp p_tp) lemma path_comp : path (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) (by simp [Functor.assoc, p_tp]; rfl) = σ ⋙ path p_tp := by @@ -168,14 +184,14 @@ lemma path_comp : path (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) · intro x simp only [path, Functor.comp_obj, heq_eq_eq] -- rw [PGrpd.functorTo_obj_fiber] --FIXME why timeout? - convert_to pathFibObj (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) + change pathFibObj (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) (by simp [Functor.assoc, p_tp]; rfl) x = pathFibObj (A := A) (p := p) p_tp (σ.obj x) rw [pathFibObj_comp] · intro x y f simp only [path, Functor.comp_map] -- rw [PGrpd.functorTo_map_fiber] - convert_to pathFibMap (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) + change pathFibMap (A := σ ⋙ A) (p := Functor.prod (𝟭 _) σ ⋙ p) (by simp [Functor.assoc, p_tp]; rfl) f ≍ pathFibMap (A := A) (p := p) p_tp (σ.map f) rw! (castMode := .all) [pathFibObj_comp _ p_tp] @@ -196,16 +212,17 @@ variable {p : Γ ⥤ PGrpd} (p_tp : p ⋙ PGrpd.forgetToGrpd = FunctorOperation.Id a0_tp a1_tp) def unpathFibObj : (x : Grpd.Interval × Γ) → A.obj x.2 -| ⟨⟨⟨.false⟩⟩, x2⟩ => PGrpd.objFiber' a0_tp x2 -| ⟨⟨⟨.true⟩⟩, x2⟩ => PGrpd.objFiber' a1_tp x2 + | ⟨⟨⟨.false⟩⟩, x2⟩ => PGrpd.objFiber' a0_tp x2 + | ⟨⟨⟨.true⟩⟩, x2⟩ => PGrpd.objFiber' a1_tp x2 def unpathFibMap : {x y : Grpd.Interval × Γ} → (f : x ⟶ y) → ((A.map f.2).obj (unpathFibObj a0_tp a1_tp x) ⟶ unpathFibObj a0_tp a1_tp y) -| ⟨⟨⟨.false⟩⟩, _⟩, ⟨⟨⟨.false⟩⟩, _⟩, f => PGrpd.mapFiber' a0_tp f.2 -| ⟨⟨⟨.false⟩⟩, _⟩, ⟨⟨⟨.true⟩⟩, y2⟩, f => (PGrpd.mapFiber' a0_tp f.2) ≫ (PGrpd.objFiber' p_tp y2).1 -| ⟨⟨⟨.true⟩⟩, _⟩, ⟨⟨⟨.false⟩⟩, y2⟩, f => - (PGrpd.mapFiber' a1_tp f.2) ≫ inv (PGrpd.objFiber' p_tp y2).1 -| ⟨⟨⟨.true⟩⟩, _⟩, ⟨⟨⟨.true⟩⟩, _⟩, f => PGrpd.mapFiber' a1_tp f.2 + | ⟨⟨⟨.false⟩⟩, _⟩, ⟨⟨⟨.false⟩⟩, _⟩, f => PGrpd.mapFiber' a0_tp f.2 + | ⟨⟨⟨.false⟩⟩, _⟩, ⟨⟨⟨.true⟩⟩, y2⟩, f => + (PGrpd.mapFiber' a0_tp f.2) ≫ (PGrpd.objFiber' p_tp y2).1 + | ⟨⟨⟨.true⟩⟩, _⟩, ⟨⟨⟨.false⟩⟩, y2⟩, f => + (PGrpd.mapFiber' a1_tp f.2) ≫ inv (PGrpd.objFiber' p_tp y2).1 + | ⟨⟨⟨.true⟩⟩, _⟩, ⟨⟨⟨.true⟩⟩, _⟩, f => PGrpd.mapFiber' a1_tp f.2 lemma unpathFibMap_id (x : Grpd.Interval × Γ) : unpathFibMap a0_tp a1_tp p_tp (𝟙 x) = eqToHom (by simp) := by @@ -215,7 +232,7 @@ open PGrpd in lemma map_objFiber'_mapFiber' {x y} (f : x ⟶ y) : (A.map f).map (objFiber' p_tp x).as ≫ mapFiber' a1_tp f = mapFiber' a0_tp f ≫ (objFiber' p_tp y).as := by - simpa using (mapFiber' p_tp f).1.1 + simpa using (mapFiber' p_tp f).eq open PGrpd in lemma map_objFiber'_mapFiber'_inv_objFiber' {x y} (f : x ⟶ y) : @@ -265,11 +282,13 @@ lemma sectR_false_comp_unpath : sectR ⟨⟨.false⟩⟩ _ ⋙ unpath a0_tp a1_t · rw [Functor.assoc, unpath, Functor.Grothendieck.functorTo_forget, ← Functor.assoc, sectR_comp_snd, a0_tp, Functor.id_comp] · intro x - simp [unpath, PGrpd.objFiber', PGrpd.objFiber, Grpd.eqToHom_obj] + simp only [Functor.comp_obj, unpath, + Functor.Grothendieck.functorTo_obj_fiber, unpathFibObj] + exact PGrpd.objFiber'_heq a0_tp · intro x y f - simp [unpath, PGrpd.mapFiber', PGrpd.mapFiber'EqToHom, Grpd.eqToHom_hom] - apply HEq.trans (eqToHom_comp_heq _ _) - simp + simp only [Functor.comp_map, unpath, + Functor.Grothendieck.functorTo_map_fiber, unpathFibMap] + exact PGrpd.mapFiber'_heq a0_tp f @[simp] lemma sectR_true_comp_unpath : sectR ⟨⟨.true⟩⟩ _ ⋙ unpath a0_tp a1_tp p_tp = a1 := by @@ -277,27 +296,21 @@ lemma sectR_true_comp_unpath : sectR ⟨⟨.true⟩⟩ _ ⋙ unpath a0_tp a1_tp · rw [Functor.assoc, unpath, Functor.Grothendieck.functorTo_forget, ← Functor.assoc, sectR_comp_snd, a1_tp, Functor.id_comp] · intro x - simp [unpath, PGrpd.objFiber', PGrpd.objFiber, Grpd.eqToHom_obj] + simp only [Functor.comp_obj, unpath, + Functor.Grothendieck.functorTo_obj_fiber, unpathFibObj] + exact PGrpd.objFiber'_heq a1_tp · intro x y f - simp [unpath, PGrpd.mapFiber', PGrpd.mapFiber'EqToHom, Grpd.eqToHom_hom] - apply HEq.trans (eqToHom_comp_heq _ _) - simp + simp only [Functor.comp_map, unpath, + Functor.Grothendieck.functorTo_map_fiber, unpathFibMap] + exact PGrpd.mapFiber'_heq a1_tp f lemma path0_unpath : path0 (unpath a0_tp a1_tp p_tp) = a0 := by - apply Functor.Grothendieck.FunctorTo.hext - · simp - · intro x - simpa [unpath] using PGrpd.objFiber'_heq a0_tp - · intro x y f - simpa [unpath] using PGrpd.mapFiber'_heq a0_tp f + change sectR ⟨⟨.false⟩⟩ _ ⋙ unpath a0_tp a1_tp p_tp = a0 + exact sectR_false_comp_unpath a0_tp a1_tp p_tp lemma path1_unpath : path1 (unpath a0_tp a1_tp p_tp) = a1 := by - apply Functor.Grothendieck.FunctorTo.hext - · simp - · intro x - simpa [unpath] using PGrpd.objFiber'_heq a1_tp - · intro x y f - simpa [unpath] using PGrpd.mapFiber'_heq a1_tp f + change sectR ⟨⟨.true⟩⟩ _ ⋙ unpath a0_tp a1_tp p_tp = a1 + exact sectR_true_comp_unpath a0_tp a1_tp p_tp lemma pathFibObj_unpath (x) : pathFibObj (unpath_comp_forgetToGrpd a0_tp a1_tp p_tp) x = PGrpd.objFiber' p_tp x := by @@ -315,6 +328,7 @@ lemma path_unpath : path (A := A) (unpath_comp_forgetToGrpd a0_tp a1_tp p_tp) = apply Functor.Grothendieck.FunctorTo.hext · rw [path_comp_forgetToGrpd, p_tp] rw! [path0_unpath, path1_unpath] + rfl · intro x exact heq_of_eq_of_heq (pathFibObj_unpath ..) (PGrpd.objFiber'_heq p_tp) · intro x y f @@ -346,51 +360,41 @@ lemma a1_comp_forgetToGrpd : a1 ⋙ PGrpd.forgetToGrpd = A := by lemma obj_ff_fiber (x) : (p.obj (ff x)).fiber ≍ PGrpd.objFiber' (a0_comp_forgetToGrpd p_tp δ0_p) x := by + subst a0 symm - convert PGrpd.objFiber'_heq (path0_comp_forgetToGrpd p_tp) (x := x) - rw [← δ0_p] + rw [PGrpd.objFiber'_naturality (sectR ⟨⟨.false⟩⟩ _) p_tp x] + exact PGrpd.objFiber'_heq p_tp lemma obj_tt_fiber (x) : (p.obj (tt x)).fiber ≍ PGrpd.objFiber' (a1_comp_forgetToGrpd p_tp δ1_p) x := by + subst a1 symm - convert PGrpd.objFiber'_heq (path1_comp_forgetToGrpd p_tp) (x := x) - rw [← δ1_p] + rw [PGrpd.objFiber'_naturality (sectR ⟨⟨.true⟩⟩ _) p_tp x] + exact PGrpd.objFiber'_heq p_tp lemma map_ff_fiber {x y : Γ} (f : ff x ⟶ ff y) : (p.map f).fiber ≍ PGrpd.mapFiber' (a0_comp_forgetToGrpd p_tp δ0_p) f.2 := by + subst a0 symm - convert PGrpd.mapFiber'_heq p_tp f - · rw! [← obj_ff_fiber p_tp δ0_p x] - rw! [PGrpd.objFiber'_heq p_tp] - · rw! [← obj_ff_fiber p_tp δ0_p y] - rw! [PGrpd.objFiber'_heq p_tp] - · rw! [← δ0_p, path0, PGrpd.mapFiber'_naturality p_tp (sectR { down := { as := false } } Γ)] - rw! [PGrpd.mapFiber'_heq p_tp] - rw! [PGrpd.mapFiber'_heq p_tp f] - rfl + rw [PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.false⟩⟩ _) f.2] + exact PGrpd.mapFiber'_heq p_tp f lemma map_tt_fiber {x y : Γ} (f : tt x ⟶ tt y) : (p.map f).fiber ≍ PGrpd.mapFiber' (a1_comp_forgetToGrpd p_tp δ1_p) f.2 := by + subst a1 symm - convert PGrpd.mapFiber'_heq p_tp f - · rw! [← obj_tt_fiber p_tp δ1_p x] - rw! [PGrpd.objFiber'_heq p_tp] - · rw! [← obj_tt_fiber p_tp δ1_p y] - rw! [PGrpd.objFiber'_heq p_tp] - · rw! [← δ1_p, path1, PGrpd.mapFiber'_naturality p_tp (sectR { down := { as := true } } Γ)] - rw! [PGrpd.mapFiber'_heq p_tp] - rw! [PGrpd.mapFiber'_heq p_tp f] - rfl + rw [PGrpd.mapFiber'_naturality p_tp (sectR ⟨⟨.true⟩⟩ _) f.2] + exact PGrpd.mapFiber'_heq p_tp f lemma mapFiber'_ffm {x y : Γ} (f : x ⟶ y) : PGrpd.mapFiber' p_tp (ffm f) ≍ PGrpd.mapFiber' (a0_comp_forgetToGrpd p_tp δ0_p) f := by rw! [← δ0_p, PGrpd.mapFiber'_naturality p_tp (sectR ..)] - simp + rfl lemma mapFiber'_ttm {x y : Γ} (f : x ⟶ y) : PGrpd.mapFiber' p_tp (ttm f) ≍ PGrpd.mapFiber' (a1_comp_forgetToGrpd p_tp δ1_p) f := by rw! [← δ1_p, PGrpd.mapFiber'_naturality p_tp (sectR ..)] - simp + rfl @[simp] lemma objFiber_path (x) : PGrpd.objFiber (path p_tp) x = pathFibObj p_tp x := @@ -405,7 +409,7 @@ lemma mapFiber_ft (x) : PGrpd.mapFiber p (ft x) ≍ symm rw [objFiber'_path_as] simp only [Functor.comp_obj, snd_obj, Functor.comp_map, snd_map, PGrpd.mapFiber', - Grpd.forgetToCat, Functor.Grothendieck.forget_obj, PGrpd.objFiber'EqToHom, + Grpd.forgetToCat, PGrpd.objFiber'EqToHom, PGrpd.mapFiber'EqToHom, Grpd.eqToHom_hom, eqToHom_trans_assoc, PGrpd.mapFiber] apply HEq.trans (eqToHom_comp_heq ..) simp @@ -436,8 +440,8 @@ lemma inv_mapFiber_tf_heq (y : Γ) : rw [PGrpd.mapFiber_inv] apply HEq.trans _ (eqToHom_comp_heq ..).symm rw! [PGrpd.inv_mapFiber_heq] - simp only [Grpd.forgetToCat, Functor.Grothendieck.forget_obj, Functor.comp_obj, Functor.comp_map, - Functor.Grothendieck.forget_map, Cat.of_α, id_eq, cast_heq_iff_heq] + simp only [Grpd.forgetToCat, Functor.comp_obj, Functor.comp_map, + PGrpd.forgetToGrpd_map, Cat.of_α, cast_heq_iff_heq] rw! [map_tf_base p_tp, Grpd.eqToHom_hom] simp only [Grpd.forgetToCat, PGrpd.mapFiber, cast_heq_iff_heq] rw! (castMode := .all) [Functor.map_inv] @@ -448,16 +452,16 @@ lemma unpath_map_ft_fiber {x y} (f : ff x ⟶ tt y) : ((unpath (a0_comp_forgetToGrpd p_tp δ0_p) (a1_comp_forgetToGrpd p_tp δ1_p) (p := FunctorOperation.Path.path p_tp) (by rw [path_comp_forgetToGrpd]; congr)).map f).fiber ≍ (p.map f).fiber := by - simp only [Grpd.forgetToCat, unpath, Functor.Grothendieck.functorTo_obj_base, - Functor.comp_obj, snd_obj, Cat.of_α, Functor.Grothendieck.functorTo_map_base, - Functor.comp_map, snd_map, id_eq, Functor.Grothendieck.functorTo_obj_fiber, unpathFibObj, + simp only [Grpd.forgetToCat, unpath, + Cat.of_α, + unpathFibObj, Functor.Grothendieck.functorTo_map_fiber, unpathFibMap] -- have hf : f = ttm f.2 ≫ ft y := by aesop_cat -- TODO: mwe and report: this should not type check have hf : f = ffm f.2 ≫ ft y := by aesop_cat conv => rhs; rw! (castMode := .all) [hf] - simp only [heq_eqRec_iff_heq] - convert_to _ ≍ mapFiber _ _ + simp only [heq_eqRec_iff] + change _ ≍ mapFiber p _ erw [mapFiber_comp] rw! [← mapFiber'_ffm p_tp δ0_p] apply HEq.trans _ (eqToHom_comp_heq ..).symm @@ -465,25 +469,28 @@ lemma unpath_map_ft_fiber {x y} (f : ff x ⟶ tt y) : · erw [Functor.congr_obj p_tp (tt y)] simp · have H := Functor.congr_hom p_tp (ffm f.2) - simp only [Grpd.forgetToCat, Functor.comp_obj, Functor.Grothendieck.forget_obj, + simp only [Grpd.forgetToCat, Functor.comp_obj, Functor.comp_map, Functor.Grothendieck.forget_map, snd_obj, snd_map, Grpd.comp_eq_comp] at H erw [Functor.congr_hom p_tp (ft y)] rw! [← δ0_p, path0, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq] simp [mapObjFiber, Grpd.eqToHom_obj, objFiber, Functor.congr_obj H, Grpd.eqToHom_obj] + try rfl · simp only [Functor.Grothendieck.forget_map] rw! [← δ0_p, path0, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq, map_ft_base p_tp, Grpd.eqToHom_obj] simp [objFiber] + rfl · rw! [← δ1_p, path1, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq] simp [objFiber] + rfl · simp only [Functor.comp_obj, snd_obj, Functor.comp_map, snd_map, Grpd.forgetToCat, - Functor.Grothendieck.forget_obj, Functor.Grothendieck.forget_map, cast_heq_iff_heq] + PGrpd.forgetToGrpd_map, cast_heq_iff_heq] rw! [map_ft_base p_tp, mapFiber'_heq] simp [Grpd.eqToHom_hom, mapFiber] · rw! [mapFiber_ft p_tp y] - simp only [Grpd.forgetToCat, Functor.Grothendieck.forget_obj, Functor.Grothendieck.forget_map, + simp only [ objFiber'_rfl, heq_cast_iff_heq] apply Discrete.as_heq_as · congr @@ -497,14 +504,15 @@ lemma unpath_map_tf_fiber {x y} (f : tt x ⟶ ff y) : ((unpath (a0_comp_forgetToGrpd p_tp δ0_p) (a1_comp_forgetToGrpd p_tp δ1_p) (p := FunctorOperation.Path.path p_tp) (by rw [path_comp_forgetToGrpd]; congr)).map f).fiber ≍ (p.map f).fiber := by - simp only [Grpd.forgetToCat, unpath, Functor.Grothendieck.functorTo_obj_base, Functor.comp_obj, - snd_obj, Cat.of_α, Functor.Grothendieck.functorTo_map_base, Functor.comp_map, snd_map, id_eq, - Functor.Grothendieck.functorTo_obj_fiber, unpathFibObj, Functor.Grothendieck.functorTo_map_fiber, + simp only [Grpd.forgetToCat, unpath, + Cat.of_α, + unpathFibObj, + Functor.Grothendieck.functorTo_map_fiber, unpathFibMap] have hf : f = ttm f.2 ≫ tf y := by aesop_cat conv => rhs; rw! (castMode := .all) [hf] - simp only [heq_eqRec_iff_heq] - convert_to _ ≍ mapFiber _ _ + simp only [heq_eqRec_iff] + change _ ≍ mapFiber p _ erw [mapFiber_comp] rw! [← mapFiber'_ttm p_tp δ1_p f.2] apply HEq.trans _ (eqToHom_comp_heq ..).symm @@ -512,23 +520,26 @@ lemma unpath_map_tf_fiber {x y} (f : tt x ⟶ ff y) : have : objFiber' (a0_comp_forgetToGrpd p_tp δ0_p) y ≍ objFiber p (ff y) := by rw! [← δ0_p, path0, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq] simp [objFiber] + rfl apply Grpd.comp_heq_comp · assumption · have H := Functor.congr_hom p_tp (ttm f.2) - simp only [Grpd.forgetToCat, Functor.comp_obj, Functor.Grothendieck.forget_obj, + simp only [Grpd.forgetToCat, Functor.comp_obj, Functor.comp_map, Functor.Grothendieck.forget_map, snd_obj, snd_map, Grpd.comp_eq_comp] at H erw [Functor.congr_hom p_tp (tf y)] rw! [← δ1_p, path1, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq] simp [mapObjFiber, Grpd.eqToHom_obj, objFiber, Functor.congr_obj H, Grpd.eqToHom_obj] + try rfl · simp only [Functor.Grothendieck.forget_map] rw! [← δ1_p, path1, objFiber'_naturality (sectR ..) p_tp, objFiber'_heq, map_tf_base p_tp, Grpd.eqToHom_obj] simp [objFiber] + rfl · assumption · simp only [Functor.comp_obj, snd_obj, Functor.comp_map, snd_map, Grpd.forgetToCat, - Functor.Grothendieck.forget_obj, Functor.Grothendieck.forget_map, cast_heq_iff_heq] + PGrpd.forgetToGrpd_map, cast_heq_iff_heq] rw! [map_tf_base p_tp, mapFiber'_heq] simp [Grpd.eqToHom_hom, mapFiber] · apply Grpd.inv_heq_of_heq_inv @@ -579,6 +590,11 @@ open Grpd Model.UnstructuredUniverse def cylinder : Cylinder Grpd := .ofCartesianMonoidalCategoryLeft Interval δ0 δ1 +private lemma cylinder_δ0_obj (Γ : Grpd) (x : Γ) : + (cylinder.δ0.app Γ).obj x = FunctorOperation.Path.ff x := rfl + +attribute [local simp] cylinder_δ0_obj + namespace UId variable {Γ Δ : Grpd} (σ : Δ ⟶ Γ) {A : Γ ⟶ U.{v}.Ty} (a0 a1 : Γ ⟶ U.Tm) @@ -595,8 +611,8 @@ def Id : Γ ⟶ U.{v}.Ty := (pt_tp a1 a1_tp)) lemma Id_comp : - UId.Id (A := σ ≫ A) (σ ≫ a0) (σ ≫ a1) (by simp only [Category.assoc, a0_tp, U_Ty]) - (by simp only [Category.assoc, a1_tp, U_Ty]) = σ ≫ UId.Id a0 a1 a0_tp a1_tp := by + UId.Id (A := σ ≫ A) (σ ≫ a0) (σ ≫ a1) (by simp only [Category.assoc, a0_tp]) + (by simp only [Category.assoc, a1_tp]) = σ ≫ UId.Id a0 a1 a0_tp a1_tp := by dsimp only [U_Ty, comp_eq_comp, Id] rw [← toCoreAsSmallEquiv_symm_apply_comp_left, ← FunctorOperation.Id_comp] @@ -689,8 +705,8 @@ variable (σ : Δ ⟶ Γ) (p0 : Γ ⟶ U.{v}.Tm) (p : cylinder.I.obj Γ ⟶ U.Ty @[simp] def liftObj : Grpd.Interval × Γ → U.{v}.Tm -| ⟨⟨⟨.false⟩⟩, x2⟩ => p0.obj x2 -| ⟨⟨⟨.true⟩⟩, x2⟩ => tpClovenIsofibration.liftObj (p.map (FunctorOperation.Path.ft x2)) + | ⟨⟨⟨.false⟩⟩, x2⟩ => p0.obj x2 + | ⟨⟨⟨.true⟩⟩, x2⟩ => tpClovenIsofibration.liftObj (p.map (FunctorOperation.Path.ft x2)) (Functor.congr_obj p0_tp x2) @[simp] @@ -738,10 +754,10 @@ lemma lift_comp_tp : · erw [Functor.congr_hom p0_tp f.2] simp rfl - · simp only [U_Tm, comp_eq_comp, Functor.comp_obj, lift_obj, liftObj, U_Ty, U_tp, + · simp only [comp_eq_comp, Functor.comp_obj, liftObj, Functor.comp_map, lift_map, liftMap, liftMap0, Functor.map_comp] erw [Functor.congr_hom p0_tp f.2] - simp only [U_Tm, comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, + simp only [comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, Category.assoc] have : f = ffm f.2 ≫ ft y := by aesop conv => rhs; rw [this] @@ -750,24 +766,24 @@ lemma lift_comp_tp : simp [← Category.assoc] rfl · rcases y with ⟨⟨⟨_|_⟩⟩, y⟩ - · simp only [U_Tm, comp_eq_comp, Functor.comp_obj, lift_obj, liftObj, U_Ty, U_tp, + · simp only [comp_eq_comp, Functor.comp_obj, liftObj, Functor.comp_map, lift_map, liftMap, liftMap0, Functor.map_comp, Functor.map_inv, IsIso.inv_comp_eq] erw [Functor.congr_hom p0_tp f.2] have : f = tf x ≫ ffm f.2 := by aesop slice_rhs 2 3 => rw [this] rw [Functor.ClovenIsofibration.map_liftIso', Functor.map_comp] - simp only [U_Tm, comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, + simp only [comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, Category.assoc, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp] have : ft x ≫ tf x = 𝟙 _ := by aesop slice_rhs 2 3 => rw [← Functor.map_comp, this, CategoryTheory.Functor.map_id] rfl - · simp only [U_Tm, comp_eq_comp, Functor.comp_obj, lift_obj, liftObj, U_Ty, U_tp, + · simp only [comp_eq_comp, Functor.comp_obj, liftObj, Functor.comp_map, lift_map, liftMap, liftMap0, Functor.map_comp, Functor.map_inv, IsIso.inv_comp_eq] erw [Functor.congr_hom p0_tp f.2] rw [Functor.ClovenIsofibration.map_liftIso', Functor.ClovenIsofibration.map_liftIso'] - simp only [U_Tm, comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, + simp only [comp_eq_comp, Functor.comp_obj, Functor.id_obj, Functor.comp_map, ← Category.assoc, ← heq_eq_eq, heq_comp_eqToHom_iff, comp_eqToHom_heq_iff] simp only [Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id, ← Functor.map_comp, heq_eq_eq] @@ -776,13 +792,7 @@ lemma lift_comp_tp : rfl lemma δ0_comp_lift : cylinder.δ0.app Γ ≫ hurewiczUTp.lift p0 p p0_tp = p0 := by - fapply CategoryTheory.Functor.ext - · intro x - convert_to (lift p0 p p0_tp).obj ⟨⟨⟨.false⟩⟩, x⟩ = _ - simp - · intro x y f - convert_to (lift p0 p p0_tp).map (ffm f) = _ - simp + rfl @[simp] lemma I_map_obj_ff (x : Δ) : (cylinder.I.map σ).obj ({ down := { as := false } }, x) = @@ -801,7 +811,7 @@ lemma lift_map_ft (x : Δ) : (lift p0 p p0_tp).map (ft (σ.obj x)) = lemma lift_map_ft' (x : Δ) : (lift p0 p p0_tp).map (ft (σ.obj x)) = tpClovenIsofibration.liftIso (p.map (⟨⟨⟨⟩⟩, σ.map (𝟙 _)⟩ : ff (σ.obj x) ⟶ tt (σ.obj x))) (by simpa using Functor.congr_obj p0_tp (σ.obj x)) ≫ eqToHom (by simp) := by - simp only [U_Tm, lift_obj, liftObj, U_Ty, U_tp, ft, lift_map, liftMap, + simp only [liftObj, ft, lift_map, liftMap, CategoryTheory.Functor.map_id, liftMap0, Category.id_comp, ← heq_eq_eq, heq_comp_eqToHom_iff] rw! (castMode := .all) [← CategoryTheory.Functor.map_id] rfl @@ -815,7 +825,7 @@ lemma lift_map_tf' (x : Δ) : (lift p0 p p0_tp).map (tf (σ.obj x)) = eqToHom (by simp [ft]; rfl) ≫ inv (tpClovenIsofibration.liftIso (p.map (⟨⟨⟨⟩⟩, σ.map (𝟙 _)⟩ : ff (σ.obj x) ⟶ tt (σ.obj x))) (by simpa using Functor.congr_obj p0_tp (σ.obj x))) := by - simp only [U_Tm, lift_obj, liftObj, U_Ty, U_tp, ft, tf, lift_map, liftMap, liftMap0, + simp only [liftObj, ft, tf, lift_map, liftMap, liftMap0, CategoryTheory.Functor.map_id, Category.comp_id, ← heq_eq_eq, heq_eqToHom_comp_iff] rw! (castMode := .all) [← CategoryTheory.Functor.map_id] rfl @@ -826,14 +836,15 @@ lemma lift_comp : lift (σ ≫ p0) (cylinder.I.map σ ≫ p) fapply CategoryTheory.Functor.ext · intro x rcases x with ⟨⟨⟨_|_⟩⟩, x⟩ - · convert_to _ = (lift p0 p p0_tp).obj (ff (σ.obj x)) - simp - · convert_to _ = (lift p0 p p0_tp).obj (tt (σ.obj x)) - simp only [U_Tm, comp_eq_comp, lift_obj, liftObj, U_Ty, U_tp, Functor.comp_obj, - Functor.comp_map] - congr - conv => rhs; rw [ft, ← CategoryTheory.Functor.map_id] - rfl + · rfl + · simp only [Grpd.comp_eq_comp, comp_eq_comp, lift_obj, liftObj, + Functor.comp_obj, Functor.comp_map, ft] + have htt : (cylinder.I.map σ).obj (tt x) = tt (σ.obj x) := by rfl + have hft : (cylinder.I.map σ).map (ft x) = ft (σ.obj x) := by + dsimp [cylinder, Cylinder.ofCartesianMonoidalCategoryLeft] + change ((ft x).1, σ.map (𝟙 x)) = ((ft x).1, 𝟙 (σ.obj x)) + rw [CategoryTheory.Functor.map_id] + simp only [htt, hft] · intro x y f rcases x with ⟨⟨⟨_|_⟩⟩, x⟩ · rcases y with ⟨⟨⟨_|_⟩⟩, y⟩ @@ -854,7 +865,7 @@ lemma lift_comp : lift (σ ≫ p0) (cylinder.I.map σ ≫ p) · have : (cylinder.I.map σ).map f = tf (σ.obj x) ≫ ffm (σ.map f.2) ≫ ft (σ.obj y) := by aesop slice_rhs 2 3 => simp only [Grpd.comp_eq_comp, Functor.comp_map, this, Functor.map_comp, lift_map_ffm, lift_map_tf', lift_map_ft'] - simp only [U_Tm, comp_eq_comp, lift_obj, liftObj, U_Ty, U_tp, Functor.comp_obj, ft, + simp only [comp_eq_comp, liftObj, Functor.comp_obj, ft, Functor.comp_map, lift_map, liftMap, liftMap0, Category.assoc, eqToHom_trans, eqToHom_refl, Category.comp_id, eqToHom_trans_assoc, Category.id_comp, IsIso.eq_inv_comp] erw [IsIso.hom_inv_id_assoc] @@ -875,20 +886,36 @@ lemma isNormal (A : Γ ⟶ U.Ty) (π_A : p = CategoryTheory.Prod.snd _ Γ ≫ A) rcases x with ⟨⟨⟨_|_⟩⟩, x⟩ · rcases y with ⟨⟨⟨_|_⟩⟩, y⟩ · simp - · simp only [U_Tm, comp_eq_comp, lift_obj, liftObj, U_Ty, U_tp, Functor.comp_obj, + · simp only [comp_eq_comp, liftObj, Functor.comp_obj, Prod.snd_obj, Functor.comp_map, Prod.snd_map, lift_map, liftMap, liftMap0, eqToHom_refl, Category.id_comp] - rw! [CategoryTheory.Functor.map_id, liftIso_id] + rw! (castMode := .all) [CategoryTheory.Functor.map_id, liftIso_id] + simp only [← heq_eq_eq, eqRec_heq_iff, + heq_comp_eqToHom_iff, comp_eqToHom_heq_iff] + rfl · rcases y with ⟨⟨⟨_|_⟩⟩, y⟩ - · simp only [U_Tm, comp_eq_comp, lift_obj, liftObj, U_Ty, U_tp, Functor.comp_obj, + · simp only [comp_eq_comp, liftObj, Functor.comp_obj, Prod.snd_obj, Functor.comp_map, Prod.snd_map, lift_map, liftMap, liftMap0, eqToHom_refl, Category.comp_id, IsIso.inv_comp_eq] - rw! [CategoryTheory.Functor.map_id, liftIso_id] - simp + rw! (castMode := .all) [CategoryTheory.Functor.map_id, liftIso_id] + simp only [← heq_eq_eq, heq_eqRec_iff, + heq_eqToHom_comp_iff, ] + rfl · simp - rw! [CategoryTheory.Functor.map_id, liftIso_id] - slice_rhs 1 2 => rw! [CategoryTheory.Functor.map_id, liftIso_id] - simp + rw! (castMode := .all) [CategoryTheory.Functor.map_id, liftIso_id] + slice_rhs 1 2 => rw! (castMode := .all) [CategoryTheory.Functor.map_id, liftIso_id] + simp only [← heq_eq_eq, + comp_eqToHom_heq_iff] + symm + apply HEq.trans ?_ (heq_of_eq (Category.id_comp (p0.map f.2))) + apply heq_comp <;> + simp only [eqRec_heq_iff, liftObj_id, + comp_eqToHom_heq_iff, + eqToHom_comp_heq_iff] <;> try rfl + · rw! (castMode := .all) [CategoryTheory.Functor.map_id] + apply liftObj_id + · apply eqToHom_heq_id + rfl end hurewiczUTp diff --git a/HoTTLean/Groupoids/IsPullback.lean b/HoTTLean/Groupoids/IsPullback.lean index c6b7383b..6231056a 100644 --- a/HoTTLean/Groupoids/IsPullback.lean +++ b/HoTTLean/Groupoids/IsPullback.lean @@ -10,6 +10,8 @@ Here we construct universes for the groupoid natural model. -- TODO: flip all the diagrams in this file -/ +set_option backward.isDefEq.respectTransparency false + universe w v u v₁ u₁ v₂ u₂ v₃ u₃ noncomputable section @@ -32,7 +34,7 @@ def tp' : AsSmall.{max u (v+1)} PGrpd.{v,v} AsSmall.down ⋙ PGrpd.forgetToGrpd ⋙ AsSmall.up theorem liftTm'_tp' : Cat.homOf liftTm'.{v,u} ≫ Cat.homOf tp'.{v+1, max u (v+2)} = - Cat.homOf tp'.{v, max u (v+2)} ≫ Cat.homOf liftTy'.{v,u} := rfl + Cat.homOf tp'.{v, max u (v+2)} ≫ Cat.homOf liftTy'.{v,u} := rfl /-- The following square is a meta-theoretic pullback @@ -88,8 +90,8 @@ def isPullback_liftTm' : Functor.IsPullback theorem isPullback_liftTm'_in_Cat : IsPullback (Cat.homOf liftTm'.{v,max u (v+2)}) - tp'.{_,max u (v+2)} - tp'.{v+1,max u (v+2)} + (Cat.homOf tp'.{_,max u (v+2)}) + (Cat.homOf tp'.{v+1,max u (v+2)}) (Cat.homOf liftTy'.{v,max u (v+2)}) := Cat.isPullback rfl isPullback_liftTm' @@ -105,7 +107,7 @@ The small universes form pullbacks -/ theorem liftTm_isPullback : IsPullback liftTm.{v,max u (v+2)} U.tp.{v, max u (v+2)} U.tp.{v+1, max u (v+2)} liftTy.{v,max u (v+2)} := by - convert Functor.map_isPullback Core.map isPullback_liftTm'_in_Cat.{v,u} + convert Functor.map_isPullback Core.map isPullback_liftTm'_in_Cat.{v,u} <;> rfl variable {Γ : Ctx} (A : Γ ⥤ Grpd) @@ -194,8 +196,9 @@ def isPullbackClassifierOfCoreAsSmall (A : Γ ⟶ Ty) : (by dsimp [functorToAsSmallEquiv] convert_to (toPGrpd (toCoreAsSmallEquiv A) ⋙ forgetToGrpd) ⋙ AsSmall.up = _ - erw [toPGrpd_forgetToGrpd, Core.functorToCoreEquiv_apply, Core.functorToCore_comp_inclusion, - Functor.assoc]) + all_goals simp [← Functor.assoc, toPGrpd_forgetToGrpd, + toCoreAsSmallEquiv, functorToAsSmallEquiv, Core.functorToCoreEquiv] + all_goals rfl) (isPullbackClassifierOfAsSmall (toCoreAsSmallEquiv A)) (by dsimp [Ctx.coreAsSmallFunctor, Grpd.homOf] @@ -222,8 +225,9 @@ def isPullbackClassifierOfCoreAsSmall (A : Γ ⟶ Ty) : Γ --------- A ------> Ty -/ theorem disp_pullback (A : Γ ⟶ Ty) : IsPullback (var A) forget tp A := by - convert Grpd.isPullback (isPullbackClassifierOfCoreAsSmall A) - simp + convert Grpd.isPullback (isPullbackClassifierOfCoreAsSmall A) <;> + try rfl + exact (toCoreAsSmallEquiv.symm_apply_apply A).symm end IsPullback end GroupoidModel diff --git a/HoTTLean/Groupoids/Pi.lean b/HoTTLean/Groupoids/Pi.lean index 2c5f2ef0..a0ed182f 100644 --- a/HoTTLean/Groupoids/Pi.lean +++ b/HoTTLean/Groupoids/Pi.lean @@ -3,12 +3,17 @@ import HoTTLean.ForMathlib.CategoryTheory.Whiskering import HoTTLean.ForMathlib.CategoryTheory.NatTrans import HoTTLean.ForMathlib.CategoryTheory.MorphismProperty.WideSubcategory +set_option backward.isDefEq.respectTransparency false + universe v u v₁ u₁ v₂ u₂ v₃ u₃ noncomputable section namespace CategoryTheory +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + lemma Pseudofunctor.StrongTrans.ext {C D : Type*} [Bicategory C] [Bicategory D] {F G : Pseudofunctor C D} (α α' : F ⟶ G) (happ : ∀ x, α.app x = α'.app x) (hnaturality : ∀ {x y} (f : x ⟶ y), (α.naturality f).hom ≫ eqToHom (by rw [happ]) = @@ -30,10 +35,12 @@ lemma Pseudofunctor.StrongTrans.ext {C D : Type*} [Bicategory C] [Bicategory D] section variable {A B : Type*} [Category A] [Category B] (F : B ⥤ A) +@[implicit_reducible] def IsSection : ObjectProperty (A ⥤ B) := fun s => s ⋙ F = Functor.id A def IsOverId : MorphismProperty ((IsSection F).FullSubcategory) := - fun s t α => Functor.whiskerRight α F = eqToHom s.property ≫ 𝟙 (𝟭 A) ≫ eqToHom t.property.symm + fun s t α => Functor.whiskerRight α.hom F = + eqToHom s.property ≫ 𝟙 (𝟭 A) ≫ eqToHom t.property.symm instance : (IsOverId F).IsMultiplicative where id_mem := by @@ -61,9 +68,9 @@ instance {A B : Type*} [Category A] [Groupoid B] (F : B ⥤ A) : instance {A B : Type*} [Category A] [Groupoid B] (F : B ⥤ A) : IsGroupoid (Section F) where all_isIso {x y} f := { - out := ⟨⟨ CategoryTheory.inv f.1, - by - simp only [IsOverId, Category.id_comp, eqToHom_trans, Set.mem_setOf_eq] + out := ⟨⟨ CategoryTheory.inv f.1, by + simp only [IsOverId, Category.id_comp, eqToHom_trans, Set.mem_ofPred_eq] + rw [ObjectProperty.hom_inv] erw [← Functor.inv_whiskerRight] rw! [f.2] simp⟩, @@ -77,6 +84,7 @@ instance Section.groupoid {A B : Type*} [Category A] [Groupoid B] (F : B ⥤ A) namespace ObjectProperty + lemma ι_mono {T C : Type u} [Category.{v} C] [Category.{v} T] {Z : C → Prop} (f g : T ⥤ FullSubcategory Z) (e : f ⋙ ι Z = g ⋙ ι Z) : f = g := by @@ -86,9 +94,9 @@ lemma ι_mono {T C : Type u} [Category.{v} C] [Category.{v} T] ext exact Functor.congr_obj e X · intro X - simp only [Functor.fullyFaithfulCancelRight_hom_app, Functor.preimage, ι_obj, ι_map, - eqToIso.hom, eqToHom_app, Functor.comp_obj, Classical.choose_eq] - rfl + apply (ι Z).map_injective + simp [Functor.fullyFaithfulCancelRight_hom_app] + exact (ι Z).map_preimage _ end ObjectProperty @@ -136,6 +144,8 @@ namespace GroupoidModel open CategoryTheory Opposite Functor.Groupoidal attribute [local simp] eqToHom_map Grpd.id_eq_id Grpd.comp_eq_comp Functor.id_comp Functor.comp_id + Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor + Grpd.forgetToCat ObjectProperty.eqToHom_hom namespace FunctorOperation section @@ -220,6 +230,8 @@ lemma conjugatingObjNatTransEquiv'_comp {x y z : Γ} (f1 : x ⟶ y) (f2 : y ⟶ (A.map f1 ⋙ A.map f2).whiskerLeft g ≫ eqToHom (by simp [Grpd.Functor.iso, ← Grpd.comp_eq_comp]) := by simp [conjugatingObjNatTransEquiv', Grpd.Functor.iso] + dsimp only [Grpd.functorIsoOfIso] + simp only [mapIso_hom, asIso_hom] rw! [Functor.map_comp A f1 f2] simp @@ -267,11 +279,13 @@ lemma conjugatingObjNatTransEquiv'_comp' {x y z : Γ} (f1 : x ⟶ y) (f2 : y ⟶ (whiskerLeft (A.map f1) (conjugatingObjNatTransEquiv' A B f2 S1 S2 g12)) ≫ eqToHom (by simp [← Grpd.comp_eq_comp, Grpd.Functor.iso]) := by subst h - simp only [Grpd.Functor.iso, Grpd.functorIsoOfIso_hom, mapIso_hom, asIso_hom, - Grpd.functorIsoOfIso_inv, mapIso_inv, asIso_inv, conjugatingObjNatTransEquiv', eqToHom_refl, + simp only [Grpd.Functor.iso, + conjugatingObjNatTransEquiv', eqToHom_refl, Category.id_comp, Equiv.coe_fn_mk, whiskerLeft_comp, whiskerLeft_eqToHom, eqToHom_trans_assoc, whiskerRight_comp, eqToHom_whiskerRight, whiskerLeft_twice, associator_eq, CategoryTheory.Iso.refl_inv, CategoryTheory.Iso.refl_hom, Category.comp_id, Category.assoc] at * + dsimp only [Grpd.functorIsoOfIso] at * + simp only [mapIso_hom, asIso_hom, mapIso_inv, asIso_inv] at * erw [Category.id_comp] rw [whiskerLeft_map_comp, whiskerLeft_map_comp] simp only [← Category.assoc, eqToHom_trans] @@ -304,7 +318,7 @@ lemma conjugatingObjNatTransEquiv₁_id_inv {x : Γ} (S) (T) simp [Groupoid.isoEquivHom] lemma conjugatingObjNatTransEquiv₁_comp_inv {x y z : Γ} (f1 : x ⟶ y) (f2 : y ⟶ z) - (S0 : (A.obj x) ⥤ (B.obj x)) + (S0 : (A.obj x) ⥤ (B.obj x)) (S1 : (A.obj y) ⥤ (B.obj y)) (S2 : (A.obj z) ⥤ (B.obj z)) (g01 : A.map (inv f1) ⋙ S0 ⋙ B.map f1 ⟶ S1) @@ -332,29 +346,31 @@ variable {Γ : Type u₂} [Groupoid.{v₂} Γ] {A : Γ ⥤ Grpd.{u₁,u₁}} def functorObj (x : Γ) : Grpd.{u₁,u₁} := Grpd.of (Section (φ.app x)) -def obj_hext {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') +theorem obj_hext {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') {F : A ⟶ B} {F' : A' ⟶ B'} (hF : F ≍ F') (x : Section F) (x' : Section F') (hx : x.obj.obj ≍ x'.obj.obj) : x ≍ x' := by aesop -def hom_hext {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') +theorem hom_hext {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') {F : A ⟶ B} {F' : A' ⟶ B'} (hF : F ≍ F') {x y : Section F} {x' y' : Section F'} {f : x ⟶ y} {f' : x' ⟶ y'} (hx : x ≍ x') - (hy : y ≍ y') (hf : f.1 ≍ f'.1) : + (hy : y ≍ y') (hf : f.1.hom ≍ f'.1.hom) : f ≍ f' := by subst hA hB hF hx hy simp at * apply MorphismProperty.WideSubcategory.hom_ext + apply InducedCategory.hom_ext apply hf -def hom_hext' {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') +theorem hom_hext' {A A' : Grpd.{u₁,u₁}} (hA : A ≍ A') {B B' : Grpd.{u₁,u₁}} (hB : B ≍ B') {F : A ⟶ B} {F' : A' ⟶ B'} (hF : F ≍ F') {x y : Section F} {x' y' : Section F'} {f : x ⟶ y} {f' : x' ⟶ y'} (hx : x ≍ x') - (hy : y ≍ y') (hf : ∀ k k', k ≍ k' → f.1.app k ≍ f'.1.app k') : + (hy : y ≍ y') (hf : ∀ k k', k ≍ k' → f.1.hom.app k ≍ f'.1.hom.app k') : f ≍ f' := by subst hA hB hF hx hy simp at * apply MorphismProperty.WideSubcategory.hom_ext + apply InducedCategory.hom_ext apply NatTrans.ext ext apply hf @@ -392,22 +408,18 @@ def functorMap : functorObj φ x ⥤ functorObj φ y := simp [- Grpd.comp_eq_comp, - Grpd.id_eq_id])) (by intro s t α - have := α.property - simp only [IsOverId, ← Grpd.comp_eq_comp, Category.id_comp, eqToHom_trans, Set.mem_setOf_eq, - ObjectProperty.lift_obj_obj, Functor.comp_obj, MorphismProperty.wideSubcategoryInclusion.obj, - ObjectProperty.ι_obj, ObjectProperty.lift_map, Functor.comp_map, - MorphismProperty.wideSubcategoryInclusion.map, ObjectProperty.ι_map, conjugating_map, - Functor.whiskerRight_twice, Functor.associator_eq, Iso.refl_hom, Iso.refl_inv] at * - rw [Functor.whiskerRight_whiskerLeft] - conv => left; left; rw! (castMode := .all) [φ.naturality, Grpd.comp_eq_comp] - erw [Functor.comp_whiskerRight, this, Category.comp_id] - simp only [Grpd.comp_eq_comp, Functor.eqToHom_whiskerRight, Functor.whiskerLeft_eqToHom, - ← heq_eq_eq, eqRec_heq_iff_heq] - congr! 1 - · simp only [← Grpd.comp_eq_comp, ← φ.naturality] - rfl - · simp only [← Grpd.comp_eq_comp, ← φ.naturality] - rfl) + have h := α.property + ext a + simp [IsOverId, ObjectProperty.homMk, conjugating_map] at h ⊢ + have hh := NatTrans.congr_app h ((A.map (inv f)).obj a) + simp only [Functor.whiskerRight_app, eqToHom_app] at hh + have hn := Functor.congr_hom (φ.naturality f) ((α.1.hom).app ((A.map (inv f)).obj a)) + simp only [Grpd.comp_eq_comp, Functor.comp_map, Functor.comp_obj] at hn + rw! (castMode := .all) [hn, hh] + rw! [eqToHom_map, Category.id_comp, eqToHom_trans, eqToHom_trans] + change 𝟙 _ ≫ (eqToHom _ : (φ.app y).obj ((B.map f).obj + (s.obj.obj.obj ((A.map (inv f)).obj a))) ⟶ _) = _ + exact Category.id_comp _) def functor : Γ ⥤ Grpd.{u₁,u₁} where obj := functorObj φ @@ -425,8 +437,8 @@ lemma functor_comp {Δ : Type u₃} [Groupoid.{v₃} Δ] (σ : Δ ⥤ Γ) : simp [functor, functorMap] @[simp] -lemma functor_map_map {s t} (α : s ⟶ t) : (((functor φ).map f).map α).1 = - Functor.whiskerRight (Functor.whiskerLeft (A.map (inv f)) α.1) (B.map f) := by +lemma functor_map_map {s t} (α : s ⟶ t) : (((functor φ).map f).map α).1.hom = + Functor.whiskerRight (Functor.whiskerLeft (A.map (inv f)) α.1.hom) (B.map f) := by simp [functor, functorMap, conjugating, MorphismProperty.lift] end @@ -443,36 +455,49 @@ variable (app : (x : Γ) → A.obj x ⥤ B.obj x) Functor.whiskerRight (naturality f).hom (B.map g) ≫ eqToHom (by simp [Functor.assoc])) -def strongTrans : (A ⋙ Grpd.forgetToCat).toPseudoFunctor'.StrongTrans - (B ⋙ Grpd.forgetToCat).toPseudoFunctor' where - app x := app x.as - naturality f := naturality f.as +def strongTrans : (A ⋙ Grpd.forgetToCat).toPseudofunctor'.StrongTrans + (B ⋙ Grpd.forgetToCat).toPseudofunctor' where + app x := (app x.as).toCatHom + naturality f := Cat.Hom.isoMk (naturality f.as) naturality_naturality := by intro x y f g η have := LocallyDiscrete.eq_of_hom η subst this - simp only [Functor.toPseudoFunctor', Functor.comp_obj, Functor.comp_map, LocallyDiscrete.id_as, - LocallyDiscrete.comp_as, pseudofunctorOfIsLocallyDiscrete, Bicategory.whiskerRight, + simp only [Functor.toPseudofunctor', Functor.comp_obj, Functor.comp_map, + pseudofunctorOfIsLocallyDiscrete, Bicategory.whiskerRight, eqToHom_refl, Bicategory.whiskerLeft] aesop naturality_id := by intro x - simp only [Functor.toPseudoFunctor', Functor.comp_obj, Functor.comp_map, LocallyDiscrete.id_as, - LocallyDiscrete.comp_as, pseudofunctorOfIsLocallyDiscrete, Bicategory.whiskerLeft, + apply Cat.Hom₂.ext + simp only [Cat.Hom.toNatTrans_comp, Cat.Hom.isoMk_hom, + NatTrans.toCatHom₂_toNatTrans] + simp only [Functor.toPseudofunctor', Functor.comp_obj, Functor.comp_map, LocallyDiscrete.id_as, + pseudofunctorOfIsLocallyDiscrete, Bicategory.whiskerLeft, eqToIso.hom, Bicategory.whiskerRight, Bicategory.leftUnitor, Bicategory.rightUnitor] + dsimp [Cat.Hom.isoMk, NatTrans.toCatHom₂] + simp only [Cat.Hom₂.eqToHom_toNatTrans] rw [Functor.eqToHom_whiskerRight, Functor.leftUnitor_hom_comp_rightUnitor_inv, Functor.whiskerLeft_eqToHom, naturality_id] simp - conv => right; apply Category.comp_id naturality_comp := by intro x y z f g - simp only [Grpd.forgetToCat, Functor.toPseudoFunctor', Functor.comp_obj, Functor.comp_map, - id_eq, LocallyDiscrete.id_as, LocallyDiscrete.comp_as, pseudofunctorOfIsLocallyDiscrete, + apply Cat.Hom₂.ext + simp only [Cat.Hom.toNatTrans_comp, Cat.Hom.isoMk_hom, + NatTrans.toCatHom₂_toNatTrans] + simp only [Grpd.forgetToCat, Functor.toPseudofunctor', Functor.comp_obj, Functor.comp_map, + LocallyDiscrete.comp_as, pseudofunctorOfIsLocallyDiscrete, naturality_comp, eqToHom_refl, Category.id_comp, Bicategory.whiskerLeft, Cat.of_α, eqToIso.hom, Category.assoc, Bicategory.whiskerRight, Bicategory.associator, - Functor.associator_eq, Iso.refl_hom, Iso.refl_inv] + Functor.associator_eq, ] + dsimp [Cat.Hom.isoMk, NatTrans.toCatHom₂] + simp only [Cat.Hom₂.eqToHom_toNatTrans] rw [Functor.eqToHom_whiskerRight, Functor.whiskerLeft_eqToHom] erw [Category.id_comp, Category.id_comp, Category.comp_id] + change Discrete (x.as ⟶ y.as) at f + change Discrete (y.as ⟶ z.as) at g + cases f + cases g simp lemma strongTrans_comp_toStrongTrans'_self_aux (happ : ∀ x, app x ⋙ φ.app x = 𝟭 _) @@ -493,22 +518,34 @@ lemma strongTrans_comp_toStrongTrans'_self (happ : ∀ x, app x ⋙ φ.app x = (Functor.whiskerRight φ Grpd.forgetToCat).toStrongTrans' = 𝟙 _ := by fapply Pseudofunctor.StrongTrans.ext · intro x - simp only [Grpd.forgetToCat, Functor.toPseudoFunctor'_obj, Functor.comp_obj, strongTrans, - comp_app, NatTrans.toStrongTrans'_app, Functor.whiskerRight_app, id_eq, categoryStruct_id_app] - apply happ + simp only [Grpd.forgetToCat, strongTrans, + comp_app, NatTrans.toStrongTrans'_app, Functor.whiskerRight_app, categoryStruct_id_app] + apply Cat.Hom.ext + exact happ x.as · intro x y f + rcases f with ⟨f⟩ ext a - simp only [Grpd.forgetToCat, Functor.toPseudoFunctor'_obj, Functor.comp_obj, Cat.of_α, - Functor.toPseudoFunctor'_map, Functor.comp_map, id_eq, strongTrans, comp_app, - NatTrans.toStrongTrans'_app, Functor.whiskerRight_app, Cat.comp_obj, categoryStruct_id_app, - Cat.id_obj, categoryStruct_comp_naturality_hom, Bicategory.associator, + simp only [Grpd.forgetToCat, + strongTrans, comp_app, + Functor.whiskerRight_app, + categoryStruct_comp_naturality_hom, Bicategory.associator, NatTrans.toStrongTrans'_naturality, eqToIso.hom, Bicategory.whiskerLeft_eqToHom, - Category.assoc, Cat.comp_app, Functor.associator_inv_app, Cat.whiskerRight_app, - Functor.associator_hom_app, Cat.eqToHom_app, Category.id_comp, eqToHom_trans, + Category.assoc, Cat.Hom.toNatTrans_comp, categoryStruct_id_naturality_hom, Bicategory.rightUnitor, Bicategory.leftUnitor, - Functor.rightUnitor_hom_app, Functor.leftUnitor_inv_app, Category.comp_id, ← heq_eq_eq, - comp_eqToHom_heq_iff] + ← heq_eq_eq] + simp only [Cat.Hom.isoMk, NatTrans.toCatHom₂, Functor.toCatHom_toFunctor, + NatTrans.toStrongTrans', + Cat.whiskerRight_toNatTrans, + NatTrans.comp_app, Functor.whiskerRight_app, + Functor.associator_inv_app, Functor.associator_hom_app, + Functor.leftUnitor_inv_app, Functor.rightUnitor_hom_app, + Category.comp_id] rw! [hnaturality] + dsimp only [Functor.toPseudofunctor', pseudofunctorOfIsLocallyDiscrete, + Functor.comp_obj, Functor.comp_map, Functor.toCatHom_toFunctor] at a ⊢ + dsimp [Grpd.forgetToCat] at a ⊢ + simp only [Cat.eqToHom_app, Category.id_comp, eqToHom_trans] + apply HEq.trans ?_ (heq_of_eq (Category.comp_id _).symm) apply eqToHom_heq_eqToHom rfl @@ -563,7 +600,7 @@ section def sigma.fstNatTrans : sigma A B ⟶ A where app x := forget - naturality x y f:= by simp [sigmaMap_forget] + naturality _ _ f := sigmaMap_forget (B := B) (f := f) @[simp] lemma sigma.fstNatTrans_app (x) : (fstNatTrans A B).app x = Functor.Groupoidal.forget := @@ -573,24 +610,12 @@ lemma sigma.map_fstNatTrans_eq : map (fstNatTrans A B) = (assoc B).inv ⋙ forge apply Functor.Groupoidal.FunctorTo.hext · simp [Functor.assoc, assoc_inv_comp_forget_comp_forget, map_forget] · intro x - simp only [fstNatTrans, map_obj_fiber, sigma_obj, Functor.Groupoidal.forget_obj, assoc, - Functor.Iso.symm_inv, Functor.comp_obj, functorIsoFrom_hom_obj, assocFib, heq_eq_eq] - rw! (castMode := .all) [pre_obj_base] - simp + simp only [fstNatTrans, map_obj_fiber, Functor.comp_obj, Functor.Groupoidal.forget_obj, + assoc_inv_obj_base_fiber] rfl · intro x y f - simp only [fstNatTrans, map_map_fiber, sigma_obj, Grpd.comp_eq_comp, Functor.comp_obj, - Functor.Groupoidal.forget_obj, sigma_map, sigmaMap_obj_base, eqToHom_refl, forget_map, - Category.id_comp, assoc, Functor.Iso.symm_inv, functorIsoFrom_hom_obj, assocFib, - Functor.comp_map, functorIsoFrom_hom_map, comp_base, Functor.Groupoidal.comp_fiber, - heq_eqToHom_comp_iff] - rw! [pre_map_base] - simp only [ι_map_base, ι_obj_base, assocHom, assocFib, assocIso, ι_map_fiber, ι_obj_fiber] - rw [preNatIso_hom_app_base, ιNatIso_hom, ιNatTrans_app_base] - simp only [Functor.comp_obj, Pi.id_apply, homMk_base, homMk_fiber] - erw [CategoryTheory.Functor.map_id (A.map (𝟙 y.base))] - erw [Category.id_comp] - simp + simp only [fstNatTrans, map_map_fiber, Functor.comp_map, Functor.Groupoidal.forget_map, + assoc_inv_map_base_fiber, eqToHom_comp_heq_iff, heq_eqToHom_comp_iff] rfl end @@ -618,7 +643,8 @@ as the induced map in the following diagram lemma pi.obj_hext {A A' : Γ ⥤ Grpd.{u₁,u₁}} (hA : A ≍ A') {B : ∫ A ⥤ Grpd.{u₁,u₁}} {B' : ∫ A' ⥤ Grpd.{u₁,u₁}} (hB : B ≍ B') (x : Γ) (f : (pi A B).obj x) (f' : (pi A' B').obj x) (hf : f.obj.obj ≍ f'.obj.obj) : f ≍ f' := by - aesop + subst hA hB + exact Section.obj_hext HEq.rfl HEq.rfl HEq.rfl f f' hf end @@ -643,8 +669,8 @@ lemma comm_sq_of_comp_mono {C : Type*} [Category C] (hh : h ≫ mW = mX ≫ h') (hg : g ≫ mZ = mY ≫ g') (hi : i ≫ mZ = mW ≫ i') - [e : Mono mZ] - : f ≫ g = h ≫ i := by + [e : Mono mZ] : + f ≫ g = h ≫ i := by apply e.right_cancellation calc (f ≫ g) ≫ mZ _ = f ≫ mY ≫ g' := by aesop @@ -664,7 +690,7 @@ theorem pi_comp : pi (σ ⋙ A) (pre A σ ⋙ B) = σ ⋙ pi A B := by apply sigma_naturality · rfl · intro x - simp only [sigma_obj, Functor.comp_obj, sigma.fstNatTrans, Functor.whiskerLeft_app] + simp only [Functor.comp_obj, sigma.fstNatTrans, Functor.whiskerLeft_app] congr 1 rw [← Functor.assoc, ι_comp_pre] @@ -698,32 +724,34 @@ lemma strongTrans.app_map_base (y) {a a'} (f : a ⟶ a') : def strongTrans.twoCell {x y : Γ} (g : x ⟶ y) : A.map (CategoryTheory.inv g) ⋙ strongTrans.app B s hs x ⋙ sigmaMap B g ⟶ - strongTrans.app B s hs y := (PGrpd.mapFiber' hs g).1 + strongTrans.app B s hs y := (Section.ι _).map (PGrpd.mapFiber' hs g) lemma strongTrans.twoCell_app_base_aux {x y : Γ} (g : x ⟶ y) (a) : base ((A.map (CategoryTheory.inv g) ⋙ app B s hs x ⋙ sigmaMap B g).obj a) = base ((app B s hs y).obj a) := by - simp only [Functor.map_inv, sigma_obj, Functor.comp_obj, sigmaMap_obj_base, app_obj_base] + simp only [Functor.map_inv, Functor.comp_obj, sigmaMap_obj_base, app_obj_base] simp [← Functor.comp_obj, ← Grpd.comp_eq_comp] @[simp] lemma strongTrans.twoCell_app_base {x y : Γ} (g : x ⟶ y) (a) : ((strongTrans.twoCell B s hs g).app a).base = eqToHom (twoCell_app_base_aux ..) := by have := NatTrans.congr_app (PGrpd.mapFiber' hs g).2 a - simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, Functor.comp_obj, - Functor.Groupoidal.forget_obj, IsOverId, Set.mem_setOf_eq, Functor.whiskerRight_app, forget_map, + simp only [sigma.fstNatTrans_app, Functor.comp_obj, + Functor.Groupoidal.forget_obj, IsOverId, Functor.whiskerRight_app, forget_map, Category.id_comp, eqToHom_trans, eqToHom_app] at this - rw [twoCell, this] + change ((PGrpd.mapFiber' hs g).1.hom.app a).base = _ + exact this @[simp] lemma strongTrans.twoCell_id (x) : twoCell B s hs (𝟙 x) = eqToHom (by simp) := by - simp [twoCell] - rfl + have h := congrArg (Section.ι ((sigma.fstNatTrans A B).app x)).map + (PGrpd.mapFiber'_id hs (x := x)) + exact h.trans (eqToHom_map _ _) set_option maxHeartbeats 400000 in lemma strongTrans.pi_map_map {x y z} (f : x ⟶ y) (g : y ⟶ z) : - (((pi A B).map g).map (PGrpd.mapFiber' hs f)).1 = + (((pi A B).map g).map (PGrpd.mapFiber' hs f)).1.hom = Functor.whiskerLeft (A.map (CategoryTheory.inv g)) (Functor.whiskerRight (twoCell B s hs f) (sigmaMap B g)) := Section.functor_map_map (A := A) @@ -746,10 +774,15 @@ lemma strongTrans.twoCell_comp {x y z} (f : x ⟶ y) (g : y ⟶ z) : Functor.whiskerLeft (A.map (CategoryTheory.inv g)) (Functor.whiskerRight (twoCell B s hs f) (sigmaMap B g)) ≫ twoCell B s hs g := by - conv => left; simp only [twoCell, sigma_obj, pi_obj_α, Set.mem_setOf_eq, - PGrpd.mapFiber'_comp' hs f g, MorphismProperty.WideSubcategory.comp_def, - MorphismProperty.WideSubcategory.coe_eqToHom, pi_map_map] - rfl + have h := congrArg (Section.ι ((sigma.fstNatTrans A B).app z)).map + (PGrpd.mapFiber'_comp' hs f g) + simp only [CategoryTheory.Functor.map_comp, eqToHom_map] at h + dsimp only [Section.ι, CategoryTheory.Functor.comp_map, + MorphismProperty.wideSubcategoryInclusion, MorphismProperty.wideInducedFunctor, + ObjectProperty.ι, inducedFunctor] at h + rw [pi_map_map] at h + exact h + def strongTrans.naturality {x y : Γ} (g : x ⟶ y) : A.map g ⋙ strongTrans.app B s hs y ≅ strongTrans.app B s hs x ⋙ sigmaMap B g := @@ -759,9 +792,10 @@ lemma strongTrans.naturality_inv_app {x y} (f : x ⟶ y) (a) : (strongTrans.naturality B s hs f).inv.app a = eqToHom (by simp [← Functor.comp_obj]; simp [← Grpd.comp_eq_comp]) ≫ (twoCell B s hs f).app ((A.map f).obj a) := by - simp only [sigma_obj, Functor.comp_obj, naturality, sigma_map, - conjugatingObjNatTransEquiv₁, Grpd.Functor.iso, Grpd.functorIsoOfIso_inv, Functor.mapIso_inv, - asIso_inv, Grpd.functorIsoOfIso_hom, Functor.mapIso_hom, asIso_hom, + simp only [Functor.comp_obj, naturality, + conjugatingObjNatTransEquiv₁, Grpd.Functor.iso, Grpd.functorIsoOfIso, + Functor.mapIso_inv, + asIso_inv, Functor.mapIso_hom, asIso_hom, conjugatingObjNatTransEquiv', Groupoid.isoEquivHom, Groupoid.inv_eq_inv, Equiv.toFun_as_coe, Equiv.trans_apply, Equiv.coe_fn_mk, Equiv.coe_fn_symm_mk, IsIso.inv_comp, Functor.inv_whiskerLeft, inv_eqToHom, Iso.symm_mk, NatTrans.comp_app, eqToHom_app, @@ -773,14 +807,30 @@ lemma strongTrans.naturality_inv_app_base {x y} (f : x ⟶ y) (a) : rw [strongTrans.naturality_inv_app, comp_base, base_eqToHom] simp +set_option maxHeartbeats 800000 in @[simp] lemma strongTrans.naturality_inv_app_fiber {x y} (f : x ⟶ y) (a) : ((strongTrans.naturality B s hs f).inv.app a).fiber = - eqToHom (by simp only [← Functor.comp_obj, naturality_inv_app_base, twoCell_app_base, - ← Grpd.comp_eq_comp]; rw! [← Functor.map_comp_assoc, IsIso.hom_inv_id, - CategoryTheory.Functor.map_id, Category.id_comp]) ≫ + eqToHom (by + have hc : (A.map (inv f)).obj ((A.map f).obj a) = a := by + simpa only [Functor.mapIso_hom, Functor.mapIso_inv, Grpd.comp_eq_comp, + Grpd.id_eq_id, Functor.comp_obj, Functor.id_obj, asIso_hom, asIso_inv] using + Functor.congr_obj (A.mapIso (asIso f)).hom_inv_id a + simp only [← Functor.comp_obj, naturality_inv_app_base, twoCell_app_base, + ← Grpd.comp_eq_comp] + rw! (castMode := .all) [← Functor.map_comp_assoc, IsIso.hom_inv_id, + CategoryTheory.Functor.map_id, Category.id_comp] + congr 1 <;> try simp only [← heq_eq_eq] + all_goals first | rfl | (simp only [heq_eqRec_iff]) + all_goals dsimp only [Functor.comp_obj] + all_goals try (apply (show ∀ {C D : Grpd}, C = D → + C.str'.toCategory ≍ D.str'.toCategory from by intros C D h; cases h; rfl)) + all_goals congr! 1 + all_goals try exact (congrArg (fun z => (ι A y).obj + (base ((sigmaMap B f).obj ((app B s hs x).obj z)))) hc).symm) ≫ Hom.fiber ((twoCell B s hs f).app ((A.map f).obj a)) := by - rw! [strongTrans.naturality_inv_app, comp_fiber, fiber_eqToHom, eqToHom_map] + rw! (castMode := .all) + [strongTrans.naturality_inv_app, comp_fiber, fiber_eqToHom, eqToHom_map] simp @[simp] @@ -788,7 +838,7 @@ lemma strongTrans.naturality_id_hom (x : Γ) : (strongTrans.naturality B s hs (𝟙 x)).hom = eqToHom (by simp) := by dsimp [strongTrans.naturality] erw [conjugatingObjNatTransEquiv₁_id_inv] - simp [sigma_obj, sigma_map, eqToHom_trans, twoCell_id] + simp [eqToHom_trans, twoCell_id] lemma inv_heq_inv {C : Type*} [Category C] {X Y : C} {X' Y' : C} (hX : X = X') (hY : Y = Y') {f : X ⟶ Y} {f' : X' ⟶ Y'} (hf : f ≍ f') [IsIso f] : @@ -809,6 +859,7 @@ lemma strongTrans.naturality_comp_hom {x y z : Γ} (g1 : x ⟶ y) (g2 : y ⟶ z) (twoCell B s hs g1) (twoCell B s hs g2) (twoCell B s hs (g1 ≫ g2)) ?_).trans · simp [naturality] + rfl · apply (strongTrans.twoCell_comp ..).trans rw [Functor.whiskerRight_whiskerLeft] simp only [sigma, eqToHom_refl] @@ -816,15 +867,16 @@ lemma strongTrans.naturality_comp_hom {x y z : Γ} (g1 : x ⟶ y) (g2 : y ⟶ z) lemma strongTrans.app_comp_fstNatTrans_app (x : Γ) : strongTrans.app B s hs x ⋙ (sigma.fstNatTrans A B).app x = 𝟭 ↑(A.obj x) := by - simpa [strongTrans.app] using (PGrpd.objFiber' hs x).obj.property + exact (PGrpd.objFiber' hs x).obj.property lemma strongTrans.app_map_naturality_hom_app {x y : Γ} (f : x ⟶ y) (a : (A.obj x)) : ((sigma.fstNatTrans A B).app y).map (((strongTrans.naturality B s hs) f).hom.app a) = eqToHom (Section.strongTrans_comp_toStrongTrans'_self_aux (sigma.fstNatTrans A B) (app B s hs) (app_comp_fstNatTrans_app B s hs) f a) := by - simp only [sigma_obj, sigma.fstNatTrans, Functor.comp_obj, Functor.Groupoidal.forget_obj, - sigmaMap_obj_base, naturality, sigma_map, conjugatingObjNatTransEquiv₁, Grpd.Functor.iso, - Grpd.functorIsoOfIso_inv, Functor.mapIso_inv, asIso_inv, Grpd.functorIsoOfIso_hom, + simp only [sigma.fstNatTrans, Functor.comp_obj, Functor.Groupoidal.forget_obj, + sigmaMap_obj_base, naturality, conjugatingObjNatTransEquiv₁, Grpd.Functor.iso, + Grpd.functorIsoOfIso, + Functor.mapIso_inv, asIso_inv, Functor.mapIso_hom, asIso_hom, conjugatingObjNatTransEquiv', Groupoid.isoEquivHom, Groupoid.inv_eq_inv, Equiv.toFun_as_coe, Equiv.trans_apply, Equiv.coe_fn_mk, Equiv.coe_fn_symm_mk, IsIso.inv_comp, Functor.inv_whiskerLeft, inv_eqToHom, Iso.symm_mk, @@ -832,8 +884,8 @@ lemma strongTrans.app_map_naturality_hom_app {x y : Γ} (f : x ⟶ y) (a : (A.ob rw [Functor.Groupoidal.comp_base, Functor.Groupoidal.base_eqToHom, ← Functor.Groupoidal.inv_base] have h := NatTrans.congr_app ((PGrpd.mapFiber' hs f)).2 ((A.map f).obj a) - simp only [Set.mem_setOf_eq, IsOverId, sigma.fstNatTrans] at h - simp only [sigma_obj, pi_obj_α, Functor.comp_obj, Functor.Groupoidal.forget_obj, + simp only [IsOverId, sigma.fstNatTrans] at h + simp only [Functor.comp_obj, Functor.Groupoidal.forget_obj, Functor.whiskerRight_app, forget_map, Category.id_comp, eqToHom_trans, eqToHom_app] at h simp [twoCell, h] @@ -897,25 +949,18 @@ lemma assocHom_app_base_base lemma assocHom_app_base_fiber {Γ : Type u₂} [Groupoid Γ] {A : Γ ⥤ Grpd} (B : ∫ A ⥤ Grpd) {x y : Γ} (f : x ⟶ y) (a) : - ((sigma.assocHom B f).app a).base.fiber = eqToHom (by - simp only [sigma.assocFib.eq_1, Functor.comp_obj, assocHom_app_base_base] - rw! (castMode := .all) [pre_obj_base B (ι A y) ((sigmaMap B f).obj a)] - rw! (castMode := .all) [pre_obj_base B (ι A x) a] - simp) := by - simp only [sigma.assocFib.eq_1, Functor.comp_obj, sigma.assocHom, - sigma.assocIso, eqToHom_refl] - rw! (castMode := .all) [preNatIso_hom_app_base, ιNatIso_hom] - simp - rfl + ((sigma.assocHom B f).app a).base.fiber = eqToHom (by rfl) := by + exact sigma.assocIso_hom_app_base_fiber B f a + lemma mapStrongTrans_comp_map_fstNatTrans : mapStrongTrans B s hs ⋙ map (sigma.fstNatTrans A B) = 𝟭 _ := by - convert Section.mapStrongTrans_comp_map_self (sigma.fstNatTrans A B) + exact Section.mapStrongTrans_comp_map_self (sigma.fstNatTrans A B) (strongTrans.app B s hs) (strongTrans.naturality B s hs) - (strongTrans.naturality_id_hom B s hs) (strongTrans.naturality_comp_hom B s hs) _ _ - · apply strongTrans.app_comp_fstNatTrans_app - · intro x y f a - apply strongTrans.app_map_naturality_hom_app + (strongTrans.naturality_id_hom B s hs) (strongTrans.naturality_comp_hom B s hs) + (strongTrans.app_comp_fstNatTrans_app B s hs) + (strongTrans.app_map_naturality_hom_app B s hs) + @[simp] lemma inversion_comp_forgetToGrpd : inversion B s hs ⋙ PGrpd.forgetToGrpd = B := by @@ -933,7 +978,7 @@ lemma mapStrongTrans_map_ι_map_fiber_fiber_heq {x : Γ} {a b : A.obj x} (h : a · simp · conv => left; right; rw [ι_map_fiber, Functor.map_comp, eqToHom_map] rw! (castMode := .all) [ι_obj_base] - simp only [mapStrongTrans_obj_base, ι_obj_base, ι_map_base, sigma_obj, ι_obj_fiber, + simp only [mapStrongTrans_obj_base, ι_obj_base, ι_map_base, ι_obj_fiber, Functor.comp_obj, strongTrans.twoCell_id, eqToHom_app, eqToHom_trans_assoc] apply HEq.trans (eqToHom_comp_heq ..) rfl @@ -945,13 +990,13 @@ lemma ι_comp_inversion {x} : ι A x ⋙ inversion B s hs = erw [toPGrpd_forgetToGrpd, ← Functor.assoc, strongTrans.app_comp_fstNatTrans_app, Functor.id_comp] · intro a - simp only [Functor.comp_obj, inversion_obj_base, inversion_obj_fiber, ι_obj_base, sigma_obj, + simp only [Functor.comp_obj, inversion_obj_fiber, ι_obj_base, toPGrpd_obj_base, toPGrpd_obj_fiber, heq_eq_eq] rw! (castMode := .all) [mapStrongTrans_obj_fiber] simp · intro a b h - simp only [Functor.comp_obj, inversion_obj_base, Functor.comp_map, inversion_map_base, - inversion_obj_fiber, ι_obj_base, inversion_map_fiber, ι_map_base, sigma_obj, toPGrpd_obj_base, + simp only [Functor.comp_obj, Functor.comp_map, + ι_obj_base, inversion_map_fiber, ι_map_base, toPGrpd_obj_base, toPGrpd_map_base, toPGrpd_obj_fiber, toPGrpd_map_fiber, eqToHom_comp_heq_iff] apply mapStrongTrans_map_ι_map_fiber_fiber_heq @@ -1031,10 +1076,10 @@ lemma lamObjFiberObjCompSigMap.naturality {x y : Γ} (f : x ⟶ y) {a1 a2 : A.ob (β.map ((ι A y).map ((A.map f).map h))).base.map (β.map ((ιNatTrans f).app a1)).fiber ≫ (β.map ((ι A y).map ((A.map f).map h))).fiber := by simpa [← heq_eq_eq] using Grothendieck.Hom.congr β_ιNatTrans_naturality - simp only [Grpd.forgetToCat.eq_1, sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, + simp only [sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, Functor.comp_map, comp_base, sigmaMap_map_base, sigmaMap_obj_fiber, comp_fiber, - sigmaMap_map_fiber, lamObjFiberObj_map_fiber, map_comp, eqToHom_map, app_fiber_eq, Cat.of_α, - id_eq, Category.assoc, eqToHom_trans_assoc, heq_eqToHom_comp_iff, eqToHom_comp_heq_iff] + sigmaMap_map_fiber, lamObjFiberObj_map_fiber, map_comp, eqToHom_map, app_fiber_eq, + Category.assoc, eqToHom_trans_assoc, heq_eqToHom_comp_iff, eqToHom_comp_heq_iff] rw [← Category.assoc] apply HEq.trans _ h_naturality apply heq_comp _ rfl rfl _ HEq.rfl @@ -1060,15 +1105,15 @@ lemma lamObjFiberObjCompSigMap.app_comp {x y z : Γ} (f : x ⟶ y) (g : y ⟶ z) ≫ (sigmaMap (β ⋙ PGrpd.forgetToGrpd) g).map (app A β f a) ≫ app A β g ((A.map f).obj a) ≫ eqToHom (by simp) := by fapply Hom.hext - · simp only [Grpd.forgetToCat.eq_1, sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, app_base, + · simp only [sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, app_base, comp_base, base_eqToHom, sigmaMap_map_base, map_id, lamObjFiberObj_obj_base, map_comp, Grpd.comp_eq_comp, eqToHom_naturality, Category.comp_id, eqToHom_trans, eqToHom_refl] · have : (β.map ((ιNatTrans (f ≫ g)).app a)) = β.map ((ιNatTrans f).app a) ≫ β.map ((ιNatTrans g).app ((A.map f).obj a)) ≫ eqToHom (by simp) := by simp [ιNatTrans_comp_app] - simp only [Grpd.forgetToCat.eq_1, sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, app, - Functor.comp_map, PGrpd.forgetToGrpd_map, sigmaMap_obj_fiber, Cat.of_α, id_eq, homMk_base, + simp only [sigmaObj, Grpd.coe_of, comp_obj, sigmaMap_obj_base, app, + Functor.comp_map, PGrpd.forgetToGrpd_map, sigmaMap_obj_fiber, homMk_base, homMk_fiber, Grothendieck.Hom.congr this, Grothendieck.Hom.comp_base, Grpd.comp_eq_comp, Grothendieck.Hom.comp_fiber, eqToHom_refl, Functor.Grothendieck.fiber_eqToHom, Category.id_comp, eqToHom_trans_assoc, comp_base, sigmaMap_map_base, comp_fiber, @@ -1159,9 +1204,10 @@ lemma whiskerLeftInvLamObjObjSigMap_comp {x y z} (f : x ⟶ y) (g : y ⟶ z) : def lamMapFiber : ((pi A (β ⋙ PGrpd.forgetToGrpd)).map f).obj (lamObjFiber A β x) ⟶ lamObjFiber A β y := - ⟨whiskerLeftInvLamObjObjSigMap A β f, by + ⟨ObjectProperty.homMk (whiskerLeftInvLamObjObjSigMap A β f), by ext - simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, comp_obj, Groupoidal.forget_obj, + simp only [ObjectProperty.homMk, sigma.fstNatTrans_app, + comp_obj, Groupoidal.forget_obj, lamObjFiber_obj_obj, whiskerLeftInvLamObjObjSigMap, lamObjFiberObjCompSigMap, whiskerRight_comp, eqToHom_whiskerRight, NatTrans.comp_app, whiskerRight_app, whiskerLeft_app, forget_map, lamObjFiberObjCompSigMap.app_base, sigmaMap_obj_base, eqToHom_app, eqToHom_refl, @@ -1170,9 +1216,11 @@ def lamMapFiber : @[simp] lemma lamMapFiber_id (x : Γ) : lamMapFiber A β (𝟙 x) = eqToHom (by simp) := by apply MorphismProperty.WideSubcategory.hom_ext - simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, Set.mem_setOf_eq, lamMapFiber, - whiskerLeftInvLamObjObjSigMap_id, MorphismProperty.WideSubcategory.coe_eqToHom] - rfl + apply ObjectProperty.hom_ext + simp only [ObjectProperty.homMk, + sigma.fstNatTrans_app, lamMapFiber, + whiskerLeftInvLamObjObjSigMap_id] + erw [MorphismProperty.WideSubcategory.coe_eqToHom, ObjectProperty.eqToHom_hom] lemma lamMapFiber_comp {x y z} (f : x ⟶ y) (g : y ⟶ z) : (lamMapFiber A β (f ≫ g)) @@ -1183,11 +1231,13 @@ lemma lamMapFiber_comp {x y z} (f : x ⟶ y) (g : y ⟶ z) : ≫ (((pi A (β ⋙ PGrpd.forgetToGrpd)).map g).map ((lamMapFiber A β) f)) ≫ (lamMapFiber A β g) := by apply MorphismProperty.WideSubcategory.hom_ext - simp only [sigma_obj, pi, Set.mem_setOf_eq, lamMapFiber, whiskerLeftInvLamObjObjSigMap_comp] + apply ObjectProperty.hom_ext + simp only [pi, lamMapFiber, whiskerLeftInvLamObjObjSigMap_comp] rw [MorphismProperty.WideSubcategory.comp_def, MorphismProperty.WideSubcategory.comp_def, MorphismProperty.WideSubcategory.coe_eqToHom] - simp + simp [ObjectProperty.homMk, ObjectProperty.FullSubcategory.comp_hom, + ObjectProperty.eqToHom_hom] rfl def lam : Γ ⥤ PGrpd.{u₁,u₁} := @@ -1240,9 +1290,9 @@ theorem lamObjFiber_naturality (x : Δ) : lamObjFiber A β (σ.obj x) ≍ apply Section.obj_hext · simp [sigmaObj_naturality, Functor.assoc] · simp - · simp only [sigma_obj, sigma.fstNatTrans_app, comp_obj] + · simp only [sigma.fstNatTrans_app, comp_obj] apply naturality_forget_heq_forget - · simp only [sigma_obj, sigma.fstNatTrans_app, lamObjFiber_obj_obj, comp_obj] + · simp only [sigma.fstNatTrans_app, lamObjFiber_obj_obj, comp_obj] apply lamObjFiberObj_naturality lemma lamObjFiberObjCompSigMap.app_naturality {x y} (f : x ⟶ y) (a) : @@ -1291,9 +1341,9 @@ lemma lam_comp_map {x y} (f : x ⟶ y) : · simp · simp [Functor.assoc] apply naturality_forget_heq_forget - · simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, comp_obj, Functor.assoc] + · simp only [sigma.fstNatTrans_app, comp_obj, Functor.assoc] rw [Functor.congr_obj (Functor.congr_hom (pi_comp A (β ⋙ PGrpd.forgetToGrpd) σ) f)] - simp only [pi_obj_α, comp_obj, Functor.comp_map, Grpd.comp_eq_comp, Grpd.eqToHom_obj, + simp only [comp_obj, Functor.comp_map, Grpd.comp_eq_comp, Grpd.eqToHom_obj, heq_cast_iff_heq, heq_eq_eq] congr 1 simp only [← heq_eq_eq, heq_cast_iff_heq] @@ -1332,46 +1382,99 @@ lemma strongTrans.app_lam_map_fiber {x y : ∫ A} (f : x ⟶ y) : PGrpd.mapFiber (ι A y.base ⋙ β) (Hom.fiber f) := by simp [lam, app, PGrpd.objFiber] +lemma strongTrans.twoCell_lam {x y : Γ} (f : x ⟶ y) : + strongTrans.twoCell (β ⋙ PGrpd.forgetToGrpd) (lam A β) + (lam_comp_forgetToGrpd ..) f = whiskerLeftInvLamObjObjSigMap A β f := by + change (Section.ι ((sigma.fstNatTrans A (β ⋙ PGrpd.forgetToGrpd)).app y)).map + (PGrpd.mapFiber' (α := lam A β) (A := pi A (β ⋙ PGrpd.forgetToGrpd)) rfl f) = _ + simp only [PGrpd.mapFiber'_rfl, PGrpd.mapFiber, lam_map_fib] + rfl + lemma strongTrans.twoCell_lam_app {x y : ∫ A} (f : x ⟶ y) : ((strongTrans.twoCell (β ⋙ PGrpd.forgetToGrpd) (lam A β) (lam_comp_forgetToGrpd ..) (Hom.base f)).app ((A.map (Hom.base f)).obj x.fiber)) = homMk (eqToHom (by - simp only [Functor.map_inv, sigma_obj, comp_obj, sigmaMap_obj_base, app_obj_base] + simp only [Functor.map_inv, comp_obj, sigmaMap_obj_base, app_obj_base] simp [← Functor.comp_obj, ← Grpd.comp_eq_comp])) (eqToHom (by - simp only [comp_obj, Functor.Grothendieck.forget_obj, sigma_obj, sigmaMap_obj_base, + simp only [ + Cat.Hom.obj, Grpd.forgetToCat, + comp_obj, sigmaMap_obj_base, Functor.comp_map, eqToHom_map, Functor.Grothendieck.forget_map, Functor.Grothendieck.base_eqToHom, sigmaMap_obj_fiber, Grpd.eqToHom_obj, ← heq_eq_eq, cast_heq_iff_heq] simp only [← Functor.comp_obj, ← Grpd.comp_eq_comp] - rw! [← Functor.map_comp, IsIso.hom_inv_id, CategoryTheory.Functor.map_id, Category.id_comp] - rfl) ≫ + rw! (castMode := .all) [← Functor.map_comp, IsIso.hom_inv_id, + CategoryTheory.Functor.map_id, Category.id_comp] + simp only [strongTrans.app_lam_obj_fiber] + have hc : (A.map (CategoryTheory.inv (Hom.base f))).obj + ((A.map (Hom.base f)).obj x.fiber) = x.fiber := by + simp [← Functor.comp_obj, ← Grpd.comp_eq_comp] + have gh {C D : Grpd} (h : C = D) : C.str'.toCategory ≍ D.str'.toCategory := by + cases h + rfl + congr! 1 + apply eq_of_heq + simp only [eqRec_heq_iff] + simp only [strongTrans.app, PGrpd.objFiber'_rfl, PGrpd.objFiber, + lam_obj_fib, lamObjFiber_obj_obj] + apply gh + simpa only [Functor.comp_obj, strongTrans.app_lam_obj_base, + lamObjFiberObj_obj_base, PGrpd.forgetToGrpd, + Functor.Grothendieck.forget_obj] using + congrArg (fun a => (β.obj ((ι A x.base).obj a)).base) hc + all_goals first + | (apply eq_of_heq + simp only [eqRec_heq_iff] + apply gh + simpa only [Functor.comp_obj, strongTrans.app_lam_obj_base, + lamObjFiberObj_obj_base, PGrpd.forgetToGrpd, + Functor.Grothendieck.forget_obj] using + congrArg (fun a => (β.obj ((A.map f.base ⋙ ι A y.base).obj a)).base) hc) + | (simp only [eqRec_heq_iff] + rfl)) ≫ (β.map ((ιNatTrans (Hom.base f)).app x.fiber)).fiber) := by - simp only [sigma_obj, lam, comp_obj, twoCell, sigma.fstNatTrans_app, pi_obj_α, - PGrpd.objFiber'_rfl, Set.mem_setOf_eq, PGrpd.mapFiber'_rfl, sigmaMap_obj_base, - Functor.Grothendieck.forget_obj, Functor.comp_map, Functor.Grothendieck.forget_map, - sigmaMap_obj_fiber] - convert_to (whiskerLeftInvLamObjObjSigMap A β f.base).app ((A.map f.base).obj x.fiber) = _ + rw [strongTrans.twoCell_lam] simp only [comp_obj, whiskerLeftInvLamObjObjSigMap, lamObjFiberObjCompSigMap, NatTrans.comp_app, whiskerLeft_app, lamObjFiberObjCompSigMap.app, sigmaMap_obj_base, - Functor.Grothendieck.forget_obj, Functor.comp_map, Functor.Grothendieck.forget_map, + Functor.comp_map, sigmaMap_obj_fiber, eqToHom_app] have h : (A.map (CategoryTheory.inv (Hom.base f))).obj ((A.map (Hom.base f)).obj x.fiber) = x.fiber := by simp [← Functor.comp_obj, ← Grpd.comp_eq_comp] - rw! [h] + rw! (castMode := .all) [h] simp only [eqToHom_refl, Category.comp_id, ← heq_eq_eq] congr 1 + apply eq_of_heq + simp only [heq_eqRec_iff, eqToHom_comp_heq_iff, + heq_eqToHom_comp_iff] + rfl lemma strongTrans.twoCell_lam_app_fiber {x y : ∫ A} (f : x ⟶ y) : ((strongTrans.twoCell (β ⋙ PGrpd.forgetToGrpd) (lam A β) (lam_comp_forgetToGrpd ..) (Hom.base f)).app ((A.map (Hom.base f)).obj x.fiber)).fiber = eqToHom (by - simp only [comp_obj, sigma_obj, sigmaMap_obj_base, Functor.Grothendieck.forget_obj, + simp only [ + Cat.Hom.obj, Grpd.forgetToCat, + comp_obj, sigmaMap_obj_base, twoCell_app_base, Functor.comp_map, eqToHom_map, Functor.Grothendieck.forget_map, Functor.Grothendieck.base_eqToHom, sigmaMap_obj_fiber] simp only [← Functor.comp_obj, ← Grpd.comp_eq_comp] - rw! [← Functor.map_comp, IsIso.hom_inv_id, CategoryTheory.Functor.map_id, Category.id_comp] - rfl + rw! (castMode := .all) [← Functor.map_comp, IsIso.hom_inv_id, + CategoryTheory.Functor.map_id, Category.id_comp] + simp only [strongTrans.app_lam_obj_fiber] + congr! 1 + apply eq_of_heq + simp only [eqRec_heq_iff] + have gh {C D : Grpd} (h : C = D) : C.str'.toCategory ≍ D.str'.toCategory := by + cases h + rfl + apply gh + simp only [CategoryTheory.Functor.comp_obj, PGrpd.forgetToGrpd, + Functor.Grothendieck.forget_obj, strongTrans.app_lam_obj_base] + exact congrArg (fun a => (β.obj ((ι A x.base).obj a)).base) + (by simp [← CategoryTheory.Functor.comp_obj, ← Grpd.comp_eq_comp]) + all_goals simp only [eqRec_heq_iff] + all_goals rfl ) ≫ (β.map ((ιNatTrans (Hom.base f)).app x.fiber)).fiber := by rw! [twoCell_lam_app] simp @@ -1386,8 +1489,8 @@ lemma mapStrongTrans_map_lam_map_fiber_fiber_heq {x y} (f : x ⟶ y) : rw [strongTrans.twoCell_lam_app_fiber] slice_lhs 2 3 => rw [Functor.map_comp, eqToHom_map] rw [strongTrans.app_lam_map_fiber] - simp only [mapStrongTrans_obj_base, comp_obj, Functor.Grothendieck.forget_obj, sigma_obj, - sigmaMap_obj_base, Functor.comp_map, Functor.Grothendieck.forget_map, sigmaMap_obj_fiber, + simp only [mapStrongTrans_obj_base, comp_obj, + sigmaMap_obj_base, Functor.comp_map, sigmaMap_obj_fiber, comp_base, strongTrans.app_lam_map_base, Category.assoc, eqToHom_trans_assoc, eqToHom_comp_heq_iff] simp [← Functor.comp_map, PGrpd.mapFiber] @@ -1400,9 +1503,10 @@ lemma mapStrongTrans_map_lam_map_fiber_fiber_heq {x y} (f : x ⟶ y) : have := Functor.congr_map β this simp [Functor.Grothendieck.Hom.congr this] rw! [Category.comp_id, CategoryTheory.Functor.map_id] - simp only [Grothendieck.Hom.id_base, Grpd.id_eq_id, id_obj, eqToHom_refl, Functor.id_map, + simp only [Grothendieck.Hom.id_base, Grpd.id_eq_id, id_obj, eqToHom_refl, Category.id_comp, heq_eq_eq] erw [Category.comp_id] + simp [PGrpd.forgetToGrpd] lemma inversion_lam : inversion (β ⋙ PGrpd.forgetToGrpd) (lam A β) (lam_comp_forgetToGrpd ..) = β := by @@ -1455,9 +1559,10 @@ lemma strongTrans.twoCell_app_inversion {x y} (f : x ⟶ y) (a) : simp lemma mapStrongTrans_obj_inversion_fiber {x y} (f : x ⟶ y) (a) : - ((mapStrongTrans B s hs).obj ((A.map f ⋙ ι A y).obj ((A.map (CategoryTheory.inv f)).obj a))).fiber = + ((mapStrongTrans B s hs).obj + ((A.map f ⋙ ι A y).obj ((A.map (CategoryTheory.inv f)).obj a))).fiber = (strongTrans.app B s hs y).obj a := by - simp only [Functor.comp_obj, mapStrongTrans_obj_base, ι_obj_base, sigma_obj, + simp only [Functor.comp_obj, mapStrongTrans_obj_base, ι_obj_base, mapStrongTrans_obj_fiber, ι_obj_fiber, Functor.map_inv] simp [← Functor.comp_obj, ← Grpd.comp_eq_comp] @@ -1481,19 +1586,19 @@ lemma lamObjFiberObjCompSigMap_app_inversion {x y} (f : x ⟶ y) (a) : apply HEq.trans _ h fapply Functor.Groupoidal.Hom.hext' · simp - · simp only [Functor.map_inv, Functor.comp_obj, mapStrongTrans_obj_base, ι_obj_base, sigma_obj, + · simp only [Functor.map_inv, Functor.comp_obj, mapStrongTrans_obj_base, ι_obj_base, mapStrongTrans_map_base, Functor.Groupoidal.ιNatTrans_app_base, sigma_map] apply Grpd.Functor.hcongr_obj · rw [inversion_comp_forgetToGrpd] · rw [inversion_comp_forgetToGrpd] · rw [inversion_comp_forgetToGrpd] · rw [Functor.map_inv] - simp only [mapStrongTrans_obj_fiber, ι_obj_base, sigma_obj, ι_obj_fiber] + simp only [mapStrongTrans_obj_fiber, ι_obj_base, ι_obj_fiber] apply Grpd.Functor.hcongr_obj rfl _ _ HEq.rfl · simp [inversion_comp_forgetToGrpd] · apply lamObjFiber_obj_obj_inversion_heq · simp only [Functor.map_inv, Functor.comp_obj, mapStrongTrans_obj_base, ι_obj_base, - mapStrongTrans_obj_fiber, sigma_obj, ι_obj_fiber] + mapStrongTrans_obj_fiber, ι_obj_fiber] apply Grpd.Functor.hcongr_obj · rfl · simp @@ -1510,7 +1615,7 @@ lemma whiskerLeftInvLamObjObjSigMap_inversion_app {x y} (f : x ⟶ y) (a) : (strongTrans.twoCell B s hs f).app a := by simp [whiskerLeftInvLamObjObjSigMap, lamObjFiberObjCompSigMap] have h := Functor.congr_obj (((pi A B).map f).obj (PGrpd.objFiber' hs x)).obj.property a - simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, Functor.comp_obj, + simp only [sigma.fstNatTrans_app, Functor.comp_obj, Functor.Groupoidal.forget_obj, Functor.id_obj] at h exact (comp_eqToHom_heq ..).trans (lamObjFiberObjCompSigMap_app_inversion ..) @@ -1524,13 +1629,13 @@ lemma lamMapFiber_inversion_heq {x y} (f : x ⟶ y) : · rw! (castMode := .all) [inversion_comp_forgetToGrpd] congr 1 rw! [lamObjFiber_inversion_heq, PGrpd.objFiber'_heq] - simp only [pi_obj_α, Functor.Grothendieck.forget_obj, Grpd.coe_of, ← heq_eq_eq, - heq_cast_iff_heq, eqRec_heq_iff_heq, cast_heq_iff_heq] + simp only [Grpd.coe_of, ← heq_eq_eq, + heq_cast_iff_heq, eqRec_heq_iff, cast_heq_iff_heq] rfl · apply lamObjFiber_inversion_heq' · intro a a' ha subst ha - simp only [sigma_obj, sigma.fstNatTrans_app, pi_obj_α, Set.mem_setOf_eq, + simp only [sigma.fstNatTrans_app, lamMapFiber] exact whiskerLeftInvLamObjObjSigMap_inversion_app A B s hs f a @@ -1593,6 +1698,7 @@ lemma equivInv_equivFun (F : Δ ⥤ ∫ pi A B) (hF : F ⋙ forget = σ) : apply (isPullback _).hom_ext · rw [Functor.IsPullback.fac_left, Functor.IsPullback.fac_left, lam_inversion] · rw! [Functor.IsPullback.fac_right, hF] + rfl lemma equivFun_equivInv (G : ∫ σ ⋙ A ⥤ ∫ B) (hG : G ⋙ forget = pre A σ) : equivFun B (equivInv B G hG) (equivInv_comp_forget B G hG) = G := by @@ -1601,6 +1707,7 @@ lemma equivFun_equivInv (G : ∫ σ ⋙ A ⥤ ∫ B) (hG : G ⋙ forget = pre A · have : pre A σ ⋙ B = (G ⋙ toPGrpd B) ⋙ PGrpd.forgetToGrpd := by rw [Functor.assoc, toPGrpd_forgetToGrpd, ← Functor.assoc, hG] rw! [Functor.IsPullback.fac_left, Functor.IsPullback.fac_left, this, inversion_lam] + rfl · rw [Functor.IsPullback.fac_right, hG] lemma equivFun_comp {Δ' : Type u} [Groupoid.{v} Δ'] {σ' : Δ' ⥤ Γ} (τ : Δ' ⥤ Δ) (hτ : τ ⋙ σ = σ') @@ -1691,7 +1798,7 @@ lemma unLam_lam {Γ : Ctx} {A : Γ ⟶ U.{v}.Ty} (B : U.ext A ⟶ U.Ty) (b : U.e lemma lam_unLam {Γ : Ctx} {A : Γ ⟶ U.{v}.Ty} (B : U.ext A ⟶ U.Ty) (f : Γ ⟶ U.Tm) (f_tp : f ≫ U.tp = UPi.Pi B) : UPi.lam (UPi.unLam B f f_tp) = f := by - simp only [U_Tm, lam, USig.SigAux, unLam, toCoreAsSmallEquiv.symm_apply_eq] + simp only [lam, USig.SigAux, unLam, toCoreAsSmallEquiv.symm_apply_eq] erw [toCoreAsSmallEquiv.apply_symm_apply] rw [pi.lam_inversion] diff --git a/HoTTLean/Groupoids/Sigma.lean b/HoTTLean/Groupoids/Sigma.lean index dcdc59ab..46ee66b9 100644 --- a/HoTTLean/Groupoids/Sigma.lean +++ b/HoTTLean/Groupoids/Sigma.lean @@ -1,12 +1,16 @@ import HoTTLean.Groupoids.UnstructuredModel import HoTTLean.ForMathlib.CategoryTheory.RepPullbackCone +set_option backward.isDefEq.respectTransparency false + noncomputable section namespace GroupoidModel open CategoryTheory Model UnstructuredUniverse Opposite Functor.Groupoidal PGrpd +attribute [local simp] Cat.Hom.obj Cat.Hom.map Cat.Hom₂.app + Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor attribute [local simp] eqToHom_map Grpd.id_eq_id Grpd.comp_eq_comp Functor.id_comp namespace FunctorOperation @@ -49,7 +53,8 @@ def sigmaMap : sigmaObj B x ⥤ sigmaObj B y := @[simp] theorem sigmaMap_obj_fiber (a) : ((sigmaMap B f).obj a).fiber = (B.map ((ιNatTrans f).app a.base)).obj (a.fiber) := rfl -theorem ιNatTrans_app_base (a : sigmaObj B x) : ((ιNatTrans f).app a.base) = homMk f (𝟙 (A.map f).obj a.base) := +theorem ιNatTrans_app_base (a : sigmaObj B x) : + ((ιNatTrans f).app a.base) = homMk f (𝟙 (A.map f).obj a.base) := rfl @[simp] theorem sigmaMap_map_base {a b : sigmaObj B x} {p : a ⟶ b} : @@ -111,14 +116,15 @@ variable {z : Γ} {f} {g : y ⟶ z} apply hext · simp · simp only [sigmaObj, Functor.comp_obj, pre_obj_fiber, map_obj_fiber, Functor.whiskerRight_app, - ιNatTrans_comp_app, Functor.map_comp, eqToHom_map, Grpd.comp_eq_comp, Grpd.eqToHom_obj, cast_heq_iff_heq, heq_eq_eq] + ιNatTrans_comp_app, Functor.map_comp, eqToHom_map, Grpd.comp_eq_comp, Grpd.eqToHom_obj, + cast_heq_iff_heq, heq_eq_eq] aesop_cat @[simp] theorem sigmaMap_comp_map {B : ∫(A) ⥤ Grpd.{v₃,u₃}} {x y z : Γ} {f : x ⟶ y} {g : y ⟶ z} {p q : sigmaObj B x} (hpq : p ⟶ q) {h1 : (sigmaMap B (f ≫ g)).obj p = (sigmaMap B g).obj ((sigmaMap B f).obj p)} - {h2 : (sigmaMap B g).obj ((sigmaMap B f).obj q) = (sigmaMap B (f ≫ g)).obj q} - : (sigmaMap B (f ≫ g)).map hpq = + {h2 : (sigmaMap B g).obj ((sigmaMap B f).obj q) = (sigmaMap B (f ≫ g)).obj q} : + (sigmaMap B (f ≫ g)).map hpq = eqToHom h1 ≫ (sigmaMap B g).map ((sigmaMap B f).map hpq) ≫ eqToHom h2 := by have h : B.map ((ιNatTrans (f ≫ g)).app q.base) = B.map ((ιNatTrans f).app q.base) @@ -167,7 +173,7 @@ theorem sigma_naturality_aux (x) : rfl lemma whiskerRight_ιNatTrans_naturality {x y : Δ} (f : x ⟶ y) : - Functor.whiskerRight (ιNatTrans f) (pre A σ ⋙ B) = + Functor.whiskerRight (ιNatTrans f) (pre A σ ⋙ B) = eqToHom (sigma_naturality_aux B σ x) ≫ Functor.whiskerRight (ιNatTrans (σ.map f)) B ≫ eqToHom (by simp [Functor.assoc, sigma_naturality_aux B σ y]) := by aesop @@ -326,7 +332,7 @@ lemma assocFibMap_comp {x y z : ∫ B} (f : x ⟶ y) (g : y ⟶ z) : · simp · simp conv => left; rw! (castMode := .all) [this] - simp only [Functor.comp_obj, Grpd.map_comp_map, Category.assoc, eqRec_heq_iff_heq, + simp only [Functor.comp_obj, Grpd.map_comp_map, Category.assoc, eqRec_heq_iff, eqToHom_comp_heq_iff, heq_eq_eq] congr 1 simp [← heq_eq_eq] @@ -412,7 +418,8 @@ lemma assocFibMap_assocHom_app {c c' : Γ} (f : c ⟶ c') (x : sigmaObj B c) : end def assoc : ∫ B ≅≅ ∫ sigma A B := .symm <| functorIsoFrom - (assocFib B) (assocHom B) (by simp) (by simp [assocHom_comp]) + (assocFib B) (assocHom B) (by simp) + (by intro c₁ c₂ c₃ f g; rw [assocHom_comp]; rfl) (forget ⋙ forget) assocFibObj assocFibMap assocFibMap_id assocFibMap_comp assocFib_comp_forget assocFibObj_assocFib_obj assocFibMap_assocFib_map assocFib_forget_comp_forget_obj assocHom_app_comp_pre_map_assocFibMap @@ -457,11 +464,7 @@ lemma assoc_hom_map_fiber_base {x y} (f : x ⟶ y) : ((assoc B).hom.map f).fiber @[simp] lemma assoc_hom_map_fiber_fiber {x y} (f : x ⟶ y) : ((assoc B).hom.map f).fiber.fiber = - eqToHom (by - simp [assoc_hom] - rw [← Functor.comp_obj, ← Grpd.comp_eq_comp, ← Functor.map_comp] - congr 2 - fapply Hom.ext <;> simp) ≫ f.fiber := + eqToHom (assocFibMap_aux f) ≫ f.fiber := rfl @[simp] @@ -478,8 +481,8 @@ lemma assoc_inv_obj_fiber (x) : ((assoc B).inv.obj x).fiber = x.fiber.fiber := @[simp] lemma assoc_inv_map_base_base {x y} (f : x ⟶ y) : ((assoc B).inv.map f).base.base = f.base := by - simp only [assoc, Functor.Iso.symm_inv, functorIsoFrom_hom_obj, sigma_obj, assocFib, - functorIsoFrom_hom_map, sigma_map, comp_base, pre_map_base, assocIso_hom_app_base_base, + simp only [assoc, Functor.Iso.symm_inv, assocFib, + functorIsoFrom_hom_map, comp_base, pre_map_base, assocIso_hom_app_base_base, ι_map_base, ι_obj_base] erw [Category.comp_id] rfl @@ -487,22 +490,38 @@ lemma assoc_inv_map_base_base {x y} (f : x ⟶ y) : ((assoc B).inv.map f).base.b @[simp] lemma assoc_inv_map_base_fiber {x y} (f : x ⟶ y) : ((assoc B).inv.map f).base.fiber = eqToHom (by simp) ≫ f.fiber.base := by - simp only [assoc, Functor.Iso.symm_inv, functorIsoFrom_hom_obj, sigma_obj, assocFib, - functorIsoFrom_hom_map, sigma_map, comp_base, assocIso_hom_app_base_base, - Functor.Groupoidal.comp_fiber, assocIso_hom_app_base_fiber, Functor.comp_obj, - CategoryTheory.Functor.map_id, Category.id_comp] - rw! [pre_map_base, ι_map_fiber] + dsimp only [assoc, functorIsoFrom, Functor.Grothendieck.functorIsoFrom, + Functor.Grothendieck.functorFrom, assocFib] + simp [assocHom, assocIso] + dsimp only [pre, Functor.Grothendieck.pre, Functor.Grothendieck.functorTo] + simp [preNatIso, Functor.Grothendieck.preNatIso, Functor.Grothendieck.transportIso] + dsimp [Hom.base, Hom.fiber, ι, Functor.Groupoidal.functorTo, ιNatIso, + Functor.Groupoidal.isoMk] simp + dsimp [ιNatTrans, Functor.Grothendieck.ιNatTrans, Functor.Grothendieck.ι, + Functor.Grothendieck.forget, Functor.Grothendieck.functorTo] + rw! (transparency := .all) [CategoryTheory.Functor.map_id (A.map (𝟙 y.base))] + rw! (transparency := .all) [Category.id_comp, eqToHom_trans_assoc] rfl @[simp] lemma assoc_inv_map_fiber {x y} (f : x ⟶ y) : ((assoc B).inv.map f).fiber = eqToHom (by - simp only [assoc_inv_obj_fiber, sigma_map, - Functor.comp_map, sigmaMap_obj_fiber] + simp only [assoc_inv_obj_fiber, + Functor.comp_map] + change (B.map ((assoc B).inv.map f).base).obj x.fiber.fiber = + (B.map ((ι A y.base).map f.fiber.base)).obj + ((B.map ((ιNatTrans f.base).app x.fiber.base)).obj x.fiber.fiber) conv => rhs; rw [← Functor.comp_obj, ← Grpd.comp_eq_comp, ← Functor.map_comp] rfl) ≫ f.fiber.fiber := by - simp [assoc] + dsimp only [assoc, functorIsoFrom, Functor.Grothendieck.functorIsoFrom, + Functor.Grothendieck.functorFrom, assocFib, pre, Functor.Grothendieck.pre, + Functor.Grothendieck.functorTo, Hom.fiber] + simp [assocHom, assocIso, preNatIso, Functor.Grothendieck.preNatIso, + Functor.Grothendieck.transportIso, Functor.Grothendieck.isoMk] + change eqToHom _ ≫ (B.map _).map (𝟙 _) ≫ f.fiber.fiber = _ + rw! (castMode := .all) (transparency := .all) [CategoryTheory.Functor.map_id] + simp rfl lemma assocFibMap_pre_pre_map {Δ : Type u₄} [Groupoid.{v₄} Δ] {σ : Δ ⥤ Γ} {x y} (f : x ⟶ y) : @@ -511,6 +530,7 @@ lemma assocFibMap_pre_pre_map {Δ : Type u₄} [Groupoid.{v₄} Δ] {σ : Δ ⥤ rw [pre_obj_base, pre_obj_base] have pre_pre_obj_base_fiber (x) : ((pre B (pre A σ)).obj x).base.fiber = x.base.fiber := by rw! (castMode := .all) [pre_obj_base, pre_obj_fiber] + rfl simp [assocFibMap] apply Hom.hext' · rw [sigma_naturality_aux] @@ -524,10 +544,12 @@ lemma assocFibMap_pre_pre_map {Δ : Type u₄} [Groupoid.{v₄} Δ] {σ : Δ ⥤ simp only [← heq_eq_eq, cast_heq_iff_heq] apply Functor.Groupoidal.hext' · rw! (castMode := .all) [sigma_naturality_aux, pre_pre_obj_base_base] + rfl · simp · simp · apply Functor.Groupoidal.hext' · rw! (castMode := .all) [sigma_naturality_aux, pre_pre_obj_base_base] + rfl · simp [pre_pre_obj_base_fiber] · simp · simp only [sigmaMap_obj_base, objMk_base, homMk_base, Functor.comp_obj, Functor.comp_map] @@ -537,7 +559,7 @@ lemma assocFibMap_pre_pre_map {Δ : Type u₄} [Groupoid.{v₄} Δ] {σ : Δ ⥤ lemma assoc_comp_fiber {Δ : Type u₄} [Groupoid.{v₄} Δ] (σ : Δ ⥤ Γ) {x y} (f : x ⟶ y) : Hom.fiber (((assoc (pre A σ ⋙ B)).hom ⋙ map (eqToHom (sigma_naturality ..).symm) ⋙ pre (sigma A B) σ).map f) ≍ Hom.fiber ((pre B (pre A σ) ⋙ (assoc B).hom).map f) := by - simp only [assoc_hom, Functor.comp_obj, sigma_obj, Functor.comp_map, sigma_map, pre_map_fiber, + simp only [assoc_hom, Functor.comp_obj, Functor.comp_map, pre_map_fiber, map_map_fiber, Functor.Groupoidal.functorTo_obj_base, Functor.Groupoidal.forget_obj, Functor.Groupoidal.functorTo_map_base, forget_map, Grpd.comp_eq_comp, Functor.Groupoidal.functorTo_obj_fiber, assocFibObj, Functor.Groupoidal.functorTo_map_fiber, @@ -560,7 +582,7 @@ lemma assoc_comp {Δ : Type u₄} [Groupoid.{v₄} Δ] (σ : Δ ⥤ Γ) : conv => right; rw [← Functor.assoc, pre_comp_forget] simp only [Functor.assoc, pre_comp_forget] · intro x - simp only [Functor.comp_obj, sigma_obj, pre_obj_fiber, map_obj_fiber, assoc_hom_obj_base, + simp only [Functor.comp_obj, pre_obj_fiber, map_obj_fiber, assoc_hom_obj_base, eqToHom_app, heq_eq_eq] rw [eqToHom_eq_homOf_map] apply Functor.Groupoidal.hext @@ -571,6 +593,7 @@ lemma assoc_comp {Δ : Type u₄} [Groupoid.{v₄} Δ] (σ : Δ ⥤ Γ) : rw [eqToHom_app, Grpd.eqToHom_obj] simp rw! (castMode := .all) [assoc_hom_obj_fiber_fiber, assoc_hom_obj_fiber_fiber, pre_obj_fiber] + rfl · rw [← Functor.assoc, ι_comp_pre A σ x.base.base] · intro x y f apply assoc_comp_fiber B σ f @@ -651,7 +674,7 @@ def assoc : U.ext B ≅ U.ext (Sig.{v₁,v₂,u} B) := Grpd.mkIso' (sigma.assoc (toCoreAsSmallEquiv B)) ≪≫ eqToIso (by dsimp [U.ext, Sig]; rw [toCoreAsSmallEquiv.apply_symm_apply]) -set_option maxHeartbeats 400000 in +set_option maxHeartbeats 800000 in lemma assoc_comp : (assoc (U.substWk σ A σA eq ≫ B)).hom ≫ U.substWk σ (Sig.{v₁,v₂,u} B) (Sig.{v₁,v₂,u} (U.substWk σ A σA eq ≫ B)) (Sig_comp.{v₁,v₂,u} ..).symm = U.substWk (U.substWk σ A σA eq) B (U.substWk σ A σA eq ≫ B) rfl ≫ (assoc B).hom := by @@ -662,7 +685,8 @@ lemma assoc_comp : (assoc (U.substWk σ A σA eq ≫ B)).hom ≫ U.substWk σ (S rw! (castMode := .all) [toCoreAsSmallEquiv.apply_symm_apply] rw! [U.substWk_eq] simp only [pre_comp, Functor.id_comp] - apply sigma.assoc_comp' (toCoreAsSmallEquiv B) (σ := σ) (toCoreAsSmallEquiv σA) + exact sigma.assoc_comp' (toCoreAsSmallEquiv B) (σ := σ) (toCoreAsSmallEquiv σA) + (by cases eq; rfl) lemma assoc_disp : (assoc B).hom ≫ U.disp (Sig.{v₁,v₂,u} B) = U.disp B ≫ U.disp A := by simpa [assoc] using sigma.assoc_hom_comp_forget _ diff --git a/HoTTLean/Groupoids/UnstructuredModel.lean b/HoTTLean/Groupoids/UnstructuredModel.lean index c7a538ec..9375e6f7 100644 --- a/HoTTLean/Groupoids/UnstructuredModel.lean +++ b/HoTTLean/Groupoids/UnstructuredModel.lean @@ -9,6 +9,8 @@ import HoTTLean.Groupoids.IsPullback Here we construct universes for the groupoid natural model. -/ +set_option backward.isDefEq.respectTransparency false + universe w v u v₁ u₁ v₂ u₂ v₃ u₃ noncomputable section @@ -43,10 +45,10 @@ def asSmallClosedType : (tensorUnit _ : Ctx) ⟶ Ty.{v+1, max u (v+2)} := def isoExtAsSmallClosedTypeHom : Core (AsSmall.{max u (v+2)} Grpd.{v,v}) ⥤ ∫(toCoreAsSmallEquiv (asSmallClosedType.{v, max u (v + 2)})) where - obj X := objMk ⟨⟨⟩⟩ ⟨AsSmall.up.obj.{_,_,v+1} (AsSmall.down.obj X.of)⟩ + obj X := objMk ⟨⟨⟩⟩ ⟨AsSmall.up.obj (AsSmall.down.obj X.of)⟩ map {X Y} F := homMk (𝟙 _) ⟨{ - hom := AsSmall.up.map.{_,_,v+1} (AsSmall.down.map F.iso.hom) - inv := AsSmall.up.map.{_,_,v+1} (AsSmall.down.map (F.iso.inv)) + hom := AsSmall.up.map (AsSmall.down.map F.iso.hom) + inv := AsSmall.up.map (AsSmall.down.map (F.iso.inv)) hom_inv_id := by simp only [← Functor.map_comp, Iso.hom_inv_id] rfl @@ -57,11 +59,11 @@ def isoExtAsSmallClosedTypeHom : def isoExtAsSmallClosedTypeInv : ∫(toCoreAsSmallEquiv (asSmallClosedType.{v, max u (v + 2)})) ⥤ Core (AsSmall.{max u (v+2)} Grpd.{v,v}) where - obj X := ⟨AsSmall.up.obj (AsSmall.down.obj.{_,_,v+1} X.fiber.of)⟩ + obj X := ⟨AsSmall.up.obj (AsSmall.down.obj X.fiber.of)⟩ map {X Y} F := ⟨{ - hom := AsSmall.up.map.{_,_,max u (v+2)} + hom := AsSmall.up.map (AsSmall.down.map F.fiber.iso.hom) - inv := AsSmall.up.map.{_,_,max u (v+2)} + inv := AsSmall.up.map (AsSmall.down.map F.fiber.iso.inv) hom_inv_id := by simp only [← Functor.map_comp, Iso.hom_inv_id] @@ -99,11 +101,15 @@ namespace U theorem substWk_eq (A : Γ ⟶ U.Ty.{v}) (σA : Δ ⟶ U.Ty.{v}) (eq) : U.substWk σ A σA eq = map (eqToHom (by subst eq; rfl)) ⋙ pre (toCoreAsSmallEquiv A) σ := by + subst σA apply (U.disp_pullback A).hom_ext · rw [substWk_var] simp [var, Grpd.comp_eq_comp] - rw [← toCoreAsSmallEquiv_symm_apply_comp_left, Functor.assoc, pre_toPGrpd, - map_eqToHom_toPGrpd] + simp only [map_id_eq] + change _ = pre (toCoreAsSmallEquiv A) σ ⋙ + toCoreAsSmallEquiv.symm (toPGrpd (toCoreAsSmallEquiv A)) + rw [← toCoreAsSmallEquiv_symm_apply_comp_left, pre_toPGrpd] + rfl · rw [substWk_disp] simp [Grpd.comp_eq_comp, Functor.assoc] erw [pre_comp_forget, ← Functor.assoc, map_forget] diff --git a/HoTTLean/Model/Natural/Interpretation.lean b/HoTTLean/Model/Natural/Interpretation.lean index 569dfdfc..8023fbc8 100644 --- a/HoTTLean/Model/Natural/Interpretation.lean +++ b/HoTTLean/Model/Natural/Interpretation.lean @@ -10,6 +10,8 @@ macro "simp_part" loc:(Lean.Parser.Tactic.location)? : tactic => Part.map_some, Part.mem_bind_iff, Part.mem_some_iff, exists_true_left, exists_const] $(loc)?) +set_option backward.isDefEq.respectTransparency false + universe v u open CategoryTheory Limits @@ -91,8 +93,7 @@ def disp {Γ Γ' : 𝒞} : s.ExtSeq Γ Γ' → (Γ' ⟶ Γ) Δ ⊢ σ : Γ d : Γ ≤ Γ' ----------------------------- Δ ≤ Δ.d[σ] Δ.d[σ] ⊢ σ.d : Γ' -``` -where +``` where ``` Δ ⊢ σ : Γ d : Γ ≤ Γ.Aₙ.….A₁ ----------------------------- @@ -477,6 +478,7 @@ theorem mem_ofTerm_app {Γ l i j B f a} {llen : l < s.length + 1} {x} : ∃ h, x = s.mkApp ilen llen _ B' f' h a' eq := by dsimp only [ofTerm]; simp_part; simp only [exists_prop_eq'] +set_option maxHeartbeats 800000 in @[simp] theorem mem_ofTerm_pair {Γ l i j B t u} {llen : l < s.length + 1} {x} : x ∈ I.ofTerm Γ l (.pair i j B t u) llen ↔ @@ -700,7 +702,7 @@ theorem mem_ofType_ofTerm_subst' {full} simp [ofTerm_bvar] at H simp [Expr.subst] induction σ generalizing i with simp [CSb.toSb, *] - | wk => exact CObj.mem_var_succ.2 ⟨_, ‹_›, rfl⟩ + | wk => exact ⟨_, ‹_›, rfl⟩ | @comp _ _ _ _ _ full σ τ ih1 ih2 => simp [Expr.comp] cases full with @@ -796,7 +798,9 @@ theorem mem_ofType_of_isClosed {e l} (e_cl : e.isClosed) isTerminal_yUnit.from y(Γ.1) ≫ se ∈ I.ofType Γ l e hl := by rcases Γ with ⟨_, ext⟩ induction ext - · convert se_mem; simp + · convert se_mem <;> try rfl + have h : isTerminal.from (𝟭_ 𝒞) = 𝟙 _ := isTerminal.hom_ext _ _ + simp [] · rename_i X se_mem have := I.mem_ofType_wk (X := X) (by omega) se_mem convert this using 1 <;> @@ -1060,7 +1064,8 @@ theorem EqTmIH.idRec {Γ A M M' t t' r r' u u' h h' l l'} : refine ⟨_, hΓ, _, _, (I.mem_ofType_ofTerm_subst _ (.snoc (.sub1 _ _ _ utp hu) _ _ _ ?_ hh) ?_).1 hM, _, I.mem_ofTerm_idRec.2 ⟨_, _, ht, _, ttp, B, ?b, _, hM, _, hr, ?a, _, hu, utp, _, hh, htp, rfl⟩, - I.mem_ofTerm_idRec.2 ⟨_, _, ht', _, ttp, B, ?b, _, hM', _, hr', ?a, _, hu', utp, _, hh', htp, rfl⟩, + I.mem_ofTerm_idRec.2 + ⟨_, _, ht', _, ttp, B, ?b, _, hM', _, hr', ?a, _, hu', utp, _, hh', htp, rfl⟩, mkIdRec_tp ..⟩ · rw [htp, Beq, comp_mkId] · congr 1 <;> simp @@ -1167,7 +1172,8 @@ theorem EqTmIH.pair_fst_snd {Γ A B p l l'} : exact have h1 := I.mem_ofTerm_fst.2 ⟨by omega, _, hA, _, hB, _, hp, ptp, rfl⟩ have h2 := I.mem_ofTerm_snd.2 ⟨by omega, _, hA, _, hB, _, hp, ptp, rfl⟩ - have pr := I.mem_ofTerm_pair.2 ⟨rfl, _, h1, _, mkFst_tp .., _, hB, _, h2, mkSnd_tp .., by simp⟩ + have pr := I.mem_ofTerm_pair.2 + ⟨rfl, _, h1, _, mkFst_tp .., _, hB, _, h2, mkSnd_tp .., by simp⟩ ⟨_, hΓ, _, _, hP, _, hp, pr, ptp⟩ theorem EqTmIH.code_el {Γ a l} : diff --git a/HoTTLean/Model/Natural/NaturalModel.lean b/HoTTLean/Model/Natural/NaturalModel.lean index 3671be69..56259af1 100644 --- a/HoTTLean/Model/Natural/NaturalModel.lean +++ b/HoTTLean/Model/Natural/NaturalModel.lean @@ -13,8 +13,15 @@ universe v u noncomputable section +set_option backward.isDefEq.respectTransparency false + open CategoryTheory Limits Opposite +attribute [local simp] CategoryTheory.Limits.pullback.lift_fst + CategoryTheory.Limits.pullback.lift_snd + CategoryTheory.Limits.pullback.lift_fst_assoc + CategoryTheory.Limits.pullback.lift_snd_assoc + namespace NaturalModel /-- A natural model with support for dependent types (and nothing more). @@ -267,6 +274,7 @@ lemma snd_mk (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ X) : snd M (mk M A B) _ (fst_mk ..) = B := by dsimp only [snd, mk] rw! [UvPoly.Equiv.snd'_mk'] + rfl section variable {Δ : Ctx} {σ : Δ ⟶ Γ} {AB : y(Γ) ⟶ M.Ptp.obj X} @@ -290,16 +298,19 @@ theorem snd_comp_left {A} (eqA : fst M AB = A) {σA} (eqσ : ym(σ) ≫ A = σA) have H2 : IsPullback ym(M.disp σA) (M.var σA) (ym(σ) ≫ UvPoly.Equiv.fst M.uvPolyTp X AB) M.uvPolyTp.p := by rw [← fst, eqA, eqσ]; exact (M.disp_pullback _).flip - convert UvPoly.Equiv.snd'_comp_left M.uvPolyTp X AB H1 _ H2 + dsimp only [snd] + convert UvPoly.Equiv.snd'_comp_left M.uvPolyTp X AB H1 _ H2 using 1 + congr 1 apply H1.hom_ext <;> simp [← Functor.map_comp, substWk] theorem mk_comp_left {Δ Γ : Ctx} (M : Universe Ctx) (σ : Δ ⟶ Γ) {X : Psh Ctx} (A : y(Γ) ⟶ M.Ty) (σA) (eq : ym(σ) ≫ A = σA) (B : y(M.ext A) ⟶ X) : ym(σ) ≫ PtpEquiv.mk M A B = PtpEquiv.mk M σA (ym(M.substWk σ A _ eq) ≫ B) := by - dsimp [PtpEquiv.mk] + dsimp only [PtpEquiv.mk] have h := UvPoly.Equiv.mk'_comp_left M.uvPolyTp X A (M.disp_pullback A).flip B ym(σ) σA eq (M.disp_pullback σA).flip - convert h + refine h.trans ?_ + congr 2 apply (M.disp_pullback _).hom_ext · simp · simp [← Functor.map_comp, substWk_disp] @@ -312,8 +323,8 @@ theorem mk_comp_right {Γ : Ctx} (M : Universe Ctx) theorem ext {AB AB' : y(Γ) ⟶ M.Ptp.obj X} (A := fst M AB) (eq : fst M AB = A := by rfl) (h1 : fst M AB = fst M AB') - (h2 : snd M AB A eq = snd M AB' A (h1 ▸ eq)) - : AB = AB' := UvPoly.Equiv.ext' _ _ _ h1 h2 + (h2 : snd M AB A eq = snd M AB' A (h1 ▸ eq)) : + AB = AB' := UvPoly.Equiv.ext' _ _ _ h1 h2 theorem eta (AB : y(Γ) ⟶ M.Ptp.obj X) : mk M (fst M AB) (snd M AB) = AB := .symm <| ext _ _ rfl (by simp) (by simp) @@ -373,8 +384,8 @@ theorem fst_tp (ab : y(Γ) ⟶ M.uvPolyTp.compDom N.uvPolyTp) : have : pullback.snd (M.uvPolyTp.fstProj N.Ty) M.tp ≫ M.tp = pullback.fst (M.uvPolyTp.fstProj N.Ty) M.tp ≫ M.uvPolyTp.fstProj N.Ty := Eq.symm pullback.condition - simp [PtpEquiv.fst, fst, this] - rfl + simp [PtpEquiv.fst, fst, Equiv.fst_eq, UvPoly.compP, + PartialProduct.fan, uvPolyTp, ← pullback.condition] theorem comp_fst (ab : y(Γ) ⟶ M.uvPolyTp.compDom N.uvPolyTp) (σ : y(Δ) ⟶ y(Γ)) : σ ≫ fst ab = fst (σ ≫ ab) := by simp [fst] @@ -424,7 +435,7 @@ theorem snd_tp (ab : y(Γ) ⟶ M.uvPolyTp.compDom N.uvPolyTp) snd ab ≫ N.tp = ym(M.sec _ (fst ab) eq) ≫ dependent ab A eq := by simp [snd, pullback.condition, dependent, PtpEquiv.snd, Equiv.snd'_eq] simp only [← Category.assoc]; congr! 1 - apply pullback.hom_ext <;> simp [fst, UvPoly.compP] + apply pullback.hom_ext <;> simp [fst, UvPoly.compP, PartialProduct.fan, uvPolyTp] /-- Universal property of `compDom`, constructing a map into `compDom`. -/ def mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) (B : y(M.ext A) ⟶ N.Ty) (β : y(Γ) ⟶ N.Tm) @@ -441,7 +452,7 @@ def mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) (B : y(M.ext A) ⟶ N.Ty @[simp] theorem fst_mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) (B : y(M.ext A) ⟶ N.Ty) (β : y(Γ) ⟶ N.Tm) (h : β ≫ N.tp = ym(M.sec _ α eq) ≫ B) : fst (mk α eq B β h) = α := by - simp [mk, fst] + simp [mk, fst, PartialProduct.fan, uvPolyTp] @[simp] theorem dependent_mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) @@ -456,7 +467,7 @@ theorem dependent_mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) @[simp] theorem snd_mk (α : y(Γ) ⟶ M.Tm) {A} (eq : α ≫ M.tp = A) (B : y(M.ext A) ⟶ N.Ty) (β : y(Γ) ⟶ N.Tm) (h : β ≫ N.tp = ym(M.sec _ α eq) ≫ B) : snd (mk α eq B β h) = β := by - simp [mk, snd] + simp [mk, snd, PartialProduct.fan, uvPolyTp] theorem ext {ab₁ ab₂ : y(Γ) ⟶ M.uvPolyTp.compDom N.uvPolyTp} {A} (eq : fst ab₁ ≫ M.tp = A) @@ -466,9 +477,10 @@ theorem ext {ab₁ ab₂ : y(Γ) ⟶ M.uvPolyTp.compDom N.uvPolyTp} refine pullback.hom_ext h3 (pullback.hom_ext ?_ h1) simp only [dependent, PtpEquiv.snd] at h2 generalize_proofs _ _ H at h2 - refine Equiv.ext' M.uvPolyTp N.Ty H ?_ h2 - simp [Equiv.fst, pullback.condition] - simp only [← Category.assoc]; congr 1 + have h := Equiv.ext' M.uvPolyTp N.Ty H ?_ h2 + · simpa only [UvPoly.compP, Category.assoc] using h + · simpa [Equiv.fst_eq, UvPoly.compP, PartialProduct.fan, uvPolyTp, + ← pullback.condition, fst, Category.assoc] using congrArg (fun k => k ≫ M.tp) h1 theorem comp_mk (α : y(Γ) ⟶ M.Tm) {A} (e1 : α ≫ M.tp = A) @@ -856,8 +868,8 @@ def toI : y(ii.motiveCtx a) ⟶ ie.i := lemma toI_comp_i1 : ie.toI a ≫ ie.i1 = M.var _ := by simp [toI] -lemma toI_comp_i2 : ie.toI a ≫ ie.i2 = ym(M.disp _) ≫ ii.toK a := - by simp [toI] +lemma toI_comp_i2 : ie.toI a ≫ ie.i2 = ym(M.disp _) ≫ ii.toK a := by + simp [toI] lemma toI_comp_left {Δ} (σ : Δ ⟶ Γ) : toI ie (ym(σ) ≫ a) = ym(ii.motiveSubst σ a) ≫ toI ie a := by @@ -1253,8 +1265,8 @@ lemma reflCase_comp_tp : reflCase ar ≫ N.tp = (M.var (ie.equivFst aC ≫ M.tp)) (by simp)) ≫ M.disp (ie.equivFst aC ≫ M.tp)) (ie.toI (ie.equivFst aC)) (UvPoly.Equiv.fst ie.iUvPoly N.Ty aC) ie.iUvPoly.p := by - convert (ie.motiveCtx_isPullback' (ie.equivFst aC)).flip - simp + simpa only [Functor.map_comp, IdElimBase.equivFst, IdIntro.motiveCtx] using + (ie.motiveCtx_isPullback' (ie.equivFst aC)).flip -- FIXME: `transparency := .default` is like `erw` and should be avoided rw! (transparency := .default) [UvPoly.snd'_verticalNatTrans_app (R := y(ii.motiveCtx (ie.equivFst aC))) diff --git a/HoTTLean/Model/Natural/UHom.lean b/HoTTLean/Model/Natural/UHom.lean index 82277fa4..f9ea5b99 100644 --- a/HoTTLean/Model/Natural/UHom.lean +++ b/HoTTLean/Model/Natural/UHom.lean @@ -9,6 +9,8 @@ universe v u noncomputable section +set_option backward.isDefEq.respectTransparency false + open CategoryTheory Limits Opposite MonoidalCategory namespace NaturalModel @@ -34,7 +36,7 @@ def Hom.comp {M N O : Universe Ctx} (α : Hom M N) (β : Hom N O) : Hom M O wher mapTy := α.mapTy ≫ β.mapTy pb := α.pb.paste_horiz β.pb -def Hom.comp_assoc {M N O P : Universe Ctx} (α : Hom M N) (β : Hom N O) (γ : Hom O P) : +theorem Hom.comp_assoc {M N O P : Universe Ctx} (α : Hom M N) (β : Hom N O) (γ : Hom O P) : comp (comp α β) γ = comp α (comp β γ) := by simp [comp] @@ -54,11 +56,11 @@ def Hom.subst (M : Universe Ctx) Hom (M.pullback (ym(σ) ≫ A)) (M.pullback A) := let Aσ := ym(σ) ≫ A { mapTm := - (M.disp_pullback A).lift (M.var Aσ) ym(M.disp Aσ ≫ σ) (by aesop_cat) + (M.disp_pullback A).lift (M.var Aσ) ym(M.disp Aσ ≫ σ) (by simp [Aσ]) mapTy := ym(σ) pb := by - convert IsPullback.of_right' (M.disp_pullback Aσ) (M.disp_pullback A) - simp } + simpa only [Universe.pullback, Aσ, Functor.map_comp] using + IsPullback.of_right' (M.disp_pullback Aσ) (M.disp_pullback A) } def Hom.cartesianNatTrans {M N : Universe Ctx} (h : Hom M N) : M.Ptp ⟶ N.Ptp := @@ -80,8 +82,7 @@ theorem Hom.mk_comp_cartesianNatTrans {M N : Universe Ctx} (h : Hom M N) refine this.trans ?_ simp [UvPoly.Equiv.mk']; congr 1 rw [← Category.assoc]; congr 1 - generalize_proofs _ h1 - apply h1.hom_ext <;> simp + apply ((M.disp_pullback A).paste_horiz h.pb).hom_ext <;> simp /- We have a 'nice', specific terminal object in `Ctx`, and this instance allows use to use it directly @@ -121,7 +122,7 @@ def UHom.comp {M N O : Universe Ctx} (α : UHom M N) (β : UHom N O) : UHom M O asTm := α.asTm ≫ β.mapTm U_pb := α.U_pb.paste_horiz β.pb -def UHom.comp_assoc {M N O P : Universe Ctx} (α : UHom M N) (β : UHom N O) (γ : UHom O P) : +theorem UHom.comp_assoc {M N O P : Universe Ctx} (α : UHom M N) (β : UHom N O) (γ : UHom O P) : comp (comp α β) γ = comp α (comp β γ) := by simp [comp, Hom.comp] @@ -248,7 +249,9 @@ theorem mk_comp_cartesianNatTrans {i j ij jlen} {Γ X} (A : y(Γ) ⟶ s[i].Ty) PtpEquiv.mk s[i] A B ≫ (s.cartesianNatTrans i j).app X = PtpEquiv.mk s[j] (A ≫ (s.homOfLe i j).mapTy) (ym(substCons _ (s[j].disp _) _ (s.unliftVar i j ij jlen A rfl) (by simp)) ≫ B) := by - convert Hom.mk_comp_cartesianNatTrans _ _ _ + dsimp only [cartesianNatTrans] + rw [Hom.mk_comp_cartesianNatTrans] + congr 2 apply (IsPullback.paste_horiz (s[i].disp_pullback _) (s.homOfLe i j).pb).hom_ext · simp [unliftVar] · simp @@ -274,14 +277,14 @@ Given `i0 ≤ i1` and `j0 ≤ j1` -/ def cartesianNatTransTm (i0 i1 j0 j1 : Nat) (ii : i0 ≤ i1 := by get_elem_tactic) (ilen : i1 < s.length + 1 := by get_elem_tactic) - (jj : j0 ≤ j1 := by get_elem_tactic) (jlen : j1 < s.length + 1 := by get_elem_tactic) - : s[i0].Ptp.obj s[j0].Tm ⟶ s[i1].Ptp.obj s[j1].Tm := + (jj : j0 ≤ j1 := by get_elem_tactic) (jlen : j1 < s.length + 1 := by get_elem_tactic) : + s[i0].Ptp.obj s[j0].Tm ⟶ s[i1].Ptp.obj s[j1].Tm := (s.cartesianNatTrans i0 i1).app s[j0].Tm ≫ s[i1].Ptp.map (s.homOfLe j0 j1).mapTm theorem mk_comp_cartesianNatTransTm {i0 i1 j0 j1 ii ilen jj jlen} - {Γ X} (A : y(Γ) ⟶ s[i0].Ty) (B : y(s[i0].ext A) ⟶ s[j0].Tm) - : PtpEquiv.mk s[i0] A B ≫ s.cartesianNatTransTm i0 i1 j0 j1 ii ilen jj jlen = + {Γ X} (A : y(Γ) ⟶ s[i0].Ty) (B : y(s[i0].ext A) ⟶ s[j0].Tm) : + PtpEquiv.mk s[i0] A B ≫ s.cartesianNatTransTm i0 i1 j0 j1 ii ilen jj jlen = PtpEquiv.mk s[i1] (A ≫ (s.homOfLe i0 i1).mapTy) (ym(substCons _ (s[i1].disp _) _ (s.unliftVar i0 i1 ii ilen A rfl) (by simp)) ≫ B ≫ (s.homOfLe j0 j1).mapTm) := by @@ -296,14 +299,14 @@ theorem cartesianNatTransTm_fstProj {i0 i1 j0 j1 ii ilen jj jlen} : def cartesianNatTransTy (i0 i1 j0 j1 : Nat) (i0len : i0 ≤ i1 := by get_elem_tactic) (i1len : i1 < s.length + 1 := by get_elem_tactic) - (j0len : j0 ≤ j1 := by get_elem_tactic) (j1len : j1 < s.length + 1 := by get_elem_tactic) - : s[i0].Ptp.obj s[j0].Ty ⟶ s[i1].Ptp.obj s[j1].Ty := + (j0len : j0 ≤ j1 := by get_elem_tactic) (j1len : j1 < s.length + 1 := by get_elem_tactic) : + s[i0].Ptp.obj s[j0].Ty ⟶ s[i1].Ptp.obj s[j1].Ty := (s.cartesianNatTrans i0 i1).app s[j0].Ty ≫ s[i1].Ptp.map (s.homOfLe j0 j1).mapTy theorem mk_comp_cartesianNatTransTy {i0 i1 j0 j1 ii ilen jj jlen} - {Γ X} (A : y(Γ) ⟶ s[i0].Ty) (B : y(s[i0].ext A) ⟶ s[j0].Ty) - : PtpEquiv.mk s[i0] A B ≫ s.cartesianNatTransTy i0 i1 j0 j1 ii ilen jj jlen = + {Γ X} (A : y(Γ) ⟶ s[i0].Ty) (B : y(s[i0].ext A) ⟶ s[j0].Ty) : + PtpEquiv.mk s[i0] A B ≫ s.cartesianNatTransTy i0 i1 j0 j1 ii ilen jj jlen = PtpEquiv.mk s[i1] (A ≫ (s.homOfLe i0 i1).mapTy) (ym(substCons _ (s[i1].disp _) _ (s.unliftVar i0 i1 ii ilen A rfl) (by simp)) ≫ B ≫ (s.homOfLe j0 j1).mapTy) := by @@ -433,7 +436,7 @@ def Pi : s[i].Ptp.obj s[j].Ty ⟶ s[max i j].Ty := def lam : s[i].Ptp.obj s[j].Tm ⟶ s[max i j].Tm := s.cartesianNatTransTm i (max i j) j (max i j) ≫ (nmPi (max i j)).lam -def Pi_pb : +theorem Pi_pb : IsPullback (s.lam ilen jlen) (s[i].Ptp.map s[j].tp) s[max i j].tp (s.Pi ilen jlen) := by have p1 : NatTrans.IsCartesian (s.cartesianNatTrans i (max i j)) := by dsimp only [UHomSeq.cartesianNatTrans] @@ -645,7 +648,7 @@ def pair : UvPoly.compDom s[i].uvPolyTp s[j].uvPolyTp ⟶ s[max i j].Tm := (s.homOfLe j (max i j)).pb.flip l ≫ (nmSig (max i j)).pair -def Sig_pb : IsPullback +theorem Sig_pb : IsPullback (s.pair ilen jlen) (s[i].uvPolyTp.compP s[j].uvPolyTp) s[max i j].tp (s.Sig ilen jlen) := diff --git a/HoTTLean/Model/Unstructured/Hurewicz.lean b/HoTTLean/Model/Unstructured/Hurewicz.lean index e3d2f1fb..cdd4e050 100644 --- a/HoTTLean/Model/Unstructured/Hurewicz.lean +++ b/HoTTLean/Model/Unstructured/Hurewicz.lean @@ -76,7 +76,8 @@ lemma δ0_app_I_obj_comp_symm_app (X) : cyl.δ0.app (cyl.I.obj X) ≫ cyl.symm.a NatTrans.congr_app (cyl.whiskerLeft_I_δ0_symm) X @[reassoc (attr := simp)] -lemma δ1_app_I_obj_comp_symm_app (X) : cyl.δ1.app (cyl.I.obj X) ≫ cyl.symm.app X = cyl.I.map (cyl.δ1.app X) := +lemma δ1_app_I_obj_comp_symm_app (X) : + cyl.δ1.app (cyl.I.obj X) ≫ cyl.symm.app X = cyl.I.map (cyl.δ1.app X) := NatTrans.congr_app (cyl.whiskerLeft_I_δ1_symm) X @[reassoc (attr := simp)] @@ -325,6 +326,7 @@ lemma unpath_ext {Γ} (A : Γ ⟶ U0.Ty) (a0 a1 : Γ ⟶ U0.Tm) (p1 p2 : cyl.I.o rw [← P0.unpath_path (A := A) a0 a1 p1 p1_tp δ0_p1 δ1_p1] rw [← P0.unpath_path a0 a1 p2 p2_tp δ0_p2 δ1_p2] rw! [h] + rfl lemma unpath_comp {Γ Δ} (σ : Δ ⟶ Γ) {A : Γ ⟶ U0.Ty} (a0 a1 : Γ ⟶ U0.Tm) (a0_tp : a0 ≫ U0.tp = A) (a1_tp : a1 ≫ U0.tp = A) (p : Γ ⟶ U0.Tm) (p_tp : p ≫ U0.tp = P0.Path a0 a1 a0_tp a1_tp) : @@ -363,7 +365,8 @@ open PolymorphicIdIntro section connection -variable (hrwcz0 : Hurewicz cyl U0.tp) {Γ Δ : Ctx} (σ : Δ ⟶ Γ) {A : Γ ⟶ U0.Ty} (a : Γ ⟶ U0.Tm) (a_tp : a ≫ U0.tp = A) +variable (hrwcz0 : Hurewicz cyl U0.tp) {Γ Δ : Ctx} (σ : Δ ⟶ Γ) + {A : Γ ⟶ U0.Ty} (a : Γ ⟶ U0.Tm) (a_tp : a ≫ U0.tp = A) /-- Fixing `Γ ⊢ a : A`, `ev` / `substConsEv` can be viewed as the cubical substitution `(i : I);(x : A).(p : Id(a,x)) ⊢ p' i : A`, @@ -401,7 +404,7 @@ abbrev ev : cyl.I.obj (U0.ext (P0.polymorphicIdIntro.weakenId a a_tp)) ⟶ U0.Tm /- ev - ⌐----------------------------¬ + +----------------------------¬ | substCons V I;Γ.(x:A).Id(a,x) ····> Γ.A -------> Tm | | | @@ -429,7 +432,8 @@ lemma substConsEv_var : P0.substConsEv a a_tp ≫ var .. = P0.unpath (A := disp simp [substConsEv] @[reassoc (attr := simp)] -lemma δ0_substConsEv : cyl.δ0.app _ ≫ P0.substConsEv a a_tp = disp .. ≫ disp .. ≫ U0.sec A a a_tp := by +lemma δ0_substConsEv : + cyl.δ0.app _ ≫ P0.substConsEv a a_tp = disp .. ≫ disp .. ≫ U0.sec A a a_tp := by apply (disp_pullback ..).hom_ext · simp [substConsEv] · simp [substConsEv] @@ -530,7 +534,6 @@ lemma I_δ0_connection : cyl.I.map (cyl.δ0.app _) ≫ P0.connection hrwcz0 a a_ cyl.π.app _ ≫ disp .. ≫ U0.disp A ≫ a := by fapply P0.unpath_ext (disp .. ≫ U0.disp A ≫ A) (disp .. ≫ U0.disp A ≫ a) (disp .. ≫ U0.disp A ≫ a) <;> simp [a_tp, connection, ← unpath_comp] - erw [δ0_connectionLift] -- FIXME simp [← path_comp] lemma connection_comp [hrwcz0.IsUniform] : @@ -582,10 +585,9 @@ lemma symmConnection_tp : P0.symmConnection hrwcz0 a a_tp ≫ U0.tp = @[simp] lemma δ0_symmConnection : cyl.δ0.app _ ≫ P0.symmConnection hrwcz0 a a_tp = cyl.π.app _ ≫ disp .. ≫ U0.disp A ≫ a := by - simp only [motiveCtx, polymorphicIdIntro_Id, Functor.id_obj, symmConnection, Functor.comp_obj, + simp only [motiveCtx, Functor.id_obj, symmConnection, Functor.comp_obj, δ0_app_I_obj_comp_symm_app_assoc] - erw [I_δ0_connection] -- FIXME - simp + erw [I_δ0_connection] @[simp] lemma I_δ0_symmConnection : cyl.I.map (cyl.δ0.app _) ≫ P0.symmConnection hrwcz0 a a_tp = @@ -597,7 +599,7 @@ lemma I_δ0_symmConnection : cyl.I.map (cyl.δ0.app _) ≫ P0.symmConnection hrw @[simp] lemma I_δ1_symmConnection : cyl.I.map (cyl.δ1.app _) ≫ P0.symmConnection hrwcz0 a a_tp = P0.ev a a_tp := by - simp only [motiveCtx, polymorphicIdIntro_Id, Functor.id_obj, symmConnection, Functor.comp_obj, + simp only [motiveCtx, Functor.id_obj, symmConnection, Functor.comp_obj, I_map_δ1_app_comp_symm_app_assoc] erw [δ1_connection] -- FIXME @@ -628,13 +630,11 @@ lemma pathSymmConnection_tp : P0.pathSymmConnection hrwcz0 a a_tp ≫ U0.tp = (cyl.π.app _ ≫ disp .. ≫ disp .. ≫ a) (cyl.δ1.app _ ≫ P0.symmConnection hrwcz0 a a_tp) (by simp [a_tp]) (by simp) := by simp [pathSymmConnection] - rw! (transparency := .default) [δ0_symmConnection] - congr 1 @[simp] lemma δ0_pathSymmConnection : cyl.δ0.app _ ≫ P0.pathSymmConnection hrwcz0 a a_tp = disp .. ≫ disp .. ≫ P0.polymorphicIdIntro.refl a a_tp := by - simp only [polymorphicIdIntro_Id, Functor.id_obj, pathSymmConnection, motiveCtx, ← path_comp, + simp only [Functor.id_obj, pathSymmConnection, motiveCtx, ← path_comp, δ0_π'_app_assoc, polymorphicIdIntro_refl, NatTrans.naturality_assoc, Functor.id_map] rw! (transparency := .default) [I_δ0_symmConnection] simp @@ -642,7 +642,7 @@ lemma δ0_pathSymmConnection : cyl.δ0.app _ ≫ P0.pathSymmConnection hrwcz0 a @[simp] lemma δ1_pathSymmConnection : cyl.δ1.app _ ≫ P0.pathSymmConnection hrwcz0 a a_tp = U0.var _ := by - simp only [polymorphicIdIntro_Id, Functor.id_obj, pathSymmConnection, motiveCtx, ← path_comp, + simp only [Functor.id_obj, pathSymmConnection, motiveCtx, ← path_comp, δ1_π'_app_assoc] rw! (transparency := .default) [I_δ1_symmConnection] simp @@ -688,13 +688,13 @@ lemma substConnection_var : P0.substConnection hrwcz0 a a_tp ≫ var .. = @[reassoc (attr := simp)] lemma δ0_substConnection : cyl.δ0.app _ ≫ P0.substConnection hrwcz0 a a_tp = disp .. ≫ disp .. ≫ reflInst _ a a_tp := by - simp only [polymorphicIdIntro_Id, Functor.id_obj, motiveCtx, substConnection, comp_substCons, + simp only [Functor.id_obj, motiveCtx, substConnection, comp_substCons, δ0_π'_app_assoc, ← cyl.δ1_naturality_assoc, polymorphicIdIntro_refl] rw! (transparency := .default) [δ0_pathSymmConnection] apply (disp_pullback ..).hom_ext · simp · apply (disp_pullback ..).hom_ext - · simp only [substCons_disp, substCons_var, Category.assoc, sec_var] + · simp only [substCons_disp, substCons_var, ] rw! (transparency := .default) [I_δ0_symmConnection] simp · simp @@ -704,10 +704,8 @@ lemma δ1_substConnection : cyl.δ1.app _ ≫ P0.substConnection hrwcz0 a a_tp = simp [substConnection] apply (disp_pullback ..).hom_ext · simp only [substCons_var, Category.id_comp] - rw! (transparency := .default) [δ1_pathSymmConnection] - simp · apply (disp_pullback ..).hom_ext - · simp only [symmConnection, motiveCtx, polymorphicIdIntro_Id, Functor.comp_obj, + · simp only [symmConnection, motiveCtx, Functor.comp_obj, δ1_app_I_obj_comp_symm_app_assoc, cyl.δ1_naturality_assoc] rw! (transparency := .default) [δ1_connection] simp @@ -717,7 +715,7 @@ lemma δ1_substConnection : cyl.δ1.app _ ≫ P0.substConnection hrwcz0 a a_tp = lemma substConnection_comp_motiveSubst [hrwcz0.IsUniform] : P0.substConnection hrwcz0 (σ ≫ a) (by simp [a_tp]) ≫ motiveSubst _ σ a a_tp rfl = cyl.I.map (motiveSubst _ σ a a_tp) ≫ P0.substConnection hrwcz0 a a_tp := by - simp only [polymorphicIdIntro_Id, motiveCtx, motiveSubst] + simp only [motiveCtx, motiveSubst] apply (disp_pullback ..).hom_ext · simp only [Category.assoc, substWk_var] erw [substConnection_var] @@ -744,7 +742,8 @@ def polymorphicIdElim (hrwcz0 : Hurewicz cyl U0.tp) [hrwcz0.IsUniform] [hrwcz0.I (U1 : UnstructuredUniverse Ctx) (hrwcz1 : Hurewicz cyl U1.tp) [Hurewicz.IsUniform hrwcz1] [Hurewicz.IsNormal hrwcz1] : PolymorphicIdElim (polymorphicIdIntro P0) U1 where jElim a a_tp C c c_tp := cyl.δ1.app _ ≫ hrwcz1.lift (disp .. ≫ disp .. ≫ c) - (substConnection P0 hrwcz0 a a_tp ≫ C) (by rw [δ0_substConnection_assoc]; simp [c_tp]) -- FIXME simp failed + (substConnection P0 hrwcz0 a a_tp ≫ C) + (by rw [δ0_substConnection_assoc]; simp [c_tp]) -- FIXME simp failed jElim_comp σ A a a_tp C c c_tp := by slice_rhs 1 2 => rw [← δ1_naturality] slice_rhs 2 3 => rw [← hrwcz1.lift_comp] @@ -752,7 +751,7 @@ def polymorphicIdElim (hrwcz0 : Hurewicz cyl U0.tp) [hrwcz0.IsUniform] [hrwcz0.I · simp [motiveSubst, substWk_disp_assoc] · rw [substConnection_comp_motiveSubst_assoc] jElim_tp a a_tp C c c_tp := by - simp only [motiveCtx, polymorphicIdIntro_Id, Category.assoc, Hurewicz.lift_comp_self'] + simp only [motiveCtx, Category.assoc, Hurewicz.lift_comp_self'] erw [δ1_substConnection_assoc] -- FIXME simp, rw failed reflSubst_jElim {Γ A} a a_tp C c c_tp := calc _ _ = cyl.δ1.app Γ ≫ cyl.I.map (reflInst _ a a_tp) ≫ diff --git a/HoTTLean/Model/Unstructured/Interpretation.lean b/HoTTLean/Model/Unstructured/Interpretation.lean index 521e84d3..643449ac 100644 --- a/HoTTLean/Model/Unstructured/Interpretation.lean +++ b/HoTTLean/Model/Unstructured/Interpretation.lean @@ -16,12 +16,14 @@ open CategoryTheory Limits noncomputable section +set_option backward.isDefEq.respectTransparency false + namespace Model.UnstructuredUniverse open SynthLean -variable {𝒞 : Type u} [Category 𝒞] (M : UnstructuredUniverse 𝒞) -variable [ChosenTerminal 𝒞] +variable {𝒞 : Type u} [Category.{v} 𝒞] (M : UnstructuredUniverse 𝒞) +variable [ChosenTerminal.{v} 𝒞] open ChosenTerminal @@ -56,7 +58,7 @@ where `Γ` is a prefix of `Γ'`. It witnesses a sequence of context extension operations in `s` that built `Γ'` on top of `Γ`. We write `Γ ≤ Γ'`. -/ -inductive ExtSeq (s : UHomSeq 𝒞) (Γ : 𝒞) : 𝒞 → Type u where +inductive ExtSeq (s : UHomSeq 𝒞) (Γ : 𝒞) : 𝒞 → Type (max u v) where | nil : s.ExtSeq Γ Γ | snoc {Γ'} {l : Nat} (d : s.ExtSeq Γ Γ') (llen : l < s.length + 1) (A : Γ' ⟶ s[l].Ty) : s.ExtSeq Γ (s[l].ext A) @@ -94,8 +96,7 @@ def disp {Γ Γ' : 𝒞} : s.ExtSeq Γ Γ' → (Γ' ⟶ Γ) Δ ⊢ σ : Γ d : Γ ≤ Γ' ----------------------------- Δ ≤ Δ.d[σ] Δ.d[σ] ⊢ σ.d : Γ' -``` -where +``` where ``` Δ ⊢ σ : Γ d : Γ ≤ Γ.Aₙ.….A₁ ----------------------------- @@ -209,7 +210,7 @@ i.e., one of the form `1.Aₙ₋₁.….A₀`, together with the extension sequence `[Aₙ₋₁ :: … :: A₀]`. This kind of object can be destructured. -/ -def CObj (s : UHomSeq 𝒞) : Type u := Σ Γ : 𝒞, s.ExtSeq (𝟭_ 𝒞) Γ +def CObj (s : UHomSeq 𝒞) : Type (max u v) := Σ Γ : 𝒞, s.ExtSeq (𝟭_ 𝒞) Γ def nilCObj (s : UHomSeq 𝒞) : s.CObj := ⟨𝟭_ 𝒞, .nil⟩ @@ -398,11 +399,10 @@ end def ofCtx : Ctx χ → Part s.CObj | [] => return s.nilCObj - | (A,l) :: Γ => do - Part.assert (l < s.length + 1) fun llen => do - let sΓ ← ofCtx Γ - let sA ← I.ofType sΓ l A - return sΓ.snoc llen sA + | (A,l) :: Γ => + Part.assert (l < s.length + 1) fun llen => + Part.bind (ofCtx Γ) fun sΓ => + Part.map (fun sA => sΓ.snoc llen sA) (I.ofType sΓ l A) @[simp] theorem mem_ofType_pi {Γ l i j A B} {llen : l < s.length + 1} {x} : @@ -567,8 +567,7 @@ theorem mem_ofType_univ {Γ l i} {llen : l < s.length + 1} {x} : @[simp] theorem mem_ofCtx_snoc {Γ A l sΓ'} : sΓ' ∈ I.ofCtx ((A,l) :: Γ) ↔ ∃ sΓ ∈ I.ofCtx Γ, ∃ llen, ∃ sA ∈ I.ofType sΓ l A llen, sΓ' = sΓ.snoc llen sA := by - simp only [ofCtx, Part.pure_eq_some, Part.bind_eq_bind, Part.mem_assert_iff, Part.mem_bind_iff, - Part.mem_some_iff] + simp only [ofCtx, Part.mem_assert_iff, Part.mem_bind_iff, Part.mem_map_iff] tauto /-! ## Semantic substitutions -/ @@ -704,7 +703,7 @@ theorem mem_ofType_ofTerm_subst' {full} simp [ofTerm_bvar] at H simp [Expr.subst] induction σ generalizing i with simp [CSb.toSb, *] - | wk => exact CObj.mem_var_succ.2 ⟨_, ‹_›, rfl⟩ + | wk => exact ⟨_, ‹_›, rfl⟩ | @comp _ _ _ _ _ full σ τ ih1 ih2 => simp [Expr.comp] cases full with @@ -803,7 +802,8 @@ theorem mem_ofType_of_isClosed {e l} (e_cl : e.isClosed) isTerminal.from Γ.1 ≫ se ∈ I.ofType Γ l e hl := by rcases Γ with ⟨_, ext⟩ induction ext - · convert se_mem; simp + · convert se_mem <;> try rfl + simp · rename_i X se_mem have := I.mem_ofType_wk (X := X) (by omega) se_mem convert this using 1 <;> @@ -1070,7 +1070,8 @@ theorem EqTmIH.idRec {Γ A M M' t t' r r' u u' h h' l l'} : refine ⟨_, hΓ, _, _, (I.mem_ofType_ofTerm_subst _ (.snoc (.sub1 _ _ _ utp hu) _ _ _ ?_ hh) ?_).1 hM, _, I.mem_ofTerm_idRec.2 ⟨_, _, ht, _, ttp, B, ?b, _, hM, _, hr, ?a, _, hu, utp, _, hh, htp, rfl⟩, - I.mem_ofTerm_idRec.2 ⟨_, _, ht', _, ttp, B, ?b, _, hM', _, hr', ?a, _, hu', utp, _, hh', htp, rfl⟩, + I.mem_ofTerm_idRec.2 + ⟨_, _, ht', _, ttp, B, ?b, _, hM', _, hr', ?a, _, hu', utp, _, hh', htp, rfl⟩, idRec_tp (I_eq := _) ..⟩ · rw [htp, Beq, ← Id_comp] congr 1 <;> simp [sAeq] @@ -1152,7 +1153,7 @@ theorem EqTmIH.idRec_refl {Γ A M t r l l'} : have sr := rtp ▸ Part.mem_unique hR sM have ir := I.mem_ofTerm_idRec.2 ⟨_, _, ht, _, ttp, B, by simp [Beq, sAeq], _, hM, _, hr, by simp [ttp, sr], _, ht, ttp, _, h1, by simp [ttp], - by rw! [ttp, PolymorphicIdElim.idRec_refl (I_eq := _)]⟩ + by rw! [ttp, PolymorphicIdElim.idRec_refl (I_eq := _)]; rfl⟩ ⟨_, hΓ, _, _, sM, _, ir, hr, sr⟩ simp [Beq, ← Id_comp, sAeq, ttp] diff --git a/HoTTLean/Model/Unstructured/UHom.lean b/HoTTLean/Model/Unstructured/UHom.lean index 3c05dc06..a3167947 100644 --- a/HoTTLean/Model/Unstructured/UHom.lean +++ b/HoTTLean/Model/Unstructured/UHom.lean @@ -8,6 +8,8 @@ universe v u noncomputable section +set_option backward.isDefEq.respectTransparency false + open CategoryTheory Opposite MonoidalCategory namespace Model @@ -35,7 +37,8 @@ def Hom.comp {M N O : UnstructuredUniverse Ctx} (α : Hom M N) (β : Hom N O) : mapTy := α.mapTy ≫ β.mapTy pb := α.pb.paste_horiz β.pb -def Hom.comp_assoc {M N O P : UnstructuredUniverse Ctx} (α : Hom M N) (β : Hom N O) (γ : Hom O P) : +theorem Hom.comp_assoc {M N O P : UnstructuredUniverse Ctx} + (α : Hom M N) (β : Hom N O) (γ : Hom O P) : comp (comp α β) γ = comp α (comp β γ) := by simp [comp] @@ -55,10 +58,10 @@ def Hom.subst (M : UnstructuredUniverse Ctx) Hom (M.pullback ((σ) ≫ A)) (M.pullback A) := let Aσ := (σ) ≫ A { mapTm := - (M.disp_pullback A).lift (M.var Aσ) (M.disp Aσ ≫ σ) (by aesop_cat) + (M.disp_pullback A).lift (M.var Aσ) (M.disp Aσ ≫ σ) (by simp [Aσ]) mapTy := (σ) pb := by - convert IsPullback.of_right' (M.disp_pullback Aσ) (M.disp_pullback A)} + exact IsPullback.of_right' (M.disp_pullback Aσ) (M.disp_pullback A)} @[simp] def Hom.extIsoExt {M N : UnstructuredUniverse Ctx} (h : Hom M N) {Γ} (A : Γ ⟶ M.Ty) : (N.ext (A ≫ h.mapTy)) ≅ (M.ext A) := @@ -99,7 +102,8 @@ def UHom.comp {M N O : UnstructuredUniverse Ctx} (α : UHom M N) (β : UHom N O) asTm := α.asTm ≫ β.mapTm U_pb := α.U_pb.paste_horiz β.pb -def UHom.comp_assoc {M N O P : UnstructuredUniverse Ctx} (α : UHom M N) (β : UHom N O) (γ : UHom O P) : +theorem UHom.comp_assoc {M N O P : UnstructuredUniverse Ctx} + (α : UHom M N) (β : UHom N O) (γ : UHom O P) : comp (comp α β) γ = comp α (comp β γ) := by simp [comp, Hom.comp] @@ -135,7 +139,8 @@ def Hom.extCompMapTyIsoExt : N.ext (A ≫ α.mapTy) ≅ M.ext A := (N.disp_pullback (A ≫ α.mapTy)).isoIsPullback _ _ (IsPullback.paste_horiz (M.disp_pullback A) α.pb) -lemma Hom.extCompMapTyIsoExt_hom_comp_substWk : +omit [ChosenTerminal Ctx] in +lemma Hom.extCompMapTyIsoExt_hom_comp_substWk : (α.extCompMapTyIsoExt σA).hom ≫ M.substWk σ A σA eq = N.substWk σ (A ≫ α.mapTy) (σA ≫ α.mapTy) (by simp [← eq]) ≫ (α.extCompMapTyIsoExt A).hom := by apply (disp_pullback ..).hom_ext @@ -370,7 +375,7 @@ class PiSeq (s : UHomSeq Ctx) where -- Re-export for use with dot notation. abbrev polyPi := @PiSeq.polyPi -def PiSeq.ofMonomorphic +abbrev PiSeq.ofMonomorphic (nmPi : (i : Nat) → (ilen : i < s.length + 1 := by get_elem_tactic) → s[i].PolymorphicPi s[i] s[i]) : PiSeq s where polyPi i j _ _ := .ofMonomorphic (nmPi (max i j)) (s.homOfLe _ _) (s.homOfLe _ _) diff --git a/HoTTLean/Model/Unstructured/UnstructuredUniverse.lean b/HoTTLean/Model/Unstructured/UnstructuredUniverse.lean index 5e57936b..279daa5e 100644 --- a/HoTTLean/Model/Unstructured/UnstructuredUniverse.lean +++ b/HoTTLean/Model/Unstructured/UnstructuredUniverse.lean @@ -320,12 +320,14 @@ lemma fst_comp {Γ Δ} (σ : Δ ⟶ Γ) {A : Γ ⟶ U0.Ty} {σA} (eq) {B : U0.ex S.fst (U0.substWk σ A σA eq ≫ B) (σ ≫ s) (by simp [s_tp, S.Sig_comp]) = σ ≫ S.fst B s s_tp := by rw! [(S.pair_fst_snd B s (by simp [s_tp])).symm, ← S.pair_comp, S.fst_pair, S.fst_pair] + rfl lemma snd_comp {Γ Δ} (σ : Δ ⟶ Γ) {A : Γ ⟶ U0.Ty} {σA} (eq) {B : U0.ext A ⟶ U1.Ty} (s : Γ ⟶ U2.Tm) (s_tp : s ≫ U2.tp = S.Sig B) : S.snd (U0.substWk σ A σA eq ≫ B) (σ ≫ s) (by simp [s_tp, S.Sig_comp]) = σ ≫ S.snd B s s_tp := by rw! [(S.pair_fst_snd B s (by simp [s_tp])).symm, ← S.pair_comp, S.snd_pair, S.snd_pair] + rfl end PolymorphicSigma @@ -362,8 +364,9 @@ lemma unLam_comp {Γ Δ} (σ : Δ ⟶ Γ) {A : Γ ⟶ U0.Ty} {σA} (eq) {B : U0. P.unLam (U0.substWk σ A σA eq ≫ B) (σ ≫ f) (by simp [f_tp, P.Pi_comp]) = U0.substWk σ A σA eq ≫ P.unLam B f f_tp := by rw [← P.unLam_lam (U0.substWk σ A σA eq ≫ B) (U0.substWk σ A σA eq ≫ P.unLam B f f_tp)] - . rw! [P.lam_comp σ eq B, P.lam_unLam] - . rw [Category.assoc, P.unLam_tp] + · rw! [P.lam_comp σ eq B, P.lam_unLam] + rfl + · rw [Category.assoc, P.unLam_tp] /-- ``` diff --git a/HoTTLean/Pointed/Basic.lean b/HoTTLean/Pointed/Basic.lean index b41f69d6..dba24a75 100644 --- a/HoTTLean/Pointed/Basic.lean +++ b/HoTTLean/Pointed/Basic.lean @@ -1,4 +1,4 @@ -import Mathlib.CategoryTheory.Category.Grpd +import Mathlib.CategoryTheory.Groupoid.Grpd.Basic import HoTTLean.ForMathlib import HoTTLean.Grothendieck.Groupoidal.Basic import HoTTLean.ForMathlib.CategoryTheory.Functor.IsPullback @@ -7,6 +7,8 @@ import HoTTLean.ForMathlib.CategoryTheory.Functor.IsPullback Here we define pointed categories and pointed groupoids as well as prove some basic lemmas. -/ +set_option backward.isDefEq.respectTransparency false + universe w v u v₁ u₁ v₂ u₂ noncomputable section @@ -14,8 +16,9 @@ noncomputable section namespace CategoryTheory attribute [local simp] eqToHom_map Grpd.id_eq_id Grpd.comp_eq_comp Functor.id_comp + Cat.Hom.obj Cat.Hom.map Cat.Hom.comp_toFunctor Cat.Hom.id_toFunctor -open Functor +open CategoryTheory.Functor abbrev PCat := ∫ 𝟭 Cat.{v,u} @@ -37,6 +40,8 @@ postfix:max "⟱" => forgetToCat.map lemma forgetToCat_map {C D : PCat} (F : C ⟶ D) : F⟱ = F.base := rfl +attribute [local simp] forgetToCat_map + @[simp] theorem id_obj {C : PCat} (X : C.base) : (𝟙 C)⟱.obj X = X := rfl @@ -124,7 +129,9 @@ theorem mapFiber_inv {x y} (f : x ⟶ y) [IsIso f] : end theorem eqToHom_base_map {x y : PCat} (eq : x = y) {a b} (f : a ⟶ b) : - (eqToHom eq).base.map f = eqToHom (by simp) ≫ (eqToHom (by simp [eq] : x.base = y.base)).map f ≫ eqToHom (by simp) := by + (eqToHom eq).base.map f = + eqToHom (by simp) ≫ (eqToHom (by simp [eq] : x.base = y.base)).map f ≫ + eqToHom (by simp) := by cases eq simp @@ -169,6 +176,8 @@ postfix:max "⟱" => forgetToGrpd.map lemma forgetToGrpd_map {C D : PGrpd} (F : C ⟶ D) : F⟱ = F.base := rfl +attribute [local simp] forgetToGrpd_map + @[simp] theorem id_obj {C : PGrpd} (X : C.base) : (𝟙 C)⟱.obj X = X := rfl @@ -385,8 +394,8 @@ end theorem Functor.hext (F G : Γ ⥤ PGrpd) (hbase : F ⋙ forgetToGrpd = G ⋙ forgetToGrpd) (hfiber_obj : ∀ x : Γ, HEq (F.obj x).fiber (G.obj x).fiber) - (hfiber_map : ∀ {x y : Γ} (f : x ⟶ y), HEq (F.map f).fiber (G.map f).fiber) - : F = G := + (hfiber_map : ∀ {x y : Γ} (f : x ⟶ y), HEq (F.map f).fiber (G.map f).fiber) : + F = G := Grothendieck.FunctorTo.hext F G hbase hfiber_obj hfiber_map section diff --git a/HoTTLean/Pointed/IsPullback.lean b/HoTTLean/Pointed/IsPullback.lean index bc889780..d15e3df6 100644 --- a/HoTTLean/Pointed/IsPullback.lean +++ b/HoTTLean/Pointed/IsPullback.lean @@ -22,7 +22,7 @@ namespace CategoryTheory namespace PGrpd lemma forgetToPCat_forgetToCat : - PGrpd.forgetToPCat.{v,u} ⋙ PCat.forgetToCat.{v,u} = + PGrpd.forgetToPCat.{v,u} ⋙ PCat.forgetToCat.{v,u} = PGrpd.forgetToGrpd.{v,u} ⋙ Grpd.forgetToCat.{v,u} := rfl @@ -38,7 +38,7 @@ The following square is a (meta-theoretic) pullback Grpd------forgetToCat------->Cat -/ def isPullback : Functor.IsPullback forgetToPCat.{v,u} forgetToGrpd.{v,u} - PCat.forgetToCat Grpd.forgetToCat := + PCat.forgetToCat Grpd.forgetToCat := Functor.Grothendieck.isPullback _ /-- diff --git a/HoTTLean/Syntax/Autosubst.lean b/HoTTLean/Syntax/Autosubst.lean index 97def38e..a8381413 100644 --- a/HoTTLean/Syntax/Autosubst.lean +++ b/HoTTLean/Syntax/Autosubst.lean @@ -271,10 +271,10 @@ attribute [autosubst] id_eq /-- Decides equality of substitutions applied to expressions. -/ -macro "autosubst" : tactic => `(tactic| simp only [autosubst]) +macro "autosubst" : tactic => `(tactic| simp only [autosubst, Function.comp_apply]) /-- Use a term modulo `autosubst` conversion. -/ -macro "autosubst% " t:term : term => `(by convert ($t) using 1 <;> autosubst) +macro "autosubst% " t:term : term => `(by convert ($t) using 1 <;> first | rfl | autosubst) /-! Lemmas that come up in a few proofs -/ diff --git a/HoTTLean/Syntax/Axioms.lean b/HoTTLean/Syntax/Axioms.lean index a7056c45..7629a7c9 100644 --- a/HoTTLean/Syntax/Axioms.lean +++ b/HoTTLean/Syntax/Axioms.lean @@ -29,7 +29,7 @@ open Classical instance : LE (Axioms χ) where le E E' := ∀ ⦃c p⦄, (E c) = some p → (E' c) = some p -instance : IsRefl (Axioms χ) (· ≤ ·) where +instance : Std.Refl (α := Axioms χ) (· ≤ ·) where refl _ _ _ := id instance : IsTrans (Axioms χ) (· ≤ ·) where diff --git a/HoTTLean/Syntax/Basic.lean b/HoTTLean/Syntax/Basic.lean index d05dfe5a..86d0c199 100644 --- a/HoTTLean/Syntax/Basic.lean +++ b/HoTTLean/Syntax/Basic.lean @@ -42,7 +42,7 @@ inductive Expr where @[simp] theorem Expr.sizeOf_pos {χ} (e : Expr χ) : 0 < sizeOf e := by - induction e <;> { dsimp; omega } + cases e <;> simp +arith [sizeOf, Expr._sizeOf_1] /-- A convergent rewriting system for the HoTT0 σ-calculus. -/ -- The attribute has to be initialized here for use in downstream modules. diff --git a/HoTTLean/Syntax/EqCtx.lean b/HoTTLean/Syntax/EqCtx.lean index ab28a0af..38aa5f12 100644 --- a/HoTTLean/Syntax/EqCtx.lean +++ b/HoTTLean/Syntax/EqCtx.lean @@ -13,7 +13,7 @@ variable (E : Axioms χ) in inductive EqCtx : Ctx χ → Ctx χ → Prop | nil : EqCtx [] [] /-- Prefer using `EqCtx.snoc`. -/ - | snoc' {Γ Γ' A A' l} : + | snoc' {Γ Γ' : Ctx χ} {A A' : Expr χ} {l : Nat} : EqCtx Γ Γ' → E ∣ Γ ⊢[l] A ≡ A' → E ∣ Γ' ⊢[l] A ≡ A' → EqCtx ((A, l) :: Γ) ((A', l) :: Γ') theorem EqCtx.refl : WfCtx E Γ → EqCtx E Γ Γ := by diff --git a/HoTTLean/Syntax/GCongr.lean b/HoTTLean/Syntax/GCongr.lean index af584802..4127002e 100644 --- a/HoTTLean/Syntax/GCongr.lean +++ b/HoTTLean/Syntax/GCongr.lean @@ -203,10 +203,10 @@ attribute [gcongr] EqTm.cong_idRec /-! ## Lemmas for substitution -/ -attribute [gcongr] WfTp.subst_eq -attribute [gcongr] EqTp.subst_eq -attribute [gcongr] WfTm.subst_eq -attribute [gcongr] EqTm.subst_eq +attribute [gcongr only] WfTp.subst_eq +attribute [gcongr only] EqTp.subst_eq +attribute [gcongr only] WfTm.subst_eq +attribute [gcongr only] EqTm.subst_eq attribute [gcongr] EqTp.subst attribute [gcongr] EqTm.subst diff --git a/HoTTLean/Syntax/Inversion.lean b/HoTTLean/Syntax/Inversion.lean index 307fb278..864b8672 100644 --- a/HoTTLean/Syntax/Inversion.lean +++ b/HoTTLean/Syntax/Inversion.lean @@ -75,7 +75,8 @@ theorem inv_all : (∀ {Γ l A t u}, E ∣ Γ ⊢[l] t ≡ u : A → (WfCtx E Γ) ∧ (E ∣ Γ ⊢[l] A) ∧ (E ∣ Γ ⊢[l] t : A) ∧ (E ∣ Γ ⊢[l] u : A)) := by mutual_induction WfCtx - all_goals dsimp; try intros + all_goals try dsimp + all_goals try intros case bvar => grind [WfCtx.lookup_wf] case cong_pi' => grind [WfTp.pi'] case cong_sigma' => grind [WfTp.sigma'] @@ -252,7 +253,7 @@ theorem comp : WfSb E Θ σ Δ → WfSb E Δ σ' Γ → WfSb E Θ (Expr.comp σ intro σ σ' apply mk σ.wf_dom σ'.wf_cod intro _ _ _ lk - exact autosubst% σ'.lookup lk |>.subst σ + simpa only [autosubst, Expr.comp, Function.comp_apply] using (σ'.lookup lk).subst σ theorem toSb : E ∣ Γ ⊢[l] t : A → WfSb E Γ t.toSb ((A, l) :: Γ) := fun t => SubstProof.wfSb_toSb t.wf_ctx t.wf_tp t diff --git a/HoTTLean/Syntax/InversionLemmas.lean b/HoTTLean/Syntax/InversionLemmas.lean index 663ff739..a5bccf5b 100644 --- a/HoTTLean/Syntax/InversionLemmas.lean +++ b/HoTTLean/Syntax/InversionLemmas.lean @@ -289,7 +289,8 @@ theorem WfTm.inv_pair {Γ B C t u l₀ l l'} : E ∣ Γ ⊢[l₀] .pair l l' B t (E ∣ Γ ⊢[l₂] u' : B.subst t'.toSb) ∧ (E ∣ Γ ⊢[l] C ≡ .sigma l₁ l₂ A B) from fun h => this h rfl - mutual_induction WfCtx <;> grind [WfTp.sigma, WfTm.wf_tp, EqTp.refl_tp, EqTp.symm_tp, EqTp.trans_tp] + mutual_induction WfCtx <;> + grind [WfTp.sigma, WfTm.wf_tp, EqTp.refl_tp, EqTp.symm_tp, EqTp.trans_tp] theorem WfTm.inv_fst {Γ A B C p l₀ l l'} : E ∣ Γ ⊢[l₀] .fst l l' A B p : C → l₀ = l ∧ (E ∣ Γ ⊢[max l l'] p : .sigma l l' A B) ∧ (E ∣ Γ ⊢[l₀] C ≡ A) := by diff --git a/HoTTLean/Syntax/Substitution.lean b/HoTTLean/Syntax/Substitution.lean index e31830aa..4ee98e80 100644 --- a/HoTTLean/Syntax/Substitution.lean +++ b/HoTTLean/Syntax/Substitution.lean @@ -1,5 +1,6 @@ import Mathlib.Tactic.Convert import Mathlib.Tactic.SimpRw +import Mathlib.Tactic.Basic import HoTTLean.Syntax.Typing import HoTTLean.Tactic.MutualInduction import HoTTLean.Tactic.GrindCases @@ -20,7 +21,6 @@ theorem le_univMax_all : (∀ {Γ l A t}, E ∣ Γ ⊢[l] t : A → l ≤ univMax) ∧ (∀ {Γ l A t u}, E ∣ Γ ⊢[l] t ≡ u : A → l ≤ univMax) := by mutual_induction WfCtx - -- I ❤ grind and omega all_goals first | omega | try grind theorem WfCtx.le_univMax_of_lookup : WfCtx E Γ → Lookup Γ i A l → l ≤ univMax := @@ -63,7 +63,7 @@ theorem wk (Γ : Ctx χ) (A l) : WfRen ((A,l) :: Γ) Nat.succ Γ := by theorem comp : WfRen Θ ξ Δ → WfRen Δ ξ' Γ → WfRen Θ (ξ ∘ ξ') Γ := by unfold WfRen; intro wf wf' _ _ _ lk - exact autosubst% wf <| wf' lk + simpa only [autosubst, Function.comp_apply] using wf (wf' lk) theorem upr : WfRen Δ ξ Γ → WfRen ((A.rename ξ, l) :: Δ) (Expr.upr ξ) ((A, l) :: Γ) := by unfold WfRen; intro wf _ _ _ lk @@ -76,7 +76,7 @@ theorem upr : WfRen Δ ξ Γ → WfRen ((A.rename ξ, l) :: Δ) (Expr.upr ξ) (( end WfRen -attribute [local grind ←] WfCtx.snoc WfRen.upr in +attribute [local grind ← ] WfCtx.snoc WfRen.upr in theorem rename_all : (∀ {Γ l A}, E ∣ Γ ⊢[l] A → ∀ {Δ ξ}, WfCtx E Δ → WfRen Δ ξ Γ → E ∣ Δ ⊢[l] A.rename ξ) ∧ @@ -90,7 +90,8 @@ theorem rename_all : have ih_subst (B a : Expr χ) (ξ) : (B.subst a.toSb).rename ξ = (B.rename (Expr.upr ξ)).subst (a.rename ξ).toSb := by autosubst mutual_induction WfCtx - all_goals dsimp only; try intros + all_goals try dsimp only + all_goals try intros all_goals try simp only [Expr.rename, ih_subst] at *; clear ih_subst -- Cases that don't go through by `grind_cases`. case ax p _ Ec _ _ ihA _ _ Δ ξ => @@ -353,7 +354,7 @@ theorem Id_bvar : WfCtx E Γ → E ∣ Γ ⊢[l] A → E ∣ Γ ⊢[l] t : A → E ∣ (A, l) :: Γ ⊢[l] .Id l (A.subst Expr.wk) (t.subst Expr.wk) (.bvar 0) := fun Γ A t => WfTp.Id' (tp_wk Γ A A) (tm_wk Γ A t) (.bvar (Γ.snoc A) (.zero ..)) -attribute [local grind ←] WfCtx.snoc eqSb_up wfSb_up in +attribute [local grind ← ] WfCtx.snoc eqSb_up wfSb_up in attribute [local grind →] EqSb.wf_left EqSb.wf_right in attribute [local grind .] -- TODO: fwd or bwd for properties of equality? EqTp.refl_tp EqTp.symm_tp EqTp.trans_tp @@ -371,7 +372,8 @@ theorem subst_all : (∀ {Γ l A t u}, E ∣ Γ ⊢[l] t ≡ u : A → ∀ {Δ σ σ'}, EqSb E Δ σ σ' Γ → E ∣ Δ ⊢[l] t.subst σ ≡ u.subst σ' : A.subst σ) := by mutual_induction WfCtx - all_goals dsimp; try intros + all_goals try dsimp + all_goals try intros all_goals try simp only [Expr.subst_toSb_subst, Expr.subst_snoc_toSb_subst, Expr.subst] at * case ax p _ Ec _ _ ihA => constructor diff --git a/HoTTLean/Syntax/Synth.lean b/HoTTLean/Syntax/Synth.lean index b168d9eb..80b6fb07 100644 --- a/HoTTLean/Syntax/Synth.lean +++ b/HoTTLean/Syntax/Synth.lean @@ -40,8 +40,7 @@ Furthermore, the correctness proof `eq_synthLvl` needs zero metatheory. Does this imply we could omit level annotations from the syntax? In the interpretation function, we'd invoke `synthLvl.go` on `ExtSeq`. -/ noncomputable def synthLvl (Γ : Ctx χ) (e : Expr χ) : Nat := - go (Γ.map (·.2)) e -where + go (Γ.map (·.2)) e where go (Γ : List Nat) : Expr χ → Nat | .ax _ A => go Γ A | .bvar i => Γ[i]? |>.getD default @@ -133,7 +132,7 @@ theorem WfTm.tp_eq_synthTp : ∀ {Γ l A t}, E ∣ Γ ⊢[l] t : A → E ∣ Γ case snd' => grind [WfTp.subst, WfSb.toSb, WfTm.fst] case refl' => simp only [synthTp] - gcongr <;> grind + gcongr case idRec' C _ _ _ _ _ _ _ _ _ => unfold synthTp apply EqTp.refl_tp <| C.subst <| WfSb.snoc (WfSb.toSb ..) .. diff --git a/HoTTLean/Typechecker/Cache.lean b/HoTTLean/Typechecker/Cache.lean index 23e70989..6d1a8bef 100644 --- a/HoTTLean/Typechecker/Cache.lean +++ b/HoTTLean/Typechecker/Cache.lean @@ -9,7 +9,9 @@ structure Caches where checkTm : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) Expr := {} synthTm : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} equateTp : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) Expr := {} - equateTm : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) Expr := {} + equateTm : + Std.HashMap + (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) Expr := {} equateNeutTm : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq) Expr := {} evalTp : Std.HashMap (ExprStructEq × ExprStructEq) (Expr × Expr) := {} evalTm : Std.HashMap (ExprStructEq × ExprStructEq) (Expr × Expr) := {} @@ -19,14 +21,16 @@ structure Caches where evalClosTp : Std.HashMap (ExprStructEq × ExprStructEq) (Expr × Expr) := {} forceClosTp : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} evalClos₂Tp : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} - forceClos₂Tp : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} + forceClos₂Tp : + Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} evalClosTm : Std.HashMap (ExprStructEq × ExprStructEq) (Expr × Expr) := {} forceClosTm : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} evalEl : Std.HashMap (ExprStructEq) (Expr × Expr) := {} evalApp : Std.HashMap (ExprStructEq × ExprStructEq) (Expr × Expr) := {} evalFst : Std.HashMap (ExprStructEq) (Expr × Expr) := {} evalSnd : Std.HashMap (ExprStructEq) (Expr × Expr) := {} - evalIdRec : Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} + evalIdRec : + Std.HashMap (ExprStructEq × ExprStructEq × ExprStructEq × ExprStructEq) (Expr × Expr) := {} inductive TypecheckerM.CacheEntry | checkTp (vΓ l T : ExprStructEq) diff --git a/HoTTLean/Typechecker/Equate.lean b/HoTTLean/Typechecker/Equate.lean index 6b38e88f..5dfcafdc 100644 --- a/HoTTLean/Typechecker/Equate.lean +++ b/HoTTLean/Typechecker/Equate.lean @@ -266,7 +266,7 @@ partial def equateNeutTm (d : Q(Nat)) (nt nu : Q(Neut $χ)) : refine ⟨TUeq, ?_⟩ apply eqt.trans_tm _ |>.trans_tm (eqt'.conv_eq TUeq.symm_tp).symm_tm apply EqTm.conv_eq _ eq.symm_tp - gcongr + exact EqTm.cong_app Beq feq aeq ) | ~q(.fst _ $k' $p), ~q(.fst _ $m' $p') => do let km' ← equateNat q($k') q($m') @@ -296,10 +296,10 @@ partial def equateNeutTm (d : Q(Nat)) (nt nu : Q(Neut $χ)) : have ⟨_, _, _, Aeq, Beq⟩ := Seq.inv_sigma refine have TUeq := ?_; ⟨TUeq, ?_⟩ . apply eq.trans_tp _ |>.trans_tp eq'.symm_tp - gcongr; apply EqSb.toSb; gcongr + exact Beq.subst_eq (EqSb.toSb (EqTm.cong_fst Aeq Beq peq)) . apply eqt.trans_tm _ |>.trans_tm (eqt'.conv_eq TUeq.symm_tp).symm_tm apply EqTm.conv_eq _ eq.symm_tp - gcongr + exact EqTm.cong_snd Aeq Beq peq ) | ~q(.idRec $k $k' $vA $va $cM $vr $nh), ~q(.idRec $m $m' $vA' $va' $cM' $vr' $nh') => do let km ← equateNat q($k) q($m) @@ -341,7 +341,7 @@ partial def equateNeutTm (d : Q(Nat)) (nt nu : Q(Neut $χ)) : autosubst; gcongr exact aeq.wf_right exact aeq.symm_tm - gcongr + exact EqTm.cong_idRec aeq Meq this beq heq ) | nt, nu => throwError "cannot prove neutral terms are equal\ diff --git a/HoTTLean/Typechecker/Evaluate.lean b/HoTTLean/Typechecker/Evaluate.lean index 858a26ba..82fcc89d 100644 --- a/HoTTLean/Typechecker/Evaluate.lean +++ b/HoTTLean/Typechecker/Evaluate.lean @@ -119,7 +119,7 @@ partial def evalTm (env : Q(List (Val $χ))) (t' : Q(Expr $χ)) : introv env t have ⟨_, lk, eq⟩ := t.inv_bvar apply ValEqTm.conv_tp _ (eq.subst env.wf_sb).symm_tp - convert env.lookup_eq lk using 1 + convert env.lookup_eq lk using 1 <;> try rfl subst $v have ⟨_, h⟩ := List.getElem?_eq_some_iff.mp ($this).symm rw [h] @@ -174,7 +174,7 @@ partial def evalTm (env : Q(List (Val $χ))) (t' : Q(Expr $χ)) : introv env t obtain ⟨rfl, p, eq⟩ := t.inv_snd apply ValEqTm.conv_tp _ (eq.subst env.wf_sb).symm_tp - convert ($vpost) ($vppost env p) using 1 + convert ($vpost) ($vppost env p) using 1 <;> try rfl autosubst )⟩ | ~q(.refl $l $u) => do @@ -392,7 +392,7 @@ partial def evalNeutTm (env : Q(List (Val $χ))) (nt : Q(Neut $χ)) : have ⟨_, lk, eqt, eq⟩ := nt.inv_bvar apply ValEqTm.conv_tm _ (eqt.subst env.wf_sb).symm_tm apply ValEqTm.conv_tp _ (eq.subst env.wf_sb).symm_tp - convert env.lookup_eq lk using 1 + convert env.lookup_eq lk using 1 <;> try rfl subst $v obtain ⟨_, rfl⟩ := List.getElem?_eq_some_iff.mp ($this).symm congr 3 @@ -408,7 +408,7 @@ partial def evalNeutTm (env : Q(List (Val $χ))) (nt : Q(Neut $χ)) : subst_vars apply ValEqTm.conv_tm _ (eqt.subst env.wf_sb).symm_tm apply ValEqTm.conv_tp _ (eq.subst env.wf_sb).symm_tp - convert ($vpost ($vfpost env nf) ($vapost env va)) using 1 + convert ($vpost ($vfpost env nf) ($vapost env va)) using 1 <;> try rfl autosubst )⟩ | ~q(.fst $k $k' $np) => @@ -431,7 +431,7 @@ partial def evalNeutTm (env : Q(List (Val $χ))) (nt : Q(Neut $χ)) : subst_vars apply ValEqTm.conv_tm _ (eqt.subst env.wf_sb).symm_tm apply ValEqTm.conv_tp _ (eq.subst env.wf_sb).symm_tp - convert ($vpost ($vppost env np_eq)) using 1 + convert ($vpost ($vppost env np_eq)) using 1 <;> try rfl autosubst )⟩ | ~q(.idRec $k $k' $vA $va $cM $vr $vh) => @@ -682,7 +682,6 @@ partial def evalApp (vf va : Q(Val $χ)) : TypecheckerM ((v : Q(Val $χ)) × apply EqTm.cong_app (EqTp.refl_tp b.wf_tp) _ (EqTm.refl_tm va.wf_tm) apply EqTm.symm_tm; apply eqt.trans_tm apply EqTm.symm_tm; gcongr - assumption )⟩ | ~q(.neut $n (.pi $k $k' $vA $vB)) => do let ⟨vBa, vBpost⟩ ← evalClosTp q($vB) q($va) @@ -719,7 +718,7 @@ partial def evalFst (vp : Q(Val $χ)) : TypecheckerM ((v : Q(Val $χ)) × apply EqTm.fst_pair Beq.wf_left t u |>.symm_tm.trans_tm gcongr apply EqTm.trans_tm _ eqt.symm_tm - gcongr <;> assumption + gcongr apply v.conv_nf (this.conv_eq Aeq) Aeq.symm_tp )⟩ | ~q(.neut $n (.sigma $k $k' $vA $vB)) => @@ -753,14 +752,14 @@ partial def evalSnd (vp : Q(Val $χ)) : TypecheckerM ((v : Q(Val $χ)) × apply EqTm.fst_pair Beq.wf_left t u |>.symm_tm.trans_tm gcongr apply EqTm.trans_tm _ eqt.symm_tm - gcongr <;> assumption + gcongr replace w := w.conv_tp <| Beq.symm_tp.subst_eq (EqSb.toSb feq) apply w.conv_tm apply EqTm.snd_pair Beq.wf_left t u |>.symm_tm.conv_eq (Beq'.wf_left.subst_eq (EqSb.toSb feq)) |>.trans_tm _ apply EqTm.symm_tm; gcongr apply eqt.trans_tm - apply EqTm.symm_tm; gcongr <;> assumption + apply EqTm.symm_tm; gcongr )⟩ | ~q(.neut $n (.sigma $k $k' $vA $vB)) => do let ⟨vf, vfpost⟩ ← evalFst q($vp) @@ -805,7 +804,7 @@ partial def evalIdRec (l' : Q(Nat)) (cM : Q(Clos $χ)) (vr vh : Q(Val $χ)) : apply EqTm.symm_tm apply EqTm.cong_idRec (.refl_tm t) (.refl_tp M) (.refl_tm vr.wf_tm) tu refine ?eq - apply EqTm.trans_tm _ <| eqt.symm_tm.conv_eq _ <;> gcongr; assumption + apply EqTm.trans_tm _ <| eqt.symm_tm.conv_eq _ <;> gcongr . apply M.subst_eq <| EqSb.snoc (EqSb.toSb tu) (.Id_bvar t) (autosubst% ?eq) )⟩ | ~q(.neut $nh (.Id $l $vA $va $vb)) => do diff --git a/HoTTLean/Typechecker/Synth.lean b/HoTTLean/Typechecker/Synth.lean index bbfc8ed7..7d971acf 100644 --- a/HoTTLean/Typechecker/Synth.lean +++ b/HoTTLean/Typechecker/Synth.lean @@ -41,6 +41,8 @@ partial def lookupVar (vΓ : Q(TpEnv Lean.Name)) (i : Q(Nat)) : partial def lookupAxiom (E : Q(Axioms Lean.Name)) (c : Q(Lean.Name)) : Lean.MetaM ((A : Q(Expr Lean.Name)) × (l : Q(Nat)) × Q(∃ h, $E $c = some ⟨($A, $l), h⟩) ⊕ Q($E $c = none)) := do + if E.isAppOf ``CheckedAx.snocAxioms then + return ← lookupAxiom (← Lean.Meta.unfoldDefinition E) c match E with | ~q(.empty _) => return .inr q(by rfl) | ~q(Axioms.snoc $E' $l $c' $A $l_le $A_cl) => @@ -71,9 +73,6 @@ partial def lookupAxiom (E : Q(Axioms Lean.Name)) (c : Q(Lean.Name)) : Lean.Meta {Lean.indentExpr q($c') |>.nest 2}\ {Lean.indentD "="}\ {Lean.indentExpr c |>.nest 2}" - | ~q(CheckedAx.snocAxioms _) => - let E ← Lean.Meta.unfoldDefinition E - lookupAxiom E c | _ => throwError "unsupported axiom environment{Lean.indentExpr E}" partial def checkAxiomsLe (E E' : Q(Axioms Lean.Name)) : Lean.MetaM Q($E ≤ $E') := do @@ -105,7 +104,7 @@ variable (E : Q(Axioms Lean.Name)) (Ewf : Q(($E).Wf)) partial def checkTp (vΓ : Q(TpEnv Lean.Name)) (l : Q(Nat)) (T : Q(Expr Lean.Name)) : TypecheckerM Q(∀ {Γ}, TpEnvEqCtx $E $vΓ Γ → $E ∣ Γ ⊢[$l] ($T)) := Lean.withTraceNode traceClsTypechecker (fun e => - return m!"{Lean.exceptEmoji e} {vΓ} ⊢[{l}] {T}") do + return m!"{e.emoji} {vΓ} ⊢[{l}] {T}") do let key := (⟨vΓ⟩, ⟨l⟩, ⟨T⟩) if let some pf := (← get).checkTp[key]? then return pf eventually (fun pf => @@ -166,7 +165,7 @@ partial def checkTm (vΓ : Q(TpEnv Lean.Name)) (l : Q(Nat)) TypecheckerM Q(∀ {Γ T}, TpEnvEqCtx $E $vΓ Γ → ValEqTp $E Γ $l $vT T → $E ∣ Γ ⊢[$l] ($t) : T) := do Lean.withTraceNode traceClsTypechecker (fun e => - return m!"{Lean.exceptEmoji e} {vΓ} ⊢[{l}] {t} ⇐ {vT}") do + return m!"{e.emoji} {vΓ} ⊢[{l}] {t} ⇐ {vT}") do let key := (⟨vΓ⟩, ⟨l⟩, ⟨vT⟩, ⟨t⟩) if let some pf := (← get).checkTm[key]? then return pf eventually (fun pf => diff --git a/HoTTLean/Typechecker/Value.lean b/HoTTLean/Typechecker/Value.lean index f88be533..4b8363c5 100644 --- a/HoTTLean/Typechecker/Value.lean +++ b/HoTTLean/Typechecker/Value.lean @@ -311,11 +311,12 @@ private theorem wf_expr : (∀ {Γ l vt t A}, ValEqTm E Γ l vt t A → E ∣ Γ ⊢[l] t : A) ∧ (∀ {Γ l vt t A}, NeutEqTm E Γ l vt t A → E ∣ Γ ⊢[l] t : A) ∧ (∀ {Γ l l' A vB B}, ClosEqTp E Γ l l' A vB B → E ∣ (A, l) :: Γ ⊢[l'] B) ∧ - (∀ {Γ A l B l' l'' cC C}, Clos₂EqTp E Γ A l B l' l'' cC C → E ∣ (B, l') :: (A, l) :: Γ ⊢[l''] C) ∧ + (∀ {Γ A l B l' l'' cC C}, + Clos₂EqTp E Γ A l B l' l'' cC C → E ∣ (B, l') :: (A, l) :: Γ ⊢[l''] C) ∧ (∀ {Γ l l' A B vb b}, ClosEqTm E Γ l l' A B vb b → E ∣ (A, l) :: Γ ⊢[l'] b : B) ∧ (∀ {Γ Eᵥ σ Γ'}, EnvEqSb E Γ Eᵥ σ Γ' → WfSb E Γ σ Γ') := by mutual_induction ValEqTp - all_goals dsimp; intros + all_goals intros case ax => apply WfTm.ax <;> assumption case conv_tp => grind [EqTp.wf_right] case conv_nf tt' AA' _ => exact tt'.wf_right.conv AA' @@ -496,7 +497,7 @@ private theorem wk_all : apply ValEqTm.pair this (iht C) (autosubst% ihu C) case conv_nf => grind [ValEqTm.conv_nf, EqTp.subst, EqTm.subst, WfSb.wk] case bvar Γ lk _ _ C => - convert NeutEqTm.bvar (Γ.snoc C) (.succ _ lk) using 1; grind + convert NeutEqTm.bvar (Γ.snoc C) (.succ _ lk) using 1 <;> first | rfl | grind case app ihA ihf iha _ _ C => exact autosubst% NeutEqTm.app (ihA C) (ihf C) (iha C) case snd ih _ _ C => diff --git a/HoTTLean/Typechecker/ValueInversion.lean b/HoTTLean/Typechecker/ValueInversion.lean index 3707e4b9..2fe5b39c 100644 --- a/HoTTLean/Typechecker/ValueInversion.lean +++ b/HoTTLean/Typechecker/ValueInversion.lean @@ -139,7 +139,7 @@ theorem ValEqTm.inv_neut {Γ vA A vt t l} : ValEqTm E Γ l (.neut vt vA) t A → all_goals grind [NeutEqTm.conv_neut, ValEqTp.conv_tp] theorem NeutEqTm.inv_ax {Γ C c vA t l₀} : NeutEqTm E Γ l₀ (.ax c vA) t C → ∃ Al, - l₀ = Al.val.2 ∧ E c = some Al ∧ ValEqTp E Γ Al.val.2 vA Al.val.1 ∧ + l₀ = Al.val.2 ∧ E c = some Al ∧ ValEqTp E Γ Al.val.2 vA Al.val.1 ∧ (E ∣ Γ ⊢[l₀] t ≡ .ax c Al.val.1 : C) ∧ (E ∣ Γ ⊢[l₀] C ≡ Al.val.1) := by suffices ∀ {Γ l₀ vt t C}, NeutEqTm E Γ l₀ vt t C → ∀ {c vA}, vt = .ax c vA → ∃ Al, l₀ = Al.val.2 ∧ E c = some Al ∧ ValEqTp E Γ Al.val.2 vA Al.val.1 ∧ @@ -203,10 +203,12 @@ theorem NeutEqTm.inv_fst {Γ C vp f l₀ l l'} : NeutEqTm E Γ l₀ (.fst l l' v theorem NeutEqTm.inv_snd {Γ C vp s l₀ l l'} : NeutEqTm E Γ l₀ (.snd l l' vp) s C → l₀ = l' ∧ ∃ A B p, NeutEqTm E Γ (max l l') vp p (.sigma l l' A B) ∧ - (E ∣ Γ ⊢[l'] s ≡ .snd l l' A B p : C) ∧ (E ∣ Γ ⊢[l'] C ≡ B.subst (Expr.fst l l' A B p).toSb) := by + (E ∣ Γ ⊢[l'] s ≡ .snd l l' A B p : C) ∧ + (E ∣ Γ ⊢[l'] C ≡ B.subst (Expr.fst l l' A B p).toSb) := by suffices ∀ {Γ l₀ vn n C}, NeutEqTm E Γ l₀ vn n C → ∀ {vp l l'}, vn = .snd l l' vp → l₀ = l' ∧ ∃ A B p, NeutEqTm E Γ (max l l') vp p (.sigma l l' A B) ∧ - (E ∣ Γ ⊢[l'] n ≡ .snd l l' A B p : C) ∧ (E ∣ Γ ⊢[l'] C ≡ B.subst (Expr.fst l l' A B p).toSb) from + (E ∣ Γ ⊢[l'] n ≡ .snd l l' A B p : C) ∧ + (E ∣ Γ ⊢[l'] C ≡ B.subst (Expr.fst l l' A B p).toSb) from fun h => this h rfl mutual_induction NeutEqTm all_goals intros; try exact True.intro diff --git a/HoTTLeanTest.lean b/HoTTLeanTest.lean new file mode 100644 index 00000000..af9d2503 --- /dev/null +++ b/HoTTLeanTest.lean @@ -0,0 +1,5 @@ +import HoTTLeanTest.basic +import HoTTLeanTest.functorMap +import HoTTLeanTest.import +import HoTTLeanTest.hott0 +import HoTTLeanTest.unitt diff --git a/test/basic.lean b/HoTTLeanTest/basic.lean similarity index 97% rename from test/basic.lean rename to HoTTLeanTest/basic.lean index 99b86d7e..31d22bc5 100644 --- a/test/basic.lean +++ b/HoTTLeanTest/basic.lean @@ -84,6 +84,6 @@ mltt noncomputable def c' : Cb := c /-! ## Using `sorry` -/ -/-- warning: declaration uses 'sorry' -/ +/-- warning: declaration uses `sorry` -/ #guard_msgs in mltt def foo : Type := sorry diff --git a/HoTTLeanTest/functorMap.lean b/HoTTLeanTest/functorMap.lean new file mode 100644 index 00000000..b6c75e16 --- /dev/null +++ b/HoTTLeanTest/functorMap.lean @@ -0,0 +1,38 @@ +import HoTTLean.ForMathlib.Tactic.CategoryTheory.FunctorMap + +/-! +# Tests for `functor_map` + +Check the generated declarations, nested attributes, and term elaborator with independent +object and morphism universes in the source and target categories. +-/ + +universe v₁ u₁ v₂ u₂ + +namespace CategoryTheory.FunctorMapTest + +variable {C : Type u₁} [Category.{v₁} C] + +@[functor_map (attr := reassoc (attr := simp))] +theorem comp_id_of_eq {X Y : C} (f g : X ⟶ Y) (h : f = g) : f ≫ 𝟙 Y = g := by + simpa using h + +run_cmd do + let env ← Lean.getEnv + for name in [``comp_id_of_eq_functor_map, ``comp_id_of_eq_functor_map_assoc] do + unless (Lean.Meta.simpExtension.getState env).lemmaNames.contains (.decl name) do + throwError "missing simp attribute on {name}" + +variable {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D) + +example {X Y : C} (f g : X ⟶ Y) (h : f = g) : F.map f = F.map g := + comp_id_of_eq_functor_map f g h F + +example {X Y : C} (f g : X ⟶ Y) (h : f = g) {Z : D} (k : F.obj Y ⟶ Z) : + F.map f ≫ k = F.map g ≫ k := + comp_id_of_eq_functor_map_assoc f g h F k + +example {X Y : C} (f g : X ⟶ Y) (h : f = g) : F.map f = F.map g := + (functor_map_of% (comp_id_of_eq f g h)) F + +end CategoryTheory.FunctorMapTest diff --git a/test/hott0.lean b/HoTTLeanTest/hott0.lean similarity index 100% rename from test/hott0.lean rename to HoTTLeanTest/hott0.lean diff --git a/test/import.lean b/HoTTLeanTest/import.lean similarity index 81% rename from test/import.lean rename to HoTTLeanTest/import.lean index aab44aca..17148e1f 100644 --- a/test/import.lean +++ b/HoTTLeanTest/import.lean @@ -1,4 +1,4 @@ -import test.basic +import HoTTLeanTest.basic /-! Test importing a theory. -/ diff --git a/test/unitt.lean b/HoTTLeanTest/unitt.lean similarity index 52% rename from test/unitt.lean rename to HoTTLeanTest/unitt.lean index 9024b7b1..7be1978f 100644 --- a/test/unitt.lean +++ b/HoTTLeanTest/unitt.lean @@ -1,6 +1,6 @@ import HoTTLean.Frontend.Commands -import HoTTLean.Model.Interpretation -import HoTTLean.Groupoids.NaturalModelBase +import HoTTLean.Model.Unstructured.Interpretation +import HoTTLean.Groupoids.UHom import HoTTLean.Groupoids.Pi import HoTTLean.Groupoids.Sigma import HoTTLean.Groupoids.Id @@ -29,34 +29,33 @@ unitt def uniq_fn {A : Type} (f g : A → Unit) : Identity f g := by /-! ## Interpretation -/ open SynthLean -open CategoryTheory MonoidalCategory NaturalModel Universe GroupoidModel - -instance : uHomSeq.IdSeq := sorry +open CategoryTheory MonoidalCategory Model.UnstructuredUniverse GroupoidModel +open ChosenTerminal theorem slen : univMax ≤ uHomSeq.length := by grind [uHomSeq, univMax] -def Groupoid.asTy (G : Type 0) [Groupoid.{0,0} G] : y(𝟙_ Ctx) ⟶ uHomSeq[0].Ty := - yonedaEquiv.symm <| ULift.up { - obj _ := Core.mk <| ULift.up <| Grpd.of G - map _ := CoreHom.mk <| Iso.refl _ - } +def Groupoid.asTy (G : Type 0) [Groupoid.{0,0} G] : (𝟭_ Ctx) ⟶ uHomSeq[0].Ty := + Grpd.homOf { + obj _ := Core.mk <| ULift.up <| Grpd.of G + map _ := CoreHom.mk (Iso.refl _) + } -def sUnit : y(𝟙_ Ctx) ⟶ uHomSeq[0].Ty := +def sUnit : (𝟭_ Ctx) ⟶ uHomSeq[0].Ty := Groupoid.asTy (Discrete _root_.Unit) -def sUnit' : y(𝟙_ Ctx) ⟶ uHomSeq[1].Tm := +def sUnit' : (𝟭_ Ctx) ⟶ uHomSeq[1].Tm := uHomSeq.code (Nat.zero_lt_succ _) sUnit @[simp] -def sUnit'_tp : sUnit' ≫ uHomSeq[1].tp = (uHomSeq.homSucc 0).wkU _ := by - simp [sUnit'] +theorem sUnit'_tp : sUnit' ≫ uHomSeq[1].tp = (uHomSeq.homSucc 0).wkU _ := by + simpa [sUnit'] using uHomSeq.code_tp (Nat.zero_lt_succ _) sUnit -def I : Universe.Interpretation Lean.Name uHomSeq where +def I : Interpretation Lean.Name uHomSeq where ax := fun | ``Unit, 1, _ => some sUnit' | _, _, _ => none -theorem I_wf : I.Wf slen Unit.snocAxioms where +theorem I_wf : Model.UnstructuredUniverse.Interpretation.Wf slen I Unit.snocAxioms where ax := by intro _ _ Ec unfold CheckedAx.snocAxioms Axioms.snoc at Ec @@ -65,12 +64,15 @@ theorem I_wf : I.Wf slen Unit.snocAxioms where subst_vars unfold Unit simp [I, Interpretation.ofType, UHomSeq.nilCObj] - rfl + exact ⟨⟨rfl, trivial⟩, sUnit'_tp⟩ -instance : Fact (I.Wf slen Unit.snocAxioms) := ⟨I_wf⟩ +instance : Fact (Model.UnstructuredUniverse.Interpretation.Wf slen I Unit.snocAxioms) := + ⟨I_wf⟩ -example : I.interpTm Unit.wf_val = sUnit' := by - unfold Interpretation.interpTm Interpretation.ofTerm CheckedAx.val I Unit +example : Model.UnstructuredUniverse.Interpretation.interpTm + (I := I) (slen := slen) Unit.wf_val = sUnit' := by + unfold Model.UnstructuredUniverse.Interpretation.interpTm + Model.UnstructuredUniverse.Interpretation.ofTerm CheckedAx.val I Unit simp only [Part.pure_eq_some, Part.get_some] conv => rhs; rw [← Category.id_comp sUnit'] - congr 1; apply Limits.IsTerminal.hom_ext ChosenTerminal.isTerminal_yUnit + congr 1 diff --git a/README.md b/README.md index 4d899b32..456763d3 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,15 @@ together with a proof mode for developing mathematics synthetically in those typ HoTTLean is work-in-progress. It currently contains the following components: + - A deep embedding of MLTT syntax with Π, Σ, Id types, and base constants (`HoTTLean.Syntax`). - **SynthLean**, a proof assistant for these deeply embedded theories (`HoTTLean.Frontend`). It includes a certifying typechecker (`HoTTLean.Typechecker`). - Natural model semantics of MLTT in presheaf categories (`HoTTLean.Model`) and a proof that this semantics is sound for the syntax (`ofType_ofTerm_sound`). - -- A `sorry`-free construction of the groupoid model of type theory with Π, Σ, Id types (`HoTTLean.Groupoids`). +- A `sorry`-free construction of the groupoid model of type theory with Π, Σ, Id types + (`HoTTLean.Groupoids`). - Pieces of general mathematics and category theory such as the Grothendieck construction for groupoids (`HoTTLean.ForMathlib`, `HoTTLean.Grothendieck`, `HoTTLean.Pointed`). @@ -23,7 +24,8 @@ Documentation of the Lean code can be found [here](https://sinhp.github.io/HoTTLean/docs/). (We also have [a blueprint](https://sinhp.github.io/HoTTLean/), but it is very outdated.) -Relevant papers to this project are listed below +Relevant papers to this project are listed below: + - [A Certifying Proof Assistant for Synthetic Mathematics in Lean](https://voidma.in/assets/papers/2026nawrocki_certifying_proof_assistant_synthetic_mathematics_lean.pdf) - [Path Types in Algebraic Type Theory](https://arxiv.org/abs/2601.06567v1) @@ -35,6 +37,13 @@ We rely on [Mathlib](https://github.com/leanprover-community/mathlib4) and [Poly](https://github.com/sinhp/Poly/), a formalization of polynomial functors. +The project uses Lean and Mathlib v4.34.1. +The required Lean version is recorded in [`lean-toolchain`](lean-toolchain), +and dependency revisions are pinned in `lake-manifest.json`. +The Poly dependency currently uses the Lean v4.34.1 port from +[`sosudo/Poly`](https://github.com/sosudo/Poly/), proposed in +[Poly PR #41](https://github.com/sinhp/Poly/pull/41). + ### How can I try out HoTTLean? First make sure that [Lean is installed](https://lean-lang.org/install/). @@ -46,15 +55,18 @@ then in a terminal execute lake exe cache get # Build the project lake build +# Build the alternative natural model +lake build NaturalModel # Run tests (optional) lake test ``` -Examples demonstrating the usage of SynthLean (for internal reasoning) -and of our model definitions (for external reasoning) -can be found under `test/`: -- `test/unitt` specifies a type theory with a unit type. -- `test/hott0` defines HoTT0, +Examples demonstrating SynthLean and our model definitions are in `HoTTLeanTest/`. +These are checked by `lake test`, including an interpretation of the unit type +in the groupoid model: + +- [`HoTTLeanTest/unitt.lean`](HoTTLeanTest/unitt.lean) specifies a type theory with a unit type. +- [`HoTTLeanTest/hott0.lean`](HoTTLeanTest/hott0.lean) defines HoTT0, a version of HoTT where univalence only holds for h-sets. ### Can I contribute to HoTTLean? diff --git a/home_page/_site/404.html b/home_page/_site/404.html deleted file mode 100644 index 0d983fdc..00000000 --- a/home_page/_site/404.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - -Groupoid Model of HoTT in Lean 4 | by S. Awodey, M. Carneiro, S. Hazratpour, J. Hua, W. Nawrocki, S. Woolfson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to the content. - - - -
- - -
-

404

- -

Page not found :(

-

The requested page could not be found.

-
- - -
- - - diff --git a/home_page/_site/assets/css/style.css b/home_page/_site/assets/css/style.css deleted file mode 100644 index 5647b980..00000000 --- a/home_page/_site/assets/css/style.css +++ /dev/null @@ -1,327 +0,0 @@ -/* In this file you can add css rules overriding rules defined by your Jekyll theme. */ -/* Import the CSS from the specified theme */ -/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ -/** 1. Set default font family to sans-serif. 2. Prevent iOS text size adjust after orientation change, without disabling user zoom. */ -@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap"); -html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ } - -/** Remove default margin. */ -body { margin: 0; } - -/* HTML5 display definitions ========================================================================== */ -/** Correct `block` display not defined for any HTML5 element in IE 8/9. Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. Correct `block` display not defined for `main` in IE 11. */ -article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } - -/** 1. Correct `inline-block` display not defined in IE 8/9. 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */ -audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ } - -/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */ -audio:not([controls]) { display: none; height: 0; } - -/** Address `[hidden]` styling not present in IE 8/9/10. Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. */ -[hidden], template { display: none; } - -/* Links ========================================================================== */ -/** Remove the gray background color from active links in IE 10. */ -a { background-color: transparent; } - -/** Improve readability when focused and also mouse hovered in all browsers. */ -a:active, a:hover { outline: 0; } - -/* Text-level semantics ========================================================================== */ -/** Address styling not present in IE 8/9/10/11, Safari, and Chrome. */ -abbr[title] { border-bottom: 1px dotted; } - -/** Address style set to `bolder` in Firefox 4+, Safari, and Chrome. */ -b, strong { font-weight: bold; } - -/** Address styling not present in Safari and Chrome. */ -dfn { font-style: italic; } - -/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari, and Chrome. */ -h1 { font-size: 2em; margin: 0.67em 0; } - -/** Address styling not present in IE 8/9. */ -mark { background: #ff0; color: #000; } - -/** Address inconsistent and variable font size in all browsers. */ -small { font-size: 80%; } - -/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */ -sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } - -sup { top: -0.5em; } - -sub { bottom: -0.25em; } - -/* Embedded content ========================================================================== */ -/** Remove border when inside `a` element in IE 8/9/10. */ -img { border: 0; } - -/** Correct overflow not hidden in IE 9/10/11. */ -svg:not(:root) { overflow: hidden; } - -/* Grouping content ========================================================================== */ -/** Address margin not present in IE 8/9 and Safari. */ -figure { margin: 1em 40px; } - -/** Address differences between Firefox and other browsers. */ -hr { box-sizing: content-box; height: 0; } - -/** Contain overflow in all browsers. */ -pre { overflow: auto; } - -/** Address odd `em`-unit font size rendering in all browsers. */ -code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; } - -/* Forms ========================================================================== */ -/** Known limitation: by default, Chrome and Safari on OS X allow very limited styling of `select`, unless a `border` property is set. */ -/** 1. Correct color not being inherited. Known issue: affects color of disabled elements. 2. Correct font properties not being inherited. 3. Address margins set differently in Firefox 4+, Safari, and Chrome. */ -button, input, optgroup, select, textarea { color: inherit; /* 1 */ font: inherit; /* 2 */ margin: 0; /* 3 */ } - -/** Address `overflow` set to `hidden` in IE 8/9/10/11. */ -button { overflow: visible; } - -/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. Correct `select` style inheritance in Firefox. */ -button, select { text-transform: none; } - -/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */ -button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ } - -/** Re-set default cursor for disabled elements. */ -button[disabled], html input[disabled] { cursor: default; } - -/** Remove inner padding and border in Firefox 4+. */ -button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } - -/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */ -input { line-height: normal; } - -/** It's recommended that you don't attempt to style these elements. Firefox's implementation doesn't respect box-sizing, padding, or width. 1. Address box sizing set to `content-box` in IE 8/9/10. 2. Remove excess padding in IE 8/9/10. */ -input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ } - -/** Fix the cursor style for Chrome's increment/decrement buttons. For certain `font-size` values of the `input`, it causes the cursor style of the decrement button to change from `default` to `text`. */ -input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } - -/** 1. Address `appearance` set to `searchfield` in Safari and Chrome. 2. Address `box-sizing` set to `border-box` in Safari and Chrome (include `-moz` to future-proof). */ -input[type="search"] { -webkit-appearance: textfield; /* 1 */ /* 2 */ box-sizing: content-box; } - -/** Remove inner padding and search cancel button in Safari and Chrome on OS X. Safari (but not Chrome) clips the cancel button when the search input has padding (and `textfield` appearance). */ -input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } - -/** Define consistent border, margin, and padding. */ -fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } - -/** 1. Correct `color` not being inherited in IE 8/9/10/11. 2. Remove padding so people aren't caught out if they zero out fieldsets. */ -legend { border: 0; /* 1 */ padding: 0; /* 2 */ } - -/** Remove default vertical scrollbar in IE 8/9/10/11. */ -textarea { overflow: auto; } - -/** Don't inherit the `font-weight` (applied by a rule above). NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */ -optgroup { font-weight: bold; } - -/* Tables ========================================================================== */ -/** Remove most spacing between table cells. */ -table { border-collapse: collapse; border-spacing: 0; } - -td, th { padding: 0; } - -.highlight table td { padding: 5px; } - -.highlight table pre { margin: 0; } - -.highlight .cm { color: #999988; font-style: italic; } - -.highlight .cp { color: #999999; font-weight: bold; } - -.highlight .c1 { color: #999988; font-style: italic; } - -.highlight .cs { color: #999999; font-weight: bold; font-style: italic; } - -.highlight .c, .highlight .cd { color: #999988; font-style: italic; } - -.highlight .err { color: #a61717; background-color: #e3d2d2; } - -.highlight .gd { color: #000000; background-color: #ffdddd; } - -.highlight .ge { color: #000000; font-style: italic; } - -.highlight .gr { color: #aa0000; } - -.highlight .gh { color: #999999; } - -.highlight .gi { color: #000000; background-color: #ddffdd; } - -.highlight .go { color: #888888; } - -.highlight .gp { color: #555555; } - -.highlight .gs { font-weight: bold; } - -.highlight .gu { color: #aaaaaa; } - -.highlight .gt { color: #aa0000; } - -.highlight .kc { color: #000000; font-weight: bold; } - -.highlight .kd { color: #000000; font-weight: bold; } - -.highlight .kn { color: #000000; font-weight: bold; } - -.highlight .kp { color: #000000; font-weight: bold; } - -.highlight .kr { color: #000000; font-weight: bold; } - -.highlight .kt { color: #445588; font-weight: bold; } - -.highlight .k, .highlight .kv { color: #000000; font-weight: bold; } - -.highlight .mf { color: #009999; } - -.highlight .mh { color: #009999; } - -.highlight .il { color: #009999; } - -.highlight .mi { color: #009999; } - -.highlight .mo { color: #009999; } - -.highlight .m, .highlight .mb, .highlight .mx { color: #009999; } - -.highlight .sb { color: #d14; } - -.highlight .sc { color: #d14; } - -.highlight .sd { color: #d14; } - -.highlight .s2 { color: #d14; } - -.highlight .se { color: #d14; } - -.highlight .sh { color: #d14; } - -.highlight .si { color: #d14; } - -.highlight .sx { color: #d14; } - -.highlight .sr { color: #009926; } - -.highlight .s1 { color: #d14; } - -.highlight .ss { color: #990073; } - -.highlight .s { color: #d14; } - -.highlight .na { color: #008080; } - -.highlight .bp { color: #999999; } - -.highlight .nb { color: #0086B3; } - -.highlight .nc { color: #445588; font-weight: bold; } - -.highlight .no { color: #008080; } - -.highlight .nd { color: #3c5d5d; font-weight: bold; } - -.highlight .ni { color: #800080; } - -.highlight .ne { color: #990000; font-weight: bold; } - -.highlight .nf { color: #990000; font-weight: bold; } - -.highlight .nl { color: #990000; font-weight: bold; } - -.highlight .nn { color: #555555; } - -.highlight .nt { color: #000080; } - -.highlight .vc { color: #008080; } - -.highlight .vg { color: #008080; } - -.highlight .vi { color: #008080; } - -.highlight .nv { color: #008080; } - -.highlight .ow { color: #000000; font-weight: bold; } - -.highlight .o { color: #000000; font-weight: bold; } - -.highlight .w { color: #bbbbbb; } - -.highlight { background-color: #f8f8f8; } - -* { box-sizing: border-box; } - -body { padding: 0; margin: 0; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.5; color: #606c71; } - -#skip-to-content { height: 1px; width: 1px; position: absolute; overflow: hidden; top: -10px; } -#skip-to-content:focus { position: fixed; top: 10px; left: 10px; height: auto; width: auto; background: #e19447; outline: thick solid #e19447; } - -a { color: #1e6bb8; text-decoration: none; } -a:hover { text-decoration: underline; } - -.btn { display: inline-block; margin-bottom: 1rem; color: rgba(255, 255, 255, 0.7); background-color: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); border-style: solid; border-width: 1px; border-radius: 0.3rem; transition: color 0.2s, background-color 0.2s, border-color 0.2s; } -.btn:hover { color: rgba(255, 255, 255, 0.8); text-decoration: none; background-color: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.3); } -.btn + .btn { margin-left: 1rem; } -@media screen and (min-width: 64em) { .btn { padding: 0.75rem 1rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .btn { padding: 0.6rem 0.9rem; font-size: 0.9rem; } } -@media screen and (max-width: 42em) { .btn { display: block; width: 100%; padding: 0.75rem; font-size: 0.9rem; } - .btn + .btn { margin-top: 1rem; margin-left: 0; } } - -.page-header { color: #fff; text-align: center; background-color: #159957; background-image: linear-gradient(120deg, #155799, #159957); } -@media screen and (min-width: 64em) { .page-header { padding: 5rem 6rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .page-header { padding: 3rem 4rem; } } -@media screen and (max-width: 42em) { .page-header { padding: 2rem 1rem; } } - -.project-name { margin-top: 0; margin-bottom: 0.1rem; } -@media screen and (min-width: 64em) { .project-name { font-size: 3.25rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .project-name { font-size: 2.25rem; } } -@media screen and (max-width: 42em) { .project-name { font-size: 1.75rem; } } - -.project-tagline { margin-bottom: 2rem; font-weight: normal; opacity: 0.7; } -@media screen and (min-width: 64em) { .project-tagline { font-size: 1.25rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .project-tagline { font-size: 1.15rem; } } -@media screen and (max-width: 42em) { .project-tagline { font-size: 1rem; } } - -.main-content { word-wrap: break-word; } -.main-content :first-child { margin-top: 0; } -@media screen and (min-width: 64em) { .main-content { max-width: 64rem; padding: 2rem 6rem; margin: 0 auto; font-size: 1.1rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .main-content { padding: 2rem 4rem; font-size: 1.1rem; } } -@media screen and (max-width: 42em) { .main-content { padding: 2rem 1rem; font-size: 1rem; } } -.main-content kbd { background-color: #fafbfc; border: 1px solid #c6cbd1; border-bottom-color: #959da5; border-radius: 3px; box-shadow: inset 0 -1px 0 #959da5; color: #444d56; display: inline-block; font-size: 11px; line-height: 10px; padding: 3px 5px; vertical-align: middle; } -.main-content img { max-width: 100%; } -.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { margin-top: 2rem; margin-bottom: 1rem; font-weight: normal; color: #159957; } -.main-content p { margin-bottom: 1em; } -.main-content code { padding: 2px 4px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.9rem; color: #567482; background-color: #f3f6fa; border-radius: 0.3rem; } -.main-content pre { padding: 0.8rem; margin-top: 0; margin-bottom: 1rem; font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace; color: #567482; word-wrap: normal; background-color: #f3f6fa; border: solid 1px #dce6f0; border-radius: 0.3rem; } -.main-content pre > code { padding: 0; margin: 0; font-size: 0.9rem; color: #567482; word-break: normal; white-space: pre; background: transparent; border: 0; } -.main-content .highlight { margin-bottom: 1rem; } -.main-content .highlight pre { margin-bottom: 0; word-break: normal; } -.main-content .highlight pre, .main-content pre { padding: 0.8rem; overflow: auto; font-size: 0.9rem; line-height: 1.45; border-radius: 0.3rem; -webkit-overflow-scrolling: touch; } -.main-content pre code, .main-content pre tt { display: inline; max-width: initial; padding: 0; margin: 0; overflow: initial; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } -.main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after { content: normal; } -.main-content ul, .main-content ol { margin-top: 0; } -.main-content blockquote { padding: 0 1rem; margin-left: 0; color: #819198; border-left: 0.3rem solid #dce6f0; } -.main-content blockquote > :first-child { margin-top: 0; } -.main-content blockquote > :last-child { margin-bottom: 0; } -.main-content table { display: block; width: 100%; overflow: auto; word-break: normal; word-break: keep-all; -webkit-overflow-scrolling: touch; } -.main-content table th { font-weight: bold; } -.main-content table th, .main-content table td { padding: 0.5rem 1rem; border: 1px solid #e9ebec; } -.main-content dl { padding: 0; } -.main-content dl dt { padding: 0; margin-top: 1rem; font-size: 1rem; font-weight: bold; } -.main-content dl dd { padding: 0; margin-bottom: 1rem; } -.main-content hr { height: 2px; padding: 0; margin: 1rem 0; background-color: #eff0f1; border: 0; } - -.site-footer { padding-top: 2rem; margin-top: 2rem; border-top: solid 1px #eff0f1; } -@media screen and (min-width: 64em) { .site-footer { font-size: 1rem; } } -@media screen and (min-width: 42em) and (max-width: 64em) { .site-footer { font-size: 1rem; } } -@media screen and (max-width: 42em) { .site-footer { font-size: 0.9rem; } } - -.site-footer-owner { display: block; font-weight: bold; } - -.site-footer-credits { color: #819198; } - -/* Put your rules below this line */ diff --git a/home_page/_site/index.html b/home_page/_site/index.html deleted file mode 100644 index 5e1110cf..00000000 --- a/home_page/_site/index.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - -Groupoid Model of HoTT in Lean 4 | by S. Awodey, M. Carneiro, S. Hazratpour, J. Hua, W. Nawrocki, S. Woolfson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to the content. - - - -
-

Useful links:

- - - - - -
- - - diff --git a/lake-manifest.json b/lake-manifest.json index 930c29a9..a4828b70 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -1,41 +1,38 @@ -{"version": "1.1.0", +{"version": "1.2.0", "packagesDir": ".lake/packages", "packages": - [{"url": "https://github.com/PatrickMassot/checkdecls.git", + [{"url": "https://github.com/sosudo/Poly", "type": "git", "subDir": null, "scope": "", - "rev": "3d425859e73fcfbef85b9638c2a91708ef4a22d4", - "name": "checkdecls", + "rev": "ba73d5149ac19b1186b6e58648217b52db6b8cdb", + "name": "Poly", "manifestFile": "lake-manifest.json", - "inputRev": null, + "inputRev": "ba73d5149ac19b1186b6e58648217b52db6b8cdb", "inherited": false, "configFile": "lakefile.lean"}, - {"url": "https://github.com/sinhp/Poly", - "type": "git", - "subDir": null, + {"type": "path", "scope": "", - "rev": "aedee22f07d681d845bcbe4a1fb9aa10f95c9977", - "name": "Poly", + "name": "checkdecls", "manifestFile": "lake-manifest.json", - "inputRev": "master", - "inherited": false, + "inherited": true, + "dir": ".lake/packages/Poly/vendor/checkdecls", "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/mathlib4.git", "type": "git", "subDir": null, "scope": "", - "rev": "32bd6c7c8ca4a4be1c71bc04df0c9cf929d04818", + "rev": "d13f23b723b8a846827a245b89c10fc7d3f11612", "name": "mathlib", "manifestFile": "lake-manifest.json", - "inputRev": null, + "inputRev": "v4.34.1", "inherited": true, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/plausible", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "8864a73bf79aad549e34eff972c606343935106d", + "rev": "118aa17ee84656b8bd727fef7c458ee8c833385c", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -45,7 +42,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "2ed4ba69b6127de8f5c2af83cccacd3c988b06bf", + "rev": "ddf04cf3949fa556442341e87d47f9f6e6074707", "name": "LeanSearchClient", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -55,7 +52,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "451499ea6e97cee4c8979b507a9af5581a849161", + "rev": "e928b72544873815af278d38681b31c0293588e3", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -65,17 +62,17 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "fb8ed0a85a96e3176f6e94b20d413ea72d92576d", + "rev": "106ff4fafc74ef4ac99d81dbf3ab399118f497a5", "name": "proofwidgets", "manifestFile": "lake-manifest.json", - "inputRev": "v0.0.77", + "inputRev": "main", "inherited": true, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/aesop", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "1fa48c6a63b4c4cda28be61e1037192776e77ac0", + "rev": "355695d523e41d0554926416cba2a2b3544fbbc9", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -85,7 +82,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "95c2f8afe09d9e49d3cacca667261da04f7f93f7", + "rev": "6a489d9af5d0c47e5b259e2e8bcdfc1811b5a259", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -95,7 +92,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "c44068fa1b40041e6df42bd67639b690eb2764ca", + "rev": "f2effa3d803fda822b1f97b806c47cf2adfbcbc2", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -105,11 +102,12 @@ "type": "git", "subDir": null, "scope": "leanprover", - "rev": "72ae7004d9f0ddb422aec5378204fdd7828c5672", + "rev": "e92c9f15fdfacc8536f31cfb3b7ad26c3c8cd204", "name": "Cli", "manifestFile": "lake-manifest.json", - "inputRev": "v4.25.0-rc2", + "inputRev": "v4.34.0", "inherited": true, "configFile": "lakefile.toml"}], "name": "hottlean", - "lakeDir": ".lake"} + "lakeDir": ".lake", + "fixedToolchain": false} diff --git a/lakefile.lean b/lakefile.lean index 2807a875..6337022d 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -1,13 +1,12 @@ import Lake open Lake DSL -require Poly from git "https://github.com/sinhp/Poly" @ "master" - -require checkdecls from git "https://github.com/PatrickMassot/checkdecls.git" +-- Lean v4.34.1 port, proposed in sinhp/Poly#41. +require Poly from git "https://github.com/sosudo/Poly" @ "ba73d5149ac19b1186b6e58648217b52db6b8cdb" meta if get_config? env = some "dev" then require «doc-gen4» from git - "https://github.com/leanprover/doc-gen4" @ "v4.25.0-rc2" + "https://github.com/leanprover/doc-gen4" @ "v4.34.1" package hottlean where -- Settings applied to both builds and interactive editing @@ -37,4 +36,4 @@ lean_lib HoTTLean where needs := #[Prelude] @[test_driver] -lean_lib test where +lean_lib HoTTLeanTest where diff --git a/lean-toolchain b/lean-toolchain index 137937a3..ba8ebf2d 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.25.0-rc2 \ No newline at end of file +leanprover/lean4:v4.34.1 diff --git a/test.lean b/test.lean deleted file mode 100644 index dc13b5c9..00000000 --- a/test.lean +++ /dev/null @@ -1,3 +0,0 @@ -import test.basic -import test.import -import test.hott0