├── .Notes (outdated) ├── HowNameSpacesWorkInLean.lean ├── natural_model_univ │ ├── .gitignore │ ├── groupoid_model.tex │ ├── main.pdf │ ├── main.tex │ ├── prooftree.tex │ └── refs.bib └── natural_model_univ_July18.pdf ├── .github └── workflows │ ├── blueprint.yml │ ├── push.yml │ └── push_pr.yml ├── .gitignore ├── .vscode └── settings.json ├── GroupoidModel.lean ├── GroupoidModel ├── ForMathlib.lean ├── ForMathlib │ ├── CategoryTheory │ │ ├── Functor │ │ │ ├── IsPullback.lean │ │ │ └── Iso.lean │ │ ├── RepPullbackCone.lean │ │ └── Yoneda.lean │ └── Tactic │ │ └── CategoryTheory │ │ └── FunctorMap.lean ├── ForPoly.lean ├── Grothendieck │ ├── Groupoidal │ │ ├── Basic.lean │ │ └── IsPullback.lean │ └── IsPullback.lean ├── Groupoids │ ├── Basic.lean │ ├── IsPullback.lean │ ├── NaturalModelBase.lean │ ├── Pi.lean │ └── Sigma.lean ├── Outline.md ├── Pointed │ ├── Basic.lean │ └── IsPullback.lean ├── Russell_PER_MS │ ├── Basic.lean │ ├── Interpretation.lean │ ├── Lemmas.lean │ ├── NaturalModel.lean │ ├── Substitution.lean │ ├── Typing.lean │ └── UHom.lean └── attic │ ├── Display.lean │ ├── FibrationForMathlib │ ├── Data │ │ └── Fiber.lean │ ├── Displayed │ │ ├── Basic.lean │ │ ├── Cartesian.lean │ │ ├── Chevalley.lean │ │ ├── Fiber.lean │ │ ├── Fibration.lean │ │ └── widget_test.lean │ └── FibredCats │ │ ├── Basic.lean │ │ ├── CartLift.lean │ │ ├── CartesianLift.lean │ │ ├── Display_test.lean │ │ ├── Displayed_BiCat.lean │ │ ├── Fibration.lean │ │ ├── Total.lean │ │ ├── VerticalLift.lean │ │ └── gaplift_cast.lean │ ├── PullbackProofs.lean │ ├── README.md │ ├── Russell_PER_MS │ └── NaturalModelPi.lean │ └── Tarski │ ├── NaturalModel.lean │ ├── TarskiNaturalModel.lean │ └── TypeTheory.lean ├── README.md ├── blueprint └── src │ ├── Packages │ └── bussproofs.py │ ├── Templates │ └── prooftree.jinja2 │ ├── blueprint.sty │ ├── chapter │ ├── all.tex │ ├── groupoid_model.tex │ ├── interpretation.tex │ ├── natural_model.tex │ ├── polynomial.tex │ └── syntax.tex │ ├── extra_styles.css │ ├── latexmkrc │ ├── macros │ ├── common.tex │ ├── print.tex │ └── web.tex │ ├── plastex.cfg │ ├── print.tex │ ├── refs.bib │ └── web.tex ├── flake.nix ├── home_page ├── 404.html ├── Gemfile ├── Gemfile.lock ├── _config.yml ├── _include │ └── mathjax.html ├── _layouts │ └── default.html ├── _site │ ├── 404.html │ ├── assets │ │ └── css │ │ │ └── style.css │ └── index.html ├── assets │ └── css │ │ └── style.scss └── index.md ├── lake-manifest.json ├── lakefile.lean ├── lean-toolchain └── scripts └── update_mathlib.sh /.Notes (outdated)/HowNameSpacesWorkInLean.lean: -------------------------------------------------------------------------------- 1 | def bar : Nat := 3 2 | 3 | namespace Foo 4 | 5 | def bar : Nat := 0 6 | 7 | def baz : Nat := 1 8 | 9 | end Foo 10 | 11 | 12 | -- #check baz -- fails because `baz` is not in the root namespace 13 | 14 | section annonymous1 15 | 16 | #check bar 17 | 18 | #check Foo.bar 19 | 20 | #eval bar -- evaluates to 3 21 | 22 | #eval Foo.bar -- evaluates to 0 23 | 24 | #check Foo.baz 25 | 26 | -- or first open `Foo` in this section and then access `bar` and `baz` in it 27 | 28 | open Foo 29 | 30 | #check bar -- this is `Foo.bar` 31 | 32 | #check _root_.bar -- this is the root `bar` defined in the first line of this file outside the namespace `Foo`. 33 | 34 | -- #eval bar -- ambiguous, possible interpretations ` _root_.bar : Nat` and ` Foo.bar : Nat`. 35 | 36 | #eval _root_.bar -- evaluates to 3 37 | 38 | #eval Foo.bar -- evaluates to 0 39 | 40 | #check baz 41 | 42 | end annonymous1 43 | 44 | 45 | 46 | 47 | 48 | section annonymous2 49 | 50 | -- open `Foo` but only access `bar` in it 51 | open Foo (bar) 52 | 53 | #check bar -- works 54 | 55 | #check baz -- fails 56 | 57 | end annonymous2 58 | 59 | 60 | section annonymous3 61 | 62 | open Foo hiding bar 63 | 64 | #check bar -- fails 65 | 66 | #check baz -- works 67 | 68 | 69 | 70 | 71 | end annonymous3 72 | 73 | 74 | section annonymous4 75 | 76 | open Foo in 77 | #check bar 78 | 79 | -- #check baz -- fails because `Foo` was opened only for `bar`. 80 | 81 | end annonymous4 82 | 83 | 84 | namespace Foo 85 | 86 | -- introducing a new namespace `Qux` inside `Foo` 87 | 88 | namespace Qux 89 | 90 | def quux : Nat := 2 91 | 92 | end Qux 93 | 94 | end Foo 95 | 96 | #check Foo.Qux.quux 97 | 98 | 99 | section annonymous5 100 | 101 | --#check Foo.quux -- fails because `quux` is in `Foo.Qux` namespace 102 | 103 | open Foo.Qux 104 | 105 | #check quux 106 | 107 | end annonymous5 108 | -------------------------------------------------------------------------------- /.Notes (outdated)/natural_model_univ/.gitignore: -------------------------------------------------------------------------------- 1 | *.synctex.gz 2 | *.out 3 | *.log 4 | *.fdb_latexmk 5 | *.blg 6 | *.bbl 7 | *.fls 8 | *.aux 9 | *.auctex-auto 10 | -------------------------------------------------------------------------------- /.Notes (outdated)/natural_model_univ/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sinhp/groupoid_model_in_lean4/a9b76bd791fcada283eb20ba2a2e20cefb939f60/.Notes (outdated)/natural_model_univ/main.pdf -------------------------------------------------------------------------------- /.Notes (outdated)/natural_model_univ/main.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,11pt]{article} 2 | 3 | \usepackage{amsthm,amsmath,amssymb,stmaryrd,enumerate,a4,array} 4 | \usepackage{geometry} 5 | \usepackage{url} 6 | \usepackage[cmtip,all]{xy} 7 | \usepackage{hyperref} 8 | \usepackage{subcaption} 9 | \usepackage{cleveref} 10 | \numberwithin{equation}{section} 11 | \usepackage[parfill]{parskip} 12 | \usepackage{tikz, tikz-cd, float} % Commutative Diagrams 13 | 14 | \input{prooftree} 15 | 16 | %%%%%%% THEOREMS %%%%%%%%% 17 | \newtheorem{theorem}{Theorem}[section] 18 | \newtheorem*{theorem*}{Theorem} 19 | \newtheorem{prop}[theorem]{Proposition} 20 | \newtheorem{obs}[theorem]{Observation} 21 | \newtheorem{lemma}[theorem]{Lemma} 22 | \newtheorem{cor}[theorem]{Corollary} 23 | \newtheorem{applemma}{Lemma}[section] 24 | 25 | \theoremstyle{definition} 26 | \newtheorem{defn}[theorem]{Definition} 27 | 28 | \theoremstyle{remark} 29 | \newtheorem{rmk}[theorem]{Remark} 30 | \newtheorem*{eg}{Example} 31 | \newtheorem{ex}{Exercise} 32 | \newtheorem*{remark*}{Remark} 33 | \newtheorem*{remarks*}{Remarks} 34 | \newtheorem*{notation*}{Notation} 35 | \newtheorem*{convention*}{Convention} 36 | 37 | \newenvironment{comment}{\begin{quote} \em Comment. }{\end{quote}} 38 | 39 | %%%%%%% SYMBOLS %%%%%%%%% 40 | 41 | \newcommand{\defeq}{=_{\mathrm{def}}} 42 | \newcommand{\iso}{\cong} 43 | \newcommand{\equi}{\simeq} 44 | \newcommand{\retequi}{\unlhd} 45 | \newcommand{\op}{\mathrm{op}} 46 | \newcommand{\Id}{\mathrm{Id}} 47 | \newcommand{\Nat}{\mathbb{N}} 48 | \newcommand{\co}{\colon} 49 | \newcommand{\st}{\,|\,} 50 | 51 | % \newcommand{\cat}{\mathbb} 52 | \newcommand{\catC}{\mathbb{C}} 53 | \newcommand{\tcat}{\mathbf} 54 | \newcommand{\id}{\mathsf{id}} 55 | \newcommand{\psh}[1]{\mathbf{Psh}(#1)} %% consider renaming to \Psh 56 | \newcommand{\yo}{\mathsf{y}} 57 | \newcommand{\pshC}{\psh{\catC}} 58 | \newcommand{\Type}{\mathsf{Ty}} 59 | \newcommand{\Term}{\mathsf{Tm}} 60 | \newcommand{\tp}{\mathsf{tp}} 61 | \newcommand{\disp}[1]{\mathsf{disp}_{#1}} 62 | \newcommand{\var}{\mathsf{var}} 63 | \newcommand{\Prop}{\mathsf{Prop}} 64 | \newcommand{\U}{\mathsf{U}} 65 | \newcommand{\E}{\mathsf{E}} 66 | \newcommand{\El}{\mathsf{El}} 67 | \newcommand{\Poly}[1]{\mathsf{Poly}_{#1}} 68 | \newcommand{\pair}{\mathsf{pair}} 69 | \newcommand{\fst}{\mathsf{fst}} 70 | \newcommand{\ev}[2]{\mathsf{ev}_{#1} \, #2} 71 | \newcommand{\counit}{\mathsf{counit}} 72 | 73 | \newcommand{\Fib}{\mathsf{Fib}} 74 | \newcommand{\lift}[2]{\mathsf{lift} \, #1 \, #2} 75 | \newcommand{\fiber}{\mathsf{fiber}} 76 | \newcommand{\terminal}{\bullet} 77 | \newcommand{\Two}{\bullet+\bullet} 78 | \newcommand{\Interval}{\mathbb{I}} 79 | 80 | \newcommand{\set}{\tcat{set}} 81 | \newcommand{\Set}{\tcat{Set}} 82 | \newcommand{\cat}{\tcat{cat}} 83 | \newcommand{\ptcat}{\tcat{cat}_\bullet} 84 | \newcommand{\Cat}{\tcat{Cat}} 85 | \newcommand{\ptCat}{\tcat{Cat}_\bullet} 86 | \newcommand{\grpd}{\tcat{grpd}} 87 | % \newcommand{\Grpd}{\tcat{Grpd}} 88 | \newcommand{\ptgrpd}{\tcat{grpd}_\bullet} 89 | % \newcommand{\ptGrpd}{\tcat{Grpd}_\bullet} 90 | \newcommand{\Pshgrpd}{\mathbf{Psh}(\grpd)} 91 | \newcommand{\PshCat}{\mathbf{Psh}(\Cat)} 92 | 93 | % % Greek 94 | \newcommand{\al}{\alpha} 95 | \newcommand{\be}{\beta} 96 | \newcommand{\ga}{\gamma} 97 | \newcommand{\de}{\delta} 98 | \newcommand{\ep}{\varepsilon} 99 | \newcommand{\io}{\iota} 100 | \newcommand{\ka}{\kappa} 101 | \newcommand{\la}{\lambda} 102 | \newcommand{\om}{\omega} 103 | \newcommand{\si}{\sigma} 104 | 105 | \newcommand{\Ga}{\Gamma} 106 | \newcommand{\De}{\Delta} 107 | \newcommand{\Th}{\Theta} 108 | \newcommand{\La}{\Lambda} 109 | \newcommand{\Si}{\Sigma} 110 | \newcommand{\Om}{\Omega} 111 | 112 | \title{Universe in the Natural Model of Type Theory} 113 | \author{Sina Hazratpour} 114 | 115 | \date{\today} 116 | 117 | \begin{document} 118 | 119 | 120 | \maketitle 121 | 122 | 123 | 124 | \section{Types} 125 | 126 | Assume an inaccessible cardinal $\lambda$. Write $\Set$ for the category of all sets. Say that a set $A$ is $\lambda$-small if $|A| < \lambda$. Write $\Set_\lambda$ for the full 127 | subcategory of $\Set$ spanned by $\lambda$-small sets. 128 | 129 | Let $\mathbb{C}$ be a small category, i.e.~a category whose class of objects is a set and 130 | whose hom-classes are sets. 131 | % We do not assume that $\mathbb{C}$ is $\lambda$-small for 132 | % the moment. 133 | 134 | We write $\pshC$ for the category of presheaves over $\catC$, 135 | \[ 136 | \pshC \defeq [\catC^\op, \Set] 137 | \] 138 | 139 | % Because of the assumption of the existence of $\lambda$, $\pshC$ has additional structure. Let 140 | % \[ 141 | % \Term \to \Type 142 | % \] 143 | % be the Hofmann-Streicher universe in $\pshC$ associated to $\lambda$. In particular, 144 | % \[ 145 | % \Type(c) \defeq \{ A \co (\catC_{/c})^\op \to \Set_{\lambda} \} 146 | % \] 147 | 148 | The Natural Model associated to a presentable map $\tp \co \Term \to \Type$ consists of 149 | \begin{itemize} 150 | \item contexts as objects $\Gamma, \Delta, \ldots \in \catC$, 151 | \item a type in context $\yo (\Gamma)$ as a map $A \co \yo(\Gamma) \to \Type$, 152 | \item a term of type $A$ in context $\Gamma$ as a map $a \co \yo(\Gamma) \to \Term$ such that 153 | \[ 154 | \xymatrix{ 155 | & \Term \ar[d]^{\tp} \\ 156 | \Gamma \ar[r]_-A \ar[ur]^{a} & \Type} 157 | \] 158 | commutes, 159 | \item an operation called ``context extension'' which given a context $\Gamma$ and a type $A \co \yo(\Gamma) \to \Type$ produces a context $\Gamma\cdot A$ which fits into a pullback diagram below. 160 | \[ 161 | \xymatrix{ 162 | \yo(\Gamma.A) \ar[r] \ar[d] & \Term \ar[d] \\ 163 | \yo(\Gamma) \ar[r]_-{A} & \Type} 164 | \] 165 | \end{itemize} 166 | 167 | % In the internal type theory of $\pshC$, we write 168 | % \[ 169 | % (\Gamma) \ A \co \Type \qquad (\Gamma) \ a \co A 170 | % \] 171 | % to mean that $A$ is a type in context $\Gamma$ and that $a$ is an element of type $A$ in context 172 | % $\Gamma$, respectively. 173 | 174 | 175 | 176 | 177 | {\bf Remark.} 178 | Sometimes, we first construct a presheaf $X$ over $\Gamma$ and observe that it can be classified by a map into $\Type$. We write 179 | \[ 180 | \xymatrix@C=1cm{ 181 | X \ar[r] \ar[d]& \Term \ar[d] \\ 182 | \yo(\Gamma) \ar[r]_-{\ulcorner X \urcorner} & \Type} 183 | \] 184 | to express this situation, i.e.~$X \cong \yo(\Gamma \cdot \ulcorner X \urcorner)$. 185 | 186 | \medskip 187 | 188 | 189 | 190 | \section{A type of small types} 191 | 192 | We now wish to formulate a condition that allows us to have a type of small types, written $\U$, not just {\em judgement} expressing that something is a type. With this notation, the judgements that we would like to derive is 193 | \[ 194 | \U \co \Type \qquad 195 | \begin{prooftree} 196 | a \co \U 197 | \justifies 198 | \El(a) \co \Type 199 | \end{prooftree} 200 | \] 201 | 202 | (A sufficient and natural condition for this seems to be that we now have another inaccessible cardinal $\kappa$, with $\kappa < \lambda$.) 203 | 204 | In the Natural Model, a universe $\U$ is postulated by a map 205 | \[ 206 | \pi \co \E \to \U 207 | \] 208 | 209 | In the Natural Model: 210 | \begin{itemize} 211 | \item There is a pullback diagram of the form 212 | \[ 213 | \xymatrix{ 214 | \U \ar[r] \ar[d] & \Term \ar[d] \\ 215 | 1 \ar[r]_-{\ulcorner \U \urcorner } & \Type } 216 | \] 217 | \item There is an inclusion of $\U$ into $\Type$ 218 | \[ 219 | \El \co \U \rightarrowtail \Type 220 | \] 221 | \item $\pi : \E \to \U$ is obtained as pullback of $\tp$; There is a pullback diagram 222 | \[ 223 | \xymatrix{ 224 | E \ar@{>->}[r] \ar[d] & \Term \ar[d] \\ 225 | \U \ar@{>->}[r]_-{\El} & \Type } 226 | \] 227 | \end{itemize} 228 | 229 | With the notation above, we get 230 | \[ 231 | \xymatrix{ 232 | \yo (\Gamma.\El(a)) \ar[r] \ar[d] & \E \ar[r] \ar[d] & \Term \ar[d] \\ 233 | \yo (\Gamma) \ar[r]_a \ar@/_2pc/[rr]_-{A} & \U \ar[r]_{\El} & \Type} 234 | \] 235 | Both squares above are pullback squares. 236 | 237 | 238 | \section{The Universe in Embedded Type Theory (HoTT0) and the relationship to the Natural Model} 239 | 240 | \section{Groupoid Model of HoTT} 241 | 242 | \include{groupoid_model.tex} 243 | 244 | 245 | 246 | 247 | 248 | 249 | \bibliography{refs.bib}{} 250 | \bibliographystyle{alpha} 251 | 252 | 253 | 254 | 255 | \end{document} 256 | 257 | -------------------------------------------------------------------------------- /.Notes (outdated)/natural_model_univ/refs.bib: -------------------------------------------------------------------------------- 1 | @misc{awodey2023hofmannstreicheruniverses, 2 | title={On Hofmann-Streicher universes}, 3 | author={Steve Awodey}, 4 | year={2023}, 5 | eprint={2205.10917}, 6 | archivePrefix={arXiv}, 7 | primaryClass={math.CT}, 8 | url={https://arxiv.org/abs/2205.10917}, 9 | } 10 | 11 | @incollection {hofmannstreicher1996, 12 | AUTHOR = {Hofmann, Martin and Streicher, Thomas}, 13 | TITLE = {The groupoid interpretation of type theory}, 14 | BOOKTITLE = {Twenty-five years of constructive type theory 15 | ({V}enice, 1995)}, 16 | SERIES = {Oxford Logic Guides}, 17 | VOLUME = {36}, 18 | PAGES = {83--111}, 19 | PUBLISHER = {Oxford Univ. Press}, 20 | ADDRESS = {New York}, 21 | YEAR = {1998}, 22 | MRCLASS = {03B15 (68N15 68Q55)}, 23 | MRNUMBER = {1686862}, 24 | } 25 | 26 | @misc{joyalnlabmodelstructuresoncat, 27 | author = {André Joyal}, 28 | title = {Model structures on Cat}, 29 | howpublished = {\url{https://ncatlab.org/joyalscatlab/published/Model+structures+on+Cat}}, 30 | } 31 | -------------------------------------------------------------------------------- /.Notes (outdated)/natural_model_univ_July18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sinhp/groupoid_model_in_lean4/a9b76bd791fcada283eb20ba2a2e20cefb939f60/.Notes (outdated)/natural_model_univ_July18.pdf -------------------------------------------------------------------------------- /.github/workflows/blueprint.yml: -------------------------------------------------------------------------------- 1 | name: Compile blueprint 2 | 3 | on: 4 | push: 5 | branches: 6 | - master # Trigger on pushes to the default branch 7 | workflow_dispatch: # Allow manual triggering of the workflow from the GitHub Actions interface 8 | 9 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 10 | permissions: 11 | contents: read # Read access to repository contents 12 | pages: write # Write access to GitHub Pages 13 | id-token: write # Write access to ID tokens 14 | 15 | jobs: 16 | build_project: 17 | runs-on: ubuntu-latest 18 | name: Build project 19 | steps: 20 | - name: Checkout project 21 | uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 # Fetch all history for all branches and tags 24 | 25 | - name: Install elan 26 | run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y 27 | 28 | - name: Ensure doc-gen4 is in lake-manifest.json 29 | run: ~/.elan/bin/lake update -R -Kenv=dev doc-gen4 30 | 31 | - name: Get Mathlib cache 32 | run: ~/.elan/bin/lake exe cache get || true 33 | 34 | - name: Build project 35 | run: ~/.elan/bin/lake build GroupoidModel 36 | 37 | - name: Cache mathlib API docs 38 | uses: actions/cache@v4 39 | with: 40 | path: | 41 | .lake/build/doc/Init 42 | .lake/build/doc/Lake 43 | .lake/build/doc/Lean 44 | .lake/build/doc/Std 45 | .lake/build/doc/Mathlib 46 | .lake/build/doc/declarations 47 | .lake/build/doc/find 48 | .lake/build/doc/*.* 49 | !.lake/build/doc/declarations/declaration-data-GroupoidModel* 50 | key: MathlibDoc-${{ hashFiles('lake-manifest.json') }} 51 | restore-keys: MathlibDoc- 52 | 53 | - name: Build project API documentation 54 | run: ~/.elan/bin/lake -R -Kenv=dev build GroupoidModel:docs 55 | 56 | - name: Check for `home_page` folder # this is meant to detect a Jekyll-based website 57 | id: check_home_page 58 | run: | 59 | if [ -d home_page ]; then 60 | echo "The 'home_page' folder exists in the repository." 61 | echo "HOME_PAGE_EXISTS=true" >> $GITHUB_ENV 62 | else 63 | echo "The 'home_page' folder does not exist in the repository." 64 | echo "HOME_PAGE_EXISTS=false" >> $GITHUB_ENV 65 | fi 66 | 67 | - name: Build blueprint and copy to `home_page/blueprint` 68 | uses: xu-cheng/texlive-action@v2 69 | with: 70 | docker_image: ghcr.io/xu-cheng/texlive-full:20231201 71 | run: | 72 | # Install necessary dependencies and build the blueprint 73 | apk update 74 | apk add --update make py3-pip git pkgconfig graphviz graphviz-dev gcc musl-dev 75 | git config --global --add safe.directory $GITHUB_WORKSPACE 76 | git config --global --add safe.directory `pwd` 77 | python3 -m venv env 78 | source env/bin/activate 79 | pip install --upgrade pip requests wheel 80 | pip install pygraphviz --global-option=build_ext --global-option="-L/usr/lib/graphviz/" --global-option="-R/usr/lib/graphviz/" 81 | pip install leanblueprint 82 | leanblueprint pdf 83 | mkdir -p home_page 84 | cp blueprint/print/print.pdf home_page/blueprint.pdf 85 | leanblueprint web 86 | cp -r blueprint/web home_page/blueprint 87 | 88 | - name: Check declarations mentioned in the blueprint exist in Lean code 89 | run: | 90 | ~/.elan/bin/lake exe checkdecls blueprint/lean_decls 91 | 92 | - name: Copy API documentation to `home_page/docs` 93 | run: cp -r .lake/build/doc home_page/docs 94 | 95 | - name: Remove unnecessary lake files from documentation in `home_page/docs` 96 | run: | 97 | find home_page/docs -name "*.trace" -delete 98 | find home_page/docs -name "*.hash" -delete 99 | 100 | - name: Bundle dependencies 101 | uses: ruby/setup-ruby@v1 102 | with: 103 | working-directory: home_page 104 | ruby-version: "3.0" # Specify Ruby version 105 | bundler-cache: true # Enable caching for bundler 106 | 107 | - name: Build website using Jekyll 108 | if: env.HOME_PAGE_EXISTS == 'true' 109 | working-directory: home_page 110 | run: JEKYLL_ENV=production bundle exec jekyll build # Note this will also copy the blueprint and API doc into home_page/_site 111 | 112 | - name: "Upload website (API documentation, blueprint and any home page)" 113 | uses: actions/upload-pages-artifact@v3 114 | with: 115 | path: ${{ env.HOME_PAGE_EXISTS == 'true' && 'home_page/_site' || 'home_page/' }} 116 | 117 | - name: Deploy to GitHub Pages 118 | id: deployment 119 | uses: actions/deploy-pages@v4 120 | 121 | - name: Make sure the API documentation cache works 122 | run: mv home_page/docs .lake/build/doc 123 | 124 | -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | 6 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 7 | permissions: 8 | contents: read 9 | pages: write 10 | id-token: write 11 | 12 | jobs: 13 | style_lint: 14 | name: Lint style 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Check for long lines 18 | if: always() 19 | run: | 20 | ! (find GroupoidModel -name "*.lean" -type f -exec grep -E -H -n '^.{101,}$' {} \; | grep -v -E 'https?://') 21 | 22 | - name: Don't 'import Mathlib', use precise imports 23 | if: always() 24 | run: | 25 | ! (find GroupoidModel -name "*.lean" -type f -print0 | xargs -0 grep -E -n '^import Mathlib$') 26 | 27 | build_project: 28 | runs-on: ubuntu-latest 29 | name: Build project 30 | steps: 31 | - name: Checkout project 32 | uses: actions/checkout@v2 33 | with: 34 | fetch-depth: 0 35 | 36 | - name: Install elan 37 | run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none 38 | 39 | - name: Get cache 40 | run: ~/.elan/bin/lake exe cache get || true 41 | 42 | - name: Build project 43 | run: ~/.elan/bin/lake build GroupoidModel 44 | 45 | # - name: Cache mathlib docs 46 | # uses: actions/cache@v3 47 | # with: 48 | # path: | 49 | # .lake/build/doc/Init 50 | # .lake/build/doc/Lake 51 | # .lake/build/doc/Lean 52 | # .lake/build/doc/Std 53 | # .lake/build/doc/Mathlib 54 | # .lake/build/doc/declarations 55 | # !.lake/build/doc/declarations/declaration-data-GroupoidModel* 56 | # key: MathlibDoc-${{ hashFiles('lake-manifest.json') }} 57 | # restore-keys: | 58 | # MathlibDoc- -------------------------------------------------------------------------------- /.github/workflows/push_pr.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | 4 | jobs: 5 | build_project: 6 | runs-on: ubuntu-latest 7 | name: Build project 8 | steps: 9 | - name: Checkout project 10 | uses: actions/checkout@v2 11 | with: 12 | fetch-depth: 0 13 | 14 | - name: Install elan 15 | run: curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain leanprover/lean4:4.0.0 16 | 17 | - name: Get cache 18 | run: ~/.elan/bin/lake exe cache get 19 | 20 | - name: Build project 21 | run: ~/.elan/bin/lake build GroupoidModel -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## macOS 2 | .DS_Store 3 | ## Lake 4 | .lake/* 5 | .cache/* 6 | ## Python 7 | __pycache__ 8 | venv 9 | ## Blueprint 10 | blueprint/web/ 11 | blueprint/src/chapter/auto 12 | blueprint/lean_decls 13 | blueprint/print/ 14 | ## Docs 15 | docs/_includes/sorries.md 16 | ## TeX 17 | *.paux 18 | *.aux 19 | *.lof 20 | *.log 21 | *.lot 22 | *.fls 23 | *.out 24 | *.toc 25 | *.fmt 26 | *.fot 27 | *.cb 28 | *.cb2 29 | .*.lb 30 | *.bbl 31 | *.bcf 32 | *.blg 33 | *-blx.aux 34 | *-blx.bib 35 | *.run.xml 36 | *.fdb_latexmk 37 | *.synctex 38 | *.synctex(busy) 39 | *.synctex.gz 40 | *.synctex.gz(busy) 41 | *.pdfsync 42 | *.json 43 | *.auctex-auto 44 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.insertSpaces": true, 3 | "editor.tabSize": 2, 4 | "editor.rulers" : [100], 5 | "files.encoding": "utf8", 6 | "files.eol": "\n", 7 | "files.insertFinalNewline": true, 8 | "files.trimFinalNewlines": true, 9 | "files.trimTrailingWhitespace": true 10 | } 11 | -------------------------------------------------------------------------------- /GroupoidModel.lean: -------------------------------------------------------------------------------- 1 | -- This module serves as the root of the `GroupoidModelInLean4` library. 2 | -- Import modules here that should be built as part of the library. 3 | import GroupoidModel.Russell_PER_MS.UHom 4 | import GroupoidModel.Russell_PER_MS.Interpretation 5 | import GroupoidModel.Groupoids.NaturalModelBase 6 | import GroupoidModel.Groupoids.Sigma 7 | import GroupoidModel.Groupoids.Pi 8 | 9 | /- There should be at least three separate files here for three separate developments: 10 | 1. the basic development of the category Grpd of groupoids 11 | 2. the intermediate natural model of HoTT which is constructed out of Gpds 12 | 3. the metaprogram level HoTT 0 for interacting with the model 13 | -/ 14 | 15 | /- 16 | # 1. The category Grpd of small groupoids 17 | We will need at least the following: 18 | - fibrations of groupoids 19 | - set-valued functors on groupoids (presheaves) 20 | - the Grothendieck construction relating the previous two 21 | - Σ- and Π-types for discrete fibrations 22 | - path groupoids 23 | - the universe of (small) discrete groupoids 24 | - polynomial functors of groupoids 25 | - maybe some W-types 26 | -/ 27 | 28 | /- 29 | # 2. The natural model of HoTT to be interpreted in Grpd 30 | We will need at least the following: 31 | - category Ctx of all small groupoids 32 | - the presheaf category 𝓔 = Psh(Ctx) in which the model lives 33 | - the presheaf Type : Ctxᵒᵖ → Set of types in context 34 | - the presheaf Term : Ctxᵒᵖ → Set of terms in context 35 | - the typing natural transformation t : Term ⟶ Type 36 | - the proof that t is (re)presentable 37 | - the polynomial endofunctor Pₜ : 𝓔 ⥤ 𝓔 38 | - the type-formers Σ, Π, Id as operations on polynomials 39 | - the universe Set of (small) discrete groupoids, 40 | along with its discrete (op-)fibration Set* ⟶ Set 41 | It might also be useful to have: 42 | - the proof that presentable natural transformations are tiny maps 43 | - the proof that Pₜ is therefore cocontinuous, since t is tiny 44 | -/ 45 | 46 | /- 47 | # 3. HoTT in Lean 48 | An interface for the groupoid model in Lean. 49 | It would be nice if the user could: 50 | - interact with types, terms, and type families rather than 51 | groupoids, homomorphisms, and fibrations 52 | - have the usual Lean rules for the Σ- and Π-types 53 | - have path-induction for the general Id-types 54 | - define the sets as the 0-types 55 | - use Lean's normal infrastructure like rewriting, tactics, mathlib, etc. 56 | for equality on sets. 57 | -/ 58 | 59 | /- 60 | # Targets 61 | Here are some things that should be doable in the setting of "HoTT 0", 62 | i.e. HoTT with a univalent universe of 0-types: 63 | - HoTT Book real numbers and cumulative hierarchy, 64 | - univalent set theory, 65 | - Lawvere's objective number theory, 66 | - structure identity principle for general algebraic structures, 67 | - propositional truncation ||A|| , 68 | - set-truncation ||X||₀ = π₀(X) , 69 | - groupoid quotients, 70 | - Eilenberg-MacLane spaces K(G,1), and some basic cohomology, 71 | - classifying spaces BG, and the theory of covering spaces, 72 | - calculation of π₁(S¹) = Z using univalence and circle induction, 73 | - Joyal’s combinatorial species, 74 | - Egbert’s univalent combinatorics, 75 | - Rezk completion of a small category, 76 | - univalent category theory: equivalences, etc. 77 | -/ 78 | -------------------------------------------------------------------------------- /GroupoidModel/ForMathlib/CategoryTheory/Functor/Iso.lean: -------------------------------------------------------------------------------- 1 | import GroupoidModel.ForMathlib 2 | 3 | 4 | namespace CategoryTheory.Functor 5 | 6 | structure Iso (C D : Type*) [Category C] [Category D] where 7 | hom : C ⥤ D 8 | inv : D ⥤ C 9 | hom_inv_id : hom ⋙ inv = 𝟭 _ := by aesop_cat 10 | inv_hom_id : inv ⋙ hom = 𝟭 _ := by aesop_cat 11 | 12 | /-- Notation for an isomorphism in a category. -/ 13 | infixr:10 " ≅≅ " => Iso -- type as \cong or \iso 14 | 15 | variable {X Y Z : Type*} [Category X] [Category Y] [Category Z] 16 | 17 | namespace Iso 18 | 19 | @[simp] lemma hom_inv_id' (I : X ≅≅ Y) : I.hom ⋙ I.inv = 𝟭 _ := I.hom_inv_id 20 | 21 | @[simp] lemma inv_hom_id' (I : X ≅≅ Y) : I.inv ⋙ I.hom = 𝟭 _ := I.inv_hom_id 22 | 23 | @[ext] 24 | theorem ext ⦃α β : X ≅≅ Y⦄ (w : α.hom = β.hom) : α = β := 25 | suffices α.inv = β.inv by 26 | cases α 27 | cases β 28 | cases w 29 | cases this 30 | rfl 31 | calc 32 | α.inv = α.inv ⋙ β.hom ⋙ β.inv := by rw [Iso.hom_inv_id, Functor.comp_id] 33 | _ = (α.inv ⋙ α.hom) ⋙ β.inv := by rw [Functor.assoc, ← w] 34 | _ = β.inv := by rw [Iso.inv_hom_id, Functor.id_comp] 35 | 36 | theorem ext_inv ⦃α β : X ≅≅ Y⦄ (w : α.inv = β.inv) : α = β := 37 | suffices α.hom = β.hom by 38 | cases α 39 | cases β 40 | cases w 41 | cases this 42 | rfl 43 | calc 44 | α.hom = α.hom ⋙ β.inv ⋙ β.hom := by rw [inv_hom_id', Functor.comp_id] 45 | _ = (α.hom ⋙ α.inv) ⋙ β.hom := by rw [Functor.assoc, ← w] 46 | _ = β.hom := by rw [hom_inv_id, Functor.id_comp] 47 | 48 | /-- Inverse isomorphism. -/ 49 | @[symm] 50 | def symm (I : X ≅≅ Y) : Y ≅≅ X where 51 | hom := I.inv 52 | inv := I.hom 53 | hom_inv_id := I.inv_hom_id 54 | inv_hom_id := I.hom_inv_id 55 | 56 | @[simp] 57 | theorem symm_hom (α : X ≅≅ Y) : α.symm.hom = α.inv := 58 | rfl 59 | 60 | @[simp] 61 | theorem symm_inv (α : X ≅≅ Y) : α.symm.inv = α.hom := 62 | rfl 63 | 64 | @[simp] 65 | theorem symm_mk (hom : X ⥤ Y) (inv : Y ⥤ X) (hom_inv_id) (inv_hom_id) : 66 | Iso.symm { hom, inv, hom_inv_id := hom_inv_id, inv_hom_id := inv_hom_id } = 67 | { hom := inv, inv := hom, hom_inv_id := inv_hom_id, inv_hom_id := hom_inv_id } := 68 | rfl 69 | 70 | @[simp] 71 | theorem symm_symm_eq (α : X ≅≅ Y) : α.symm.symm = α := rfl 72 | 73 | theorem symm_bijective : Function.Bijective (symm : (X ≅≅ Y) → _) := 74 | Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm_eq, symm_symm_eq⟩ 75 | 76 | @[simp] 77 | theorem symm_eq_iff {α β : X ≅≅ Y} : α.symm = β.symm ↔ α = β := 78 | symm_bijective.injective.eq_iff 79 | 80 | variable (X) (Y) in 81 | theorem nonempty_iso_symm : Nonempty (X ≅≅ Y) ↔ Nonempty (Y ≅≅ X) := 82 | ⟨fun h => ⟨h.some.symm⟩, fun h => ⟨h.some.symm⟩⟩ 83 | 84 | variable (X) in 85 | /-- Identity isomorphism. -/ 86 | @[refl, simps] 87 | def refl : X ≅≅ X where 88 | hom := Functor.id X 89 | inv := Functor.id X 90 | 91 | instance : Inhabited (X ≅≅ X) := ⟨Iso.refl X⟩ 92 | 93 | variable (X) in 94 | theorem nonempty_iso_refl : Nonempty (X ≅≅ X) := ⟨default⟩ 95 | 96 | variable (X) in 97 | @[simp] 98 | theorem refl_symm : (Iso.refl X).symm = Iso.refl X := rfl 99 | 100 | /-- Composition of two isomorphisms -/ 101 | @[simps] 102 | def trans (α : X ≅≅ Y) (β : Y ≅≅ Z) : X ≅≅ Z where 103 | hom := α.hom ⋙ β.hom 104 | inv := β.inv ⋙ α.inv 105 | hom_inv_id := by 106 | calc (α.hom ⋙ β.hom) ⋙ β.inv ⋙ α.inv = α.hom ⋙ (β.hom ⋙ β.inv) ⋙ α.inv := by rw! [Functor.assoc] 107 | _ = α.hom ⋙ 𝟭 _ ⋙ α.inv := by rw [β.hom_inv_id] 108 | _ = α.hom ⋙ α.inv := by rw [Functor.id_comp] 109 | _ = 𝟭 _ := by rw [α.hom_inv_id'] 110 | inv_hom_id := by 111 | calc (β.inv ⋙ α.inv) ⋙ α.hom ⋙ β.hom = β.inv ⋙ (α.inv ⋙ α.hom) ⋙ β.hom := by rw! [Functor.assoc] 112 | _ = β.inv ⋙ 𝟭 _ ⋙ β.hom := by rw [α.inv_hom_id] 113 | _ = β.inv ⋙ β.hom := by rw [Functor.id_comp] 114 | _ = 𝟭 _ := by rw [β.inv_hom_id'] 115 | 116 | /-- Notation for composition of isomorphisms. -/ 117 | infixr:80 " ≪⋙ " => Iso.trans -- type as `\ll \ggg`. 118 | 119 | @[simp] 120 | theorem trans_mk (hom : X ⥤ Y) (inv : Y ⥤ X) (hom_inv_id) (inv_hom_id) 121 | (hom' : Y ⥤ Z) (inv' : Z ⥤ Y) (hom_inv_id') (inv_hom_id') (hom_inv_id'') (inv_hom_id'') : 122 | Iso.trans ⟨hom, inv, hom_inv_id, inv_hom_id⟩ ⟨hom', inv', hom_inv_id', inv_hom_id'⟩ = 123 | ⟨hom ⋙ hom', inv' ⋙ inv, hom_inv_id'', inv_hom_id''⟩ := 124 | rfl 125 | 126 | @[simp] 127 | theorem trans_symm (α : X ≅≅ Y) (β : Y ≅≅ Z) : (α ≪⋙ β).symm = β.symm ≪⋙ α.symm := 128 | rfl 129 | 130 | variable {Z' : Type*} [Category Z'] in 131 | @[simp] 132 | theorem trans_assoc (α : X ≅≅ Y) (β : Y ≅≅ Z) (γ : Z ≅≅ Z') : 133 | (α ≪⋙ β) ≪⋙ γ = α ≪⋙ β ≪⋙ γ := by 134 | ext; simp only [trans_hom, Functor.assoc] 135 | 136 | @[simp] 137 | theorem refl_trans (α : X ≅≅ Y) : Iso.refl X ≪⋙ α = α := by ext; apply Functor.id_comp 138 | 139 | @[simp] 140 | theorem trans_refl (α : X ≅≅ Y) : α ≪⋙ Iso.refl Y = α := by ext; apply Functor.comp_id 141 | 142 | @[simp] 143 | theorem symm_self_id (α : X ≅≅ Y) : α.symm ≪⋙ α = Iso.refl Y := 144 | ext α.inv_hom_id 145 | 146 | @[simp] 147 | theorem self_symm_id (α : X ≅≅ Y) : α ≪⋙ α.symm = Iso.refl X := 148 | ext α.hom_inv_id 149 | 150 | @[simp] 151 | theorem symm_self_id_assoc (α : X ≅≅ Y) (β : Y ≅≅ Z) : α.symm ≪⋙ α ≪⋙ β = β := by 152 | rw [← trans_assoc, symm_self_id, refl_trans] 153 | 154 | @[simp] 155 | theorem self_symm_id_assoc (α : X ≅≅ Y) (β : X ≅≅ Z) : α ≪⋙ α.symm ≪⋙ β = β := by 156 | rw [← trans_assoc, self_symm_id, refl_trans] 157 | 158 | theorem inv_comp_eq (α : X ≅≅ Y) {f : X ⥤ Z} {g : Y ⥤ Z} : α.inv ⋙ f = g ↔ f = α.hom ⋙ g := 159 | ⟨fun H => by simp [H.symm, ← Functor.assoc, Functor.id_comp], 160 | fun H => by simp [H, ← Functor.assoc, Functor.id_comp]⟩ 161 | 162 | theorem eq_inv_comp (α : X ≅≅ Y) {f : X ⥤ Z} {g : Y ⥤ Z} : g = α.inv ⋙ f ↔ α.hom ⋙ g = f := 163 | (inv_comp_eq α.symm).symm 164 | 165 | theorem comp_inv_eq (α : X ≅≅ Y) {f : Z ⥤ Y} {g : Z ⥤ X} : f ⋙ α.inv = g ↔ f = g ⋙ α.hom := 166 | ⟨fun H => by simp [H.symm, Functor.assoc, Functor.comp_id], 167 | fun H => by simp [H, Functor.assoc, Functor.comp_id]⟩ 168 | 169 | theorem eq_comp_inv (α : X ≅≅ Y) {f : Z ⥤ Y} {g : Z ⥤ X} : g = f ⋙ α.inv ↔ g ⋙ α.hom = f := 170 | (comp_inv_eq α.symm).symm 171 | 172 | theorem inv_eq_inv (f g : X ≅≅ Y) : f.inv = g.inv ↔ f.hom = g.hom := 173 | ⟨fun h => by rw [ext_inv h], fun h => by rw [ext h]⟩ 174 | 175 | theorem hom_comp_eq_id (α : X ≅≅ Y) {f : Y ⥤ X} : α.hom ⋙ f = Functor.id X ↔ f = α.inv := by 176 | rw [← eq_inv_comp, Functor.comp_id] 177 | 178 | theorem comp_hom_eq_id (α : X ≅≅ Y) {f : Y ⥤ X} : f ⋙ α.hom = Functor.id Y ↔ f = α.inv := by 179 | rw [← eq_comp_inv, Functor.id_comp] 180 | 181 | theorem inv_comp_eq_id (α : X ≅≅ Y) {f : X ⥤ Y} : α.inv ⋙ f = Functor.id Y ↔ f = α.hom := 182 | hom_comp_eq_id α.symm 183 | 184 | theorem comp_inv_eq_id (α : X ≅≅ Y) {f : X ⥤ Y} : f ⋙ α.inv = Functor.id X ↔ f = α.hom := 185 | comp_hom_eq_id α.symm 186 | 187 | theorem hom_eq_inv (α : X ≅≅ Y) (β : Y ≅≅ X) : α.hom = β.inv ↔ β.hom = α.inv := by 188 | rw [← symm_inv, inv_eq_inv α.symm β, eq_comm] 189 | rfl 190 | 191 | /-- The bijection `(Z ⥤ X) ≃ (Z ⥤ Y)` induced by `α : X ≅≅ Y`. -/ 192 | @[simps] 193 | def homToEquiv (α : X ≅≅ Y) : (Z ⥤ X) ≃ (Z ⥤ Y) where 194 | toFun f := f ⋙ α.hom 195 | invFun g := g ⋙ α.inv 196 | left_inv := by 197 | refine Function.leftInverse_iff_comp.mpr ?_ 198 | ext g 199 | rw [Function.comp_apply, id_eq, Functor.assoc, hom_inv_id, Functor.comp_id] 200 | right_inv := by 201 | refine Function.rightInverse_iff_comp.mpr ?_ 202 | ext g 203 | rw [Function.comp_apply, id_eq, Functor.assoc, inv_hom_id, Functor.comp_id] 204 | 205 | /-- The bijection `(X ⥤ Z) ≃ (Y ⥤ Z)` induced by `α : X ≅≅ Y`. -/ 206 | @[simps] 207 | def homFromEquiv (α : X ≅≅ Y) : (X ⥤ Z) ≃ (Y ⥤ Z) where 208 | toFun f := α.inv ⋙ f 209 | invFun g := α.hom ⋙ g 210 | left_inv := by 211 | refine Function.leftInverse_iff_comp.mpr ?_ 212 | ext g 213 | rw [Function.comp_apply, id_eq, ← Functor.assoc, hom_inv_id, Functor.id_comp] 214 | right_inv := by 215 | refine Function.rightInverse_iff_comp.mpr ?_ 216 | ext g 217 | rw [Function.comp_apply, id_eq, ← Functor.assoc, inv_hom_id, Functor.id_comp] 218 | 219 | @[aesop apply safe (rule_sets := [CategoryTheory])] 220 | theorem inv_ext {f : X ≅≅ Y} {g : Y ⥤ X} (hom_inv_id : f.hom ⋙ g = Functor.id X) : f.inv = g := 221 | ((hom_comp_eq_id f).1 hom_inv_id).symm 222 | 223 | @[aesop apply safe (rule_sets := [CategoryTheory])] 224 | theorem inv_ext' {f : X ≅≅ Y} {g : Y ⥤ X} (hom_inv_id : f.hom ⋙ g = Functor.id X) : g = f.inv := 225 | (hom_comp_eq_id f).1 hom_inv_id 226 | 227 | @[simp] 228 | theorem cancel_iso_hom_left (f : X ≅≅ Y) (g g' : Y ⥤ Z) : 229 | f.hom ⋙ g = f.hom ⋙ g' ↔ g = g' := by 230 | constructor 231 | . intro h 232 | calc g = (f.inv ⋙ f.hom) ⋙ g := by rw [f.inv_hom_id, Functor.id_comp] 233 | _ = f.inv ⋙ (f.hom ⋙ g) := by rw [Functor.assoc] 234 | _ = f.inv ⋙ (f.hom ⋙ g') := by rw [h] 235 | _ = (f.inv ⋙ f.hom) ⋙ g' := by rw [Functor.assoc] 236 | _ = g' := by rw [f.inv_hom_id, Functor.id_comp] 237 | . intro h 238 | rw[h] 239 | 240 | 241 | @[simp] 242 | theorem cancel_iso_inv_left (f : Y ≅≅ X) (g g' : Y ⥤ Z) : 243 | f.inv ⋙ g = f.inv ⋙ g' ↔ g = g' := by 244 | constructor 245 | . intro h 246 | calc g = (f.hom ⋙ f.inv) ⋙ g := by rw [f.hom_inv_id, Functor.id_comp] 247 | _ = f.hom ⋙ (f.inv ⋙ g) := by rw [Functor.assoc] 248 | _ = f.hom ⋙ (f.inv ⋙ g') := by rw [h] 249 | _ = (f.hom ⋙ f.inv) ⋙ g' := by rw [Functor.assoc] 250 | _ = g' := by rw [f.hom_inv_id, Functor.id_comp] 251 | . intro h 252 | rw[h] 253 | 254 | @[simp] 255 | theorem cancel_iso_hom_right (f f' : X ⥤ Y) (g : Y ≅≅ Z) : 256 | f ⋙ g.hom = f' ⋙ g.hom ↔ f = f' := by 257 | constructor 258 | . intro h 259 | calc f = f ⋙ (g.hom ⋙ g.inv) := by rw [g.hom_inv_id, Functor.comp_id] 260 | _ = (f ⋙ g.hom) ⋙ g.inv := by rw [Functor.assoc] 261 | _ = (f' ⋙ g.hom) ⋙ g.inv := by rw [h] 262 | _ = f' ⋙ (g.hom ⋙ g.inv) := by rw [Functor.assoc] 263 | _ = f' := by rw [g.hom_inv_id, Functor.comp_id] 264 | . intro h 265 | rw[h] 266 | 267 | @[simp] 268 | theorem cancel_iso_inv_right (f f' : X ⥤ Y) (g : Z ≅≅ Y) : 269 | f ⋙ g.inv = f' ⋙ g.inv ↔ f = f' := by 270 | constructor 271 | . intro h 272 | calc f = f ⋙ (g.inv ⋙ g.hom) := by rw [g.inv_hom_id, Functor.comp_id] 273 | _ = (f ⋙ g.inv) ⋙ g.hom := by rw [Functor.assoc] 274 | _ = (f' ⋙ g.inv) ⋙ g.hom := by rw [h] 275 | _ = f' ⋙ (g.inv ⋙ g.hom) := by rw [Functor.assoc] 276 | _ = f' := by rw [g.inv_hom_id, Functor.comp_id] 277 | . intro h 278 | rw[h] 279 | 280 | variable {W X' : Type*} [Category W] [Category X'] 281 | /- 282 | Unfortunately cancelling an isomorphism from the right of a chain of compositions is awkward. 283 | We would need separate lemmas for each chain length (worse: for each pair of chain lengths). 284 | 285 | We provide two more lemmas, for case of three morphisms, because this actually comes up in practice, 286 | but then stop. 287 | -/ 288 | @[simp] 289 | theorem cancel_iso_hom_right_assoc (f : W ⥤ X) (g : X ⥤ Y) (f' : W ⥤ X') 290 | (g' : X' ⥤ Y) (h : Y ≅≅ Z) : f ⋙ g ⋙ h.hom = f' ⋙ g' ⋙ h.hom ↔ f ⋙ g = f' ⋙ g' := by 291 | constructor 292 | . intro hy 293 | rw [← Functor.assoc, ← Functor.assoc] at hy 294 | exact (cancel_iso_hom_right (f ⋙ g) (f' ⋙ g') h).mp hy 295 | . intro hy 296 | simp only [← Functor.assoc, cancel_iso_hom_right] 297 | exact hy 298 | 299 | @[simp] 300 | theorem cancel_iso_inv_right_assoc (f : W ⥤ X) (g : X ⥤ Y) (f' : W ⥤ X') 301 | (g' : X' ⥤ Y) (h : Z ≅≅ Y) : f ⋙ g ⋙ h.inv = f' ⋙ g' ⋙ h.inv ↔ f ⋙ g = f' ⋙ g' := by 302 | constructor 303 | . intro hy 304 | rw [← Functor.assoc, ← Functor.assoc] at hy 305 | exact (cancel_iso_inv_right (f ⋙ g) (f' ⋙ g') h).mp hy 306 | . intro hy 307 | simp only [← Functor.assoc, cancel_iso_inv_right] 308 | exact hy 309 | 310 | end Iso 311 | 312 | end CategoryTheory.Functor 313 | 314 | namespace CategoryTheory.AsSmall 315 | 316 | variable {C : Type*} [Category C] 317 | 318 | def downIso : AsSmall C ≅≅ C where 319 | hom := AsSmall.down 320 | inv := AsSmall.up 321 | 322 | end CategoryTheory.AsSmall 323 | -------------------------------------------------------------------------------- /GroupoidModel/ForMathlib/CategoryTheory/RepPullbackCone.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.CategoryTheory.Limits.Yoneda 2 | import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction 3 | import Mathlib.CategoryTheory.Limits.Preserves.Finite 4 | import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq 5 | 6 | /-! 7 | This file builds API for showing that a presheaf diagram is a pullback 8 | by its universal property among representable cones. 9 | -/ 10 | 11 | universe u v u₁ v₁ u₂ v₂ 12 | 13 | namespace CategoryTheory 14 | 15 | namespace Limits 16 | 17 | universe u₃ v₃ 18 | variable {J : Type u₁} [Category.{v₁} J] {K : Type u₂} [Category.{v₂} K] 19 | variable {C : Type u₃} [Category.{v₃} C] 20 | 21 | open CategoryTheory 22 | open Functor 23 | 24 | /-- A `c : RepCone F` is: 25 | * an object `c.pt` and 26 | * a natural transformation `c.π : yoneda.obj c.pt ⟶ F` 27 | from the constant `yoneda.obj c.pt` functor to `F`. 28 | -/ 29 | structure RepCone (F : J ⥤ Cᵒᵖ ⥤ Type v₃) where 30 | /-- An object of `C` -/ 31 | pt : C 32 | /-- A natural transformation from the constant functor at `X` to `F` -/ 33 | π : (const J).obj (yoneda.obj pt) ⟶ F 34 | 35 | namespace RepCone 36 | 37 | variable {F : J ⥤ Cᵒᵖ ⥤ Type v₃} 38 | 39 | @[reducible] def cone (s : RepCone F) : Limits.Cone F where 40 | pt := yoneda.obj s.pt 41 | π := s.π 42 | 43 | end RepCone 44 | 45 | variable {F : J ⥤ Cᵒᵖ ⥤ Type v₃} 46 | 47 | structure RepIsLimit (t : Cone F) where 48 | lift : ∀ s : RepCone F, s.cone.pt ⟶ t.pt 49 | fac : ∀ (s : RepCone F) (j : J), 50 | lift s ≫ t.π.app j = (s.cone).π.app j := by aesop_cat 51 | /-- It is the unique such map to do this -/ 52 | uniq : ∀ (s : RepCone F) (m : s.cone.pt ⟶ t.pt) 53 | (_ : ∀ j : J, m ≫ t.π.app j = s.cone.π.app j), m = lift s := by 54 | aesop_cat 55 | 56 | def repConeOfConeMap (s : Cone F) (c : C) (x' : yoneda.obj c ⟶ s.pt) : RepCone F := 57 | { pt := c 58 | π := {app := λ j ↦ x' ≫ s.π.app j}} 59 | 60 | namespace RepIsLimit 61 | 62 | variable {t : Cone F} (P : RepIsLimit t) {s : Cone F} 63 | 64 | def lift' (c : C) (x' : yoneda.obj c ⟶ s.pt) : yoneda.obj c ⟶ t.pt := 65 | P.lift $ repConeOfConeMap s c x' 66 | 67 | @[simp] lemma lift'_naturality {s : Cone F} {c d : C} 68 | (f : c ⟶ d) (x' : yoneda.obj d ⟶ s.pt) : 69 | lift' P c (yoneda.map f ≫ x') = yoneda.map f ≫ lift' P d x' := by 70 | apply Eq.symm 71 | apply P.uniq (repConeOfConeMap s c (yoneda.map f ≫ x')) (yoneda.map f ≫ lift' P d x') 72 | intro j 73 | have h := P.fac (repConeOfConeMap s d x') j 74 | dsimp[repConeOfConeMap] 75 | dsimp[repConeOfConeMap] at h 76 | rw[Category.assoc, Category.assoc, ← h] 77 | rfl 78 | 79 | def lift''_app (s : Cone F) (c : C) : 80 | s.pt.obj (Opposite.op c) → t.pt.obj (Opposite.op c) := 81 | yonedaEquiv ∘ lift' P c ∘ yonedaEquiv.symm 82 | 83 | theorem lift''_app_naturality {c d : C} (f : c ⟶ d) : 84 | s.pt.map (f.op) ≫ lift''_app P s c 85 | = lift''_app P s d ≫ t.pt.map (Opposite.op f) := by 86 | ext x 87 | simp[lift''_app, lift'] 88 | rw[yonedaEquiv_naturality'] 89 | have h := lift'_naturality P f (yonedaEquiv.symm x) 90 | simp[lift'] at h 91 | simp 92 | rw[← h, yonedaEquiv_symm_naturality_left] 93 | 94 | variable (s) 95 | 96 | def lift'' : s.pt ⟶ t.pt := { 97 | app := λ c ↦ lift''_app P s c.unop 98 | naturality := by 99 | intros 100 | apply lift''_app_naturality 101 | } 102 | 103 | theorem fac_ext (j : J) (c : C) (x) : 104 | (lift'' P s ≫ t.π.app j).app (Opposite.op c) x 105 | = (s.π.app j).app (Opposite.op c) x := by 106 | dsimp [lift'',lift', lift''_app, ← yonedaEquiv_comp] 107 | rw [P.fac (repConeOfConeMap s c (yonedaEquiv.symm x)) j] 108 | simp [repConeOfConeMap, yonedaEquiv_comp, Equiv.apply_symm_apply yonedaEquiv x] 109 | 110 | theorem uniq_ext (m : s.pt ⟶ t.pt) 111 | (hm : ∀ (j : J), m ≫ t.π.app j = s.π.app j) (c : C) (x) : 112 | m.app (Opposite.op c) x 113 | = (P.lift'' s).app (Opposite.op c) x := by 114 | let x' := yonedaEquiv.symm x 115 | have hj : (∀ (j : J), (x' ≫ m) ≫ t.π.app j = x' ≫ s.π.app j) := by simp[hm] 116 | have h := P.uniq (repConeOfConeMap s c x') (x' ≫ m) hj 117 | dsimp [lift'', lift''_app, lift'] 118 | rw [← h, yonedaEquiv_comp, Equiv.apply_symm_apply yonedaEquiv x] 119 | 120 | def IsLimit {t : Cone F} (P : RepIsLimit t) : IsLimit t where 121 | lift := lift'' P 122 | fac := λ s j ↦ by 123 | ext c x 124 | apply fac_ext 125 | uniq := λ s m hm ↦ by 126 | ext c x 127 | apply uniq_ext P s m hm 128 | 129 | end RepIsLimit 130 | 131 | abbrev RepPullbackCone {X Y Z : Cᵒᵖ ⥤ Type v₃} (f : X ⟶ Z) (g : Y ⟶ Z) := 132 | RepCone (cospan f g) 133 | 134 | namespace RepPullbackCone 135 | 136 | variable {W X Y Z : Cᵒᵖ ⥤ Type v₃} 137 | {f : X ⟶ Z} {g : Y ⟶ Z} (t : RepPullbackCone f g) 138 | 139 | def mk (W : C) (fst : yoneda.obj W ⟶ X) (snd : yoneda.obj W ⟶ Y) 140 | (h : fst ≫ f = snd ≫ g) : 141 | RepPullbackCone f g := 142 | repConeOfConeMap (PullbackCone.mk fst snd h) W (𝟙 _) 143 | 144 | def pullbackCone : PullbackCone f g where 145 | pt := yoneda.obj t.pt 146 | π := t.π 147 | 148 | /-- The first projection of a pullback cone. -/ 149 | abbrev fst : yoneda.obj t.pt ⟶ X := 150 | t.pullbackCone.fst 151 | 152 | /-- The second projection of a pullback cone. -/ 153 | abbrev snd : yoneda.obj t.pt ⟶ Y := 154 | t.pullbackCone.snd 155 | 156 | @[reassoc] 157 | theorem condition : t.fst ≫ f = t.snd ≫ g := 158 | t.pullbackCone.condition 159 | 160 | open WalkingSpan.Hom WalkingCospan.Hom WidePullbackShape.Hom WidePushoutShape.Hom Limits.PullbackCone 161 | 162 | def repIsLimitAux (t : PullbackCone f g) (lift : ∀ s : RepPullbackCone f g, yoneda.obj s.pt ⟶ t.pt) 163 | (fac_left : ∀ s : RepPullbackCone f g, lift s ≫ t.fst = s.fst) 164 | (fac_right : ∀ s : RepPullbackCone f g, lift s ≫ t.snd = s.snd) 165 | (uniq : ∀ (s : RepPullbackCone f g) (m : yoneda.obj s.pt ⟶ t.pt) 166 | (_ : ∀ j : WalkingCospan, m ≫ t.π.app j = s.π.app j), m = lift s) : RepIsLimit t := 167 | { lift 168 | fac := fun s j => Option.casesOn j (by 169 | rw [← s.cone.w inl, ← t.w inl, ← Category.assoc] 170 | congr 171 | exact fac_left s) 172 | fun j' => WalkingPair.casesOn j' (fac_left s) (fac_right s) 173 | uniq := uniq } 174 | 175 | /-- To show that a `PullbackCone` in a presheaf category constructed using `PullbackCone.mk` is a limit cone, 176 | it suffices to show its universal property among representable cones. 177 | -/ 178 | def RepIsLimit.mk {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g) 179 | (lift : ∀ s : RepPullbackCone f g, yoneda.obj s.pt ⟶ W) 180 | (fac_left : ∀ s : RepPullbackCone f g, lift s ≫ fst = s.fst) 181 | (fac_right : ∀ s : RepPullbackCone f g, lift s ≫ snd = s.snd) 182 | (uniq : 183 | ∀ (s : RepPullbackCone f g) (m : yoneda.obj s.pt ⟶ W) 184 | (_ : m ≫ fst = s.fst) (_ : m ≫ snd = s.snd), 185 | m = lift s) : 186 | IsLimit (PullbackCone.mk fst snd eq) := 187 | RepIsLimit.IsLimit $ 188 | repIsLimitAux _ lift fac_left fac_right fun s m w => 189 | uniq s m (w WalkingCospan.left) (w WalkingCospan.right) 190 | 191 | theorem is_pullback {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g) 192 | (lift : ∀ s : RepPullbackCone f g, yoneda.obj s.pt ⟶ W) 193 | (fac_left : ∀ s : RepPullbackCone f g, lift s ≫ fst = s.fst) 194 | (fac_right : ∀ s : RepPullbackCone f g, lift s ≫ snd = s.snd) 195 | (uniq : 196 | ∀ (s : RepPullbackCone f g) (m : yoneda.obj s.pt ⟶ W) 197 | (_ : m ≫ fst = s.fst) (_ : m ≫ snd = s.snd), 198 | m = lift s) : 199 | IsPullback fst snd f g := 200 | IsPullback.of_isLimit' ⟨ eq ⟩ (RepIsLimit.mk eq lift fac_left fac_right uniq) 201 | 202 | end RepPullbackCone 203 | 204 | 205 | end Limits 206 | -------------------------------------------------------------------------------- /GroupoidModel/ForMathlib/CategoryTheory/Yoneda.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.CategoryTheory.Yoneda 2 | 3 | /-! Notation for the Yoneda embedding. -/ 4 | 5 | namespace CategoryTheory 6 | 7 | notation:max "y(" Γ ")" => yoneda.obj Γ 8 | notation:max "ym(" f ")" => yoneda.map f 9 | 10 | open Lean PrettyPrinter in 11 | @[app_unexpander Prefunctor.obj] 12 | def Prefunctor.obj.unexpand : Unexpander 13 | | `($_ $F $X) => 14 | if let .node _ _ #[.ident _ _ `yoneda _, _, .ident _ _ `toPrefunctor _] := F.raw then 15 | `(y($X)) 16 | else 17 | throw () 18 | | _ => throw () 19 | 20 | open Lean PrettyPrinter in 21 | @[app_unexpander Prefunctor.map] 22 | def Prefunctor.map.unexpand : Unexpander 23 | | `($_ $F $X) => 24 | if let .node _ _ #[.ident _ _ `yoneda _, _, .ident _ _ `toPrefunctor _] := F.raw then 25 | `(ym($X)) 26 | else 27 | throw () 28 | | _ => throw () 29 | 30 | end CategoryTheory 31 | -------------------------------------------------------------------------------- /GroupoidModel/ForMathlib/Tactic/CategoryTheory/FunctorMap.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2022 Kim Morrison. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Kim Morrison, Wojciech Nawrocki 5 | -/ 6 | import Mathlib.CategoryTheory.Functor.Basic 7 | import Mathlib.Lean.Meta.Simp 8 | import Mathlib.Tactic.Simps.Basic 9 | import Mathlib.Util.AddRelatedDecl 10 | import Mathlib.Tactic.CategoryTheory.Reassoc 11 | 12 | /-! 13 | # The `functor_map` attribute 14 | 15 | Adding `@[functor_map]` to a lemma named `fact` of shape `∀ .., f ≫ g = i ≫ j`, 16 | where `f g i j` are morphisms in some category `C`, 17 | will create a new lemma named `fact_functor_map` of shape 18 | `∀ .. {D : Type} [Category D] (F : C ⥤ D), F.map f ≫ F.map g = F.map i ≫ F.map j`, 19 | with the conclusion simplified using the axioms for a category 20 | (`Category.comp_id`, `Category.id_comp`, and `Category.assoc`). 21 | 22 | This is useful for generating lemmas which the simplifier can use even on expressions 23 | that appear under a functor. 24 | 25 | There is also a term elaborator `functor_map_of% t` for use within proofs. 26 | -/ 27 | 28 | open Lean Meta Elab Tactic 29 | open Mathlib.Tactic 30 | 31 | namespace CategoryTheory 32 | 33 | universe v₁ u₁ v₂ u₂ 34 | variable {C : Type u₁} [Category.{v₁} C] 35 | 36 | private theorem eq_functor_map {X Y : C} {f g : X ⟶ Y} (w : f = g) : 37 | ∀ {D : Type u₂} [Category.{v₂} D] (F : C ⥤ D), F.map f = F.map g := by 38 | intros; rw [w] 39 | 40 | /-- Like `categorySimp` but also includes `Functor.map_comp`, `Functor.map_id`. -/ 41 | def categorySimp' (e : Expr) : MetaM Simp.Result := 42 | simpOnlyNames [``Category.comp_id, ``Category.id_comp, ``Category.assoc, 43 | ``Functor.id_obj, ``Functor.id_map, ``Functor.comp_obj, ``Functor.comp_map, 44 | ``Functor.map_id, ``Functor.map_comp] e 45 | (config := { decide := false }) 46 | 47 | def functorMapExpr (e : Expr) (lvl_params : Bool) : MetaM (Expr × List Level) := do 48 | let [v₂, u₂] ← 49 | if lvl_params then 50 | let v₂ := mkLevelParam (← mkFreshLMVarId).name 51 | let u₂ := mkLevelParam (← mkFreshLMVarId).name 52 | pure [v₂, u₂] 53 | else mkFreshLevelMVars 2 | panic! "internal error" 54 | let e ← mapForallTelescope (forallTerm := e) fun e => do 55 | let eTp ← inferType e 56 | let some (hom, _, _) := eTp.eq? | throwError "expected an equality, got{indentD eTp}" 57 | if !hom.isAppOf ``Quiver.Hom then 58 | throwError "expected an equality of morphisms, got{indentD eTp}" 59 | let [.succ v₁, u₁] := hom.getAppFn.constLevels! | 60 | throwError "unexpected universe levels in{indentD hom.getAppFn}" 61 | let e' ← mkAppM' (.const ``eq_functor_map [v₁, u₁, v₂, u₂]) #[e] 62 | simpType categorySimp' e' 63 | return (e, [v₂, u₂]) 64 | 65 | syntax (name := functor_map) "functor_map" (" (" &"attr" ":=" Parser.Term.attrInstance,* ")")? : attr 66 | 67 | initialize registerBuiltinAttribute { 68 | name := `functor_map 69 | descr := "" 70 | applicationTime := .afterCompilation 71 | add := fun src ref kind => match ref with 72 | | `(attr| functor_map $[(attr := $stx?,*)]?) => MetaM.run' do 73 | if (kind != AttributeKind.global) then 74 | throwError "`functor_map` can only be used as a global attribute" 75 | addRelatedDecl src "_functor_map" ref stx? fun type value levels => do 76 | let (e, levels') ← functorMapExpr (← mkExpectedTypeHint value type) true 77 | pure (e, levels ++ levels'.map fun | .param n => n | _ => panic! "") 78 | | _ => throwUnsupportedSyntax } 79 | 80 | open Term in 81 | elab "functor_map_of% " t:term : term => do 82 | Prod.fst <$> functorMapExpr (← elabTerm t none) false 83 | 84 | end CategoryTheory 85 | -------------------------------------------------------------------------------- /GroupoidModel/ForPoly.lean: -------------------------------------------------------------------------------- 1 | import Poly.UvPoly.Basic 2 | import GroupoidModel.ForMathlib 3 | 4 | open CategoryTheory Limits 5 | 6 | noncomputable section 7 | 8 | namespace CategoryTheory.UvPoly 9 | 10 | variable {𝒞} [Category 𝒞] [HasTerminal 𝒞] [HasPullbacks 𝒞] 11 | 12 | variable {E B : 𝒞} (P : UvPoly E B) (A : 𝒞) 13 | 14 | def compDomEquiv {Γ E B D A : 𝒞} {P : UvPoly E B} {Q : UvPoly D A} : 15 | (Γ ⟶ compDom P Q) ≃ 16 | (AB : Γ ⟶ P.functor.obj A) × (α : Γ ⟶ E) × (β : Γ ⟶ D) ×' 17 | (w : AB ≫ P.fstProj A = α ≫ P.p) ×' 18 | (β ≫ Q.p = pullback.lift AB α w ≫ (PartialProduct.fan P A).snd) := 19 | calc 20 | _ ≃ (β : Γ ⟶ D) × (αB : Γ ⟶ pullback (PartialProduct.fan P A).fst P.p) ×' 21 | β ≫ Q.p = αB ≫ (PartialProduct.fan P A).snd := 22 | pullbackHomEquiv 23 | _ ≃ (β : Γ ⟶ D) × (αB : (AB : Γ ⟶ P.functor.obj A) × (α : Γ ⟶ E) ×' 24 | AB ≫ P.fstProj A = α ≫ P.p) ×' 25 | β ≫ Q.p = pullback.lift αB.1 αB.2.1 αB.2.2 ≫ (PartialProduct.fan P A).snd := 26 | Equiv.sigmaCongrRight (fun β => calc 27 | _ ≃ (αB : (AB : Γ ⟶ P.functor.obj A) × (α : Γ ⟶ E) ×' (AB ≫ P.fstProj A = α ≫ P.p)) ×' 28 | (β ≫ Q.p = pullback.lift αB.1 αB.2.1 αB.2.2 ≫ (PartialProduct.fan P A).snd) := 29 | Equiv.psigmaCongrProp pullbackHomEquiv (fun αB => by 30 | apply Eq.congr_right 31 | congr 1 32 | apply pullback.hom_ext 33 | · simp [pullbackHomEquiv] 34 | · simp [pullbackHomEquiv])) 35 | _ ≃ _ := { 36 | -- TODO should be general tactic for this? 37 | toFun x := ⟨ x.2.1.1, x.2.1.2.1 , x.1 , x.2.1.2.2, x.2.2 ⟩ 38 | invFun x := ⟨ x.2.2.1 , ⟨ x.1, x.2.1 , x.2.2.2.1 ⟩ , x.2.2.2.2 ⟩ 39 | left_inv _ := rfl 40 | right_inv _ := rfl } 41 | 42 | @[simp] theorem compDomEquiv_symm_comp_p {Γ E B D A : 𝒞} {P : UvPoly E B} 43 | {Q : UvPoly D A} (AB : Γ ⟶ P.functor.obj A) (α : Γ ⟶ E) 44 | (β : Γ ⟶ D) (w : AB ≫ P.fstProj A = α ≫ P.p) 45 | (h : β ≫ Q.p = pullback.lift AB α w ≫ (PartialProduct.fan P A).snd) : 46 | compDomEquiv.symm ⟨AB,α,β,w,h⟩ ≫ (P.comp Q).p = AB := by 47 | simp [compDomEquiv, Equiv.psigmaCongrProp, Equiv.sigmaCongrRight_symm, 48 | Equiv.coe_fn_symm_mk, pullbackHomEquiv] 49 | 50 | end CategoryTheory.UvPoly 51 | -------------------------------------------------------------------------------- /GroupoidModel/Grothendieck/Groupoidal/IsPullback.lean: -------------------------------------------------------------------------------- 1 | import GroupoidModel.Pointed.IsPullback 2 | import GroupoidModel.Grothendieck.Groupoidal.Basic 3 | 4 | import SEq.Tactic.DepRewrite 5 | 6 | /-! 7 | # The Grothendieck construction as a pullback of categories 8 | 9 | * `CategoryTheory.Grothendieck.Groupoidal.isPullback` 10 | shows that `Grothendieck.forget A` is classified by `PGrpd.forgetToGrpd` 11 | as the (meta-theoretic) pullback of `A`. 12 | This uses the proof of the similar fact 13 | `CategoryTheory.Grothendieck.isPullback`, 14 | as well as the proof `CategoryTheory.isPullback_forgetToGrpd_forgetToCat` 15 | that `PGrpd` is the pullback of `PCat` 16 | 17 | ∫(A) ------- toPGrpd ---------> PGrpd 18 | | | 19 | | | 20 | forget PGrpd.forgetToGrpd 21 | | | 22 | v v 23 | Γ--------------A---------------> Grpd 24 | 25 | -/ 26 | 27 | universe v u v₁ u₁ v₂ u₂ v₃ u₃ 28 | 29 | namespace CategoryTheory 30 | 31 | namespace Grothendieck 32 | 33 | namespace Groupoidal 34 | 35 | section 36 | 37 | variable {Γ : Type u} [Category.{v} Γ] (A : Γ ⥤ Grpd.{v₁,u₁}) 38 | 39 | -- TODO maybe revert this to the direct definition `toPGrpd'` 40 | -- so that the style is consistent with `sec` and `ι` 41 | /-- 42 | `toPGrpd` is the lift induced by the pullback property of `PGrpd` 43 | ∫(A) ------- toPGrpd ---------> PGrpd --------> PCat 44 | | | | 45 | | | | 46 | forget PGrpd.forgetToGrpd PCat.forgetToCat 47 | | | | 48 | | | | 49 | v v v 50 | Γ--------------A---------------> Grpd --------> Cat 51 | -/ 52 | def toPGrpd : ∫(A) ⥤ PGrpd.{v₁,u₁} := 53 | PGrpd.functorTo (forget ⋙ A) (fun x => x.fiber) (fun f => f.fiber) 54 | (by simp) (by simp [forget_map, Hom.base]) 55 | 56 | @[simp] theorem toPGrpd_obj_base (x) : 57 | ((toPGrpd A).obj x).base = A.obj x.base := by 58 | rfl 59 | 60 | @[simp] theorem toPGrpd_obj_fiber (x) : 61 | ((toPGrpd A).obj x).fiber = x.fiber := by 62 | rfl 63 | 64 | @[simp] theorem toPGrpd_map_base {x y} (f : x ⟶ y) : 65 | ((toPGrpd A).map f).base = A.map f.base := by 66 | rfl 67 | 68 | @[simp] theorem toPGrpd_map_fiber {x y} (f : x ⟶ y) : 69 | ((toPGrpd A).map f).fiber = f.fiber := by 70 | rfl 71 | 72 | theorem toPGrpd_forgetToGrpd : toPGrpd A ⋙ PGrpd.forgetToGrpd = forget ⋙ A := 73 | rfl 74 | 75 | theorem toPGrpd_forgetToPCat : toPGrpd A ⋙ PGrpd.forgetToPCat = (Grothendieck.toPCat _) := 76 | rfl 77 | 78 | /-- 79 | We also provide a definition of `toPGrpd` as the universal lift 80 | of the pullback `PGrpd`. 81 | -/ 82 | def toPGrpd' : ∫(A) ⥤ PGrpd.{v₁,u₁} := 83 | PGrpd.isPullback.lift (Grothendieck.toPCat (A ⋙ Grpd.forgetToCat)) (forget ⋙ A) (by 84 | rw [toPCat_forgetToCat] 85 | rfl) 86 | 87 | /-- 88 | The left square is a pullback since the right square and outer square are. 89 | ∫(A) ------- toPGrpd ---------> PGrpd --------> PCat 90 | | | | 91 | | | | 92 | forget PGrpd.forgetToGrpd PCat.forgetToCat 93 | | | | 94 | | | | 95 | v v v 96 | Γ--------------A---------------> Grpd --------> Cat 97 | -/ 98 | def isPullback' : Functor.IsPullback (toPGrpd' A) forget PGrpd.forgetToGrpd A := 99 | Functor.IsPullback.Paste.ofRight' 100 | (Grothendieck.toPCat_forgetToCat _) 101 | (Grothendieck.isPullback _) 102 | PGrpd.forgetToPCat_forgetToCat 103 | PGrpd.isPullback 104 | 105 | theorem toPGrpd_eq_toPGrpd' : toPGrpd A = toPGrpd' A := by 106 | apply PGrpd.isPullback.lift_uniq 107 | · rfl 108 | · rfl 109 | 110 | def isPullback : Functor.IsPullback (toPGrpd A) forget PGrpd.forgetToGrpd A := 111 | cast (by rw [toPGrpd_eq_toPGrpd']) (isPullback' A) 112 | 113 | end 114 | 115 | section 116 | 117 | variable {Γ : Type u} [Category.{v} Γ] 118 | variable (A : Γ ⥤ Grpd.{v₁,u₁}) (α : Γ ⥤ PGrpd.{v₁,u₁}) (h : α ⋙ PGrpd.forgetToGrpd = A) 119 | 120 | /-- `sec` is the universal lift in the following diagram, 121 | which is a section of `Groupoidal.forget` 122 | α 123 | ===== Γ -------α--------------¬ 124 | ‖ ↓ sec V 125 | ‖ ∫(A) ----------------> PGrpd 126 | ‖ | | 127 | ‖ | | 128 | ‖ forget forgetToGrpd 129 | ‖ | | 130 | ‖ V V 131 | ===== Γ --α ≫ forgetToGrpd--> Grpd 132 | -/ 133 | def sec : Γ ⥤ ∫(A) := 134 | Groupoidal.functorTo (𝟭 _) (fun x => PGrpd.objFiber' h x) (fun f => PGrpd.mapFiber' h f) 135 | (fun x => by simp) (fun f g => by subst h; simp [PGrpd.mapFiber']) 136 | 137 | @[simp] lemma sec_obj_base (x) : ((sec A α h).obj x).base = x := 138 | rfl 139 | 140 | @[simp] lemma sec_obj_fiber (x) : 141 | ((sec A α h).obj x).fiber = PGrpd.objFiber' h x := 142 | rfl 143 | 144 | @[simp] lemma sec_map_base {x y} {f : x ⟶ y} : ((sec A α h).map f).base = f := 145 | rfl 146 | 147 | @[simp] lemma sec_map_fiber {x y} {f : x ⟶ y} : 148 | ((sec A α h).map f).fiber = PGrpd.mapFiber' h f := 149 | rfl 150 | 151 | @[simp] def sec_toPGrpd : sec A α h ⋙ toPGrpd _ = α := by 152 | apply Grothendieck.Functor.hext 153 | · rw [Functor.assoc, toPGrpd_forgetToGrpd, sec, ← Functor.assoc, h] 154 | rfl 155 | · intro x 156 | simp [toPGrpd_obj_fiber, PGrpd.objFiber', PGrpd.objFiber, Grpd.eqToHom_obj] 157 | · intro x y f 158 | simp only [Functor.comp_map, toPGrpd_map_fiber, sec_map_fiber, PGrpd.mapFiber', 159 | Grpd.eqToHom_hom] 160 | rw! [eqToHom_comp_heq] 161 | simp 162 | 163 | @[simp] def sec_forget : sec A α h ⋙ forget = 𝟭 _ := 164 | rfl 165 | 166 | theorem sec_eq_lift : sec A α h = (isPullback A).lift α (𝟭 _) (by simp [h, Functor.id_comp]) := by 167 | apply (Grothendieck.Groupoidal.isPullback _).lift_uniq 168 | · simp 169 | · simp 170 | 171 | section naturality 172 | variable {Δ : Type u₃} [Category.{v₃} Δ] (σ : Δ ⥤ Γ) 173 | 174 | @[simp] 175 | theorem pre_toPGrpd (A : Γ ⥤ Grpd) : pre A σ ⋙ toPGrpd _ = toPGrpd _ := by 176 | rfl 177 | 178 | theorem sec_naturality : σ ⋙ sec A α h = sec (σ ⋙ A) (σ ⋙ α) (by rw [← h]; rfl) ⋙ pre A σ := by 179 | apply (isPullback A).hom_ext 180 | . simp [Functor.assoc, Functor.comp_id] 181 | . conv_rhs => rw [Functor.assoc, pre_forget, ← Functor.assoc, sec_forget] 182 | simp [Functor.assoc, Functor.comp_id, Functor.id_comp] 183 | 184 | end naturality 185 | 186 | end 187 | 188 | section ι 189 | 190 | variable {C : Type u} [Category.{v} C] (F : C ⥤ Grpd.{v₁,u₁}) 191 | 192 | theorem ι_eq_lift (c : C) : ι F c = 193 | (Grothendieck.Groupoidal.isPullback F).lift 194 | (ι F c ⋙ toPGrpd F) 195 | (ι F c ⋙ forget) rfl := by 196 | apply (Grothendieck.Groupoidal.isPullback F).lift_uniq 197 | · simp 198 | · simp 199 | 200 | end ι 201 | 202 | 203 | end Groupoidal 204 | end Grothendieck 205 | end CategoryTheory 206 | -------------------------------------------------------------------------------- /GroupoidModel/Groupoids/Basic.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.CategoryTheory.Limits.Preserves.FunctorCategory 2 | import Mathlib.CategoryTheory.Functor.ReflectsIso 3 | import Mathlib.CategoryTheory.Category.Cat.Limit 4 | import Mathlib.CategoryTheory.ChosenFiniteProducts.Cat 5 | 6 | import GroupoidModel.Russell_PER_MS.NaturalModel 7 | import GroupoidModel.Grothendieck.Groupoidal.IsPullback 8 | 9 | /-! 10 | Here we construct universes for the groupoid natural model. 11 | -/ 12 | 13 | universe w v u v₁ u₁ v₂ u₂ v₃ u₃ 14 | 15 | noncomputable section 16 | open CategoryTheory ULift Grothendieck.Groupoidal 17 | Limits NaturalModelBase CategoryTheory.Functor 18 | 19 | namespace CategoryTheory.PGrpd 20 | def pGrpdToGroupoidalAsSmallFunctor : PGrpd.{v, v} ⥤ 21 | ∫(Grpd.asSmallFunctor.{max w (v+1), v, v}) := 22 | Grothendieck.functorTo (Grothendieck.forget _) 23 | (fun x => AsSmall.up.obj.{v, v, max w (v + 1)} x.fiber) 24 | (fun f => AsSmall.up.map f.fiber) 25 | (by aesop_cat) 26 | (by aesop_cat) 27 | 28 | def groupoidalAsSmallFunctorToPGrpd : 29 | ∫(Grpd.asSmallFunctor.{max w (v+1), v, v}) ⥤ PGrpd.{v,v} := 30 | PGrpd.functorTo (Grothendieck.forget _) 31 | (fun x => AsSmall.down.obj.{v, v, max w (v + 1)} x.fiber) 32 | (fun f => AsSmall.down.map f.fiber) 33 | (by aesop_cat) 34 | (by aesop_cat) 35 | 36 | @[simp] def pGrpdToGroupoidalAsSmallFunctor_groupoidalAsSmallFunctorToPGrpd : 37 | groupoidalAsSmallFunctorToPGrpd ⋙ pGrpdToGroupoidalAsSmallFunctor = 𝟭 _ := 38 | rfl 39 | 40 | @[simp] def groupoidalAsSmallFunctorToPGrpd_pGrpdToGroupoidalAsSmallFunctor : 41 | pGrpdToGroupoidalAsSmallFunctor ⋙ groupoidalAsSmallFunctorToPGrpd = 𝟭 _ := 42 | rfl 43 | 44 | @[simp] def pGrpdToGroupoidalAsSmallFunctor_forget : pGrpdToGroupoidalAsSmallFunctor 45 | ⋙ Grothendieck.Groupoidal.forget = Grothendieck.forget _ := 46 | rfl 47 | 48 | def asSmallFunctor : PGrpd.{v, v} ⥤ PGrpd.{max w (v+1), max w (v+1)} := 49 | pGrpdToGroupoidalAsSmallFunctor ⋙ 50 | Grothendieck.Groupoidal.toPGrpd Grpd.asSmallFunctor.{max w (v+1), v, v} 51 | 52 | end CategoryTheory.PGrpd 53 | 54 | namespace GroupoidModel 55 | 56 | /-- 57 | Ctx is 58 | the category of 59 | {small groupoids - size u objects and size u hom sets} 60 | which itself has size u+1 objects (small groupoids) 61 | and size u hom sets (functors). 62 | 63 | We want our context category to be a small category so we will use 64 | `AsSmall.{u}` for some large enough `u` 65 | -/ 66 | abbrev Ctx := AsSmall.{u} Grpd.{u,u} 67 | 68 | namespace Ctx 69 | 70 | @[simps] def equivalence : CategoryTheory.Equivalence Grpd.{u,u} Ctx.{u} where 71 | functor := AsSmall.up 72 | inverse := AsSmall.down 73 | unitIso := eqToIso rfl 74 | counitIso := eqToIso rfl 75 | 76 | abbrev ofGrpd : Grpd.{u,u} ⥤ Ctx.{u} := equivalence.functor 77 | 78 | abbrev toGrpd : Ctx.{u} ⥤ Grpd.{u,u} := equivalence.inverse 79 | 80 | def ofGroupoid (Γ : Type u) [Groupoid.{u} Γ] : Ctx.{u} := 81 | ofGrpd.obj (Grpd.of Γ) 82 | 83 | def ofCategory (C : Type (v+1)) [Category.{v} C] : Ctx.{max u (v+1)} := 84 | Ctx.ofGrpd.obj $ Grpd.of (Core (AsSmall C)) 85 | 86 | def homOfFunctor {C : Type (v+1)} [Category.{v} C] {D : Type (w+1)} [Category.{w} D] 87 | (F : C ⥤ D) : Ctx.ofCategory.{v, max u (v+1) (w+1)} C 88 | ⟶ Ctx.ofCategory.{w, max u (v+1) (w+1)} D := 89 | Ctx.ofGrpd.map $ Grpd.homOf $ Core.map' $ AsSmall.down ⋙ F ⋙ AsSmall.up 90 | 91 | instance : ChosenFiniteProducts Ctx := equivalence.chosenFiniteProducts 92 | 93 | end Ctx 94 | 95 | @[simps] def catLift : Cat.{u,u} ⥤ Cat.{u,u+1} where 96 | obj x := Cat.of (ULift.{u + 1, u} x) 97 | map {x y} f := downFunctor ⋙ f ⋙ upFunctor 98 | 99 | section yonedaCat 100 | variable (C D) [Category.{u} C] [Category.{u} D] 101 | 102 | /-- `yonedaCat` is the following composition 103 | 104 | Cat --- yoneda ---> Psh Cat -- restrict along inclusion --> Psh Ctx 105 | 106 | where Ctx --- inclusion ---> Cat 107 | takes a groupoid and forgets it to a category 108 | (with appropriate universe level adjustments) 109 | -/ 110 | abbrev yonedaCat : Cat.{u,u+1} ⥤ Ctx.{u}ᵒᵖ ⥤ Type (u + 1) := 111 | yoneda ⋙ (whiskeringLeft _ _ _).obj 112 | (AsSmall.down ⋙ Grpd.forgetToCat ⋙ catLift).op 113 | 114 | instance yonedaCatPreservesLimits : PreservesLimits yonedaCat := 115 | comp_preservesLimits _ _ 116 | 117 | variable {Γ Δ : Ctx.{u}} {C D : Cat.{u,u+1}} 118 | 119 | def yonedaCatEquivAux : (yonedaCat.obj C).obj (Opposite.op Γ) 120 | ≃ (Ctx.toGrpd.obj Γ) ⥤ C where 121 | toFun := λ A ↦ ULift.upFunctor ⋙ A 122 | invFun := λ A ↦ ULift.downFunctor ⋙ A 123 | left_inv := λ _ ↦ rfl 124 | right_inv := λ _ ↦ rfl 125 | 126 | /- The bijection y(Γ) → [-,C] ≃ Γ ⥤ C -/ 127 | def yonedaCatEquiv : (yoneda.obj Γ ⟶ yonedaCat.obj C) 128 | ≃ Ctx.toGrpd.obj Γ ⥤ C := 129 | yonedaEquiv.trans yonedaCatEquivAux 130 | 131 | lemma yonedaCatEquiv_yonedaEquivSymm {Γ : Ctx} 132 | (A : (yonedaCat.obj C).obj (Opposite.op Γ)) : 133 | yonedaCatEquiv (yonedaEquiv.symm A) = upFunctor ⋙ A := by 134 | congr 135 | 136 | theorem yonedaCatEquiv_naturality_left 137 | (A : yoneda.obj Γ ⟶ yonedaCat.obj C) (σ : Δ ⟶ Γ) : 138 | yonedaCatEquiv (yoneda.map σ ≫ A) = 139 | (Ctx.toGrpd.map σ) ⋙ yonedaCatEquiv A:= by 140 | simp only [AsSmall.down_obj, AsSmall.down_map, yonedaCatEquiv, 141 | Functor.op_obj, Functor.comp_obj, Cat.of_α, 142 | Equiv.trans_apply, Equiv.coe_fn_mk, ← yonedaEquiv_naturality] 143 | rfl 144 | 145 | theorem yonedaCatEquiv_naturality_right 146 | (A : yoneda.obj Γ ⟶ yonedaCat.obj D) (U : D ⥤ C) : 147 | yonedaCatEquiv (A ≫ yonedaCat.map U) = yonedaCatEquiv A ⋙ U := rfl 148 | 149 | theorem yonedaCatEquiv_symm_naturality_left 150 | (A : Ctx.toGrpd.obj Γ ⥤ C) (σ : Δ ⟶ Γ) : 151 | yoneda.map σ ≫ yonedaCatEquiv.symm A = 152 | yonedaCatEquiv.symm (Ctx.toGrpd.map σ ⋙ A) := rfl 153 | 154 | theorem yonedaCatEquiv_symm_naturality_right 155 | (A : Ctx.toGrpd.obj Γ ⥤ D) (U : D ⥤ C) : 156 | yonedaCatEquiv.symm (A ⋙ U) = 157 | yonedaCatEquiv.symm A ≫ yonedaCat.map U := rfl 158 | 159 | end yonedaCat 160 | 161 | def Ctx.homGrpdEquivFunctor {Γ : Ctx} {G : Type v} [Groupoid.{v} G] 162 | : (Γ ⟶ Ctx.ofGrpd.obj (Grpd.of G)) 163 | ≃ Ctx.toGrpd.obj Γ ⥤ G where 164 | toFun A := Ctx.toGrpd.map A 165 | invFun A := Ctx.ofGrpd.map A 166 | left_inv _ := rfl 167 | right_inv _ := rfl 168 | 169 | section 170 | 171 | variable {Γ Δ : Ctx} (σ : Δ ⟶ Γ) {C : Type (v+1)} [Category.{v} C] 172 | {D : Type (v+1)} [Category.{v} D] 173 | 174 | def toCoreAsSmallEquiv : (Γ ⟶ Ctx.ofGrpd.obj (Grpd.of (Core (AsSmall C)))) 175 | ≃ (Ctx.toGrpd.obj Γ ⥤ C) := 176 | Ctx.homGrpdEquivFunctor.trans ( 177 | Core.functorToCoreEquiv.symm.trans functorToAsSmallEquiv) 178 | 179 | theorem toCoreAsSmallEquiv_symm_naturality_left {A : Ctx.toGrpd.obj Γ ⥤ C} : 180 | toCoreAsSmallEquiv.symm (Ctx.toGrpd.map σ ⋙ A) = σ ≫ toCoreAsSmallEquiv.symm A := by 181 | sorry 182 | 183 | theorem toCoreAsSmallEquiv_naturality_left (A : Γ ⟶ Ctx.ofCategory C) : 184 | toCoreAsSmallEquiv (σ ≫ A) = Ctx.toGrpd.map σ ⋙ toCoreAsSmallEquiv A := by 185 | sorry 186 | 187 | /- The bijection y(Γ) → y[-,C] ≃ Γ ⥤ C -/ 188 | abbrev yonedaCategoryEquiv {Γ : Ctx} {C : Type (v+1)} [Category.{v} C] : 189 | (y(Γ) ⟶ y(Ctx.ofCategory C)) 190 | ≃ Ctx.toGrpd.obj Γ ⥤ C := 191 | Yoneda.fullyFaithful.homEquiv.symm.trans toCoreAsSmallEquiv 192 | 193 | theorem yonedaCategoryEquiv_naturality_left (A : y(Γ) ⟶ y(Ctx.ofCategory C)) : 194 | yonedaCategoryEquiv (ym(σ) ≫ A) = Ctx.toGrpd.map σ ⋙ yonedaCategoryEquiv A := 195 | sorry 196 | 197 | theorem yonedaCategoryEquiv_naturality_left' (A : y(Γ) ⟶ y(Ctx.ofCategory C)) 198 | {σ : y(Δ) ⟶ y(Γ)} : yonedaCategoryEquiv (σ ≫ A) = 199 | Ctx.toGrpd.map (Yoneda.fullyFaithful.preimage σ) 200 | ⋙ yonedaCategoryEquiv A := by 201 | have h : σ = ym(Yoneda.fullyFaithful.preimage σ) := by simp 202 | rw [h, yonedaCategoryEquiv_naturality_left] 203 | rfl 204 | 205 | theorem yonedaCategoryEquiv_naturality_right {D : Type (v+1)} [Category.{v} D] 206 | (A : y(Γ) ⟶ y(Ctx.ofCategory C)) (F : C ⥤ D) : 207 | yonedaCategoryEquiv (A ≫ ym(Ctx.homOfFunctor F)) = yonedaCategoryEquiv A ⋙ F := 208 | sorry 209 | 210 | theorem yonedaCategoryEquiv_symm_naturality_right 211 | {A : Ctx.toGrpd.obj Γ ⥤ C} (F : C ⥤ D): 212 | yonedaCategoryEquiv.symm (A ⋙ F) = 213 | yonedaCategoryEquiv.symm A ≫ ym(Ctx.homOfFunctor F) := by 214 | sorry 215 | 216 | end 217 | 218 | /-- This is a natural isomorphism between functors in the following diagram 219 | Ctx.{u}------ yoneda -----> Psh Ctx 220 | | Λ 221 | | | 222 | | | 223 | inclusion precomposition with inclusion 224 | | | 225 | | | 226 | | | 227 | V | 228 | Cat.{big univ}-- yoneda -----> Psh Cat 229 | 230 | -/ 231 | def asSmallUp_comp_yoneda_iso_forgetToCat_comp_catLift_comp_yonedaCat : 232 | (yoneda : Ctx.{u} ⥤ Ctx.{u}ᵒᵖ ⥤ Type (u + 1)) 233 | ≅ AsSmall.down ⋙ Grpd.forgetToCat ⋙ catLift ⋙ yonedaCat where 234 | hom := {app Γ := yonedaEquiv.symm (CategoryStruct.id _)} 235 | inv := { 236 | app Γ := { 237 | app Δ := λ F ↦ 238 | AsSmall.up.map $ ULift.upFunctor ⋙ F ⋙ ULift.downFunctor}} 239 | 240 | /-- `U.{v}` is the object representing the 241 | universe of `v`-small types 242 | i.e. `y(U) = Ty` for the small natural models `smallU`. -/ 243 | def U : Ctx.{max u (v+1)} := 244 | Ctx.ofCategory Grpd.{v,v} 245 | 246 | /-- `E.{v}` is the object representing `v`-small terms, 247 | living over `U.{v}` 248 | i.e. `y(E) = Tm` for the small natural models `smallU`. -/ 249 | def E : Ctx.{max u (v + 1)} := 250 | Ctx.ofCategory PGrpd.{v,v} 251 | 252 | 253 | /-- `π.{v}` is the morphism representing `v`-small `tp`, 254 | for the small natural models `smallU`. -/ 255 | abbrev π : E.{v,max u (v+1)} ⟶ U.{v, max u (v+1)} := 256 | Ctx.homOfFunctor PGrpd.forgetToGrpd 257 | 258 | namespace U 259 | 260 | variable {Γ : Ctx.{max u (v + 1)}} (A : Γ ⟶ U.{v}) 261 | 262 | def classifier : Ctx.toGrpd.obj Γ ⥤ Grpd.{v,v} := 263 | Ctx.toGrpd.map A ⋙ Core.inclusion (AsSmall Grpd) ⋙ AsSmall.down 264 | 265 | abbrev ext : Ctx.{max u (v + 1)} := 266 | Ctx.ofGrpd.obj (Grpd.of ∫(classifier A)) 267 | 268 | abbrev disp : ext A ⟶ Γ := 269 | Ctx.ofGrpd.map forget 270 | 271 | abbrev var : ext A ⟶ E.{v} := 272 | toCoreAsSmallEquiv.symm (toPGrpd (classifier A)) 273 | 274 | section SmallUHom 275 | 276 | variable {Γ : Ctx.{max u (v + 1)}} (A : Γ ⟶ U.{v}) 277 | 278 | -- TODO rename `U.toU` to `U.liftU` and rename `U.toE` to `U.liftE` 279 | /-- `toU` is the base map between two `v`-small universes 280 | toE 281 | E.{v} --------------> E.{v+1} 282 | | | 283 | | | 284 | π | | π 285 | | | 286 | v v 287 | U.{v}-------toU-----> U.{v+1} 288 | -/ 289 | def toU : U.{v, max u (v+2)} ⟶ U.{v+1, max u (v+2)} := 290 | Ctx.homOfFunctor.{v+1,v} Grpd.asSmallFunctor.{v+1} 291 | 292 | def toE : E.{v, max u (v+2)} ⟶ E.{v+1,max u (v+2)} := 293 | Ctx.homOfFunctor.{v+1,v} PGrpd.asSmallFunctor.{v+1} 294 | 295 | end SmallUHom 296 | 297 | end U 298 | 299 | end GroupoidModel 300 | 301 | end 302 | -------------------------------------------------------------------------------- /GroupoidModel/Groupoids/NaturalModelBase.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.CategoryTheory.Limits.Preserves.FunctorCategory 2 | import Mathlib.CategoryTheory.Functor.ReflectsIso 3 | import Mathlib.CategoryTheory.Category.Cat.Limit 4 | import Mathlib.CategoryTheory.ChosenFiniteProducts.Cat 5 | 6 | import GroupoidModel.Russell_PER_MS.UHom 7 | import GroupoidModel.Grothendieck.Groupoidal.IsPullback 8 | import GroupoidModel.Groupoids.IsPullback 9 | 10 | /-! 11 | Here we construct universes for the groupoid natural model. 12 | -/ 13 | 14 | universe w v u v₁ u₁ v₂ u₂ v₃ u₃ 15 | 16 | noncomputable section 17 | open CategoryTheory 18 | Limits NaturalModelBase 19 | GroupoidModel.IsPullback.SmallU 20 | GroupoidModel.IsPullback.SmallUHom 21 | Grothendieck.Groupoidal 22 | 23 | namespace GroupoidModel 24 | 25 | -- TODO link to this in blueprint 26 | /-- The natural model that acts as the classifier of `v`-large terms and types. 27 | Note that `Ty` and `Tm` are representables, 28 | but since representables are `max u (v+1)`-large, 29 | its representable fibers can be larger (in terms of universe levels) than itself. 30 | -/ 31 | @[simps] def smallU : NaturalModelBase Ctx.{max u (v+1)} where 32 | Ty := y(U.{v}) 33 | Tm := y(E) 34 | tp := ym(π) 35 | ext A := Ctx.ofGrpd.obj (Grpd.of ∫(yonedaCategoryEquiv A)) 36 | disp A := Ctx.ofGrpd.map forget 37 | var A := yonedaCategoryEquiv.symm (toPGrpd _) 38 | disp_pullback A := by 39 | convert isPullback_yonedaDisp_yonedaπ (Yoneda.fullyFaithful.homEquiv.symm A) 40 | simp 41 | 42 | namespace U 43 | 44 | open MonoidalCategory 45 | 46 | def asSmallClosedType' : tensorUnit 47 | ⟶ U.{v+1, max u (v+2)} := 48 | toCoreAsSmallEquiv.symm ((Functor.const _).obj 49 | (Grpd.of (Core (AsSmall.{v+1} Grpd.{v,v})))) 50 | 51 | def asSmallClosedType : y(tensorUnit) 52 | ⟶ smallU.{v+1, max u (v+2)}.Ty := 53 | ym(U.asSmallClosedType') 54 | 55 | def isoGrpd : Core (AsSmall.{max u (v+2)} Grpd.{v,v}) 56 | ⥤ Grpd.{v,v} := Core.inclusion _ ⋙ AsSmall.down 57 | 58 | def isoExtAsSmallClosedTypeHom : 59 | Core (AsSmall.{max u (v+2)} Grpd.{v,v}) 60 | ⥤ ∫(classifier (asSmallClosedType'.{v, max u (v + 2)})) where 61 | obj X := ⟨ ⟨⟨⟩⟩ , AsSmall.up.obj.{_,_,v+1} (AsSmall.down.obj X) ⟩ 62 | map {X Y} F := ⟨ (CategoryStruct.id _) , { 63 | hom := AsSmall.up.map.{_,_,v+1} (AsSmall.down.map F.hom) 64 | inv := AsSmall.up.map.{_,_,v+1} (AsSmall.down.map (F.inv)) 65 | hom_inv_id := by 66 | simp only [← Functor.map_comp, Iso.hom_inv_id] 67 | rfl 68 | inv_hom_id := by 69 | simp only [← Functor.map_comp, Iso.inv_hom_id] 70 | rfl } ⟩ 71 | 72 | def isoExtAsSmallClosedTypeInv : 73 | ∫(classifier (asSmallClosedType'.{v, max u (v + 2)})) ⥤ 74 | Core (AsSmall.{max u (v+2)} Grpd.{v,v}) where 75 | obj X := AsSmall.up.obj (AsSmall.down.obj.{_,_,v+1} X.fiber) 76 | map {X Y} F := { 77 | hom := AsSmall.up.map.{_,_,max u (v+2)} 78 | (AsSmall.down.map F.fiber.hom) 79 | inv := AsSmall.up.map.{_,_,max u (v+2)} 80 | (AsSmall.down.map F.fiber.inv) 81 | hom_inv_id := by 82 | simp only [← Functor.map_comp, Iso.hom_inv_id] 83 | rfl 84 | inv_hom_id := by 85 | simp only [← Functor.map_comp, Iso.inv_hom_id] 86 | rfl } 87 | 88 | def isoExtAsSmallClosedType : 89 | U.{v,max u (v+2)} 90 | ≅ smallU.{v+1,max u (v+2)}.ext U.asSmallClosedType.{v, max u (v+2)} where 91 | hom := Ctx.ofGrpd.map (Grpd.homOf isoExtAsSmallClosedTypeHom.{v,u}) 92 | inv := Ctx.ofGrpd.map (Grpd.homOf isoExtAsSmallClosedTypeInv.{v,u}) 93 | hom_inv_id := rfl 94 | inv_hom_id := rfl 95 | 96 | end U 97 | 98 | def uHomSeqObjs (i : Nat) (h : i < 4) : NaturalModelBase Ctx.{4} := 99 | match i with 100 | | 0 => smallU.{0,4} 101 | | 1 => smallU.{1,4} 102 | | 2 => smallU.{2,4} 103 | | 3 => smallU.{3,4} 104 | | (n+4) => by omega 105 | 106 | def smallUHom : UHom smallU.{v, max u (v+2)} smallU.{v+1, max u (v+2)} := 107 | @UHom.ofTyIsoExt _ _ _ _ _ 108 | { mapTy := ym(U.toU.{v,max u (v+2)}) 109 | mapTm := ym(U.toE) 110 | pb := isPullback_yπ_yπ } 111 | U.asSmallClosedType 112 | (Functor.mapIso yoneda U.isoExtAsSmallClosedType.{v,u}) 113 | 114 | def uHomSeqHomSucc' (i : Nat) (h : i < 3) : 115 | (uHomSeqObjs i (by omega)).UHom (uHomSeqObjs (i + 1) (by omega)) := 116 | match i with 117 | | 0 => smallUHom.{0,4} 118 | | 1 => smallUHom.{1,4} 119 | | 2 => smallUHom.{2,4} 120 | | (n+3) => by omega 121 | 122 | /-- 123 | The groupoid natural model with three nested representable universes 124 | within the ambient natural model. 125 | -/ 126 | def uHomSeq : NaturalModelBase.UHomSeq Ctx.{4} where 127 | length := 3 128 | objs := uHomSeqObjs 129 | homSucc' := uHomSeqHomSucc' 130 | 131 | open CategoryTheory NaturalModelBase Opposite 132 | 133 | section 134 | 135 | variable {Γ : Ctx} {C : Type (v+1)} [Category.{v} C] {Δ : Ctx} (σ : Δ ⟶ Γ) 136 | 137 | -- TODO rename 138 | def smallUPTpEquiv : 139 | (y(Γ) ⟶ smallU.{v}.Ptp.obj y(Ctx.ofCategory C)) 140 | ≃ (A : Ctx.toGrpd.obj Γ ⥤ Grpd.{v,v}) × (∫(A) ⥤ C) := 141 | smallU.Ptp_equiv.trans ( 142 | Equiv.sigmaCongr 143 | yonedaCategoryEquiv 144 | (fun _ => yonedaCategoryEquiv)) 145 | 146 | theorem smallUPTpEquiv_naturality_left 147 | (AB : y(Γ) ⟶ smallU.{v}.Ptp.obj y(Ctx.ofCategory C)) : smallUPTpEquiv (ym(σ) ≫ AB) = 148 | ⟨ Ctx.toGrpd.map σ ⋙ (smallUPTpEquiv AB).fst, 149 | pre _ (Ctx.toGrpd.map σ) ⋙ (smallUPTpEquiv AB).snd ⟩ := by 150 | dsimp [smallUPTpEquiv] 151 | erw [Ptp_equiv_naturality_left] 152 | simp [Equiv.sigmaCongr] 153 | constructor 154 | · erw [← yonedaCategoryEquiv_naturality_left] 155 | rfl 156 | · dsimp 157 | sorry 158 | 159 | end 160 | 161 | @[simp] theorem smallU_sec {Γ : Ctx.{max u (v+1)}} (α : y(Γ) ⟶ smallU.{v}.Tm) : 162 | smallU.sec _ α rfl = Ctx.ofGrpd.map (sec _ (yonedaCategoryEquiv α) rfl) := by 163 | apply Yoneda.fullyFaithful.map_injective 164 | apply (smallU.disp_pullback _).hom_ext 165 | . rw [NaturalModelBase.sec_var, smallU_var] 166 | convert_to α = ym(Ctx.ofGrpd.map $ Grpd.homOf (sec (yonedaCategoryEquiv (α ≫ ym(Ctx.homOfFunctor PGrpd.forgetToGrpd))) (yonedaCategoryEquiv α) _)) ≫ yonedaCategoryEquiv.symm (_) 167 | dsimp [toCoreAsSmallEquiv, Ctx.homGrpdEquivFunctor, functorToAsSmallEquiv, 168 | Core.functorToCoreEquiv] 169 | rw [← Functor.map_comp, ← Functor.map_comp, Grpd.comp_eq_comp, ← Core.functorToCore_naturality_left, ← Functor.assoc, sec_toPGrpd] 170 | simp [yonedaCategoryEquiv, toCoreAsSmallEquiv, functorToAsSmallEquiv, 171 | Core.functorToCoreEquiv, Core.forgetFunctorToCore, Ctx.homGrpdEquivFunctor, 172 | -AsSmall.down_map, Functor.assoc, Functor.comp_id, 173 | Core.functorToCore_naturality_left, Core.functorToCore_inclusion_apply] 174 | . rw [← Functor.map_comp, sec_disp] 175 | simp only [CategoryTheory.Functor.map_id, smallU_Tm, smallU_Ty, smallU_tp, smallU_ext, 176 | Ctx.equivalence_functor, Ctx.equivalence_inverse, smallU_disp, ← 177 | Functor.map_comp, Grpd.comp_eq_comp, Grpd.coe_of, sec_forget, ← Grpd.id_eq_id] 178 | rfl 179 | 180 | theorem smallU_lift {Γ Δ : Ctx.{max u (v+1)}} (A : y(Γ) ⟶ smallU.{v}.Ty) 181 | (fst : y(Δ) ⟶ smallU.{v}.Tm) (snd : Δ ⟶ Γ) 182 | (w : fst ≫ smallU.{v}.tp = ym(snd) ≫ A) : 183 | (smallU.{v}.disp_pullback A).lift fst ym(snd) w = 184 | ym(Ctx.ofGrpd.map ((Grothendieck.Groupoidal.isPullback _).lift 185 | (yonedaCategoryEquiv fst) 186 | (Ctx.toGrpd.map snd) 187 | (by erw [← yonedaCategoryEquiv_naturality_right, w, 188 | yonedaCategoryEquiv_naturality_left]))) := by 189 | apply (smallU.{v}.disp_pullback A).hom_ext 190 | · simp [← Functor.map_comp] 191 | dsimp at * 192 | -- erw [(isPullback (yonedaCategoryEquiv A)).fac_left] 193 | sorry 194 | · simp only [smallU_ext, Ctx.equivalence_functor, Ctx.equivalence_inverse, 195 | smallU_Tm, smallU_Ty, smallU_var, Grpd.coe_of, Equiv.symm_trans_apply, 196 | Equiv.symm_symm, Functor.FullyFaithful.homEquiv_apply, smallU_disp, smallU_tp, 197 | IsPullback.lift_snd, ← Functor.map_comp, Grpd.comp_eq_comp] 198 | erw [(isPullback (yonedaCategoryEquiv A)).fac_right, AsSmall.down_map_up_map] 199 | 200 | -- TODO shorten name 201 | /-- A specialization of the universal property of `UvPoly.compDom` 202 | to the natural model `smallU`. 203 | This consists of a pair of dependent types 204 | `A = α ⋙ forgetToGrpd` and `B`, 205 | `a : A` captured by `α`, 206 | and `b : B[a / x] = β ⋙ forgetToGrpd` caputred by `β`. 207 | -/ 208 | def smallUCompDomEquiv {Γ : Ctx.{max u (v+1)}} : 209 | (y(Γ) ⟶ smallU.{v}.uvPolyTp.compDom smallU.{v}.uvPolyTp) 210 | ≃ (α : Ctx.toGrpd.obj Γ ⥤ PGrpd.{v,v}) 211 | × (B : ∫(α ⋙ PGrpd.forgetToGrpd) ⥤ Grpd.{v,v}) 212 | × (β : Ctx.toGrpd.obj Γ ⥤ PGrpd.{v,v}) 213 | ×' β ⋙ PGrpd.forgetToGrpd = Grothendieck.Groupoidal.sec _ α rfl ⋙ B := 214 | (smallU.uvPolyTpCompDomEquiv smallU Γ).trans 215 | (Equiv.sigmaCongr 216 | yonedaCategoryEquiv $ 217 | fun α => Equiv.sigmaCongr 218 | yonedaCategoryEquiv $ 219 | fun B => Equiv.psigmaCongrProp 220 | yonedaCategoryEquiv $ 221 | fun β => by 222 | convert (yonedaCategoryEquiv.apply_eq_iff_eq).symm 223 | rw [yonedaCategoryEquiv_naturality_left, smallU_sec] 224 | rfl) 225 | 226 | /- 227 | For the natural model `smallU`, a map `ab : y(Γ) ⟶ compDom tp` 228 | is equivalent to the data of `(α,B,β,h)` due to `smallUCompDomEquiv` 229 | ``` 230 | (α : Ctx.toGrpd.obj Γ ⥤ PGrpd.{v,v}) 231 | × (B : ∫(α ⋙ PGrpd.forgetToGrpd) ⥤ Grpd.{v,v}) 232 | × (β : Ctx.toGrpd.obj Γ ⥤ PGrpd.{v,v}) 233 | ×' (h : β ⋙ PGrpd.forgetToGrpd = Grothendieck.Groupoidal.sec _ α rfl ⋙ B) 234 | ``` 235 | The following lemma computes the base type 236 | `α ⋙ forgetToGrpd : y(Γ) ⟶ Grpd` in two different ways. 237 | LHS is via `smallUPTpEquiv`, the universal property of `P_tp Ty`. 238 | RHS is via `smallUCompDomEquiv` 239 | -/ 240 | theorem smallUCompDomEquiv_apply_fst_forgetToGrpd 241 | {Γ : Ctx.{max u (v+1)}} 242 | (ab : y(Γ) ⟶ smallU.{v}.uvPolyTp.compDom smallU.{v}.uvPolyTp) : 243 | (smallUCompDomEquiv ab).fst ⋙ PGrpd.forgetToGrpd 244 | = (smallUPTpEquiv (ab ≫ ( 245 | smallU.{v}.uvPolyTp.comp smallU.{v}.uvPolyTp).p)).fst := by 246 | dsimp only [smallUPTpEquiv, Equiv.trans_apply] 247 | rw [Equiv.sigmaCongr_apply_fst] 248 | convert congr_arg yonedaCategoryEquiv.toFun 249 | (@uvPolyTpCompDomEquiv_apply_fst_tp 250 | Ctx.{max u (v+1)} _ smallU.{v} smallU.{v} Γ ab) 251 | 252 | theorem smallUCompDomEquiv_apply_snd_fst {Γ : Ctx.{max u (v+1)}} 253 | (ab : y(Γ) ⟶ smallU.{v}.uvPolyTp.compDom smallU.{v}.uvPolyTp) : 254 | (smallUCompDomEquiv ab).snd.fst 255 | = (Grothendieck.Groupoidal.isPullback _).lift (toPGrpd _) forget (by 256 | rw [smallUCompDomEquiv_apply_fst_forgetToGrpd]; rfl) 257 | ⋙ (smallUPTpEquiv (ab ≫ ( 258 | smallU.{v}.uvPolyTp.comp smallU.{v}.uvPolyTp).p)).snd := by 259 | dsimp only [smallUPTpEquiv, Equiv.trans_apply, smallUCompDomEquiv] 260 | conv => left; erw [Equiv.sigmaCongr_apply_snd, Equiv.sigmaCongr_apply_fst] 261 | conv => right; rw [Equiv.sigmaCongr_apply_snd] 262 | rw [uvPolyTpCompDomEquiv_apply_snd_fst] 263 | apply (yonedaCategoryEquiv_naturality_left' _).trans 264 | rw [smallU_lift] 265 | simp only [Ctx.equivalence_inverse, Ctx.equivalence_functor, 266 | AsSmall.down_obj, AsSmall.up_obj_down, Functor.FullyFaithful.preimage_map, 267 | AsSmall.down_map, AsSmall.up_map_down] 268 | rw! [smallU_var] 269 | rfl 270 | 271 | -- theorem smallUTpCompDomEquiv_apply_fst {Γ : Ctx.{max u (v+1)}} 272 | -- (ab : y(Γ) ⟶ smallU.{v}.uvPolyTp.compDom smallU.{v}.uvPolyTp) : 273 | -- (smallUCompDomEquiv ab).fst ⋙ PGrpd.forgetToGrpd 274 | -- = (smallUPTpEquiv (ab ≫ ( 275 | -- smallU.{v}.uvPolyTp.comp smallU.{v}.uvPolyTp).p)).fst := by 276 | -- dsimp only [smallUPTpEquiv, Equiv.trans_apply, Equiv.sigmaCongrLeft] 277 | -- rw [Equiv.sigmaCongr_apply_fst] 278 | -- sorry 279 | -- -- convert congr_arg yonedaCategoryEquiv.toFun 280 | -- -- (@compDomEquiv_apply_fst Ctx.{max u (v+1)} _ smallU.{v} smallU.{v} Γ ab) 281 | 282 | end GroupoidModel 283 | 284 | end 285 | -------------------------------------------------------------------------------- /GroupoidModel/Outline.md: -------------------------------------------------------------------------------- 1 | 2 | /- There should be at least three separate files here for three separate developments: 3 | 1. the basic development of the category Grpd of groupoids 4 | 2. the intermediate natural model of HoTT which is constructed out of Gpds 5 | 3. the metaprogram level HoTT 0 for interacting with the model 6 | -/ 7 | 8 | /- 9 | # 1. The category Grpd of small groupoids 10 | We need at least the following, some of which is already in MathLib: 11 | - the category of small groupoids and their homomorphisms 12 | - (discrete and split) fibrations of groupoids 13 | - pullbacks of (discrete and split) fibrations exist in Grpd and are again (such) fibrations 14 | - set- and groupoid-valued presheaves on groupoids 15 | - the Grothendieck construction relating the previous two 16 | - the equivalence between (split) fibrations and presheaves of groupoids 17 | - Σ and Π-types for (split) fibrations 18 | - path groupoids 19 | - the universe of (small) discrete groupoids (aka sets) 20 | - polynomial functors of groupoids 21 | - maybe some W-types 22 | - eventually we will want some groupoid quotients as well 23 | -/ 24 | 25 | /- 26 | # 2. The natural model of HoTT in Grpd 27 | We will need at least the following: 28 | - the category Ctx (to be interpreted as small groupoids) 29 | - the display maps of contexts, arising from iterated context extensions 30 | - the presheaf category 𝓔 = Psh(Ctx) in which the model lives 31 | - the presheaf Type : Ctxᵒᵖ → Set of types in context 32 | - the presheaf Term : Ctxᵒᵖ → Set of terms in context 33 | - the typing natural transformation t : Term ⟶ Type 34 | - the proof that t is (re)presentable 35 | - the polynomial endofunctor Pₜ : 𝓔 ⥤ 𝓔 36 | - the type-formers Σ, Π, Id as operations on polynomials over 𝓔 37 | - the universe Set of (small) discrete groupoids, 38 | along with its discrete (op-)fibration Set* ⟶ Set 39 | It would also be useful to have: 40 | - the proof that presentable natural transformations are tiny maps 41 | - the proof that Pₜ is therefore cocontinuous, since t is tiny 42 | -/ 43 | 44 | /- 45 | # 3. HoTT_0 46 | No idea how to do this in practice! 47 | But it would be nice if the user could: 48 | - interact with types, terms, and type families, rather than 49 | groupoids, homomorphisms, and fibrations 50 | - have the usual Lean rules for the Σ- and Π-types 51 | - have path-induction for the general identity types 52 | - define the sets as the 0-types 53 | - use Lean's normal infrastructure like rewriting, tactics, mathlib, etc. 54 | for equality on sets. 55 | -/ 56 | 57 | /- 58 | # Targets 59 | Here are some things that should be doable in HoTT_0: 60 | - HoTT Book real numbers and cumulative hierarchy, 61 | - univalent set theory, 62 | - structure identity principle for general algebraic structures, 63 | - propositional truncation ||A|| , 64 | - set-truncation ||X||₀ = π₀(X) , 65 | - groupoid quotients, 66 | - Eilenberg-MacLane spaces K(G,1), and some basic cohomology, 67 | - classifying spaces BG, and the theory of covering spaces, 68 | - calculation of π₁(S¹) = Z using univalence and circle induction, 69 | - Joyal’s combinatorial species, 70 | - Lawvere's objective number theory, 71 | - Egbert’s univalent combinatorics, 72 | - Rezk completion of a small category, 73 | - univalent category theory: equivalences, etc. 74 | -/ 75 | -------------------------------------------------------------------------------- /GroupoidModel/Pointed/IsPullback.lean: -------------------------------------------------------------------------------- 1 | import GroupoidModel.Grothendieck.IsPullback 2 | /-! 3 | # Pointed groupoids as the pullback of pointed categories 4 | 5 | This file shows that `PGrpd.forgetToGrpd` is the pullback 6 | along `Grpd.forgetToCat` of `PCat.forgetToCat`. 7 | 8 | ## Main statements 9 | 10 | * `CategoryTheory.PGrpd.isPullback_forgetToGrpd_forgetToCat` - 11 | the functor `PGrpd.forgetToGrpd` is the pullback 12 | along `Grpd.forgetToCat` of `PCat.forgetToCat`. 13 | 14 | - TODO Probably the latter half of this file can be shortened 15 | significantly by providing a direct proof of pullback 16 | using the `IsMegaPullback` definitions 17 | -/ 18 | 19 | 20 | universe v u v₁ u₁ v₂ u₂ 21 | 22 | /- 23 | -/ 24 | namespace CategoryTheory 25 | 26 | namespace PGrpd 27 | 28 | lemma forgetToPCat_forgetToCat : 29 | PGrpd.forgetToPCat.{v,u} ⋙ PCat.forgetToCat.{v,u} = 30 | PGrpd.forgetToGrpd.{v,u} ⋙ Grpd.forgetToCat.{v,u} := 31 | rfl 32 | 33 | /-- 34 | The following square is a (meta-theoretic) pullback 35 | 36 | PGrpd ------ toPCat ------> PCat 37 | | | 38 | | | 39 | PGrpd.forgetToGrpd PCat.forgetToCat 40 | | | 41 | v v 42 | Grpd------forgetToCat------->Cat 43 | -/ 44 | def isPullback : Functor.IsPullback forgetToPCat.{v,u} forgetToGrpd.{v,u} 45 | PCat.forgetToCat Grpd.forgetToCat := 46 | Grothendieck.isPullback _ 47 | 48 | /-- 49 | The following square is a pullback in `Cat` 50 | 51 | PGrpd ------ toPCat ------> PCat 52 | | | 53 | | | 54 | PGrpd.forgetToGrpd PCat.forgetToCat 55 | | | 56 | v v 57 | Grpd------forgetToCat------->Cat 58 | -/ 59 | theorem isPullback' : 60 | IsPullback 61 | (Cat.homOf PGrpd.forgetToPCat.{u,u}) 62 | (Cat.homOf PGrpd.forgetToGrpd.{u,u}) 63 | (Cat.homOf PCat.forgetToCat.{u,u}) 64 | (Cat.homOf Grpd.forgetToCat.{u,u}) := 65 | Cat.isPullback forgetToPCat_forgetToCat isPullback 66 | 67 | 68 | end PGrpd 69 | end CategoryTheory 70 | -------------------------------------------------------------------------------- /GroupoidModel/Russell_PER_MS/Basic.lean: -------------------------------------------------------------------------------- 1 | /-! Presentation with 2 | - PER-style equality judgments; and 3 | - Russell-style universes up to N; and 4 | - judgments stratified by universe. 5 | -/ 6 | 7 | /-- A Hott₀ expression. -/ 8 | inductive Expr where 9 | /-- De Bruijn index. -/ 10 | | bvar (i : Nat) 11 | /-- Dependent product. -/ 12 | | pi (l l' : Nat) (A B : Expr) 13 | /-- Dependent sum. -/ 14 | | sigma (l l' : Nat) (A B : Expr) 15 | /-- Lambda. -/ 16 | | lam (l l' : Nat) (ty body : Expr) 17 | /-- Application at the specified output type. -/ 18 | | app (l l' : Nat) (B fn arg : Expr) 19 | /-- Pair formation. -/ 20 | | pair (l l' : Nat) (B t u : Expr) 21 | /-- First component. -/ 22 | | fst (l l' : Nat) (A B p : Expr) 23 | /-- Second component. -/ 24 | | snd (l l' : Nat) (A B p : Expr) 25 | /-- (Russell) type universe. -/ 26 | | univ (l : Nat) 27 | /-- Type from a code. -/ 28 | | el (a : Expr) : Expr 29 | /-- Code from a type. -/ 30 | | code (A : Expr) : Expr 31 | deriving Repr 32 | 33 | @[simp] 34 | theorem Expr.sizeOf_pos (e : Expr) : 0 < sizeOf e := by 35 | induction e <;> { dsimp; omega } 36 | -------------------------------------------------------------------------------- /GroupoidModel/Russell_PER_MS/Lemmas.lean: -------------------------------------------------------------------------------- 1 | import GroupoidModel.Russell_PER_MS.Typing 2 | 3 | /-! Basic syntactic metatheory. -/ 4 | 5 | theorem EqTp.le_univMax {Γ A B l} : Γ ⊢[l] A ≡ B → l ≤ univMax := by 6 | apply @EqTp.rec (fun _ l _ _ _ => l ≤ univMax) (fun _ l _ _ _ _ => l ≤ univMax) 7 | all_goals intros; first| trivial | omega 8 | 9 | theorem EqTm.le_univMax {Γ A t u l} : Γ ⊢[l] t ≡ u : A → l ≤ univMax := by 10 | apply @EqTm.rec (fun _ l _ _ _ => l ≤ univMax) (fun _ l _ _ _ _ => l ≤ univMax) 11 | all_goals intros; first| trivial | omega 12 | 13 | theorem EqTp.wf_left {Γ A B l} : Γ ⊢[l] A ≡ B → Γ ⊢[l] A := 14 | fun h => .trans_tp h (.symm_tp h) 15 | 16 | theorem EqTp.wf_right {Γ A B l} : Γ ⊢[l] A ≡ B → Γ ⊢[l] B := 17 | fun h => .trans_tp (.symm_tp h) h 18 | 19 | theorem EqTm.wf_left {Γ A t u l} : Γ ⊢[l] t ≡ u : A → Γ ⊢[l] t : A := 20 | fun h => .trans_tm h (.symm_tm h) 21 | 22 | theorem EqTm.wf_right {Γ A t u l} : Γ ⊢[l] t ≡ u : A → Γ ⊢[l] u : A := 23 | fun h => .trans_tm (.symm_tm h) h 24 | 25 | theorem EqTm.wf_tp {Γ A t u l} : Γ ⊢[l] t ≡ u : A → Γ ⊢[l] A := by 26 | apply @EqTm.rec 27 | (fun _ _ _ _ _ => True) 28 | (fun Γ l _ _ A _ => Γ ⊢[l] A) 29 | all_goals intros; try trivial 30 | case cong_bvar0 A_wf _ => 31 | exact EqTp.lift_tp _ _ A_wf 32 | case cong_lam A_eq _ _ B_wf => 33 | exact .cong_pi A_eq.wf_left B_wf 34 | case cong_app B_eq _ a_eq _ _ _ => 35 | exact (EqTp.inst_tp B_eq a_eq).wf_left 36 | case cong_code => 37 | apply EqTp.cong_univ; assumption 38 | case cong_pair B_eq _ _ _ A_wf _ => 39 | exact .cong_sigma A_wf B_eq.wf_left 40 | case cong_fst A_eq _ _ _ _ _ => 41 | exact A_eq.wf_left 42 | case cong_snd A_eq B_eq p_eq _ _ _ => 43 | exact (EqTm.cong_fst A_eq B_eq p_eq |> EqTp.inst_tp B_eq).wf_left 44 | case app_lam u_wf B_wf _ => 45 | exact EqTp.inst_tp B_wf u_wf 46 | case conv A_eq _ _ _ => 47 | exact A_eq.wf_right 48 | case inst_tm a_eq B_wf _ => 49 | exact (EqTp.inst_tp B_wf a_eq).wf_left 50 | case lift_tm t_eq A_wf => 51 | exact EqTp.lift_tp _ _ A_wf 52 | 53 | theorem Lookup.wf_tp {Γ i A l} : Lookup Γ i A l → Γ ⊢[l] A := by 54 | intro h; induction h <;> { apply EqTp.lift_tp; assumption } 55 | 56 | theorem Lookup.wf_bvar {Γ i A l} : Lookup Γ i A l → Γ ⊢[l] .bvar i : A := by 57 | intro h; induction h 58 | . apply EqTm.cong_bvar0 59 | assumption 60 | . rename_i ih 61 | convert EqTm.lift_tm _ _ ih using 1 <;> 62 | simp [Expr.lift, Expr.liftN, Nat.add_comm] 63 | -------------------------------------------------------------------------------- /GroupoidModel/Russell_PER_MS/Substitution.lean: -------------------------------------------------------------------------------- 1 | import GroupoidModel.Russell_PER_MS.Basic 2 | 3 | /-! In this module we compute the action of substitutions. -/ 4 | 5 | /-! ## Lifting/weakening 6 | 7 | Write `↑ⁿ` for the `n`-fold weakening substitution `{n+i/i}`. 8 | Write `σ:k` for `σ.vₖ₋₁.….v₁.v₀`. 9 | 10 | The *thinning* substitution `↑ⁿ⁺ᵏ:k`, 11 | i.e., `{0/0,…,k-1/k-1, k+n/k,k+1+n/k+1,…}`, 12 | arises by starting with `↑ⁿ` and traversing under `k` binders: 13 | for example, `(ΠA. B)[↑¹] ≡ ΠA[↑¹]. B[↑².v₀] ≡ ΠA[↑¹]. B[↑¹⁺¹:1]`. 14 | 15 | Applying `↑ⁿ⁺ᵏ:k` moves an expression into a context 16 | with `n` new binders inserted at index `k`: 17 | `Γ.Bₙ.….B₁.Aₖ₋₁[↑ⁿ].….A₀[⋯] ⊢ ↑ⁿ⁺ᵏ:k : Γ.Aₖ₋₁.….A₀`. 18 | (With `k = 0`, the codomain is just `Γ`.) -/ 19 | 20 | /-- Substitute `↑ⁿ⁺ᵏ:k` in the de Bruijn index `i`. -/ 21 | def liftVar (n i : Nat) (k := 0) : Nat := if i < k then i else n + i 22 | 23 | variable (n : Nat) in 24 | /-- Substitute `↑ⁿ⁺ᵏ:k` in an expression. -/ 25 | def Expr.liftN : Expr → (k : Nat := 0) → Expr 26 | | .bvar i, k => .bvar (liftVar n i k) 27 | | .pi l l' A B, k => .pi l l' (A.liftN k) (B.liftN (k+1)) 28 | | .sigma l l' A B, k => .sigma l l' (A.liftN k) (B.liftN (k+1)) 29 | | .lam l l' A t, k => .lam l l' (A.liftN k) (t.liftN (k+1)) 30 | | .app l l' B fn arg, k => .app l l' (B.liftN (k+1)) (fn.liftN k) (arg.liftN k) 31 | | .pair l l' B t u, k => .pair l l' (B.liftN (k+1)) (t.liftN k) (u.liftN k) 32 | | .fst l l' A B p, k => .fst l l' (A.liftN k) (B.liftN (k+1)) (p.liftN k) 33 | | .snd l l' A B p, k => .snd l l' (A.liftN k) (B.liftN (k+1)) (p.liftN k) 34 | | .univ l, _ => .univ l 35 | | .el a, k => .el (a.liftN k) 36 | | .code A, k => .code (A.liftN k) 37 | 38 | /-- Substitute `↑¹` in an expression. -/ 39 | abbrev Expr.lift := Expr.liftN 1 40 | 41 | /-! ## Instantiation 42 | 43 | The substitution `↑ᵏ.e[↑ᵏ]:k`, 44 | i.e., `{0/0,…,k-1/k-1, e[↑ᵏ]/k, k/k+1,k+2/k+3,…}`, 45 | arises by starting with `id.e` and traversing under `k` binders: 46 | for example `(ΠA. B)[id.e] ≡ ΠA[id.e]. B[↑.e[↑].v₀] ≡ ΠA[id.e]. B[↑¹.e[↑¹]:1]`. 47 | 48 | Applying `↑ᵏ.e[↑ᵏ]:k` moves an expression `t` into a context 49 | with the `k`th binder removed: 50 | `Γ.Aₖ₋₁[id.e].….A₀[⋯] ⊢ ↑ᵏ.e[↑ᵏ]:k : Γ.B.Aₖ₋₁.….A₀`. 51 | 52 | The substitution `id.e` is used in `β`-reduction: 53 | `(λb) a ↝ b[id.a]`. -/ 54 | 55 | /-- Substitute `↑ᵏ.e[↑ᵏ]:k` in the de Bruijn index `i`. -/ 56 | def instVar (i : Nat) (e : Expr) (k := 0) : Expr := 57 | if i < k then .bvar i else if i = k then .liftN k e else .bvar (i - 1) 58 | 59 | /-- Substitute `↑ᵏ.e[↑ᵏ]:k` in an expression. -/ 60 | def Expr.inst : Expr → Expr → (k :_:= 0) → Expr 61 | | .bvar i, e, k => instVar i e k 62 | | .pi l l' A B, e, k => .pi l l' (A.inst e k) (B.inst e (k+1)) 63 | | .sigma l l' A B, e, k => .sigma l l' (A.inst e k) (B.inst e (k+1)) 64 | | .lam l l' A t, e, k => .lam l l' (A.inst e k) (t.inst e (k+1)) 65 | | .app l l' B fn arg, e, k => .app l l' (B.inst e (k+1)) (fn.inst e k) (arg.inst e k) 66 | | .pair l l' B t u, e, k => .pair l l' (B.inst e (k+1)) (t.inst e k) (u.inst e k) 67 | | .fst l l' A B p, e, k => .fst l l' (A.inst e k) (B.inst e (k+1)) (p.inst e k) 68 | | .snd l l' A B p, e, k => .snd l l' (A.inst e k) (B.inst e (k+1)) (p.inst e k) 69 | | .univ l, _, _ => .univ l 70 | | .el a, e, k => .el (a.inst e k) 71 | | .code A, e, k => .code (A.inst e k) 72 | 73 | /-! ## Lemmas -/ 74 | 75 | @[simp] 76 | theorem liftVar_zero (i k) : liftVar 0 i k = i := by 77 | simp [liftVar] 78 | 79 | @[simp] 80 | theorem liftVar_zero' (n i) : liftVar n i 0 = n + i := by 81 | simp [liftVar] 82 | 83 | @[simp] 84 | theorem Expr.liftN_zero (t : Expr) (k) : t.liftN 0 k = t := by 85 | induction t generalizing k <;> simp [liftN, *] 86 | -------------------------------------------------------------------------------- /GroupoidModel/Russell_PER_MS/Typing.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.Tactic.Convert 2 | 3 | import GroupoidModel.Russell_PER_MS.Substitution 4 | 5 | /-! In this file we specify typing judgments of the type theory 6 | as `Prop`-valued relations. -/ 7 | 8 | section Notation -- TODO make notation local 9 | 10 | declare_syntax_cat judgment 11 | syntax:25 term:51 " ⊢[" term:51 "] " judgment:50 : term 12 | 13 | syntax:50 term:51 : judgment 14 | syntax:50 term:51 " ≡ " term:51 : judgment 15 | syntax:50 term:51 " : " term:51 : judgment 16 | syntax:50 term:51 " ≡ " term:51 " : " term:51 : judgment 17 | 18 | set_option hygiene false in 19 | macro_rules 20 | | `($Γ ⊢[$l:term] $t:term : $A:term) => `($Γ ⊢[$l] $t:term ≡ $t : $A) 21 | | `($Γ ⊢[$l:term] $A:term ≡ $B:term) => `(EqTp $Γ $l $A $B) 22 | | `($Γ ⊢[$l:term] $A:term) => `($Γ ⊢[$l] $A:term ≡ $A) 23 | | `($Γ ⊢[$l:term] $t:term ≡ $u:term : $A:term) => `(EqTm $Γ $l $t $u $A) 24 | 25 | end Notation 26 | 27 | /-- A typing context consisting of expressions and their universe levels. -/ 28 | abbrev Ctx := List (Expr × Nat) 29 | 30 | /-- The maximum `l` for which `Γ ⊢[l] 𝒥` makes sense. 31 | When set to `0`, types cannot be quantified over at all. -/ 32 | def univMax := 37 33 | 34 | /- `presupp` indicates presuppositions. 35 | We don't add literally all of them, 36 | just the ones needed that make inversion easy. -/ 37 | 38 | /- Convention on order of implicit parameters: 39 | contexts, types, de Bruijn indices, universe levels. -/ 40 | 41 | mutual 42 | inductive EqTp : Ctx → Nat → Expr → Expr → Prop 43 | -- Congruences / constructors 44 | | cong_pi {Γ A A' B B' l l'} : 45 | Γ ⊢[l] A ≡ A'→ 46 | (A,l) :: Γ ⊢[l'] B ≡ B' → 47 | Γ ⊢[max l l'] .pi l l' A B ≡ .pi l l' A' B' 48 | 49 | | cong_sigma {Γ A A' B B' l l'} : 50 | Γ ⊢[l] A ≡ A'→ 51 | (A,l) :: Γ ⊢[l'] B ≡ B' → 52 | Γ ⊢[max l l'] .sigma l l' A B ≡ .sigma l l' A' B' 53 | 54 | | cong_univ (Γ l) : 55 | l < univMax → 56 | Γ ⊢[l+1] .univ l 57 | 58 | | cong_el {Γ A A' l} : 59 | Γ ⊢[l+1] A ≡ A' : .univ l → 60 | Γ ⊢[l] .el A ≡ .el A' 61 | 62 | -- Substitution 63 | | inst_tp {Γ A B B' t u l l'} : 64 | (A,l) :: Γ ⊢[l'] B ≡ B' → 65 | Γ ⊢[l] t ≡ u : A → 66 | Γ ⊢[l'] B.inst t ≡ B.inst u 67 | 68 | | lift_tp {Γ A A' l} (B l') : 69 | Γ ⊢[l] A ≡ A' → 70 | (B, l') :: Γ ⊢[l] A.lift ≡ A'.lift 71 | 72 | -- Symmetric-transitive closure 73 | | symm_tp {Γ A A' l} : 74 | Γ ⊢[l] A ≡ A' → 75 | Γ ⊢[l] A' ≡ A 76 | 77 | | trans_tp {Γ A A' A'' l} : 78 | Γ ⊢[l] A ≡ A' → 79 | Γ ⊢[l] A' ≡ A'' → 80 | Γ ⊢[l] A ≡ A'' 81 | 82 | inductive EqTm : Ctx → Nat → Expr → Expr → Expr → Prop 83 | -- Congruences / constructors 84 | | cong_bvar0 {Γ A l} : 85 | Γ ⊢[l] A → 86 | (A,l) :: Γ ⊢[l] .bvar 0 : A.lift 87 | 88 | | cong_lam {Γ A A' B t t' l l'} : 89 | Γ ⊢[l] A ≡ A' → 90 | (A,l) :: Γ ⊢[l'] t ≡ t' : B → 91 | Γ ⊢[max l l'] .lam l l' A t ≡ .lam l l' A' t' : .pi l l' A B 92 | 93 | | cong_app {Γ A B B' f f' a a' l l'} : 94 | (A,l) :: Γ ⊢[l'] B ≡ B' → 95 | Γ ⊢[max l l'] f ≡ f' : .pi l l' A B → 96 | Γ ⊢[l] a ≡ a' : A → 97 | Γ ⊢[l'] .app l l' B f a ≡ .app l l' B' f' a' : B.inst a 98 | 99 | | cong_pair {Γ A B B' t t' u u' l l'} : 100 | (A,l) :: Γ ⊢[l'] B ≡ B' → 101 | Γ ⊢[l] t ≡ t' : A → 102 | Γ ⊢[l'] u ≡ u' : B.inst t → 103 | Γ ⊢[max l l'] .pair l l' B t u ≡ .pair l l' B' t' u' : .sigma l l' A B 104 | 105 | | cong_fst {Γ A A' B B' p p' l l'} : 106 | Γ ⊢[l] A ≡ A' → 107 | (A,l) :: Γ ⊢[l'] B ≡ B' → 108 | Γ ⊢[max l l'] p ≡ p' : .sigma l l' A B → 109 | Γ ⊢[l] .fst l l' A B p ≡ .fst l l' A' B' p' : A 110 | 111 | | cong_snd {Γ A A' B B' p p' l l'} : 112 | Γ ⊢[l] A ≡ A' → 113 | (A,l) :: Γ ⊢[l'] B ≡ B' → 114 | Γ ⊢[max l l'] p ≡ p' : .sigma l l' A B → 115 | Γ ⊢[l'] .snd l l' A B p ≡ .snd l l' A' B' p' : B.inst (.fst l l' A B p) 116 | 117 | | cong_code {Γ A A' l} : 118 | l < univMax → 119 | Γ ⊢[l] A ≡ A' → 120 | Γ ⊢[l+1] .code A ≡ .code A' : .univ l 121 | 122 | -- Reductions 123 | | app_lam {Γ A B t u l l'} : 124 | (A,l) :: Γ ⊢[l'] t : B → 125 | Γ ⊢[l] u : A → 126 | Γ ⊢[l'] .app l l' B (.lam l l' A t) u ≡ t.inst u : B.inst u 127 | 128 | | fst_pair {Γ} {A B t u : Expr} {l l'} : 129 | Γ ⊢[l] A → 130 | (A,l) :: Γ ⊢[l'] B → 131 | Γ ⊢[l] t : A → 132 | Γ ⊢[l'] u : B.inst t → 133 | Γ ⊢[l] .fst l l' A B (.pair l l' B t u) ≡ t : A 134 | 135 | | snd_pair {Γ} {A B t u : Expr} {l l'} : 136 | Γ ⊢[l] A → 137 | (A,l) :: Γ ⊢[l'] B → 138 | Γ ⊢[l] t : A → 139 | Γ ⊢[l'] u : B.inst t → 140 | Γ ⊢[l'] .snd l l' A B (.pair l l' B t u) ≡ u : B.inst t 141 | 142 | -- Expansions 143 | | lam_app {Γ A B f l l'} : 144 | Γ ⊢[max l l'] f : .pi l l' A B → 145 | Γ ⊢[max l l'] f ≡ .lam l l' A (.app l l' (B.liftN 1 1) f.lift (.bvar 0)) : .pi l l' A B 146 | 147 | | pair_fst_snd {Γ A B p l l'} : 148 | Γ ⊢[l] A → 149 | (A,l) :: Γ ⊢[l'] B → 150 | Γ ⊢[max l l'] p : .sigma l l' A B → 151 | Γ ⊢[max l l'] p ≡ .pair l l' B (.fst l l' A B p) (.snd l l' A B p) : .sigma l l' A B 152 | 153 | -- Conversion 154 | | conv {Γ A A' t t' l} : 155 | Γ ⊢[l] A ≡ A' → 156 | Γ ⊢[l] t ≡ t' : A → 157 | Γ ⊢[l] t ≡ t' : A' 158 | 159 | -- Substitution 160 | | inst_tm {Γ A B a b t u l l'} : 161 | (A,l) :: Γ ⊢[l'] a ≡ b : B → 162 | Γ ⊢[l] t ≡ u : A → 163 | Γ ⊢[l'] a.inst t ≡ b.inst u : B.inst t 164 | 165 | | lift_tm {Γ A t t' l} (B l') : 166 | Γ ⊢[l] t ≡ t' : A → 167 | (B, l') :: Γ ⊢[l] t.lift ≡ t'.lift : A.lift 168 | 169 | -- Symmetric-transitive closure 170 | | symm_tm {Γ A t t' l} : 171 | Γ ⊢[l] t ≡ t' : A → 172 | Γ ⊢[l] t' ≡ t : A 173 | 174 | | trans_tm {Γ A t t' t'' l} : 175 | Γ ⊢[l] t ≡ t' : A → 176 | Γ ⊢[l] t' ≡ t'' : A → 177 | Γ ⊢[l] t ≡ t'' : A 178 | end 179 | 180 | /-- `Lookup Γ i A l` means that `(A, l)` is stored at index `i` in `Γ`. 181 | This implies `Γ ⊢[l] .bvar i : A` (see `Lemmas`). -/ 182 | inductive Lookup : Ctx → Nat → Expr → Nat → Prop where 183 | | zero (Γ A l) : Γ ⊢[l] A → Lookup ((A,l) :: Γ) 0 A.lift l 184 | | succ {Γ A i l} (B l') : Lookup Γ i A l → Lookup ((B,l') :: Γ) (i+1) A.lift l 185 | 186 | /-! Pretty-printers. -/ 187 | 188 | section PrettyPrinting 189 | open Lean PrettyPrinter 190 | 191 | @[app_unexpander EqTp] 192 | def EqTp.unexpand : Unexpander 193 | | `($_ $Γ $l $A $A') => 194 | if A == A' then 195 | `($Γ ⊢[$l] $A:term) 196 | else 197 | `($Γ ⊢[$l] $A:term ≡ $A') 198 | | _ => throw () 199 | 200 | @[app_unexpander EqTm] 201 | def EqTm.unexpand : Unexpander 202 | | `($_ $Γ $l $t $t' $A) => 203 | if t == t' then 204 | `($Γ ⊢[$l] $t:term : $A) 205 | else 206 | `($Γ ⊢[$l] $t:term ≡ $t' : $A) 207 | | _ => throw () 208 | 209 | end PrettyPrinting 210 | -------------------------------------------------------------------------------- /GroupoidModel/attic/Display.lean: -------------------------------------------------------------------------------- 1 | import Mathlib.CategoryTheory.Yoneda 2 | import Mathlib.CategoryTheory.Limits.Shapes.Terminal 3 | import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq 4 | import Mathlib.CategoryTheory.Limits.Presheaf 5 | import Mathlib.CategoryTheory.Adjunction.Over 6 | import Poly.LCCC.Presheaf 7 | import Poly.UvPoly 8 | import GroupoidModel.Tarski.NaturalModel 9 | 10 | -- (SH) TODO: Make the proof and construction work with `Disp` rather than `Disp'`. 11 | 12 | universe u 13 | 14 | open CategoryTheory Category Limits 15 | 16 | noncomputable section 17 | 18 | variable {C : Type u} [Category C] [HasTerminal C] [HasPullbacks C] 19 | 20 | variable {𝔼 𝕌 : C} (π : 𝔼 ⟶ 𝕌) 21 | 22 | class DisplayStruct {D A : C} (p : D ⟶ A) where 23 | char : A ⟶ 𝕌 24 | var : D ⟶ 𝔼 25 | disp_pullback : IsPullback var p π char 26 | 27 | def IsDisplay : MorphismProperty C := 28 | fun D A (p : D ⟶ A) ↦ Nonempty (DisplayStruct π p) 29 | 30 | structure Disp' where 31 | T : C 32 | B : C 33 | p : T ⟶ B 34 | disp : DisplayStruct π p := by infer_instance 35 | 36 | variable (C) in 37 | 38 | /-- `Cart C` is a typeclass synonym for `Arrow C` which comes equipped with 39 | a cateogry structure whereby morphisms between arrows `p` and `q` are cartesian 40 | squares between them. -/ 41 | abbrev Cart := Arrow C 42 | 43 | @[simp] 44 | lemma IsPullback.of_horiz_id {X Y : C} (f : X ⟶ Y) : IsPullback (𝟙 X) f f (𝟙 Y) := by 45 | apply IsPullback.of_horiz_isIso 46 | simp only [CommSq.mk, id_comp, comp_id] 47 | 48 | instance : Category (Cart C) where 49 | Hom p q := { v : p ⟶ q // IsPullback v.left p.hom q.hom v.right} 50 | id p := ⟨ ⟨𝟙 _, 𝟙 _, by simp⟩, IsPullback.of_horiz_id p.hom⟩ 51 | comp {p q r} u v := ⟨⟨u.1.left ≫ v.1.left, u.1.right ≫ v.1.right, by simp⟩, 52 | IsPullback.paste_horiz u.2 v.2⟩ 53 | id_comp {p q} f:= by 54 | simp only [Functor.id_obj, Arrow.mk_left, Arrow.mk_right, id_comp] 55 | rfl -- we can replace by aesop, but they are a bit slow 56 | comp_id {p q} f := by 57 | simp only [Functor.id_obj, Arrow.mk_left, Arrow.mk_right, comp_id] 58 | rfl 59 | assoc {p q r s} f g h := by 60 | simp_all only [Functor.id_obj, Arrow.mk_left, Arrow.mk_right, assoc] 61 | 62 | def WideSubcategory (C) [Category C] := WideSubquiver C 63 | 64 | def displayStructPresheaf : (Cart C)ᵒᵖ ⥤ Type u where 65 | obj p := DisplayStruct π p.unop.hom 66 | map {p q} f := fun d ↦ ⟨f.unop.1.right ≫ d.char , f.unop.1.left ≫ d.var, by 67 | apply IsPullback.paste_horiz f.unop.2 d.disp_pullback⟩ 68 | map_id := by sorry 69 | map_comp := by sorry 70 | 71 | abbrev Disp := ((displayStructPresheaf π).Elements)ᵒᵖ 72 | 73 | def forget : Disp π ⥤ Cart C := 74 | (CategoryOfElements.π (displayStructPresheaf π)).leftOp 75 | 76 | namespace DisplayStruct 77 | 78 | structure Hom {D A E B : C} (p : D ⟶ A) [i : DisplayStruct π p] 79 | (q : E ⟶ B) [j : DisplayStruct π q] where 80 | base : B ⟶ A 81 | base_eq : base ≫ i.char = j.char 82 | 83 | instance category : Category (Disp' π) where 84 | Hom P Q := {t : P.B ⟶ Q.B // (t ≫ Q.disp.char) = P.disp.char} 85 | id (P : Disp' π) := ⟨𝟙 P.B, by simp only [id_comp]⟩ 86 | comp {P Q R : Disp' π} f g := ⟨f.1 ≫ g.1, by simp only [assoc, f.2, g.2]⟩ 87 | 88 | /-- A morphism of display maps is necessarily cartesian: The cartesian square is obtained by the 89 | pullback pasting lemma. -/ 90 | theorem is_cartesian {Q P : Disp' π} (f : Q ⟶ P) : 91 | let cone := PullbackCone.mk Q.disp.var (Q.p ≫ f.1) <| by 92 | rw [Category.assoc, f.2]; exact Q.disp.disp_pullback.w 93 | IsPullback (P.disp.disp_pullback.isLimit.lift cone) Q.p P.p f.1 := by 94 | let cone := PullbackCone.mk Q.disp.var (Q.p ≫ f.1) <| by 95 | rw [Category.assoc, f.2] 96 | exact Q.disp.disp_pullback.w 97 | let v := P.disp.disp_pullback.isLimit.lift cone 98 | have h₁ := P.disp.disp_pullback 99 | have h₂ := Q.disp.disp_pullback 100 | have h₃ : v ≫ P.disp.var = Q.disp.var := P.disp.disp_pullback.isLimit.fac cone (some .left) 101 | rw [← f.2, ← h₃] at h₂ 102 | exact (IsPullback.of_right h₂ (P.disp.disp_pullback.isLimit.fac cone (some .right)) h₁) 103 | 104 | def pullback {D A E B : C} (π : E ⟶ B) (p : D ⟶ A) (q : E ⟶ B) 105 | [i : DisplayStruct π p] [j : DisplayStruct π q] 106 | (t : B ⟶ A) (h : t ≫ i.char = j.char) : 107 | DisplayStruct p q where -- should be changed to a morphism from Disp'.mk p to Disp'.mk q 108 | char := t 109 | var := i.disp_pullback.isLimit.lift <| PullbackCone.mk j.var (q ≫ t) <| by 110 | rw [Category.assoc, h] 111 | exact j.disp_pullback.w 112 | disp_pullback := by 113 | let c := PullbackCone.mk j.var (q ≫ t) (by rw [Category.assoc, h]; exact j.disp_pullback.w) 114 | let v := i.disp_pullback.isLimit.lift c 115 | show IsPullback v .. 116 | have h₁ := i.disp_pullback 117 | have h₂ := j.disp_pullback 118 | have h₃ : v ≫ i.var = j.var := i.disp_pullback.isLimit.fac c (some .left) 119 | rw [← h, ← h₃] at h₂ 120 | exact (IsPullback.of_right h₂ (i.disp_pullback.isLimit.fac c (some .right)) h₁) 121 | 122 | def displayMapOfPullback {D A B : C} (p : D ⟶ A) [i : DisplayStruct π p] (t : B ⟶ A) : 123 | DisplayStruct π (pullback.snd p t) where 124 | char := t ≫ i.char 125 | var := pullback.fst .. ≫ i.var 126 | disp_pullback := IsPullback.paste_horiz (IsPullback.of_hasPullback _ _) i.disp_pullback 127 | 128 | end DisplayStruct 129 | 130 | variable {Ctx : Type u} [SmallCategory Ctx] [HasTerminal Ctx] 131 | 132 | open NaturalModel in 133 | 134 | instance [NaturalModelBase Ctx] (Γ : Ctx) (A : y(Γ) ⟶ Ty) : 135 | DisplayStruct tp (yoneda.map (disp Γ A)) where 136 | char := A 137 | var := var Γ A 138 | disp_pullback := disp_pullback A 139 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/Data/Fiber.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2023 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import Mathlib.Tactic.Basic 8 | import Mathlib.Data.Subtype 9 | import Mathlib.Logic.Equiv.Basic 10 | import Mathlib.CategoryTheory.Category.Cat 11 | 12 | /-! 13 | # Fiber 14 | 15 | This files define the type `Fiber` of the fiber of a map at a given point. 16 | -/ 17 | 18 | 19 | /-- The fiber of a map at a given point. -/ 20 | @[simp] 21 | def Fiber {C E : Type*} (P : E → C) (c : C) := {d : E // P d = c} 22 | 23 | namespace Fiber 24 | 25 | variable {C E : Type*} {P : E → C} {c d : C} 26 | 27 | /-- Coercion from the fiber to the domain. -/ 28 | instance {c : C} : CoeOut (Fiber P c) E where 29 | coe := fun x => x.1 30 | 31 | lemma coe_mk {e : E} (h : P e = c) : ((⟨e, h⟩ : Fiber P c) : E) = e := rfl 32 | 33 | lemma mk_coe {x : Fiber P c} : ⟨x.1, x.2⟩ = x := rfl 34 | 35 | lemma coe_inj (x y : Fiber P c) : (x : E) = y ↔ x = y := Subtype.coe_inj 36 | 37 | lemma over (x : Fiber P c) : P x = c := x.2 38 | 39 | lemma over_eq (x y : Fiber P c) : P x = P y := by 40 | simp only [Fiber.over] 41 | 42 | /-- A tautological construction of an element in the fiber of the image of a domain element. -/ 43 | @[simp] 44 | def tauto (e : E) : Fiber P (P e) := ⟨e, rfl⟩ 45 | 46 | /-- Regarding an element of the domain as an element in the fibre of its image. -/ 47 | instance instTautoFib (e : E) : CoeDep (E) (e) (Fiber P (P e) ) where 48 | coe := tauto e 49 | 50 | lemma tauto_over (e : E) : (tauto e : Fiber P (P e)).1 = e := rfl 51 | 52 | /-- Cast an element of a fiber along an equality of the base objects. -/ 53 | @[simp] 54 | def cast (e : Fiber P c) (eq : c = d) : Fiber P d := ⟨e.1, by simp_all only [over]⟩ 55 | 56 | theorem coe_cast (e : Fiber P c) (eq : c = d) : (cast e eq : E) = e.1 := rfl 57 | 58 | lemma cast_coe_tauto (e : Fiber P c) : cast (tauto e.1) (by simp [over]) = e := rfl 59 | 60 | lemma cast_coe_tauto' (e : Fiber P c) : (tauto e.1) = cast e (by simp [over]) := rfl 61 | 62 | @[simps!] 63 | def equivCompSigma {C E F : Type*} (P : E → C) (Q : F → E) (c : C) : 64 | (Fiber (P ∘ Q) c) ≃ (t : Fiber P c) × Fiber Q (t.1) where 65 | toFun := fun x ↦ ⟨⟨Q x.1 , x.2⟩ , x.1⟩ 66 | invFun := fun x ↦ ⟨x.2 , by dsimp; rw [x.2.over, x.1.over]⟩ 67 | left_inv := fun _ ↦ rfl 68 | right_inv := by intro x; ext; simp [over]; rfl 69 | 70 | /-- The total space of a map. -/ 71 | @[ext] 72 | structure Total {C E : Type*} (P : E → C) where 73 | /-- The base object in `C` -/ 74 | base : C 75 | /-- The object in the fiber of the base object. -/ 76 | fiber : Fiber P base 77 | 78 | end Fiber 79 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/Displayed/Cartesian.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import GroupoidModel.FibrationForMathlib.Displayed.Fiber 8 | import GroupoidModel.FibrationForMathlib.Displayed.Basic 9 | import Mathlib.CategoryTheory.Limits.Preserves.Basic 10 | 11 | /-! 12 | # Cartesian lifts 13 | 14 | We introduce the structures `Display.Cartesian` and `Display.CoCartesian` 15 | carrying data witnessing that a given lift is cartesian and cocartesian, respectively. 16 | 17 | Specialized to the display category structure of a functor `P : E ⥤ C`, 18 | we obtain the class `CartMor` of cartesian morphisms in `E`. 19 | The type `CartMor P` is defined in terms of the predicate `isCartesianMorphism`. 20 | 21 | Given a displayed category structure on a type family `F : C → Type`, and an object `I : C`, we shall refer to 22 | the type `F I` as the "fiber" of `F` at `I`. For a morphism `f : I ⟶ J` in `C`, and objects 23 | `X : F I` and `Y : F J`, we shall refer to a hom-over `g : X ⟶[f] Y` as a "lift" of `f` to `X` and `Y`. 24 | 25 | We prove the following closure properties of the class `CartMor` of cartesian morphisms: 26 | - `cart_id` proves that the identity morphism is cartesian. 27 | - `cart_comp` proves that the composition of cartesian morphisms is cartesian. 28 | - `cart_iso_closed` proves that the class of cartesian morphisms is closed under isomorphisms. 29 | - `cart_pullback` proves that, if `P` preserves pullbacks, then 30 | the pullback of a cartesian morphism is cartesian. 31 | 32 | `instCatCart` provides a category instance for the class of cartesian morphisms, 33 | and `Cart.forget` provides the forgetful functor from the category of cartesian morphisms 34 | to the domain category `E`. 35 | 36 | ## Main declarations 37 | 38 | - `CartLift f Y` is the type of cartesian lifts of a morphism `f` with fixed target `Y`. 39 | - `CoCartLift f X` is the type of cocartesian lifts of a morphism `f` with fixed source `X`. 40 | 41 | Given `g : CartLift f Y`, we have 42 | - `g.1` is the lift of `f` to `Y`. 43 | - `g.homOver : CartLift.toLift.src ⟶[f] Y` is a morphism over `f`. 44 | - `g.homOver.hom` is the underlying morphism of `g.homOver`. 45 | - `g.is_cart` is the proof that `g.homOver` is cartesian. 46 | 47 | Similarly, given `g : CoCartLift f X`, we have 48 | - `g.1` is the lift of `f` from `X`. 49 | - `g.homOver : X ⟶[f] CoCartLift.toCoLift.tgt` is a morphism over `f`. 50 | - `g.homOver.hom` is the underlying morphism of `g.homOver`. 51 | - `g.is_cocart` is the proof that `g.homOver` is cocartesian. 52 | -/ 53 | 54 | set_option autoImplicit true 55 | 56 | namespace CategoryTheory 57 | 58 | open Category Opposite Functor Limits Cones 59 | 60 | variable {C E : Type*} [Category C] {F : C → Type*} [Display F] 61 | 62 | namespace Display 63 | 64 | variable {I J : C} {f : I ⟶ J} {X : F I} {Y : F J} 65 | 66 | /-- A lift `g : X ⟶[f] Y` is cartesian if for every morphism `u : K ⟶ I` 67 | in the base and every hom-over `g' : Z ⟶[u ≫ f] Y` over the composite 68 | `u ≫ f`, there is a unique morphism `k : Z ⟶[u] X` over `u` such that 69 | `k ≫ g = g'`. 70 | ``` 71 | _ _ _ _ _ _ _ _ _ _ _ 72 | / g' \ 73 | | v 74 | Z - - - - > X --------> Y 75 | _ ∃!k _ g _ 76 | | | | 77 | | | | 78 | v v v 79 | K --------> I --------> J 80 | u f 81 | ``` 82 | -/ 83 | class Cartesian (g : X ⟶[f] Y) where 84 | uniq_lift : ∀ ⦃K : C⦄ ⦃Z : F K⦄ (u : K ⟶ I) (g' : Z ⟶[u ≫ f] Y), 85 | Unique {k : Z ⟶[u] X // (k ≫ₒ g) = g'} 86 | 87 | class Cartesian' [Category E] {P : E ⥤ C} {X Y : E} (g : X ⟶ Y) where 88 | uniq_lift : ∀ ⦃Z : E⦄ (u : P.obj Z ⟶ P.obj X) (g' : Z ⟶ Y), 89 | Unique {k : Z ⟶ X // (k ≫ g) = g' ∧ P.map k = u} 90 | 91 | /-- A lift `g : X ⟶[f] Y` is cocartesian if for all morphisms `u` in the 92 | base and `g' : X ⟶[f ≫ u] Z`, there is a unique morphism 93 | `k : Y ⟶[u] Z` over `u` such that `g ≫ k = g'`. 94 | ``` 95 | _ _ _ _ _ _ _ _ _ _ _ 96 | / g' \ 97 | | v 98 | X ------- > Y - - - - > Z 99 | _ g _ ∃!k _ 100 | | | | 101 | | | | 102 | v v v 103 | I --------> J --------> K 104 | f u 105 | ``` 106 | -/ 107 | class CoCartesian (g : X ⟶[f] Y) where 108 | uniq_lift : ∀ ⦃K : C⦄ ⦃Z : F K⦄ (u : J ⟶ K) (g' : X ⟶[f ≫ u] Z), 109 | Unique {k : Y ⟶[u] Z // (g ≫ₒ k) = g'} 110 | 111 | namespace Cartesian 112 | 113 | open Display 114 | 115 | variable (g : X ⟶[f] Y) [Cartesian g] {K : C} {Z : F K} 116 | 117 | /-- `gap g u g'` is the canonical map from a lift `g' : Z ⟶[u ≫ f] X` to a 118 | cartesian lift `g` of `f`. -/ 119 | def gap {u : K ⟶ I} (g' : Z ⟶[u ≫ f] Y) : Z ⟶[u] X := 120 | (Cartesian.uniq_lift (g:= g) (Z:= Z) u g').default.val 121 | 122 | /-- A variant of `gaplift` for `g' : Z ⟶[f'] Y` with casting along `f' = u ≫ f` 123 | baked into the definition. -/ 124 | def gapCast (u : K ⟶ I) {f' : K ⟶ J} (g' : Z ⟶[f'] Y) (w : f' = u ≫ f) : 125 | Z ⟶[u] X := 126 | (Cartesian.uniq_lift (g:= g) (Z:= Z) u (w ▸ g')).default.val 127 | 128 | @[simp] 129 | lemma gap_cast (u : K ⟶ I) {f' : K ⟶ J} (g' : Z ⟶[f'] Y) 130 | (w : f' = u ≫ f) : gapCast g u g' w = gap g (w ▸ g') := rfl 131 | 132 | /-- The composition of the gap lift and the cartesian hom-over is the given hom-over. -/ 133 | @[simp] 134 | lemma gap_prop (u : K ⟶ I) (g' : Z ⟶[u ≫ f] Y) : 135 | ((gap g g') ≫ₒ g) = g' := 136 | (Cartesian.uniq_lift (f:= f) (g:= g) (Z := Z) u g').default.property 137 | 138 | /-- The uniqueness part of the universal property of the gap lift. -/ 139 | @[simp] 140 | lemma gaplift_uniq {u : K ⟶ I} (g' : Z ⟶[u ≫ f] Y) (v : Z ⟶[u] X) 141 | (hv : v ≫ₒ g = g') : v = gap g g' := by 142 | rw [gap, ← (Cartesian.uniq_lift u g').uniq ⟨v,hv⟩] 143 | 144 | /-- The identity hom-over is cartesian. -/ 145 | instance instId {X : F I} : Cartesian (𝟙ₒ X) where 146 | uniq_lift := fun K Z u g' => { 147 | default := ⟨(comp_id u) ▸ g', by simp⟩ 148 | uniq := by aesop 149 | } 150 | 151 | /-- Cartesian based-lifts are closed under composition. -/ 152 | instance instComp {X : F I} {Y : F J} {Z : F K} {f₁ : I ⟶ J} {f₂ : J ⟶ K} 153 | (g₁ : X ⟶[f₁] Y) [Cartesian g₁] (g₂ : Y ⟶[f₂] Z) [Cartesian g₂] : 154 | Cartesian (g₁ ≫ₒ g₂) where 155 | uniq_lift := fun I' W u g' => { 156 | default := ⟨gap g₁ (gap g₂ (assoc u f₁ f₂ ▸ g')), by 157 | rw [← Display.cast_assoc_symm, gap_prop g₁ _ _, gap_prop g₂ _ _] 158 | simp⟩ 159 | uniq := by 160 | intro ⟨l, hl⟩ 161 | rw [Subtype.mk.injEq] 162 | apply gaplift_uniq _ _ _ (gaplift_uniq _ _ _ _) 163 | simp [assoc_cast, hl] } 164 | 165 | end Cartesian 166 | 167 | /-- The type of cartesian lifts of a morphism `f` with fixed target. -/ 168 | class CartLift (f : I ⟶ J) (tgt : F J) extends Lift f tgt where 169 | is_cart : Cartesian homOver 170 | 171 | /--Mere existence of a cartesian lift with fixed target. -/ 172 | def HasCartLift (f : I ⟶ J) (tgt : F J) := Nonempty (CartLift f tgt) 173 | 174 | /-- The type of cocartesian lifts of a morphism `f` with fixed source. -/ 175 | class CoCartLift (f : I ⟶ J) (src : F I) extends CoLift f src where 176 | is_cocart : CoCartesian homOver 177 | 178 | def HasCoCartLift (f : I ⟶ J) (src : F I) := Nonempty (CoCartLift f src) 179 | 180 | end Display 181 | 182 | end CategoryTheory 183 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/Displayed/Chevalley.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | import Mathlib.CategoryTheory.Category.Cat 7 | import Mathlib.CategoryTheory.Comma.Arrow 8 | import Mathlib.CategoryTheory.Opposites 9 | import Mathlib.CategoryTheory.Elements 10 | import Mathlib.CategoryTheory.Equivalence 11 | import Mathlib.CategoryTheory.Grothendieck 12 | import GroupoidModel.FibrationForMathlib.Displayed.Fiber 13 | import GroupoidModel.FibrationForMathlib.Displayed.Basic 14 | import GroupoidModel.FibrationForMathlib.Displayed.Cartesian 15 | 16 | set_option pp.explicit false 17 | --set_option pp.notation true 18 | set_option trace.simps.verbose true 19 | --set_option trace.Meta.synthInstance.instances true 20 | --set_option trace.Meta.synthInstance true 21 | set_option pp.coercions true 22 | 23 | namespace CategoryTheory 24 | 25 | open Category Opposite BasedLift Fiber Display 26 | 27 | namespace Display 28 | 29 | variable {C : Type*} [Category C] (F : C → Type*) [Display F] 30 | 31 | #check CartLift 32 | 33 | end Display 34 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/Displayed/Fiber.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import Mathlib.Tactic.Basic 8 | import Mathlib.Data.Subtype 9 | import Mathlib.Logic.Equiv.Basic 10 | import Mathlib.CategoryTheory.Category.Cat 11 | import Mathlib.CategoryTheory.Comma.Arrow 12 | import Mathlib.CategoryTheory.Opposites 13 | import Mathlib.CategoryTheory.Equivalence 14 | import Mathlib.CategoryTheory.EqToHom 15 | import Mathlib.CategoryTheory.Sigma.Basic 16 | 17 | /-! 18 | # Fibers of a functor 19 | 20 | This files define the type `Fiber` of a functor at a given object in the base category. 21 | 22 | We provide the category instance on the fibers of a functor. 23 | We show that for a functor `P`, the fiber of the opposite functor 24 | `P.op` are isomorphic to the opposites of the fiber categories of `P`. 25 | 26 | ## Notation 27 | 28 | We provide the following notations: 29 | * `P ⁻¹ I` for the fiber of functor `P` at `I`. 30 | -/ 31 | 32 | namespace CategoryTheory 33 | 34 | open Category Opposite Functor 35 | 36 | /-- The fiber of a functor at a given object in the codomain category. -/ 37 | def Fiber {C E : Type*} [Category C] [Category E] (P : E ⥤ C) (I : C) := 38 | {X : E // P.obj X = I} 39 | 40 | /-- The essential fiber of a functor at a given object in the codomain category. -/ 41 | structure EFiber {C E : Type*} [Category C] [Category E] (P : E ⥤ C) (I : C) where 42 | obj : E 43 | iso : P.obj obj ≅ I 44 | 45 | /-- The lax fiber of a functor at a given object in the codomain category. -/ 46 | structure LaxFiber {C E : Type*} [Category C] [Category E] (P : E ⥤ C) (I : C) where 47 | obj : E 48 | from_base : I ⟶ P.obj obj 49 | 50 | notation:75 (name := Fiber_stx) P " ⁻¹ " I => Fiber P I 51 | 52 | notation:75 (name := EFiber_stx) P " ⁻¹ᵉ " I => EFiber P I 53 | 54 | notation:75 (name := LaxFiber_stx) P " ⁻¹ˡ " I => LaxFiber P I 55 | 56 | namespace Fiber 57 | 58 | variable {C E : Type*} [Category C] [Category E] {P : E ⥤ C} 59 | 60 | @[ext] 61 | lemma ext {I : C} (X Y : P⁻¹ I) (h : X.1 = Y.1) : X = Y := by 62 | cases X 63 | cases Y 64 | simp at h 65 | subst h 66 | rfl 67 | 68 | /-- Coercion from the fiber to the domain. -/ 69 | instance {I : C} : CoeOut (P⁻¹ I) E where 70 | coe := fun x => x.1 71 | 72 | variable {I : C} 73 | 74 | lemma coe_mk {X : E} (h : P.obj X = I) : ((⟨X, h⟩ : P⁻¹ I) : E) = X := rfl 75 | 76 | lemma mk_coe {X : P⁻¹ I} : ⟨X.1, X.2⟩ = X := rfl 77 | 78 | lemma coe_inj (X Y : P⁻¹ I) : (X : E) = Y ↔ X = Y := Subtype.coe_inj 79 | 80 | lemma over (X : P⁻¹ I) : P.obj X = I := X.2 81 | 82 | lemma over_eq (X Y : P⁻¹ I) : P.obj X = P.obj Y := by 83 | simp [over] 84 | 85 | /-- A tautological construction of an element in the fiber of the image of a domain element. -/ 86 | @[simp] 87 | def tauto (X : E) : P⁻¹ (P.obj X) := ⟨X, rfl⟩ 88 | 89 | /-- Regarding an element of the domain as an element in the Fiber of its image. -/ 90 | instance instTautoFib (X : E) : CoeDep (E) (X) (P ⁻¹ (P.obj X) ) where 91 | coe := tauto X 92 | 93 | lemma tauto_over (X : E) : (tauto X : P⁻¹ (P.obj X)).1 = X := rfl 94 | 95 | /-- The total space of a map. -/ 96 | @[ext] 97 | structure Total where 98 | /-- The base object in `C` -/ 99 | base : C 100 | /-- The object in the fiber of the base object. -/ 101 | fiber : P⁻¹ base 102 | 103 | /-- The category structure on the fibers of a functor. -/ 104 | instance category {I : C} : Category (P ⁻¹ I) where 105 | Hom X Y := {g : (X : E) ⟶ (Y : E) // P.map g = eqToHom (over_eq X Y)} 106 | id X := ⟨𝟙 (X : E), by simp only [Functor.map_id, eqToHom_refl]⟩ 107 | comp g h := ⟨g.1 ≫ h.1, by rw [Functor.map_comp, g.2, h.2, eqToHom_trans]⟩ 108 | 109 | lemma id_coe {I : C} (X : P⁻¹ I) : (𝟙 X : X ⟶ X).val = 𝟙 (X : E) := rfl 110 | 111 | lemma comp_coe {c : C} {X Y Z : P⁻¹ c} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).1 = f.1 ≫ g.1 := rfl 112 | 113 | @[simp, aesop forward safe] 114 | lemma fiber_hom_over {I : C} (X Y : P⁻¹ I) (g : X ⟶ Y) : P.map g.1 = eqToHom (Fiber.over_eq X Y) := g.2 115 | 116 | /-- The forgetful functor from a fiber to the domain category. -/ 117 | @[simps] 118 | def forget {I : C} : (P⁻¹ I) ⥤ E where 119 | obj := fun x => x 120 | map := @fun x y f => f.1 121 | 122 | lemma fiber_comp_obj {c: C} (X Y Z : P⁻¹ c) (f: X ⟶ Y) (g: Y ⟶ Z) : 123 | (f ≫ g).1 = f.1 ≫ g.1 := rfl 124 | 125 | @[simp] 126 | lemma fiber_comp_obj_eq {c: C} {X Y Z : P⁻¹ c} 127 | {f: X ⟶ Y} {g: Y ⟶ Z} {h : X ⟶ Z} : 128 | (f ≫ g = h) ↔ f.1 ≫ g.1 = h.1 := by 129 | constructor 130 | · intro H 131 | cases H 132 | rfl 133 | · intro H 134 | cases f 135 | cases g 136 | cases h 137 | simp at H 138 | subst H 139 | rfl 140 | 141 | @[simp] 142 | lemma fiber_id_obj {I : C} (X : P⁻¹ I) : (𝟙 X : X ⟶ X).val = 𝟙 (X : E) := rfl 143 | 144 | /- Two morphisms in a fiber P⁻¹ c are equal if their underlying morphisms in E are equal. -/ 145 | lemma hom_ext {I : C} {X Y : P⁻¹ I} {f g : X ⟶ Y} (h : f.1 = g.1) : f = g := by 146 | cases f 147 | cases g 148 | simp at h 149 | subst h 150 | rfl 151 | 152 | @[simps] 153 | lemma is_iso {I : C} {X Y : P⁻¹ I} (f : X ⟶ Y) : IsIso f ↔ IsIso f.1 := 154 | ⟨fun h ↦ (asIso f) |> forget.mapIso |> Iso.isIso_hom, fun h ↦ ⟨⟨⟨inv f.1, by simp⟩, by simp⟩⟩⟩ 155 | 156 | end Fiber 157 | namespace EFiber 158 | 159 | variable {C E : Type*} [Category C] [Category E] {P : E ⥤ C} 160 | 161 | /-- Coercion from the fiber to the domain. -/ 162 | instance {I : C} : CoeOut (P⁻¹ᵉ I) E where 163 | coe := fun X => X.1 164 | 165 | /-- A tautological construction of an element in the fiber of the image of a domain element. -/ 166 | @[simps!] 167 | def tauto (X : E) : EFiber P (P.obj X) := ⟨X , Iso.refl _⟩ 168 | 169 | /-- Regarding an element of the domain as an element in the essential fiber of its image. -/ 170 | instance instTautoFib (X : E) : CoeDep (E) (X) (EFiber P (P.obj X) ) where 171 | coe := tauto X 172 | 173 | /-- The category structure on the essential fibers of a functor. -/ 174 | instance category {I : C} : Category (P⁻¹ᵉ I) where 175 | Hom X Y := {g : (X : E) ⟶ (Y : E) // P.map g = X.iso.hom ≫ Y.iso.inv} 176 | id X := ⟨𝟙 (X : E), by simp only [map_id, Iso.hom_inv_id]⟩ 177 | comp {X Y Z} g h := ⟨g.1 ≫ h.1, by 178 | simp [Functor.map_comp] 179 | calc 180 | P.map g.1 ≫ P.map h.1 = X.iso.hom ≫ Y.iso.inv ≫ Y.iso.hom ≫ Z.iso.inv := by 181 | rw [g.2, h.2] -- simp only not working here? 182 | simp 183 | _ = X.iso.hom ≫ Z.iso.inv := by simp⟩ 184 | 185 | end EFiber 186 | 187 | namespace Fiber.Op 188 | 189 | open Fiber 190 | 191 | variable {C E : Type*} [Category C] [Category E] {P : E ⥤ C} 192 | 193 | @[simp] 194 | lemma obj_over {I : C} (X : P.op ⁻¹ (op I)) : P.obj (unop (X.1)) = I := by 195 | cases' X with e h 196 | simpa [Functor.op] using h 197 | 198 | /-- The Fibers of the opposite functor `P.op` are in bijection with the the Fibers of `P`. -/ 199 | @[simps] 200 | def equiv (I : C) : (P.op ⁻¹ (op I)) ≃ (P⁻¹ I) where 201 | toFun := fun X => (⟨unop X.1, by rw [obj_over] ⟩) 202 | invFun := fun X => ⟨op X.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ 203 | left_inv := fun X ↦ rfl 204 | right_inv := fun X ↦ rfl 205 | 206 | /-- The Fibers of the opposite functor `P.op` are isomorphic to the the Fibers of `P`. -/ 207 | @[simps] 208 | def iso (I : C) : (P.op ⁻¹ (op I)) ≅ (P⁻¹ I) where 209 | hom := fun X => (⟨unop X.1, by rw [obj_over] ⟩) 210 | inv := fun X => ⟨op X.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ 211 | 212 | lemma unop_op_map {I : C} {X Y : (P.op) ⁻¹ (op I)} (f : X ⟶ Y) : 213 | unop (P.op.map f.1) = P.map f.1.unop := rfl 214 | 215 | lemma op_map_unop {I : C} {X Y : (P ⁻¹ I)ᵒᵖ} (f : X ⟶ Y) : 216 | P.op.map (f.unop.1.op) = (P.map (f.unop.1)).op := rfl 217 | 218 | /-- The fiber categories of the opposite functor `P.op` are isomorphic 219 | to the opposites of the fiber categories of `P`. -/ 220 | def Iso (P : E ⥤ C) (I : C) : Cat.of (P.op ⁻¹ (op I) ) ≅ Cat.of ((P⁻¹ I)ᵒᵖ) where 221 | hom := { 222 | obj := fun X => op (⟨unop X.1, by rw [obj_over] ⟩) 223 | map := @fun X Y f => ⟨f.1.unop, by dsimp; rw [← (unop_op_map f), f.2]; apply eqToHom_unop ⟩ 224 | } 225 | inv := { 226 | obj := fun X => ⟨op X.unop.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ 227 | map := @fun X Y f => ⟨(f.unop.1).op , by dsimp; simp [Functor.op_map]⟩ 228 | } 229 | hom_inv_id := rfl 230 | inv_hom_id := rfl 231 | 232 | end Fiber.Op 233 | 234 | end CategoryTheory 235 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/Displayed/widget_test.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import Mathlib.CategoryTheory.Category.Preorder 8 | import GroupoidModel.FibrationForMathlib.Displayed.Fiber 9 | 10 | import ProofWidgets.Component.Panel.Basic 11 | import ProofWidgets.Component.PenroseDiagram 12 | import Mathlib.Tactic.Widget.CommDiag 13 | import ProofWidgets.Component.Panel.SelectionPanel 14 | import ProofWidgets.Component.Panel.GoalTypePanel 15 | 16 | /-! 17 | # Widget test for fibred category theory 18 | -/ 19 | 20 | namespace CategoryTheory 21 | 22 | open Category CategoryTheory ProofWidgets 23 | 24 | variable {C : Type*} [Category C] (F : C → Type*) 25 | 26 | show_panel_widgets [local GoalTypePanel] 27 | 28 | /-- Transporting a morphism `f : I ⟶ J` along equalities `w : I = I'` and `w' : J = J'`. 29 | Note: It might be a good idea to add this to eqToHom file. -/ 30 | @[simp] 31 | def eqToHomMap {I I' J J' : C} (w : I = I') (w' : J = J') (f : I ⟶ J) : I' ⟶ J' := 32 | w' ▸ (w ▸ f) --eqToHom (w.symm) ≫ f ≫ eqToHom w' 33 | 34 | /-- 35 | The diagram below commutes: 36 | ``` 37 | I --eqToHom w --> J 38 | | | 39 | f | | eqToHomMap w w' f 40 | v v 41 | I' --eqToHom w'-> J' 42 | ``` 43 | -/ 44 | @[simp] 45 | lemma eqToHomMap_naturality' {I I' J J' : C} {w : I = I'} {w' : J = J'} (f : I ⟶ J) : 46 | eqToHom w ≫ eqToHomMap w w' f = f ≫ eqToHom w' := by 47 | subst w' w 48 | simp 49 | 50 | /-- Transporting a morphism `f : I ⟶ J` along equalities `w : I = I'` and `w' : J = J'`. 51 | Note: It might be a good idea to add this to eqToHom file. -/ 52 | @[simp] 53 | def eqToHomMap' {I I' J J' : C} (w : I = I') (w' : J = J') (f : I ⟶ J) : I' ⟶ J' := by 54 | let a : I' ⟶ J := eqToHom (w.symm) ≫ f 55 | let b : I' ⟶ J' := a ≫ eqToHom w' 56 | exact b 57 | 58 | class DisplayStruct where 59 | /-- The type of morphisms indexed over morphisms of `C`. -/ 60 | HomOver : ∀ {I J : C}, (I ⟶ J) → F I → F J → Type* 61 | /-- The identity morphism overlying the identity morphism of `C`. -/ 62 | id_over : ∀ {I : C} (X : F I), HomOver (𝟙 I) X X 63 | /-- Composition of morphisms overlying composition of morphisms of `C`. -/ 64 | comp_over : ∀ {I J K : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {X : F I} {Y : F J} 65 | {Z : F K}, HomOver f₁ X Y → HomOver f₂ Y Z → HomOver (f₁ ≫ f₂) X Z 66 | 67 | notation X " ⟶[" f "] " Y => DisplayStruct.HomOver f X Y 68 | notation " 𝟙ₗ " => DisplayStruct.id_over 69 | scoped infixr:80 " ≫ₗ " => DisplayStruct.comp_over 70 | 71 | class Display extends DisplayStruct F where 72 | id_comp_cast {I J : C} {f : I ⟶ J} {X : F I} {Y : F J} 73 | (g : X ⟶[f] Y) : (𝟙ₗ X) ≫ₗ g = (id_comp f).symm ▸ g := by aesop_cat 74 | comp_id_cast {I J : C} {f : I ⟶ J} {X : F I} {Y : F J} 75 | (g : X ⟶[f] Y) : g ≫ₗ (𝟙ₗ Y) = ((comp_id f).symm ▸ g) := by aesop_cat 76 | assoc_cast {I J K L : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {f₃ : K ⟶ L} {X : F I} 77 | {Y : F J} {Z : F K} {W : F L} (g₁ : X ⟶[f₁] Y) 78 | (g₂ : Y ⟶[f₂] Z) (g₃ : Z ⟶[f₃] W) : 79 | (g₁ ≫ₗ g₂) ≫ₗ g₃ = (assoc f₁ f₂ f₃).symm ▸ (g₁ ≫ₗ (g₂ ≫ₗ g₃)) := by aesop_cat 80 | 81 | attribute [simp] Display.id_comp_cast Display.comp_id_cast Display.assoc_cast 82 | attribute [trans] Display.assoc_cast 83 | 84 | variable {E : Type*} [Category E] {P : E ⥤ C} 85 | 86 | /-- The type of lifts of a given morphism in the base 87 | with fixed source and target in the Fibres of the domain and codomain respectively.-/ 88 | structure BasedLift {I J : C} (f : I ⟶ J) (X : P⁻¹ I) (Y : P⁻¹ J) where 89 | hom : (X : E) ⟶ (Y : E) 90 | over_eq : (P.map hom) ≫ eqToHom (Y.2) = eqToHom (X.2) ≫ f 91 | 92 | /-- 93 | The structure of based-lifts up to an isomorphism of the domain objects in the base. 94 | ``` g 95 | X --------------------> Y 96 | _ - 97 | | | | 98 | | | | 99 | v v v 100 | P.obj X ---------> I ---------> J 101 | ≅ f 102 | ``` 103 | -/ 104 | structure EBasedLift {I J : C} (f : I ⟶ J) (X : EFiber P I) (Y : EFiber P J) where 105 | hom : X.obj ⟶ Y.obj 106 | iso_over_eq : (P.map hom) ≫ Y.iso.hom = X.iso.hom ≫ f := by aesop_cat 107 | 108 | attribute [reassoc] EBasedLift.iso_over_eq 109 | 110 | namespace BasedLift 111 | 112 | variable {E : Type*} [Category E] {P : E ⥤ C} 113 | 114 | @[simp] 115 | lemma over_base {I J : C} {f : I ⟶ J} {X : P⁻¹ I} {Y : P⁻¹ J} (g : BasedLift f X Y) : 116 | P.map g.hom = eqToHom (X.2) ≫ f ≫ (eqToHom (Y.2).symm) := by 117 | simp only [← Category.assoc _ _ _, ← g.over_eq, assoc, eqToHom_trans, eqToHom_refl, comp_id] 118 | 119 | /-- The identity based-lift. -/ 120 | @[simps!] 121 | def id {I : C} (X : P⁻¹ I) : BasedLift (𝟙 I) X X := ⟨𝟙 _, by simp⟩ 122 | 123 | /-- The composition of based-lifts -/ 124 | @[simps] 125 | def comp {I J K : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {X : P⁻¹ I} {Y : P⁻¹ J} {Z : P⁻¹ K} 126 | (g₁ : BasedLift f₁ X Y) (g₂ : BasedLift f₂ Y Z) : 127 | BasedLift (f₁ ≫ f₂) X Z := by 128 | with_panel_widgets [SelectionPanel] 129 | refine ⟨g₁.hom ≫ g₂.hom, ?_⟩ 130 | have := by 131 | calc 132 | P.map (g₁.hom ≫ g₂.hom) = P.map g₁.hom ≫ P.map g₂.hom := by 133 | rw [P.map_comp] 134 | _ = (eqToHom (X.2) ≫ f₁ ≫ eqToHom (Y.2).symm) ≫ P.map g₂.hom := by 135 | rw [g₁.over_base] 136 | _ = eqToHom (X.2) ≫ f₁ ≫ (eqToHom (Y.2).symm ≫ P.map g₂.hom) := by 137 | simp only [assoc] 138 | _ = eqToHom (X.2) ≫ f₁ ≫ (eqToHom (Y.2).symm ≫ eqToHom (Y.2) ≫ f₂ ≫ eqToHom (Z.2).symm) := by 139 | rw [g₂.over_base] 140 | simp [this] 141 | 142 | @[simps!] 143 | def cast {I J : C} {f f' : I ⟶ J} {X : P⁻¹ I} {Y : P⁻¹ J} (w : f = f') 144 | (g : BasedLift f X Y) : BasedLift f' X Y := ⟨g.hom, by rw [←w, g.over_eq]⟩ 145 | 146 | end BasedLift 147 | namespace EBasedLift 148 | 149 | @[simp] 150 | lemma iso_over_eq' {I J : C} {f : I ⟶ J} {X : EFiber P I} {Y : EFiber P J} (g : EBasedLift f X Y) : 151 | P.map g.hom = X.iso.hom ≫ f ≫ Y.iso.inv := by 152 | simpa using g.iso_over_eq_assoc (Y.iso.inv) 153 | 154 | def id {I : C} (X : EFiber P I) : EBasedLift (𝟙 I) X X where 155 | hom := 𝟙 _ 156 | 157 | def comp {I J K : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {X : EFiber P I} {Y : EFiber P J} {Z : EFiber P K} 158 | (g₁ : EBasedLift f₁ X Y) (g₂ : EBasedLift f₂ Y Z) : 159 | EBasedLift (f₁ ≫ f₂) X Z := by 160 | with_panel_widgets [SelectionPanel] 161 | refine ⟨g₁.hom ≫ g₂.hom, ?_⟩ 162 | have := by 163 | calc 164 | P.map (g₁.hom ≫ g₂.hom) = P.map (g₁.hom) ≫ P.map (g₂.hom) := by rw [P.map_comp] 165 | _ = (X.iso.hom ≫ f₁ ≫ Y.iso.inv) ≫ P.map (g₂.hom) := by rw [g₁.iso_over_eq'] 166 | _ = X.iso.hom ≫ f₁ ≫ (Y.iso.inv ≫ P.map (g₂.hom)) := by 167 | simp only [iso_over_eq', assoc, Iso.inv_hom_id_assoc] 168 | _ = X.iso.hom ≫ f₁ ≫ (Y.iso.inv ≫ Y.iso.hom ≫ f₂ ≫ Z.iso.inv) := by rw [g₂.iso_over_eq'] 169 | _ = X.iso.hom ≫ f₁ ≫ (𝟙 J ≫ f₂ ≫ Z.iso.inv) := by rw [Iso.inv_hom_id_assoc, id_comp] 170 | _ = X.iso.hom ≫ f₁ ≫ f₂ ≫ Z.iso.inv := by rw [id_comp] 171 | simp [this] 172 | 173 | end EBasedLift 174 | 175 | end CategoryTheory 176 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/Basic.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import Mathlib.CategoryTheory.Category.Cat 8 | import Mathlib.CategoryTheory.Comma.Arrow 9 | import Mathlib.CategoryTheory.Opposites 10 | import Mathlib.CategoryTheory.Equivalence 11 | import Mathlib.CategoryTheory.EqToHom 12 | import Mathlib.CategoryTheory.Sigma.Basic 13 | import GroupoidModel.FibrationForMathlib.Data.Fiber 14 | 15 | /-! 16 | # Basic 17 | 18 | We provide the category instance on the fibers of a functor. 19 | We show that for a functor `P`, the fiber of the opposite functor 20 | `P.op` are isomorphic to the opposites of the fiber categories of `P`. 21 | 22 | We provide the following notations: 23 | * `P ⁻¹ c` for the fiber of `P` at `c`. 24 | -/ 25 | 26 | set_option autoImplicit true 27 | 28 | namespace CategoryTheory 29 | 30 | open Category Opposite Functor Fiber 31 | 32 | /-- The fiber of a functor at a given object in the base category. -/ 33 | abbrev FiberCat {C E : Type*} [Category C] [Category E] (P : E ⥤ C) (c : C) := Fiber P.obj c 34 | notation:75 (name := FiberCat_stx) P " ⁻¹ " c => FiberCat P c 35 | 36 | namespace FiberCat 37 | variable {C E : Type*} [Category C] [Category E] {P : E ⥤ C} 38 | 39 | /-- The category structure on the fibers of a functor. -/ 40 | instance instCategoryFiber {c : C} : Category (P ⁻¹ c) where 41 | Hom x y := { g : (x : E) ⟶ (y : E) // P.map g = eqToHom (over_eq x y) } 42 | id x := ⟨𝟙 (x : E), by simp only [Functor.map_id, eqToHom_refl]⟩ 43 | comp g h := ⟨g.1 ≫ h.1, by simp only [Functor.map_comp, Fiber.over, eqToHom_trans]⟩ 44 | 45 | lemma id_coe {c : C} (x : P⁻¹ c) : (𝟙 x : x ⟶ x).val = 𝟙 (x : E) := rfl 46 | 47 | lemma comp_coe {c : C} {x y z : P⁻¹ c} (f : x ⟶ y) (g : y ⟶ z) : (f ≫ g).1 = f.1 ≫ g.1 := rfl 48 | 49 | @[simp, aesop forward safe] 50 | lemma fiber_hom_over {c: C} (x y : P⁻¹ c) (g : x ⟶ y) : 51 | P.map g.1 = eqToHom (Fiber.over_eq x y) := g.2 52 | 53 | /-- The forgetful functor from a fiber to the domain category. -/ 54 | @[simps] 55 | def forget {c : C} : (P⁻¹ c) ⥤ E where 56 | obj := fun x => x 57 | map := @fun x y f => f.1 58 | 59 | lemma fiber_comp_obj {c: C} (x y z : P⁻¹ c) (f: x ⟶ y) (g: y ⟶ z) : 60 | (f ≫ g).1 = f.1 ≫ g.1 := rfl 61 | 62 | @[simp] 63 | lemma fiber_comp_obj_eq {c: C} {x y z : P⁻¹ c} {f: x ⟶ y} {g: y ⟶ z} {h : x ⟶ z} : 64 | (f ≫ g = h) ↔ f.1 ≫ g.1 = h.1 := by 65 | constructor 66 | · intro H; cases H; rfl 67 | · intro H; cases f; cases g; cases h; simp at H; subst H; rfl 68 | 69 | @[simp] 70 | lemma fiber_id_obj {c: C} (x : P⁻¹ c) : (𝟙 x : x ⟶ x).val = 𝟙 (x : E) := rfl 71 | 72 | /- Two morphisms in a fiber P⁻¹ c are equal if their underlying morphisms in E are equal. -/ 73 | lemma hom_ext {c : C} {x y : P⁻¹ c} {f g : x ⟶ y} (h : f.1 = g.1) : f = g := by 74 | cases f; cases g; simp at h; subst h; rfl 75 | 76 | @[simps] 77 | lemma is_iso {c : C} {x y : P⁻¹ c} (f : x ⟶ y) : IsIso f ↔ IsIso f.1 := 78 | ⟨fun h ↦ (asIso f) |> forget.mapIso |> Iso.isIso_hom, 79 | fun h ↦ ⟨⟨⟨inv f.1, by simp⟩, by simp⟩⟩⟩ 80 | 81 | namespace Op 82 | 83 | @[simp] 84 | lemma obj_over (x : P.op ⁻¹ (op c)) : P.obj (unop (x.1)) = c := by 85 | cases' x with e h 86 | simpa [Functor.op] using h 87 | 88 | /-- The fibres of the opposite functor `P.op` are in bijection with the the fibres of `P`. -/ 89 | @[simps] 90 | def equiv (c : C) : (P.op ⁻¹ (op c)) ≃ (P⁻¹ c) where 91 | toFun := fun x => (⟨unop x.1, by rw [obj_over] ⟩) 92 | invFun := fun x => ⟨op x.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ 93 | left_inv := fun _ ↦ rfl 94 | right_inv := fun _ ↦ rfl 95 | 96 | /-- The fibres of the opposite functor `P.op` are isomorphic 97 | to the the fibres of `P`. -/ 98 | @[simps] 99 | def iso (c : C) : (P.op ⁻¹ (op c)) ≅ (P⁻¹ c) where 100 | hom := fun x => (⟨unop x.1, by rw [obj_over] ⟩) -- ⟨x.obj, by simp⟩ 101 | inv := fun x => ⟨op x.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ -- aesop generated 102 | 103 | @[simp] 104 | lemma unop_op_map {c : C} {x y : (P.op) ⁻¹ (op c)} (f : x ⟶ y) : 105 | unop (P.op.map f.1) = P.map f.1.unop := rfl 106 | 107 | @[simp] 108 | lemma op_map_unop {c : C} {x y : (P ⁻¹ c)ᵒᵖ} (f : x ⟶ y) : P.op.map (f.unop.1.op) = (P.map (f.unop.1)).op := rfl 109 | 110 | /-- The fiber categories of the opposite functor `P.op` are isomorphic 111 | to the opposites of the fiber categories of `P`. -/ 112 | def Iso (P : E ⥤ C) (c : C) : Cat.of (P.op ⁻¹ (op c) ) ≅ Cat.of ((P⁻¹ c)ᵒᵖ) where 113 | hom := { 114 | obj := fun x => op (⟨unop x.1, by rw [obj_over] ⟩) 115 | map := @fun x y f => ⟨f.1.unop, by dsimp; rw [← (unop_op_map f), f.2]; apply eqToHom_unop ⟩ 116 | } 117 | inv := { 118 | obj := fun x => ⟨op x.unop.1 , by simp only [Functor.op_obj, unop_op, Fiber.over]⟩ 119 | map := @fun x y f => ⟨(f.unop.1).op , by dsimp; simp [Functor.op_map]⟩ 120 | } 121 | hom_inv_id := rfl 122 | inv_hom_id := rfl 123 | 124 | end Op 125 | end FiberCat 126 | 127 | end CategoryTheory 128 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/Display_test.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import GroupoidModel.FibrationForMathlib.FibredCats.Basic 8 | 9 | /-! 10 | # Displayed Category Of A Functor 11 | 12 | Given a type family `F : C → Type*` on a category `C` we then define the displayed category `Display F`. 13 | 14 | For a functor `P : E ⥤ C`, we define the structure `BasedLift f src tgt` as the type of 15 | lifts in `E` of a given morphism `f : c ⟶ d` in `C` which have a fixed source `src` and a 16 | fixed target `tgt` in the fibers of `c` and `d` respectively. We call the elements of 17 | `BasedLift f src tgt` based-lifts of `f` with source `src` and target `tgt`. 18 | 19 | We also provide various useful constructors for based-lifts: 20 | * `BasedLift.tauto` regards a morphism `g` of the domain category `E` as a 21 | tautological based-lift of its image `P.map g`. 22 | * `BasedLift.id` and `BasedLift.comp` provide the identity and composition of 23 | based-lifts, respectively. 24 | * We can cast a based-lift along an equality of the base morphisms using the equivalence `BasedLift.cast`. 25 | 26 | We provide the following notations: 27 | * `X ⟶[f] Y` for `DisplayStruct.HomOver f x y` 28 | * `f ≫ₗ g` for `DisplayStruct.comp_over f g` 29 | 30 | We show that for a functor `P`, the type `BasedLift P` induces a display category structure on the fiber family `fun c => P⁻¹ c`. 31 | 32 | -/ 33 | 34 | set_option autoImplicit true 35 | 36 | namespace CategoryTheory 37 | 38 | open Category 39 | 40 | variable {C : Type*} [Category C] (F : C → Type*) 41 | 42 | /-- Cast an element of a fiber along an equality of the base objects. -/ 43 | def fiberCast {I I' : C} (w : I = I') (X : F I) : F I' := 44 | w ▸ X 45 | 46 | /-- Transporting a morphism `f : I ⟶ J` along equalities `w : I = I'` and `w' : J = J'`. 47 | Note: It might be a good idea to add this to eqToHom file. -/ 48 | @[simp] 49 | def eqToHomMap {I I' J J' : C} (w : I = I') (w' : J = J') (f : I ⟶ J) : I' ⟶ J' := 50 | w' ▸ (w ▸ f) 51 | --eqToHom (w.symm) ≫ f ≫ eqToHom w' 52 | 53 | @[simp] 54 | def eqToHomMapId {I I' : C} (w : I = I') : w ▸ 𝟙 I = 𝟙 I' := by 55 | subst w 56 | rfl 57 | 58 | @[simp] 59 | lemma eqToHomMap_naturality {I I' J J' : C} {w : I = I'} {w' : J = J'} (f : I ⟶ J) : 60 | eqToHom w ≫ eqToHomMap w w' f = f ≫ eqToHom w' := by 61 | subst w' w 62 | simp 63 | 64 | @[simp] 65 | lemma fiber_cast_trans (X : F I) {w : I = I'} {w' : I' = I''} {w'' : I = I''} : 66 | w' ▸ (w ▸ X) = w'' ▸ X := by 67 | subst w' 68 | rfl 69 | 70 | lemma fiber_cast_cast (X : F I) {w : I = I'} {w' : I' = I} : w' ▸ w ▸ X = X := by 71 | simp only [fiber_cast_trans] 72 | 73 | class DisplayStruct where 74 | /-- The type of morphisms indexed over morphisms of `C`. -/ 75 | HomOver : ∀ {I J : C}, (I ⟶ J) → F I → F J → Type* 76 | /-- The identity morphism overlying the identity morphism of `C`. -/ 77 | id_over : ∀ {I : C} (X : F I), HomOver (𝟙 I) X X 78 | /-- Composition of morphisms overlying composition of morphisms of `C`. -/ 79 | comp_over : ∀ {I J K : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {X : F I} {Y : F J} {Z : F K}, HomOver f₁ X Y → HomOver f₂ Y Z → HomOver (f₁ ≫ f₂) X Z 80 | 81 | notation X " ⟶[" f "] " Y => DisplayStruct.HomOver f X Y 82 | notation " 𝟙ₗ " => DisplayStruct.id_over 83 | scoped infixr:80 " ≫ₗ " => DisplayStruct.comp_over 84 | 85 | variable {F} 86 | 87 | class DisplayStruct.CastEq [DisplayStruct F] {I J : C} {f f' : I ⟶ J} {X : F I} {Y : F J} 88 | (g : X ⟶[f] Y) (g' : X ⟶[f'] Y) : Prop where 89 | base_eq : f = f' 90 | cast_eq : base_eq ▸ g = g' 91 | 92 | scoped infixr:50 " =▸= " => DisplayStruct.CastEq 93 | 94 | variable (F) 95 | 96 | class Display extends DisplayStruct F where 97 | id_comp_cast {I J : C} {f : I ⟶ J} {X : F I} {Y : F J} 98 | (g : X ⟶[f] Y) : (𝟙ₗ X) ≫ₗ g =▸= g := by aesop_cat 99 | comp_id_cast {I J : C} {f : I ⟶ J} {X : F I} {Y : F J} 100 | (g : X ⟶[f] Y) : g ≫ₗ (𝟙ₗ Y) =▸= g := by aesop_cat 101 | assoc_cast {I J K L : C} {f₁ : I ⟶ J} {f₂ : J ⟶ K} {f₃ : K ⟶ L} {X : F I} 102 | {Y : F J} {Z : F K} {W : F L} (g₁ : X ⟶[f₁] Y) 103 | (g₂ : Y ⟶[f₂] Z) (g₃ : Z ⟶[f₃] W) : 104 | (g₁ ≫ₗ g₂) ≫ₗ g₃ =▸= (g₁ ≫ₗ (g₂ ≫ₗ g₃)) := by aesop_cat 105 | 106 | attribute [simp] Display.id_comp_cast Display.comp_id_cast Display.assoc_cast 107 | attribute [trans] Display.assoc_cast 108 | 109 | namespace HomOver 110 | 111 | open Display 112 | 113 | variable {F} 114 | variable [Display F] {I J : C} 115 | 116 | @[simp] 117 | def cast {f f' : I ⟶ J} {X : F I} {Y : F J} (w : f = f') (g : X ⟶[f] Y) : X ⟶[f'] Y := 118 | w ▸ g 119 | 120 | @[simp] 121 | lemma cast_trans {f f' f'' : I ⟶ J} {X : F I} {Y : F J} {w : f = f'} {w' : f' = f''} 122 | (g : X ⟶[f] Y) : w' ▸ w ▸ g = (w.trans w') ▸ g := by 123 | subst w' 124 | rfl 125 | 126 | lemma cast_unique {f f' : I ⟶ J} {X : F I} {Y : F J} {w w' : f = f'} (g : X ⟶[f] Y) : 127 | w ▸ g = w' ▸ g := by 128 | rfl 129 | 130 | lemma cast_cast {f f' : I ⟶ J} {X : F I} {Y : F J} (w : f = f') (w' : f' = f) (g : X ⟶[f'] Y) : 131 | w' ▸ w ▸ g = g := by 132 | simp only [cast_trans] --subst w'; rfl 133 | 134 | lemma comp_id_eq_cast_id_comp {f : I ⟶ J} {X : F I} {Y : F J} (g : X ⟶[f] Y) : 135 | g ≫ₗ 𝟙ₗ Y =▸= (𝟙ₗ X ≫ₗ g) where 136 | base_eq := (comp_id f).trans (id_comp f).symm 137 | cast_eq := by sorry -- rw [comp_id_cast] 138 | 139 | --by 140 | --use (comp_id f).trans (id_comp f).symm 141 | --simp only [comp_id_cast, cast, id_comp_cast, comp_id, cast_trans] 142 | 143 | /-- `EqToHom w X` is a hom-over `eqToHom w` from `X` to `w ▸ X`. -/ 144 | def eqToHom (w : I = I') (X : F I) : X ⟶[eqToHom w] (w ▸ X) := by 145 | subst w 146 | exact 𝟙ₗ X 147 | 148 | @[simp] 149 | def eqToHomMap (w : I = I') (w' : J = J') {f : I ⟶ J} {X : F I } {Y : F J} (g : X ⟶[f] Y) : 150 | (w ▸ X) ⟶[eqToHomMap w w' f] (w' ▸ Y) := by 151 | subst w 152 | subst w' 153 | exact g 154 | 155 | @[simp] 156 | def eqToHomMapId (w : I = I') {X : F I } {Y : F I} (g : X ⟶[𝟙 I] Y) : 157 | (w ▸ X) ⟶[𝟙 I'] (w ▸ Y) := by 158 | subst w 159 | exact g 160 | 161 | lemma eqToHom_naturality {X : F I} {Y : F J} (w : I = I') (w' : J = J') (f : I ⟶ J) (g : X ⟶[f] Y) : 162 | g ≫ₗ eqToHom w' Y = cast (eqToHomMap_naturality f) (eqToHom w X ≫ₗ eqToHomMap w w' g) := by 163 | subst w' w 164 | simp only [eqToHom, comp_id_eq_cast_id_comp, cast] 165 | -- rfl 166 | sorry 167 | 168 | @[simps!] 169 | def castEquiv {I J : C} {f f' : I ⟶ J} {X : F I} {Y : F J} (w : f = f') : (X ⟶[f] Y) ≃ (X ⟶[f'] Y) where 170 | toFun := fun g ↦ w ▸ g 171 | invFun := fun g ↦ w.symm ▸ g 172 | left_inv := by aesop_cat 173 | right_inv := by aesop_cat 174 | 175 | #check HEq 176 | 177 | end HomOver 178 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/Fibration.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | import Mathlib.CategoryTheory.Category.Cat 7 | import Mathlib.CategoryTheory.Comma.Arrow 8 | import Mathlib.CategoryTheory.Opposites 9 | import Mathlib.CategoryTheory.Elements 10 | import Mathlib.CategoryTheory.Equivalence 11 | import Mathlib.CategoryTheory.Grothendieck 12 | import GroupoidModel.FibrationForMathlib.FibredCats.Basic 13 | import GroupoidModel.FibrationForMathlib.FibredCats.CartesianLift 14 | import GroupoidModel.FibrationForMathlib.FibredCats.VerticalLift 15 | 16 | set_option pp.explicit false 17 | --set_option pp.notation true 18 | set_option trace.simps.verbose true 19 | --set_option trace.Meta.synthInstance.instances true 20 | --set_option trace.Meta.synthInstance true 21 | set_option pp.coercions true 22 | 23 | /- 24 | namespace CategoryTheory 25 | 26 | open Category Opposite BasedLift Fiber FiberCat 27 | 28 | variable {C E : Type*} [Category C] [Category E] 29 | 30 | /-- A Cloven fibration provides for every morphism `c ⟶ d` in the base and `y : P⁻¹ d` a cartesian lift in the total category. -/ 31 | class ClovenFibration (P : E ⥤ C) where 32 | /-- A lift function which assigns to a morphism `f` and an 33 | object in the fiber -/ 34 | lift {c d : C} (f : c ⟶ d) (y : P⁻¹ d) : CartLift (P:= P) f y 35 | 36 | class ClovenwFibration (P : E ⥤ C) where 37 | 38 | 39 | class Fibration (P : E ⥤ C) where 40 | lift {c d : C} (f : c ⟶ d) (y : P⁻¹ d) : HasCartLift (P:= P) f y 41 | 42 | section 43 | variable {C E : Type*} [Category C] [Category E] (P : E ⥤ C) [ClovenFibration P] {c d : C} (f : c ⟶ d) (y : P⁻¹ d) (g : CartLift f y) 44 | #check Fibration.lift 45 | #check g.1 46 | #check g.1.based_lift 47 | #check g.based_lift.hom 48 | end 49 | 50 | 51 | class Transport (P : E ⥤ C) where 52 | transport {c d : C} (f : c ⟶ d) (y : P⁻¹ d) : P⁻¹ c 53 | 54 | --notation f " ⋆ " y : 10 => Transport.transport f y 55 | scoped infixr:80 " ⋆ " => Transport.transport -- NtS: infix right ensures that `f ⋆ y ⋆ z` is parsed as `f ⋆ (y ⋆ z)` 56 | 57 | @[simp] 58 | lemma transport_over {P : E ⥤ C} [Transport P] (f : c ⟶ d) (y : P⁻¹ d) : 59 | P.obj (f ⋆ y) = c := by 60 | simp [Fiber.over] 61 | 62 | namespace ClovenFibration 63 | 64 | variable {P : E ⥤ C} [ClovenFibration P] 65 | 66 | @[simp] 67 | instance instTransport : Transport P where 68 | transport := fun f x ↦ ⟨(lift f x).src , by simp only [Fiber.over]⟩ 69 | 70 | example (f : c ⟶ d) (g : d ⟶ e) (y : P⁻¹ e) : f ⋆ g ⋆ y = f ⋆ (g ⋆ y) := rfl 71 | 72 | @[simp] 73 | def Transport (f : c ⟶ d) : (P⁻¹ d) → (P⁻¹ c) := fun y ↦ f ⋆ y 74 | 75 | /-- The lift of a morphism `f` ending at `y`. -/ 76 | def basedLift (f : c ⟶ d) (y : P⁻¹ d) : (f ⋆ y) ⟶[f] y := (lift f y).based_lift 77 | 78 | /-- The lift `(f ⋆ y) ⟶[f] y` is cartesian. -/ 79 | instance instCartesianBasedLift {f : c ⟶ d} {y : P⁻¹ d} : Cartesian (basedLift f y) := 80 | (lift f y).is_cart 81 | 82 | @[simp] 83 | def basedLiftHom (f : c ⟶ d) (y : P⁻¹ d) : (f ⋆ y : E) ⟶ (y : E) := (lift f y).based_lift.hom 84 | 85 | @[simp] 86 | lemma basedLiftHom_over (f : c ⟶ d) (y : P⁻¹ d) : 87 | P.map (basedLiftHom f y) = 88 | (eqToHom (transport_over (P:= P) f y)) ≫ f ≫ eqToHom ((Fiber.over y).symm) := by 89 | simp only [Fiber.mk_coe, basedLiftHom, BasedLift.over_base] 90 | 91 | instance CartLiftOf (f : c ⟶ d) (y : P⁻¹ d) : CartLift f y := lift f y 92 | 93 | @[simp] 94 | def fiberHomOfBasedLiftHom {c d : C} {f : c ⟶ d} {x : P⁻¹ c} {y : P⁻¹ d} (g : x ⟶[f] y) : x ⟶ f ⋆ y where 95 | val := gaplift (basedLift f y) (𝟙 c) (g.cast (id_comp f).symm) 96 | property := by simp_all only [basedLift, over_base, id_comp, eqToHom_trans] 97 | 98 | def basedLiftOfFiberHom' {c : C} {x y : P⁻¹ c} (f : x ⟶ y) : x ⟶[𝟙 c] y := 99 | ⟨f.1, by simp [f.2]⟩ 100 | 101 | @[simps!] 102 | def equivFiberCatHomBasedLift {c d : C} {f : c ⟶ d} {x : P⁻¹ c} {y : P⁻¹ d} : 103 | (x ⟶[f] y) ≃ (x ⟶ f ⋆ y) where 104 | toFun g := fiberHomOfBasedLiftHom g 105 | invFun g := (basedLiftOfFiberHom g ≫[l] basedLift f y).cast (id_comp f) 106 | left_inv := by 107 | intro g; ext; dsimp; simp [basedLiftOfFiberHom, gaplift_hom_property] 108 | right_inv := by 109 | intro g; simp only [basedLiftOfFiberHom]; cases g; sorry -- use the uniqueness of the gap lift 110 | 111 | 112 | #check CategoryTheory.Epi.left_cancellation 113 | 114 | -- def equivTransportId {c : C} (x : P⁻¹ c) : ((𝟙 c) ⋆ x) ≅ x where 115 | -- hom := gaplift' (BasedLift.id x) (𝟙 c) (basedLiftOf (𝟙 c) x) (by simp only [comp_id]) 116 | -- inv := equivFiberCatHomBasedLift (id x) 117 | -- hom_inv_id := by ext; 118 | -- inv_hom_id := _ 119 | 120 | /-- Transporting along the identity morphism creates an isomorphic copy 121 | of the transported object. -/ 122 | def equivTransportId {c : C} (x : P⁻¹ c) : ((𝟙 c) ⋆ x) ≅ x := by 123 | haveI : Cartesian (basedLiftOfFiberHom (basedLift (𝟙 c) x : (𝟙 c) ⋆ x ⟶ x)) := by sorry --simp only [equivFiberHomBasedLift.right_inv]; infer_instance 124 | apply vertCartIso (g:= (basedLift (𝟙 c) x : (𝟙 c) ⋆ x ⟶ x)) 125 | 126 | lemma is_iso_gaplift_id_transport {c : C} (x : P⁻¹ c) : IsIso (gaplift' (BasedLift.id x) (𝟙 c) (basedLift (𝟙 c) x) (comp_id (𝟙 c)).symm ).hom := by 127 | have H : (gaplift' (BasedLift.id x) (𝟙 c) (basedLift (𝟙 c) x) (comp_id (𝟙 c)).symm ).hom = (basedLift (𝟙 c) x).hom := by 128 | simp [gaplift']; rfl 129 | haveI : Cartesian (basedLiftOfFiberHom (basedLift (𝟙 c) x : (𝟙 c) ⋆ x ⟶ x)) := by 130 | simp 131 | --infer_instance 132 | sorry 133 | haveI: IsIso (vertCartIso (g:= (basedLift (𝟙 c) x : (𝟙 c) ⋆ x ⟶ x))).hom := by infer_instance 134 | simp only [vertCartIso] at this 135 | rw [H] 136 | sorry 137 | 138 | 139 | --set_option trace.Meta.synthInstance true in 140 | -- @[simp] 141 | -- lemma transport_id {c : C} (x : P⁻¹ c) : ((𝟙 c) ⋆ x) ≅ x where 142 | -- hom := gaplift' (BasedLift.id x) (𝟙 c) (basedLiftOf (𝟙 c) x) (by simp only [comp_id]) 143 | -- inv := gaplift' (basedLiftOf (𝟙 c) x) (𝟙 c) (BasedLift.id x) (by simp only [id_comp]) 144 | -- hom_inv_id := by 145 | -- simp [FiberCat.comp_coe]; simp only [← BasedLift.id_hom] 146 | -- apply hom_comp_cast (h₁ := (id_comp (𝟙 c)).symm).mpr ; rw [gaplift_comp]; 147 | -- --change 148 | -- --rw [← cast_hom (h:= (id_comp (𝟙 x)).symm)]; --apply comp_hom_aux.mp; 149 | -- inv_hom_id := sorry 150 | 151 | -- @[simp] 152 | -- lemma transport_comp {c d₁ d₂ : C} {f₁ : c ⟶ d₁} {f₂ : d₁ ⟶ d₂} {y : P⁻¹ d₂} : ((f₁ ≫ f₂) ⋆ y) ≅ f₁ ⋆ (f₂ ⋆ y) := by 153 | -- apply vertCartIso (g:= (basedLift (f₁ ≫ f₂) y : (f₁ ≫ f₂) ⋆ y ⟶ y)) 154 | 155 | -- @[simp] 156 | -- lemma transport_comp {c d₁ d₂ : C} {f₁ : c ⟶ d₁} {f₂ : d₁ ⟶ d₂} {y : P⁻¹ d₂} : ((f₁ ≫ f₂) ⋆ y) ≅ f₁ ⋆ (f₂ ⋆ y) where 157 | -- hom := gaplift (basedLift f₁ (f₂ ⋆ y)) (𝟙 c) (castIdComp.invFun (gaplift (basedLift f₂ y) f₁ (basedLift (f₁ ≫ f₂) y))) 158 | -- inv := gaplift (basedLift (f₁ ≫ f₂) y) (𝟙 c) (castIdComp.invFun ((basedLift f₁ (f₂ ⋆ y)) ≫[l] (basedLift f₂ y))) 159 | -- hom_inv_id := by simp; rw [← comp_hom _ _, ← id_hom]; congr; simp; sorry --aesop--apply gaplift_uniq' (BasedLiftOf f₁ (f₂ ⋆ y)) _ 160 | -- inv_hom_id := sorry 161 | 162 | variable {F : Type*} [Category F] 163 | 164 | /-- The composition of two cloven fibrations is a cloven fibration. -/ 165 | instance instComp (P : E ⥤ C) [ClovenFibration P] (Q : F ⥤ E) [ClovenFibration Q] : ClovenFibration (Q ⋙ P) where 166 | lift := @fun c d f z => by 167 | have : P.obj (Q.obj z) = d := by simp only [← Functor.comp_obj, z.over] 168 | let y : P ⁻¹ d := ⟨Q.obj z, this⟩ 169 | let g := lift f y 170 | haveI : Cartesian g.based_lift := by exact g.is_cart 171 | let z' : Q⁻¹ (y.1) := Fiber.tauto (P:= Q.obj) z.1 172 | let k := lift (P:= Q) g.based_lift.hom z' 173 | exact { 174 | src := sorry 175 | based_lift := sorry 176 | is_cart := sorry 177 | } 178 | 179 | end ClovenFibration 180 | 181 | open ClovenFibration 182 | 183 | class SplitFibration (P : E ⥤ C) extends ClovenFibration P where 184 | transport_id_obj {c : C} (x : P⁻¹ c) : ((𝟙 c) ⋆ x).1 = x.1 185 | transport_id_hom {c : C} (x : P⁻¹ c) : basedLiftHom (𝟙 c) x = eqToHom (transport_id_obj x) ≫ 𝟙 (x.1) 186 | transport_comp_obj {c d₁ d₂ : C} (f₁ : c ⟶ d₁) (f₂ : d₁ ⟶ d₂) (x : P⁻¹ d₂) : ((f₁ ≫ f₂) ⋆ x).1 = (f₁ ⋆ (f₂ ⋆ x)).1 187 | lift_comp_hom {c d e : C} (f₁ : c ⟶ d) (f₂ : d ⟶ d') (x : P⁻¹ d') : 188 | basedLiftHom (f₁ ≫ f₂) x = eqToHom (transport_comp_obj f₁ f₂ x) ≫ basedLiftHom f₁ (f₂ ⋆ x) ≫ (basedLiftHom f₂ x) 189 | -/ 190 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/Total.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | import Mathlib.CategoryTheory.Category.Cat 7 | import Mathlib.CategoryTheory.Functor.Basic 8 | import GroupoidModel.FibrationForMathlib.FibredCats.Basic 9 | import GroupoidModel.FibrationForMathlib.FibredCats.CartesianLift 10 | 11 | 12 | namespace CategoryTheory 13 | open Category Opposite Functor Limits Cones 14 | 15 | variable {C E : Type*} [Category C] [Category E] 16 | 17 | abbrev TotalCat {C E : Type*} [Category C] [Category E] (P : E ⥤ C) := Fiber.Total P.obj 18 | 19 | prefix:75 " ∫ " => TotalCat 20 | 21 | @[ext] 22 | structure TotalCatHom {P : E ⥤ C} (X Y : ∫ P) where 23 | base : X.base ⟶ Y.base 24 | fiber : X.fiber.1 ⟶ Y.fiber.1 25 | eq : (P.map fiber) ≫ eqToHom (Y.fiber.over) = eqToHom (X.fiber.over) ≫ base 26 | 27 | namespace TotalCat 28 | 29 | def BasedLiftOf {P : E ⥤ C} {X Y : ∫ P} (g : TotalCatHom X Y) : X.fiber ⟶[g.base] Y.fiber where 30 | hom := g.fiber 31 | over := g.eq 32 | 33 | @[simp] 34 | lemma over_base {P : E ⥤ C} {X Y : ∫ P} (g : TotalCatHom X Y) : 35 | P.map g.fiber = eqToHom (X.fiber.over) ≫ g.base ≫ (eqToHom (Y.fiber.over).symm) := by 36 | simp [← Category.assoc _ _ _, ← g.eq] 37 | 38 | 39 | instance instCatOfTotal (P : E ⥤ C) : Category (∫ P) where 40 | Hom X Y := TotalCatHom X Y 41 | id X := ⟨𝟙 X.base, 𝟙 X.fiber.1, by simp⟩ 42 | comp := @fun X Y Z f g => ⟨f.1 ≫ g.1, f.2 ≫ g.2, by 43 | rw [map_comp, assoc, over_base g, over_base f] 44 | slice_lhs 3 4 => 45 | rw [eqToHom_trans, eqToHom_refl] 46 | simp 47 | ⟩ 48 | id_comp := by intro X Y f; dsimp; congr 1 <;> simp 49 | comp_id := by intro X Y f; dsimp; congr 1 <;> simp 50 | assoc := by intro X Y Z W f g h; dsimp; congr 1 <;> simp 51 | 52 | end TotalCat 53 | 54 | end CategoryTheory 55 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/VerticalLift.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | import Mathlib.CategoryTheory.Category.Basic 7 | import Mathlib.CategoryTheory.Sigma.Basic 8 | import GroupoidModel.FibrationForMathlib.Data.Fiber 9 | import GroupoidModel.FibrationForMathlib.FibredCats.CartesianLift 10 | /-! 11 | # Vertical Lifts 12 | 13 | We call a lift `v : x ⟶[𝟙 c] y` of the identity morphism a vertical lift/morphism. 14 | 15 | Question: Can we use extension types to define VertHom so that the proofs of 16 | `vertHomOfBasedLift` and `basedLiftOfVertHom` are more concise/automated? 17 | -/ 18 | 19 | 20 | namespace CategoryTheory 21 | 22 | open Category Functor Fiber BasedLift 23 | 24 | variable {C E : Type*} [Category C] [Category E] 25 | 26 | abbrev Vert (P : E ⥤ C) := Σ c, P⁻¹ c 27 | 28 | -- inductive VertHom {P : E ⥤ C} : (Vert P) → (Vert P) → Type max v u 29 | -- | mk : ∀ {c : C} {X Y : P⁻¹ c}, (X ⟶ Y) → VertHom (⟨c, X⟩ : Vert P) (⟨c, Y⟩ : Vert P) 30 | 31 | -- def VertHom {P : E ⥤ C} (x y : Vert P) := Σ (h : x.1 = y.1), x.2 ⟶[𝟙 x.1] (y.2.cast h.symm) 32 | 33 | variable {P : E ⥤ C} 34 | 35 | instance instCategoryVert : Category (Vert P) := inferInstance 36 | 37 | /-- A based-lift of the identity generates a morphism in `Vert P. -/ 38 | def vertHomOfBasedLift {X Y : Vert P} (h : X.1 = Y.1) 39 | (f : X.2 ⟶[𝟙 X.1] Y.2.cast h.symm) : (X ⟶ Y) := by 40 | obtain ⟨c, x⟩ := X 41 | obtain ⟨c', y⟩ := Y 42 | have H : c = c' := h 43 | subst H 44 | simp at f 45 | exact ⟨f.1, by aesop⟩ 46 | 47 | --NtS: shorter proof of above for mathlib 48 | -- def vertHomOfBasedLift' {X Y : Vert P} {h : X.1 = Y.1} 49 | -- (f : X.2 ⟶[𝟙 X.1] Y.2.cast h.symm) : (X ⟶ Y) := by 50 | -- cases X; cases Y; simp at h; subst h; exact ⟨f.1, by aesop⟩ 51 | 52 | @[simp] 53 | lemma base_eq_of_vert_hom {X Y : Vert P} (f : X ⟶ Y) : X.1 = Y.1 := by 54 | cases f; 55 | rfl 56 | 57 | @[simp] 58 | def basedLiftOfVertHomAux {X Y : Vert P} (f : X ⟶ Y) : X.2.1 ⟶ Y.2.1 := by 59 | obtain ⟨f'⟩ := f 60 | exact f'.1 61 | 62 | @[simp] 63 | lemma basedLiftOfVertHomAux_over {X Y : Vert P} {f : X ⟶ Y} : 64 | have : P.obj Y.2.1 = X.1 := by simp [Fiber.over]; symm; exact base_eq_of_vert_hom f 65 | P.map (basedLiftOfVertHomAux f) ≫ eqToHom (this) = eqToHom (X.2.over) ≫ 𝟙 X.1 := by 66 | cases f; simp 67 | 68 | def basedLiftOfVertHom {X Y : Vert P} (f : X ⟶ Y) : 69 | have : X.1 = Y.1 := base_eq_of_vert_hom f 70 | X.2 ⟶[𝟙 X.1] Y.2.cast this.symm := ⟨basedLiftOfVertHomAux f, by cases f; simp⟩ 71 | 72 | --@[aesop forward safe] 73 | set_option trace.simps.verbose true in 74 | @[simp] 75 | def basedLiftOfFiberHom {c : C} {x y : P⁻¹ c} (f : x ⟶ y) : x ⟶[𝟙 c] y := 76 | ⟨f.1, by simp [f.2]⟩ 77 | 78 | /-- Coercing a based-lift `x ⟶[𝟙 c] y` of the identity morphism `𝟙 c` 79 | to a morphism `x ⟶ y` in the fiber `P⁻¹ c`. -/ 80 | @[simps] 81 | instance instCoeFiberHom {c : C} {x y : P⁻¹ c} : Coe (x ⟶[𝟙 c] y) (x ⟶ y) where 82 | coe := fun f ↦ ⟨ f.hom , by simp [f.over]⟩ 83 | 84 | /-- The bijection between the hom-type of the fiber P⁻¹ c and the based-lifts of the identity 85 | morphism of c. -/ 86 | @[simps!] 87 | def equivFiberHomBasedLift {c : C} {x y : P⁻¹ c} : (x ⟶ y) ≃ (x ⟶[𝟙 c] y) where 88 | toFun := fun g ↦ basedLiftOfFiberHom g 89 | invFun := fun g ↦ g 90 | left_inv := by intro g; simp [basedLiftOfFiberHom] 91 | right_inv := by intro g; rfl 92 | 93 | @[simps!] 94 | def equivVertHomBasedLift {c : C} {x y : P⁻¹ c} : ((⟨c, x⟩ : Vert P) ⟶ ⟨c, y⟩) ≃ (x ⟶[𝟙 c] y) where 95 | toFun := fun g ↦ basedLiftOfVertHom g 96 | invFun := fun g ↦ vertHomOfBasedLift rfl g 97 | left_inv := fun g ↦ by cases g; rfl 98 | right_inv := fun _ ↦ rfl 99 | 100 | 101 | /-- The bijection between the type of the isomorphisms in the fiber P⁻¹ c and the iso-based-lifts 102 | of the identity morphism of c. -/ 103 | noncomputable 104 | def isoVertBasedLiftEquiv {c : C} {x y : P⁻¹ c} : (x ≅ y) ≃ (x ⟶[≅(𝟙 c)] y) where 105 | toFun := fun g => ⟨⟨g.hom.1, by simp [g.hom.2]⟩, by use g.inv.1; simp; cases g; aesop⟩ 106 | invFun := fun g => { 107 | hom := ⟨g.hom , by simp⟩ 108 | inv := ⟨ (asIso g.hom).inv , by simp⟩ 109 | hom_inv_id := by aesop 110 | inv_hom_id := by aesop 111 | } 112 | left_inv := fun _ ↦ Iso.ext rfl 113 | right_inv := fun _ ↦ rfl 114 | 115 | /-- Vertical cartesian morphisms are isomorphism. -/ 116 | @[simps!] 117 | def vertCartIso {P : E ⥤ C} {c: C} {e e' : P⁻¹ c} (g : e ⟶ e') 118 | [Cartesian (basedLiftOfFiberHom g)] : e ≅ e' where 119 | hom := g 120 | inv := sorry -- gaplift (basedLiftOfFiberHom g) (𝟙 c) (id e' ≫[l] id e') 121 | inv_hom_id := by 122 | rw [← comp_id (𝟙 e')]; apply FiberCat.hom_ext; sorry -- apply gaplift_hom_property 123 | hom_inv_id := by 124 | rw [← comp_id (𝟙 e)] 125 | let g' : e' ⟶[𝟙 c] e := basedLiftOfFiberHom sorry -- (gaplift (basedLiftOfFiberHom g) (𝟙 c) (id e' ≫[l] id e')) 126 | sorry 127 | /- 128 | have : ((basedLiftOfFiberHom g ≫[l] g') ≫[l] basedLiftOfFiberHom g) = (BasedLift.id e ≫[l] BasedLift.id e) ≫[l](basedLiftOfFiberHom g) := by 129 | simp only [BasedLift.comp, BasedLift.id, comp_id, 130 | Category.assoc, id_comp, BasedLift.mk.injEq] 131 | have : ( (gaplift (basedLiftOfFiberHom g) (𝟙 c) (id e' ≫[l] id e')) ≫[l] basedLiftOfFiberHom g) = (BasedLift.id e' ≫[l] BasedLift.id e') := by apply gaplift_property 132 | simp only [basedLiftOfFiberHom] at * 133 | aesop 134 | have H := gaplift_uniq' (basedLiftOfFiberHom g) ((basedLiftOfFiberHom g) ≫[l] g') (BasedLift.id e ≫[l] BasedLift.id e) (this) 135 | apply FiberCat.hom_ext 136 | dsimp 137 | aesop 138 | -/ 139 | -- have H' := comp_hom'.mp H 140 | -- simp only [BasedLift.comp, BasedLift.id, comp_id] at H' 141 | -- simp only [comp_id, H'] 142 | -- simp_all only [BasedLift.comp, BasedLift.id, comp_id, id_comp, FiberCat.fiber_id_obj] 143 | -- exact H' 144 | 145 | end CategoryTheory 146 | -------------------------------------------------------------------------------- /GroupoidModel/attic/FibrationForMathlib/FibredCats/gaplift_cast.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Copyright (c) 2024 Sina Hazratpour. All rights reserved. 3 | Released under Apache 2.0 license as described in the file LICENSE. 4 | Authors: Sina Hazratpour 5 | -/ 6 | 7 | import Mathlib.CategoryTheory.Category.Cat 8 | import Mathlib.CategoryTheory.Comma.Arrow 9 | import Mathlib.CategoryTheory.Opposites 10 | import Mathlib.CategoryTheory.Equivalence 11 | import Mathlib.CategoryTheory.EqToHom 12 | import Mathlib.CategoryTheory.Sigma.Basic 13 | import Mathlib.CategoryTheory.MorphismProperty.Basic 14 | import Mathlib.CategoryTheory.Limits.Preserves.Basic 15 | import GroupoidModel.FibrationForMathlib.Data.Fiber 16 | import GroupoidModel.FibrationForMathlib.FibredCats.Basic 17 | import GroupoidModel.FibrationForMathlib.FibredCats.CartesianLift 18 | 19 | /- 20 | open BasedLift 21 | 22 | variable {P : E ⥤ C} {c' c d : C} {f : c ⟶ d} {x : P⁻¹ c} {y : P⁻¹ d} {x' : P⁻¹ c'} (g : x ⟶[f] y) [CartesianBasedLift (P:= P) g] 23 | 24 | def gaplift_aux (u : c' ⟶ c) (g' : x' ⟶[u ≫ f] y) : x' ⟶[u] x := 25 | (CartesianBasedLift.uniq_lift (P:= P) (f:= f) (g:= g) (z:= x') u g').default.val 26 | 27 | /-- `gaplift g u g'` is the canonical map from a lift `g' : x' ⟶[u ≫ f] y` to a 28 | cartesian lift `g` of `f`. -/ 29 | def gaplift (u : c' ⟶ c) {f' : c' ⟶ d} (g' : x' ⟶[f'] y) (h : f' = u ≫ f) : x' ⟶[u] x := 30 | (CartesianBasedLift.uniq_lift (P:= P) (f:= f) (g:= g) (z:= x') u (BasedLift.cast h g')).default.val 31 | 32 | /-- The composition of the gap lift and the cartesian lift is the given lift. -/ 33 | @[simp] 34 | lemma gaplift_property (u : c' ⟶ c) {f' : c' ⟶ d} (g' : x' ⟶[f'] y) 35 | (h : f' = u ≫ f) : ((gaplift g u g' h) ≫[l] g) = BasedLift.cast h g':= 36 | (CartesianBasedLift.uniq_lift (P:= P) (f:= f) (g:= g) (z:= x') u 37 | (BasedLift.cast h g')).default.property 38 | 39 | /-- A variant of the gaplift property for equality of the underlying morphisms. -/ 40 | @[simp] 41 | lemma gaplift_hom_property (u : c' ⟶ c) {f' : c' ⟶ d} (g' : x' ⟶[f'] y) 42 | (h : f' = u ≫ f) : (gaplift g u g' h).hom ≫ g.hom = g'.hom := by rw [← BasedLift.comp_hom _ _]; simp only [gaplift_property g u g' h, cast_hom] 43 | 44 | end BasedLift 45 | -/ 46 | -------------------------------------------------------------------------------- /GroupoidModel/attic/README.md: -------------------------------------------------------------------------------- 1 | Files that are not currently needed but may be used in the future are stored in the attic. 2 | -------------------------------------------------------------------------------- /GroupoidModel/attic/Russell_PER_MS/NaturalModelPi.lean: -------------------------------------------------------------------------------- 1 | /-! DEPRECATED in favor of `UHomSeqPis` -/ 2 | #exit 3 | 4 | import GroupoidModel.Russell_PER_MS.NaturalModelBase 5 | 6 | universe u 7 | 8 | noncomputable section 9 | 10 | open CategoryTheory Limits Opposite 11 | 12 | class NaturalModelPi (Ctx : Type u) [SmallCategory.{u} Ctx] extends NaturalModelBase Ctx where 13 | Pi : toNaturalModelBase.Ptp.obj Ty ⟶ Ty 14 | lam : toNaturalModelBase.Ptp.obj Tm ⟶ Tm 15 | Pi_pullback : IsPullback lam (toNaturalModelBase.Ptp.map tp) tp Pi 16 | 17 | namespace NaturalModelPi 18 | 19 | variable {Ctx : Type u} [SmallCategory.{u} Ctx] (M : NaturalModelPi Ctx) 20 | 21 | def mkPi {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) : y(Γ) ⟶ M.Ty := 22 | M.Ptp_equiv ⟨A, B⟩ ≫ M.Pi 23 | 24 | def mkLam {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (t : y(M.ext A) ⟶ M.Tm) : y(Γ) ⟶ M.Tm := 25 | M.Ptp_equiv ⟨A, t⟩ ≫ M.lam 26 | 27 | @[simp] 28 | theorem mkLam_tp {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 29 | (t : y(M.ext A) ⟶ M.Tm) (t_tp : t ≫ M.tp = B) : 30 | M.mkLam A t ≫ M.tp = M.mkPi A B := by 31 | simp [mkLam, mkPi, NaturalModelPi.Pi_pullback.w] 32 | rw [← Category.assoc, M.Ptp_equiv_naturality, t_tp] 33 | 34 | /-- 35 | ``` 36 | Γ ⊢ A type Γ.A ⊢ B type Γ ⊢ f : ΠA.B 37 | -------------------------------------- 38 | Γ.A ⊢ f[↑] v₀ : B 39 | ``` 40 | -/ 41 | def mkPApp {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 42 | (f : y(Γ) ⟶ M.Tm) (f_tp : f ≫ M.tp = M.mkPi A B) : y(M.ext A) ⟶ M.Tm := by 43 | let total : y(Γ) ⟶ M.Ptp.obj M.Tm := 44 | NaturalModelPi.Pi_pullback.isLimit.lift <| 45 | PullbackCone.mk f (M.Ptp_equiv ⟨A, B⟩) f_tp 46 | convert (M.Ptp_equiv.symm total).snd 47 | have eq : total ≫ M.Ptp.map M.tp = M.Ptp_equiv ⟨A, B⟩ := 48 | NaturalModelPi.Pi_pullback.isLimit.fac _ (some .right) 49 | simpa [M.Ptp_equiv_symm_naturality] using (M.Ptp_ext.mp eq).left.symm 50 | 51 | -- mkP_equiv.symm.injective 52 | -- have : total' ≫ (P tp).map tp = mkP A B := 53 | -- NaturalModelPi.Pi_pullback.isLimit.fac _ (some .right) 54 | -- let total := mkP_equiv.1 total' 55 | -- have := mkP_equiv.symm.injective <| 56 | -- show mkP total.1 (total.2 ≫ tp) = mkP A B by 57 | -- rw [← mkP_app]; simp [mkP, total, this] 58 | -- have aeq : total.1 = A := congrArg Sigma.fst this 59 | -- refine ⟨aeq ▸ total, ?_⟩ 60 | -- clear_value total'; cases this; rfl 61 | 62 | @[simp] 63 | theorem mkPApp_tp {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 64 | (f : y(Γ) ⟶ M.Tm) (f_tp : f ≫ M.tp = M.mkPi A B) : 65 | M.mkPApp A B f f_tp ≫ M.tp = B := by 66 | let total : y(Γ) ⟶ M.Ptp.obj M.Tm := 67 | M.Pi_pullback.isLimit.lift <| 68 | PullbackCone.mk f (M.Ptp_equiv ⟨A, B⟩) f_tp 69 | -- have eq : total ≫ M.P.map tp = P_equiv ⟨A, B⟩ := 70 | -- NaturalModelPi.Pi_pullback.isLimit.fac _ (some .right) 71 | -- unfold mkPApp 72 | sorry 73 | 74 | def mkApp {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 75 | (f : y(Γ) ⟶ M.Tm) (f_tp : f ≫ M.tp = M.mkPi A B) 76 | (a : y(Γ) ⟶ M.Tm) (a_tp : a ≫ M.tp = A) : y(Γ) ⟶ M.Tm := 77 | M.inst A (M.mkPApp A B f f_tp) a a_tp 78 | 79 | @[simp] 80 | theorem mkApp_tp {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 81 | (f : y(Γ) ⟶ M.Tm) (f_tp : f ≫ M.tp = M.mkPi A B) 82 | (a : y(Γ) ⟶ M.Tm) (a_tp : a ≫ M.tp = A) : 83 | M.mkApp A B f f_tp a a_tp ≫ M.tp = M.inst A B a a_tp := 84 | sorry 85 | 86 | -- semantic beta reduction 87 | @[simp] 88 | theorem mkApp_mkLam {Γ : Ctx} (A : y(Γ) ⟶ M.Ty) (B : y(M.ext A) ⟶ M.Ty) 89 | (t : y(M.ext A) ⟶ M.Tm) (t_tp : t ≫ M.tp = B) 90 | (lam_tp : M.mkLam A t ≫ M.tp = M.mkPi A B) 91 | (a : y(Γ) ⟶ M.Tm) (a_tp : a ≫ M.tp = A) : 92 | -- TODO: rethink this; idk if we really want to have `inst` 93 | -- be a simp-NF; might be preferrable to just use `_ ≫ σ` 94 | M.mkApp A B (M.mkLam A t) lam_tp a a_tp = M.inst A t a a_tp := by 95 | sorry 96 | 97 | end NaturalModelPi 98 | -------------------------------------------------------------------------------- /GroupoidModel/attic/Tarski/NaturalModel.lean: -------------------------------------------------------------------------------- 1 | /- 2 | Natural Models: 3 | see https://arxiv.org/pdf/1406.3219 4 | for the definition of a natural model 5 | and how to model the type formers Σ,Π,Id. 6 | A recent talk is here: 7 | https://awodey.github.io/talks/ATT.pdf 8 | -/ 9 | 10 | import Mathlib 11 | 12 | import Mathlib.CategoryTheory.Yoneda 13 | import Mathlib.CategoryTheory.Limits.Shapes.Terminal 14 | import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq 15 | import Mathlib.CategoryTheory.Limits.Presheaf 16 | 17 | import Poly.ForMathlib.CategoryTheory.LocallyCartesianClosed.Presheaf 18 | 19 | import GroupoidModel.ForPoly 20 | 21 | universe u v 22 | 23 | namespace CategoryTheory 24 | 25 | open Functor Limits Opposite 26 | 27 | noncomputable section 28 | 29 | /- 30 | We will need at least the following: 31 | - the category Ctx (to be interpreted as small groupoids) 32 | - the display maps of contexts, arising from iterated context extensions 33 | - the presheaf category 𝓔 = Psh(Ctx) in which the model lives 34 | - the presheaf Ty : Ctxᵒᵖ → Set of types in context 35 | - the presheaf Tm : Ctxᵒᵖ → Set of terms in context 36 | - the typing natural transformation tp : Tm ⟶ Ty 37 | - the proof that tp is (re)presentable 38 | - the polynomial endofunctor Pₜ : 𝓔 ⥤ 𝓔 39 | - the rules for Π-types as an operation on Pₜ(tp) 40 | - the rules for Σ-types as an operation on Pₜ(tp) 41 | - the rules for Id-types as an operation on tp : Tm ⟶ Ty 42 | - the universe Set of (small) discrete groupoids, 43 | along with its discrete (op-)fibration Set* ⟶ Set 44 | It would probably also be useful to have: 45 | - the proof that presentable natural transformations are "tiny" maps 46 | (the pushforward has a right adjoint) 47 | - the proof that Pₜ is therefore cocontinuous, since tp is tiny 48 | - need to add a general formulation for (groupoid) quotient types 49 | -/ 50 | 51 | /-! 52 | # Natural Models 53 | -/ 54 | 55 | variable {Ctx : Type u} [SmallCategory Ctx] [HasTerminal Ctx] 56 | 57 | notation:max "y(" Γ ")" => yoneda.obj Γ 58 | 59 | namespace NaturalModel 60 | 61 | variable (Ctx) in 62 | class NaturalModelBase where 63 | Tm : Psh Ctx 64 | Ty : Psh Ctx 65 | tp : Tm ⟶ Ty 66 | ext (Γ : Ctx) (A : y(Γ) ⟶ Ty) : Ctx 67 | disp (Γ : Ctx) (A : y(Γ) ⟶ Ty) : ext Γ A ⟶ Γ 68 | var (Γ : Ctx) (A : y(Γ) ⟶ Ty) : y(ext Γ A) ⟶ Tm 69 | disp_pullback {Γ : Ctx} (A : y(Γ) ⟶ Ty) : 70 | IsPullback (var Γ A) (yoneda.map (disp Γ A)) tp A 71 | 72 | export NaturalModelBase (Tm Ty tp ext disp var disp_pullback) 73 | variable [M : NaturalModelBase Ctx] 74 | 75 | instance : HasFiniteWidePullbacks (Psh Ctx) := hasFiniteWidePullbacks_of_hasFiniteLimits _ 76 | 77 | @[reducible] 78 | def uvPoly {Tm Ty : Psh Ctx} (tp : Tm ⟶ Ty) : UvPoly Tm Ty := ⟨tp, inferInstance⟩ 79 | def uvPolyT {Tm Ty : Psh Ctx} (tp : Tm ⟶ Ty) : UvPoly.Total (Psh Ctx) := ⟨uvPoly tp⟩ 80 | 81 | def P {Tm Ty : Psh Ctx} (tp : Tm ⟶ Ty) : Psh Ctx ⥤ Psh Ctx := (uvPoly tp).functor 82 | 83 | def P_naturality {E B E' B' : Psh Ctx} 84 | {f : E ⟶ B} {f' : E' ⟶ B'} (α : uvPolyT f ⟶ uvPolyT f') : P f ⟶ P f' := 85 | UvPoly.naturality (P := uvPolyT f) (Q := uvPolyT f') α 86 | 87 | def proj {Tm Ty : Psh Ctx} (tp : Tm ⟶ Ty) : (P tp).obj Ty ⟶ Ty := (uvPoly tp).fstProj _ 88 | 89 | -- def PolyTwoCellBack {Tm Ty : Psh Ctx} (tp : Tm ⟶ Ty) := sorry 90 | 91 | -- def NaturalitySquare { F G : Psh Ctx } { α : F ⥤ G } { h : C → D } { C D : Ctx } 92 | -- : α_D ∘ (F h) = (G h) ∘ α_C := sorry 93 | 94 | -- def UniformWeakPullback (f : A → B) (g : C → D) (c : A → C) (d : B → D) 95 | -- : d ∘ f = g ∘ c and (f, c) : A → B ×_D C has a section j : B ×_D C → A with 96 | -- (f, c) ∘ j = id. 97 | 98 | -- def WeakElimRule {Tm Ty I : Psh Ctx} (tp : Tm ⟶ Ty)(q : I ⟶ Ty)(δ : Tm ⟶ I) 99 | -- : UniformWeakPullback NaturalitySquare ... 100 | 101 | -- def DeltaOver {C : Type*} [ category C ] ( f : A → B ) := ⟨𝟙 A, 𝟙 A⟩ : A → A ×_B A as an arrow in C/B . 102 | 103 | variable (Ctx) in 104 | class NaturalModelPi where 105 | Pi : (P tp).obj Ty ⟶ M.Ty 106 | lam : (P tp).obj Tm ⟶ M.Tm 107 | Pi_pullback : IsPullback lam ((P tp).map tp) tp Pi 108 | 109 | variable (Ctx) in 110 | class NaturalModelSigma where 111 | Sig : (P tp).obj Ty ⟶ M.Ty 112 | pair : (UvPoly.compDom (uvPoly M.tp) (uvPoly M.tp)) ⟶ M.Tm 113 | Sig_pullback : IsPullback pair ((uvPoly M.tp).comp (uvPoly M.tp)).p M.tp Sig 114 | 115 | def δ : M.Tm ⟶ pullback tp tp := pullback.lift (𝟙 _) (𝟙 _) rfl 116 | variable (Ctx) in 117 | class NaturalModelEq where 118 | Eq : pullback tp tp ⟶ M.Ty 119 | refl : Tm ⟶ M.Tm 120 | Eq_pullback : IsPullback refl δ tp Eq 121 | 122 | variable (Ctx) in 123 | class NaturalModelIdBase where 124 | Id : pullback tp tp ⟶ M.Ty 125 | i : Tm ⟶ M.Tm 126 | Id_commute : δ ≫ Id = i ≫ tp 127 | 128 | section 129 | variable [NaturalModelIdBase Ctx] 130 | open NaturalModelIdBase 131 | 132 | def I : Psh Ctx := pullback Id tp 133 | def q : I ⟶ M.Ty := pullback.fst .. ≫ pullback.fst .. ≫ tp 134 | def ρ : M.Tm ⟶ I := pullback.lift δ i Id_commute 135 | 136 | def ρs : P q ⟶ P M.tp := 137 | UvPoly.star (P := uvPoly M.tp) (Q := uvPoly q) ρ (by simp [ρ, uvPoly, q, δ]) 138 | 139 | def pb2 : Psh Ctx := pullback (ρs.app M.Ty) ((P M.tp).map M.tp) 140 | def ε : (P q).obj M.Tm ⟶ pb2 := 141 | pullback.lift ((P q).map tp) (ρs.app Tm) (by aesop_cat) 142 | 143 | -- FIXME: NaturalModelId doesn't compile without this being opaque 144 | variable (Ctx) in 145 | irreducible_def NaturalModelIdData := 146 | { J : pb2 ⟶ (P q).obj M.Tm // J ≫ ε = 𝟙 _ } 147 | end 148 | 149 | variable (Ctx) in 150 | class NaturalModelId extends NaturalModelIdBase Ctx where 151 | data : NaturalModelIdData Ctx 152 | 153 | def NaturalModelId.J [NaturalModelId Ctx] : 154 | pb2 ⟶ (P q).obj M.Tm := by 155 | have := NaturalModelId.data (Ctx := Ctx) 156 | rw [NaturalModelIdData] at this 157 | exact this.1 158 | 159 | theorem NaturalModelId.J_section [NaturalModelId Ctx] : J (Ctx := Ctx) ≫ ε = 𝟙 _ := by 160 | dsimp [J] 161 | generalize cast .. = x 162 | exact x.2 163 | 164 | variable (Ctx) in 165 | class NaturalModelU where 166 | U : y(⊤_ Ctx) ⟶ Ty 167 | El : y(ext (⊤_ Ctx) U) ⟶ Ty 168 | -- El_mono : Mono El 169 | export NaturalModelU (U El) 170 | 171 | open NaturalModelU in 172 | def toPiArgs [NaturalModelU Ctx] [NaturalModelPi Ctx] : 173 | (P (yoneda.map (disp (ext (⊤_ Ctx) U) El))).obj y(ext (⊤_ Ctx) U) ⟶ (P tp).obj Ty := 174 | (P _).map El ≫ (P_naturality ⟨_, _, (disp_pullback El).flip⟩).app _ 175 | 176 | open NaturalModelU NaturalModelPi in 177 | variable (Ctx) in 178 | class NaturalModelSmallPi [NaturalModelU Ctx] [NaturalModelPi Ctx] where 179 | SmallPi : (P (yoneda.map (disp (ext (⊤_ Ctx) U) El))).obj y(ext (⊤_ Ctx) U) ⟶ y(ext (⊤_ Ctx) U) 180 | SmallPi_eq : SmallPi ≫ El = toPiArgs ≫ Pi 181 | 182 | section NaturalModelSmallPi 183 | 184 | def NaturalModelSmallPi.lambda [NaturalModelU Ctx] [NaturalModelPi Ctx] : 185 | (P (yoneda.map (disp (ext (⊤_ Ctx) U) El))).obj Tm ⟶ Tm := 186 | sorry 187 | 188 | theorem NaturalModelSmallPi.pullback [NaturalModelU Ctx] [NaturalModelPi Ctx] : 189 | IsPullback lambda 190 | ((P (yoneda.map (disp (ext (⊤_ Ctx) U) El))).map tp) tp 191 | ((P_naturality ⟨_, _, (disp_pullback El).flip⟩).app _ ≫ NaturalModelPi.Pi) := sorry 192 | 193 | end NaturalModelSmallPi 194 | 195 | -- These are placeholders for definitions 196 | def NaturalModelSmallSigma : Type := sorry 197 | def NaturalModelSmallId : Type := sorry 198 | def NaturalModelUnivalentU : Type := sorry 199 | 200 | /- 201 | we will also want to say that the universe U is closed under Sigma, Pi, and Id, 202 | so that we can say that U is univalent. 203 | -/ 204 | /- 205 | it would probably also be useful to have another universe U1 with U : U1, 206 | and maybe some type formers for U1 as well . 207 | -/ 208 | 209 | end NaturalModel 210 | 211 | open NaturalModel in 212 | variable (Ctx) in 213 | class NaturalModel extends 214 | NaturalModelBase Ctx, NaturalModelPi Ctx, NaturalModelSigma Ctx, 215 | NaturalModelId Ctx, NaturalModelU Ctx, NaturalModelSmallPi Ctx 216 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # HoTTLean : *Formalizing the Meta-Theory of HoTT in Lean* 3 | 4 | This repository formalizes in Lean the groupoid model of HoTT. 5 | A web version of the mathematics, Lean documentation, and a dependency graph on the progress of formalization can be found 6 | [here](https://sinhp.github.io/groupoid_model_in_lean4/). 7 | 8 | This is intended to serve as the basis for a HoTT mode in Lean. 9 | 10 | This repository relies on the [formalization of polynomial functors](https://github.com/sinhp/Poly/tree/master). 11 | 12 | To get the most recent changes of the polynomial functors repository, run `lake update` first in the terminal inside the VSCode. 13 | You should see a message like 14 | 15 | ``` 16 | info: Poly: updating repository '././.lake/packages/Poly' to revision '7297691124d30c971ff69d691e6cbd35e9a5bcac' 17 | ``` 18 | 19 | To get mathlib cached `.olean` files run 20 | 21 | ``` 22 | lake exe cache get 23 | ``` 24 | 25 | 26 | and to get the cached files and override your potentially corrupted `.olean` files run 27 | 28 | ``` 29 | lake exe cache get! 30 | ``` 31 | -------------------------------------------------------------------------------- /blueprint/src/Packages/bussproofs.py: -------------------------------------------------------------------------------- 1 | from plasTeX import VerbatimEnvironment 2 | 3 | def ProcessOptions(options, document): 4 | document.config['images']['scales'].setdefault('prooftree', 1.5) 5 | 6 | class prooftree(VerbatimEnvironment): 7 | pass 8 | -------------------------------------------------------------------------------- /blueprint/src/Templates/prooftree.jinja2: -------------------------------------------------------------------------------- 1 |
3 | {% if obj.renderer.vectorImager.enabled %} 4 | {{ obj.source|e }} 5 | {% else %} 6 | {{ obj.source|e }} 7 | {% endif %} 8 |
9 | -------------------------------------------------------------------------------- /blueprint/src/blueprint.sty: -------------------------------------------------------------------------------- 1 | \DeclareOption*{} 2 | \ProcessOptions -------------------------------------------------------------------------------- /blueprint/src/chapter/all.tex: -------------------------------------------------------------------------------- 1 | % This file collects all the blueprint chapters. 2 | % It is not supposed to be built standalone: 3 | % see web.tex and print.tex instead. 4 | 5 | \title{HoTTLean : { \it Formalizing the Meta-Theory of HoTT in Lean} } 6 | \author{Steve Awodey, Mario Carneiro, Sina Hazratpour, Joseph Hua, 7 | Wojciech Nawrocki, Spencer Woolfson} 8 | 9 | \begin{document} 10 | \maketitle 11 | 12 | \chapter{Syntax of HoTT0} 13 | \input{chapter/syntax} 14 | \chapter{Natural Models} 15 | \input{chapter/natural_model} 16 | \chapter{HoTT0 interpreted in natural models} 17 | \input{chapter/interpretation} 18 | \chapter{The Groupoid Model} 19 | \input{chapter/groupoid_model} 20 | \chapter{Polynomial Endofunctors} 21 | \input{chapter/polynomial} 22 | 23 | \bibliography{refs.bib}{} 24 | \bibliographystyle{alpha} 25 | 26 | \end{document} 27 | -------------------------------------------------------------------------------- /blueprint/src/chapter/interpretation.tex: -------------------------------------------------------------------------------- 1 | %% Interpretation of Syntax into a specified Natural Model 2 | 3 | %% This natural model should have 4 | 5 | % - N universes and lifts (so N+1 natural models) 6 | % - Pi types and Sigma types across all N+1 natural models 7 | % - Identity types in every natural model, 8 | % such that the smallest universe's Identity type satisfies UIP 9 | % - The smallest universe satisfies univalence 10 | -------------------------------------------------------------------------------- /blueprint/src/chapter/syntax.tex: -------------------------------------------------------------------------------- 1 | %% Syntax of HoTT0 2 | 3 | %% Γ ⊢{i} a : A for each i ≤ N 4 | 5 | 6 | % - N universes ${U_i}$and lifts $L : U{i} → U{i+1}$ 7 | % - Pi types and Sigma types across all N+1 natural models 8 | % - Identity types in every natural model, 9 | % such that the smallest universe's Identity type satisfies UIP 10 | % - The smallest universe satisfies univalence 11 | 12 | For HoTT, most of the rules are standard. Here, we will go over them. 13 | 14 | \textbf{The Context Rules} 15 | \[ 16 | \begin{bprooftree} 17 | \bottomAlignProof 18 | \AxiomC{} 19 | \UnaryInfC{$ \epsilon \text{ ctx}$} 20 | \end{bprooftree} 21 | \begin{bprooftree} 22 | \bottomAlignProof 23 | \AxiomC{$\Gamma \text{ ctx}$} 24 | \AxiomC{$\Gamma \vdash A \text{ type}$} 25 | \BinaryInfC{$ \Gamma, x : A \text{ ctx}$} 26 | \end{bprooftree} 27 | \begin{bprooftree} 28 | \bottomAlignProof 29 | \AxiomC{$\Gamma, x:A \text{ ctx}$} 30 | \UnaryInfC{$\Gamma, x:A \vdash x:A$} 31 | \end{bprooftree} 32 | \begin{bprooftree} 33 | \bottomAlignProof 34 | \AxiomC{$\Gamma, x:A \text{ ctx}$} 35 | \AxiomC{$\Gamma \vdash y : B$} 36 | \BinaryInfC{$\Gamma, x:A \vdash y:B$} 37 | \end{bprooftree} 38 | \] 39 | 40 | \textbf{The Pi Rules} 41 | \[ 42 | \begin{bprooftree} 43 | \AxiomC{$\Gamma, x:A \vdash B(x) \text{ type}$} 44 | \UnaryInfC{$\Gamma \vdash \prod_{a : A} B(a) \text{ type}$} 45 | \end{bprooftree} 46 | \begin{bprooftree} 47 | \AxiomC{$\Gamma, x :A \vdash b(x) : B(x)$} 48 | \UnaryInfC{$\Gamma \vdash \lambda (a : A).b(a) : \prod_{a :A} B(a) $} 49 | \end{bprooftree} 50 | \] 51 | \[ 52 | \begin{bprooftree} 53 | \AxiomC{$\Gamma \vdash f: \prod_{a :A} B(a)$} 54 | \AxiomC{$\Gamma \vdash x : A$} 55 | \BinaryInfC{$f(x) : B(x)$} 56 | \end{bprooftree} 57 | \begin{bprooftree} 58 | \AxiomC{$\Gamma, x: A \vdash b(x) : B(x)$} 59 | \UnaryInfC{$\Gamma, a:A\vdash \lambda(x: A).b(x)(a) \equiv b(a) : B(a)$} 60 | \end{bprooftree} 61 | \] 62 | 63 | \textbf{The Sigma Rules} 64 | \[ 65 | \begin{bprooftree} 66 | \AxiomC{$\Gamma, x:A \vdash B(x) \text{ type}$} 67 | \UnaryInfC{$\Gamma \vdash \sum_{a : A} B(a) \text{ type}$} 68 | \end{bprooftree} 69 | \begin{bprooftree} 70 | \AxiomC{$\Gamma \vdash a : A$} 71 | \AxiomC{$\Gamma\vdash b : B(a)$} 72 | \BinaryInfC{$\Gamma \vdash \langle a,b\rangle : \sum_{x :A} B(x) $} 73 | \end{bprooftree} 74 | \] 75 | \[ 76 | \begin{bprooftree} 77 | \AxiomC{$\Gamma \vdash p: \sum_{x :A} B(x)$} 78 | \UnaryInfC{$\Gamma \vdash \text{fst}(p) : A$} 79 | \end{bprooftree} 80 | \begin{bprooftree} 81 | \AxiomC{$\Gamma \vdash p: \sum_{x :A} B(x)$} 82 | \UnaryInfC{$\Gamma \vdash \text{snd}(p) : B(\text{fst}(p))$} 83 | \end{bprooftree} 84 | \] 85 | \[ 86 | \begin{bprooftree} 87 | \AxiomC{$\Gamma \vdash a : A$} 88 | \AxiomC{$\Gamma\vdash b : B(a)$} 89 | \BinaryInfC{$\Gamma\vdash \text{fst}(\langle a,b\rangle) \equiv a : A $} 90 | \end{bprooftree} 91 | \begin{bprooftree} 92 | \AxiomC{$\Gamma \vdash a : A$} 93 | \AxiomC{$\Gamma\vdash b : B(a)$} 94 | \BinaryInfC{$\Gamma\vdash \text{snd}(\langle a,b\rangle) \equiv b : B(a) $} 95 | \end{bprooftree} 96 | \] 97 | 98 | \textbf{The Id Rules} 99 | \[ 100 | \begin{bprooftree} 101 | \AxiomC{$\Gamma \vdash a:A$} 102 | \AxiomC{$\Gamma \vdash b:A$} 103 | \BinaryInfC{$\Gamma \vdash \text{id}_{A}(a,b) \text{ type}$} 104 | \end{bprooftree} 105 | \begin{bprooftree} 106 | \AxiomC{$\Gamma \vdash a:A$} 107 | \UnaryInfC{$\Gamma \vdash \text{refl}(a) : \text{id}_{A}(a,a)$} 108 | \end{bprooftree} 109 | \] 110 | 111 | \[ 112 | \begin{bprooftree} 113 | \AxiomC{$\Gamma,x:A,y:A,u: \text{id}_A(x,y) \vdash E(x,y,u) \text{ type}$} 114 | \AxiomC{$\Gamma, x : A \vdash e(x) : E(x,x,\text{refl}(x))$} 115 | \BinaryInfC{$\Gamma,x:A,y:A,u: \text{id}_A(x,y) \vdash \text{J}(x,y,u,e) : E(x,y,u)$} 116 | \end{bprooftree} 117 | \] 118 | 119 | \textbf{The Universe} 120 | \[ 121 | \begin{bprooftree} 122 | \AxiomC{$\Gamma \text{ ctx}$} 123 | \UnaryInfC{$\Gamma \vdash \text{U} \text{ type}$} 124 | \end{bprooftree} 125 | \begin{bprooftree} 126 | \AxiomC{$\Gamma \vdash a : \text{U}$} 127 | \UnaryInfC{$\Gamma \vdash \text{El}(a) \text{ type}$} 128 | \end{bprooftree} 129 | \] 130 | \[ 131 | \begin{bprooftree} 132 | \AxiomC{$\Gamma,a : \text{U}, x:\text{El}(a) \vdash b(x) : \text{U}$} 133 | \UnaryInfC{$\Gamma,a : \text{U} \vdash \pi(a,b(x)) : \text{U}$} 134 | \end{bprooftree} 135 | \begin{bprooftree} 136 | \AxiomC{$\Gamma,a : \text{U}, x:\text{El}(a) \vdash b(x) : \text{U}$} 137 | \UnaryInfC{$\Gamma,a : \text{U} \vdash \sigma(a,b(x)) : \text{U}$} 138 | \end{bprooftree} 139 | \begin{bprooftree} 140 | \AxiomC{$\Gamma,a : \text{U} \vdash \alpha : \text{El}(a)$} 141 | \AxiomC{$\Gamma,a : \text{U} \vdash \beta : \text{El}(a)$} 142 | \BinaryInfC{$\Gamma,a : \text{U} \vdash \iota(\alpha,\beta) : \text{U}$} 143 | \end{bprooftree} 144 | \] 145 | \[ 146 | \begin{bprooftree} 147 | \AxiomC{$\Gamma,a : \text{U}, x:\text{El}(a) \vdash b(x) : \text{U}$} 148 | \UnaryInfC{$\Gamma,a : \text{U} \vdash \text{El}(\pi(a,b(x))) \equiv \prod_{x : \text{El}(a)} \text{El}(b(x)) \text{ type}$} 149 | \end{bprooftree} 150 | \begin{bprooftree} 151 | \AxiomC{$\Gamma,a : \text{U}, x:\text{El}(a) \vdash b(x) : \text{U}$} 152 | \UnaryInfC{$\Gamma,a : \text{U} \vdash \text{El}(\sigma(a,b(x))) \equiv \sum_{x : \text{El}(a)} \text{El}(b(x)) \text{ type}$} 153 | \end{bprooftree} 154 | \] 155 | 156 | \textbf{Definitions and Axioms} 157 | 158 | To simplify, we denote non-dependent products and functions with $\times$ and $\to$. This is not part of the type theory but improves readability. 159 | 160 | \textbf{Truncation Levels} 161 | \begin{align*} 162 | \text{isContr}(A) &:= \sum_{x : A} \prod_{y : A} \text{id}_{A}(y,x)\\ 163 | \text{isProp}(A) &:= \prod_{x : A} \prod_{y : A} \text{id}_{A}(x,y)\\ 164 | \text{isSet}(A) &:= \prod_{x : A} \prod_{y: A} \text{isProp}(\text{Id}_{A}(x, y)) 165 | \end{align*} 166 | 167 | \textbf{The Set Universe} 168 | $$\text{Set} := \sum_{u : \text{U}} \text{isSet}(\text{El}(u))$$ 169 | 170 | \textbf{Type Equivalence} 171 | $$A \simeq B := \sum_{f :A \to B}\sum_{g :B \to A}\sum_{h :B \to A}\Big(\prod_{a : A} \text{id}_{A}(g(f(a)),a) \Big) \times \Big(\prod_{b : B} \text{id}_{B}(f(h(b)),b) \Big)$$ 172 | 173 | \textbf{Set Isomorphism} 174 | $$A \cong B := \text{isSet}(A) \times \text{isSet}(B)\times\sum_{f :A \to B}\sum_{g :B \to A}\Big(\prod_{a : A} \text{id}_{A}(g(f(a)),a) \Big) \times \Big(\prod_{b : B} \text{id}_{B}(f(g(b)),b) \Big)$$ 175 | 176 | \textbf{The Univalence Axiom} 177 | $$\text{UA}: \prod_{x : \text{U}} \prod_{y : \text{U}} \text{Id}_{\text{U}}(x,y) \simeq \Big(\text{El}(x) \simeq \text{El}(y)\Big)$$ 178 | 179 | \textbf{The Univalence Axiom for Sets} 180 | $$\text{UASet}: \prod_{x : \text{Set}} \prod_{y : \text{Set}} \text{Id}_{\text{Set}}(x,y) \cong \Big(\text{El}(x) \cong \text{El}(y)\Big)$$ 181 | 182 | \textbf{Function Extensionality} 183 | $$\text{FunExt}: \prod_{a : \text{U}} \prod_{b : \text{U}} \prod_{f : \text{El}(a) \to \text{El}(b)} \prod_{g : \text{El}(a) \to \text{El}(b)}\Big( \prod_{\alpha : \text{El}(a)}\text{id}_{\text{El(b)}}(f\alpha,g\alpha)\Big) \simeq \text{id}_{\text{El}(a) \to \text{El}(b)}(f,g)$$ 184 | -------------------------------------------------------------------------------- /blueprint/src/extra_styles.css: -------------------------------------------------------------------------------- 1 | /* This file contains CSS tweaks for this blueprint. 2 | * As an example, we included CSS rules that put 3 | * a vertical line on the left of theorem statements 4 | * and proofs. 5 | * */ 6 | 7 | div.theorem_thmcontent { 8 | border-left: .15rem solid black; 9 | } 10 | 11 | div.proposition_thmcontent { 12 | border-left: .15rem solid black; 13 | } 14 | 15 | div.lemma_thmcontent { 16 | border-left: .1rem solid black; 17 | } 18 | 19 | div.corollary_thmcontent { 20 | border-left: .1rem solid black; 21 | } 22 | 23 | div.proof_content { 24 | border-left: .08rem solid grey; 25 | } 26 | -------------------------------------------------------------------------------- /blueprint/src/latexmkrc: -------------------------------------------------------------------------------- 1 | # This file configures the latexmk command you can use to compile 2 | # the pdf version of the blueprint 3 | $pdf_mode = 1; 4 | $pdflatex = 'xelatex -synctex=1'; 5 | @default_files = ('print.tex'); -------------------------------------------------------------------------------- /blueprint/src/macros/common.tex: -------------------------------------------------------------------------------- 1 | % In this file you should put all LaTeX macros and settings to be used both by 2 | % the pdf version and the web version. 3 | % This should be most of your macros. 4 | 5 | % The theorem-like environments defined below are those that appear by default 6 | % in the dependency graph. See the README of leanblueprint if you need help to 7 | % customize this. 8 | % The configuration below use the theorem counter for all those environments 9 | % (this is what the [theorem] arguments mean) and never resets it. 10 | % If you want for instance to number them within chapters then you can add 11 | % [chapter] at the end of the next line. 12 | 13 | %%%%%%% THEOREMS %%%%%%%%% 14 | \newtheorem{theorem}{Theorem}[section] 15 | \newtheorem*{theorem*}{Theorem} 16 | \newtheorem{prop}[theorem]{Proposition} 17 | \newtheorem{obs}[theorem]{Observation} 18 | \newtheorem{lemma}[theorem]{Lemma} 19 | \newtheorem{cor}[theorem]{Corollary} 20 | \newtheorem{applemma}{Lemma}[section] 21 | 22 | \theoremstyle{definition} 23 | \newtheorem{defn}[theorem]{Definition} 24 | 25 | \theoremstyle{remark} 26 | \newtheorem{rmk}[theorem]{Remark} 27 | \newtheorem*{eg}{Example} 28 | \newtheorem{ex}{Exercise} 29 | \newtheorem*{remark*}{Remark} 30 | \newtheorem*{remarks*}{Remarks} 31 | \newtheorem*{notation*}{Notation} 32 | \newtheorem*{convention*}{Convention} 33 | 34 | \newenvironment{comment}{\begin{quote} \em Comment. }{\end{quote}} 35 | 36 | %%%%%%% Relations 37 | 38 | \newcommand{\defeq}{=_{\mathrm{def}}} 39 | \newcommand{\iso}{\cong} 40 | \newcommand{\equi}{\simeq} 41 | \newcommand{\retequi}{\unlhd} 42 | \newcommand{\op}{\mathrm{op}} 43 | \newcommand{\Nat}{\mathbb{N}} 44 | % \newcommand{\co}{\colon} 45 | \newcommand{\st}{\,|\,} 46 | 47 | 48 | %%% Morphisms 49 | 50 | \newcommand{\id}{\mathsf{id}} 51 | \newcommand{\yo}{\mathsf{y}} 52 | \newcommand{\Arr}{\mathsf{Arr}} 53 | \newcommand{\CartArr}{\mathsf{CartArr}} 54 | \newcommand{\unit}{\, \mathsf{unit} \, } 55 | \newcommand{\counit}{\, \mathsf{counit} \, } 56 | 57 | %%%% Objects 58 | 59 | \newcommand{\tcat}{\mathbf} 60 | \newcommand{\catC}{\mathbb{C}} 61 | \newcommand{\pshC}{\psh{\catC}} 62 | \newcommand{\psh}[1]{\mathbf{Psh}(#1)} %% consider renaming to \Psh 63 | \newcommand{\PSH}[1]{\mathbf{PSH}(#1)} 64 | \newcommand{\set}{\tcat{set}} 65 | \newcommand{\Set}{\tcat{Set}} 66 | \newcommand{\SET}{\tcat{SET}} 67 | \newcommand{\cat}{\tcat{cat}} 68 | \newcommand{\ptcat}{\tcat{cat}_\bullet} 69 | \newcommand{\Cat}{\tcat{Cat}} 70 | \newcommand{\ptCat}{\tcat{Cat}_\bullet} 71 | \newcommand{\grpd}{\tcat{grpd}} 72 | \newcommand{\Grpd}{\tcat{Grpd}} 73 | \newcommand{\ptgrpd}{\tcat{grpd}_\bullet} 74 | \newcommand{\ptGrpd}{\tcat{Grpd}_\bullet} 75 | \newcommand{\Pshgrpd}{\mathbf{Psh}(\grpd)} 76 | \newcommand{\PshCat}{\mathbf{Psh}(\Cat)} 77 | 78 | \newcommand{\terminal}{\bullet} 79 | \newcommand{\Two}{\bullet+\bullet} 80 | 81 | %%% Polynomials 82 | \newcommand{\PolyComp}{\lhd} 83 | \newcommand{\Poly}[1]{P_{#1}} 84 | \newcommand{\Star}[1]{{#1}^{\star}} 85 | 86 | 87 | %%%% Syntax 88 | 89 | \newcommand{\Type}{\mathsf{Ty}} 90 | \newcommand{\Term}{\mathsf{Tm}} 91 | \newcommand{\tp}{\mathsf{tp}} 92 | \newcommand{\disp}[1]{\mathsf{disp}_{#1}} 93 | \newcommand{\var}{\mathsf{var}} 94 | \newcommand{\Prop}{\mathsf{Prop}} 95 | \newcommand{\U}{\mathsf{U}} 96 | \newcommand{\E}{\mathsf{E}} 97 | \newcommand{\El}{\mathsf{El}} 98 | \newcommand{\pair}{\mathsf{pair}} 99 | \newcommand{\Id}{\mathsf{Id}} 100 | \newcommand{\refl}{\mathsf{refl}} 101 | \newcommand{\J}{\mathsf{J}} 102 | \newcommand{\fst}{\mathsf{fst}} 103 | \newcommand{\snd}{\mathsf{snd}} 104 | \newcommand{\ev}[2]{\mathsf{ev}_{#1} \, #2} 105 | \newcommand{\dom}{\mathsf{dom}} 106 | \newcommand{\cod}{\mathsf{cod}} 107 | \newcommand{\Exp}{\mathsf{Exp}} 108 | \newcommand{\fun}{\mathsf{fun}} 109 | \newcommand{\name}[1]{\ulcorner #1 \urcorner} 110 | 111 | \newcommand{\Fib}{\mathsf{Fib}} 112 | \newcommand{\lift}[2]{\mathsf{lift} \, #1 \, #2} 113 | \newcommand{\fiber}{\mathsf{fiber}} 114 | \newcommand{\Interval}{\mathbb{I}} 115 | \newcommand{\Lift}[2]{\mathsf{L}_{#1}^{#2}} 116 | 117 | %%%% Interpretation 118 | 119 | \newcommand{\doublesquarelbracket}{[\![} 120 | \newcommand{\doublesquarerbracket}{]\!]} 121 | \newcommand{\IntpCtx}[1]{\doublesquarelbracket #1 \doublesquarerbracket} 122 | \newcommand{\IntpType}[1]{\doublesquarelbracket #1 \doublesquarerbracket} 123 | \newcommand{\IntpTerm}[1]{\doublesquarelbracket #1 \doublesquarerbracket} 124 | 125 | % % Greek 126 | \newcommand{\al}{\alpha} 127 | \newcommand{\be}{\beta} 128 | \newcommand{\ga}{\gamma} 129 | \newcommand{\de}{\delta} 130 | \newcommand{\ep}{\varepsilon} 131 | \newcommand{\io}{\iota} 132 | \newcommand{\ka}{\kappa} 133 | \newcommand{\la}{\lambda} 134 | \newcommand{\om}{\omega} 135 | \newcommand{\si}{\sigma} 136 | 137 | \newcommand{\Ga}{\Gamma} 138 | \newcommand{\De}{\Delta} 139 | \newcommand{\Th}{\Theta} 140 | \newcommand{\La}{\Lambda} 141 | \newcommand{\Si}{\Sigma} 142 | \newcommand{\Om}{\Omega} 143 | 144 | % % Misc 145 | \newenvironment{bprooftree} 146 | {\leavevmode\hbox\bgroup} 147 | {\DisplayProof\egroup} 148 | -------------------------------------------------------------------------------- /blueprint/src/macros/print.tex: -------------------------------------------------------------------------------- 1 | % In this file you should put macros to be used only by 2 | % the printed version. Of course they should have a corresponding 3 | % version in macros/web.tex. 4 | % Typically the printed version could have more fancy decorations. 5 | % This should be a very short file. 6 | % 7 | % This file starts with dummy macros that ensure the pdf 8 | % compiler will ignore macros provided by plasTeX that make 9 | % sense only for the web version, such as dependency graph 10 | % macros. 11 | 12 | 13 | % Dummy macros that make sense only for web version. 14 | \newcommand{\lean}[1]{} 15 | \newcommand{\discussion}[1]{} 16 | \newcommand{\leanok}{} 17 | \newcommand{\mathlibok}{} 18 | \newcommand{\notready}{} 19 | % Make sure that arguments of \uses and \proves are real labels, by using invisible refs: 20 | % latex prints a warning if the label is not defined, but nothing is shown in the pdf file. 21 | % It uses LaTeX3 programming, this is why we use the expl3 package. 22 | \ExplSyntaxOn 23 | \NewDocumentCommand{\uses}{m} 24 | {\clist_map_inline:nn{#1}{\vphantom{\ref{##1}}}% 25 | \ignorespaces} 26 | \NewDocumentCommand{\proves}{m} 27 | {\clist_map_inline:nn{#1}{\vphantom{\ref{##1}}}% 28 | \ignorespaces} 29 | \ExplSyntaxOff -------------------------------------------------------------------------------- /blueprint/src/macros/web.tex: -------------------------------------------------------------------------------- 1 | % In this file you should put macros to be used only by 2 | % the web version. Of course they should have a corresponding 3 | % version in macros/print.tex. 4 | % Typically the printed version could have more fancy decorations. 5 | % This will probably be a very short file. -------------------------------------------------------------------------------- /blueprint/src/plastex.cfg: -------------------------------------------------------------------------------- 1 | [general] 2 | renderer=HTML5 3 | copy-theme-extras=yes 4 | plugins=plastexdepgraph plastexshowmore leanblueprint 5 | packages-dirs=./Packages/ 6 | extra-templates=./Templates/ 7 | 8 | [document] 9 | toc-depth=3 10 | toc-non-files=True 11 | 12 | [files] 13 | directory=../web/ 14 | split-level= 0 15 | 16 | [html5] 17 | localtoc-level=0 18 | extra-css=extra_styles.css 19 | mathjax-dollars=False 20 | -------------------------------------------------------------------------------- /blueprint/src/print.tex: -------------------------------------------------------------------------------- 1 | % This file makes a printable version of the blueprint 2 | % It should include all the \usepackage needed for the pdf version. 3 | % The template version assume you want to use a modern TeX compiler 4 | % such as xeLaTeX or luaLaTeX including support for unicode 5 | % and Latin Modern Math font with standard bugfixes applied. 6 | % It also uses expl3 in order to support macros related to the dependency graph. 7 | % It also includes standard AMS packages (and their improved version 8 | % mathtools) as well as support for links with a sober decoration 9 | % (no ugly rectangles around links). 10 | % It is otherwise a very minimal preamble (you should probably at least 11 | % add cleveref and tikz-cd). 12 | 13 | \documentclass[a4paper]{report} 14 | 15 | \usepackage{geometry} 16 | 17 | \usepackage{expl3} 18 | 19 | \usepackage{amsthm,amssymb,mathtools} 20 | \usepackage[unicode,colorlinks=true,linkcolor=blue,urlcolor=magenta, citecolor=blue]{hyperref} 21 | 22 | \usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} 23 | 24 | \usepackage{amsmath,stmaryrd,enumerate,a4,array} 25 | \usepackage{geometry} 26 | \usepackage{url} 27 | \usepackage[cmtip,all]{xy} 28 | \usepackage{subcaption} 29 | \usepackage{cleveref} 30 | \numberwithin{equation}{section} 31 | \usepackage[parfill]{parskip} 32 | \usepackage{tikz, tikz-cd, float} % Commutative Diagrams 33 | \usepackage{bussproofs} 34 | \usepackage{graphics} 35 | 36 | \input{macros/common} 37 | \input{macros/print} 38 | 39 | \input{chapter/all} 40 | -------------------------------------------------------------------------------- /blueprint/src/refs.bib: -------------------------------------------------------------------------------- 1 | @misc{awodey2023hofmannstreicheruniverses, 2 | title={On Hofmann-Streicher universes}, 3 | author={Steve Awodey}, 4 | year={2023}, 5 | eprint={2205.10917}, 6 | archivePrefix={arXiv}, 7 | primaryClass={math.CT}, 8 | url={https://arxiv.org/abs/2205.10917}, 9 | } 10 | 11 | @incollection {hofmannstreicher1996, 12 | AUTHOR = {Hofmann, Martin and Streicher, Thomas}, 13 | TITLE = {The groupoid interpretation of type theory}, 14 | BOOKTITLE = {Twenty-five years of constructive type theory 15 | ({V}enice, 1995)}, 16 | SERIES = {Oxford Logic Guides}, 17 | VOLUME = {36}, 18 | PAGES = {83--111}, 19 | PUBLISHER = {Oxford Univ. Press}, 20 | ADDRESS = {New York}, 21 | YEAR = {1998}, 22 | MRCLASS = {03B15 (68N15 68Q55)}, 23 | MRNUMBER = {1686862}, 24 | } 25 | 26 | @misc{joyalnlabmodelstructuresoncat, 27 | author = {André Joyal}, 28 | title = {Model structures on Cat}, 29 | howpublished = {\url{https://ncatlab.org/joyalscatlab/published/Model+structures+on+Cat}}, 30 | } 31 | 32 | @misc{awodey2017naturalmodelshomotopytype, 33 | title={Natural models of homotopy type theory}, 34 | author={Steve Awodey}, 35 | year={2017}, 36 | eprint={1406.3219}, 37 | archivePrefix={arXiv}, 38 | primaryClass={math.CT}, 39 | url={https://arxiv.org/abs/1406.3219}, 40 | } 41 | 42 | @misc{streicher1995ExtensionalConceptsInIntensionalTypeTheory, 43 | title={Extensional concepts in intensional type theory}, 44 | author={Martin Hofmann}, 45 | year={1995}, 46 | url={https://www2.mathematik.tu-darmstadt.de/~streicher/HabilStreicher.pdf}, 47 | } 48 | -------------------------------------------------------------------------------- /blueprint/src/web.tex: -------------------------------------------------------------------------------- 1 | % This file makes a web version of the blueprint 2 | % It should include all the \usepackage needed for this version. 3 | % The template includes standard AMS packages. 4 | % It is otherwise a very minimal preamble (you should probably at least 5 | % add cleveref and tikz-cd). 6 | 7 | \documentclass{report} 8 | 9 | \usepackage{amssymb, amsthm, amsmath} 10 | \usepackage{hyperref} 11 | \usepackage[showmore, dep_graph,thms=defn+prop+lemma+cor]{blueprint} 12 | \usepackage{tikz-cd} 13 | \usepackage{bussproofs} 14 | 15 | \input{macros/common} 16 | \input{macros/web} 17 | 18 | \home{https://sinhp.github.io/groupoid_model_in_lean4} 19 | \github{https://github.com/sinhp/groupoid_model_in_lean4} 20 | \dochome{https://sinhp.github.io/groupoid_model_in_lean4/docs} 21 | 22 | \input{chapter/all} 23 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | outputs = { self, nixpkgs, flake-utils }: 3 | flake-utils.lib.eachDefaultSystem (system: let 4 | pkgs = nixpkgs.legacyPackages.${system}; 5 | in { 6 | devShells.default = pkgs.mkShell { 7 | packages = with pkgs; [ 8 | bashInteractive 9 | typst 10 | texlive.combined.scheme-full 11 | python3 12 | graphviz 13 | ]; 14 | }; 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /home_page/404.html: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /404.html 3 | layout: default 4 | --- 5 | 6 | 19 | 20 |
21 |

404

22 | 23 |

Page not found :(

24 |

The requested page could not be found.

25 |
-------------------------------------------------------------------------------- /home_page/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # To upgrade, run `bundle update github-pages`. 4 | gem "github-pages", group: :jekyll_plugins 5 | # If you have any plugins, put them here! 6 | group :jekyll_plugins do 7 | #gem "jekyll-feed", "~> 0.12" 8 | end 9 | 10 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem 11 | # and associated library. 12 | platforms :mingw, :x64_mingw, :mswin, :jruby do 13 | gem "tzinfo", "~> 1.2" 14 | gem "tzinfo-data" 15 | end 16 | 17 | # Performance-booster for watching directories on Windows. 18 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] 19 | 20 | # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem 21 | # do not have a Java counterpart. 22 | gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] 23 | 24 | # Used for locally serving the website. 25 | gem "webrick", "~> 1.7" -------------------------------------------------------------------------------- /home_page/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activesupport (6.0.5) 5 | concurrent-ruby (~> 1.0, >= 1.0.2) 6 | i18n (>= 0.7, < 2) 7 | minitest (~> 5.1) 8 | tzinfo (~> 1.1) 9 | zeitwerk (~> 2.2, >= 2.2.2) 10 | addressable (2.8.0) 11 | public_suffix (>= 2.0.2, < 5.0) 12 | coffee-script (2.4.1) 13 | coffee-script-source 14 | execjs 15 | coffee-script-source (1.11.1) 16 | colorator (1.1.0) 17 | commonmarker (0.23.4) 18 | concurrent-ruby (1.1.10) 19 | dnsruby (1.61.9) 20 | simpleidn (~> 0.1) 21 | em-websocket (0.5.3) 22 | eventmachine (>= 0.12.9) 23 | http_parser.rb (~> 0) 24 | ethon (0.15.0) 25 | ffi (>= 1.15.0) 26 | eventmachine (1.2.7) 27 | execjs (2.8.1) 28 | faraday (1.10.0) 29 | faraday-em_http (~> 1.0) 30 | faraday-em_synchrony (~> 1.0) 31 | faraday-excon (~> 1.1) 32 | faraday-httpclient (~> 1.0) 33 | faraday-multipart (~> 1.0) 34 | faraday-net_http (~> 1.0) 35 | faraday-net_http_persistent (~> 1.0) 36 | faraday-patron (~> 1.0) 37 | faraday-rack (~> 1.0) 38 | faraday-retry (~> 1.0) 39 | ruby2_keywords (>= 0.0.4) 40 | faraday-em_http (1.0.0) 41 | faraday-em_synchrony (1.0.0) 42 | faraday-excon (1.1.0) 43 | faraday-httpclient (1.0.1) 44 | faraday-multipart (1.0.3) 45 | multipart-post (>= 1.2, < 3) 46 | faraday-net_http (1.0.1) 47 | faraday-net_http_persistent (1.2.0) 48 | faraday-patron (1.0.0) 49 | faraday-rack (1.0.0) 50 | faraday-retry (1.0.3) 51 | ffi (1.15.5) 52 | forwardable-extended (2.6.0) 53 | gemoji (3.0.1) 54 | github-pages (226) 55 | github-pages-health-check (= 1.17.9) 56 | jekyll (= 3.9.2) 57 | jekyll-avatar (= 0.7.0) 58 | jekyll-coffeescript (= 1.1.1) 59 | jekyll-commonmark-ghpages (= 0.2.0) 60 | jekyll-default-layout (= 0.1.4) 61 | jekyll-feed (= 0.15.1) 62 | jekyll-gist (= 1.5.0) 63 | jekyll-github-metadata (= 2.13.0) 64 | jekyll-include-cache (= 0.2.1) 65 | jekyll-mentions (= 1.6.0) 66 | jekyll-optional-front-matter (= 0.3.2) 67 | jekyll-paginate (= 1.1.0) 68 | jekyll-readme-index (= 0.3.0) 69 | jekyll-redirect-from (= 0.16.0) 70 | jekyll-relative-links (= 0.6.1) 71 | jekyll-remote-theme (= 0.4.3) 72 | jekyll-sass-converter (= 1.5.2) 73 | jekyll-seo-tag (= 2.8.0) 74 | jekyll-sitemap (= 1.4.0) 75 | jekyll-swiss (= 1.0.0) 76 | jekyll-theme-architect (= 0.2.0) 77 | jekyll-theme-cayman (= 0.2.0) 78 | jekyll-theme-dinky (= 0.2.0) 79 | jekyll-theme-hacker (= 0.2.0) 80 | jekyll-theme-leap-day (= 0.2.0) 81 | jekyll-theme-merlot (= 0.2.0) 82 | jekyll-theme-midnight (= 0.2.0) 83 | jekyll-theme-minimal (= 0.2.0) 84 | jekyll-theme-modernist (= 0.2.0) 85 | jekyll-theme-primer (= 0.6.0) 86 | jekyll-theme-slate (= 0.2.0) 87 | jekyll-theme-tactile (= 0.2.0) 88 | jekyll-theme-time-machine (= 0.2.0) 89 | jekyll-titles-from-headings (= 0.5.3) 90 | jemoji (= 0.12.0) 91 | kramdown (= 2.3.2) 92 | kramdown-parser-gfm (= 1.1.0) 93 | liquid (= 4.0.3) 94 | mercenary (~> 0.3) 95 | minima (= 2.5.1) 96 | nokogiri (>= 1.13.4, < 2.0) 97 | rouge (= 3.26.0) 98 | terminal-table (~> 1.4) 99 | github-pages-health-check (1.17.9) 100 | addressable (~> 2.3) 101 | dnsruby (~> 1.60) 102 | octokit (~> 4.0) 103 | public_suffix (>= 3.0, < 5.0) 104 | typhoeus (~> 1.3) 105 | html-pipeline (2.14.1) 106 | activesupport (>= 2) 107 | nokogiri (>= 1.4) 108 | http_parser.rb (0.8.0) 109 | i18n (0.9.5) 110 | concurrent-ruby (~> 1.0) 111 | jekyll (3.9.2) 112 | addressable (~> 2.4) 113 | colorator (~> 1.0) 114 | em-websocket (~> 0.5) 115 | i18n (~> 0.7) 116 | jekyll-sass-converter (~> 1.0) 117 | jekyll-watch (~> 2.0) 118 | kramdown (>= 1.17, < 3) 119 | liquid (~> 4.0) 120 | mercenary (~> 0.3.3) 121 | pathutil (~> 0.9) 122 | rouge (>= 1.7, < 4) 123 | safe_yaml (~> 1.0) 124 | jekyll-avatar (0.7.0) 125 | jekyll (>= 3.0, < 5.0) 126 | jekyll-coffeescript (1.1.1) 127 | coffee-script (~> 2.2) 128 | coffee-script-source (~> 1.11.1) 129 | jekyll-commonmark (1.4.0) 130 | commonmarker (~> 0.22) 131 | jekyll-commonmark-ghpages (0.2.0) 132 | commonmarker (~> 0.23.4) 133 | jekyll (~> 3.9.0) 134 | jekyll-commonmark (~> 1.4.0) 135 | rouge (>= 2.0, < 4.0) 136 | jekyll-default-layout (0.1.4) 137 | jekyll (~> 3.0) 138 | jekyll-feed (0.15.1) 139 | jekyll (>= 3.7, < 5.0) 140 | jekyll-gist (1.5.0) 141 | octokit (~> 4.2) 142 | jekyll-github-metadata (2.13.0) 143 | jekyll (>= 3.4, < 5.0) 144 | octokit (~> 4.0, != 4.4.0) 145 | jekyll-include-cache (0.2.1) 146 | jekyll (>= 3.7, < 5.0) 147 | jekyll-mentions (1.6.0) 148 | html-pipeline (~> 2.3) 149 | jekyll (>= 3.7, < 5.0) 150 | jekyll-optional-front-matter (0.3.2) 151 | jekyll (>= 3.0, < 5.0) 152 | jekyll-paginate (1.1.0) 153 | jekyll-readme-index (0.3.0) 154 | jekyll (>= 3.0, < 5.0) 155 | jekyll-redirect-from (0.16.0) 156 | jekyll (>= 3.3, < 5.0) 157 | jekyll-relative-links (0.6.1) 158 | jekyll (>= 3.3, < 5.0) 159 | jekyll-remote-theme (0.4.3) 160 | addressable (~> 2.0) 161 | jekyll (>= 3.5, < 5.0) 162 | jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) 163 | rubyzip (>= 1.3.0, < 3.0) 164 | jekyll-sass-converter (1.5.2) 165 | sass (~> 3.4) 166 | jekyll-seo-tag (2.8.0) 167 | jekyll (>= 3.8, < 5.0) 168 | jekyll-sitemap (1.4.0) 169 | jekyll (>= 3.7, < 5.0) 170 | jekyll-swiss (1.0.0) 171 | jekyll-theme-architect (0.2.0) 172 | jekyll (> 3.5, < 5.0) 173 | jekyll-seo-tag (~> 2.0) 174 | jekyll-theme-cayman (0.2.0) 175 | jekyll (> 3.5, < 5.0) 176 | jekyll-seo-tag (~> 2.0) 177 | jekyll-theme-dinky (0.2.0) 178 | jekyll (> 3.5, < 5.0) 179 | jekyll-seo-tag (~> 2.0) 180 | jekyll-theme-hacker (0.2.0) 181 | jekyll (> 3.5, < 5.0) 182 | jekyll-seo-tag (~> 2.0) 183 | jekyll-theme-leap-day (0.2.0) 184 | jekyll (> 3.5, < 5.0) 185 | jekyll-seo-tag (~> 2.0) 186 | jekyll-theme-merlot (0.2.0) 187 | jekyll (> 3.5, < 5.0) 188 | jekyll-seo-tag (~> 2.0) 189 | jekyll-theme-midnight (0.2.0) 190 | jekyll (> 3.5, < 5.0) 191 | jekyll-seo-tag (~> 2.0) 192 | jekyll-theme-minimal (0.2.0) 193 | jekyll (> 3.5, < 5.0) 194 | jekyll-seo-tag (~> 2.0) 195 | jekyll-theme-modernist (0.2.0) 196 | jekyll (> 3.5, < 5.0) 197 | jekyll-seo-tag (~> 2.0) 198 | jekyll-theme-primer (0.6.0) 199 | jekyll (> 3.5, < 5.0) 200 | jekyll-github-metadata (~> 2.9) 201 | jekyll-seo-tag (~> 2.0) 202 | jekyll-theme-slate (0.2.0) 203 | jekyll (> 3.5, < 5.0) 204 | jekyll-seo-tag (~> 2.0) 205 | jekyll-theme-tactile (0.2.0) 206 | jekyll (> 3.5, < 5.0) 207 | jekyll-seo-tag (~> 2.0) 208 | jekyll-theme-time-machine (0.2.0) 209 | jekyll (> 3.5, < 5.0) 210 | jekyll-seo-tag (~> 2.0) 211 | jekyll-titles-from-headings (0.5.3) 212 | jekyll (>= 3.3, < 5.0) 213 | jekyll-watch (2.2.1) 214 | listen (~> 3.0) 215 | jemoji (0.12.0) 216 | gemoji (~> 3.0) 217 | html-pipeline (~> 2.2) 218 | jekyll (>= 3.0, < 5.0) 219 | kramdown (2.3.2) 220 | rexml 221 | kramdown-parser-gfm (1.1.0) 222 | kramdown (~> 2.0) 223 | liquid (4.0.3) 224 | listen (3.7.1) 225 | rb-fsevent (~> 0.10, >= 0.10.3) 226 | rb-inotify (~> 0.9, >= 0.9.10) 227 | mercenary (0.3.6) 228 | minima (2.5.1) 229 | jekyll (>= 3.5, < 5.0) 230 | jekyll-feed (~> 0.9) 231 | jekyll-seo-tag (~> 2.1) 232 | minitest (5.15.0) 233 | multipart-post (2.1.1) 234 | nokogiri (1.13.6-arm64-darwin) 235 | racc (~> 1.4) 236 | nokogiri (1.13.6-x86_64-linux) 237 | racc (~> 1.4) 238 | octokit (4.22.0) 239 | faraday (>= 0.9) 240 | sawyer (~> 0.8.0, >= 0.5.3) 241 | pathutil (0.16.2) 242 | forwardable-extended (~> 2.6) 243 | public_suffix (4.0.7) 244 | racc (1.6.0) 245 | rb-fsevent (0.11.1) 246 | rb-inotify (0.10.1) 247 | ffi (~> 1.0) 248 | rexml (3.2.5) 249 | rouge (3.26.0) 250 | ruby2_keywords (0.0.5) 251 | rubyzip (2.3.2) 252 | safe_yaml (1.0.5) 253 | sass (3.7.4) 254 | sass-listen (~> 4.0.0) 255 | sass-listen (4.0.0) 256 | rb-fsevent (~> 0.9, >= 0.9.4) 257 | rb-inotify (~> 0.9, >= 0.9.7) 258 | sawyer (0.8.2) 259 | addressable (>= 2.3.5) 260 | faraday (> 0.8, < 2.0) 261 | simpleidn (0.2.1) 262 | unf (~> 0.1.4) 263 | terminal-table (1.8.0) 264 | unicode-display_width (~> 1.1, >= 1.1.1) 265 | thread_safe (0.3.6) 266 | typhoeus (1.4.0) 267 | ethon (>= 0.9.0) 268 | tzinfo (1.2.9) 269 | thread_safe (~> 0.1) 270 | unf (0.1.4) 271 | unf_ext 272 | unf_ext (0.0.8.1) 273 | unicode-display_width (1.8.0) 274 | webrick (1.7.0) 275 | zeitwerk (2.5.4) 276 | 277 | PLATFORMS 278 | arm64-darwin-22 279 | x86_64-linux 280 | 281 | DEPENDENCIES 282 | github-pages 283 | http_parser.rb (~> 0.6.0) 284 | tzinfo (~> 1.2) 285 | tzinfo-data 286 | wdm (~> 0.1.1) 287 | webrick (~> 1.7) 288 | 289 | BUNDLED WITH 290 | 2.3.14 291 | -------------------------------------------------------------------------------- /home_page/_config.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Jekyll! 2 | # 3 | # This config file is meant for settings that affect your whole blog, values 4 | # which you are expected to set up once and rarely edit after that. If you find 5 | # yourself editing this file very often, consider using Jekyll's data files 6 | # feature for the data you need to update frequently. 7 | # 8 | # For technical reasons, this file is *NOT* reloaded automatically when you use 9 | # 'bundle exec jekyll serve'. If you change this file, please restart the server process. 10 | # 11 | # If you need help with YAML syntax, here are some quick references for you: 12 | # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml 13 | # https://learnxinyminutes.com/docs/yaml/ 14 | # 15 | # Site settings 16 | # These are used to personalize your new site. If you look in the HTML files, 17 | # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. 18 | # You can create any custom variable you would like, and they will be accessible 19 | # in the templates via {{ site.myvariable }}. 20 | 21 | title: "HoTTLean : Formalizing the Meta-Theory of HoTT in Lean" 22 | #email: your-email@example.com 23 | description: by S. Awodey, M. Carneiro, S. Hazratpour, J. Hua, W. Nawrocki, S. Woolfson, Y. Xu 24 | baseurl: "" # the subpath of your site, e.g. /blog 25 | url: "https://sinhp.github.io/groupoid_model_in_lean4" # the base hostname & protocol for your site, e.g. http://example.com 26 | twitter_username: 27 | github_username: sinhp 28 | repository: sinhp/groupoid_model_in_lean4 29 | 30 | # Build settings 31 | remote_theme: pages-themes/cayman@v0.2.0 32 | plugins: 33 | - jekyll-remote-theme 34 | -------------------------------------------------------------------------------- /home_page/_include/mathjax.html: -------------------------------------------------------------------------------- 1 | 2 | {% if page.usemathjax %} 3 | 4 | 13 | 14 | 17 | {% endif %} -------------------------------------------------------------------------------- /home_page/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {% seo %} 8 | 9 | 11 | 12 | 13 | 14 | {% if jekyll.environment == "production" %} 15 | 17 | {% else %} 18 | 19 | {% endif %} 20 | {% include head-custom.html %} 21 | 22 | 23 | 24 | Skip to the content. 25 | 26 | 36 | 37 |
38 | {{ content }} 39 | 40 | 46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /home_page/_site/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Groupoid Model of HoTT in Lean 4 | by S. Awodey, M. Carneiro, S. Hazratpour, J. Hua, W. Nawrocki, S. Woolfson 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Skip to the content. 48 | 49 | 58 | 59 |
60 | 73 | 74 |
75 |

404

76 | 77 |

Page not found :(

78 |

The requested page could not be found.

79 |
80 | 81 | 87 |
88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /home_page/_site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Groupoid Model of HoTT in Lean 4 | by S. Awodey, M. Carneiro, S. Hazratpour, J. Hua, W. Nawrocki, S. Woolfson 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Skip to the content. 48 | 49 | 58 | 59 |
60 |

Useful links:

61 | 62 | 69 | 70 | 71 | 77 |
78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /home_page/assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | /* In this file you can add css rules overriding rules defined by your Jekyll theme. */ 5 | 6 | /* Import the CSS from the specified theme */ 7 | @import "{{ site.theme }}"; 8 | 9 | /* Put your rules below this line */ -------------------------------------------------------------------------------- /home_page/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # Feel free to add content and custom Front Matter to this file. 3 | # To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults 4 | 5 | # layout: home 6 | usemathjax: true 7 | --- 8 | 9 | Useful links: 10 | 11 | * [Zulip chat for Lean](https://leanprover.zulipchat.com/) for coordination 12 | * [Blueprint]({{ site.url }}/blueprint/) 13 | * [Blueprint as pdf]({{ site.url }}/blueprint.pdf) 14 | * [Dependency graph]({{ site.url }}/blueprint/dep_graph_document.html) 15 | * [Doc pages for this repository]({{ site.url }}/docs/) 16 | -------------------------------------------------------------------------------- /lake-manifest.json: -------------------------------------------------------------------------------- 1 | {"version": "1.1.0", 2 | "packagesDir": ".lake/packages", 3 | "packages": 4 | [{"url": "https://github.com/PatrickMassot/checkdecls.git", 5 | "type": "git", 6 | "subDir": null, 7 | "scope": "", 8 | "rev": "3d425859e73fcfbef85b9638c2a91708ef4a22d4", 9 | "name": "checkdecls", 10 | "manifestFile": "lake-manifest.json", 11 | "inputRev": null, 12 | "inherited": false, 13 | "configFile": "lakefile.lean"}, 14 | {"url": "https://github.com/Vtec234/Poly.git", 15 | "type": "git", 16 | "subDir": null, 17 | "scope": "", 18 | "rev": "b514a5adebd8046abbf93ad22109bace6c9faf2b", 19 | "name": "Poly", 20 | "manifestFile": "lake-manifest.json", 21 | "inputRev": "profunctor-naturality", 22 | "inherited": false, 23 | "configFile": "lakefile.lean"}, 24 | {"url": "https://github.com/Vtec234/lean4-seq", 25 | "type": "git", 26 | "subDir": null, 27 | "scope": "", 28 | "rev": "b6b76a5d7cc1c8b11c52f12a7bd90c460b7cba5a", 29 | "name": "seq", 30 | "manifestFile": "lake-manifest.json", 31 | "inputRev": null, 32 | "inherited": true, 33 | "configFile": "lakefile.lean"}, 34 | {"url": "https://github.com/leanprover-community/mathlib4.git", 35 | "type": "git", 36 | "subDir": null, 37 | "scope": "", 38 | "rev": "fbe595fc740ee7a1789c6e6ebefa322e054a41c0", 39 | "name": "mathlib", 40 | "manifestFile": "lake-manifest.json", 41 | "inputRev": null, 42 | "inherited": true, 43 | "configFile": "lakefile.lean"}, 44 | {"url": "https://github.com/leanprover-community/plausible", 45 | "type": "git", 46 | "subDir": null, 47 | "scope": "leanprover-community", 48 | "rev": "ebfb31672ab0a5b6d00a018ff67d2ec51ed66f3a", 49 | "name": "plausible", 50 | "manifestFile": "lake-manifest.json", 51 | "inputRev": "main", 52 | "inherited": true, 53 | "configFile": "lakefile.toml"}, 54 | {"url": "https://github.com/leanprover-community/LeanSearchClient", 55 | "type": "git", 56 | "subDir": null, 57 | "scope": "leanprover-community", 58 | "rev": "ba020ed434b9c5877eb62ff072a28f5ec56eb871", 59 | "name": "LeanSearchClient", 60 | "manifestFile": "lake-manifest.json", 61 | "inputRev": "main", 62 | "inherited": true, 63 | "configFile": "lakefile.toml"}, 64 | {"url": "https://github.com/leanprover-community/import-graph", 65 | "type": "git", 66 | "subDir": null, 67 | "scope": "leanprover-community", 68 | "rev": "c96401869916619b86e2e54dbb8e8488bd6dd19c", 69 | "name": "importGraph", 70 | "manifestFile": "lake-manifest.json", 71 | "inputRev": "main", 72 | "inherited": true, 73 | "configFile": "lakefile.toml"}, 74 | {"url": "https://github.com/leanprover-community/ProofWidgets4", 75 | "type": "git", 76 | "subDir": null, 77 | "scope": "leanprover-community", 78 | "rev": "a602d13aca2913724c7d47b2d7df0353620c4ee8", 79 | "name": "proofwidgets", 80 | "manifestFile": "lake-manifest.json", 81 | "inputRev": "v0.0.53", 82 | "inherited": true, 83 | "configFile": "lakefile.lean"}, 84 | {"url": "https://github.com/leanprover-community/aesop", 85 | "type": "git", 86 | "subDir": null, 87 | "scope": "leanprover-community", 88 | "rev": "ec060e0e10c685be8af65f288e23d026c9fde245", 89 | "name": "aesop", 90 | "manifestFile": "lake-manifest.json", 91 | "inputRev": "master", 92 | "inherited": true, 93 | "configFile": "lakefile.toml"}, 94 | {"url": "https://github.com/leanprover-community/quote4", 95 | "type": "git", 96 | "subDir": null, 97 | "scope": "leanprover-community", 98 | "rev": "d892d7a88ad0ccf748fb8e651308ccd13426ba73", 99 | "name": "Qq", 100 | "manifestFile": "lake-manifest.json", 101 | "inputRev": "master", 102 | "inherited": true, 103 | "configFile": "lakefile.toml"}, 104 | {"url": "https://github.com/leanprover-community/batteries", 105 | "type": "git", 106 | "subDir": null, 107 | "scope": "leanprover-community", 108 | "rev": "f2fb9809751c4646c68c329b14f7d229a93176fd", 109 | "name": "batteries", 110 | "manifestFile": "lake-manifest.json", 111 | "inputRev": "main", 112 | "inherited": true, 113 | "configFile": "lakefile.toml"}, 114 | {"url": "https://github.com/leanprover/lean4-cli", 115 | "type": "git", 116 | "subDir": null, 117 | "scope": "leanprover", 118 | "rev": "dd423cf2b153b5b14cb017ee4beae788565a3925", 119 | "name": "Cli", 120 | "manifestFile": "lake-manifest.json", 121 | "inputRev": "main", 122 | "inherited": true, 123 | "configFile": "lakefile.toml"}], 124 | "name": "groupoid_model", 125 | "lakeDir": ".lake"} 126 | -------------------------------------------------------------------------------- /lakefile.lean: -------------------------------------------------------------------------------- 1 | import Lake 2 | open Lake DSL 3 | 4 | package groupoid_model where 5 | -- Settings applied to both builds and interactive editing 6 | leanOptions := #[ 7 | ⟨`pp.unicode.fun, true⟩, -- pretty-prints `fun a ↦ b` 8 | ⟨`autoImplicit, false⟩, 9 | ⟨`relaxedAutoImplicit, false⟩ 10 | ] 11 | -- add any additional package configuration options here 12 | 13 | require Poly from git "https://github.com/Vtec234/Poly.git" @ "profunctor-naturality" 14 | 15 | @[default_target] 16 | lean_lib GroupoidModel where 17 | globs := #[`GroupoidModel] 18 | -- add any library configuration options here 19 | 20 | require checkdecls from git "https://github.com/PatrickMassot/checkdecls.git" 21 | 22 | meta if get_config? env = some "dev" then 23 | require «doc-gen4» from git 24 | "https://github.com/leanprover/doc-gen4" @ "v4.17.0-rc1" 25 | -------------------------------------------------------------------------------- /lean-toolchain: -------------------------------------------------------------------------------- 1 | leanprover/lean4:v4.18.0-rc1 2 | -------------------------------------------------------------------------------- /scripts/update_mathlib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Update Mathlib and the Lean toolchain. 4 | 5 | # Download the latest lean-toolchain file from the Mathlib4 repository 6 | curl -L https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain -o lean-toolchain 7 | 8 | # Update the Mathlib dependencies and ensure doc-gen is also updated 9 | # The `-R -Kenv=dev` flag ensures that the development environment is updated, including doc-gen 10 | lake -R -Kenv=dev update 11 | --------------------------------------------------------------------------------