Professional Documents
Culture Documents
We are now using the notation f ∘ g for compositions and using an actual
arrow “→” for functions. I thought the prior raising the “ ∘” was an issue
with the Consolas font.
Basic definitions
Before we define categories, we need a shitty definition we can
build upon.
- 1) source(fk)=x
- 2) target(fi)=source(fi-1) for i=2,...,k
- 3) target(f1)=y
Paths
By convention, for each node x there is a unique path of length 0
from x to x that is denoted (). It is called the empty path at x.
With the arrows going from left to right, fk will be on the left
and the subscripts will go down from left to right. We do it this
way for consistency with composition.
For any arrow f, (f) is a path length of one (because it’s just
one arrow duh).
Note on paths
We directly refer to paths as the actual parentheses they
symbolize
In the diagram above, there is just one path of any natural
number length from n to n, namely () then the number of
loops ( (succ),(succ,succ),(succ,succ,succ) and so on ).
The set of paths
The set of paths of length k in a graph is denoted G k.
Similarly, the number of empty paths is pretty much one for each
node, so G0 can refer to both. If there were an object that
required the composition of two arrows, we could pretty much refer
to it the same as an element of a set G2 (illustrated next panel)
illustrated
Compare the use of ‘2’ to denote either the integer or the real number
(they are in parallel spaces and often mean the same thing). One might
want to keep the two meanings of G1 separate for purposes of
implementing a graph as a data structure.
Category
A category is a graph C together with two functions c: C 2→C1 and u: C0→C1.
The elements of C0 are called objects and those of C1 are called arrows.
Domain: source
Codomain: target
Again, a set of the form Hom(A,B) is called a Hom set. Other common
notations for Hom(A,B) are C(A,B) and C(AB).
continued
-the reference to the set of all arrows from A to B assumes
that the arrows do in fact form a set. A category with the
property that Hom(A,B) is a set for all objects A and B is
called locally small.
Path definitions
-for any path (f1,f2,...,fn) in a category C, f1 ∘ f2 ∘ … ∘
fn is defined recursively by
The statements that this is a category amounts to the statements that composition of
functions is associative (C-2) and that identity function id s:S→S satisfies f∘ids=f
and ids∘g=g for all f with source S and all g with target S (C-4)
The axioms of a category are met by composition of functions being associative. The
fact that composition of arrows is associative follows by using the definition of
composition repeatedly:
A-1: We assume there is a “do nothing” operation idA for each type A (primitive and
constructed). When applied, it does nothing to the data[1]
A-2: We add to the language an additional type called 1, which has the property that
from every type A there is a unique operation to 1. We interpret each constant c of type A
as an arrow c:1→A (note that we aren’t talking about the number 1. ‘1’ is a value that
occurs in strings, floats, integers, and Booleans). The operation defines the constant, and
as such it’s no longer separate data
A-3: We assume the language has a composition constructor: take an operation f that
takes something of type A as input and produces something of type B (so like float to
integer for example), and another operation g that has input of type B and output of type C
(such as from integer to string or integer to Boolean). The doing one after the other is a
derived operation (or program) typically denoted f;g, which has input of type A and output
of type C[2]
[1] See what we are doing here? We are treating the data type as the object and the data as in the data type, which makes sense- a string is an element of the type
“string”. And this “do nothing” operation is required for categories and is how categories derive objects/types from arrows
[2] So this serves as the equivalent of the composition function requirement for a category
relating these rules to composition
-as we just stated, functional programming languages generally
have do-nothing operations and composition constructors. A-1
and A-3 fit the concepts that they would in defining a
category (C-3 and C-1 respectively). The language resulting
from A-2 is operationally equivalent to the original language.
iii) CHAR should have on constant c:1→CHAR for each desired character c
The objects are the types and constants: NAT, BOOLEAN, CHAR, and
1 (observe that typing is a natural part of the syntax in this
approach)
further continued
The arrows of C(L), which includes all of the possible permutations of
compositions, consists of all programs, with two programs being identified
if they must be the same because of the equations. For example, the arrow
chr∘succ∘ord:CHAR→CHAR
chr∘succ∘ord∘chr∘ord:CHAR→CHAR
ord∘(chr∘succ∘ord)=ord∘(chr∘succ∘ord∘chr∘ord)
We say that α is reflexive if xαx for all x∈S and transitive if xαy and yαz implies
xαz for all x,y,z∈S.
A set S with a reflexive, transitive nature relation α on it is a structure (S,α)
called a preordered set. This structure determines a category C(S,α) defined as
follows.
CO-2: If x,y ∈ S and xαy, then C(S,α) has exactly one arrow from x to y, denoted
(y,x) (this choice of notation is odd but fits the right-to-left composition we use.
The domain of (y,x) is x and the codomain is y)
α={<C,C>,<C,D>,<D,D>}
Is the category 2:
Ordered sets
A preordered set (S,α) for which α is antisymmetric (that
is, xαy and yαx imply x=y) is called an ordered set or
poset (for ‘partially ordered set’).
(a,b,d,a)(c,a,b)=(a,b,d,a,c,a,b)
-the natural numbers with addition form a submonoid of the integers with
addition. The integers with multiplication as the operation, so that 1 is the
identity element, is also submonoid of it. So do the natural numbers, and the
set of positive natural numbers- the product of two positive numbers is another
one.
-the singleton set {0} is a subset of the integers that is closed under
multiplication, is a monoid, but is not a submonoid of the integers on
multiplication, because it does not contain the identity element 1.
Monoids as categories
Any monoid M determines a category C(M):
CM-1: C(M) has one object designated “*” and this object can be chosen
arbitrarily. A single uniform choice is to take *=M
CM-2: The arrows of C(M) are the elements of M with * as source and target
CM-3: Composition is the binary operation on M [ILLUSTRATE]