Skip to content

bheuer/CategoryProject

Repository files navigation

Welcome to the CategoryProject!

The Category Project is an attempt to write a 'Category Theory Solver', that is a device that can manipulate diagrams obeying the rules of category theory.

We have all been there: You play around in algebraic geometry and suddenly you find yourself wondering whether, given a cube three faces of which are fiber products, the fourth face is necessarily a fiber product as well. While you draw lots of diagrams and apply universal properties of objects and subdiagrams you wonder why you can't give all these mechanical calculation to a computer. Computers can prove hard theorems and do all sorts of funny stuff to elliptic curves nowadays - why shouldn't they be able to do the category theory for you?

The Category Theory Project is an attempt to do this for you. It provides functionaliy to

  • create Diagrams in certain Categories
  • add Objects and Morphisms to these Diagrams
  • talk about commutativity of Morphisms
  • give Objects, Morphisms and Subdiagrams Properties, like "A->P<-B is a Product".
  • talk about Rules that manipulate diagrams, like the existence or uniqueness of morphisms etc
  • deduce features of your diagram by applying these rules
  • manage Rules in such a way that they are applied in a sensible order, ie prioritising "interesting" features over "less interesting" ones

In all this, the Category Theory Project has a focus on being user-friendly and open to customisation:

  • user input is simple intuitive
  • there is LaTeX input/output support, so you can just read a diagram from your TeX file into the solver
  • there are easy-to-use interfaces for writing own Properties and Rules, which can be applied immediately

At the moment, the Category Theory Project has implemented products, coproducts, fibre products, monomorphisms, epimorphisms, kernels, cokernels, images, abelian categories and exactness. It shouldn't require too much work to add your own Property and Rule to the list.

Initially, the goal of the Category Theory Project was to being so good at abelian categories, that it would "kill" them. We therefore named it Cain, because it's supposed to kill Abel. However, as it turns out, abelian categories are hard and we can't even do the snake lemma because of complexity issues. So right now, our project is killed by abelian categories. Consequently, at it's current state it is called CoCain.

Usage

Here is a very short tutorial.

** If you are in a hurry, just look in the file test.py for lots of examples! **

You can use CoCain from the command line as well as from inside your own python file. When you are in the CategoryProject folder, just type

from cocain import *

to import pretty much everything you want from cocain. Then you can just type the following:

from cocain import *

D = Diagram()

A = Object(D,"A")
B = Object(D,"B")

f = Morphism(A,B,"f")

print D

You have created your first diagram! You can add Properties as follows:

P = Object(D,"P")

pi1 = Morphism(P,A,"pi1")
pi2 = Morphism(P,B,"pi2")

ProductProperty(pi1,pi2)

Now let's try to proof something: Lets create a diagram which looks like this:

            V
          /   \
         |     |
         |  P  |      product
         | / \ |
         |/   \|
         A     B

and prove that there is a natural map V->P. In order to do so, we need to apply rules. This is done by invoking a RuleMaster:

from cocain import *

D = Diagram()

A = Object(D,"A")
B = Object(D,"B")
P = Object(D,"P")
V = Object(D,"V")
  
pi1 = Morphism(P,A,"pi1")
pi2 = Morphism(P,B,"pi2")

f = Morphism(V,P,"f")
g = Morphism(V,P,"g")
  
ProductProperty(pi1,pi2)

RM = RuleMaster(D)

Commute(pi2*f,pi2*g)
RM.rule_exhaustively()

print D

Now let's prove our first little Lemma: The tower of two Cartesian diagrams (aka fibre products) is again a Cartesian diagram. To do so, we have to show existence and uniqueness. Here is how to prove uniqueness:

from cocain import *
'''
      T
  m,m2 \\  f   g
    	A -- B -- C
      h |   i|   j|
    	|    |    |
    	D -- E -- F
    	  k    l
'''
A=Object(CD,"A")
B=Object(CD,"B")
C=Object(CD,"C")
D=Object(CD,"D")
E=Object(CD,"E")
F=Object(CD,"F")
T=Object(CD,"T")
    	
f=Morphism(A,B,"f")
g=Morphism(B,C,"g")
h=Morphism(A,D,"h")
i=Morphism(B,E,"i")
j=Morphism(C,F,"j")
k=Morphism(D,E,"k")
l=Morphism(E,F,"l")

Commute(k*h,i*f)
Commute(l*i,j*g)
FibreProductProperty(h,f,k,i)
FibreProductProperty(i,g,l,j)

m=Morphism(T,A)
m2=Morphism(T,A)
Commute(h*m,h*m2)
Commute(f*m,f*m2)

RM = RuleMaster(CD,Rules = [FibreProductRuleUnique])
    
assert l*k*h==j*g*f
assert m!=m2
RM.rule_exhaustively()
assert m==m2

Look at the file test.py for many, many more examples!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages