Difference between revisions of "User:Michiexile/MATH198/Lecture 4"

From HaskellWiki
Jump to navigation Jump to search
Line 13: Line 13:
 
This is what we use to define what we want to mean by products in a categorical setting.
 
This is what we use to define what we want to mean by products in a categorical setting.
   
''Definition'' Let <math>C</math> be a category. The ''product'' of two objects <math>A,B</math> is an object <math>A\times B</math> equipped with maps <math>p_1: A\times B\to A</math> and <math>p_2: A\times B\to B</math> such that any other object <math>V</math> with maps <math>A\leftarrow^{q_1} V\rightarrow^{q_2} B</math> has a unique map <math>V\to A\times B</math> such that both maps from <math>V</math> factor through the <math>p_1,p_2</math>.
+
'''Definition''' Let <math>C</math> be a category. The ''product'' of two objects <math>A,B</math> is an object <math>A\times B</math> equipped with maps <math>p_1: A\times B\to A</math> and <math>p_2: A\times B\to B</math> such that any other object <math>V</math> with maps <math>A\leftarrow^{q_1} V\rightarrow^{q_2} B</math> has a unique map <math>V\to A\times B</math> such that both maps from <math>V</math> factor through the <math>p_1,p_2</math>.
   
 
In the category of Set, the unique map from <math>V</math> to <math>A\times B</math> would be given by <math>q(v) = (q_1(v),q_2(v))</math>.
 
In the category of Set, the unique map from <math>V</math> to <math>A\times B</math> would be given by <math>q(v) = (q_1(v),q_2(v))</math>.
Line 25: Line 25:
 
and the projection maps <math>p_1,p_2</math> are just <hask>fst, snd</math>.
 
and the projection maps <math>p_1,p_2</math> are just <hask>fst, snd</math>.
   
  +
Recall from the first lecture, the product construction on categories: objects are pairs of objects, morphisms are pairs of morphisms, identity morphisms are pairs of identity morphisms, and composition is componentwise.
   
  +
This is, in fact, the product construction applied to <math>Cat</math> - or even to <math>CAT</math>: we get functors <math>P_1,P_2</math> picking out the first and second components, and everything works out exactly as in the cases above.
* Cartesian product in Set
 
* Product of categories construction
 
* Record types
 
* Categorical formulation
 
** Universal X such that Y
 
   
 
===Coproduct===
 
===Coproduct===
   
  +
The other thing you can do in a Haskell data type declaration looks like this:
* Diagram definition
 
  +
<haskell>
* Disjoint union in Set
 
* Coproduct of categories construction
+
Coproduct a b = A a | B b
  +
</haskell>
* Union types
 
  +
and the corresponding library type is <hask>Either a b = Left a | Right b</hask>.
   
  +
This type provides us with functions
===Limits and colimits===
 
  +
<haskell>
  +
A :: a -> Coproduct a b
  +
B :: b -> Coproduct a b
  +
</haskell>
  +
and hence looks quite like a dual to the product construction, in that the guaranteed functions the type brings are in the reverse directions from the arrows that the product projection arrows.
   
  +
So, maybe what we want to do is to simply dualize the entire definition?
* Generalizing these constructions
 
* Diagram and universal object mapping to (from) the diagram
 
* Express product/coproduct as limit/colimit
 
* Issues with Haskell
 
** No dependent types
 
** No compiler-enforced equational conditions
 
** Can be ''simulated'' but not enforced, e.g. using QuickCheck.
 
   
  +
'''Definition''' Let <math>C</math> be a category. The ''coproduct'' of two objects <math>A,B</math> is an object <math>A+B</math> equipped with maps <math>i_1:A\to A+B</math> and <math>i_2:B\to A+B</math> such that any other object <math>V</math> with maps <math>A\rightarrow_{v_1} V \leftarrow_{v_2} B</math> has a unique map <math>v:A+B\to V</math> such that <math>v_1 = v i_1</math> and <math>v_2 = v i_2</math>.
====Useful limits and colimits====
 
   
  +
In the Haskell case, the maps <math>i_1,i_2</math> are the type constructors <math>A, B</math>. And indeed, this Coproduct, the union type construction, is the type which guarantees inclusion of source types, but with minimal additional assumptions on the type.
=====Equalizer, coequalizer=====
 
   
  +
In the category of sets, the coproduct construction is one where we can embed both sets into the coproduct, faithfully, and the result has no additional structure beyond that. Thus, the coproduct in set, is the disjoint union of the included sets: both sets are included without identifications made, and no extra elements are introduced.
* Kernels, cokernels, images, coimages
 
** connect to linear algebra: null spaces et.c.
 
   
=====Pushout and pullback squares=====
 
   
* Computer science applications
 
   
 
* Diagram definition
* The power of dualization.
 
 
* Disjoint union in Set
* Limits, colimits.
 
 
* Coproduct of categories construction
* Products, coproducts.
 
 
* Union types
* Equalizers, coequalizers.</hask>
 

Revision as of 02:37, 8 October 2009

IMPORTANT NOTE: THESE NOTES ARE STILL UNDER DEVELOPMENT. PLEASE WAIT UNTIL AFTER THE LECTURE WITH HANDING ANYTHING IN, OR TREATING THE NOTES AS READY TO READ.

Product

Recall the construction of a cartesian product: for sets , the set .

The cartesian product is one of the canonical ways to combine sets with each other. This is how we build binary operations, and higher ones - as well as how we formally define functions, partial functions and relations in the first place.

This, too, is how we construct vector spaces: recall that is built out of tuples of elements from , with pointwise operations. This constructions reoccurs all over the place - sets with structure almost always have the structure carry over to products by pointwise operations.

Given the cartesian product in sets, the important thing about the product is that we can extract both parts, and doing so preserves any structure present, since the structure is defined pointwise.

This is what we use to define what we want to mean by products in a categorical setting.

Definition Let be a category. The product of two objects is an object equipped with maps and such that any other object with maps has a unique map such that both maps from factor through the .

In the category of Set, the unique map from to would be given by .

The uniqueness requirement is what, in the theoretical setting, forces the product to be what we expect it to be - pairing of elements with no additional changes, preserving as much of the structure as we possibly can make it preserve.

In the Haskell category, the product is simply the Pair type:

Product a b = (a,b)

and the projection maps are just fst, snd</math>. Recall from the first lecture, the product construction on categories: objects are pairs of objects, morphisms are pairs of morphisms, identity morphisms are pairs of identity morphisms, and composition is componentwise. This is, in fact, the product construction applied to <math>Cat</math> - or even to <math>CAT</math>: we get functors <math>P_1,P_2</math> picking out the first and second components, and everything works out exactly as in the cases above. ===Coproduct=== The other thing you can do in a Haskell data type declaration looks like this: <haskell> Coproduct a b = A a | B b </haskell> and the corresponding library type is <hask>Either a b = Left a | Right b.

This type provides us with functions

A :: a -> Coproduct a b
B :: b -> Coproduct a b

and hence looks quite like a dual to the product construction, in that the guaranteed functions the type brings are in the reverse directions from the arrows that the product projection arrows.

So, maybe what we want to do is to simply dualize the entire definition?

Definition Let be a category. The coproduct of two objects is an object equipped with maps and such that any other object with maps has a unique map such that and .

In the Haskell case, the maps are the type constructors . And indeed, this Coproduct, the union type construction, is the type which guarantees inclusion of source types, but with minimal additional assumptions on the type.

In the category of sets, the coproduct construction is one where we can embed both sets into the coproduct, faithfully, and the result has no additional structure beyond that. Thus, the coproduct in set, is the disjoint union of the included sets: both sets are included without identifications made, and no extra elements are introduced.


  • Diagram definition
  • Disjoint union in Set
  • Coproduct of categories construction
  • Union types