• Stars
    star
    348
  • Rank 117,969 (Top 3 %)
  • Language Agda
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 17 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A new Categories library for Agda

agda-categories library

Welcome to what will hopefully become the standard Category Theory library for Agda.

The current library release, v0.1.8, works with Agda-2.6.3 and stdlib-1.7.2. The master branch should also work with same, but may contain various incompatibilities.

Note that this should be considered pre-beta software, and that backwards compability is not assured (although we don't intend to break things whimsically).

When citing this library, please link to the github repo and also cite

@inproceedings{10.1145/3437992.3439922,
  author = {Hu, Jason Z. S. and Carette, Jacques},
  title = {Formalizing Category Theory in Agda},
  year = {2021},
  isbn = {9781450382991},
  publisher = {Association for Computing Machinery},
  address = {New York, NY, USA},
  url = {https://doi.org/10.1145/3437992.3439922},
  doi = {10.1145/3437992.3439922},
  abstract = {The generality and pervasiveness of category theory in modern mathematics makes it a frequent and useful target of formalization. It is however quite challenging to formalize, for a variety of reasons. Agda currently (i.e. in 2020) does not have a standard, working formalization of category theory. We document our work on solving this dilemma. The formalization revealed a number of potential design choices, and we present, motivate and explain the ones we picked. In particular, we find that alternative definitions or alternative proofs from those found in standard textbooks can be advantageous, as well as "fit" Agda's type theory more smoothly. Some definitions regarded as equivalent in standard textbooks turn out to make different "universe level" assumptions, with some being more polymorphic than others. We also pay close attention to engineering issues so that the library integrates well with Agda's own standard library, as well as being compatible with as many of supported type theories in Agda as possible.},
  booktitle = {Proceedings of the 10th ACM SIGPLAN International Conference on Certified Programs and Proofs},
  pages = {327โ€“342},
  numpages = {16},
  keywords = {formal mathematics, Agda, category theory},
  location = {Virtual, Denmark},
  series = {CPP 2021}
}

Origins

This library is a rewrite of copumpkin's version of a previous library, which worked very well up to Agda 2.4.3 or so, but began bit-rotting and was completely broken by 2.6 (with various stages of 'functioning' in between). That library itself has older origins, which are well documented in that project's own documentation.

Design

One of the main reasons that the old library started bit-rotting was that it used proof-irrelevance quite extensively. And that this feature started misbehaving in later versions of Agda (it does not seem to be used much in the standard library, so gets less testing). And the desire to see how far one could go in Category Theory while being proof relevant. This proof relevance does not have a large effect, at least not until some definitions that use natural transformation-based identities (like that for Monad); here the classical definition is "sloppy", omitting some coherence natural isomorphisms that are expanded away in the proof-irrelevant case, but must be inserted here. Along with proof relevance, it also makes sense to develop under the conditions of --without-K and --safe. And to stay away from strict category theory -- being Setoid-enriched doesn't play well with that at all.

A second aim is to make this library 'ready' to be, in whole or in part, incorporated into the main standard library. Thus that means removing many custom-made parts written for Setoid-based reasoning from the previous version, amongst others, and instead rely on the standard library as much as possible. Also, the style should be adapted to use that of the standard library.

Another clear design decision, already present in the original, is to internalize to each category a version of Hom-equality, i.e. as mentioned above, to be Setoid-enriched. In practice what this means is that here and there, the flavour is that of bicategory theory instead of category theory.

All non-trivial proofs are done in equational style. One-liner proofs are not; some very short proofs (obvious 2- or 3-steps) are done combinator-style. Very large proofs with trivial sequences of steps "in the middle" have those done combinator-style too.

Some of the lower-level design decisions (naming conventions, organization) are (will be) documented in the proto-contributor's guide.

Some design decisions

  • We add sym-assoc and identityยฒ in order to achieve better definitional equality of Category. The rationale can be found in this paper.
  • We also add other "redundant" axioms into other definitions so that we achieve a better definitional equality property for definitions with opposites.
  • Use (private) modules instead of local renaming to resolve name clashes that would occur with opening the same module twice, such as when working with two categories, two functors, etc.
  • (bicategory is defined as Enriched over (Monoidal) Cats instead of 'by hand')
  • (definition of Pseudofunctor is in Benabou style rather than 'by hand')

Places to find more design notes

Smaller Design decisions

  • Do not make implicit fields that can rarely be inferred (like what had been done in Category and Functor)
  • Do not use Heterogeneous equality at all. Really, never ever.
  • Minimize all use of propositional equality. Try to make things Setoid-enriched instead of Set-enriched.

Contributing

We welcome contributions! Please submit PRs, issues, etc. A full-fledged contributor's guide will be written, eventually.

Organization

Right now, one can browse everything in nicely highlighted HTML. The basic layout:

  • All code that shouldn't (eventually) be in stdlib is under Categories.
  • If something is some kind of Category, it should be under Category/
  • Instances, i.e. if you say "X is a category", or "X is a functor", go under Instances/
  • Constructions, i.e. if you say "given W then we can build a Category" (or Functor, etc) got under Constructions/
  • Properties that follow from a definition or concept X go under X.Properties
  • The important concepts of Category Theory have their own directories:
    • Adjoint
    • Object
    • Morphism
    • Diagram
    • Functor
    • Kan
    • Yoneda
  • There are sub-directories for:
    • Enriched Categories
    • Minus2 Categories
    • Minus1 Categories
    • Bicategories
    • Bifunctors
  • To be precise, a lot of the usual definitions about categories are under that directory, namely:
    • Complete, Cocomplete
    • Close, Cartesian, CartesianClosed
    • Discrete, Finite
    • Monoidal (it has its own rich hierarchy as well)
    • Product
    • Slice
    • Topos
    • WithFamilies

Naming Conventions

(Some conventions are slowly arising, document them)

  • Some definitions (like that of Category) are in Category.Core, to avoid various kinds of import loops, and re-exported. .Core modules should only be imported if doing otherwise causes an import cycle.
  • Various 'examples' of categories used to be scattered about; these are now gathered together in Category.Instance. More generally, Function.Instance, etc.
  • Various constructions of categories (like the Arrow category of a category) are in Category.Construction. And more generally, Functor.Construction, etc.
  • The basic rule of thumb is that constructions are parametrized over some input in a non-trivial way, whereas instances are not parametrics (like the (large) Category of (small) Categories, the Category of Types and functions, the Category of Setoids, etc.
  • Named modules are often used when multiple structures are in concurrent use; for example, if the 'components' of two categories (say A and B) are used in the same context, then (private) modules A and B are defined for easier access.
  • Components of larger structures use long English names instead of the more usual Categorical 1-Greek-letter short-hands. So unitorl rather than ฮป and associator rather than ฮฑ.

More Repositories

1

agda

Agda is a dependently typed programming language / interactive theorem prover.
Haskell
2,379
star
2

agda-stdlib

The Agda standard library
Agda
556
star
3

cubical

An experimental library for Cubical Agda
Agda
426
star
4

agda2hs

Compiling Agda code to readable Haskell
Agda
167
star
5

agda-frp-js

ECMAScript back end for Functional Reactive Programming in Agda
Agda
100
star
6

agda-language-server

Language Server for Agda
Haskell
95
star
7

agda-frp-ltl

An implementation of Functional Reactive Programming
Agda
41
star
8

agda-ocaml

OCaml backend for Agda
Haskell
39
star
9

agda-pkg

apkg - package manager for Agda
Python
33
star
10

agda-spec

Specification of Agda.
TeX
25
star
11

agda-system-io

Bindings to Haskell's IO monad which respect Agda's semantics
Agda
24
star
12

agda-web-semantic

Agda libraries for the semantic web
Agda
22
star
13

ooAgda

Interactive and object-oriented programming in Agda using coinductive types
Agda
21
star
14

agda-finite-prover

Library for proving propositions quantified over finite sets
Agda
13
star
15

package-index

A package Index for agda libraries
12
star
16

categories-examples

Examples of categorical structures
Agda
11
star
17

agda-assoc-free

An implementation of "Associativity for Free"
9
star
18

agda-base

This is an experimental base library which is supposed to contain functional datastructures and reflection code.
Agda
9
star
19

fix-whitespace

Fixes whitespace issues
Haskell
8
star
20

hs-tags

Generate ctags and etags for Haskell files
Haskell
5
star
21

agda-makefile

An makefile with lightweight dependency management
5
star
22

guarded

Agda
5
star
23

agda-data-bindings

Agda bindings for low-level datatypes such as raw naturals and bytestrings
Agda
5
star
24

agda-web-uri

Simple bindings for parsing, processing and serializing URIs
Haskell
4
star
25

agda-github-syntax-highlighting

Syntax highlighting used on GitHub
Agda
4
star
26

agda-uhc

UHC backend for Agda
Haskell
4
star
27

agda-ghc-names

Tool for making sense of the Haskell code generated by the Agda compiler
Haskell
4
star
28

agda-text-xml

Simple bindings for parsing, processing and serializing XML
3
star