├── .github └── workflows │ └── latex.yml ├── .gitignore ├── .latexmkrc ├── CITATION.cff ├── LICENCE ├── POPL23.tex ├── README.md ├── SPL.jpg ├── SRC ├── .latexmkrc ├── SRC (bad).md ├── SRC (bad).tex ├── SRC finals.md ├── SRC script.md ├── SRC.bib ├── SRC.pdf └── SRC.tex ├── biblio.bib ├── chapters ├── abstract.tex ├── acknowledgements.tex ├── appendix.tex ├── dedication.tex ├── discussion.tex ├── introduction.tex ├── laysummary.tex ├── model.tex ├── preface.tex ├── proofs.tex ├── sized.tex └── typography.tex ├── code ├── .gitignore ├── InftyConat.agda ├── InftyHIT.agda ├── InftyPair.agda ├── OrdSized.agda ├── README.md ├── SizeLoop.agda ├── SizeOrd.agda ├── SizeOrd.ced └── SizeOrd.v ├── figures ├── cic.tex ├── congruence.tex ├── definitions.tex ├── ind.tex ├── sized.tex ├── takahashi.tex └── translation.tex ├── iosevka.ttc ├── scratch ├── bounded-NW.pdf ├── bounded-NW.tex ├── bounded-ind.pdf ├── bounded-ind.tex ├── proofs-conversion.md ├── proofs-equivalence.md ├── successor-N.pdf ├── successor-N.tex ├── successor-W.pdf ├── successor-W.tex ├── successor-ind.pdf └── successor-ind.tex ├── style.sty ├── thesis.tex └── ubcdiss.cls /.github/workflows/latex.yml: -------------------------------------------------------------------------------- 1 | on: [push, workflow_dispatch] 2 | 3 | jobs: 4 | build_latex: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v3 8 | - run: docker run -v $(pwd):/workdir -w /workdir texlive/texlive latexmk --synctex=0 9 | - uses: actions/upload-artifact@v3 10 | with: 11 | name: thesis.pdf 12 | path: ubc_2022_november_chan_jonathan.pdf 13 | - run: docker run -v $(pwd):/workdir -w /workdir texlive/texlive latexmk --synctex=0 --jobname=POPL23 POPL23.tex 14 | - uses: actions/upload-artifact@v3 15 | with: 16 | name: POPL23.pdf 17 | path: POPL23.pdf 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Auxilliary, log, outline, PDF files 2 | *.aux 3 | *.log 4 | *.out 5 | *.pdf 6 | 7 | # Bibtex bibliography, log, backreferences 8 | *.bbl 9 | *.blg 10 | *.brf 11 | 12 | # Lists of tables/figures, table of contents 13 | *.lot 14 | *.lof 15 | *.toc 16 | 17 | # Index, makeindex source, makeindex log 18 | *.ind 19 | *.idx 20 | *.ilg 21 | 22 | # Recorder files, latexmk sources, synctex 23 | *.fls 24 | *.fdb_latexmk 25 | *.synctex.gz 26 | 27 | # Working directories and temporary files 28 | *_minted*/ 29 | *.vscode/ 30 | *~ -------------------------------------------------------------------------------- /.latexmkrc: -------------------------------------------------------------------------------- 1 | $pdf_mode = 4; 2 | $lualatex = 'lualatex --shell-escape --interaction=nonstopmode --synctex=1 %O %S'; 3 | $bibtex_use = 2; 4 | $success_cmd = 'latexmk --jobname=%R -c; [ ! -f thesis.pdf ] || mv thesis.pdf ubc_2022_november_chan_jonathan.pdf'; 5 | push @generated_exts, 'brf'; 6 | @default_files = ('thesis.tex'); -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | authors: 3 | - family-names: Chan 4 | given-names: Jonathan 5 | affiliation: University of British Columbia 6 | orcid: https://orcid.org/0000-0003-0830-3180 7 | title: Sized Dependent Types via Extensional Type Theory 8 | repository-code: https://github.com/ionathanch/msc-thesis 9 | license: MIT 10 | preferred-citation: 11 | type: mastersthesis 12 | title: Sized Dependent Types via Extensional Type Theory 13 | authors: 14 | - family-names: Chan 15 | given-names: Jonathan 16 | affiliation: University of British Columbia 17 | orcid: https://orcid.org/0000-0003-0830-3180 18 | institution: 19 | name: University of British Columbia 20 | month: 7 21 | year: 2022 22 | doi: TBD 23 | repository-code: https://github.com/ionathanch/msc-thesis 24 | license: CC-BY-4.0 -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Attribution 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution 4.0 International Public License 58 | 59 | By exercising the Licensed Rights (defined below), You accept and agree 60 | to be bound by the terms and conditions of this Creative Commons 61 | Attribution 4.0 International Public License ("Public License"). To the 62 | extent this Public License may be interpreted as a contract, You are 63 | granted the Licensed Rights in consideration of Your acceptance of 64 | these terms and conditions, and the Licensor grants You such rights in 65 | consideration of benefits the Licensor receives from making the 66 | Licensed Material available under these terms and conditions. 67 | 68 | 69 | Section 1 -- Definitions. 70 | 71 | a. Adapted Material means material subject to Copyright and Similar 72 | Rights that is derived from or based upon the Licensed Material 73 | and in which the Licensed Material is translated, altered, 74 | arranged, transformed, or otherwise modified in a manner requiring 75 | permission under the Copyright and Similar Rights held by the 76 | Licensor. For purposes of this Public License, where the Licensed 77 | Material is a musical work, performance, or sound recording, 78 | Adapted Material is always produced where the Licensed Material is 79 | synched in timed relation with a moving image. 80 | 81 | b. Adapter's License means the license You apply to Your Copyright 82 | and Similar Rights in Your contributions to Adapted Material in 83 | accordance with the terms and conditions of this Public License. 84 | 85 | c. Copyright and Similar Rights means copyright and/or similar rights 86 | closely related to copyright including, without limitation, 87 | performance, broadcast, sound recording, and Sui Generis Database 88 | Rights, without regard to how the rights are labeled or 89 | categorized. For purposes of this Public License, the rights 90 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 91 | Rights. 92 | 93 | d. Effective Technological Measures means those measures that, in the 94 | absence of proper authority, may not be circumvented under laws 95 | fulfilling obligations under Article 11 of the WIPO Copyright 96 | Treaty adopted on December 20, 1996, and/or similar international 97 | agreements. 98 | 99 | e. Exceptions and Limitations means fair use, fair dealing, and/or 100 | any other exception or limitation to Copyright and Similar Rights 101 | that applies to Your use of the Licensed Material. 102 | 103 | f. Licensed Material means the artistic or literary work, database, 104 | or other material to which the Licensor applied this Public 105 | License. 106 | 107 | g. Licensed Rights means the rights granted to You subject to the 108 | terms and conditions of this Public License, which are limited to 109 | all Copyright and Similar Rights that apply to Your use of the 110 | Licensed Material and that the Licensor has authority to license. 111 | 112 | h. Licensor means the individual(s) or entity(ies) granting rights 113 | under this Public License. 114 | 115 | i. Share means to provide material to the public by any means or 116 | process that requires permission under the Licensed Rights, such 117 | as reproduction, public display, public performance, distribution, 118 | dissemination, communication, or importation, and to make material 119 | available to the public including in ways that members of the 120 | public may access the material from a place and at a time 121 | individually chosen by them. 122 | 123 | j. Sui Generis Database Rights means rights other than copyright 124 | resulting from Directive 96/9/EC of the European Parliament and of 125 | the Council of 11 March 1996 on the legal protection of databases, 126 | as amended and/or succeeded, as well as other essentially 127 | equivalent rights anywhere in the world. 128 | 129 | k. You means the individual or entity exercising the Licensed Rights 130 | under this Public License. Your has a corresponding meaning. 131 | 132 | 133 | Section 2 -- Scope. 134 | 135 | a. License grant. 136 | 137 | 1. Subject to the terms and conditions of this Public License, 138 | the Licensor hereby grants You a worldwide, royalty-free, 139 | non-sublicensable, non-exclusive, irrevocable license to 140 | exercise the Licensed Rights in the Licensed Material to: 141 | 142 | a. reproduce and Share the Licensed Material, in whole or 143 | in part; and 144 | 145 | b. produce, reproduce, and Share Adapted Material. 146 | 147 | 2. Exceptions and Limitations. For the avoidance of doubt, where 148 | Exceptions and Limitations apply to Your use, this Public 149 | License does not apply, and You do not need to comply with 150 | its terms and conditions. 151 | 152 | 3. Term. The term of this Public License is specified in Section 153 | 6(a). 154 | 155 | 4. Media and formats; technical modifications allowed. The 156 | Licensor authorizes You to exercise the Licensed Rights in 157 | all media and formats whether now known or hereafter created, 158 | and to make technical modifications necessary to do so. The 159 | Licensor waives and/or agrees not to assert any right or 160 | authority to forbid You from making technical modifications 161 | necessary to exercise the Licensed Rights, including 162 | technical modifications necessary to circumvent Effective 163 | Technological Measures. For purposes of this Public License, 164 | simply making modifications authorized by this Section 2(a) 165 | (4) never produces Adapted Material. 166 | 167 | 5. Downstream recipients. 168 | 169 | a. Offer from the Licensor -- Licensed Material. Every 170 | recipient of the Licensed Material automatically 171 | receives an offer from the Licensor to exercise the 172 | Licensed Rights under the terms and conditions of this 173 | Public License. 174 | 175 | b. No downstream restrictions. You may not offer or impose 176 | any additional or different terms or conditions on, or 177 | apply any Effective Technological Measures to, the 178 | Licensed Material if doing so restricts exercise of the 179 | Licensed Rights by any recipient of the Licensed 180 | Material. 181 | 182 | 6. No endorsement. Nothing in this Public License constitutes or 183 | may be construed as permission to assert or imply that You 184 | are, or that Your use of the Licensed Material is, connected 185 | with, or sponsored, endorsed, or granted official status by, 186 | the Licensor or others designated to receive attribution as 187 | provided in Section 3(a)(1)(A)(i). 188 | 189 | b. Other rights. 190 | 191 | 1. Moral rights, such as the right of integrity, are not 192 | licensed under this Public License, nor are publicity, 193 | privacy, and/or other similar personality rights; however, to 194 | the extent possible, the Licensor waives and/or agrees not to 195 | assert any such rights held by the Licensor to the limited 196 | extent necessary to allow You to exercise the Licensed 197 | Rights, but not otherwise. 198 | 199 | 2. Patent and trademark rights are not licensed under this 200 | Public License. 201 | 202 | 3. To the extent possible, the Licensor waives any right to 203 | collect royalties from You for the exercise of the Licensed 204 | Rights, whether directly or through a collecting society 205 | under any voluntary or waivable statutory or compulsory 206 | licensing scheme. In all other cases the Licensor expressly 207 | reserves any right to collect such royalties. 208 | 209 | 210 | Section 3 -- License Conditions. 211 | 212 | Your exercise of the Licensed Rights is expressly made subject to the 213 | following conditions. 214 | 215 | a. Attribution. 216 | 217 | 1. If You Share the Licensed Material (including in modified 218 | form), You must: 219 | 220 | a. retain the following if it is supplied by the Licensor 221 | with the Licensed Material: 222 | 223 | i. identification of the creator(s) of the Licensed 224 | Material and any others designated to receive 225 | attribution, in any reasonable manner requested by 226 | the Licensor (including by pseudonym if 227 | designated); 228 | 229 | ii. a copyright notice; 230 | 231 | iii. a notice that refers to this Public License; 232 | 233 | iv. a notice that refers to the disclaimer of 234 | warranties; 235 | 236 | v. a URI or hyperlink to the Licensed Material to the 237 | extent reasonably practicable; 238 | 239 | b. indicate if You modified the Licensed Material and 240 | retain an indication of any previous modifications; and 241 | 242 | c. indicate the Licensed Material is licensed under this 243 | Public License, and include the text of, or the URI or 244 | hyperlink to, this Public License. 245 | 246 | 2. You may satisfy the conditions in Section 3(a)(1) in any 247 | reasonable manner based on the medium, means, and context in 248 | which You Share the Licensed Material. For example, it may be 249 | reasonable to satisfy the conditions by providing a URI or 250 | hyperlink to a resource that includes the required 251 | information. 252 | 253 | 3. If requested by the Licensor, You must remove any of the 254 | information required by Section 3(a)(1)(A) to the extent 255 | reasonably practicable. 256 | 257 | 4. If You Share Adapted Material You produce, the Adapter's 258 | License You apply must not prevent recipients of the Adapted 259 | Material from complying with this Public License. 260 | 261 | 262 | Section 4 -- Sui Generis Database Rights. 263 | 264 | Where the Licensed Rights include Sui Generis Database Rights that 265 | apply to Your use of the Licensed Material: 266 | 267 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 268 | to extract, reuse, reproduce, and Share all or a substantial 269 | portion of the contents of the database; 270 | 271 | b. if You include all or a substantial portion of the database 272 | contents in a database in which You have Sui Generis Database 273 | Rights, then the database in which You have Sui Generis Database 274 | Rights (but not its individual contents) is Adapted Material; and 275 | 276 | c. You must comply with the conditions in Section 3(a) if You Share 277 | all or a substantial portion of the contents of the database. 278 | 279 | For the avoidance of doubt, this Section 4 supplements and does not 280 | replace Your obligations under this Public License where the Licensed 281 | Rights include other Copyright and Similar Rights. 282 | 283 | 284 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 285 | 286 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 287 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 288 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 289 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 290 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 291 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 292 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 293 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 294 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 295 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 296 | 297 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 298 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 299 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 300 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 301 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 302 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 303 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 304 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 305 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 306 | 307 | c. The disclaimer of warranties and limitation of liability provided 308 | above shall be interpreted in a manner that, to the extent 309 | possible, most closely approximates an absolute disclaimer and 310 | waiver of all liability. 311 | 312 | 313 | Section 6 -- Term and Termination. 314 | 315 | a. This Public License applies for the term of the Copyright and 316 | Similar Rights licensed here. However, if You fail to comply with 317 | this Public License, then Your rights under this Public License 318 | terminate automatically. 319 | 320 | b. Where Your right to use the Licensed Material has terminated under 321 | Section 6(a), it reinstates: 322 | 323 | 1. automatically as of the date the violation is cured, provided 324 | it is cured within 30 days of Your discovery of the 325 | violation; or 326 | 327 | 2. upon express reinstatement by the Licensor. 328 | 329 | For the avoidance of doubt, this Section 6(b) does not affect any 330 | right the Licensor may have to seek remedies for Your violations 331 | of this Public License. 332 | 333 | c. For the avoidance of doubt, the Licensor may also offer the 334 | Licensed Material under separate terms or conditions or stop 335 | distributing the Licensed Material at any time; however, doing so 336 | will not terminate this Public License. 337 | 338 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 339 | License. 340 | 341 | 342 | Section 7 -- Other Terms and Conditions. 343 | 344 | a. The Licensor shall not be bound by any additional or different 345 | terms or conditions communicated by You unless expressly agreed. 346 | 347 | b. Any arrangements, understandings, or agreements regarding the 348 | Licensed Material not stated herein are separate from and 349 | independent of the terms and conditions of this Public License. 350 | 351 | 352 | Section 8 -- Interpretation. 353 | 354 | a. For the avoidance of doubt, this Public License does not, and 355 | shall not be interpreted to, reduce, limit, restrict, or impose 356 | conditions on any use of the Licensed Material that could lawfully 357 | be made without permission under this Public License. 358 | 359 | b. To the extent possible, if any provision of this Public License is 360 | deemed unenforceable, it shall be automatically reformed to the 361 | minimum extent necessary to make it enforceable. If the provision 362 | cannot be reformed, it shall be severed from this Public License 363 | without affecting the enforceability of the remaining terms and 364 | conditions. 365 | 366 | c. No term or condition of this Public License will be waived and no 367 | failure to comply consented to unless expressly agreed to by the 368 | Licensor. 369 | 370 | d. Nothing in this Public License constitutes or may be interpreted 371 | as a limitation upon, or waiver of, any privileges and immunities 372 | that apply to the Licensor or You, including from the legal 373 | processes of any jurisdiction or authority. 374 | 375 | 376 | ======================================================================= 377 | 378 | Creative Commons is not a party to its public licenses. 379 | Notwithstanding, Creative Commons may elect to apply one of its public 380 | licenses to material it publishes and in those instances will be 381 | considered the “Licensor.” The text of the Creative Commons public 382 | licenses is dedicated to the public domain under the CC0 Public Domain 383 | Dedication. Except for the limited purpose of indicating that material 384 | is shared under a Creative Commons public license or as otherwise 385 | permitted by the Creative Commons policies published at 386 | creativecommons.org/policies, Creative Commons does not authorize the 387 | use of the trademark "Creative Commons" or any other trademark or logo 388 | of Creative Commons without its prior written consent including, 389 | without limitation, in connection with any unauthorized modifications 390 | to any of its public licenses or any other arrangements, 391 | understandings, or agreements concerning use of licensed material. For 392 | the avoidance of doubt, this paragraph does not form part of the public 393 | licenses. 394 | 395 | Creative Commons may be contacted at creativecommons.org. 396 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sized Dependent Types via Extensional Type Theory 2 | 3 | ## Graduation Checklist 4 | 5 | **DEADLINE: 26 August 2022** 6 | 7 | * Apply for graduation in SSC 8 | * Present thesis at a department seminar 9 | * Schedule date with supervisor and committee members 10 | * Book a meeting room on [My CS](https://my.cs.ubc.ca/) 11 | * Send date, time, location, supervisor's name, thesis title, abstract to [grad-info@cs.ubc.ca](mailto:grad-info@cs.ubc.ca) seven days in advance 12 | * ~~Have supervisor enter supervisory committee in [SISC](https://www.grad.ubc.ca/forms/masters-thesis-approval)~~ Joyce does this 13 | * Send the following forms to [Joyce](mailto:poon@cs.ubc.ca): 14 | * [Master's thesis approval form](https://www.grad.ubc.ca/sites/default/files/forms/masters_thesis_approval.pdf) (signed by supervisor and supervisory committee member) 15 | * [Thesis submission cover sheet](https://www.grad.ubc.ca/sites/default/files/forms/thesis_dissertation_cover_sheet.pdf) 16 | * Register for a [cIRcle](https://circle.library.ubc.ca/register) account 17 | * Send name and email address to [G+PS](mailto:graduate.thesis@ubc.ca) to activate account _after_ Joyce has sent the above forms to G+PS 18 | * Submit thesis to cIRcle named as `ubc_2022_november_chan_jonathan.pdf` 19 | * Send [MSc release form](https://my.cs.ubc.ca/system/files/docs/mscreleaseform.pdf) to [Joyce](mailto:poon@cs.ubc.ca) with signatures/emails from: 20 | * Supervisor 21 | * [Group Assistant](mailto:ga-help@cs.ubc.ca) 22 | * [Help Desk](mailto:helpdeskers@cs.ubc.ca) 23 | * [Undergrad Program Assistant](mailto:undergrad-info@cs.ubc.ca) 24 | * [CS Reading Room](mailto:rdngroom@cs.ubc.ca) 25 | 26 | ### Helpful Links 27 | 28 | * [Structure of Theses and Dissertations](https://www.grad.ubc.ca/current-students/dissertation-thesis-preparation/structure-theses-dissertations) 29 | * [Formatting Requirements](https://www.grad.ubc.ca/current-students/dissertation-thesis-preparation/formatting-requirements) 30 | * [Final Submission Requirements](https://www.grad.ubc.ca/current-students/final-dissertation-thesis-submission/final-submission-instructions) 31 | * [UBC Open Collections - MSc Theses](https://open.library.ubc.ca/search?collection=ubctheses&q=campus:%22%20UBCV%22%20affiliation:%22Computer%20Science,%20Department%20of%22&program=Computer%20Science°ree=Master%20of%20Science%20-%20MSc) 32 | * [Graduation from MSc Program](https://my.cs.ubc.ca/docs/graduation-msc-program) 33 | * [MSc Graduation Checklist](https://my.cs.ubc.ca/docs/msc-graduation-checklist) 34 | * [Rasmussen Bindery - Thesis binding](https://www.rasmussenbindery.com/thesis-binding/) 35 | * Costs are on website; colour printing is ~0.40$ a page 36 | -------------------------------------------------------------------------------- /SPL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/SPL.jpg -------------------------------------------------------------------------------- /SRC/.latexmkrc: -------------------------------------------------------------------------------- 1 | $pdf_mode = 4; 2 | $lualatex = 'lualatex --shell-escape --interaction=nonstopmode --synctex=1 %O %S'; 3 | $clean_ext = '%R.brf %R.bbl'; 4 | @default_files = ('SRC.tex'); -------------------------------------------------------------------------------- /SRC/SRC (bad).md: -------------------------------------------------------------------------------- 1 | # A Syntactic Model of Sized Dependent Types 2 | 3 | ## ??? 4 | 5 | The types-as-propositions paradigm associates certain type theories with formal logical systems, 6 | and consequently types in those theories with propositions in those logics. 7 | Furthermore, well-typed programs are associated with proofs of the corresponding proposition. 8 | Many dependent type theories, for instance, correspond to higher-order logics, 9 | and having an automated type checker means having the ability to automatically verify proofs. 10 | One must be careful, however, not to allow nonterminating programs, 11 | because they correspond to logical inconsistencies, i.e. proofs of falsehood; 12 | additionally, in dependent type checkers where programs may be evaluated during type checking, 13 | failure to rule out nonterminating programs leads to nonterminating type checking. 14 | Contemporary proof assistants based on dependent type theories, such as Coq, Agda, Lean, Idris, 15 | and many more, typically restrict recursive functions to _structurally-recursive_ ones, 16 | where the argument of recursive calls must be _syntactically_ smaller. 17 | As an example, consider the following function `minus n m` that computes $\min(n - m, 0)$. 18 | 19 | ```agda 20 | minus : Nat → Nat → Nat 21 | minus Zero m = Zero 22 | minus n Zero = n 23 | minus (Succ n) (Succ m) = minus n m 24 | ``` 25 | 26 | Inuitively, any well-typed call to `minus` is guaranteed to terminate because the recursive call 27 | only occurs on constructor arguments, and the base cases must be reached eventually. 28 | However, we often wish to write terminating functions that aren't necessarily syntactically recursive. 29 | Consider now the following function `div n m` that computes $\lceil\frac{n}{m+1}\rceil$ using `minus`. 30 | 31 | ```agda 32 | div : Nat → Nat → Nat 33 | div Zero m = Zero 34 | div (Succ n) m = Succ (div (minus n m) m) 35 | ``` 36 | 37 | Despite the fact that `minus` returns a natural no greater than its first argument, 38 | meaning that the first argument of the recursive call to `div` has a smaller magnitude 39 | than the original argument, 40 | the type checker is unable to conclude that this is a terminating function, 41 | because the first argument isn't _syntactically_ smaller (i.e. `n`). 42 | The programmer would have to alter the definition of `minus` to prove this property, 43 | as well as the definition of `div` to use this proof, making writing otherwise simple code burdensome. 44 | Sometimes it would be possible to make the type checker a little more clever by selectively inlining 45 | certain functions that allow the syntactic termination check to pass, 46 | but this is not always possible, and requiring inlining just to pass termination checking is anti-modular. 47 | If inlining `minus` in the body of `div` helped, then we are forced to import its entire definition, 48 | rather than merely its name and type, as is only required for type checking alone. 49 | 50 | 51 | 52 | A _type-based_ rather than syntactic method of termination checking uses _sized types_ (Hughes 1996), 53 | where a function is guaranteed to terminate simply if it type checks. 54 | To use sized types, we first alter our definition of naturals to take a size expression as a parameter. 55 | 56 | ```agda 57 | data Nat [α] : Type where 58 | Zero : ∀β < α. Nat [α] 59 | Succ : ∀β < α. Nat [β] → Nat [α] 60 | ``` 61 | 62 | The bounded size quantification `∀β < α.` asks for some size `β` strictly smaller than `α`. 63 | So to construct the successor of some natural `n : Nat [s]`, we need a size larger than `s`. 64 | Let `↑s` denote the next size up from `s`. 65 | Then the successor is simply `Succ {↑s} [s] n` (using curly braces for the implicit size parameter). 66 | Next, let us express the fact that `minus` returns a natural no larger than its first argument using sizes, 67 | i.e. that `minus` is in fact _size-preserving_. 68 | 69 | ```agda 70 | minus : ∀α β. Nat [α] → Nat [β] → Nat [α] 71 | ``` 72 | 73 | Now we are able to write a `div` function that the type checker will accept to be terminating 74 | with just a few more annotations. 75 | 76 | ```agda 77 | div : ∀α β. Nat [α] → Nat [β] → Nat [α] 78 | div [α] [β] (Zero {α} [γ]) m = Zero {α} [γ] 79 | div [α] [β] (Succ {α} [γ] n) m = Succ {α} [γ] (div [γ] [β] (minus [γ] [β] n m) m) 80 | ``` 81 | 82 | In the second branch, when matching on the first argument of size `α`, we have the successor of `n`, 83 | which itself has size `γ < α`. 84 | Then the call to `minus` returns a natural of size `γ`, which is then passed to the recursive call of `div`. 85 | Type checking passes without problem because the size `γ` of the recursive call is strictly smaller 86 | than the size `α` of the original call to `div`. 87 | More precisely, when expressing recursive functions as fixpoints, 88 | their typing rule and reduction behaviour is the following 89 | (using e[x ↦ e'] to denote substitution of x by e' in e): 90 | 91 | ``` 92 | Γ, α, f : ∀β < α. σ[α ↦ β] ⊢ e : σ 93 | ---------------------------------- fix 94 | Γ ⊢ fix f [α] : σ := e : ∀α. σ 95 | 96 | (fix f [α] : σ := e) [s] e' ⊳ e[α ↦ s, f ↦ Λβ < s. (fix f [α] : σ := e) [β]] e' 97 | ``` 98 | 99 | A fixpoint is well-typed if the body has the same type under the environment where 100 | the recursive reference to the fixpoint quantifies over a _smaller_ size. 101 | When reducing the fixpoint applied to some size, we substitute in the body the fixpoint bounded by that size. 102 | 103 | 121 | 122 | ## ??? 123 | 124 | Once we have a program and correctness proofs about the program, we may wish to compile and run our program. 125 | In Coq and Agda, programs get _extracted_ to OCaml and Haskell code, respectively, which are then compiled. 126 | However, the process of extraction necessarily discards some type information, 127 | since the extraction targets are not dependently typed. 128 | This makes it possible to link our proven-safe program after extraction with unsafe code, 129 | which might cause runtime errors, making all of the work proving it correct in vain. 130 | To ensure that our proofs are preserved and verified even during linking, 131 | we want to compile our code in a _type-preserving_ manner (Bowman, 2018). 132 | The type-based nature of sized types makes it more amenable than syntactic termination checking 133 | to type-preserving compilation of recursive functions. 134 | 135 | Traditionally in dependent type theories, there are two mutually-dependent judgements: 136 | the typing judgement, and the (typed) equality judgement. 137 | Equality is used in the following typing rule: 138 | 139 | ``` 140 | Γ ⊢ e : τ 141 | Γ ⊢ τ ≡ σ : Type 142 | ---------------- conv 143 | Γ ⊢ e : σ 144 | ``` 145 | 146 | Meanwhile, typing premises are used in various equality rules. 147 | However, the mutual dependency between the judgements greatly complicate proving type preservation of compilers. 148 | As an alternative, type theories with untyped equality are used, 149 | meaning that typing premises do not appear in equality judgements, breaking the mutual dependency. 150 | 151 | 152 | 153 | The ultimate goal is to define a sized dependent type theory for use as the core calculus of a proof assistant, 154 | and a type-preserving compiler so that we can run the programs about which we prove properties. 155 | This work is merely the modest beginnings of such an endeavour, 156 | starting with showing that we have a suitable type theory to work with. 157 | We therefore seek to prove the logical consistency of a type theory with the following features: 158 | 159 | * Dependent types; 160 | * Untyped equality; 161 | * Bounded size quantification (i.e. ∀α. τ); and 162 | * Higher-rank size quantification (i.e. ∀α. (∀β. τ) → σ). 163 | 164 | To our knowledge, there is no past theoretical work on a type theory with all four features. 165 | Barthe et al. (2006), Grégoire and Sacchini (2010), Sacchini (2011), and Sacchini (2013) 166 | introduce and prove consistent a lineage of Calculi of (Co)Inductive Constructions (CIC) 167 | with no bounded size quantification and rank-1 (that is, prenex) size quantification. 168 | Meanwhile, Abel (2006), Abel (2010), Abel (2012), and Abel and Pientka (2016) introduce first 169 | higher-rank size quantification followed by bounded size quantification, but in variants of System Fω. 170 | The most recent work on dependent sized types is Abel (2017), 171 | who proves the consistency of a dependent type theory with naturals and higher-rank size quantification. 172 | However, not only does that type theory use typed equality, 173 | but the method by which consistency is proven relies on it as well, 174 | so it cannot easily be extended to suit our needs. 175 | 176 | The usual methods of proving consistency involve vastly complex set-theoretic models of the type theory 177 | requiring a lot of work to set up correctly and knowledge of advanced set-theoretic methods. 178 | The majority of Sacchini's dissertation (2011), for instance, is devoted to proving consistency. 179 | Instead of taking the set-theoretic model approach, we define a _syntactic_ model (Boulier et al. 2017), 180 | which is essentially a type-preserving compiler from our source type theory 181 | into a target type theory that is known to be consistent. 182 | If there is such a compiler, then the source type theory must be consistent as well, 183 | for if one could prove an inconsistency in the source, 184 | then its type-preserving interpretation would be a proof of inconsistency in the target, which is a contradiction. 185 | The remainder of this abstract discusses an attempt at a syntactic model of a sized type theory 186 | with all four of the above features in _extensional CIC_, 187 | along with problems with the model that remain to be solved. 188 | 189 | ## The Syntactic Model 190 | 191 | The source language is the Generalized Calclulus of Constructions with definitions (CCω) (Harper and Pollack, 1991) — 192 | that is, a Calculus of Constructions with untyped equality, a cumulative universe hierarchy, and `let` expressions — 193 | extended with bounded and unbounded size quantification, abstraction, and application, 194 | as well as size expressions consisting of size variables, a base size, and the size successor operator `↑·`. 195 | We can add to this fixpoints and inductive types in general, but for the purposes of this discussion we add only fixpoints and two well-known examples: 196 | naturals and the W type. 197 | The target language is the Extensional Calculus of Inductive Constructions (CICᴱ) (Oury, 2005). 198 | Inductive definitions provide us with the expressivity needed to translate naturals, W types, sizes, and their ordering relation, 199 | while extensionality (that is, equality reflection) is a technical requirement of the proofs. 200 | 201 | Notice that in our sized definition of the naturals, 202 | we treat its size as if it were a parameter. 203 | This is exactly what we do in the interpretation: 204 | we parametrize inductive definitions by a `Size` inductive type. 205 | Because the source only has base and successor sizes, 206 | it might be tempting to implement `Size` with only these constructors. 207 | While this works for expressing naturals of all sizes, 208 | this doesn't scale to _general_ inductive definitions like the W type, 209 | where a construction might conceptually have an "infinite" number of subconstructions, so to speak. 210 | Taking inspiration from the set-theoretic models where sizes are interpreted as set-theoretic ordinals, 211 | we define `Size` as an inductive similar to type-theoretic ordinals, namely Brouwer ordinals (Kraus et al. 2021). 212 | A `Size` is then either a successor size or a limit size. 213 | 214 | ```agda 215 | data Size : Type where 216 | ↑_ : Size → Size 217 | ⊔_ : {A : Type} → (A → Size) → Size 218 | ``` 219 | 220 | The limit size constructor, given some function `f : A → Size`, 221 | can be thought of as the least upper bound of all the sizes produced by `f`. 222 | In fact, we can define a nonstrict preorder on `Size` that ensures this property. 223 | 224 | ```agda 225 | data _≤_ : Size → Size → Type where 226 | mono : ∀ α β → α ≤ β → ↑ α ≤ ↑ β 227 | cocone : ∀ β f → (∃[ x ] β ≤ f x) → β ≤ ⊔ f 228 | limit : ∀ β f → (∀ x → f x ≤ β) → ⊔ f ≤ β 229 | ``` 230 | 231 | `cocone` asserts that `⊔ f` is an upper bound of sizes returned by `f`, 232 | while `limit` asserts that it a _least_ upper bound; 233 | `mono` is the usual monotonicity of the successor operator with respect to the order. 234 | From this nonstrict preorder, we define the corresponding strict preorder `α < β` simply as `↑ α ≤ β`. 235 | Now we are able to define the interpretation of naturals and the W type in the target language. 236 | 237 | ```agda 238 | data ℕ (α : Size) : Type where 239 | zero : ∀ β → β < α → ℕ α 240 | succ : ∀ β → β < α → ℕ β → ℕ α 241 | 242 | data 𝕎 (α : Size) (A : Type) (B : A → Type) : Type where 243 | sup : ∀ β → β < α → (x : A) → (B x → 𝕎 β A B) → 𝕎 α A B 244 | ``` 245 | 246 | The translation for universes, functions, `let` expressions, and `case` expressions are fairly straightforward. 247 | But what about for fixpoints? 248 | The key insight is that fixpoints no longer correspond to structural induction on some inductive datum, 249 | but instead _well-founded induction_ on `Size`, which we can prove via an _accessibility predicate_. 250 | 251 | ```agda 252 | data Acc (α : Size) : Type where 253 | acc : (∀ β → β < α → Acc β) → Acc α 254 | 255 | accSize : ∀ α → Acc α 256 | elim : (P : Size → Type) → (∀ α → (∀ β → β < α → P β) → P α) → (∀ α → P α) 257 | ``` 258 | 259 | Intuitively, accessibility of sizes says that there is no infinitely-descending chain of sizes ordered by `<`, 260 | while well-founded induction says that to prove a property about a size, 261 | it suffices to show that it can be proven assuming that it holds for all smaller sizes. 262 | Now consider a fixpoint `fix f [α] : σ := e`, whose type is `∀α. σ`. 263 | If we informally associate `σ` with the first argument `P` of `elim`, 264 | then the type of the fixpoint looks a lot like the return type of `elim`. 265 | In fact, recalling the premise of the fixpoint typing rule, 266 | 267 | ``` 268 | Γ, α, (f : ∀β < α. σ[α ↦ β]) ⊢ e : σ 269 | ``` 270 | 271 | this looks exactly like the second argument type of `elim`. 272 | Formally, we define the translation of a fixpoint as follows, 273 | using `⟦·⟧` to denote the translation of a source term, 274 | completing the translation to target terms. 275 | 276 | ``` 277 | ⟦fix f [α] : σ := e⟧ ≝ elim (λα : Size. ⟦σ⟧) (λα : Size. λf : ∀β → β < α → ⟦σ[α ↦ β]⟧. ⟦e⟧) 278 | ``` 279 | 280 | ## Problems with the Model and Future Work 281 | -------------------------------------------------------------------------------- /SRC/SRC (bad).tex: -------------------------------------------------------------------------------- 1 | \documentclass[acmsmall,nonacm]{acmart} 2 | \acmConference[]{}{}{} 3 | 4 | \usepackage{minted} 5 | \newmintinline[agda]{agda}{escapeinside=<>,mathescape=true} 6 | 7 | \newcommand{\α}{\alpha} 8 | \newcommand{\β}{\beta} 9 | \newcommand{\γ}{\gamma} 10 | \newcommand{\σ}{\sigma} 11 | \newcommand{\Γ}{\Gamma} 12 | \newcommand{\Λ}{\Lambda} 13 | \newcommand{\∀}{\forall} 14 | \newcommand{\↑}{\uparrow} 15 | \newcommand{\⊢}{\vdash} 16 | \newcommand{\↦}{\mapsto} 17 | \newcommand{\⊳}{\rhd} 18 | \newcommand{\fix}{\textrm{fix}} 19 | 20 | % Each submission (referred to as “abstract” below) should include the student author’s name and e-mail address; 21 | % institutional affiliation; research advisor’s name; ACM student member number; category (undergraduate or graduate) 22 | \author{Jonathan Chan} 23 | \title{A Syntactic Model of Sized Dependent Types} 24 | 25 | \begin{document} 26 | \maketitle 27 | 28 | \section{???} 29 | 30 | The types-as-propositions paradigm associates certain type theories with formal logical systems, 31 | and consequently types in those theories with propositions in those logics. 32 | Furthermore, well-typed programs are associated with proofs of the corresponding proposition. 33 | Many dependent type theories, for instance, correspond to higher-order logics, 34 | and having an automated type checker means having the ability to automatically verify proofs. 35 | One must be careful, however, not to allow nonterminating programs, 36 | because they correspond to logical inconsistencies, i.e. proofs of falsehood; 37 | additionally, in dependent type checkers where programs may be evaluated during type checking, 38 | failure to rule out nonterminating programs leads to nonterminating type checking. 39 | Contemporary proof assistants based on dependent type theories, such as Coq, Agda, Lean, Idris, 40 | and more, typically restrict recursive functions to \emph{structurally-recursive} ones, 41 | where the argument of recursive calls must be \emph{syntactically} smaller. 42 | As an example, consider the following function \agda{minus n m} that computes $\min(n - m, 0)$. 43 | 44 | \begin{minted}{agda} 45 | minus : Nat → Nat → Nat 46 | minus Zero m = Zero 47 | minus n Zero = n 48 | minus (Succ n) (Succ m) = minus n m 49 | \end{minted} 50 | 51 | Inuitively, any well-typed call to \agda{minus} is guaranteed to terminate because the recursive call 52 | only occurs on constructor arguments, and the base cases must be reached eventually. 53 | However, we often wish to write terminating functions that aren't necessarily syntactically recursive. 54 | Consider now the following function \agda{div n m} that computes $\big\lceil\frac{n}{m+1}\big\rceil$ using \agda{minus}. 55 | 56 | \begin{minted}{agda} 57 | div : Nat → Nat → Nat 58 | div Zero m = Zero 59 | div (Succ n) m = Succ (div (minus n m) m) 60 | \end{minted} 61 | 62 | Despite the fact that \agda{minus} returns a natural no greater than its first argument, 63 | meaning that the first argument of the recursive call to \agda{div} has a smaller magnitude 64 | than the original argument, 65 | the type checker is unable to conclude that this is a terminating function, 66 | because the first argument isn't \emph{syntactically} smaller (i.e. \agda{n}). 67 | The programmer would have to alter the definition of \agda{minus} to prove this property, 68 | as well as the definition of \agda{div} to use this proof, making writing otherwise simple code burdensome. 69 | Sometimes it would be possible to make the type checker a little more clever by selectively inlining 70 | certain functions that allow the syntactic termination check to pass, 71 | but this is not always possible, and requiring inlining just to pass termination checking is anti-modular. 72 | If inlining \agda{minus} in the body of \agda{div} helped, then we are forced to import its entire definition, 73 | rather than merely its name and type, as is only required for type checking alone. 74 | 75 | %\paragraph*{} 76 | A \emph{type-based} rather than syntactic method of termination checking uses \emph{sized types} (Hughes 1996), 77 | where a function is guaranteed to terminate simply if it type checks. 78 | To use sized types, we first alter our definition of naturals to take a size expression as a parameter. 79 | 80 | \begin{minted}[escapeinside=<>,mathescape=true]{agda} 81 | data Nat [<$\α$>] : Type where 82 | Zero : <$\∀ \β < \α$>. Nat [<$\α$>] 83 | Succ : <$\∀ \β < \α$>. Nat [<$\β$>] → Nat [<$\β$>] 84 | \end{minted} 85 | 86 | The bounded size quantification \agda{<$\∀\β < \α$>} asks for some size $\β$ strictly smaller than $\α$. 87 | So to construct the successor of some natural \agda{n : Nat [s]}, we need a size larger than \agda{s}. 88 | Let \agda{<$\↑$>s} denote the next size up from \agda{s}. 89 | Then the successor is simply \agda{Succ {<$\↑$>s} [s] n} (using curly braces for the implicit size parameter). 90 | Now, let us express the fact that \agda{minus} returns a natural no larger than its first argument using sizes, 91 | i.e. that \agda{minus} is in fact \emph{size-preserving}. 92 | 93 | \begin{minted}[escapeinside=<>,mathescape=true]{agda} 94 | minus : <$\∀\α$>, <$\β$>. Nat [<$\α$>] → Nat [<$\β$>] → Nat [<$\α$>] 95 | \end{minted} 96 | 97 | Then we are able to write a \agda{div} function that the type checker will accept to be terminating 98 | with just a few more annotations. 99 | 100 | \begin{minted}[escapeinside=<>,mathescape=true]{agda} 101 | div : <$\∀\α$>, <$\β$>. Nat [<$\α$>] → Nat [<$\β$>] → Nat [<$\α$>] 102 | div [<$\α$>] [<$\β$>] (Zero {<$\α$>} [<$\γ$>]) m = Zero {<$\α$>} [<$\γ$>] 103 | div [<$\α$>] [<$\β$>] (Succ {<$\α$>} [<$\γ$>] n) m = Succ {<$\α$>} [<$\γ$>] (div [<$\γ$>] [<$\β$>] (minus [<$\γ$>] [<$\β$>] n m) m) 104 | \end{minted} 105 | 106 | In the second branch, when matching on the first argument of size $\α$, we have the successor of \agda{n}, 107 | which itself has size $\γ < \α$. 108 | Then the call to \agda{minus} returns a natural of size $\γ$, which is then passed to the recursive call of \agda{div}. 109 | Type checking passes without problem because the size $\γ$ of the recursive call is strictly smaller 110 | than the size $\α$ of the original call to \agda{div}. 111 | More precisely, when expressing recursive functions as fixpoints, 112 | their typing rule and reduction behaviour is the following 113 | (using $e[x \↦ e']$ to denote substitution of $x$ by $e'$ in $e$): 114 | \begin{align*} 115 | &\Γ, \α, f : \∀\β < \α \mathpunct{.} \σ[\α \↦ \β] \⊢ e : \σ \\[-2\jot] 116 | &\cline{1-2} 117 | &\Γ \⊢ \fix \, f \, [\α] : \σ \coloneqq e : \∀\α \mathpunct{.} \σ 118 | \end{align*} 119 | \begin{align*} 120 | (\fix \, f \, [\α] : \σ \coloneqq e) \: [s] \: e' &\⊳ e[\α \↦ s, f \↦ \Λ\β < s \mathpunct{.} (\fix \, f \, [\α] : \σ \coloneqq e) [\β]] \: e' 121 | \end{align*} 122 | 123 | A fixpoint is well-typed if the body has the same type under the environment where 124 | the recursive reference to the fixpoint quantifies over a \emph{smaller} size. 125 | When reducing the fixpoint applied to some size, we substitute in the body the fixpoint bounded by that size. 126 | 127 | \section{???} 128 | 129 | Once we have a program and correctness proofs about the program, we may wish to compile and run our program. 130 | In Coq and Agda, programs get \emph{extracted} to OCaml and Haskell code, respectively, which are then compiled. 131 | However, the process of extraction necessarily discards some type information, 132 | since the extraction targets are not dependently typed. 133 | This makes it possible to link our proven-safe program after extraction with unsafe code, 134 | which might cause runtime errors, making all of the work proving it correct in vain. 135 | To ensure that our proofs are preserved and verified even during linking, 136 | we want to compile our code in a \emph{type-preserving} manner (Bowman, 2018). 137 | The type-based nature of sized types makes it more amenable than syntactic termination checking 138 | to type-preserving compilation of recursive functions. 139 | 140 | Traditionally in dependent type theories, there are two mutually-dependent judgements: 141 | the typing judgement, and the (typed) equality judgement. 142 | Equality is used in the following typing rule: 143 | \end{document} -------------------------------------------------------------------------------- /SRC/SRC finals.md: -------------------------------------------------------------------------------- 1 | Hello! My name is Jonathan Chan, I'm a Master's student at UBC, 2 | I'll be talking about my work on a syntactic model for a sized dependent type theory. 3 | 4 | First of all, dependent types are used by a lot of modern theorem provers 5 | that are founded on the types-as-propositions paradigm 6 | where type checking corresponds to checking a proof in some logical system. 7 | To ensure that the logic is consistent and that type checking is decidable, 8 | for the type theories of theorem provers such as Agda or Coq, 9 | they have to ensure that their recursive functions are terminating. 10 | 11 | This is currently done using syntactic checks ensuring that the functions are 12 | structurally recursive and recur only on syntactically smaller arguments, 13 | but this is sometimes too restrictive. 14 | Some checks will inline definitions along the way, but then this makes definitions nonmodular, 15 | and even minor syntactic changes can affect whether later functions pass the check. 16 | 17 | Instead of these checks, another option is to use a type-based termination checking method called *sized types*, 18 | where inductive types carry additional size information, 19 | and constructors build inductives with larger sizes. 20 | In fixpoints, recursive calls have to be done on arguments with smaller sizes to guarantee termination; 21 | there's no other syntactic checks required, 22 | and they no longer depend on the bodies of prior definitions, 23 | only on their types. 24 | The trick here is that functions can now be typed to be *size-preserving*, 25 | while proving similar properties without sized types would be quite a large burden on the user in comparison. 26 | 27 | There's a fair amount of relevant past work on sized types which I've divided into three groups, 28 | based on their coverage of dependent types, higher-rank sized types, 29 | and bounded size quantification. 30 | The first row here introduces sized types to the Calculus of Inductive Constructions, 31 | but with only prenex size quantification, 32 | which means for instance that you can't pass around a size-preserving function. 33 | The second row introduces higher-rank size quantification *and* bounded size quantification, 34 | which is a feature that ensures that pattern-matching with sized types is consistent 35 | and eliminates the need for complex monotonicity checks, 36 | but this is only for System Fω. 37 | Finally, the third row proves normalization of a higher-rank sized dependent type theory with naturals, 38 | but without bounded size quantification. 39 | 40 | To my knowledge, there is no formal model of a type theory with all three of these features, 41 | while all these and more are implemented in Agda. 42 | My goal is to fill this gap and show that a type theory with all three can in fact be consistent. 43 | 44 | I start with the Generalized Calculus of Constructions with sized types, 45 | naturals, W types, case expressions, and fixpoints. 46 | To show its consistency, I use a syntactic model in extensional CIC, 47 | which is a standard, well-studied dependent type theory. 48 | The syntactic model is essentially a type-preserving compiler from the source type theory into CIC. 49 | Since an inconsistency in the source would compile to one in the target, 50 | and we know what CIC is consistent, 51 | if the model is correct (meaning type-preserving), 52 | the source must be consistent as well. 53 | 54 | In the model, sizes translate to an inductively-defined notation of (Brouwer) ordinals and their order, 55 | and we can show that sizes are indeed well-founded with respect to that order using a standard accessibility predicate. 56 | This is important because it turns out that fixpoints in the source, 57 | regardless of what they recur on, 58 | translate to applications of well-founded induction on Sizes. 59 | I only have naturals and W types, 60 | which translate to their corresponding inductive definitions but parametrized by a Size, 61 | but in principle the translation should apply to any inductive definition. 62 | 63 | Proving that the translation is type preserving is still ongoing work. 64 | One notable challenge is ensuring that the universe levels of all the inductive types are correct. 65 | Other future work include handling inductives in general, coinductives, 66 | and some notion of the "infinite" size. 67 | 68 | That's all for my talk, and thanks for watching! -------------------------------------------------------------------------------- /SRC/SRC script.md: -------------------------------------------------------------------------------- 1 | Hello! My name is Jonathan Chan and I'm a Master's student at UBC. 2 | I'll be talking about my work on a syntactic model for a sized dependent type theory. 3 | 4 | First of all, dependent types are used by a lot of modern theorem provers 5 | that are founded on the types-as-propositions paradigm 6 | where type checking corresponds to checking a proof in some logical system. 7 | To ensure that type checking is decidable and that the logic is consistent, 8 | for the type theories of theorem provers such as Agda or Coq, 9 | they have to ensure that their recursive functions are terminating. 10 | 11 | This is currently done using syntactic checks ensuring that the functions are 12 | structurally recursive and recur only on syntactically smaller arguments, 13 | but this is sometimes too restrictive. 14 | Some checks will inline definitions along the way, but then this makes definitions nonmodular, 15 | and even minor syntactic changes can affect whether later functions pass the check. 16 | 17 | Instead of these checks, another option is to use a type-based termination checking method 18 | called sized types, where inductive types carry additional size information, 19 | and constructors build inductives with larger sizes. 20 | In fixpoints, recursive calls have to be done on arguments with smaller sizes so that they terminate, 21 | and type checking will guarantee this, with no additional syntactic checking required. 22 | 23 | There's a fair amount of relevant past work on sized types falling roughly into three groups, 24 | covering various combinations of dependent types, higher-rank sized types, and bounded size quantification, 25 | but to my knowledge no theoretical work covers all three, so my work seeks to fill this gap 26 | with a higher-rank sized dependent type theory with bounded size quantification. 27 | 28 | In short, this is the Generalized Calculus of Constructions with sized types, 29 | naturals, W types, case expressions, and fixpoints. 30 | To show that the theory consistent, I use a syntactic model in extensional CIC, or CIC_E, 31 | which is a standard, well-studied dependent type theory. 32 | The syntactic model is essentially a type-preserving compiler from the source type theory into CIC_E. 33 | With this model, since we know that CIC_E is consistent, 34 | an inconsistency in the source would compile to one in the target, 35 | which would therefore be a contradiction. 36 | 37 | In the model, size expressions translate to an inductively-defined representation of (Brouwer) ordinals, 38 | along with a representation of the less-than relation on them, 39 | and naturals and W types translate to their corresponding inductive definitions but parametrized by a Size. 40 | The interesting part of the translation is fixpoints, shown on this slide: 41 | they now translate to applications of well-founded induction on Sizes. 42 | 43 | Proving that the translation is type preserving is still ongoing work. 44 | One notable challenge is ensuring that the universe levels of all the inductive types are correct. 45 | Other future work include handling general inductives, coinductives, and an "infinite" size. 46 | If you have any questions or want to learn more, be sure to drop by the SRC discussion session. 47 | 48 | Thanks for watching! 49 | 50 | Questions: 51 | * Why a syntactic model rather than usual set-theoretic models? 52 | * Why an extensional CIC? 53 | * Why are sizes ordinals and not just naturals? 54 | * Aren't sized types in Agda inconsistent? Does it apply here? 55 | * What's the problem with universe levels and how will you fix it? -------------------------------------------------------------------------------- /SRC/SRC.bib: -------------------------------------------------------------------------------- 1 | @inproceedings{guard-predicate, 2 | address = {Berlin, Heidelberg}, 3 | title = {Codifying guarded definitions with recursive schemes}, 4 | isbn = {978-3-540-47770-9}, 5 | booktitle = {Types for {Proofs} and {Programs}}, 6 | publisher = {Springer Berlin Heidelberg}, 7 | author = {Giménez, Eduardo}, 8 | editor = {Dybjer, Peter and Nordström, Bengt and Smith, Jan}, 9 | year = {1995}, 10 | pages = {39--59} 11 | } 12 | 13 | @inproceedings{hughes, 14 | address = {New York, NY, USA}, 15 | series = {{POPL} '96}, 16 | title = {Proving the correctness of reactive systems using sized types}, 17 | isbn = {978-0-89791-769-8}, 18 | url = {https://doi.org/10.1145/237721.240882}, 19 | doi = {10.1145/237721.240882}, 20 | booktitle = {Proceedings of the 23rd {ACM} {SIGPLAN}-{SIGACT} symposium on {Principles} of programming languages}, 21 | publisher = {Association for Computing Machinery}, 22 | author = {Hughes, John and Pareto, Lars and Sabry, Amr}, 23 | month = jan, 24 | year = {1996}, 25 | pages = {410--423} 26 | } 27 | 28 | @inproceedings{cic-hat, 29 | Author = {Barthe, Gilles and Gr\'egoire, Benjamin and Pastawski, Fernando}, 30 | Editor = {{Hermann, M and Voronkov, A}}, 31 | title = {{CIC$\widehat{~}$ : Type-Based Termination of Recursive Definitions in the Calculus of Inductive Constructions}}, 32 | Booktitle = {{Logic for Programming, Artificial Intelligence, and Reasoning, Proceedings}}, 33 | Series = {{Lecture Notes in Artificial Intelligence}}, 34 | Year = {{2006}}, 35 | Volume = {{4246}}, 36 | Pages = {{257-271}}, 37 | Publisher = {{Springer-Verlag Berlin}}, 38 | Address = {{Heidelberger Platz 3, D-14197 Berlin, Germany}}, 39 | Type = {{Proceedings Paper}}, 40 | Language = {{English}}, 41 | Affiliation = {{Barthe, G (Reprint Author), INRIA, Sophia Antipolis, France. INRIA, Sophia Antipolis, France. Univ Nacl Cordoba, FaMAF, RA-5000 Cordoba, Argentina.}}, 42 | DOI = {10.1007/11916277\_18}, 43 | ISSN = {{0302-9743}}, 44 | ISBN = {{3-540-48281-4}} 45 | } 46 | 47 | @incollection{cic-hat-minus-nat, 48 | location = {Berlin, Heidelberg}, 49 | title = {On Strong Normalization of the Calculus of Constructions with Type-Based Termination}, 50 | volume = {6397}, 51 | isbn = {978-3-642-16241-1 978-3-642-16242-8}, 52 | abstract = {Termination of recursive functions is an important property in proof assistants based on dependent type theories; it implies consistency and decidability of type checking. Type-based termination is a mechanism for ensuring termination that uses types annotated with size information to check that recursive calls are performed on smaller arguments. Our long-term goal is to extend the Calculus of Inductive Constructions with a type-based termination mechanism and prove its logical consistency. In this paper, we present an extension of the Calculus of Constructions (including universes and impredicativity) with sized natural numbers, and prove strong normalization and logical consistency. Moreover, the proof can be easily adapted to include other inductive types.}, 53 | pages = {333--347}, 54 | booktitle = {Logic for Programming, Artificial Intelligence, and Reasoning}, 55 | publisher = {Springer Berlin Heidelberg}, 56 | author = {Grégoire, Benjamin and Sacchini, Jorge Luis}, 57 | editor = {Ferm{\"u}ller, Christian G. and Voronkov, Andrei}, 58 | address = {Berlin, Heidelberg}, 59 | year = {2010}, 60 | doi = {10.1007/978-3-642-16242-8_24}, 61 | note = {Series Title: Lecture Notes in Computer Science} 62 | } 63 | 64 | @phdthesis{cic-hat-minus, 65 | TITLE = {{On type-based termination and dependent pattern matching in the calculus of inductive constructions}}, 66 | AUTHOR = {Sacchini, Jorge Luis}, 67 | URL = {https://pastel.archives-ouvertes.fr/pastel-00622429}, 68 | NUMBER = {2011ENMP0022}, 69 | SCHOOL = {{{\'E}cole Nationale Sup{\'e}rieure des Mines de Paris}}, 70 | YEAR = {2011}, 71 | MONTH = Jun, 72 | KEYWORDS = {Type-based termination ; d{\'e}pendent types ; pattern matching ; calculus of inductive constructions ; Terminaison bas{\'e}e sur les types ; types d{\'e}pendants ; filtrage par motifs ; calcul des constructions inductives}, 73 | TYPE = {Theses}, 74 | PDF = {https://pastel.archives-ouvertes.fr/pastel-00622429/file/21076_SACCHINI_2011_archivage.pdf}, 75 | HAL_ID = {pastel-00622429}, 76 | HAL_VERSION = {v1} 77 | } 78 | 79 | @inproceedings{cc-hat-omega, 80 | Author = {Sacchini, Jorge Luis}, 81 | Book-Group-Author = {{IEEE Comp Soc}}, 82 | Title = {{Type-Based Productivity of Stream Definitions in the Calculus of Constructions}}, 83 | Booktitle = {{2013 28TH Annual IEEE/ACM Symposium on Logic in Computer Science (LICS)}}, 84 | Series = {{IEEE Symposium on Logic in Computer Science}}, 85 | Year = {{2013}}, 86 | Pages = {{233-242}}, 87 | Publisher = {{IEEE}}, 88 | Address = {{345 E 47th St., New York, NY 10017 USA}}, 89 | Type = {{Proceedings Paper}}, 90 | Language = {{English}}, 91 | Affiliation = {{Sacchini, JL (Reprint Author), Carnegie Mellon Univ, Doha, Qatar. Carnegie Mellon Univ, Doha, Qatar.}}, 92 | DOI = {10.1109/LICS.2013.29}, 93 | ISSN = {{1043-6871}}, 94 | ISBN = {{978-1-4799-0413-6}} 95 | } 96 | 97 | @phdthesis{abel-diss, 98 | title = {Type-based termination: a polymorphic lambda-calculus with sized higher-order types}, 99 | author = {Abel, Andreas}, 100 | year = {2006}, 101 | url = {http://www.cse.chalmers.se/~abela/diss.pdf}, 102 | type = {Theses}, 103 | school = {University of Munich}, 104 | publisher = {HARLAND media} 105 | } 106 | 107 | @article{flationary, 108 | title = {{Type-Based Termination, Inflationary Fixed-Points, and Mixed Inductive-Coinductive Types}}, 109 | volume = {77}, 110 | ISSN = {2075-2180}, 111 | url = {http://dx.doi.org/10.4204/EPTCS.77.1}, 112 | DOI = {10.4204/eptcs.77.1}, 113 | journal = {Electronic Proceedings in Theoretical Computer Science}, 114 | publisher = {Open Publishing Association}, 115 | author = {Abel, Andreas}, 116 | year = {2012}, 117 | month = {Feb}, 118 | pages = {1--11} 119 | } 120 | 121 | @article{f-omega-cop, 122 | title = {Well-founded recursion with copatterns and sized types}, 123 | volume = {26}, 124 | issn = {0956-7968, 1469-7653}, 125 | url = {https://www.cambridge.org/core/product/identifier/S0956796816000022/type/journal_article}, 126 | doi = {10.1017/S0956796816000022}, 127 | journal = {Journal of Functional Programming}, 128 | author = {Abel, Andreas and Pientka, Brigitte}, 129 | year = {2016}, 130 | pages = {e2} 131 | } 132 | 133 | @article{nbe-sized, 134 | author = {Abel, Andreas and Vezzosi, Andrea and Winterhalter, Theo}, 135 | title = {Normalization by Evaluation for Sized Dependent Types}, 136 | year = {2017}, 137 | issue_date = {September 2017}, 138 | publisher = {Association for Computing Machinery}, 139 | address = {New York, NY, USA}, 140 | volume = {1}, 141 | number = {ICFP}, 142 | url = {https://doi.org/10.1145/3110277}, 143 | doi = {10.1145/3110277}, 144 | journal = {Proc. ACM Program. Lang.}, 145 | month = aug, 146 | articleno = {33}, 147 | numpages = {30} 148 | } 149 | 150 | @inproceedings{syntactic-models, 151 | address = {Paris, France}, 152 | title = {The next 700 syntactical models of type theory}, 153 | isbn = {978-1-4503-4705-1}, 154 | url = {https://dl.acm.org/doi/10.1145/3018610.3018620}, 155 | doi = {10.1145/3018610.3018620}, 156 | eventtitle = {{CPP} '17: Certified Proofs and Programs}, 157 | pages = {182--194}, 158 | booktitle = {Proceedings of the 6th {ACM} {SIGPLAN} Conference on Certified Programs and Proofs}, 159 | publisher = {{ACM}}, 160 | author = {Boulier, Simon and P{\'e}drot, Pierre-Marie and Tabareau, Nicolas}, 161 | year = {2017} 162 | } 163 | 164 | 165 | @incollection{CCE, 166 | location = {Berlin, Heidelberg}, 167 | title = {{Extensionality in the Calculus of Constructions}}, 168 | volume = {3603}, 169 | isbn = {978-3-540-28372-0 978-3-540-31820-0}, 170 | url = {http://link.springer.com/10.1007/11541868_18}, 171 | pages = {278--293}, 172 | booktitle = {Theorem Proving in Higher Order Logics}, 173 | publisher = {Springer Berlin Heidelberg}, 174 | address = {Berlin, Heidelberg}, 175 | author = {Oury, Nicolas}, 176 | editor = {Hurd, Joe and Melham, Tom}, 177 | editorb = {Hutchison, David and Kanade, Takeo and Kittler, Josef and Kleinberg, Jon M. and Mattern, Friedemann and Mitchell, John C. and Naor, Moni and Nierstrasz, Oscar and Pandu Rangan, C. and Steffen, Bernhard and Sudan, Madhu and Terzopoulos, Demetri and Tygar, Dough and Vardi, Moshe Y. and Weikum, Gerhard}, 178 | year = {2005}, 179 | doi = {10.1007/11541868_18}, 180 | note = {Series Title: Lecture Notes in Computer Science} 181 | } 182 | 183 | @article{universes, 184 | title = {Type checking with universes}, 185 | volume = {89}, 186 | issn = {03043975}, 187 | doi = {10.1016/0304-3975(90)90108-T}, 188 | language = {en}, 189 | number = {1}, 190 | journal = {Theoretical Computer Science}, 191 | author = {Harper, Robert and Pollack, Robert}, 192 | month = oct, 193 | year = {1991}, 194 | pages = {107--136} 195 | } 196 | 197 | @article{wfind, 198 | title = {Terminating general recursion}, 199 | volume = {28}, 200 | issn = {0006-3835, 1572-9125}, 201 | url = {http://link.springer.com/10.1007/BF01941137}, 202 | doi = {10.1007/BF01941137}, 203 | pages = {605--619}, 204 | number = {3}, 205 | journal = {{BIT Numerical Mathematics}}, 206 | author = {Nordström, Bengt}, 207 | year = {1988} 208 | } 209 | 210 | @phdthesis{compiling, 211 | title = {Compiling with Dependent Types}, 212 | pages = {281}, 213 | author = {Bowman, William J.}, 214 | school = {Northeastern University}, 215 | year = {2018}, 216 | type = {Theses}, 217 | url = {http://hdl.handle.net/2047/D20316239}, 218 | doi = {10.17760/D20316239}, 219 | publisher = {Northeastern University} 220 | } 221 | 222 | @InProceedings{ordinals, 223 | author = {Kraus, Nicolai and Nordvall Forsberg, Fredrik and Xu, Chuangjie}, 224 | title = {{Connecting Constructive Notions of Ordinals in Homotopy Type Theory}}, 225 | booktitle = {46th International Symposium on Mathematical Foundations of Computer Science (MFCS 2021)}, 226 | pages = {70:1--70:16}, 227 | series = {Leibniz International Proceedings in Informatics (LIPIcs)}, 228 | ISBN = {978-3-95977-201-3}, 229 | ISSN = {1868-8969}, 230 | year = {2021}, 231 | volume = {202}, 232 | editor = {Bonchi, Filippo and Puglisi, Simon J.}, 233 | publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik}, 234 | address = {Dagstuhl, Germany}, 235 | URL = {https://drops.dagstuhl.de/opus/volltexte/2021/14510}, 236 | URN = {urn:nbn:de:0030-drops-145100}, 237 | doi = {10.4230/LIPIcs.MFCS.2021.70}, 238 | } 239 | -------------------------------------------------------------------------------- /SRC/SRC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/SRC/SRC.pdf -------------------------------------------------------------------------------- /SRC/SRC.tex: -------------------------------------------------------------------------------- 1 | \documentclass[acmsmall,nonacm, screen]{acmart} 2 | \acmConference[]{}{}{} 3 | 4 | \usepackage{xspace} 5 | \usepackage{enumitem} 6 | \setlist[itemize]{leftmargin=*} 7 | 8 | \newcommand{\lang}{Sized CC$_\omega$\xspace} 9 | \newcommand{\CICE}{CIC$_\mathrm{E}$\xspace} 10 | \newcommand{\our}{my\xspace} 11 | \newcommand{\Our}{My\xspace} 12 | \newcommand{\we}{I\xspace} 13 | \newcommand{\We}{I\xspace} 14 | 15 | % Each submission (referred to as “abstract” below) should include the student author’s name and e-mail address; 16 | % institutional affiliation; research advisor’s name; ACM student member number; category (undergraduate or graduate) 17 | \title{Towards a Syntactic Model of Sized Dependent Types} 18 | \author{Jonathan Chan} 19 | \email{jcxz@cs.ubc.ca} % why doesn't this show up? 20 | \affiliation{ 21 | \institution{University of British Columbia} 22 | \city{Vancouver} 23 | \country{Canada}, 24 | \href{mailto:jcxz@cs.ubc.ca}{jcxz@cs.ubc.ca} \\ 25 | Graduate student (MSc.) advised by William J. Bowman 26 | } 27 | 28 | \begin{document} 29 | \maketitle 30 | 31 | \section{Termination Checking for Dependent Type Theories} 32 | 33 | The types-as-propositions paradigm associates certain type theories with formal logical systems, 34 | and consequently types in those theories with propositions in those logics. 35 | Furthermore, well-typed programs are associated with proofs of the corresponding proposition. 36 | Many dependent type theories, for instance, correspond to higher-order logics, 37 | and having an automated type checker means having the ability to automatically verify proofs. 38 | 39 | One must be careful, however, not to allow nonterminating programs, 40 | because they correspond to logical inconsistencies, i.e. proofs of falsehood. 41 | Additionally, in dependent type checkers where programs may be evaluated during type checking, 42 | failure to rule out nonterminating programs leads to nonterminating type checking. 43 | Contemporary proof assistants based on dependent type theories, such as Coq, Agda, Lean, Idris, 44 | and many more, typically restrict recursive functions to \emph{structurally-recursive} ones, 45 | where the argument of recursive calls must be \emph{syntactically} smaller, 46 | peeling away layers of constructors until a base case is reached. 47 | Type checkers in these proof assistants use \emph{guard predicates}~\citep{guard-predicate} to ensure the restriction. 48 | 49 | However, the guard predicate is often \emph{too} restrictive to accept a variety of recursive functions 50 | for which termination is otherwise evident to the discerning programmer. 51 | In particular, functions recurring on subarguments that have first been passed to other functions 52 | known not to add any more layers of constructors must surely terminate, 53 | but since the recursive argument is not \emph{syntactically} the subargument, 54 | the guard predicate does not hold. 55 | 56 | Some type checkers will inline function definitions for the purpose of termination checking, 57 | but this reliance on other function definitions makes code non-modular, 58 | and inlining very large definitions could severely negatively impact type checking performance. 59 | Furthermore, the syntactic nature of the guard predicate makes it sensitive to minor syntactic changes, 60 | and a subtle refactoring of a function inlined in later functions could affect whether 61 | those functions even pass termination checking at all! 62 | In short, a syntactic guard predicate goes against good programming practices. 63 | 64 | \section{Type-Based Termination Checking} 65 | 66 | An alternative to syntactic termination checking is to instead use \emph{type-based} termination checking, 67 | where if a recursive function type checks without involving any other termination conditions, 68 | then it is guaranteed to terminate. 69 | One such method uses \emph{sized types}~\citep{hughes}, where inductive types carry additional size information. 70 | Intuitively, the size is a measure of how many layers a member of that type contains, 71 | and constructors must have a greater size than its subarguments. 72 | The types of functions then carry information about whether it affects the size of its argument, 73 | meaning that no inlining is required --- only the type is needed, not the whole definition. 74 | 75 | Sized types have been implemented in Agda and can be enabled with the \texttt{-\hspace{0em}-sized-types} pragma.% 76 | \footnote{Unfortunately, the implementation is inconsistent due to the presence of an \emph{infinite size}, 77 | which is defined to be the size strictly greater than all other sizes, including itself.} 78 | It encludes sophisticated features like first-class sizes and bounded size quantification. 79 | There is also a large body of theoretical work on sized types in various type systems, 80 | but none of them quite satisfy all of the desirable features. 81 | 82 | \begin{itemize} 83 | \item \citet{cic-hat}, \citet{cic-hat-minus-nat}, \citet{cic-hat-minus}, and \citet{cc-hat-omega} 84 | introduce and prove consistent a lineage of Calculi of (Co)Inductive Constructions (CIC) with sized types, 85 | but only prenex size quantification is possible: one cannot, for instance, 86 | pass around a higher-order function quantifying over a size. 87 | \item \citet{abel-diss}, \citet{flationary}, and \citet{f-omega-cop} 88 | introduce not only higher-rank size quantification but also bounded size quantification, 89 | the latter of which eliminates the need for complex monotonicity checks or syntactic approximations thereof. 90 | However, these type systems extend System F$_{\omega}$ rather than a dependent type theory. 91 | \item \citet{nbe-sized} prove normalization of a higher-rank sized dependent type theory with naturals, 92 | but without bounded size quantification. 93 | \end{itemize} 94 | 95 | \textbf{In ongoing work, \we seek to prove the logical consistency of \lang, 96 | a higher-rank sized dependent type theory with bounded size quantification.} 97 | Rather than using very involved set-theoretic methods like in Sacchini's dissertation~\citep{cic-hat-minus} 98 | or the normalization by evaluation technique in~\citet{nbe-sized} 99 | which requires a typed definitional equality judgement in the type theory, 100 | \we instead define a \emph{syntactic model}~\citep{syntactic-models} into Extensional CIC (\CICE)~\citep{CCE}. 101 | That is, \we need to define a compiler from \lang to \CICE, then prove that it is \emph{type-preserving}: 102 | given some well-typed term in \lang, if both the term and its type are translated to \CICE, 103 | then the translated term should also be well typed against the translated type. 104 | Because \CICE is known to be consistent, and an inconsistency in \lang 105 | implies the existence of an inconsistency in \CICE via the type-preserving compilation, 106 | inconsistency of \lang would be a contradiction. 107 | 108 | \section{Syntactic Model of \texorpdfstring{\lang}{Sized CCω}} 109 | 110 | \lang is a Generalized Calclulus of Constructions with definitions (CC$\omega$)~\citep{universes} --- 111 | that is, a Calculus of Constructions with untyped equality, a cumulative universe hierarchy, and \texttt{let} expressions --- 112 | extended with bounded and unbounded size quantification, abstraction, and application, 113 | as well as size expressions consisting of size variables, a base size, and a size successor operation. 114 | \We further add naturals and W types only, but these should scale directly to inductive types in general. 115 | 116 | In \lang, the natural type and W types are parametrized by some size, and their constructors quantify 117 | over a bounded size representing the strictly smaller size of recursive subarguments. 118 | In \CICE, \we define a \texttt{Size} inductive type representing the sizes in \lang, 119 | and an indexed inductive type \texttt{\_$\leqslant$\_} on \texttt{Size} 120 | representing the ordering relation used in bounded quantification and abstraction. 121 | The natural type and W types then compile to corresponding inductive types literally parametrized by \texttt{Size}, 122 | and whose constructors take proofs of strict inequality of two \texttt{Size}s. 123 | 124 | The majority of the remaining translation is straightforward, 125 | especially for universes, functions, \texttt{let} expressions, and \texttt{case} expressions. 126 | Bounded size quantification and abstraction correspond to quantification and abstraction 127 | over a \texttt{Size} and an inequality, and correspondingly for unbounded ones. 128 | But what about fixpoints? 129 | 130 | The typing rule for fixpoints in \lang has as premise the well-typedness of its body 131 | in an environment where the fixpoint itself is in scope, but quantifying over a smaller size. 132 | The key insight is that fixpoints now correspond to \emph{well-founded induction} over sizes, 133 | rather than structural induction. 134 | To show that well-founded induction indeed holds for \texttt{Size}, 135 | \we first show that all \texttt{Size}s satisfy an \emph{accessibility predicate}~\citep{wfind}; 136 | well-founded induction then follows by a structurally-inductive proof over the predicate. 137 | Fixpoints in \lang then translate immediately to applications of well-founded induction. 138 | 139 | Now that a translation from \lang to \CICE is established, \we show that it is type preserving. 140 | Because \lang uses an untyped equality judgement, \we can use standard techniques for showing type preservation~\citep{compiling}. 141 | An important proof detail is that equality reflection (and therefore extensionality) is required 142 | to show an $\eta$-equivalence rule for \texttt{case} expressions 143 | and to show that proofs of accessibility are equal, 144 | which are properties used to prove that the translations of an applied fixpoint and its reduction in \lang 145 | are definitionally equal in \CICE. 146 | 147 | \section{Status and Future Work} 148 | 149 | The work is not yet done; 150 | there remain unresolved problems with the model, 151 | and additional features to add that one would expect 152 | from a practically-useable sized dependent type theory. 153 | 154 | \subsection{Universe Levels and \texttt{Size}} 155 | 156 | To be able to assign sizes to \emph{general inductive types} such as W types, 157 | which conceptually can have transfinitely many recursive subarguments, 158 | \texttt{Size} itself must be able to express the same transfinitivity. 159 | Therefore, its inductive definition in \CICE mirrors that of \emph{Brouwer ordinals}~\citep{ordinals}, 160 | although the domain of the function in the size corresponding to the limit ordinal is an arbitrary type $A$ 161 | rather than merely the usual natural numbers. 162 | \texttt{Size} itself must then live in a universe higher than that of $A$, 163 | according to the usual well-formedness restrictions on inductive types. 164 | 165 | Recall that the natural type and W types in \lang are parametrized by \texttt{Size}. 166 | Given a W type with type parameters $A : \texttt{Type}_\ell$ and $B : A \rightarrow \texttt{Type}_\ell$, 167 | the type used in limit sizes for the W type would also be $A$. 168 | Meanwhile, the naturals aren't transfinite, so we simply have $A \coloneq \bot : \texttt{Type}_0$, the uninhabited type. 169 | Unfortunately, since \texttt{Size} itself would then live in 170 | \texttt{Type}$_{\ell+1}$ and \texttt{Type}$_1$, respectively, 171 | so must the W type and the natural type, 172 | rather than in \texttt{Type}$_{\ell}$ and \texttt{Type}$_0$ as one would expect. 173 | Intuitively, \texttt{Size} itself must be ``large enough'' (in the type universe sense) 174 | to include all sizes of naturals and elements of W types, 175 | which makes it ``too large'' to live in the same universe as what it should include. 176 | 177 | One unsatisfactory solution would be to accept the natural type and W types living in larger universes 178 | than they normally would in an unsized dependent type theory. 179 | Another solution would be to parametrize \texttt{Size} itself by the limit size's type $A$, 180 | which would allow it to live in the same universe as $A$. 181 | However, the translation of sizes and size quantifications and abstractions would have 182 | an underdetermined parameter, and sizes used for one inductive could not be used for another. 183 | 184 | \subsection{The Infinite Size} 185 | 186 | In nearly all past work on sized types, including the Agda implementation, 187 | there is a notion of an infinite size $\infty$ that is strictly larger than all sizes, 188 | including itself: the relation $\infty < \infty$ holds. 189 | \lang does not have the infinite size, because this property would make sizes no longer well-founded, 190 | undermining all efforts to interpret fixpoints as applications of well-founded induction. 191 | In fact, this is why sized types are inconsistent in Agda: 192 | dependent types make it possible to internalize the order on sizes as an inductive type within Agda itself, 193 | from which well-foundedness can be proven, yielding falsehood when combined with $\infty < \infty$. 194 | Finding a suitable replacement for uses of $\infty$ that capture its convenience while retaining consistency 195 | remains an open problem. 196 | One possibility is to use an existentially size-quantified inductive type in place of the $\infty$-sized inductive% 197 | %\footnote{Dually, the $\infty$-sized \emph{coinductive} type would be \emph{universally} size-quantified.}, 198 | but it appears this might require a nonconstructive axiom that does not compute. 199 | 200 | \subsection{Coinductive Types} 201 | 202 | Aside from termination checking, sized types are also used for 203 | \emph{productivity checking} of \emph{corecursive} definitions, 204 | making reasoning about corecursive constructions much easier. 205 | If \lang is indeed consistent, \we expect that extending the language and the proofs 206 | to include sized coinductive types would be relatively straightforward. 207 | 208 | \bibliography{SRC} 209 | \bibliographystyle{ACM-Reference-Format} 210 | \end{document} -------------------------------------------------------------------------------- /chapters/abstract.tex: -------------------------------------------------------------------------------- 1 | \chapter{Abstract} 2 | 3 | Many contemporary proof assistants based on dependent type theories such as Coq and Agda 4 | are founded on the types-as-propositions paradigm where type checking a program 5 | corresponds to verifying a proof of some proposition in a higher-order predicate logic. 6 | To ensure decidability of type checking and consistency of the logic, 7 | these proof assistants forbid nonterminating recursive functions 8 | using guard predicates that only allow structurally recursive functions 9 | recurring on syntactically smaller arguments. 10 | However, these guard predicates are sometimes too restrictive 11 | and reject simple terminating functions that aren't otherwise structurally recursive. 12 | 13 | An alternative is to use type-based termination checking such as sized types, 14 | where inductively-defined types are annotated with sizes. 15 | Successful type checking guarantees that functions recur only on arguments whose types have smaller sizes, 16 | rather than merely on syntactic subarguments. 17 | Some existing models of sized dependent type theories 18 | support features for more expressive sized types, 19 | namely higher-rank size quantification 20 | (which allows for passing around size-preserving functions) 21 | and bounded size quantification 22 | (which eliminates the need for complex semi-continuity checks), 23 | but unfortunately none support both simultaneously. 24 | Meanwhile, the only implementation of sized types in a major proof assistant, Agda, 25 | does support these features, but is unfortunately logically inconsistent. 26 | 27 | In this thesis, I design a sized dependent type theory with higher-rank and bounded sizes (\lang), 28 | and show that it's suitable for theorem proving by proving its consistency with a syntactic model: 29 | by compiling \lang into the Extensional Calculus of Inductive Constructions (\CICE), 30 | a variant of Coq's core type theory, 31 | and showing that this translation is type preserving, 32 | the consistency of \lang follows from the consistency of \CICE. 33 | 34 | This approach refutes the existence of an infinite size strictly greater than all sizes, 35 | which is present in prior sized type systems to overcome the limitations of finitary size expressions, 36 | meaning that some infinitary constructs unfortunately aren't definable in \lang. 37 | Even so, \lang provides a valid foundation for sized types in a proof assistant, 38 | opening the way for future work on recovering expressivity lost from the lack of an infinite size 39 | and on restricting sized types in Agda to be consistent. -------------------------------------------------------------------------------- /chapters/acknowledgements.tex: -------------------------------------------------------------------------------- 1 | \chapter{Acknowledgements} 2 | 3 | I'd like to thank the following people for their support over the past two years: 4 | 5 | \begin{itemize} 6 | \item William Bowman, for your encouragement and mentorship throughout my Bachelor's and Master's theses 7 | and in navigating academia. 8 | Your influence on me is likely greater than I currently realize, 9 | and I wouldn't have it any other way. 10 | \item Alex Summers, for all the helpful feedback you provided as the very second reader of this thesis, 11 | and for introducing to me a bunch of really fun board games. 12 | \item Jordy Dickinson, for exposing me to all sorts of niches of type theory and constructive mathematics, 13 | and for giving an ear to the most out-of-context problems I was working on. 14 | I hope you're doing well. 15 | \item Hazel Levine, for making \href{https://types.pl/}{types.pl} a reality (and letting me in on the fun). 16 | \item The folks on PL Twitter, the TYPES, Coq, Agda, Idris, and Cedille mailing lists and Zulips, 17 | and the Proof Assistants Stack Exchange for answering my many questions 18 | and for asking far more interesting ones. 19 | \item Finally and most importantly, all my other splabmates at the Software Practices Lab 20 | for making grad school a way better experience than I could have hoped for, 21 | especially during an ongoing global pandemic. 22 | To name a few:\footnote{in no particular order except to avoid line breaks across names} 23 | \vspace{-0.25\baselineskip} 24 | \begin{quote} 25 | James Yoo\textsuperscript{\href{https://youtu.be/dQw4w9WgXcQ}{0}}, Chris Chen\punctstack{,}\footnote{honourary splabmate} 26 | Felipe Ba\~nados Schwerter, Markus de Medeiros, 27 | Braxton Hall, Paulette Koronkevich, Justin Frank, Ron Garcia, Lily Bryant, 28 | Adam Geller, Joey Eremondi, 29 | \end{quote} 30 | \vspace{-0.5\baselineskip} 31 | and many more, especially those who brought treats for the lab. 32 | \end{itemize} 33 | 34 | \noindent {\small This research was supported by the Canada Graduate Scholarships -- Master’s (CGS M) programme. 35 | Cette recherche a \'et\'e financ\'ee par le Programme de bourses d'\'etudes sup\'erieures 36 | du Canada au niveau de la maitrise (BESC M).} -------------------------------------------------------------------------------- /chapters/appendix.tex: -------------------------------------------------------------------------------- 1 | \chapter{Congruence Rules} \label{app:cong} 2 | 3 | \input{figures/congruence.tex} 4 | 5 | \iffalse 6 | The following two sections contain the full congruence rules for 7 | the congruent closure of reduction in \lang, 8 | and for equivalence in \CICE. 9 | The shorthand rules \rref*{red-cong} and \rref*{equiv-cong} can then be proven 10 | as theorems by induction on the respective congruence rules. 11 | \fi 12 | 13 | \section{Congruence Rules for Reduction in \lang} \label{app:cong:red} 14 | 15 | \FigCongRed{fig:cong:red*} 16 | \FigCongRedCase{fig:cong:red*-case} 17 | 18 | \section{Congruence Rules for Complete Development in \lang} \label{app:cong:develop} 19 | 20 | \FigCongTakahashi{fig:cong:develop} 21 | \vfill % don't touch! 22 | 23 | \section{Congruence Rules for Equivalence in \CICE} \label{app:cong:equiv} 24 | 25 | \FigCongEquiv{fig:cong:equiv} 26 | 27 | \chapter{Mechanized \CICE Definitions} \label{app:mechanization} 28 | 29 | \setmonofont{iosevka.ttc} 30 | 31 | \section{Coq} 32 | 33 | The following type check on Coq 8.15.2. 34 | 35 | \subsection{Preliminary definitions} \label{app:mechanization:coq:prelim} 36 | 37 | \begin{singlespace} 38 | \begin{minted}{coq} 39 | From Equations Require Import Equations. 40 | Require Import Coq.Program.Equality. 41 | Require Import Coq.Unicode.Utf8_core. 42 | 43 | Reserved Notation "r ≤ s" (at level 70, no associativity). 44 | 45 | Inductive Size : Type := 46 | | suc : Size → Size 47 | | lim : ∀ {A : Type}, (A → Size) → Size. 48 | 49 | Inductive Leq : Size → Size → Type := 50 | | mono : ∀ {r s}, r ≤ s → suc r ≤ suc s 51 | | cocone : ∀ {s A f} (a : A), s ≤ f a → s ≤ lim f 52 | | limiting : ∀ {s A f}, (∀ (a : A), f a ≤ s) → lim f ≤ s 53 | where "r ≤ s" := (Leq r s). 54 | 55 | Definition Lt r s : Type := suc r ≤ s. 56 | Notation "r < s" := (Lt r s). 57 | 58 | Definition base : Size := lim (False_rect Size). 59 | 60 | Definition baseLeq s : base ≤ s := 61 | limiting (λ a, (False_rect (_ ≤ s) a)). 62 | 63 | Fixpoint reflLeq {s} : s ≤ s := 64 | match s with 65 | | suc s => mono reflLeq 66 | | lim f => limiting (λ a, cocone a reflLeq) 67 | end. 68 | 69 | Property transLeq {r s t} (rs : r ≤ s) (st : s ≤ t) : r ≤ t. 70 | Admitted. 71 | 72 | (* 73 | Derive NoConfusion for Size. 74 | Equations transLeq {r s t : Size} (rs : r ≤ s) (st : s ≤ t) : r ≤ t := 75 | transLeq (mono rs) (mono st) := mono (transLeq rs st); 76 | transLeq rs (cocone a sfa) := cocone a (transLeq rs sfa); 77 | transLeq (limiting fas) st := limiting (λ a, transLeq (fas a) st); 78 | transLeq (cocone a rfa) (limiting fat) := transLeq rfa (fat a). 79 | *) 80 | 81 | Fixpoint sucLeq s : s ≤ suc s := 82 | match s with 83 | | suc s => mono (sucLeq s) 84 | | lim f => limiting (λ a, transLeq (sucLeq (f a)) (mono (cocone a reflLeq))) 85 | end. 86 | 87 | Inductive Acc (s : Size) : Prop := 88 | acc { accLt : ∀ r, r < s → Acc r }. 89 | Arguments accLt {_}. 90 | 91 | Axiom funext : ∀ {A} {B : A → Type} {p q : ∀ x, B x}, 92 | (∀ x, p x = q x) → p = q. 93 | 94 | Equations accIsProp {s} (acc1 acc2 : Acc s) : acc1 = acc2 := 95 | | acc _ p, acc _ q => 96 | f_equal _ (funext (λ r, funext (λ rs, accIsProp (p r rs) (q r rs)))). 97 | 98 | Lemma accLeq : ∀ r s, r ≤ s → Acc s → Acc r. 99 | Proof. 100 | intros r s rs acc. 101 | induction acc as [s p IH]. 102 | exact (acc r (λ t tr, p t (transLeq tr rs))). 103 | Qed. 104 | 105 | Theorem wf : ∀ s, Acc s. 106 | Proof. 107 | intros s. 108 | induction s as [s IH | A f IH]. 109 | - refine (acc (suc s) (λ r rsucs, accLeq r s _ IH)). 110 | inversion rsucs as [r' s' rs | |]. 111 | exact rs. 112 | - refine (acc (lim f) (λ r rlimf, _)). 113 | inversion rlimf as [| r' A' f' a rfa eqr eqA |]. 114 | dependent destruction H. 115 | destruct (IH a) as [p]. 116 | exact (p r rfa). 117 | Qed. 118 | 119 | Definition wfInd P IH s : P s := 120 | let wfInd := fix wfAcc s acc {struct acc} := 121 | IH s (λ r rs, wfAcc r (acc.(accLt) r rs)) 122 | in wfInd s (wf s). 123 | \end{minted} 124 | \end{singlespace} 125 | 126 | \subsection{W Types} \label{app:mechanization:coq:W} 127 | 128 | \begin{singlespace} 129 | \begin{minted}{coq} 130 | Import SigTNotations. 131 | 132 | Inductive W (A : Type) (B : A → Type) (s : Size) : Type := 133 | | sup : ∀ r, r < s → ∀ a, (B a → W A B r) → W A B s. 134 | Arguments sup {_ _ _}. 135 | 136 | Definition ac {A B} a (f : B a → {s & W A B s}) : {s & B a → W A B s} := 137 | let f' b := 138 | match (f b).2 with 139 | | sup r rs a f => sup r (transLeq rs (cocone b reflLeq)) a f 140 | end 141 | in (lim (λ b, (f b).1) ; f'). 142 | \end{minted} 143 | \end{singlespace} 144 | 145 | \subsection{Full Inductives and Infinite Sizes} 146 | 147 | \begin{singlespace} 148 | \begin{minted}{coq} 149 | (* Naturals *) 150 | 151 | Inductive N (s : Size) : Type := 152 | | zero : ∀ r, r < s → N s 153 | | succ : ∀ r, r < s → N r → N s. 154 | Arguments zero {_}. 155 | Arguments succ {_}. 156 | 157 | Equations limN (n : nat) : Size := 158 | | O => suc base 159 | | S n => suc (limN n). 160 | 161 | Equations natToN (n : nat) : N (limN n) := 162 | | O => zero base reflLeq 163 | | S n => succ (limN n) reflLeq (natToN n). 164 | 165 | Definition infN : Size := lim limN. 166 | Definition leqInfN (n : nat) : limN n ≤ infN := cocone n reflLeq. 167 | 168 | (* W types *) 169 | 170 | Inductive WInf (A : Type) (B : A → Type) : Type := 171 | | sup' : ∀ a, (B a → WInf A B) → WInf A B. 172 | 173 | Equations limW {A} {B} (w : WInf A B) : Size := 174 | | sup' a f => suc (lim (λ b, limW (f b))). 175 | 176 | Equations liftW {A} {B} {r} {s} : r ≤ s → W A B r → W A B s := 177 | | rs, sup t tr a f => sup t (transLeq tr rs) a f. 178 | 179 | Equations WInfToW {A} {B} (w : WInf A B) : W A B (limW w) := 180 | | sup' a f => sup (lim (λ b, limW (f b))) reflLeq a (λ b, liftW _ (WInfToW (f b))). 181 | 182 | Definition infW {A} {B} : Size := lim (@limW A B). 183 | Definition leqInfW {A} {B} (w : WInf A B) : limW w ≤ @infW A B := cocone w reflLeq. 184 | \end{minted} 185 | \end{singlespace} 186 | 187 | \section{Agda} 188 | 189 | The following type check on Agda 2.6.2. 190 | 191 | \subsection{Preliminary definitions} \label{app:mechanization:agda:prelim} 192 | 193 | \begin{singlespace} 194 | \begin{minted}{agda} 195 | {-# OPTIONS --without-K #-} 196 | 197 | open import Agda.Primitive using (Level; lsuc) 198 | open import Relation.Binary.PropositionalEquality.Core using (_≡_; cong) 199 | open import Data.Empty using (⊥; ⊥-elim) 200 | 201 | variable 202 | ℓ ℓ′ : Level 203 | A C : Set ℓ 204 | B : A → Set ℓ 205 | 206 | infix 30 ↑_ 207 | infix 30 ⊔_ 208 | 209 | data Size {ℓ} : Set (lsuc ℓ) where 210 | ↑_ : Size {ℓ} → Size 211 | ⊔_ : {A : Set ℓ} → (A → Size {ℓ}) → Size 212 | 213 | data _≤_ {ℓ} : Size {ℓ} → Size {ℓ} → Set (lsuc ℓ) where 214 | ↑s≤↑s : ∀ {r s} → r ≤ s → ↑ r ≤ ↑ s 215 | s≤⊔f : ∀ {s} f (a : A) → s ≤ f a → s ≤ ⊔ f 216 | ⊔f≤s : ∀ {s} f → (∀ (a : A) → f a ≤ s) → ⊔ f ≤ s 217 | 218 | ◯ : Size 219 | ◯ = ⊔ ⊥-elim 220 | 221 | ◯≤s : ∀ {s} → ◯ ≤ s 222 | ◯≤s = ⊔f≤s ⊥-elim λ () 223 | 224 | s≤s : ∀ {s : Size {ℓ}} → s ≤ s 225 | s≤s {s = ↑ s} = ↑s≤↑s s≤s 226 | s≤s {s = ⊔ f} = ⊔f≤s f (λ a → s≤⊔f f a s≤s) 227 | 228 | s≤s≤s : ∀ {r s t : Size {ℓ}} → r ≤ s → s ≤ t → r ≤ t 229 | s≤s≤s (↑s≤↑s r≤s) (↑s≤↑s s≤t) = ↑s≤↑s (s≤s≤s r≤s s≤t) 230 | s≤s≤s r≤s (s≤⊔f f a s≤fa) = s≤⊔f f a (s≤s≤s r≤s s≤fa) 231 | s≤s≤s (⊔f≤s f fa≤s) s≤t = ⊔f≤s f (λ a → s≤s≤s (fa≤s a) s≤t) 232 | s≤s≤s (s≤⊔f f a s≤fa) (⊔f≤s f fa≤t) = s≤s≤s s≤fa (fa≤t a) 233 | 234 | s≤↑s : ∀ {s : Size {ℓ}} → s ≤ ↑ s 235 | s≤↑s {s = ↑ s} = ↑s≤↑s s≤↑s 236 | s≤↑s {s = ⊔ f} = ⊔f≤s f (λ a → s≤s≤s s≤↑s (↑s≤↑s (s≤⊔f f a s≤s))) 237 | 238 | _<_ : Size {ℓ} → Size {ℓ} → Set (lsuc ℓ) 239 | r < s = ↑ r ≤ s 240 | 241 | record Acc (s : Size {ℓ}) : Set (lsuc ℓ) where 242 | inductive 243 | pattern 244 | constructor acc 245 | field acc< : (∀ r → r < s → Acc r) 246 | open Acc 247 | 248 | accIsProp : ∀ {s : Size {ℓ}} → (acc1 acc2 : Acc s) → acc1 ≡ acc2 249 | accIsProp (acc p) (acc q) = 250 | cong acc (funext p q (λ r → funext (p r) (q r) (λ r mono reflLeq 28 | | lim f => limiting (λ a, cocone a reflLeq) 29 | end. 30 | 31 | Property transLeq {r s t} (rs : r ≤ s) (st : s ≤ t) : r ≤ t. 32 | Admitted. 33 | 34 | (* 35 | Derive NoConfusion for Size. 36 | Equations transLeq {r s t : Size} (rs : r ≤ s) (st : s ≤ t) : r ≤ t := 37 | transLeq (mono rs) (mono st) := mono (transLeq rs st); 38 | transLeq rs (cocone a sfa) := cocone a (transLeq rs sfa); 39 | transLeq (limiting fas) st := limiting (λ a, transLeq (fas a) st); 40 | transLeq (cocone a rfa) (limiting fat) := transLeq rfa (fat a). 41 | *) 42 | 43 | Fixpoint sucLeq s : s ≤ suc s := 44 | match s with 45 | | suc s => mono (sucLeq s) 46 | | lim f => limiting (λ a, transLeq (sucLeq (f a)) (mono (cocone a reflLeq))) 47 | end. 48 | 49 | Inductive Acc (s : Size) : Prop := 50 | acc { accLt : ∀ r, r < s → Acc r }. 51 | Arguments accLt {_}. 52 | 53 | Axiom funext : ∀ {A} {B : A → Type} {p q : ∀ x, B x}, 54 | (∀ x, p x = q x) → p = q. 55 | 56 | Equations accIsProp {s} (acc1 acc2 : Acc s) : acc1 = acc2 := 57 | | acc _ p, acc _ q => 58 | f_equal _ (funext (λ r, funext (λ rs, accIsProp (p r rs) (q r rs)))). 59 | 60 | Lemma accLeq : ∀ r s, r ≤ s → Acc s → Acc r. 61 | Proof. 62 | intros r s rs acc. 63 | induction acc as [s p IH]. 64 | exact (acc r (λ t tr, p t (transLeq tr rs))). 65 | Qed. 66 | 67 | Theorem wf : ∀ s, Acc s. 68 | Proof. 69 | intros s. 70 | induction s as [s IH | A f IH]. 71 | - refine (acc (suc s) (λ r rsucs, accLeq r s _ IH)). 72 | inversion rsucs as [r' s' rs | |]. 73 | exact rs. 74 | - refine (acc (lim f) (λ r rlimf, _)). 75 | inversion rlimf as [| r' A' f' a rfa eqr eqA |]. 76 | dependent destruction H. 77 | destruct (IH a) as [p]. 78 | exact (p r rfa). 79 | Qed. 80 | 81 | Definition wfInd P IH s : P s := 82 | let wfInd := fix wfAcc s acc {struct acc} := 83 | IH s (λ r rs, wfAcc r (acc.(accLt) r rs)) 84 | in wfInd s (wf s). 85 | 86 | Import SigTNotations. 87 | 88 | Inductive W (A : Type) (B : A → Type) (s : Size) : Type := 89 | | sup : ∀ r, r < s → ∀ a, (B a → W A B r) → W A B s. 90 | Arguments sup {_ _ _}. 91 | 92 | Definition ac {A B} a (f : B a → {s & W A B s}) : {s & B a → W A B s} := 93 | let f' b := 94 | match (f b).2 with 95 | | sup r rs a f => sup r (transLeq rs (cocone b reflLeq)) a f 96 | end 97 | in (lim (λ b, (f b).1) ; f'). 98 | 99 | Inductive N (s : Size) : Type := 100 | | zero : ∀ r, r < s → N s 101 | | succ : ∀ r, r < s → N r → N s. 102 | Arguments zero {_}. 103 | Arguments succ {_}. 104 | 105 | Equations limN (n : nat) : Size := 106 | | O => suc base 107 | | S n => suc (limN n). 108 | 109 | Equations natToN (n : nat) : N (limN n) := 110 | | O => zero base reflLeq 111 | | S n => succ (limN n) reflLeq (natToN n). 112 | 113 | Definition infN : Size := lim limN. 114 | 115 | Definition leqInfN (n : nat) : limN n ≤ infN := cocone n reflLeq. 116 | 117 | Inductive WInf (A : Type) (B : A → Type) : Type := 118 | | sup' : ∀ a, (B a → WInf A B) → WInf A B. 119 | 120 | Equations limW {A} {B} (w : WInf A B) : Size := 121 | | sup' a f => suc (lim (λ b, limW (f b))). 122 | 123 | Equations liftW {A} {B} {r} {s} : r ≤ s → W A B r → W A B s := 124 | | rs, sup t tr a f => sup t (transLeq tr rs) a f. 125 | 126 | Equations WInfToW {A} {B} (w : WInf A B) : W A B (limW w) := 127 | | sup' a f => sup (lim (λ b, limW (f b))) reflLeq a (λ b, WInfToW (f b)). 128 | 129 | Definition infW {A} {B} : Size := lim (@limW A B). -------------------------------------------------------------------------------- /figures/cic.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigSyntaxCIC}[1]{ 2 | \begin{figure}[h] 3 | \centering 4 | \begin{align*} 5 | \iT, \jT, \kT, \mT, \nT &\Coloneqq \meta{\textrm{naturals}} & 6 | \GammaT &\Coloneqq \mt \mid \GammaT, \annotT{\xT}{\tauT} \mid \GammaT, \define{\xT}{\tauT}{\eT} \\ 7 | \fT, \gT, \wT, \xT, \yT, \zT, \alphaT, \betaT, \gammaT &\Coloneqq \meta{\textrm{term variables}} & 8 | \DeltaT &\Coloneqq \mt \mid \DeltaT, \annotT{\xT}{\tauT} \mid \DeltaT, \annotT{\cT}{\tauT} \\ 9 | \XT &\Coloneqq \meta{\textrm{inductive type names}} & 10 | \UT &\Coloneqq \PropT \mid \TypeT{\iT} \\ 11 | \cT &\Coloneqq \meta{\textrm{inductive constructor names}} & 12 | \DT &\Coloneqq \app{\dataT{\app{\XT}{\DeltaT}}{\arrT*{\DeltaT}{\UT}}}{\DeltaT} \\ 13 | \eT, \aT, \dT, \pT, \PT, \rT, \sT, \tauT, \sigmaT &\Coloneqq 14 | \mathrlap{\xT \mid \UT \mid \funtypeT{\xT}{\tauT}{\tauT} \mid \funT{\xT}{\tauT}{\eT} \mid \app{\eT}{\eT} \mid \letinT{\xT}{\tauT}{\eT}{\eT} \mid \fixT{\iT}{\fT}{\tauT}{\eT}} \\ 15 | &\mid \mathrlap{\eqT{\eT}{\tauT}{\eT} \mid \reflT{\eT} \mid \JT{\PT}{\dT}{\pT} \mid \matchT{\eT}{\funT*{\vec{\yT}}{\xT}{\PT}}{(\app{\cT}{\vec{\zT}} \RightarrowT \eT) \seq}} 16 | \end{align*} 17 | \caption{Syntax (\CICE)} 18 | \label{#1} 19 | \end{figure} 20 | } 21 | 22 | \newcommand{\FigEquiv}[2][p]{ 23 | \begin{figure}[#1] 24 | \centering 25 | \begin{mathpar} 26 | \fbox{$\defeq{\GammaT}{\eT}{\eT}{\tauT}$} \hfill \\ 27 | \inferrule[\rlabel{$\equiv$-refl}{equiv-refl}]{ 28 | \type{\GammaT}{\eT}{\tauT} 29 | }{ 30 | \defeq{\GammaT}{\eT}{\eT}{\tauT} 31 | } 32 | \and 33 | \inferrule[\rlabel{$\equiv$-sym}{equiv-sym}]{ 34 | \defeq{\GammaT}{\eT_2}{\eT_1}{\tauT} 35 | }{ 36 | \defeq{\GammaT}{\eT_1}{\eT_2}{\tauT} 37 | } 38 | \and 39 | \inferrule[\rlabel{$\equiv$-trans}{equiv-trans}]{ 40 | \defeq{\GammaT}{\eT_1}{\eT_2}{\tauT} \\\\ 41 | \defeq{\GammaT}{\eT_2}{\eT_3}{\tauT} 42 | }{ 43 | \defeq{\GammaT}{\eT_1}{\eT_3}{\tauT} 44 | } 45 | \and 46 | \inferrule[\rlabel{$\equiv$-conv}{equiv-conv}]{ 47 | \subtype{\GammaT}{\sigmaT}{\tauT} \\\\ 48 | \defeq{\GammaT}{\eT_1}{\eT_2}{\sigmaT} 49 | }{ 50 | \defeq{\GammaT}{\eT_1}{\eT_2}{\tauT} 51 | } 52 | \and 53 | \inferrule[\rlabel{$\equiv$-reflect}{equiv-reflect}]{ 54 | \type{\GammaT}{\pT}{\eqT{\eT_1}{\tauT}{\eT_2}} 55 | }{ 56 | \defeq{\GammaT}{\eT_1}{\eT_2}{\tauT} 57 | } 58 | \and 59 | \inferrule[\rlabel{$\equiv$-cong}{equiv-cong}]{ 60 | \textrm{For every $1 \leq i \leq n$:} \\ 61 | \defeq{\GammaT'}{\eT_i}{\eT'_i}{\tauT'} 62 | }{ 63 | \defeq{\GammaT} 64 | {\subst{\eT}{\xT_1, \seq, \xT_n}{\eT_1, \seq, \eT_n}} 65 | {\subst{\eT}{\xT_1, \seq, \xT_n}{\eT'_1, \seq, \eT'_n}} 66 | {\tauT} 67 | } 68 | \and 69 | \inferrule[\rlabel{$\equiv$-$\delta$}{equiv-delta}]{ 70 | (\defineT{\xT}{\tauT}{\eT}) \in \GammaT 71 | }{ 72 | \defeq{\GammaT}{\xT}{\eT}{\tauT} 73 | } 74 | \and 75 | \inferrule[\rlabel{$\equiv$-$\beta$}{equiv-beta}]{ 76 | \type{\GammaT}{\sigmaT}{\UT} \\ 77 | \type{\GammaT, \annotT{\xT}{\sigmaT}}{\eT}{\tauT} \\ 78 | \type{\GammaT}{\eT'}{\sigmaT} 79 | }{ 80 | \defeq{\GammaT}{\app{(\funT{\xT}{\sigmaT}{\eT})}{\eT'}}{\subst{\eT}{\xT}{\eT'}}{\subst{\tauT}{\xT}{\eT'}} 81 | } 82 | \and 83 | \inferrule[\rlabel{$\equiv$-$\eta$}{equiv-eta}]{ 84 | \defeq{\GammaT, \annotT{\xT}{\sigmaT}}{\app{\eT_1}{\xT}}{\app{\eT_2}{\xT}}{\tauT} 85 | }{ 86 | \defeq{\GammaT}{\eT_1}{\eT_2}{\funtypeT{\xT}{\sigmaT}{\tauT}} 87 | } 88 | \and 89 | \inferrule[\rlabel{$\equiv$-$\zeta$}{equiv-zeta}]{ 90 | \type{\GammaT}{\sigmaT}{\UT} \\ 91 | \type{\GammaT}{\eT'}{\sigmaT} \\ 92 | \type{\GammaT, \defineT{\xT}{\sigmaT}{\eT'}}{\eT}{\tauT} 93 | }{ 94 | \defeq{\GammaT}{\letinT{\xT}{\sigmaT}{\eT'}{\eT}}{\subst{\eT}{\xT}{\eT'}}{\subst{\tauT}{\xT}{\eT'}} 95 | } 96 | \and 97 | \inferrule[\rlabel{$\equiv$-$\rho$}{equiv-rho}]{ 98 | \type{\GammaT}{\eT}{\tauT} \\ 99 | \type{\GammaT}{\PT}{\funtypeT{\yT}{\tauT}{\arrT*{\eqT{\eT}{\tauT}{\yT}}{\UT}}} \\ 100 | \type{\GammaT}{\dT}{\app{\PT}{\eT}{\reflT{\eT}}} 101 | }{ 102 | \defeq{\GammaT}{\JT{\PT}{\dT}{\reflT{\eT}}}{\dT}{\app{\PT}{\eT}{\reflT{\eT}}} 103 | } 104 | \iffalse 105 | \and 106 | \inferrule[\rlabel{$\equiv$-$\iota$}{equiv-iota}]{ 107 | \app{\dataT{\app{\XT}{(\annotT{\vec{\wT}}{\vec{\vphantom{\wT}\any}})}}{\arrT*{\DeltaT_I}{\UT}}}{\DeltaT_c} \\ 108 | \annotT{\vec{\yT}}{\vec{\sigmaT}} = \subst{\DeltaT_I}{\vec{\wT}}{\vec{\pT}} \\ 109 | (\annotT{\cT}{\arrT*{(\annotT{\vec{\zT}}{\vec{\tauT}})}{\app{\XT}{\vec{\pT}}{\vec{\aT}}}}) \in \subst{\DeltaT_c}{\vec{\wT}}{\vec{\pT}} \\ 110 | \vec{\aT}' = \subst{\vec{\aT}}{\vec{\zT}}{\vec{\eT}} \\ 111 | \type{\GammaT}{\app{\cT}{\vec{\pT}}{\vec{\eT}}}{\app{\XT}{\vec{\pT}}{\vec{\aT}'}} \\ 112 | \type{\GammaT, \annotT{\vec{\yT}}{\vec{\sigmaT}}, \annotT{\xT}{\app{\XT}{\vec{\pT}}{\vec{\yT}}}}{\PT}{\UT} \\ 113 | \type{\GammaT, \annotT{\vec{\zT}}{\vec{\tauT}}}{\eT}{\subst{\PT}{\vec{\yT}, \vec{\xT}}{\vec{\aT}, \app{\cT}{\vec{\pT}}{\vec{\zT}}}} 114 | }{ 115 | \defeq{\GammaT}{\matchT{\app{\cT}{\vec{\pT}}{\vec{\eT}}}{\funT*{\vec{\yT}}{\xT}{\PT}}{\seq(\app{\cT}{\vec{\zT}} \RightarrowT \eT)\seq}}{\subst{\eT}{\vec{\zT}}{\vec{\eT}}}{\subst{\PT}{\vec{\yT}, \xT}{\vec{\aT}', \app{\cT}{\vec{\pT}}{\vec{\eT}}}} 116 | } 117 | \fi 118 | \and 119 | \inferrule[\rlabel{$\equiv$-$\iota$}{equiv-iota}]{ 120 | \app{\dataT{\app{\XT}{(\annotT{\vec{\wT}}{\vec{\sigmaT}_P})}}{\arrT*{\DeltaT_I}{\UT}}}{\DeltaT_c} \\ 121 | \type{\GammaT}{\vec{\pT}}{\vec{\sigmaT}_P} \\ 122 | \annotT{\vec{\yT}}{\vec{\sigmaT}_I} = \subst{\DeltaT_I}{\vec{\wT}}{\vec{\pT}} \\ 123 | \type{\GammaT, \annotT{\vec{\yT}}{\vec{\sigmaT}_I}, \annotT{\xT}{\app{\XT}{\vec{\pT}}{\vec{\yT}}}}{\PT}{\UT'} \\ 124 | \elim{\XT}{\UT}{\UT'} \\\\ 125 | \card{\DeltaT_c} = n \\ 126 | \textrm{For every $1 \leq i \leq n$:} \\ 127 | (\annotT{\cT_i}{\arrT*{(\annotT{\vec{\zT}_i}{\vec{\tauT}_i})}{\app{\XT}{\vec{\pT}}{\vec{\aT}_i}}}) \in \subst{\DeltaT_c}{\vec{\wT}}{\vec{\pT}} \\ 128 | \type{\GammaT, \annotT{\vec{\zT}_i}{\vec{\tauT}_i}}{\eT_i}{\subst{\PT}{\vec{\yT}, \vec{\xT}}{\vec{\aT}_i, \app{\cT_i}{\vec{\pT}}{\vec{\zT}_i}}} \\\\ 129 | j \in 1 \seq n \\ 130 | \type{\GammaT}{\vec{\eT}}{\vec{\tauT}_j} \\ 131 | \vec{\aT}'_j = \subst{\vec{\aT}_j}{\vec{\zT}_j}{\vec{\eT}} 132 | }{ 133 | \defeq{\GammaT}{\matchT{\app{\cT_j}{\vec{\pT}}{\vec{\eT}}}{\funT*{\vec{\yT}}{\xT}{\PT}}{(\app{\cT_1}{\vec{\zT}_1} \RightarrowT \eT_1)\seq(\app{\cT_n}{\vec{\zT}_n} \RightarrowT \eT_n)}}{\subst{\eT_j}{\vec{\zT}_j}{\vec{\eT}}}{\subst{\PT}{\vec{\yT}, \xT}{\vec{\aT}'_j, \app{\cT_j}{\vec{\pT}}{\vec{\eT}}}} 134 | } 135 | \and 136 | \inferrule[\rlabel{$\equiv$-$\mu$}{equiv-mu}]{ 137 | \type{\GammaT}{\tauT}{\UT} \\ 138 | \defeq{\GammaT}{\tauT}{\arr*{\DeltaT}{\funtypeT{\any}{\app{\XT}{\vec{\pT}}{\vec{\aT}}}{\tauT'}}}{\UT} \\ 139 | \card{\DeltaT} + 1 = \nT \\ 140 | \type{\GammaT, \annotT{\fT}{\tauT}}{\eT}{\tauT} 141 | }{ 142 | \defeq{\GammaT}{\fixT{\nT}{\fT}{\tauT}{\eT}}{\subst{\eT}{\fT}{\fixT{\nT}{\fT}{\tauT}{\eT}}}{\tauT} 143 | } 144 | \end{mathpar} 145 | \caption{Equivalence rules} 146 | \label{#2} 147 | \end{figure} 148 | } 149 | 150 | \newcommand{\FigTypingCIC}[2][p]{ 151 | \begin{figure}[#1] 152 | \centering 153 | \begin{mathpar} 154 | \fbox{$\wf{}{\GammaT}$} \qquad 155 | \fbox{$\type{\GammaT}{\eT}{\tauT}$} \hfill \\ 156 | \inferrule[\rlabel*{nil*}]{~}{\wf{}{\mt}} 157 | \and 158 | \inferrule[\rlabel*{cons*-ass}]{ 159 | \wf{}{\GammaT} \\\\ 160 | \type{\GammaT}{\tauT}{\UT} 161 | }{ 162 | \wf{}{\GammaT, \annotT{\xT}{\tauT}} 163 | } 164 | \and 165 | \inferrule[\rlabel*{cons*-def}]{ 166 | \wf{}{\GammaT} \\\\ 167 | \type{\GammaT}{\eT}{\tauT} 168 | }{ 169 | \wf{}{\GammaT, \defineT{\xT}{\tauT}{\eT}} 170 | } 171 | \and 172 | \inferrule[\rlabel*{conv*}]{ 173 | \type{\GammaT}{\eT}{\sigmaT} \\ 174 | \type{\GammaT}{\sigmaT}{\UT} \\\\ 175 | \type{\GammaT}{\tauT}{\UT} \\ 176 | \subtype{\GammaT}{\sigmaT}{\tauT} 177 | }{ 178 | \type{\GammaT}{\eT}{\tauT} 179 | } 180 | \and 181 | \inferrule[\rlabel*{var*}]{ 182 | \wf{}{\GammaT} \\ 183 | (\annotT{\xT}{\tauT}) \in \GammaT \\\\ 184 | \textit{or } (\defineT{\xT}{\tauT}{\eT}) \in \GammaT 185 | }{ 186 | \type{\GammaT}{\xT}{\tauT} 187 | } 188 | \and 189 | \inferrule[\rlabel*{univ*}]{ 190 | \wf{}{\GammaT} 191 | }{ 192 | \type{\GammaT}{\UT}{\axioms{\UT}} 193 | } 194 | \and 195 | \inferrule[\rlabel*{pi*}]{ 196 | \type{\GammaT}{\sigmaT}{\UT_1} \\ 197 | \type{\GammaT, \annotT{\xT}{\sigmaT}}{\tauT}{\UT_2} 198 | }{ 199 | \type{\GammaT}{\funtypeT{\xT}{\sigmaT}{\tauT}}{\rules{\UT_1}{\UT_2}} 200 | } 201 | \and 202 | \inferrule[\rlabel*{lam*}]{ 203 | \type{\GammaT}{\sigmaT}{\UT} \\ 204 | \type{\GammaT, \annotT{\xT}{\sigmaT}}{\eT}{\tauT} 205 | }{ 206 | \type{\GammaT}{\funT{\xT}{\sigmaT}{\eT}}{\funtypeT{\xT}{\sigmaT}{\tauT}} 207 | } 208 | \and 209 | \inferrule[\rlabel*{app*}]{ 210 | \type{\GammaT}{\eT_1}{\funtypeT{\xT}{\sigmaT}{\tauT}} \\ 211 | \type{\GammaT}{\eT_2}{\sigmaT} 212 | }{ 213 | \type{\GammaT}{\app{\eT_1}{\eT_2}}{\subst{\tauT}{\xT}{\eT_2}} 214 | } 215 | \and 216 | \inferrule[\rlabel*{let*}]{ 217 | \type{\GammaT}{\sigmaT}{\UT} \\ 218 | \type{\GammaT}{\eT_1}{\sigmaT} \\ 219 | \type{\GammaT, \defineT{\xT}{\sigmaT}{\eT_1}}{\eT_2}{\tauT} 220 | }{ 221 | \type{\GammaT}{\letinT{\xT}{\sigmaT}{\eT_1}{\eT_2}}{\subst{\tauT}{\xT}{\eT_1}} 222 | } 223 | \and 224 | \inferrule[\rlabel*{eq}]{ 225 | \type{\GammaT}{\tauT}{\UT} \\ 226 | \type{\GammaT}{\eT_1}{\tauT} \\ 227 | \type{\GammaT}{\eT_2}{\tauT} 228 | }{ 229 | \type{\GammaT}{\eqT{\eT_1}{\tauT}{\eT_2}}{\UT} 230 | } 231 | \and 232 | \inferrule[\rlabel*{refl}]{ 233 | \type{\GammaT}{\eT}{\tauT} 234 | }{ 235 | \type{\GammaT}{\reflT{\eT}}{\eqT{\eT}{\tauT}{\eT}} 236 | } 237 | \and 238 | \inferrule[\rlabel*{J}]{ 239 | \type{\GammaT}{\pT}{\eqT{\eT_1}{\tauT}{\eT_2}} \\ 240 | \type{\GammaT}{\PT}{\funtypeT{\yT}{\tauT}{\arrT*{\eqT{\eT_1}{\tauT}{\yT}}{\UT}}} \\ 241 | \type{\GammaT}{\dT}{\app{\PT}{\eT_1}{\reflT{\eT_1}}} 242 | }{ 243 | \type{\GammaT}{\JT{\PT}{\dT}{\pT}}{\app{\PT}{\eT_2}{\pT}} 244 | } 245 | \and 246 | \inferrule[\rlabel*{ind}]{ 247 | \wf{}{\GammaT} \\ 248 | \app{\dataT{\app{\XT}{\DeltaT_P}}{\tauT}}{\any} 249 | }{ 250 | \type{\GammaT}{\XT}{\arrT*{\DeltaT_P}{\tauT}} 251 | } 252 | \and 253 | \inferrule[\rlabel*{constr}]{ 254 | \wf{}{\GammaT} \\ 255 | \app{\dataT{\app{\XT}{\DeltaT_P}}{\any}}{\DeltaT_c} \\ 256 | (\annotT{\cT}{\tauT}) \in \DeltaT_c 257 | }{ 258 | \type{\GammaT}{\cT}{\arrT*{\DeltaT_P}{\tauT}} 259 | } 260 | \and 261 | \inferrule[\rlabel*{case}]{ 262 | \app{\dataT{\app{\XT}{(\annotT{\vec{\wT}}{\vec{\vphantom{\wT}\any}})}}{\arrT*{\DeltaT_I}{\UT}}}{\DeltaT_c} \\ 263 | \annotT{\vec{\yT}}{\vec{\sigmaT}} = \subst{\DeltaT_I}{\vec{\wT}}{\vec{\pT}} \\ 264 | \type{\GammaT}{\eT}{\app{\XT}{\vec{\pT}}{\vec{\aT}}} \\ 265 | \type{\GammaT, \annotT{\vec{\yT}}{\vec{\sigmaT}}, \annotT{\xT}{\app{\XT}{\vec{\pT}}{\vec{\yT}}}}{\PT}{\UT'} \\ 266 | \elim{\XT}{\UT}{\UT'} \\\\ 267 | \card{\DeltaT_c} = n \\ 268 | \textrm{For every $1 \leq i \leq n$:} \\ 269 | (\annotT{\cT_i}{\arrT*{(\annotT{\vec{\zT}_i}{\vec{\tauT}_i})}{\app{\XT}{\vec{\pT}}{\vec{\aT}_i}}}) \in \subst{\DeltaT_c}{\vec{\wT}}{\vec{\pT}} \\ 270 | \type{\GammaT, \annotT{\vec{\zT}_i}{\vec{\tauT}_i}}{\eT_i}{\subst{\PT}{\vec{\yT}, \vec{\xT}}{\vec{\aT}_i, \app{\cT_i}{\vec{\pT}}{\vec{\zT}_i}}} 271 | }{ 272 | \type{\GammaT}{\matchT{\eT}{\funT*{\vec{\yT}}{\xT}{\PT}}{(\app{\cT_1}{\vec{\zT}_1} \RightarrowT \eT_1)\seq(\app{\cT_n}{\vec{\zT}_n} \RightarrowT \eT_n)}}{\subst{\PT}{\vec{\yT}, \xT}{\vec{\aT}, \eT}} 273 | } 274 | \and 275 | \inferrule[\rlabel*{fix*}]{ 276 | \type{\GammaT}{\tauT}{\UT} \\ 277 | \defeq{\GammaT}{\tauT}{\arr*{\DeltaT}{\funtypeT{\any}{\app{\XT}{\vec{\pT}}{\vec{\aT}}}{\tauT'}}}{\UT} \\ 278 | \card{\DeltaT} + 1 = \nT \\ 279 | \type{\GammaT, \annotT{\fT}{\tauT}}{\eT}{\tauT} 280 | }{ 281 | \type{\GammaT}{\fixT{\nT}{\fT}{\tauT}{\eT}}{\tauT} 282 | } 283 | \end{mathpar} 284 | \caption{Typing and well-formedness rules (\CICE)} 285 | \label{#2} 286 | \end{figure} 287 | } 288 | 289 | \newcommand{\FigSubtypingCIC}[1]{ 290 | \begin{figure}[h] 291 | \centering 292 | \begin{mathpar} 293 | \fbox{$\subtype{\GammaT}{\tauT}{\tauT}$} \hfill \\ 294 | \inferrule[\rlabel{$\preccurlyeq$-conv}{subtype-conv}]{ 295 | \defeq{\GammaT}{\tauT_1}{\tauT_2}{\UT} 296 | }{ 297 | \subtype{\GammaT}{\tauT_1}{\tauT_2} 298 | } 299 | \and 300 | \inferrule[\rlabel{$\preccurlyeq$-trans}{subtype-trans}]{ 301 | \subtype{\GammaT}{\tauT_1}{\tauT_2} \\ 302 | \subtype{\GammaT}{\tauT_2}{\tauT_3} 303 | }{ 304 | \subtype{\GammaT}{\tauT_1}{\tauT_3} 305 | } 306 | \and 307 | \inferrule[\rlabel{$\preccurlyeq$-prop}{subtype-prop}]{~}{ 308 | \subtype{\GammaT}{\PropT}{\TypeT{\iT}} 309 | } 310 | \and 311 | \inferrule[\rlabel{$\preccurlyeq$-type}{subtype-type}]{ 312 | \iT \leq \jT 313 | }{ 314 | \subtype{\GammaT}{\TypeT{\iT}}{\TypeT{\jT}} 315 | } 316 | \and 317 | \inferrule[\rlabel{$\preccurlyeq$-pi}{subtype-pi}]{ 318 | \defeq{\GammaT}{\sigmaT_1}{\sigmaT_2}{\UT} \\ 319 | \subtype{\GammaT, \annotT{\xT}{\sigmaT_2}}{\tauT_1}{\tauT_2} 320 | }{ 321 | \subtype{\GammaT}{\funtypeT{\xT}{\sigmaT_1}{\tauT_1}}{\funtypeT{\xT}{\sigmaT_2}{\tauT_2}} 322 | } 323 | \end{mathpar} 324 | \caption{Subtyping rules (\CICE)} 325 | \label{#1} 326 | \end{figure} 327 | } -------------------------------------------------------------------------------- /figures/congruence.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigCongRed}[1]{ 2 | \small 3 | \begin{mathpar} 4 | \inferrule{ 5 | \red{\Phi; \Gamma}{\sigma}{\sigma'} 6 | }{ 7 | \red{\Phi; \Gamma}{\funtype{x}{\sigma}{\tau}}{\funtype{x}{\sigma'}{\tau}} 8 | } 9 | \and 10 | \inferrule{ 11 | \red{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} 12 | }{ 13 | \red{\Phi; \Gamma}{\funtype{x}{\sigma}{\tau}}{\funtype{x}{\sigma}{\tau'}} 14 | } 15 | \and 16 | \inferrule{ 17 | \red{\Phi; \Gamma}{\sigma}{\sigma'} 18 | }{ 19 | \red{\Phi; \Gamma}{\fun{x}{\sigma}{e}}{\fun{x}{\sigma'}{e}} 20 | } 21 | \and 22 | \inferrule{ 23 | \red{\Phi; \Gamma, \annot{x}{\sigma}}{e}{e'} 24 | }{ 25 | \red{\Phi; \Gamma}{\fun{x}{\sigma}{e}}{\fun{x}{\sigma}{e'}} 26 | } 27 | \and 28 | \inferrule{ 29 | \red{\Phi; \Gamma}{e_1}{e'_1} 30 | }{ 31 | \red{\Phi; \Gamma}{\app{e_1}{e_2}}{\app{e'_1}{e_2}} 32 | } 33 | \and 34 | \inferrule{ 35 | \red{\Phi; \Gamma}{e_2}{e'_2} 36 | }{ 37 | \red{\Phi; \Gamma}{\app{e_1}{e_2}}{\app{e_1}{e'_2}} 38 | } 39 | \and 40 | \inferrule{ 41 | \red{\Phi; \Gamma}{\sigma}{\sigma'} 42 | }{ 43 | \red{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\letin{x}{\sigma'}{e_1}{e_2}} 44 | } 45 | \and 46 | \inferrule{ 47 | \red{\Phi; \Gamma}{e_1}{e'_1} 48 | }{ 49 | \red{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\letin{x}{\sigma}{e'_1}{e_2}} 50 | } 51 | \and 52 | \inferrule{ 53 | \red{\Phi; \Gamma, \define{x}{\sigma}{e_1}}{e_2}{e'_2} 54 | }{ 55 | \red{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\letin{x}{\sigma}{e_1}{e'_2}} 56 | } 57 | \\ 58 | \inferrule{ 59 | \red{\Phi, \alpha; \Gamma}{\tau}{\tau'} 60 | }{ 61 | \red{\Phi; \Gamma}{\Funtype{\alpha}{\tau}}{\Funtype{\alpha}{\tau'}} 62 | } 63 | \and 64 | \inferrule{ 65 | \red{\Phi, \alpha; \Gamma}{e}{e'} 66 | }{ 67 | \red{\Phi; \Gamma}{\Fun{\alpha}{e}}{\Fun{\alpha}{e'}} 68 | } 69 | \and 70 | \inferrule{ 71 | \red{\Phi; \Gamma}{e}{e'} 72 | }{ 73 | \red{\Phi; \Gamma}{\App{e}{s}}{\App{e'}{s}} 74 | } 75 | \and 76 | \inferrule{ 77 | \red{\Phi, \bound{\alpha}{s}; \Gamma}{\tau}{\tau'} 78 | }{ 79 | \red{\Phi; \Gamma}{\Funtype<{\alpha}{s}{\tau}}{\Funtype<{\alpha}{s}{\tau'}} 80 | } 81 | \and 82 | \inferrule{ 83 | \red{\Phi, \bound{\alpha}{s}; \Gamma}{e}{e'} 84 | }{ 85 | \red{\Phi; \Gamma}{\Fun<{\alpha}{s}{e}}{\Fun<{\alpha}{s}{e'}} 86 | } 87 | \and 88 | \inferrule{ 89 | \red{\Phi, \alpha; \Gamma}{\sigma}{\sigma'} 90 | }{ 91 | \red{\Phi; \Gamma}{\fix{f}{\alpha}{\sigma}{e}}{\fix{f}{\alpha}{\sigma'}{e}} 92 | } 93 | \and 94 | \inferrule{ 95 | \red{\Phi, \alpha; \Gamma, \annot{f}{\Funtype<{\beta}{\alpha}{\subst{\sigma}{\alpha}{\beta}}}}{e}{e'} 96 | }{ 97 | \red{\Phi; \Gamma}{\fix{f}{\alpha}{\sigma}{e}}{\fix{f}{\alpha}{\sigma}{e'}} 98 | } 99 | \and 100 | \inferrule{ 101 | \red{\Phi; \Gamma}{\sigma}{\sigma'} 102 | }{ 103 | \red{\Phi; \Gamma}{\W{x}{\sigma}{\tau}{s}}{\W{x}{\sigma'}{\tau}{s}} 104 | } 105 | \and 106 | \inferrule{ 107 | \red{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} 108 | }{ 109 | \red{\Phi; \Gamma}{\W{x}{\sigma}{\tau}{s}}{\W{x}{\sigma}{\tau'}{s}} 110 | } 111 | \and 112 | \inferrule{ 113 | \red{\Phi; \Gamma}{e}{e'} 114 | }{ 115 | \red{\Phi; \Gamma}{\succ{r}{s}{e}}{\succ{r}{s}{e'}} 116 | } 117 | \end{mathpar} 118 | } 119 | 120 | \newcommand{\FigCongRedCase}[1]{ 121 | \small 122 | \begin{mathpar} 123 | \setlength{\jot}{-1.5pt} 124 | \inferrule{ 125 | \red{\Phi; \Gamma}{\sigma}{\sigma'} 126 | }{ 127 | \red{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\sup{x}{\sigma'}{\tau}{s}{r}{e_1}{e_2}} 128 | } 129 | \quad 130 | \inferrule{ 131 | \red{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} 132 | }{ 133 | \red{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\sup{x}{\sigma}{\tau'}{s}{r}{e_1}{e_2}} 134 | } 135 | \and 136 | \inferrule{ 137 | \red{\Phi; \Gamma}{e_1}{e'_1} 138 | }{ 139 | \red{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\sup{x}{\sigma}{\tau}{s}{r}{e'_1}{e_2}} 140 | } 141 | \quad 142 | \inferrule{ 143 | \red{\Phi; \Gamma}{e_2}{e'_2} 144 | }{ 145 | \red{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e'_2}} 146 | } 147 | \and 148 | \inferrule{ 149 | \red{\Phi; \Gamma}{e}{e'} 150 | }{ 151 | \red{\Phi; \Gamma}{ 152 | \begin{aligned} 153 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 154 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 155 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 156 | \end{aligned} 157 | }{ 158 | \begin{aligned} 159 | &\match{e'}{\fun{x}{\N{s}}{P}}{ \\ 160 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 161 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 162 | \end{aligned} 163 | } 164 | } 165 | \and 166 | \inferrule{ 167 | \red{\Phi; \Gamma, \annot{x}{\N{s}}}{P}{P'} 168 | }{ 169 | \red{\Phi; \Gamma}{ 170 | \begin{aligned} 171 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 172 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 173 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 174 | \end{aligned} 175 | }{ 176 | \begin{aligned} 177 | &\match{e}{\fun{x}{\N{s}}{P'}}{ \\ 178 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 179 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 180 | \end{aligned} 181 | } 182 | } 183 | \and 184 | \inferrule{ 185 | \red{\Phi, \bound{\alpha}{s}; \Gamma}{e_z}{e'_z} 186 | }{ 187 | \red{\Phi; \Gamma}{ 188 | \begin{aligned} 189 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 190 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 191 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 192 | \end{aligned} 193 | }{ 194 | \begin{aligned} 195 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 196 | &\quad \App{\zero*}{\alpha} \Rightarrow e'_z \\ 197 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 198 | \end{aligned} 199 | } 200 | } 201 | \and 202 | \inferrule{ 203 | \red{\Phi, \bound{\beta}{s}; \Gamma, \annot{z}{\N{\beta}}}{e_s}{e'_s} 204 | }{ 205 | \red{\Phi; \Gamma}{ 206 | \begin{aligned} 207 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 208 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 209 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 210 | \end{aligned} 211 | }{ 212 | \begin{aligned} 213 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 214 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 215 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e'_s} 216 | \end{aligned} 217 | } 218 | } 219 | \and 220 | \inferrule{ 221 | \red{\Phi; \Gamma}{e}{e'} 222 | }{ 223 | \red{\Phi; \Gamma}{ 224 | \begin{aligned} 225 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 226 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 227 | \end{aligned} 228 | }{ 229 | \begin{aligned} 230 | &\match{e'}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 231 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 232 | \end{aligned} 233 | } 234 | } 235 | \and 236 | \inferrule{ 237 | \red{\Phi; \Gamma, \annot{x}{\W{y}{\sigma}{\tau}{s}}}{P}{P'} 238 | }{ 239 | \red{\Phi; \Gamma}{ 240 | \begin{aligned} 241 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 242 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 243 | \end{aligned} 244 | }{ 245 | \begin{aligned} 246 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P'}}{ \\ 247 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 248 | \end{aligned} 249 | } 250 | } 251 | \and 252 | \inferrule{ 253 | \red{\Phi, \bound{\alpha}{s}; \Gamma, \annot{z_1}{\sigma}, \annot{z_2}{\arr*{\subst{\tau}{y}{z_1}}{\W{y}{\sigma}{\tau}{\alpha}}}}{e_s}{e'_s} 254 | }{ 255 | \red{\Phi; \Gamma}{ 256 | \begin{aligned} 257 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 258 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 259 | \end{aligned} 260 | }{ 261 | \begin{aligned} 262 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 263 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e'_s} 264 | \end{aligned} 265 | } 266 | } 267 | \end{mathpar} 268 | } 269 | 270 | \newcommand{\FigCongTakahashi}[1]{ 271 | \small 272 | \begin{mathpar} 273 | \setlength{\jot}{-1.5pt} 274 | \inferrule{ 275 | \develop{\Phi; \Gamma}{\sigma}{\sigma'} \\ 276 | \develop{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} 277 | }{ 278 | \develop{\Phi; \Gamma}{\funtype{x}{\sigma}{\tau}}{\funtype{x}{\sigma'}{\tau}} 279 | } 280 | \and 281 | \inferrule{ 282 | \develop{\Phi; \Gamma}{\sigma}{\sigma'} \\ 283 | \develop{\Phi; \Gamma, \annot{x}{\sigma}}{e}{e'} 284 | }{ 285 | \develop{\Phi; \Gamma}{\fun{x}{\sigma}{e}}{\fun{x}{\sigma'}{e}} 286 | } 287 | \and 288 | \inferrule{ 289 | \develop{\Phi; \Gamma}{e_1}{e'_1} \\ 290 | \develop{\Phi; \Gamma}{e_2}{e'_2} 291 | }{ 292 | \develop{\Phi; \Gamma}{\app{e_1}{e_2}}{\app{e'_1}{e'_2}} 293 | } 294 | \and 295 | \inferrule{ 296 | \develop{\Phi, \alpha; \Gamma}{\tau}{\tau'} 297 | }{ 298 | \develop{\Phi; \Gamma}{\Funtype{\alpha}{\tau}}{\Funtype{\alpha}{\tau'}} 299 | } 300 | \and 301 | \inferrule{ 302 | \develop{\Phi, \alpha; \Gamma}{e}{e'} 303 | }{ 304 | \develop{\Phi; \Gamma}{\Fun{\alpha}{e}}{\Fun{\alpha}{e'}} 305 | } 306 | \and 307 | \inferrule{ 308 | \develop{\Phi; \Gamma}{e}{e'} 309 | }{ 310 | \develop{\Phi; \Gamma}{\App{e}{s}}{\App{e'}{s}} 311 | } 312 | \and 313 | \inferrule{ 314 | \develop{\Phi, \bound{\alpha}{s}; \Gamma}{\tau}{\tau'} 315 | }{ 316 | \develop{\Phi; \Gamma}{\Funtype<{\alpha}{s}{\tau}}{\Funtype<{\alpha}{s}{\tau'}} 317 | } 318 | \and 319 | \inferrule{ 320 | \develop{\Phi, \bound{\alpha}{s}; \Gamma}{e}{e'} 321 | }{ 322 | \develop{\Phi; \Gamma}{\Fun<{\alpha}{s}{e}}{\Fun<{\alpha}{s}{e'}} 323 | } 324 | \and 325 | \inferrule{ 326 | \develop{\Phi, \alpha; \Gamma}{\tau}{\tau'} \\\\ 327 | \develop{\Phi, \alpha; \Gamma, \annot{f}{\Funtype<{\beta}{\alpha}{\subst{\tau}{\alpha}{\beta}}}}{e}{e'} 328 | }{ 329 | \develop{\Phi; \Gamma}{\fix{f}{\alpha}{\tau}{e}}{\fix{f}{\alpha}{\tau'}{e}} 330 | } 331 | \and 332 | \inferrule{ 333 | \develop{\Phi; \Gamma}{\sigma}{\sigma'} \\ 334 | \develop{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} 335 | }{ 336 | \develop{\Phi; \Gamma}{\W{x}{\sigma}{\tau}{s}}{\W{x}{\sigma'}{\tau'}{s}} 337 | } 338 | \and 339 | \inferrule{ 340 | \develop{\Phi; \Gamma}{e}{e'} 341 | }{ 342 | \develop{\Phi; \Gamma}{\succ{r}{s}{e}}{\succ{r}{s}{e'}} 343 | } 344 | \and 345 | \inferrule{ 346 | \develop{\Phi; \Gamma}{\sigma}{\sigma'} \\ 347 | \develop{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{\tau'} \\\\ 348 | \develop{\Phi; \Gamma}{e_1}{e'_1} \\ 349 | \develop{\Phi; \Gamma}{e_2}{e'_2} 350 | }{ 351 | \develop{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{r}{s}{e_1}{e_2}}{\sup{x}{\sigma'}{\tau'}{r}{s}{e'_1}{e'_2}} 352 | } 353 | \and 354 | \inferrule{ 355 | \develop{\Phi; \Gamma}{e}{e'} \\ 356 | \develop{\Phi; \Gamma, \annot{x}{\N{s}}}{P}{P'} \\\\ 357 | \develop{\Phi, \bound{\alpha}{s}; \Gamma}{e_z}{e'_z} \\ 358 | \develop{\Phi, \bound{\beta}{s}; \Gamma, \annot{z}{\N{\beta}}}{e_s}{e'_s} 359 | }{ 360 | \develop{\Phi; \Gamma}{ 361 | \begin{aligned} 362 | &\match{e}{\fun{x}{\N{s}}{P}}{ \\ 363 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 364 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 365 | \end{aligned} 366 | }{ 367 | \begin{aligned} 368 | &\match{e'}{\fun{x}{\N{s}}{P'}}{ \\ 369 | &\quad \App{\zero*}{\alpha} \Rightarrow e'_z \\ 370 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e'_s} 371 | \end{aligned} 372 | } 373 | } 374 | \and 375 | \inferrule{ 376 | \develop{\Phi; \Gamma}{e}{e'} \\ 377 | \develop{\Phi; \Gamma, \annot{x}{\W{y}{\sigma}{\tau}{s}}}{P}{P'} \\\\ 378 | \develop{\Phi, \bound{\alpha}{s}; \Gamma, \annot{z_1}{\sigma}, \annot{z_2}{\arr*{\subst{\tau}{y}{z_1}}{\W{y}{\sigma}{\tau}{\alpha}}}}{e_s}{e'_s} 379 | }{ 380 | \develop{\Phi; \Gamma}{ 381 | \begin{aligned} 382 | &\match{e}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P}}{ \\ 383 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 384 | \end{aligned} 385 | }{ 386 | \begin{aligned} 387 | &\match{e'}{\fun{x}{\W{y}{\sigma}{\tau}{s}}{P'}}{ \\ 388 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e'_s} 389 | \end{aligned} 390 | } 391 | } 392 | \and 393 | \inferrule{~}{ 394 | \develop{\Phi; \Gamma}{e}{e} 395 | } 396 | \end{mathpar} 397 | } 398 | 399 | \newcommand{\FigCongEquiv}[1]{ 400 | \begin{mathpar} 401 | \setlength{\jot}{-4pt} 402 | \inferrule{ 403 | \defeq{\GammaT}{\sigmaT}{\sigmaT'}{\UT_1} \\ 404 | \defeq{\GammaT, \annotT{\xT}{\sigmaT}}{\tauT}{\tauT'}{\UT_2} 405 | }{ 406 | \defeq{\GammaT}{\funtypeT{\xT}{\sigmaT}{\tauT}}{\funtypeT{\xT}{\sigmaT'}{\tauT'}}{\rules{\UT_1}{\UT_2}} 407 | } 408 | \and 409 | \inferrule{ 410 | \defeq{\GammaT}{\sigmaT}{\sigmaT'}{\UT} \\ 411 | \defeq{\GammaT, \annotT{\xT}{\sigmaT}}{\eT}{\eT'}{\tauT} 412 | }{ 413 | \defeq{\GammaT}{\funT{\xT}{\sigmaT}{\eT}}{\funT{\xT}{\sigmaT}{\eT'}}{\funtypeT{\xT}{\sigmaT}{\tauT}} 414 | } 415 | \and 416 | \inferrule{ 417 | \defeq{\GammaT}{\eT_1}{\eT'_1}{\funtypeT{\xT}{\sigmaT}{\tauT}} \\ 418 | \defeq{\GammaT}{\eT_2}{\eT'_2}{\sigmaT} 419 | }{ 420 | \defeq{\GammaT}{\app{\eT_1}{\eT_2}}{\app{\eT'_1}{\eT'_2}}{\subst{\tauT}{\xT}{\eT_2}} 421 | } 422 | \and 423 | \inferrule{ 424 | \defeq{\GammaT}{\eT}{\eT'}{\tauT} 425 | }{ 426 | \defeq{\GammaT}{\reflT{\eT}}{\reflT{\eT'}}{\eqT{\eT}{\tau}{\eT}} 427 | } 428 | \and 429 | \inferrule{ 430 | \defeq{\GammaT}{\sigmaT}{\sigmaT'}{\UT} \\ 431 | \defeq{\GammaT}{\eT_1}{\eT'_1}{\sigmaT} \\ 432 | \defeq{\GammaT, \defineT{\xT}{\sigmaT}{\eT_1}}{\eT_2}{\eT'_2}{\tauT} 433 | }{ 434 | \defeq{\GammaT}{\letinT{\xT}{\sigmaT}{\eT_1}{\eT_2}}{\letinT{\xT}{\sigmaT'}{\eT'_1}{\eT'_2}}{\subst{\tauT}{\xT}{\eT_1}} 435 | } 436 | \and 437 | \inferrule{ 438 | \defeq{\GammaT}{\tauT}{\tauT'}{\UT} \\\\ 439 | \defeq{\GammaT}{\eT_1}{\eT'_1}{\tauT} \\ 440 | \defeq{\GammaT}{\eT_2}{\eT'_2}{\tauT} 441 | }{ 442 | \defeq{\GammaT}{\eqT{\eT_1}{\tauT}{\eT_2}}{\eqT{\eT'_1}{\tauT'}{\eT'_2}}{\UT} 443 | } 444 | \and 445 | \inferrule{ 446 | \defeq{\GammaT}{\PT}{\PT'}{\funtypeT{\yT}{\tauT}{\funtypeT{\zT}{\eqT{\eT_1}{\tauT}{\yT}}{\UT}}} \\\\ 447 | \defeq{\GammaT}{\dT}{\dT'}{\app{\PT}{\eT_1}{\reflT{\eT_1}}} \\ 448 | \defeq{\GammaT}{\pT}{\pT'}{\eqT{\eT_1}{\tauT}{\eT_2}} 449 | }{ 450 | \defeq{\GammaT}{\JT{\PT}{\dT}{\pT}}{\JT{\PT'}{\dT'}{\pT'}}{\app{\PT}{\eT_2}{\pT}} 451 | } 452 | \and 453 | \inferrule{ 454 | \app{\dataT{\app{\XT}{(\annotT{\vec{\wT}}{\vec{\vphantom{\wT}\any}})}}{\arrT*{\DeltaT_I}{\UT}}}{\DeltaT_c} \\ 455 | \annotT{\vec{\yT}}{\vec{\sigmaT}} = \subst{\DeltaT_I}{\vec{\wT}}{\vec{\pT}} \\ 456 | \defeq{\GammaT}{\eT}{\eT'}{\app{\XT}{\vec{\pT}}{\vec{\aT}}} \\ 457 | \defeq{\GammaT, \annotT{\vec{\yT}}{\vec{\sigmaT}}, \annotT{\xT}{\app{\XT}{\vec{\pT}}{\vec{\aT}}}}{\PT}{\PT'}{\UT'} \\ 458 | \textrm{For every $1 \leq i \leq n$:} \\ 459 | (\annotT{\cT_i}{\arrT*{(\annotT{\vec{\zT}_i}{\vec{\tauT}_i})}{\app{\XT}{\vec{\pT}}{\vec{\aT}_i}}}) \in \subst{\DeltaT_c}{\vec{\wT}}{\vec{\pT}} \\ 460 | \defeq{\GammaT, \annotT{\vec{\zT}_i}{\vec{\tauT}_i}}{\eT_i}{\eT'_i}{\subst{\PT}{\vec{\yT}, \xT}{\vec{\aT}_i, \app{\cT_i}{\vec{\pT}}{\vec{\zT}_i}}} 461 | }{ 462 | \defeq{\GammaT}{ 463 | \begin{aligned} 464 | &\matchT{\eT}{\funT*{\vec{\yT}}{\xT}{\PT}}{ \\ 465 | &\quad \app{\cT_1}{\vec{\zT}_1} \RightarrowT \eT_1 \\ 466 | &\quad \seq \\ 467 | &\quad \app{\cT_n}{\vec{\zT}_n} \RightarrowT \eT_n} 468 | \end{aligned} 469 | }{ 470 | \begin{aligned} 471 | &\matchT{\eT'}{\funT*{\vec{\yT}}{\xT}{\PT'}}{ \\ 472 | &\quad \app{\cT_1}{\vec{\zT}_1} \RightarrowT \eT'_1 \\ 473 | &\quad \seq \\ 474 | &\quad \app{\cT_n}{\vec{\zT}_n} \RightarrowT \eT'_n} 475 | \end{aligned} 476 | }{\subst{\PT}{\vec{\yT}, \xT}{\vec{\aT}, \eT}} 477 | } 478 | \and 479 | \inferrule{ 480 | \defeq{\GammaT}{\tauT}{\tauT'}{\UT} \\ 481 | \defeq{\GammaT, \annotT{\fT}{\tauT}}{\eT}{\eT'}{\tauT} 482 | }{ 483 | \defeq{\GammaT}{\fixT{\nT}{\fT}{\tauT}{\eT}}{\fixT{\nT}{\fT}{\tauT'}{\eT'}}{\tauT} 484 | } 485 | \end{mathpar} 486 | } -------------------------------------------------------------------------------- /figures/definitions.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigData}[1]{ 2 | \begin{figure}[h] 3 | \newlength{\xspacing} 4 | \setlength{\xspacing}{1.5ex} 5 | \centering 6 | \begin{align*} 7 | &\dataT{\botT}{\PropT} \\[\xspacing] 8 | &\dataT{\SizeT}{\TypeT{\tg{i+1}}} \\ 9 | &\quad \annotT{\sucT}{\arrT*{\SizeT}{\SizeT}} \\ 10 | &\quad \annotT{\limT}{\funtypeT{A}{\TypeT{\iT}}{\arrT*{(\arrT*{A}{\SizeT})}{\SizeT}}} \\ 11 | &\LetT{\baseT}{\SizeT}{\app{\limT}{\botT}{(\funT{\mathit{false}}{\botT}{\matchT{\mathit{false}}{\funT*{\mt}{\any}{\SizeT}}{\mt}})}} \\[\xspacing] 12 | &\dataT{\any \szleT \any}{\arrT*{\SizeT}{\SizeT}{\TypeT{\tg{i+1}}}} \\ 13 | &\quad \annotT{\monoT}{\funtypeT{\alpha, \beta}{\SizeT}{\arrT*{\alpha \szleT \beta}{\app{\sucT}{\alpha} \szleT \app{\sucT}{\beta}}}} \\ 14 | &\quad \annotT{\coconeT}{\funtypeT{A}{\TypeT{\iT}}{\funtypeT{\beta}{\SizeT}{\funtypeT{f}{\arrT*{A}{\SizeT}}{\funtypeT{a}{A}{\arr*{\beta \szleT \app{f}{a}}{\beta \szleT \app{\limT}{A}{f}}}}}}} \\ 15 | &\quad \annotT{\limitT}{\funtypeT{A}{\TypeT{\iT}}{\funtypeT{\beta}{\SizeT}{\funtypeT{f}{\arrT*{A}{\SizeT}}{\arr*{(\funtypeT{a}{A}{\app{f}{a} \szleT \beta})}{\app{\limT}{A}{f} \szleT \beta}}}}} \\ 16 | &\LetT{\any \szltT \any}{\arrT*{\SizeT}{\SizeT}{\TypeT{\tg{i+1}}}}{\funT{\alpha, \beta}{\SizeT}{\app{\sucT}{\alpha} \szltT \beta}} \\[\xspacing] 17 | &\dataT{\app{\AccT}{(\annot{\alpha}{\SizeT})}}{\PropT} \\ 18 | &\quad \annot{\accT}{\arrT*{(\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szltT \alpha}{\app{\AccT}{\beta}}})}{\app{\AccT}{\alpha}}} \\[\xspacing] 19 | &\dataT{\app{\NatT}{(\annot{\alpha}{\SizeT})}}{\TypeT{\tg{1}}} \\ 20 | &\quad \annot{\zeroT}{\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szltT \alpha}{\app{\NatT}{\alpha}}}} \\ 21 | &\quad \annot{\succT}{\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szltT \alpha}{\app{\NatT}{\beta}}{\app{\NatT}{\alpha}}}} \\[\xspacing] 22 | &\dataT{\app{\WT}{(\annot{A}{\TypeT{\iT}})}{(\annot{B}{\arrT*{A}{\TypeT{\iT}}})}{(\annot{\alpha}{\SizeT})}}{\TypeT{\tg{i+1}}} \\ 23 | &\quad \annot{\supT}{\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szltT \alpha}{\funtypeT{a}{A}{\arrT*{(\arrT*{\app{B}{a}}{\app{\WT}{A}{B}{\beta}})}{\app{\WT}{A}{B}{\alpha}}}}}} 24 | \end{align*} 25 | \caption{Inductive data definitions} 26 | \label{#1} 27 | \end{figure} 28 | } 29 | 30 | \newcommand{\FigDefns}[1]{ 31 | \begin{figure}[h] 32 | \centering 33 | \begin{align*} 34 | &\LetT{\funext}{\funtypeT{A}{\TypeT{\iT}}{\funtypeT{B}{\arrT*{A}{\TypeT{\iT}}}{\funtypeT{f, g}{(\funtypeT{x}{A}{\app{B}{x}})}{ \\ 35 | &\phantom{\app{\tg{let}}{\funext} \mathrel{:} \phantom{}} \arrT*{(\funtypeT{x}{A}{\eqT{\app{f}{x}}{}{\app{g}{x}}})}{\eqT{f}{}{g}}}}}}{\seq} \\ 36 | &\LetT{\baseleq}{\funtypeT{\alpha}{\SizeT}{\baseT \szleT \alpha}}{\seq} \\ 37 | &\LetT{\reflleq}{\funtypeT{\alpha}{\SizeT}{\alpha \szleT \alpha}}{\seq} \\ 38 | &\LetT{\transleq}{\funtypeT{\alpha, \beta, \gamma}{\SizeT}{\arrT*{\alpha \szleT \beta}{\beta \szleT \gamma}{\alpha \szleT \gamma}}} \\ 39 | &\LetT{\sucleq}{\funtypeT{\alpha}{\SizeT}{\alpha \szleT \app{\sucT}{\alpha}}} \\ 40 | &\LetT{\accIsProp}{\funtypeT{\alpha}{\SizeT}{\funtypeT{\mathit{acc}_1, \mathit{acc}_2}{\app{\AccT}{\alpha}}{\eqT{\mathit{acc}_1}{}{\mathit{acc}_2}}}}{\seq} \\ 41 | &\LetT{\accleq}{\funtypeT{\alpha, \beta}{\SizeT}{\arrT*{\beta \szleT \alpha}{\app{\AccT}{\alpha}}{\app{\AccT}{\beta}}}}{\seq} \\ 42 | &\LetT{\accessible}{\funtypeT{\alpha}{\SizeT}{\app{\AccT}{\alpha}}}{\seq} \\ 43 | \hfill \\ 44 | &\LetT{\wfacc}{\funtypeT{P}{(\arrT*{\SizeT}{\TypeT{\iT}})}{\arrT*{(\funtypeT{\alpha}{\SizeT}{\arrT*{(\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szleT \alpha}{\app{P}{\beta}}})}{\app{P}{\alpha}}})}{ \\ 45 | &\phantom{\app{\tg{let}}{\wfacc} \mathrel{:} \phantom{}} \funtypeT{\alpha}{\SizeT}{\arrT*{\app{\AccT}{\alpha}}{\app{P}{\alpha}}}}}}{\funT{P}{\any}{\funT{f}{\any}{\funT{\alpha}{\any}{\funT{\mathit{acc}}{\any}{ \\ 46 | & \quad \app{(\fixT{1}{\wfacc*}{\funtype{\alpha}{\SizeT}{\arrT*{\app{\AccT}{\alpha}}{\app{P}{\alpha}}}}{ \\ 47 | & \qquad \funT{\alpha}{\any}{\funT{\mathit{acc}}{\any}{\app{f}{\alpha}{(\funT{\beta}{\SizeT}{\funT{\beta^*}{\beta \szltT \alpha}{ \\ 48 | & \qquad \quad \app{\wfacc*}{\beta}{(\matchT*{\mathit{acc}}{(\app{\accT}{p} \Rightarrow \app{p}{\beta}{\beta^*})})}}})}}}})}{\alpha}{\mathit{acc}}}}}}} \\ 49 | &\LetT{\wfind}{\funtypeT{P}{(\arrT*{\SizeT}{\TypeT{\iT}})}{\arrT*{(\funtypeT{\alpha}{\SizeT}{\arrT*{(\funtypeT{\beta}{\SizeT}{\arrT*{\beta \szleT \alpha}{\app{P}{\beta}}})}{\app{P}{\alpha}}})}{ \\ 50 | &\phantom{\app{\tg{let}}{\wfind} \mathrel{:} \phantom{}} \funtypeT{\alpha}{\SizeT}{\app{P}{\alpha}}}}}{\fun{P}{\any}{\fun{f}{\any}{\fun{\alpha}{\any}{\app{\wfacc}{P}{f}{\alpha}{(\app{\accessible}{\alpha})}}}}} 51 | \end{align*} 52 | \caption{Definitions in \CICE} 53 | \label{#1} 54 | \end{figure} 55 | } -------------------------------------------------------------------------------- /figures/ind.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigSyntaxInd}[1]{ 2 | \begin{figure}[h] 3 | \centering 4 | \begin{align*} 5 | c &\Coloneqq \zero* \mid \succ* \mid \sup* &&&&& \\ 6 | %t &\Coloneqq e \mid \mathopen{[} s \mathclose{]} & 7 | %\Theta &\Coloneqq \mt \mid \Theta, \annot{x}{\tau} \mid \Theta, \alpha \mid \Theta, \bound{\alpha}{s} & \\ 8 | e &\Coloneqq \mathrlap{\cdots \mid \N{s} \mid \zero{s}{s} \mid \succ{s}{s}{e} \mid \W{x}{\tau}{\tau}{s} \mid \sup{x}{\tau}{\tau}{s}{s}{e}{e}} \\ 9 | &\mid \mathrlap{\match{e}{\fun*{x}{P}}{(\app{\App{c}{\alpha}}{\vec{z}} \Rightarrow e) \seq} \mid \fix{f}{\alpha}{\tau}{e}} 10 | \end{align*} 11 | \caption{Syntax (\lang inductives)} 12 | \label{#1} 13 | \end{figure} 14 | } 15 | 16 | \newcommand{\FigRedInd}[1]{ 17 | \begin{figure}[h] 18 | \centering 19 | \begin{mathpar} 20 | % This shrinks the space between the cdots and the first inference rule. 21 | % Don't ask me why it goes before the fbox instead of after. Don't touch it. 22 | \vspace{-0.5\baselineskip} 23 | \fbox{$\red{\Phi; \Gamma}{e}{e}$} \quad \cdots \hfill \\ 24 | \inferrule[]{~}{ 25 | \red[]{\Phi; \Gamma}{\match*{\App{\zero*_{\any}}{s}}{(\App{\zero*}{\alpha} \Rightarrow e_z) (\app{\App{\succ*}{\any}}{\any} \Rightarrow \any)}}{\subst{e_z}{\alpha}{s}} 26 | } 27 | \and 28 | \inferrule[]{~}{ 29 | \red[]{\Phi; \Gamma}{\match*{\app{\App{\succ*_{\any}}{s}}{e}}{(\App{\zero*}{\any} \Rightarrow \any) (\app{\App{\succ*}{\alpha}}{z} \Rightarrow e_s)}}{\subst{e_s}{\alpha, z}{s, e}} 30 | } 31 | \and 32 | \inferrule[]{~}{ 33 | \red[]{\Phi; \Gamma}{\match*{\app{\App{\sup*_{\any}}{s}}{e_1}{e_2}}{(\app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e)}}{\subst{e}{\alpha, z_1, z_2}{s, e_1, e_2}} 34 | } 35 | \and 36 | \inferrule[]{ 37 | \subsize{\Phi}{\sss{r}}{s} 38 | }{ 39 | \red[]{\Phi; \Gamma}{ 40 | \App{(\fix{f}{\alpha}{\sigma}{e})}{s} 41 | }{ 42 | \subst{e}{\alpha, f}{s, \Fun<{\beta}{s}{\App{(\fix{f}{\alpha}{\sigma}{e})}{\beta}}} 43 | } 44 | } 45 | \end{mathpar} 46 | \caption[Reduction rules ($\kw{case}$, fixpoints)]{Reduction rules ($\kw{case}$ and fixpoint expressions)} 47 | \label{#1} 48 | \end{figure} 49 | } 50 | 51 | \newcommand{\FigTypingInd}[1]{ 52 | \begin{figure}[h] 53 | \begin{mathpar} 54 | \fbox{$\type{\Phi; \Gamma}{e}{\tau}$} \quad \cdots \hfill \\ 55 | \inferrule[\rlabel*{nat}]{ 56 | \wf{\Phi}{\Gamma} \\ 57 | \wf{\Phi}{s} 58 | }{ 59 | \infer{\Phi; \Gamma}{\N{s}}{\Type{1}} 60 | } 61 | \and 62 | \inferrule[\rlabel*{zero}]{ 63 | \wf{\Phi}{\Gamma} \\ 64 | \subsize{\Phi}{\sss{r}}{s} 65 | }{ 66 | \infer{\Phi; \Gamma}{\zero{s}{r}}{\N{s}} 67 | } 68 | \and 69 | \inferrule[\rlabel*{succ}]{ 70 | \subsize{\Phi}{\sss{r}}{s} \\ 71 | \check{\Phi; \Gamma}{e}{\N{r}} 72 | }{ 73 | \infer{\Phi; \Gamma}{\succ{s}{r}{e}}{\N{s}} 74 | } 75 | \and 76 | \inferrule[\rlabel*{wft}]{ 77 | \wf{\Phi}{s} \\ 78 | \infer{\Phi; \Gamma}{\sigma}{U} \\\\ 79 | \infer{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{U} 80 | }{ 81 | \infer{\Phi; \Gamma}{\W{x}{\sigma}{\tau}{s}}{\axioms{U}} 82 | } 83 | \and 84 | \inferrule[\rlabel*{sup}]{ 85 | \subsize{\Phi}{\sss{r}}{s} \\ 86 | \infer{\Phi; \Gamma}{\sigma}{U} \\ 87 | \infer{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{U} \\\\ 88 | \check{\Phi; \Gamma}{e_1}{\sigma} \\ 89 | \check{\Phi; \Gamma}{e_2}{\arr*{\subst{\tau}{x}{e_1}}{\W{x}{\sigma}{\tau}{r}}} 90 | }{ 91 | \infer{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\W{x}{\sigma}{\tau}{s}} 92 | } 93 | \and 94 | \inferrule[\rlabel*{case-nat}]{ 95 | \infer{\Phi; \Gamma}{e}{\N{s}} \\ 96 | \infer{\Phi; \Gamma, \annot{x}{\N{s}}}{P}{U} \\\\ 97 | \check{\Phi, \bound{\alpha}{s}; \Gamma}{e_z}{\subst{P}{x}{\zero{s}{\alpha}}} \\ 98 | \check{\Phi, \bound{\beta}{s}; \Gamma, \annot{z}{\N{\beta}}}{e_s}{\subst{P}{x}{\succ{s}{\beta}{z}}} 99 | }{ 100 | \infer{\Phi; \Gamma}{\match{e}{\fun*{x}{P}}{(\App{\zero*}{\alpha} \Rightarrow e_z)(\app{\App{\succ*}{\beta}}{z} \Rightarrow e_s)}}{\subst{P}{x}{e}} 101 | } 102 | \and 103 | \inferrule[\rlabel*{case-wft}]{ 104 | \infer{\Phi; \Gamma}{e}{\W{y}{\sigma}{\tau}{s}} \\ 105 | \infer{\Phi; \Gamma, \annot{x}{\W{y}{\sigma}{\tau}{s}}}{P}{U} \\ 106 | \check{\Phi, \bound{\alpha}{s}; \Gamma, \annot{z_1}{\sigma}, \annot{z_2}{\arr*{\subst{\tau}{y}{z_1}}{\W{y}{\tau}{\sigma}{\alpha}}}}{e_s}{\subst{P}{x}{\sup{y}{\sigma}{\tau}{s}{\alpha}{z_1}{z_2}}} 107 | }{ 108 | \infer{\Phi; \Gamma}{\match{e}{\fun*{x}{P}}{(\app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s)}}{\subst{P}{x}{e}} 109 | } 110 | \and 111 | \inferrule[\rlabel*{fix}]{ 112 | \infer{\Phi, \alpha; \Gamma}{\sigma}{U} \\ 113 | \fresh{\beta} \\ 114 | \check{\Phi, \alpha; \Gamma, \annot{f}{\Funtype<{\beta}{\alpha}{\subst{\sigma}{\alpha}{\beta}}}}{e}{\sigma} 115 | }{ 116 | \infer{\Phi; \Gamma}{\fix{f}{\alpha}{\sigma}{e}}{\Funtype{\alpha}{\sigma}} 117 | } 118 | \end{mathpar} 119 | \caption{Typing rules (\lang inductives)} 120 | \label{#1} 121 | \end{figure} 122 | } -------------------------------------------------------------------------------- /figures/sized.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigSyntax}[1]{ 2 | \begin{figure}[h] 3 | \centering 4 | \begin{align*} 5 | i, j, k, m, n &\Coloneqq \meta{\textrm{naturals}} & 6 | \Gamma &\Coloneqq \mt \mid \Gamma, \annot{x}{\tau} \mid \Gamma, \define{x}{\tau}{e} & 7 | r, s &\Coloneqq \alpha \mid \sss{s} \mid \circ \\ 8 | f, g, x, y, z &\Coloneqq \meta{\textrm{term variables}} & 9 | \Delta &\Coloneqq \mt \mid \Delta, \annot{x}{\tau} & 10 | U &\Coloneqq \Prop \mid \Type{i+1} \\ 11 | \alpha, \beta, \gamma &\Coloneqq \meta{\textrm{size variables}} & 12 | \Phi &\Coloneqq \mt \mid \Phi, \alpha \mid \Phi, \bound{\alpha}{s} \\ 13 | e, P, \tau, \sigma &\Coloneqq \mathrlap{x \mid U \mid \funtype{x}{\tau}{\tau} \mid \fun{x}{\tau}{e} \mid \app{e}{e} \mid \letin{x}{\tau}{e}{e}} \\ 14 | &\mid \mathrlap{\Funtype{\alpha}{\tau} \mid \Funtype<{\alpha}{s}{\tau} \mid \Fun{\alpha}{e} \mid \Fun<{\alpha}{s}{e} \mid \App{e}{s}} 15 | %&\mid \Pairtype{\alpha}{\tau} \mid \Pair{s}{e} \mid \unpair{\alpha}{x}{e}{e} 16 | %&\mid \mathrlap{\eq{e}{\tau}{e} \mid \refl{e} \mid \J{P}{d}{p}} 17 | \end{align*} 18 | \caption{Syntax (base \lang)} 19 | \label{#1} 20 | \end{figure} 21 | } 22 | 23 | \newcommand{\FigRed}[1]{ 24 | \begin{figure}[h] 25 | \centering 26 | \begin{mathpar} 27 | \fbox{$\red{\Phi; \Gamma}{e}{e}$} \qquad 28 | \fbox{$\red*{\Phi; \Gamma}{e}{e}$} \hfill \\ 29 | \inferrule[]{ 30 | (\define{x}{\tau}{e}) \in \Gamma 31 | }{ 32 | \red{\Phi; \Gamma}{x}{e} 33 | } 34 | \and \inferrule[]{~}{\red{\Phi; \Gamma}{\app{(\fun{x}{\tau}{e})}{e'}}{\subst{e}{x}{e'}}} 35 | %\and \inferrule[]{~}{\red{\Phi; \Gamma}{\J{}{d}{\refl{}}}{d}} 36 | \and \inferrule[]{~}{\red{\Phi; \Gamma}{\App{(\Fun{\alpha}{e})}{s}}{\subst{e}{\alpha}{s}}} 37 | \and \inferrule[]{~}{\red{\Phi; \Gamma}{\App{(\Fun<{\alpha}{r}{e})}{s}}{\subst{e}{\alpha}{s}}} 38 | \and \inferrule[]{~}{\red{\Phi; \Gamma}{\letin{x}{\tau}{e'}{e}}{\subst{e}{x}{e'}}} 39 | %\and \inferrule[]{~}{\red{\Phi; \Gamma}{\unpair{\alpha}{x}{\Pair{s}{e'}}{e}}{\subst{e}{\alpha, x}{s, e'}}} 40 | \and \inferrule[\rlabel{$\rhd$-cong}{red-cong}]{ 41 | \red{\Phi'; \Gamma'}{e'}{e''} 42 | }{ 43 | \red{\Phi; \Gamma}{\subst{e}{x}{e'}}{\subst{e}{x}{e''}} 44 | } 45 | \\\\ 46 | \inferrule[\rlabel{$\rhd^*$-once}{red*-once}]{ 47 | \red{\Phi; \Gamma}{e_1}{e_2} 48 | }{ 49 | \red*{\Phi; \Gamma}{e_1}{e_2} 50 | } 51 | \and 52 | \inferrule[\rlabel{$\rhd^*$-refl}{red*-refl}]{~}{\red*{\Phi; \Gamma}{e}{e}} 53 | \and 54 | \inferrule[\rlabel{$\rhd^*$-trans}{red*-trans}]{ 55 | \red*{\Phi; \Gamma}{e_1}{e_2} \\ 56 | \red*{\Phi; \Gamma}{e_2}{e_3} 57 | }{ 58 | \red*{\Phi; \Gamma}{e_1}{e_3} 59 | } 60 | \end{mathpar} 61 | \caption{Reduction rules (base \lang)} 62 | \label{#1} 63 | \end{figure} 64 | } 65 | 66 | \newcommand{\FigSubtype}[1]{ 67 | \begin{figure}[h] 68 | \centering 69 | \begin{mathpar} 70 | \fbox{$\subtype{\Phi; \Gamma}{\tau}{\tau}$} \qquad 71 | \fbox{$\acum{e}{e}$} \hfill \\ 72 | \inferrule[\rlabel{$\preccurlyeq$-red}{subtype-red}]{ 73 | \red*{\Phi; \Gamma}{\tau_1}{\sigma_1} \\ 74 | \red*{\Phi; \Gamma}{\tau_2}{\sigma_2} \\ 75 | \acum{\sigma_1}{\sigma_2} 76 | }{ 77 | \subtype{\Phi; \Gamma}{\tau_1}{\tau_2} 78 | } 79 | \and 80 | \inferrule[\rlabel{$\sqsubseteq$-prop}{acum-prop}]{~}{\acum{\Prop{}}{\Type{i}}} 81 | \and 82 | \inferrule[\rlabel{$\sqsubseteq$-type}{acum-type}]{i \leq j}{\acum{\Type{i}}{\Type{j}}} 83 | \and 84 | \inferrule[\rlabel{$\sqsubseteq$-refl}{acum-refl}]{ 85 | }{ 86 | \acum{e}{e} 87 | } 88 | \and 89 | \inferrule[\rlabel{$\sqsubseteq$-pi}{acum-pi}]{ 90 | \acum{\tau_1}{\tau_2} 91 | }{ 92 | \acum{\funtype{x}{\sigma}{\tau_1}}{\funtype{x}{\sigma}{\tau_2}} 93 | } 94 | \and 95 | \inferrule[\rlabel{$\sqsubseteq$-forall}{acum-forall}]{ 96 | \acum{\tau_1}{\tau_2} 97 | }{ 98 | \acum{\Funtype{\alpha}{\tau_1}}{\Funtype{\alpha}{\tau_2}} 99 | } 100 | \and 101 | \inferrule[\rlabel{$\sqsubseteq$-forall$<$}{acum-forall<}]{ 102 | \acum{\tau_1}{\tau_2} 103 | }{ 104 | \acum{\Funtype<{\alpha}{s}{\tau_1}}{\Funtype<{\alpha}{s}{\tau_2}} 105 | } 106 | \end{mathpar} 107 | \caption{Subtyping and $\alpha$-cumulativity rules} 108 | \label{#1} 109 | \end{figure} 110 | } 111 | 112 | \newcommand{\FigSubsize}[1]{ 113 | \begin{figure}[h] 114 | \centering 115 | \begin{mathpar} 116 | \fbox{$\wf{\Phi}{s}$} \qquad 117 | \fbox{$\subsize{\Phi}{s}{s}$} \hfill \\ 118 | \inferrule[]{ 119 | \wf{}{\Phi} \\ 120 | \alpha \in \Phi 121 | \textit{ or } 122 | (\bound{\alpha}{s}) \in \Phi 123 | }{ 124 | \wf{\Phi}{\alpha} 125 | } 126 | \and 127 | \inferrule[]{\wf{}{\Phi}}{\wf{\Phi}{\circ}} 128 | \and 129 | \inferrule[]{ 130 | \wf{\Phi}{s} 131 | }{ 132 | \wf{\Phi}{\sss{s}} 133 | } 134 | \and 135 | \inferrule[]{ 136 | \wf{}{\Phi} \\ 137 | (\bound{\alpha}{s}) \in \Phi 138 | }{ 139 | \subsize{\Phi}{\sss{\alpha}}{s} 140 | } 141 | \\ 142 | \inferrule[]{ 143 | \wf{\Phi}{s} 144 | }{ 145 | \subsize{\Phi}{\circ}{s} 146 | } 147 | \and 148 | \inferrule[]{ 149 | \wf{\Phi}{s} 150 | }{ 151 | \subsize{\Phi}{s}{s} 152 | } 153 | \and 154 | \inferrule[]{ 155 | \wf{\Phi}{s} 156 | }{ 157 | \subsize{\Phi}{s}{\sss{s}} 158 | } 159 | \and 160 | \inferrule[]{ 161 | \subsize{\Phi}{r}{s} 162 | }{ 163 | \subsize{\Phi}{\sss{r}}{\sss{s}} 164 | } 165 | \and 166 | \inferrule[]{ 167 | \subsize{\Phi}{s_1}{s_2} \\\\ 168 | \subsize{\Phi}{s_2}{s_3} 169 | }{ 170 | \subsize{\Phi}{s_1}{s_3} 171 | } 172 | % \and \inferrule[]{~}{\subsize{\Gamma}{s}{\infty}} 173 | \end{mathpar} 174 | \caption{Size and subsizing rules} 175 | \label{#1} 176 | \end{figure} 177 | } 178 | 179 | \newcommand{\FigWF}[1]{ 180 | \begin{figure}[h] 181 | \centering 182 | \begin{mathpar} 183 | \fbox{$\wf{}{\Phi}$} \qquad 184 | \fbox{$\wf{\Phi}{\Gamma}$} \hfill \\ 185 | \inferrule[\rlabel{nil}{nil}]{~}{\wf{}{\mt}} 186 | \and 187 | \inferrule[\rlabel{cons-size}{cons-size}]{ 188 | \wf{}{\Phi} 189 | }{ 190 | \wf{}{\Phi, \alpha} 191 | } 192 | \and 193 | \inferrule[\rlabel{cons-size$<$}{cons-size<}]{ 194 | \wf{}{\Phi} \\\\ 195 | \wf{\Phi}{s} 196 | }{ 197 | \wf{}{\Phi, \bound{\alpha}{s}} 198 | } 199 | \and 200 | \inferrule[nil]{\wf{}{\Phi}}{\wf{\Phi}{\mt}} 201 | \and 202 | \inferrule[\rlabel{cons-ass}{cons-ass}]{ 203 | \wf{\Phi}{\Gamma} \\\\ 204 | \infer{\Phi; \Gamma}{\tau}{U} 205 | }{ 206 | \wf{\Phi}{\Gamma, \annot{x}{\tau}} 207 | } 208 | \and 209 | \inferrule[\rlabel{cons-def}{cons-def}]{ 210 | \wf{\Phi}{\Gamma} \\\\ 211 | \infer{\Phi; \Gamma}{e}{\tau} 212 | }{ 213 | \wf{\Phi}{\Gamma, \define{x}{\tau}{e}} 214 | } 215 | \end{mathpar} 216 | \caption{Well-formedness rules} 217 | \label{#1} 218 | \end{figure} 219 | } 220 | 221 | \newcommand{\FigRulesAxioms}[1]{ 222 | \begin{figure}[h] 223 | \centering 224 | \begin{align*} 225 | \axioms{\Prop} &= \Type{1} & 226 | \rules{U}{\Prop} &= \Prop \\ 227 | \axioms{\Type{i}} &= \Type{i+1} & 228 | \rules{\Prop}{U} &= U \\ 229 | && \rules{\Type{i}}{\Type{j}} &= \Type{\maximum{i, j}} 230 | \end{align*} 231 | \caption{Metafunctions: $\axioms*$ and $\rules*$} 232 | \label{#1} 233 | \end{figure} 234 | } 235 | 236 | \newcommand{\FigTyping}[2][p]{ 237 | \begin{figure}[#1] 238 | \centering 239 | \begin{mathpar} 240 | \fbox{$\type{\Phi; \Gamma}{e}{\tau}$} \hfill \\ 241 | \inferrule[\rlabel*{conv}]{ 242 | \infer{\Phi; \Gamma}{e}{\sigma} \\ 243 | \check{\Phi; \Gamma}{\sigma}{U} \\\\ 244 | \infer{\Phi; \Gamma}{\tau}{U} \\ 245 | \subtype{\Phi; \Gamma}{\sigma}{\tau} 246 | }{ 247 | \check{\Phi; \Gamma}{e}{\tau} 248 | } 249 | \and 250 | \inferrule[\rlabel*{var}]{ 251 | \wf{\Phi}{\Gamma} \\ 252 | (\annot{x}{\tau}) \in \Gamma \\\\ 253 | \textit{or } (\define{x}{\tau}{e}) \in \Gamma 254 | }{ 255 | \infer{\Phi; \Gamma}{x}{\tau} 256 | } 257 | \and 258 | \inferrule[\rlabel*{univ}]{ 259 | \wf{\Phi}{\Gamma} \\ 260 | }{ 261 | \infer{\Phi; \Gamma}{U}{\axioms{U}} 262 | } 263 | \and 264 | \inferrule[\rlabel*{pi}]{ 265 | \infer{\Phi; \Gamma}{\sigma}{U_1} \\ 266 | \infer{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{U_2} 267 | }{ 268 | \infer{\Gamma}{\funtype{x}{\sigma}{\tau}}{\rules{U_1}{U_2}} 269 | } 270 | \and 271 | \inferrule[\rlabel*{lam}]{ 272 | \infer{\Phi; \Gamma}{\sigma}{U} \\ 273 | \infer{\Phi; \Gamma, \annot{x}{\sigma}}{e}{\tau} 274 | }{ 275 | \infer{\Phi; \Gamma}{\fun{x}{\sigma}{e}}{\funtype{x}{\sigma}{\tau}} 276 | } 277 | \and 278 | \inferrule[\rlabel*{app}]{ 279 | \infer{\Phi; \Gamma}{e_1}{\funtype{x}{\sigma}{\tau}} \\ 280 | \check{\Phi; \Gamma}{e_2}{\sigma} 281 | }{ 282 | \infer{\Phi; \Gamma}{\app{e_1}{e_2}}{\subst{\tau}{x}{e_2}} 283 | } 284 | \and 285 | \inferrule[\rlabel*{let}]{ 286 | \infer{\Phi; \Gamma}{\sigma}{U} \\ 287 | \check{\Phi; \Gamma}{e_1}{\sigma} \\\\ 288 | \infer{\Phi; \Gamma, \define{x}{\sigma}{e_1}}{e_2}{\tau} 289 | }{ 290 | \infer{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\subst{\tau}{x}{e_1}} 291 | } 292 | \and 293 | \inferrule[\rlabel*{forall}]{ 294 | \infer{\Phi, \alpha; \Gamma}{\tau}{U} 295 | }{ 296 | \infer{\Phi; \Gamma}{\Funtype{\alpha}{\tau}}{U} 297 | } 298 | \and 299 | \inferrule[\rlabel*{slam}]{ 300 | \infer{\Phi,\alpha; \Gamma}{e}{\tau} 301 | }{ 302 | \infer{\Phi; \Gamma}{\Fun{\alpha}{e}}{\Funtype{\alpha}{\tau}} 303 | } 304 | \and 305 | \inferrule[\rlabel*{sapp}]{ 306 | \infer{\Phi; \Gamma}{e}{\Funtype{\alpha}{\tau}} \\ 307 | \wf{\Phi}{s} 308 | }{ 309 | \infer{\Phi; \Gamma}{\App{e}{s}}{\subst{\tau}{\alpha}{s}} 310 | } 311 | \and 312 | \inferrule[\rlabel{forall$<$}{forall<}]{ 313 | \wf{\Phi}{s} \\ 314 | \infer{\Phi, \bound{\alpha}{s}; \Gamma}{\tau}{U} 315 | }{ 316 | \infer{\Phi; \Gamma}{\Funtype<{\alpha}{s}{\tau}}{U} 317 | } 318 | \and 319 | \inferrule[\rlabel{slam$<$}{slam<}]{ 320 | \wf{\Phi}{s} \\ 321 | \infer{\Phi, \bound{\alpha}{s}; \Gamma}{e}{\tau} 322 | }{ 323 | \infer{\Phi; \Gamma}{\Fun<{\alpha}{s}{e}}{\Funtype<{\alpha}{s}{\tau}} 324 | } 325 | \and 326 | \inferrule[\rlabel{sapp$<$}{sapp<}]{ 327 | \infer{\Phi; \Gamma}{e}{\Funtype<{\alpha}{r}{\tau}} \\ 328 | \subsize{\Phi}{\sss{s}}{r} 329 | }{ 330 | \infer{\Phi; \Gamma}{\App{e}{s}}{\subst{\tau}{\alpha}{s}} 331 | } 332 | \iffalse 333 | \and 334 | \inferrule[\rlabel*{exists}]{ 335 | \infer{\Phi, \alpha; \Gamma}{\tau}{U} 336 | }{ 337 | \infer{\Phi; \Gamma}{\Pairtype{\alpha}{\tau}}{U} 338 | } 339 | \and 340 | \inferrule[\rlabel*{pair}]{ 341 | \wf{\Phi}{s} \\ 342 | \check{\Phi; \Gamma}{e}{\subst{\tau}{\alpha}{s}} 343 | }{ 344 | \infer{\Phi; \Gamma}{\Pair{s}{e}_{\Pairtype{\alpha}{\tau}}}{\Pairtype{\alpha}{\tau}} 345 | } 346 | \and 347 | \inferrule[\rlabel*{unpair}]{ 348 | \infer{\Phi; \Gamma}{e_1}{\Pairtype{\alpha}{\sigma}} \\ 349 | \infer{\Phi, \alpha; \Gamma, \annot{x}{\sigma}}{e_2}{\tau} 350 | }{ 351 | \infer{\Phi; \Gamma}{\unpair{\alpha}{x}{e_1}{e_2}}{\tau} 352 | } 353 | \and 354 | \inferrule[\rlabel*{eq}]{ 355 | \infer{\Phi; \Gamma}{\tau}{U} \\ 356 | \check{\Phi; \Gamma}{e_1}{\tau} \\ 357 | \check{\Phi; \Gamma}{e_2}{\tau} 358 | }{ 359 | \infer{\Phi; \Gamma}{\eq{e_1}{\tau}{e_2}}{U} 360 | } 361 | \and 362 | \inferrule[\rlabel*{refl}]{ 363 | \infer{\Phi; \Gamma}{e}{\tau} 364 | }{ 365 | \infer{\Phi; \Gamma}{\refl{e}}{\eq{e}{\tau}{e}} 366 | } 367 | \and 368 | \inferrule[\rlabel*{J}]{ 369 | \infer{\Phi; \Gamma}{p}{\eq{e_1}{\tau}{e_2}} \\ 370 | \fresh{y, z} \\\\ 371 | \infer{\Phi; \Gamma, \annot{y}{\tau}, \annot{z}{\eq{e_1}{\tau}{y}}}{\app{\app{P}{y}}{z}}{U} \\ 372 | \check{\Phi; \Gamma}{d}{\app{\app{P}{e_1}}{\refl{e_1}}} \\ 373 | }{ 374 | \infer{\Phi; \Gamma}{\J{P}{d}{p}}{\app{\app{P}{e_2}}{p}} 375 | } 376 | \fi 377 | \end{mathpar} 378 | \caption{Typing rules} 379 | \label{#2} 380 | \end{figure} 381 | } -------------------------------------------------------------------------------- /figures/takahashi.tex: -------------------------------------------------------------------------------- 1 | \iffalse 2 | \newcommand{\FigTakahashi}[1]{ 3 | \begin{figure}[h] 4 | \centering 5 | \begin{align*} 6 | x^\bullet_{\Phi; \Gamma} &= e^\bullet_{\Phi; \Gamma} \qquad \textit{if $(\define{x}{\tau}{e}) \in \Gamma$} \\ 7 | (\app{(\fun{x}{\tau}{e})}{e'})^\bullet_{\Phi; \Gamma} &= \subst{e^\bullet_{\Phi; \Gamma}}{x}{e'^\bullet_{\Phi; \Gamma}} \\ 8 | (\App{(\Fun{\alpha}{e})}{s})^\bullet_{\Phi; \Gamma} &= \subst{e^\bullet_{\Phi, \alpha; \Gamma}}{\alpha}{s} \\ 9 | (\App{(\Fun<{\alpha}{r}{e})}{s})^\bullet_{\Phi; \Gamma} &= \subst{e^\bullet_{\Phi, \bound{\alpha}{r}; \Gamma}}{\alpha}{s} \\ 10 | (\letin{x}{\tau}{e'}{e})^\bullet_{\Phi; \Gamma} &= \subst{e^\bullet_{\Phi; \Gamma}}{x}{e'^\bullet_{\Phi; \Gamma}} \\ 11 | (\match*{\App{\zero*_{\any}}{s}}{(\App{\zero*}{\alpha} \Rightarrow e)\any})^\bullet_{\Phi; \Gamma} 12 | &= \subst{e^\bullet_{\Phi; \Gamma}}{\alpha}{s} \\ 13 | (\match*{\app{\App{\succ*_{\any}}{s}}{e'}}{\any(\app{\App{\succ*}{\alpha}}{z} \Rightarrow e)})^\bullet_{\Phi; \Gamma} 14 | &= \subst{e^\bullet_{\Phi; \Gamma}}{\alpha, z}{s, e'^\bullet_{\Phi; \Gamma}} \\ 15 | (\match*{\app{\App{\sup*_{\any}}{s}}{e_1}{e_2}}{(\app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e)})^\bullet_{\Phi; \Gamma} 16 | &= \subst{e^\bullet_{\Phi; \Gamma}}{\alpha, z_1, z_2}{s, {e_1}^\bullet_{\Phi; \Gamma}, {e_2}^\bullet_{\Phi; \Gamma}} \\ 17 | (\App{(\fix{f}{\alpha}{\tau}{e})}{s})^\bullet_{\Phi; \Gamma} 18 | &= \subst{e^\bullet_{\Phi, \alpha; \Gamma}}{\alpha, f}{s, \Fun<{\beta}{s}{\App{(\fix{f}{\alpha}{\tau^\bullet_{\Phi, \alpha; \Gamma}}{e^\bullet_{\Phi, \alpha; \Gamma}})}{\beta}}} \\ 19 | &\mathrel{\phantom{=}} \textit{if $\subsize{\Phi}{\sss{r}}{s}$} \\ 20 | (\funtype{x}{\sigma}{\tau})^\bullet_{\Phi; \Gamma} &= \funtype{x}{\sigma^\bullet_{\Phi; \Gamma}}{\tau^\bullet_{\Phi; \Gamma}} \\ 21 | (\fun{x}{\sigma}{e})^\bullet_{\Phi; \Gamma} &= \fun{x}{\sigma^\bullet_{\Phi; \Gamma}}{e^\bullet_{\Phi; \Gamma}} \\ 22 | (\app{e}{e_2})^\bullet_{\Phi; \Gamma} &= \app{{e_1}^\bullet_{\Phi; \Gamma}}{{e_2}^\bullet_{\Phi; \Gamma}} \\ 23 | (\Funtype{\alpha}{\tau})^\bullet_{\Phi; \Gamma} &= \Funtype{\alpha}{\tau^\bullet_{\Phi, \alpha; \Gamma}} \\ 24 | (\Funtype<{\alpha}{s}{\tau})^\bullet_{\Phi; \Gamma} &= \Funtype<{\alpha}{s}{\tau^\bullet_{\Phi, \bound{\alpha}{s}; \Gamma}} \\ 25 | (\Fun{\alpha}{e})^\bullet_{\Phi; \Gamma} &= \Fun{\alpha}{e^\bullet_{\Phi, \alpha; \Gamma}} \\ 26 | (\Fun<{\alpha}{s}{e})^\bullet_{\Phi; \Gamma} &= \Fun<{\alpha}{s}{e^\bullet_{\Phi, \bound{\alpha}{s}; \Gamma}} \\ 27 | (\App{e}{s})^\bullet_{\Phi; \Gamma} &= \App{e^\bullet_{\Phi; \Gamma}}{s} \\ 28 | (\succ{s}{r}{e})^\bullet_{\Phi; \Gamma} &= \succ{s}{r}{e^\bullet_{\Phi; \Gamma}} \\ 29 | (\W{x}{\sigma}{\tau}{s})^\bullet_{\Phi; \Gamma} &= \W{x}{\sigma^\bullet_{\Phi; \Gamma}}{\tau^\bullet_{\Phi; \Gamma}}{s} \\ 30 | (\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2})^\bullet_{\Phi; \Gamma} &= \sup{x}{\sigma^\bullet_{\Phi; \Gamma}}{\tau^\bullet_{\Phi; \Gamma}}{s}{r}{{e_1}^\bullet_{\Phi; \Gamma}}{{e_2}^\bullet_{\Phi; \Gamma}} \\ 31 | (\match{e'}{\fun{x}{P}}{(\app{\App{c}{\alpha}}{\vec{z}} \Rightarrow e) \seq})^\bullet_{\Phi; \Gamma} 32 | &= \match{e'^\bullet_{\Phi; \Gamma}}{\fun{x}{P^\bullet_{\Phi; \Gamma}}}{(\app{\App{c}{\alpha}}{\vec{z}} \Rightarrow e^\bullet_{\Phi; \Gamma}) \seq} \\ 33 | (\fix{f}{\alpha}{\tau}{e})^\bullet_{\Phi; \Gamma} &= \fix{f}{\alpha}{\tau^\bullet_{\Phi, \alpha; \Gamma}}{e^\bullet_{\Phi, \alpha; \Gamma}} \\ 34 | e^\bullet_{\Phi; \Gamma} &= e 35 | \end{align*} 36 | \caption[Complete development for \lang]{Extension of Takahashi's complete development for \lang} 37 | \label{#1} 38 | \end{figure} 39 | } 40 | \fi 41 | 42 | \newcommand{\FigTakahashi}[1]{ 43 | \begin{figure}[h] 44 | \centering 45 | \begin{mathpar} 46 | \fbox{$\develop{\Phi; \Gamma}{e}{e}$} \hfill \\ 47 | \inferrule[]{ 48 | (\define{x}{\tau}{e}) \in \Gamma \\ 49 | \develop{\Phi; \Gamma}{e}{e'} 50 | }{ 51 | \develop{\Phi; \Gamma}{x}{e'} 52 | } 53 | \and 54 | \inferrule[]{ 55 | \develop{\Phi; \Gamma, \annot{x}{\tau}}{e_1}{e'_1} \\ 56 | \develop{\Phi; \Gamma}{e_2}{e'_2} 57 | }{ 58 | \develop{\Phi; \Gamma}{\app{(\fun{x}{\tau}{e_1})}{e_2}}{\subst{e'_1}{x}{e'_2}} 59 | } 60 | \and 61 | \inferrule[]{ 62 | \develop{\Phi, \alpha; \Gamma}{e}{e'} 63 | }{ 64 | \develop{\Phi; \Gamma}{\App{(\Fun{\alpha}{e})}{s}}{\subst{e'}{\alpha}{s}} 65 | } 66 | \and 67 | \inferrule[]{ 68 | \develop{\Phi, \bound{\alpha}{r}; \Gamma}{e}{e'} 69 | }{ 70 | \develop{\Phi; \Gamma}{\App{\Fun<{\alpha}{r}{e}}{s}}{\subst{e'}{\alpha}{s}} 71 | } 72 | \and 73 | \inferrule[]{ 74 | \develop{\Phi; \Gamma}{e_1}{e'_1} \\ 75 | \develop{\Phi; \Gamma, \define{x}{\tau}{e_1}}{e_2}{e'_2} 76 | }{ 77 | \develop{\Phi; \Gamma}{\letin{x}{\tau}{e_1}{e_2}}{\subst{e'_2}{x}{e'_1}} 78 | } 79 | \and 80 | \inferrule[]{ 81 | \develop{\Phi, \bound{\alpha}{r}; \Gamma}{e_z}{e_z'} 82 | }{ 83 | \develop{\Phi; \Gamma}{ 84 | \match*{\zero{r}{s}}{(\App{\zero*}{\alpha} \Rightarrow e_z) \any} 85 | }{\subst{e'_z}{\alpha}{s}} 86 | } 87 | \and 88 | \inferrule[]{ 89 | \develop{\Phi; \Gamma}{e}{e'} \\ 90 | \develop{\Phi, \bound{\alpha}{r}; \Gamma, \annot{z}{\N{\alpha}}}{e_s}{e'_s} 91 | }{ 92 | \develop{\Phi; \Gamma}{ 93 | \match*{\succ{r}{s}{e}}{\any (\app{\App{\succ*}{\alpha}}{z} \Rightarrow e_s)} 94 | }{\subst{e'_s}{\alpha, z}{s, e'}} 95 | } 96 | \and 97 | \inferrule[]{ 98 | \develop{\Phi; \Gamma}{e_1}{e'_1} \\ 99 | \develop{\Phi; \Gamma}{e_2}{e'_2} \\ 100 | \develop{\Phi, \bound{\alpha}{r}; \Gamma, \annot{z_1}{\sigma}, \annot{z_2}{\subst{\tau}{x}{z_1}}}{e}{e'} 101 | }{ 102 | \develop{\Phi; \Gamma}{ 103 | \match*{\sup{x}{\sigma}{\tau}{r}{s}{e_1}{e_2}}{(\app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e)} 104 | }{\subst{e'}{\alpha, z_1, z_2}{s, e'_1, e'_2}} 105 | } 106 | \and 107 | \inferrule[]{ 108 | \subsize{\Phi}{\sss{r}}{s} \\ 109 | \develop{\Phi, \alpha; \Gamma}{\tau}{\tau'} \\ 110 | \develop{\Phi, \alpha; \Gamma, \annot{f}{\Funtype<{\beta}{\alpha}{\subst{\tau}{\alpha}{\beta}}}}{e}{e'} 111 | }{ 112 | \develop{\Phi; \Gamma}{\App{\fix{f}{\alpha}{\tau}{e}}{s}}{\subst{e'}{\alpha, f}{s, \Fun<{\beta}{s}{\App{(\fix{f}{\alpha}{\tau'}{e'})}{\beta}}}} 113 | } 114 | \end{mathpar} 115 | \caption[Complete development for \lang]{Extension of Takahashi's complete development for \lang \\ (excerpt excl. congruence)} 116 | \label{#1} 117 | \end{figure} 118 | } -------------------------------------------------------------------------------- /figures/translation.tex: -------------------------------------------------------------------------------- 1 | \newcommand{\FigTransSize}[1]{ 2 | \begin{figure}[h] 3 | \centering 4 | \vspace{-\baselineskip} 5 | \begin{multicols}{2} 6 | \begin{align*} 7 | \Aboxed{\compile{s} &= \eT} \\ 8 | \compile{\alpha} &= \alphaT \\ 9 | \compile{\circ} &= \baseT \\ 10 | \compile{\sss{s}} &= \app{\sucT}{\compile{s}} 11 | \end{align*} 12 | 13 | \begin{align*} 14 | \Aboxed{\compile{\Phi} &= \GammaT} \\ 15 | \compile{\mt} &= \mt \\ 16 | \compile{\Phi, \alpha} &= \compile{\Phi}, \annot{\alphaT}{\SizeT} \\ 17 | \compile{\Phi, \bound{\alpha}{s}} &= \compile{\Phi}, \annot{\alphaT}{\SizeT}, \annot{\alphaT^*}{\alphaT \szltT \compile{s}} 18 | \end{align*} 19 | \end{multicols} 20 | \caption{Translation of sizes and size environments} 21 | \label{#1} 22 | \end{figure} 23 | } 24 | 25 | \newcommand{\FigTransSubsize}[1]{ 26 | \begin{figure}[h] 27 | \centering 28 | \begin{mathpar} 29 | \fbox{$\subsizeto{\Phi}{s}{s}{\eT}$} \hfill \\ 30 | \inferrule{ 31 | (\bound{\alpha}{s}) \in \Phi 32 | }{ 33 | \subsizeto{\Phi}{\sss{\alpha}}{s}{\alphaT^*} 34 | } 35 | \and 36 | \inferrule{\wf{\Phi}{s}}{ 37 | \subsizeto{\Phi}{\circ}{s}{\app{\baseleq}{\compile{s}}} 38 | } 39 | \and 40 | \inferrule{\wf{\Phi}{s}}{ 41 | \subsizeto{\Phi}{s}{s}{\app{\reflleq}{\compile{s}}} 42 | } 43 | \and 44 | \inferrule{\wf{\Phi}{s}}{ 45 | \subsizeto{\Phi}{s}{\sss{s}}{\app{\sucleq}{\compile{s}}} 46 | } 47 | \and 48 | \inferrule{ 49 | \subsizeto{\Phi}{r}{s}{\eT} 50 | }{ 51 | \subsizeto{\Phi}{\sss{r}}{\sss{s}}{\app{\monoT}{\compile{r}}{\compile{s}}{\eT}} 52 | } 53 | \and 54 | \inferrule{ 55 | \subsizeto{\Phi}{s_1}{s_2}{\eT_{12}} \\ 56 | \subsizeto{\Phi}{s_2}{s_3}{\eT_{23}} 57 | }{ 58 | \subsizeto{\Phi}{s_1}{s_3}{\app{\transleq}{\compile{s_1}}{\compile{s_2}}{\compile{s_3}}{\eT_{12}}{\eT_{23}}} 59 | } 60 | \end{mathpar} 61 | \caption[Translation of subsizing]{Translation of subsizing derivations} 62 | \label{#1} 63 | \end{figure} 64 | } 65 | 66 | \newcommand{\FigTransTerm}[1]{ 67 | \begin{figure}[ht] 68 | \centering 69 | \vspace{-\baselineskip} 70 | \begin{multicols}{2} 71 | \begin{align*} 72 | \Aboxed{\compile{e} &= \eT} \\ 73 | \compile{x} &= \xT \\ 74 | \compile{U} &= \UT \\ 75 | \compile{\funtype{x}{\sigma}{\tau}} &= \funtypeT{\xT}{\compile{\sigma}}{\compile{\tau}_{\annot{x}{\sigma}}} \\ 76 | \compile{\fun{x}{\sigma}{e}} &= \funT{\xT}{\compile{\sigma}}{\compile{e}_{\annot{x}{\sigma}}} \\ 77 | \compile{\app{e_1}{e_2}} &= \app{\compile{e_1}}{\compile{e_2}} \\ 78 | \compile{\Funtype{\alpha}{\tau}} &= \funtypeT{\alphaT}{\SizeT}{\compile{\tau}_{\alpha}} \\ 79 | \compile{\Funtype<{\alpha}{s}{\tau}} &= \funtypeT{\alphaT}{\SizeT}{\funtypeT{\alphaT^*}{\alphaT \szltT \compile{s}}{\compile{\tau}_{\bound{\alpha}{s}}}} \\ 80 | \compile{\Fun{\alpha}{e}} &= \funT{\alphaT}{\SizeT}{\compile{e}_{\alpha}} \\ 81 | \compile{\Fun<{\alpha}{s}{e}} &= \funT{\alphaT}{\SizeT}{\funT{\alphaT^*}{\alphaT \szltT \compile{s}}{\compile{e}_{\bound{\alpha}{s}}}} \\ 82 | \compile{\App{e}{s}} &= \app{\compile{e}}{\compile{s}} \qquad (\textrm{\rref{sapp}}) \\ 83 | \end{align*} 84 | 85 | \begin{align*} 86 | % \wfto{\Phi}{\Gamma &}{\GammaT} % why won't this work? 87 | \Aboxed{\wf{\Phi}{\Gamma} &\rightsquigarrow \GammaT} \\ 88 | \wfto{\Phi}{\mt &}{\compile{\Phi}} \\ 89 | \hfill \\ 90 | \Aboxed{\compile{\Gamma} &= \GammaT} \\ 91 | &\cdots \\ 92 | \compile{\Gamma, \annot{x}{\tau}} &= \compile{\Gamma}, \annotT{\xT}{\compile{\tau}} \\ 93 | \compile{\Gamma, \define{x}{\tau}{e}} &= \compile{\Gamma}, \defineT{\xT}{\compile{\tau}}{\compile{e}} 94 | \end{align*} 95 | \end{multicols} 96 | \vspace{-2\baselineskip} 97 | \begin{mathpar} 98 | \fbox{$\typeto{\Phi; \Gamma}{e}{\tau}{\eT}$} \quad \cdots \hfill \\ 99 | \inferrule[\nameref{conv}]{ 100 | \cdots \\ 101 | \typeto{\Phi; \Gamma}{e}{\sigma}{\eT} \\ 102 | \subtype{\Phi; \Gamma}{\sigma}{\tau} 103 | }{ 104 | \typeto{\Phi; \Gamma}{e}{\tau}{\eT} 105 | } 106 | \and 107 | \inferrule[\nameref{sapp<}]{ 108 | \subsizeto{\Phi}{\sss{s}}{r}{\eT'} \\ 109 | \typeto{\Phi; \Gamma}{e}{\Funtype<{\alpha}{r}{\tau}}{\eT} 110 | }{ 111 | \typeto{\Phi; \Gamma}{\App{e}{s}}{\subst{\tau}{\alpha}{s}}{\app{\eT}{\compile{s}}{\eT'}} 112 | } 113 | \and 114 | \inferrule[\nameref{let}]{ 115 | \typeto{\Phi; \Gamma}{\sigma}{\UT}{\sigmaT} \\ 116 | \typeto{\Phi; \Gamma}{e_1}{\sigma}{\eT_1} \\ 117 | \typeto{\Phi; \Gamma, \define{x}{\sigma}{e_1}}{e_2}{\tau}{\eT_2} 118 | }{ 119 | \typeto{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\subst{\tau}{x}{e_1}}{\letinT{\xT}{\sigmaT}{\eT_1}{\eT_2}} 120 | } 121 | \end{mathpar} 122 | \caption{Translation of terms (base \lang) and term environments} 123 | \label{#1} 124 | \end{figure} 125 | } 126 | 127 | \newcommand{\FigTransTermSquash}[1]{ 128 | \begin{figure}[ht] 129 | \centering 130 | \begin{multicols}{2} 131 | \begin{align*} 132 | \Aboxed{\wf{\Phi}{\Gamma} &\rightsquigarrow \GammaT} \\ 133 | \wfto{\Phi}{\mt &}{\compile{\Phi}} \\ 134 | \Aboxed{\compile{\Gamma} &= \GammaT} \\ 135 | &\cdots \\ 136 | \compile{\Gamma, \annot{x}{\tau}} &= \compile{\Gamma}, \annotT{\xT}{\compile{\tau}} \\ 137 | \compile{\Gamma, \define{x}{\tau}{e}} &= \compile{\Gamma}, \defineT{\xT}{\compile{\tau}}{\compile{e}} \\ 138 | \Aboxed{\compile{e} &= \eT} \\ 139 | \compile{x} &= \xT \\ 140 | \compile{U} &= \UT \\ 141 | \end{align*} 142 | 143 | \begin{align*} 144 | \hfill \\ 145 | \mathclap{\mathit{(continued)}} \\ 146 | \compile{\App{e}{s}} &= \app{\compile{e}}{\compile{s}} \qquad (\textrm{\rref{sapp}}) \\ 147 | \compile{\funtype{x}{\sigma}{\tau}} &= \funtypeT{\xT}{\compile{\sigma}}{\compile{\tau}_{\annot{x}{\sigma}}} \\ 148 | \compile{\fun{x}{\sigma}{e}} &= \funT{\xT}{\compile{\sigma}}{\compile{e}_{\annot{x}{\sigma}}} \\ 149 | \compile{\app{e_1}{e_2}} &= \app{\compile{e_1}}{\compile{e_2}} \\ 150 | \compile{\Funtype{\alpha}{\tau}} &= \funtypeT{\alphaT}{\SizeT}{\compile{\tau}_{\alpha}} \\ 151 | \compile{\Funtype<{\alpha}{s}{\tau}} &= \funtypeT{\alphaT}{\SizeT}{\funtypeT{\alphaT^*}{\alphaT \szltT \compile{s}}{\compile{\tau}_{\bound{\alpha}{s}}}} \\ 152 | \compile{\Fun{\alpha}{e}} &= \funT{\alphaT}{\SizeT}{\compile{e}_{\alpha}} \\ 153 | \compile{\Fun<{\alpha}{s}{e}} &= \funT{\alphaT}{\SizeT}{\funT{\alphaT^*}{\alphaT \szltT \compile{s}}{\compile{e}_{\bound{\alpha}{s}}}} \\ 154 | \hfill 155 | \end{align*} 156 | \end{multicols} 157 | \vspace{-2\baselineskip} 158 | \begin{mathpar} 159 | \fbox{$\typeto{\Phi; \Gamma}{e}{\tau}{\eT}$} \quad \cdots \hfill \\ 160 | \inferrule[\nameref{conv}]{ 161 | \cdots \\ 162 | \typeto{\Phi; \Gamma}{e}{\sigma}{\eT} \\ 163 | \subtype{\Phi; \Gamma}{\sigma}{\tau} 164 | }{ 165 | \typeto{\Phi; \Gamma}{e}{\tau}{\eT} 166 | } 167 | \and 168 | \inferrule[\nameref{sapp<}]{ 169 | \subsizeto{\Phi}{\sss{s}}{r}{\eT'} \\ 170 | \typeto{\Phi; \Gamma}{e}{\Funtype<{\alpha}{r}{\tau}}{\eT} 171 | }{ 172 | \typeto{\Phi; \Gamma}{\App{e}{s}}{\subst{\tau}{\alpha}{s}}{\app{\eT}{\compile{s}}{\eT'}} 173 | } 174 | \and 175 | \inferrule[\nameref{let}]{ 176 | \typeto{\Phi; \Gamma}{\sigma}{\UT}{\sigmaT} \\ 177 | \typeto{\Phi; \Gamma}{e_1}{\sigma}{\eT_1} \\ 178 | \typeto{\Phi; \Gamma, \define{x}{\sigma}{e_1}}{e_2}{\tau}{\eT_2} 179 | }{ 180 | \typeto{\Phi; \Gamma}{\letin{x}{\sigma}{e_1}{e_2}}{\subst{\tau}{x}{e_1}}{\letinT{\xT}{\sigmaT}{\eT_1}{\eT_2}} 181 | } 182 | \end{mathpar} 183 | \caption{Translation of terms (base \lang) and term environments} 184 | \label{#1} 185 | \end{figure} 186 | } 187 | 188 | \newcommand{\FigTransInd}[2][p]{ 189 | \begin{figure}[#1] 190 | \centering 191 | \begin{align*} 192 | \Aboxed{\compile{e} &= \eT} \quad \cdots \\ 193 | \compile{\N{s}} &= \app{\NatT}{\compile{s}} \\ 194 | \compile{\W{s}{x}{\sigma}{\tau}} &= \app{\WT}{\compile{\sigma}}{\compile{\fun{x}{\sigma}{\tau}}}{\compile{s}} 195 | \end{align*} 196 | \begin{mathpar} 197 | \setlength{\jot}{-1.5pt} 198 | \fbox{$\typeto{\Phi; \Gamma}{e}{\tau}{\eT}$} \quad \cdots \hfill \\ 199 | \inferrule[\nameref{zero}]{ 200 | \wf{\Phi}{\Gamma} \\ 201 | \subsizeto{\Phi}{\sss{r}}{s}{\eT'} 202 | }{ 203 | \typeto{\Phi; \Gamma}{\zero{s}{r}}{\N{s}}{\app{\zeroT}{\compile{s}}{\compile{r}}{\eT'}} 204 | } 205 | \and 206 | \inferrule[\nameref{succ}]{ 207 | \subsizeto{\Phi}{\sss{r}}{s}{\eT'} \\ 208 | \typeto{\Phi; \Gamma}{e}{\N{r}}{\eT} 209 | }{ 210 | \typeto{\Phi; \Gamma}{\succ{s}{r}{e}}{\N{s}}{\app{\succT}{\compile{s}}{\compile{r}}{\eT'}{\eT}} 211 | } 212 | \and 213 | \inferrule[\nameref{sup}]{ 214 | \subsizeto{\Phi}{\sss{r}}{s}{\eT'} \\ 215 | \typeto{\Phi; \Gamma}{\sigma}{U}{\sigmaT} \\ 216 | \typeto{\Phi; \Gamma, \annot{x}{\sigma}}{\tau}{U}{\tauT} \\\\ 217 | \typeto{\Phi; \Gamma}{e_1}{\sigma}{\eT_1} \\ 218 | \typeto{\Phi; \Gamma}{e_2}{\arr*{\subst{\tau}{x}{e_1}}{\W{x}{\sigma}{\tau}{r}}}{\eT_2} 219 | }{ 220 | \typeto{\Phi; \Gamma}{\sup{x}{\sigma}{\tau}{s}{r}{e_1}{e_2}}{\W{x}{\sigma}{\tau}{s}}{\app{\supT}{\sigmaT}{(\funT{\xT}{\sigmaT}{\tauT})}{\compile{s}}{\compile{r}}{\eT'}{\eT_1}{\eT_2}} 221 | } 222 | \and 223 | \inferrule[\nameref{case-nat}]{ 224 | \typeto{\Phi; \Gamma}{e}{\N{s}}{\eT} \\ 225 | \typeto{\Phi; \Gamma, \annot{x}{\N{s}}}{P}{U}{\PT} \\\\ 226 | \typeto{\Phi, \bound{\alpha}{s}; \Gamma}{e_z}{\subst{P}{x}{\zero{s}{\alpha}}}{\eT_z} \\ 227 | \typeto{\Phi, \bound{\beta}{s}; \Gamma, \annot{z}{\N{\beta}}}{e_s}{\subst{P}{x}{\succ{s}{\beta}{z}}}{\eT_s} 228 | }{ 229 | \typeto{\Phi; \Gamma}{ 230 | \begin{aligned} 231 | &\match{e}{\fun*{x}{P}}{ \\ 232 | &\quad \App{\zero*}{\alpha} \Rightarrow e_z \\ 233 | &\quad \app{\App{\succ*}{\beta}}{z} \Rightarrow e_s} 234 | \end{aligned} 235 | }{\subst{P}{x}{e}}{ 236 | \begin{aligned} 237 | &\matchT{\eT}{\funT*{\mt}{\xT}{\PT}}{\\ 238 | &\quad \app{\zeroT}{\alphaT}{\alphaT^*} \RightarrowT \eT_z \\ 239 | &\quad \app{\succT}{\betaT}{\betaT^*}{\zT} \RightarrowT \eT_s} 240 | \end{aligned} 241 | } 242 | } 243 | \and 244 | \inferrule[\nameref{case-wft}]{ 245 | \typeto{\Phi; \Gamma}{e}{\W{y}{\sigma}{\tau}{s}}{\eT} \\ 246 | \typeto{\Phi; \Gamma, \annot{x}{\W{y}{\sigma}{\tau}{s}}}{P}{U}{\PT} \\ 247 | \typeto{\Phi, \bound{\alpha}{s}; \Gamma, \annot{z_1}{\sigma}, \annot{z_2}{\arr*{\subst{\tau}{y}{z_1}}{\W{y}{\tau}{\sigma}{\alpha}}}}{e_s}{\subst{P}{x}{\sup{y}{\sigma}{\tau}{s}{\alpha}{z_1}{z_2}}}{\eT_s} 248 | }{ 249 | \typeto{\Phi; \Gamma}{ 250 | \begin{aligned} 251 | &\match{e}{\fun*{x}{P}}{ \\ 252 | &\quad \app{\App{\sup*}{\alpha}}{z_1}{z_2} \Rightarrow e_s} 253 | \end{aligned} 254 | }{\subst{P}{x}{e}}{ 255 | \begin{aligned} 256 | &\matchT{\eT}{\funT*{\mt}{\xT}{\PT}}{ \\ 257 | &\quad \app{\supT}{\alphaT}{\alphaT^*}{\zT_1}{\zT_2} \RightarrowT \eT_s} 258 | \end{aligned} 259 | } 260 | } 261 | \and 262 | \inferrule[\nameref{fix}]{ 263 | \typeto{\Phi, \alpha; \Gamma}{\sigma}{U}{\sigmaT} \\ 264 | \typeto{\Phi, \alpha; \Gamma, \annot{f}{\Funtype<{\beta}{\alpha}{\subst{\sigma}{\alpha}{\beta}}}}{e}{\sigma}{\eT} 265 | }{ 266 | \typeto{\Phi; \Gamma}{\fix{f}{\alpha}{\sigma}{e}}{\Funtype{\alpha}{\sigma}}{ 267 | \begin{aligned} 268 | &\app{\wfind}{(\funT{\alphaT}{\SizeT}{\sigmaT})}{ \\ 269 | &\quad (\funT{\alphaT}{\SizeT}{\funT{\fT}{\funtypeT{\betaT}{\SizeT}{\arrT*{\betaT \szltT \alphaT}{\subst{\sigmaT}{\alphaT}{\betaT}}}}{\eT}})} 270 | \end{aligned} 271 | } 272 | } 273 | \end{mathpar} 274 | \caption[Translation of naturals, well-founded trees, $\kw{case}$, fixpoints]{Translation of naturals, well-founded trees, \\ 275 | and $\kw{case}$ and fixpoint expressions} 276 | \label{#2} 277 | \end{figure} 278 | } -------------------------------------------------------------------------------- /iosevka.ttc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/iosevka.ttc -------------------------------------------------------------------------------- /scratch/bounded-NW.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/scratch/bounded-NW.pdf -------------------------------------------------------------------------------- /scratch/bounded-ind.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/scratch/bounded-ind.pdf -------------------------------------------------------------------------------- /scratch/successor-N.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/scratch/successor-N.pdf -------------------------------------------------------------------------------- /scratch/successor-W.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/scratch/successor-W.pdf -------------------------------------------------------------------------------- /scratch/successor-ind.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionathanch/msc-thesis/bd66856ae6e0c29eb00de1c3798e0d97a2b81663/scratch/successor-ind.pdf -------------------------------------------------------------------------------- /style.sty: -------------------------------------------------------------------------------- 1 | \ProvidesPackage{style} 2 | 3 | % required packages 4 | \RequirePackage{checkend} 5 | \RequirePackage{enumitem} 6 | \RequirePackage{graphicx} 7 | \RequirePackage{multicol} 8 | \RequirePackage{booktabs} 9 | \RequirePackage{xspace} 10 | \RequirePackage{xcolor} 11 | \RequirePackage{suffix} 12 | \RequirePackage{minted} 13 | \RequirePackage{tikz-cd} 14 | \RequirePackage{stmaryrd} 15 | \RequirePackage{mathtools} 16 | \RequirePackage{mathpartir} 17 | \RequirePackage[capitalize, noabbrev]{cleveref} 18 | 19 | % font for code listings 20 | \newfontfamily{\codefont}{iosevka.ttc} 21 | 22 | % save default lengths 23 | \newlength{\@fboxsepdefault} 24 | \setlength{\@fboxsepdefault}{\fboxsep} 25 | 26 | % \newcmd*{\cmd}[n]{expression} defines the suffixed command \cmd* 27 | % similarly for \newcmd< 28 | \WithSuffix\newcommand\newcmd*[3]{\WithSuffix\newcommand#1*#2{#3}} 29 | \WithSuffix\newcommand\newcmd<[3]{\WithSuffix\newcommand#1<#2{#3}} 30 | 31 | % rule labels: 32 | % \rlabel{name}{label} creates given label and prints name 33 | % \rref{label} prints "Rule " 34 | % \rref{label, label} prints "Rules and " 35 | % \rref{label, ..., label} prints "Rules , ..., and " 36 | % NOTE: \rule and \@rule seem to conflict with footnotes, somehow?? 37 | \newcounter{nrules} 38 | \newcommand{\rlabel}[2]{% 39 | \edef\@currentlabelname{#1}% 40 | \phantomsection\label{#2}#1% 41 | } 42 | \newcmd*{\rlabel}[1]{\rlabel{#1}{#1}} 43 | \newcommand{\rref}[1]{% 44 | \setcounter{nrules}{0}% 45 | \edef\r@les{\zap@space #1 \@empty}% 46 | \@for\r@le:={#1}\do{\addtocounter{nrules}{1}}% 47 | \ifcase \value{nrules} 48 | \or Rule~\mbox{\textsc{\nameref{#1}}}% 49 | \or Rules\@for\r@le:={\r@les}\do{ 50 | \ifcase \value{nrules} 51 | \or and \mbox{\textsc{\nameref{\r@le}}}% 52 | \else \mbox{\textsc{\nameref{\r@le}}}% 53 | \fi 54 | \addtocounter{nrules}{-1}% 55 | }% 56 | \else Rules\@for\r@le:={\r@les}\do{ 57 | \ifcase \value{nrules} 58 | \or and \mbox{\textsc{\nameref{\r@le}}}% 59 | \else \mbox{\textsc{\nameref{\r@le}}},% 60 | \fi 61 | \addtocounter{nrules}{-1}% 62 | }% 63 | \fi 64 | } 65 | \newcmd*{\rref}[1]{\mbox{\textsc{\nameref{#1}}}} 66 | 67 | % colours for: 68 | % - metafunctions (pale magenta) 69 | % - keywords (golden yellow) 70 | % - constants (soft blue) 71 | % - constructions (turquoise) 72 | % - target language (dark orange) 73 | % by Okabe and Ito (https://jfly.uni-koeln.de/color/#pallet) 74 | \definecolor{metacolour}{HTML}{CC79A7} 75 | \definecolor{kwcolour}{HTML}{E69F00} 76 | \definecolor{constcolour}{HTML}{0072B2} 77 | \definecolor{constrcolour}{HTML}{009E73} 78 | \definecolor{targetcolour}{HTML}{D55E00} 79 | \definecolor{newcolour}{gray}{0.85} 80 | 81 | % various theorem environments 82 | \newtheorem{theorem}{Theorem}[section] 83 | \newtheorem{definition}[theorem]{Definition} 84 | \newtheorem{lemma}[theorem]{Lemma} 85 | \newtheorem{sublemma}[theorem]{Sublemma} 86 | \newtheorem{postulate}[theorem]{Postulate} 87 | \newtheorem{corollary}[theorem]{Corollary} 88 | 89 | % foreign phrases 90 | \newcommand{\eg}{\emph{e.g.}\@\xspace} 91 | \newcommand{\ie}{\emph{i.e.}\@\xspace} 92 | \newcommand{\cf}{\emph{cf.}\@\xspace} 93 | \newcommand{\etal}{\emph{et al.}\@\xspace} 94 | \newcommand{\ala}{\emph{\`a la}\xspace} 95 | \newcommand{\opcit}{\emph{op.\! cit.}\@\xspace} 96 | \newcommand{\TODO}{\meta{\texttt{TODO}}\xspace} 97 | 98 | % check mark, cross mark, interrogation mark 99 | \newcmd*{\checkmark}[0]{\Large\textbf{\textcolor{constrcolour}{\checkmark}}} 100 | \newcommand{\crossmark}{\large$\displaystyle\mathbf{\times}$} 101 | \newcommand{\interromark}{?} 102 | 103 | % slanted fractions 104 | \newcommand{\sfrac}[2]{{}^{#1}\!/_{#2}} 105 | 106 | % use this before footnote to stack footnote mark above punctuation 107 | \newlength{\@punctwidth} 108 | \newcommand{\punctstack}[1]{#1% 109 | \settowidth{\@punctwidth}{#1}% 110 | \hspace*{-\the\@punctwidth}% 111 | } 112 | 113 | % language names 114 | \newcommand{\lang}{STT\xspace} 115 | \newcommand{\GCC}{CC$^\omega$\xspace} 116 | \newcommand{\Fstar}{F$\star$\xspace} 117 | \newcommand{\lambdahat}{$\lambda\widehat{~}$\xspace} 118 | \newcommand{\Fhat}{F$\widehat{~}$\xspace} 119 | \newcommand{\Fhatomega}{F$\widehat{_\omega}$\xspace} 120 | \newcommand{\Fhattimes}{F$\widehat{_{\times}}$\xspace} 121 | \newcommand{\Fcopomega}{F$^{\textrm{cop}}_{\omega}$\xspace} 122 | \newcommand{\CCE}{\texorpdfstring{CC$_E$}{CC(E)}\xspace} 123 | \newcommand{\CICE}{\texorpdfstring{CIC$_E$}{CIC(E)}\xspace} 124 | \newcommand{\CIChat}{CIC$\widehat{~}$\xspace} 125 | \newcommand{\CIChatminus}{CIC$\widehat{_-}$\xspace} 126 | \newcommand{\CChatomega}{CC$\widehat{\omega}$\xspace} 127 | \newcommand{\CIChatstar}{CIC$\widehat{\ast}$\xspace} 128 | \newcommand{\CIChatl}{CIC$\widehat{_\ell}$} 129 | \newcommand{\CIChatsub}{CIC$\widehat{_\sqsubseteq}$\xspace} 130 | \newcommand{\CCR}{$\mathfrak{CCR}$\xspace} 131 | 132 | % styling 133 | \newcommand{\meta}[1]{\textcolor{metacolour}{#1}} 134 | \newcommand{\kw}[1]{\mathsf{\textcolor{kwcolour}{#1}}} 135 | \newcommand{\const}[1]{\mathsf{\textcolor{constcolour}{#1}}} 136 | \newcommand{\constr}[1]{\mathsf{\textcolor{constrcolour}{#1}}} 137 | \newcommand{\tg}[1]{\mathtt{\textcolor{targetcolour}{#1}}} 138 | \newcmd*{\tg}[1]{\textcolor{targetcolour}{#1}} 139 | \newcommand{\new}[1]{% 140 | \setlength{\fboxsep}{3pt}% 141 | \colorbox{newcolour}{\rule{0em}{0.5\baselineskip}#1}% 142 | \setlength{\fboxsep}{\@fboxsepdefault}% 143 | } 144 | 145 | % delimiters 146 | \DeclarePairedDelimiter{\sqbr}{[}{]} 147 | \DeclarePairedDelimiter{\set}{\{}{\}} 148 | \DeclarePairedDelimiter{\ang}{\langle}{\rangle} 149 | 150 | % metafunctions 151 | \newcommand{\mt}{\,\meta{\mathbf{\cdot}}\,} 152 | \newcommand{\seq}{\,\meta{\textbf{\ldots}}\,} 153 | \newcommand{\any}{\meta{\texttt{\_}}} 154 | \newcommand{\hole}{\meta{\mathbf{?}}} 155 | \renewcommand{\vec}[1]{\meta{\overline{\textcolor{black}{#1}}}} 156 | \newcommand{\subst}[3]{#1\mathopen{\meta{\mathbf{[}}}#2 \mathrel{\meta{\mathbf{\mapsto}}} #3\mathclose{\meta{\mathbf{]}}}} 157 | \newcommand{\card}[1]{\mathopen{\meta{\mathbf{\lvert}}} #1 \mathclose{\meta{\mathbf{\rvert}}}} 158 | \newcommand{\compile}[1]{\mathopen{\meta{\mathbf{\llbracket}}} #1 \mathclose{\meta{\mathbf{\rrbracket}}}} 159 | \newcmd*{\compile}[1]{\meta{\mathbf{\biggl\llbracket}} #1 \meta{\mathbf{\biggr\rrbracket}}} 160 | \newcommand{\metafun}[2]{\meta{\textbf{#1(}}#2\meta{\textbf{)}}} 161 | \newcmd*{\metafun}[1]{\meta{\textbf{#1}}} 162 | \newcommand{\maximum}[1]{\metafun{max}{#1}} 163 | \newcommand{\minimum}[1]{\metafun{min}{#1}} 164 | \newcommand{\rules}[2]{\metafun{rule}{#1, #2}} 165 | \newcommand{\axioms}[1]{\metafun{axiom}{#1}} 166 | \newcmd*{\rules}[0]{\meta{\textbf{rule}}} 167 | \newcmd*{\axioms}[0]{\meta{\textbf{axiom}}} 168 | \newcommand{\fresh}[1]{\metafun{fresh}{#1}} 169 | \newcommand{\FV}[1]{\metafun{FV}{#1}} 170 | \newcommand{\elim}[3]{\metafun{elim}{#1, #2, #3}} 171 | 172 | % source binders 173 | \newcommand{\annot}[2]{#1 \mathrel{:} #2} 174 | \newcommand{\define}[3]{#1 \mathrel{:} #2 \mathrel{\coloneqq} #3} 175 | \newcmd*{\define}[2]{#1 \mathrel{\coloneqq} #2} 176 | \newcommand{\bound}[2]{#1 \mathrel{<} #2} 177 | 178 | % source language 179 | \newcommand{\@et}{\:} 180 | \newcommand{\Type}[1]{\const{Type}_{#1}} 181 | \newcommand{\Prop}{\const{Prop}} 182 | \newcommand{\Set}{\const{Set}} 183 | \newcommand{\sss}[1]{\widehat{#1}} 184 | \newcommand{\app}[1]{#1\@ifnextchar\bgroup{\@et\app}{\xspace}} 185 | \newcommand{\@pp}[1]{\sqbr{#1}\@ifnextchar\bgroup{\@et\@pp}{\xspace}} 186 | \newcommand{\App}[1]{#1\@ifnextchar\bgroup{\@et\@pp}{\xspace}} 187 | \newcommand{\fun}[3]{\lambda \annot{#1}{#2} \mathpunct{.} #3} 188 | \newcmd*{\fun}[2]{\lambda #1 \mathpunct{.} #2} 189 | \newcommand{\Fun}[2]{\Lambda #1 \mathpunct{.} #2} 190 | \newcmd<{\Fun}[3]{\Lambda \bound{#1}{#2} \mathpunct{.} #3} 191 | \newcommand{\funtype}[3]{\Pi \annot{#1}{#2} \mathpunct{.} #3} 192 | \newcommand{\Funtype}[2]{\forall #1 \mathpunct{.} #2} 193 | \newcmd<{\Funtype}[3]{\forall \bound{#1}{#2} \mathpunct{.} #3} 194 | \newcommand{\arr}[3]{\mathopen{(} \annot{#1}{#2} \mathclose{)} \mathrel{\rightarrow} \phantom{} #3} 195 | \newcmd*{\arr}[1]{#1\@ifnextchar\bgroup{\mathrel{\rightarrow}\arr*}{\xspace}} 196 | \newcommand{\letin}[4]{\kw{let} \@et #1 \mathrel{:} #2 \mathrel{\coloneqq} \phantom{} #3 \@et \kw{in} \@et #4} 197 | \newcommand{\Let}[3]{\kw{let} \@et \annot{#1}{#2} \mathrel{\coloneqq} \phantom{} #3} 198 | \newcommand{\Pairtype}[2]{\exists #1 \mathpunct{.} #2} 199 | \newcommand{\Pair}[2]{\ang{#1 \mathpunct{,} #2}} 200 | \newcommand{\unpair}[6]{\kw{let} \@et \Pair{#1}{#2}_{\Pairtype{#3}{#4}} \mathrel{\coloneqq} #5 \@et \kw{in} \@et #6} 201 | \newcmd*{\unpair}[4]{\kw{let} \@et \Pair{#1}{#2} \mathrel{\coloneqq} #3 \@et \kw{in} \@et #4} 202 | \newcommand{\eq}[3]{#1 \stackrel{#2}{=\joinrel=} #3} 203 | \newcommand{\refl}[1]{\constr{refl}_{#1}} 204 | \newcommand{\J}[3]{\constr{J}_{#1} \@et #2 \@et #3} 205 | \newcmd*{\J}[0]{\constr{J}} 206 | \newcommand{\Size}{\const{Size}} 207 | \newcommand{\slim}[2]{\mathopen{\constr{\sqcup}_{#1}}#2} 208 | 209 | % source inductives 210 | \newcommand{\data}[2]{\kw{data} \@et \annot{#1}{#2} \@et \kw{where}} 211 | \newcommand{\N}[1]{\App{\const{\mathbb{N}}}{#1}} 212 | \newcmd*{\N}[0]{\const{\mathbb{N}}} 213 | \newcommand{\W}[4]{\App{\const{\mathbb{W}} \annot{#1}{#2} \mathpunct{.} #3}{#4}} 214 | \newcmd*{\W}[0]{\const{\mathbb{W}}} 215 | \newcommand{\zero}[2]{\App{\constr{zero}_{\N{#1}}}{#2}} 216 | \newcmd*{\zero}[0]{\constr{zero}} 217 | \renewcommand{\succ}[3]{\app{\App{\constr{succ}_{\N{#1}}}{#2}}{#3}} 218 | \newcmd*{\succ}[0]{\constr{succ}} 219 | \renewcommand{\sup}[7]{\app{\App{\constr{sup}_{\W{#1}{#2}{#3}{#4}}}{#5}}{#6}{#7}} 220 | \newcmd*{\sup}[0]{\constr{sup}} 221 | \newcommand{\List}[2]{\App{\app{\const{List}}{#1}}{#2}} 222 | \newcmd*{\List}[0]{\const{List}} 223 | \newcommand{\nil}[3]{\App{\constr{nil}_{\List{#1}{#2}}}{#3}} 224 | \newcmd*{\nil}[0]{\constr{nil}} 225 | \newcommand{\cons}[5]{\app{\App{\constr{cons}_{\List{#1}{#2}}}{#3}}{#4}{#5}} 226 | \newcmd*{\cons}[0]{\constr{cons}} 227 | \newcommand{\Ord}[1]{\App{\const{Ord}}{#1}} 228 | \newcmd*{\Ord}[0]{\const{Ord}} 229 | \newcommand{\zord}[2]{\App{\constr{z}_{\Ord{#1}}}{#2}} 230 | \newcmd*{\zord}[0]{\constr{z}} 231 | \newcommand{\sord}[3]{\app{\App{\constr{s}_{\Ord{#1}}}{#2}}{#3}} 232 | \newcmd*{\sord}[0]{\constr{s}} 233 | \newcommand{\lord}[3]{\app{\App{\constr{\ell}_{\Ord{#1}}}{#2}}{#3}} 234 | \newcmd*{\lord}[0]{\constr{\ell}} 235 | \newcommand{\match}[3]{\kw{case} \@et #1 \@et \kw{return} \@et #2 \@et \kw{of} \@et \phantom{} #3} 236 | \newcmd*{\match}[2]{\kw{case} \@et #1 \@et \kw{of} \@et \phantom{} #2} 237 | \newcommand{\fix}[4]{\kw{fix} \@et #1 \@et \sqbr{#2} \mathrel{:} #3 \mathrel{\coloneqq} \phantom{} #4} 238 | 239 | % source coinductives 240 | \newcmd*{\M}[0]{\const{M}} 241 | \newcmd*{\inf}[0]{\constr{inf}} 242 | \newcommand{\Stream}[2]{\App{\app{\const{Stream}}{#1}}{{#2}}} 243 | \newcmd*{\Stream}[0]{\const{Stream}} 244 | \newcommand{\shd}[1]{#1\mathord{.}\constr{hd}} 245 | \newcommand{\stl}[1]{#1\mathord{.}\constr{tl}} 246 | \newcommand{\scons}[6]{\set{\constr{hd} \mathrel{\coloneqq} #3 \mathpunct{;} \app{\constr{tl}}{[\bound{#4}{#5}]} \mathrel{\coloneqq} #6}} 247 | \newcmd*{\scons}[0]{\constr{scons}} 248 | \newcommand{\cofix}[4]{\kw{cofix} \@et #1 \@et \sqbr{#2} \mathrel{:} #3 \mathrel{\coloneqq} \phantom{} #4} 249 | \newcommand{\Thunk}[2]{\App{\app{\const{Thunk}}{#1}}{#2}} 250 | \newcmd*{\Thunk}[0]{\const{Thunk}} 251 | \newcommand{\force}[1]{#1\mathord{.}\constr{force}} 252 | \newcmd*{\force}[0]{\constr{force}} 253 | \newcommand{\thunk}[3]{\set{\app{\constr{force}}{[\bound{#1}{#2}]} \mathrel{\coloneqq} #3}} 254 | 255 | % source names 256 | \newcommand{\liftN}{\const{liftN}} 257 | \newcommand{\liftW}{\const{liftW}} 258 | \newcommand{\liftL}{\const{liftL}} 259 | \newcommand{\liftO}{\const{liftO}} 260 | \newcommand{\monus}{\const{monus}} 261 | \newcommand{\pred}{\const{pred}} 262 | \newcommand{\divv}{\const{div}} 263 | \newcommand{\Nary}{\const{Nary}} 264 | \newcommand{\maX}{\const{max}} 265 | \newcommand{\MaX}{\const{maximum}} 266 | \newcommand{\ifleq}{\const{ifleq}} 267 | \newcommand{\append}{\const{append}} 268 | \newcommand{\mrg}{\const{merge}} 269 | \newcommand{\spt}{\const{split}} 270 | \newcommand{\partition}{\const{partition}} 271 | \newcommand{\qsort}{\const{qsort}} 272 | \newcommand{\msort}{\const{msort}} 273 | \newcommand{\msorted}{\const{msort'}} 274 | \newcommand{\traverseW}{\const{traverseW}} 275 | \newcommand{\natOrd}{\const{natOrd}} 276 | \newcommand{\omegaOrd}{\const{\omega}} 277 | \newcommand{\dup}{\const{repeat}} 278 | \newcommand{\odds}{\const{odds}} 279 | \renewcommand{\interleave}{\const{interleave}} 280 | \newcommand{\zip}{\const{zip}} 281 | \newcommand{\fibs}{\const{fibs}} 282 | 283 | % example names 284 | \newcommand{\id}{\mathit{id}} 285 | \newcommand{\Id}{\mathit{Id}} 286 | \newcommand{\hd}{\mathit{hd}} 287 | \newcommand{\tl}{\mathit{tl}} 288 | \newcommand{\lift}{\mathit{lift}} 289 | \newcommand{\nary}[0]{\mathit{nary}} 290 | \newcommand{\traverse}[0]{\mathit{traverse}} 291 | \newcmd*{\monus}[0]{\mathit{monus}} 292 | \newcmd*{\divv}[0]{\mathit{div}} 293 | \newcmd*{\MaX}[0]{\mathit{maximum}} 294 | \newcmd*{\qsort}[0]{\mathit{qsort}} 295 | \newcmd*{\msort}[0]{\mathit{msort}} 296 | \newcmd*{\natOrd}[0]{\mathit{natOrd}} 297 | \newcmd*{\dup}[0]{\mathit{repeat}} 298 | \newcmd*{\odds}[0]{\mathit{odds}} 299 | \newcmd*{\interleave}[0]{\mathit{interleave}} 300 | \newcmd*{\zip}[0]{\mathit{zip}} 301 | \newcmd*{\fibs}[0]{\mathit{fibs}} 302 | 303 | % judgements 304 | \newcommand{\wf}[2]{#1 \mathrel{\vdash} #2} 305 | \renewcommand{\check}[3]{#1 \mathrel{\vdash} #2 \mathrel{:} #3} 306 | \renewcommand{\infer}[3]{#1 \mathrel{\vdash} #2 \mathrel{:} #3} 307 | \newcommand{\type}[3]{#1 \mathrel{\vdash} \annot{#2}{#3}} 308 | \newcommand{\defeq}[4]{#1 \mathrel{\vdash} \annot{#2 \mathrel{\equiv} #3}{#4}} 309 | \newcommand{\subsize}[3]{#1 \mathrel{\vdash} #2 \mathrel{\leqslant} #3} 310 | \newcmd*{\subsize}[2]{#1 \mathrel{\leqslant} #2} 311 | \newcommand{\subtype}[3]{#1 \mathrel{\vdash} #2 \mathrel{\preccurlyeq} #3} 312 | \newcommand{\acum}[2]{#1 \mathrel{\sqsubseteq} #2} 313 | \newcommand{\red}[4][]{#2 \mathrel{\vdash} #3 \mathrel{\rhd}_{#1} #4} 314 | \newcmd*{\red}[3]{#1 \mathrel{\vdash} #2 \mathrel{\rhd^*} #3} 315 | \newcommand{\develop}[3]{#1 \mathrel{\vdash} #2 \mathrel{\blacktriangleright} #3} 316 | \newcommand{\subsizeto}[4]{#1 \mathrel{\vdash} #2 \mathrel{\leqslant} #3 \mathrel{\rightsquigarrow} #4} 317 | \newcommand{\wfto}[3]{#1 \mathrel{\vdash} #2 \mathrel{\rightsquigarrow} #3} 318 | \newcommand{\typeto}[4]{#1 \mathrel{\vdash} \annot{#2}{#3} \mathrel{\rightsquigarrow} #4} 319 | 320 | % target metavariables 321 | \newcommand{\GammaT}{\tg*{\Gamma}} 322 | \newcommand{\DeltaT}{\tg*{\Delta}} 323 | \newcommand{\iT}{\tg{i}} 324 | \newcommand{\jT}{\tg{j}} 325 | \newcommand{\kT}{\tg{k}} 326 | \newcommand{\mT}{\tg{m}} 327 | \newcommand{\nT}{\tg{n}} 328 | \newcommand{\UT}{\tg{U}} 329 | \newcommand{\DT}{\tg{D}} 330 | \newcommand{\eT}{\tg{e}} 331 | \newcommand{\aT}{\tg{a}} 332 | \newcommand{\bT}{\tg{b}} 333 | \newcommand{\dT}{\tg{d}} 334 | \newcommand{\pT}{\tg{p}} 335 | \newcommand{\PT}{\tg{P}} 336 | \newcommand{\rT}{\tg{r}} 337 | \newcommand{\sT}{\tg{s}} 338 | \newcommand{\alphaT}{\tg*{\alpha}} 339 | \newcommand{\betaT}{\tg*{\beta}} 340 | \newcommand{\gammaT}{\tg*{\gamma}} 341 | \newcommand{\tauT}{\tg*{\tau}} 342 | \newcommand{\sigmaT}{\tg*{\sigma}} 343 | \newcommand{\XT}{\tg{X}} 344 | \newcommand{\cT}{\tg{c}} 345 | \newcommand{\fT}{\tg{f}} 346 | \newcommand{\gT}{\tg{g}} 347 | \newcommand{\wT}{\tg{w}} 348 | \newcommand{\xT}{\tg{x}} 349 | \newcommand{\yT}{\tg{y}} 350 | \newcommand{\zT}{\tg{z}} 351 | \newcommand{\RightarrowT}{\mathrel{\tg{\Rightarrow}}} 352 | 353 | % target binders 354 | \newcommand{\annotT}[2]{#1 \mathrel{\tg{:}} #2} 355 | \newcmd*{\annotT}[2]{\mathmbox{#1 \mathrel{\tg{:}} #2}} 356 | \newcommand{\defineT}[3]{#1 \mathrel{\tg{:}} #2 \mathrel{\tg{\coloneqq}} #3} 357 | \newcommand{\boundT}[2]{#1 \mathrel{\tg{<}} #2} 358 | 359 | % target language 360 | \newcommand{\PropT}{\tg{Prop}} 361 | \newcommand{\SPropT}{\tg{SProp}} 362 | \newcommand{\TypeT}[1]{\tg{Type}_{#1}} 363 | \newcommand{\sssT}[1]{\tg{\widehat{#1}}} 364 | \newcommand{\funT}[3]{\tg{\lambda} \annotT{#1}{#2} \mathpunct{\tg{.}} #3} 365 | \newcmd*{\funT}[3]{\tg{\lambda} #1 \mathord{\tg{.}} #2 \mathpunct{\tg{.}} #3} 366 | \newcommand{\funtypeT}[3]{\tg*{\Pi} \annotT{#1}{#2} \mathpunct{\tg{.}} #3} 367 | \newcommand{\arrT}[3]{\mathopen{\tg{(}} \annotT{#1}{#2} \mathclose{\tg{)}} \mathrel{\tg{\rightarrow}} \phantom{} #3} 368 | \newcmd*{\arrT}[1]{#1\@ifnextchar\bgroup{\mathrel{\tg{\rightarrow}}\arr*}{\xspace}} 369 | \newcommand{\letinT}[4]{\tg{let} \@et #1 \mathrel{\tg{:}} #2 \mathrel{\tg{\coloneqq}} \phantom{} #3 \@et \tg{in} \@et #4} 370 | \newcommand{\LetT}[3]{\tg{let} \@et \annotT{#1}{#2} \mathrel{\tg{\coloneqq}} \phantom{} #3} 371 | \newcommand{\eqT}[3]{#1 \stackrel{#2}{\tg{=\joinrel=}} #3} 372 | \newcommand{\reflT}[1]{\tg{refl}_{#1}} 373 | \newcommand{\JT}[3]{\tg{J} \@et {#1} \@et #2 \@et #3} 374 | \newcmd*{\JT}[0]{\tg{J}} 375 | \newcommand{\inftyT}{\tg{\infty}} 376 | 377 | % target inductives 378 | \newcommand{\dataT}[2]{\tg{data} \@et \annotT{#1}{#2} \@et \tg{where}} 379 | \newcommand{\matchT}[3]{\tg{case} \@et #1 \@et \tg{return} \@et #2 \@et \tg{of} \@et \phantom{} #3} 380 | \newcmd*{\matchT}[2]{\tg{case} \@et #1 \@et \tg{of} \@et \phantom{} #2} 381 | \newcommand{\fixT}[4]{\tg{fix}_{#1} \@et #2 \mathrel{\tg{:}} #3 \mathrel{\tg{\coloneqq}} \phantom{} #4} 382 | \newcommand{\botT}{\tg{\bot}} 383 | \newcommand{\SizeT}{\tg{Size}} 384 | \newcommand{\SizeUnivT}{\tg{SizeUniv}} 385 | \newcommand{\baseT}{\tg{base}} 386 | \newcommand{\sucT}{\tg{suc}} 387 | \newcommand{\limT}{\tg{lim}} 388 | \newcommand{\szleT}{\mathbin{\tg{\le}}} 389 | \newcommand{\szltT}{\mathbin{\tg{<}}} 390 | \newcommand{\monoT}{\tg{mono}} 391 | \newcommand{\coconeT}{\tg{cocone}} 392 | \newcommand{\limitT}{\tg{limiting}} 393 | \newcommand{\AccT}{\tg{Acc}} 394 | \newcommand{\accT}{\tg{acc}} 395 | \newcommand{\NatT}{\tg{Nat}} 396 | \newcommand{\zeroT}{\tg{zero}} 397 | \newcommand{\succT}{\tg{succ}} 398 | \newcommand{\WT}{\tg{W}} 399 | \newcommand{\supT}{\tg{sup}} 400 | 401 | % target names 402 | \newcommand{\baseleq}{\tg{base\mathord{\le}}} 403 | \newcommand{\reflleq}{\tg{refl\mathord{\le}}} 404 | \newcommand{\sucleq}{\tg{suc\mathord{\le}}} 405 | \newcommand{\transleq}{\tg{trans\mathord{\le}}} 406 | \newcommand{\funext}{\tg{funext}} 407 | \newcommand{\accIsProp}{\tg{accIsProp}} 408 | \newcommand{\accleq}{\tg{acc\mathord{\le}}} 409 | \newcommand{\accessible}{\tg{wf}} 410 | \newcommand{\access}{\tg{access}} 411 | \newcommand{\wfacc}{\tg{wfAcc}} 412 | \newcommand{\wfind}{\tg{wfInd}} 413 | \newcommand{\inftyltinfty}{\tg{\infty\text{<}\infty}} 414 | \newcmd*{\wfacc}[0]{\tg{wfAcc'}} -------------------------------------------------------------------------------- /thesis.tex: -------------------------------------------------------------------------------- 1 | %% The ubcdiss class provides several options: 2 | %% 10pt, 11pt, 12pt 3 | %% set default font size 4 | %% oneside, twoside 5 | %% whether to format for single-sided or double-sided printing 6 | %% singlespacing, onehalfspacing, doublespacing 7 | %% set default inter-line text spacing; the ubcdiss class 8 | %% provides \textspacing to revert to this configured spacing 9 | 10 | \documentclass[oneside,onehalfspacing,11pt]{ubcdiss} 11 | 12 | % https://tex.stackexchange.com/a/637286/202877 13 | \usepackage[no-math]{fontspec} 14 | \usepackage{mlmodern} 15 | \usepackage[T1]{fontenc} 16 | \usepackage[width=6in, height=8.5in]{geometry} 17 | \usepackage[numbers]{natbib} 18 | \usepackage[hang, sc, skip=1ex]{caption} 19 | \usepackage{xcolor, imakeidx} 20 | \usepackage{amsmath, amssymb, amsthm} 21 | \usepackage[pagebackref,bookmarksnumbered,linktocpage,colorlinks,pdfusetitle]{hyperref} 22 | \usepackage{style} 23 | 24 | % backreferences styled as ↪ page(s) x, y, and z 25 | \renewcommand{\backrefalt}[4]{\textcolor{gray}{\ifcase #1\or $\hookrightarrow$~page~#2\else $\hookrightarrow$~pages~#2\fi}} 26 | 27 | % links must be in "dark blue" 28 | % https://www.grad.ubc.ca/current-students/dissertation-thesis-preparation/fonts-print 29 | \definecolor{darkblue}{HTML}{0000EE} 30 | \hypersetup{allcolors=darkblue} 31 | 32 | % style URLs (incl. DOIs) in sans serif 33 | \urlstyle{sf} 34 | \newcommand{\doi}[1]{doi:\href{https://doi.org/#1}{\textsf{#1}}} 35 | 36 | % use ∎ as QED symbol 37 | \renewcommand\qedsymbol{\codefont ∎} 38 | 39 | % set caption margins to 2× indent 40 | \setlength{\captionmargin}{2\parindent} 41 | 42 | \title{Sized Dependent Types via Extensional Type Theory} 43 | \makeindex[intoc] 44 | 45 | \author{Jonathan {\footnotesize H.W. \relax}Chan} 46 | \degreetitle{Master of Science} 47 | \institution{The University of British Columbia} 48 | \campus{Vancouver} 49 | \faculty{The Faculty of Graduate and Postdoctoral Studies} 50 | \department{Computer Science} 51 | \submissionmonth{July} 52 | \submissionyear{2022} 53 | 54 | \examiningcommittee{William J. Bowman, Assistant Professor, Computer Science, UBC}{Supervisor} 55 | \examiningcommittee{Alexander J. Summers, Associate Professor, Computer Science, UBC}{Supervisory Committee Member} 56 | %\examiningcommittee{Ronald Garcia, Associate Professor, Computer Science, UBC}{Supervisory Committee Member} 57 | 58 | \begin{document} 59 | \maketitle 60 | \makecommitteepage 61 | \textspacing 62 | 63 | \include{chapters/abstract} 64 | \include{chapters/laysummary} 65 | \include{chapters/preface} 66 | 67 | % Page links in ToC, LoT, LoF must be black 68 | \hypersetup{allcolors=black} 69 | \tableofcontents 70 | \listoftables 71 | \listoffigures 72 | \hypersetup{allcolors=darkblue} 73 | 74 | \include{chapters/acknowledgements} 75 | \include{chapters/dedication} 76 | \include{chapters/typography.tex} 77 | 78 | \mainmatter 79 | \include{chapters/introduction.tex} 80 | \include{chapters/sized.tex} 81 | \include{chapters/model.tex} 82 | \include{chapters/proofs.tex} 83 | \include{chapters/discussion.tex} 84 | 85 | \bibliographystyle{plainnat} 86 | \begin{singlespace} 87 | \raggedright 88 | \bibliography{biblio} 89 | \end{singlespace} 90 | 91 | \appendix 92 | \include{chapters/appendix} 93 | 94 | \backmatter 95 | \printindex 96 | \end{document} 97 | -------------------------------------------------------------------------------- /ubcdiss.cls: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %% ubcdiss.cls: A LaTeX document class for the revised UBC Thesis Guidelines 3 | %% Originally created by Brian de Alwis. I developed this separately from 4 | %% Michael McNeil Forbes's ubcthesis.cls/genthesis.class: unlike Forbes' class, 5 | %% this class builds on top of the standard LaTeX book class and should have 6 | %% better compatibility with standard LaTeX packages. 7 | %% 8 | %% GPS Thesis Specifications and Formatting Requirements 9 | %% 10 | %% 11 | %% 12 | %% Useful documents: 13 | %% * LaTeX2e for class and package writers 14 | %% 15 | %% 16 | %% This package, and all its contents, are placed in the public domain. 17 | %% 18 | 19 | %% Options that can be specified with the documentclass: 20 | %% singlespacing typeset text single spaced 21 | %% onehalfspacing typeset text line-and-a-half spacing 22 | %% doublespacing typeset text double spaced 23 | %% 10pt use a 10pt font 24 | %% 11pt use a 11pt font (default) 25 | %% 12pt use a 12pt font 26 | %% oneside arrange pages for single-sided printing (default) 27 | %% twoside insert blank pages as required for double-sided printing 28 | 29 | \NeedsTeXFormat{LaTeX2e} 30 | \ProvidesClass{ubcdiss}[2022/02/22] 31 | 32 | % default line spacing in \textspacing 33 | \newcommand{\textspacing}{\singlespacing} 34 | \DeclareOption{singlespacing}{\renewcommand{\textspacing}{\singlespacing}} 35 | \DeclareOption{onehalfspacing}{\renewcommand{\textspacing}{\onehalfspacing}} 36 | \DeclareOption{doublespacing}{\renewcommand{\textspacing}{\doublespacing}} 37 | 38 | \DeclareOption{10pt}{\PassOptionsToClass{10pt}{book}} 39 | \DeclareOption{11pt}{\PassOptionsToClass{11pt}{book}} 40 | \DeclareOption{12pt}{\PassOptionsToClass{12pt}{book}} 41 | \DeclareOption{oneside}{\PassOptionsToClass{oneside}{book}} 42 | \DeclareOption{twoside}{\PassOptionsToClass{twoside,openright}{book}} 43 | 44 | \ExecuteOptions{11pt,oneside} 45 | \ProcessOptions\relax 46 | \LoadClass[letterpaper]{book} 47 | 48 | \RequirePackage{calc} 49 | \RequirePackage{textcase} % upper-/lower-casing 50 | \RequirePackage{setspace} % line spacing 51 | \RequirePackage{tocbibind} % ToC with LoT, LoF, biblio, index 52 | \RequirePackage[titles]{tocloft} % ToC, LoT, LoF typesetting 53 | \RequirePackage{fancyhdr} % custom headers and footers 54 | 55 | % ToC full name 56 | \renewcommand{\contentsname}{Table of Contents} 57 | 58 | % ToC leader dots 59 | \renewcommand{\cftpartdotsep}{\cftdotsep} 60 | \renewcommand{\cftchapdotsep}{\cftdotsep} 61 | 62 | % prefix entries in LoT and LoF with Table/Figure 63 | \setlength{\cfttabindent}{0em} 64 | \setlength{\cftfigindent}{0em} 65 | \renewcommand{\cfttabpresnum}{Table } 66 | \renewcommand{\cftfigpresnum}{Figure } 67 | \addtolength{\cfttabnumwidth}{\widthof{\cfttabfont\cfttabpresnum~}} 68 | \addtolength{\cftfignumwidth}{\widthof{\cfttabfont\cfttabpresnum~}} 69 | 70 | % From 71 | % LaTeX per default only allows a part of the top of a text-page 72 | % (70%) to contain figures, and requires at least 20% of a page to 73 | % be text when text and figures share a page. These parameters should 74 | % be set to more reasonable values, for example 85% and 10%. Be careful 75 | % not to make \floatpagefraction larger than \topfraction, then you 76 | % risk to produce a figure that can neither go on the top of a text 77 | % page, nor on a page by itself. 78 | \renewcommand{\topfraction}{0.85} 79 | \renewcommand{\textfraction}{0.1} 80 | \renewcommand{\floatpagefraction}{0.75} 81 | 82 | % no headers, centre bottom page number 83 | \pagestyle{plain} 84 | 85 | % Useful command stolen from Forbes' genthesis.cls 86 | \newcommand{\@addto}[2]{ 87 | \expandafter\let\expandafter\old\csname#1\endcsname 88 | \toks1=\expandafter{\old} 89 | \toks2=\expandafter{#2} 90 | \expandafter\xdef\csname#1\endcsname{\the\toks1 \the\toks2 } 91 | } 92 | 93 | % defaults 94 | \newcommand*{\@subtitle}{} 95 | \newcommand*{\@previousdegrees}{} 96 | \newcommand{\@degreetitle}{% 97 | \ClassError{ubcdiss}{Missing degree title}{% 98 | Specify \protect\degreetitle\space in your dissertation 99 | metadata section.} 100 | \emph{missing degree title}} 101 | \newcommand{\@institution}{The University of British Columbia} 102 | \newcommand{\f@culty}{Graduate and Postdoctoral Studies} 103 | \newcommand*{\dep@rtment}{} 104 | \newcommand{\c@mpus}{% 105 | \ClassError{ubcdiss}{Missing campus name}{% 106 | Specify \protect\campus\{\}\space in your dissertation 107 | metadata section.}% 108 | \emph{missing campus}} 109 | \newcommand{\@subye@r}{ 110 | \ClassError{ubcdiss}{Missing submission year}{% 111 | Specify \protect\submissionyear\space in your dissertation 112 | metadata section.} 113 | \emph{missing submission year}} 114 | \newcommand{\@submonth}{ 115 | \ClassError{ubcdiss}{Missing submission month}{% 116 | Specify \protect\submissionmonth\space in your dissertation 117 | metadata section.} 118 | \emph{missing submission month}} 119 | 120 | \newcommand{\subtitle}[1]{\renewcommand{\@subtitle}{#1}} 121 | \newcommand{\previousdegree}[1]{\@addto{@previousdegrees}{#1\par}} 122 | \newcommand{\degreetitle}[1]{\renewcommand{\@degreetitle}{#1}} 123 | \newcommand{\institution}[1]{\renewcommand{\@institution}{#1}} 124 | \newcommand{\faculty}[1]{\renewcommand{\f@culty}{#1}} 125 | \newcommand{\department}[1]{\renewcommand{\dep@rtment}{#1}} 126 | \newcommand{\program}[1]{\department{#1}} 127 | \newcommand{\campus}[1]{\renewcommand{\c@mpus}{#1}} 128 | \newcommand{\submissionyear}[1]{\renewcommand{\@subye@r}{#1}} 129 | \newcommand{\submissionmonth}[1]{\renewcommand{\@submonth}{#1}} 130 | 131 | \renewcommand{\date}[1]{% 132 | \ClassWarning{ubcdiss}{Ignoring \protect\date: 133 | use \protect\submissionyear and \protect\submissionmonth instead}} 134 | 135 | \renewcommand{\maketitle}{% 136 | \frontmatter 137 | \thispagestyle{empty} 138 | \begin{titlepage} 139 | \begin{center} 140 | \begin{doublespace} 141 | {\Large \textbf{\@title}}\\\medskip 142 | \ifx\@subtitle\empty\relax\else{\large\textbf{\@subtitle}}\\\medskip\fi 143 | 144 | {\large by}\\\medskip 145 | {\large \@author}\\\medskip 146 | \ifx\@previousdegrees\empty\vspace{0.5\baselineskip}\else\@previousdegrees\\\bigskip\fi 147 | 148 | {\Large \textsc{a thesis submitted in partial fulfillment}}\\ 149 | {\Large \textsc{of the requirements for the degree of}}\\\medskip 150 | {\large \textbf{\@degreetitle}}\\\medskip 151 | 152 | {\large in}\\\medskip 153 | {\Large \textsc{\MakeTextLowercase{\f@culty}}}\\ 154 | \ifx\dep@rtment\empty\vspace{\baselineskip}\else{\large (\dep@rtment)}\\\bigskip\fi 155 | 156 | {\Large \textsc{\MakeTextLowercase{\@institution}}}\\ 157 | {\large (\c@mpus)}\\\bigskip 158 | {\large \@submonth\ \@subye@r} 159 | 160 | \vfill 161 | {\large \textcopyright\ \@author, \@subye@r} 162 | \end{doublespace} 163 | \end{center} 164 | \end{titlepage} 165 | \setcounter{page}{2} 166 | \renewcommand{\frontmatter}{\ClassError{ubcdiss}{frontmatter should not be used}} 167 | } 168 | 169 | \newcommand*{\ex@miners}{} 170 | \newcommand*{\@supervisory}{} 171 | \newcommand{\examiningcommittee}[2]{\@addto{ex@miners}{ 172 | \par\medskip\noindent#1\\\emph{#2}}} 173 | \newcommand{\supervisorycommittee}[2]{\@addto{@supervisory}{ 174 | \par\medskip\noindent#1\\\emph{#2}}} 175 | \newcommand{\makecommitteepage}{ 176 | \begin{singlespace} 177 | \noindent The following individuals certify that they have read, 178 | and recommend to the Faculty of Graduate and Postdoctoral Studies 179 | for acceptance, the thesis entitled: 180 | \par\bigskip 181 | {\large \textbf{\@title\ifx\@subtitle\empty\relax\else: \@subtitle\fi}} 182 | \par\bigskip\noindent 183 | submitted by 184 | \textbf{\@author} 185 | in partial fulfillment of the requirements for the degree of 186 | \textbf{\@degreetitle} 187 | in 188 | \textbf{\ifx\dep@rtment\empty\f@culty\else\dep@rtment\fi}. 189 | \par\bigskip\noindent 190 | \textbf{Examining Committee:} 191 | \ex@miners 192 | \ifx\@supervisory\empty\relax\else 193 | \par\bigskip\noindent 194 | \textbf{Additional Supervisory Committee Members:} 195 | \@supervisory 196 | \fi 197 | \end{singlespace} 198 | \cleardoublepage 199 | } --------------------------------------------------------------------------------