SlideShare une entreprise Scribd logo
1  sur  23
Formal Methods in
Software
Lecture 7. Category Theory
Vlad Patryshev
SCU
2014
In This Lecture
• database example
• terminal object, initial object;
• products, unions
• equalizers
• pullbacks
Database Example
create type rels as enum (‘spouse’, ‘child’, ‘partner’);
create type jobs as enum (‘ceo’, ‘cto’, ‘eng’, ‘sales’);
create table Person (id bigint, name varchar(80), primary key (id));
create table Company (id bigint, name varchar(80), primary key (id));
create table Rel (from bigint, to bigint, kind rels,
constraint p1_fk foreign key (from references Person(id),
constraint p2_fk foreign key (yo references Person(id)
);
create table Job (company bigint, employee bigint, position jobs,
constraint c_fk foreign key (comp references Company(id),
constraint p_fk foreign key (pers references Person(id)
);
“Conceptual Model”
Person
id
name
Company
id
name
Job
position
company
employee
Relationship
kind
from
to
rels
{spouse,
child,
partner}
jobs
{ceo, cto,
eng, sales}
“More Conceptual Model”
Person
name
Company
name
Job
Relationship
rels
{spouse,
child,
partner}
jobs
{ceo, cto,
eng, sales}
“More Conceptual Model”
Person
name
Company
name
Job
Relationship
rels
{spouse,
child,
partner}
jobs
{ceo, cto,
eng, sales}
It’s a category!
Pet Database
create type kind as enum (‘cat’, ‘dog’, ‘fly’, ‘hamster’, ‘e.coli’);
create table Person (id bigint, name varchar(80), pet bigint,
primary key (id),
constraint pet_fk foreign key (pet references Animal(id));
create table Animal (id bigint, kind kind, name varchar(80), owner
bigint,
primary key (id),
constraint owner_pk foreign key owner references Person(id));
“More Conceptual Model”
Person
name
Animal
kind
{cat, dog,
fly, hamster,
e.coli}
Where’s composition?
kind(pet(owner(pet(“John”)))
select kind from Animal a where a.owner
in (select id from Person where pet in
(select id from Animal where owner in
(select id from person where
name=’John’)));
Initial Object in a Category
Definition. Given a category C, Initial Object is such an object 0 that there is
a unique function iX:0 → X for any given X. (this is its “universal property”)
Note that if we take X=0, we see that there is just one function 0 → 0. Can
you name a set (or two) with only one function S→S?
And what if there’s more than one such an object? Say 01 and 02, both have
this interesting feature. Then, for 01, we have a unique a:01 → 02; and
similarly we have a unique b:02 → 01. Composing a and b either way, we
get an identity; so they are isomorphisms.
Initial object is unique up to an isomorphism.
Examples of Initial Objects
• Sets: ∅, and it is unique (by sets axioms)
• Monoids: {0} - all “such monoids” are isomorphic
• Categories: empty category (whether there’s a plurality of them…)
• In this category of three objects we see no initial object:
• In this category c is initial object:
• How about more than one
initial object?
They are
isomorphic!
Terminal Object in a Category
Definition. Given a category C, Terminal Object is such an object 1 that
there is a unique function uX:X → 1 for any given X. (this is its “universal
property”)
Note that if we take X=1, we see that there is just one function 1 → 1, same
as with 0.
And what if there’s more than one such an object? Say 11 and 12, both have
this interesting feature. Then, for 11, we have a unique a:11 → 12; and
similarly we have a unique b:12 → 11. Composing a and b either way, we
get an identity; so they are isomorphisms.
Terminal object, like initial one, is unique up to an isomorphism.
Examples of Terminal Objects
• Sets: any singleton {x} is terminal. They are not equal, but are isomorphic.
• Monoids: {0} - all “such monoids” are isomorphic
• Categories: empty category (whether there’s a plurality of them…)
• In this category of three objects we see no terminal object:
• In this category c is terminal object:
Initial and Terminal Object in our DB
terminal
Cartesian Product
Definition. Given a category C, and two objects in it, X and Y, their Cartesian
Product is such an object Z=X×Y, together with two functions, pX:Z→X and
pY:Z→Y, that for any pair f:A→X and g:A→Y, f=pX∘h and g=pY∘h for some
unique h. (this is its “universal property”)
Cartesian product is unique up to an isomorphism. (proof?)
Examples of Cartesian Products
• Sets: AxB = {(a,b)|a∈A,b∈B}, and it is unique (by sets axioms)
• Databases: select * from A,B;
• Good programming languages, e.g. Scala: (A,B)
val intWithString: (Int, String) = (42, “Hello 42”)
• In a monoid? We have just one object!
• In a poset? It’s min(a,b)
Disjoint Union (dual to Product)
Definition. Given a category C, and two objects in it, X and Y, their Disjoint
Union is such an object Z=X+Y, together with two functions, iX:X→Z and
iY:Y→Z, that for any pair f:X→A and g:Y→A, f=h∘iX and g=h∘iY for some
unique h. (this is its “universal property”)
Disjoint union is unique up to an isomorphism. (proof?)
Examples of Disjoint Unions
• Sets: A+B = A∪B, and it is unique (by sets axioms)
• Databases: select * from A union B;
• Good programming languages, e.g. Scala: Either[A,B]
val intOrString: Either[Int, String] = Left(42)// Right(“Hello 42”)
• In a poset? It’s max(a,b)
Equalizers
Definition. Given a category C, two objects in it, X and Y, and two functions,
f,g:X→Y, their Equalizer is such an object E=Eq(f,g), together with a
function eq:E→X, such that that f∘eq=g∘eq for any m:O→X, m=eq∘u for
some unique u. (this is its “universal property”)
An equalizer is unique up to an isomorphism. (proof?)
Pullbacks
Definition. Given a category C, objects, X, Y and Z, and two functions,
f:X→Z and g:X→Z, their Pullback is such an object X×ZY, together with
functions pX:X×ZY→X and pY:X×ZY→Y, such that g∘pY = f∘pX, and for any
pair x:U→X, y:U→Y, x=pX∘h and y=pY∘h for some unique h. (this is its
“universal property”)
A pullback is unique up to an isomorphism. (proof?)
Examples of Pullbacks
• Sets: {(x,y)|x∈X,y∈Y,f(x)=g(y)}
• Databases: select * from A, B where A.f=B.g;
e.g. select * from Person A, Person B where A.pet=B.pet;
• In a poset? Same as min.
• Cartesian products are pullbacks.
References
http://www.amazon.com/Category-Computer-Scientists-Foundations-Computing/dp/0262660717
Wikipedia
Formal methods   7 - category theory

Contenu connexe

Tendances

Bayesian Methods for Machine Learning
Bayesian Methods for Machine LearningBayesian Methods for Machine Learning
Bayesian Methods for Machine Learning
butest
 
كتيب ملخصات دروس للرياضيات السنة الثانية ثانوي 2
كتيب   ملخصات دروس للرياضيات السنة الثانية ثانوي 2كتيب   ملخصات دروس للرياضيات السنة الثانية ثانوي 2
كتيب ملخصات دروس للرياضيات السنة الثانية ثانوي 2
math44
 

Tendances (11)

Programming haskell chapter10
Programming haskell chapter10Programming haskell chapter10
Programming haskell chapter10
 
5
55
5
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Functional and Algebraic Domain Modeling
Functional and Algebraic Domain ModelingFunctional and Algebraic Domain Modeling
Functional and Algebraic Domain Modeling
 
Nested loop
Nested loopNested loop
Nested loop
 
Bayesian Methods for Machine Learning
Bayesian Methods for Machine LearningBayesian Methods for Machine Learning
Bayesian Methods for Machine Learning
 
Architectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsArchitectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain Models
 
Application of ordinal logistic to pregnancy outcomes
Application of ordinal logistic to pregnancy outcomesApplication of ordinal logistic to pregnancy outcomes
Application of ordinal logistic to pregnancy outcomes
 
Cats in Scala
Cats in ScalaCats in Scala
Cats in Scala
 
كتيب ملخصات دروس للرياضيات السنة الثانية ثانوي 2
كتيب   ملخصات دروس للرياضيات السنة الثانية ثانوي 2كتيب   ملخصات دروس للرياضيات السنة الثانية ثانوي 2
كتيب ملخصات دروس للرياضيات السنة الثانية ثانوي 2
 

En vedette (9)

Introduction to formal methods
Introduction to formal methodsIntroduction to formal methods
Introduction to formal methods
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
 
Agile Software Development Overview
Agile Software Development OverviewAgile Software Development Overview
Agile Software Development Overview
 
Z specification
Z specificationZ specification
Z specification
 
Formal Verification Techniques
Formal Verification TechniquesFormal Verification Techniques
Formal Verification Techniques
 
Formal Methods lecture 01
Formal Methods lecture 01Formal Methods lecture 01
Formal Methods lecture 01
 
Formal Methods
Formal MethodsFormal Methods
Formal Methods
 
#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering#1 formal methods – introduction for software engineering
#1 formal methods – introduction for software engineering
 
Formal verification
Formal verificationFormal verification
Formal verification
 

Similaire à Formal methods 7 - category theory

Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
Bryan O'Sullivan
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
Meetu Maltiar
 

Similaire à Formal methods 7 - category theory (20)

ECMA 入门
ECMA 入门ECMA 入门
ECMA 入门
 
Intoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryIntoduction to Homotopy Type Therory
Intoduction to Homotopy Type Therory
 
It Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaIt Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in Java
 
What can scala puzzlers teach us
What can scala puzzlers teach usWhat can scala puzzlers teach us
What can scala puzzlers teach us
 
Elements of functional programming
Elements of functional programmingElements of functional programming
Elements of functional programming
 
Sets, functions and groups
Sets, functions and groupsSets, functions and groups
Sets, functions and groups
 
Absolute and Relative Clustering
Absolute and Relative ClusteringAbsolute and Relative Clustering
Absolute and Relative Clustering
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
 
Prolog2 (1)
Prolog2 (1)Prolog2 (1)
Prolog2 (1)
 
Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
 
Propositional Logic and Pridicate logic
Propositional Logic and Pridicate logicPropositional Logic and Pridicate logic
Propositional Logic and Pridicate logic
 
Python speleology
Python speleologyPython speleology
Python speleology
 
Category Theory in 10 Minutes
Category Theory in 10 MinutesCategory Theory in 10 Minutes
Category Theory in 10 Minutes
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
 
Dm2021 binary operations
Dm2021 binary operationsDm2021 binary operations
Dm2021 binary operations
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 

Plus de Vlad Patryshev

Plus de Vlad Patryshev (20)

Formal methods 8 - category theory (last one)
Formal methods   8 - category theory (last one)Formal methods   8 - category theory (last one)
Formal methods 8 - category theory (last one)
 
Formal methods 5 - Pi calculus
Formal methods   5 - Pi calculusFormal methods   5 - Pi calculus
Formal methods 5 - Pi calculus
 
Formal methods 3 - languages and machines
Formal methods   3 - languages and machinesFormal methods   3 - languages and machines
Formal methods 3 - languages and machines
 
Formal methods 2 - languages and machines
Formal methods   2 - languages and machinesFormal methods   2 - languages and machines
Formal methods 2 - languages and machines
 
Formal methods 1 - introduction
Formal methods   1 - introductionFormal methods   1 - introduction
Formal methods 1 - introduction
 
Truth, deduction, computation lecture i (last one)
Truth, deduction, computation   lecture i (last one)Truth, deduction, computation   lecture i (last one)
Truth, deduction, computation lecture i (last one)
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture h
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
 
Truth, deduction, computation lecture f
Truth, deduction, computation   lecture fTruth, deduction, computation   lecture f
Truth, deduction, computation lecture f
 
Truth, deduction, computation lecture e
Truth, deduction, computation   lecture eTruth, deduction, computation   lecture e
Truth, deduction, computation lecture e
 
Truth, deduction, computation lecture d
Truth, deduction, computation   lecture dTruth, deduction, computation   lecture d
Truth, deduction, computation lecture d
 
Truth, deduction, computation lecture c
Truth, deduction, computation   lecture cTruth, deduction, computation   lecture c
Truth, deduction, computation lecture c
 
Truth, deduction, computation lecture b
Truth, deduction, computation   lecture bTruth, deduction, computation   lecture b
Truth, deduction, computation lecture b
 
Truth, deduction, computation lecture a
Truth, deduction, computation   lecture aTruth, deduction, computation   lecture a
Truth, deduction, computation lecture a
 
Truth, deduction, computation lecture 9
Truth, deduction, computation   lecture 9Truth, deduction, computation   lecture 9
Truth, deduction, computation lecture 9
 
Truth, deduction, computation lecture 8
Truth, deduction, computation   lecture 8Truth, deduction, computation   lecture 8
Truth, deduction, computation lecture 8
 
Truth, deduction, computation lecture 7
Truth, deduction, computation   lecture 7Truth, deduction, computation   lecture 7
Truth, deduction, computation lecture 7
 
Truth, deduction, computation lecture 6
Truth, deduction, computation   lecture 6Truth, deduction, computation   lecture 6
Truth, deduction, computation lecture 6
 
Truth, deduction, computation; lecture 5
Truth, deduction, computation;  lecture 5Truth, deduction, computation;  lecture 5
Truth, deduction, computation; lecture 5
 
Truth, deduction, computation; lecture 4
Truth, deduction, computation;  lecture 4Truth, deduction, computation;  lecture 4
Truth, deduction, computation; lecture 4
 

Dernier

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Dernier (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Formal methods 7 - category theory

  • 1. Formal Methods in Software Lecture 7. Category Theory Vlad Patryshev SCU 2014
  • 2. In This Lecture • database example • terminal object, initial object; • products, unions • equalizers • pullbacks
  • 3. Database Example create type rels as enum (‘spouse’, ‘child’, ‘partner’); create type jobs as enum (‘ceo’, ‘cto’, ‘eng’, ‘sales’); create table Person (id bigint, name varchar(80), primary key (id)); create table Company (id bigint, name varchar(80), primary key (id)); create table Rel (from bigint, to bigint, kind rels, constraint p1_fk foreign key (from references Person(id), constraint p2_fk foreign key (yo references Person(id) ); create table Job (company bigint, employee bigint, position jobs, constraint c_fk foreign key (comp references Company(id), constraint p_fk foreign key (pers references Person(id) );
  • 7. Pet Database create type kind as enum (‘cat’, ‘dog’, ‘fly’, ‘hamster’, ‘e.coli’); create table Person (id bigint, name varchar(80), pet bigint, primary key (id), constraint pet_fk foreign key (pet references Animal(id)); create table Animal (id bigint, kind kind, name varchar(80), owner bigint, primary key (id), constraint owner_pk foreign key owner references Person(id));
  • 8. “More Conceptual Model” Person name Animal kind {cat, dog, fly, hamster, e.coli} Where’s composition? kind(pet(owner(pet(“John”))) select kind from Animal a where a.owner in (select id from Person where pet in (select id from Animal where owner in (select id from person where name=’John’)));
  • 9. Initial Object in a Category Definition. Given a category C, Initial Object is such an object 0 that there is a unique function iX:0 → X for any given X. (this is its “universal property”) Note that if we take X=0, we see that there is just one function 0 → 0. Can you name a set (or two) with only one function S→S? And what if there’s more than one such an object? Say 01 and 02, both have this interesting feature. Then, for 01, we have a unique a:01 → 02; and similarly we have a unique b:02 → 01. Composing a and b either way, we get an identity; so they are isomorphisms. Initial object is unique up to an isomorphism.
  • 10. Examples of Initial Objects • Sets: ∅, and it is unique (by sets axioms) • Monoids: {0} - all “such monoids” are isomorphic • Categories: empty category (whether there’s a plurality of them…) • In this category of three objects we see no initial object: • In this category c is initial object: • How about more than one initial object? They are isomorphic!
  • 11. Terminal Object in a Category Definition. Given a category C, Terminal Object is such an object 1 that there is a unique function uX:X → 1 for any given X. (this is its “universal property”) Note that if we take X=1, we see that there is just one function 1 → 1, same as with 0. And what if there’s more than one such an object? Say 11 and 12, both have this interesting feature. Then, for 11, we have a unique a:11 → 12; and similarly we have a unique b:12 → 11. Composing a and b either way, we get an identity; so they are isomorphisms. Terminal object, like initial one, is unique up to an isomorphism.
  • 12. Examples of Terminal Objects • Sets: any singleton {x} is terminal. They are not equal, but are isomorphic. • Monoids: {0} - all “such monoids” are isomorphic • Categories: empty category (whether there’s a plurality of them…) • In this category of three objects we see no terminal object: • In this category c is terminal object:
  • 13. Initial and Terminal Object in our DB terminal
  • 14. Cartesian Product Definition. Given a category C, and two objects in it, X and Y, their Cartesian Product is such an object Z=X×Y, together with two functions, pX:Z→X and pY:Z→Y, that for any pair f:A→X and g:A→Y, f=pX∘h and g=pY∘h for some unique h. (this is its “universal property”) Cartesian product is unique up to an isomorphism. (proof?)
  • 15. Examples of Cartesian Products • Sets: AxB = {(a,b)|a∈A,b∈B}, and it is unique (by sets axioms) • Databases: select * from A,B; • Good programming languages, e.g. Scala: (A,B) val intWithString: (Int, String) = (42, “Hello 42”) • In a monoid? We have just one object! • In a poset? It’s min(a,b)
  • 16.
  • 17. Disjoint Union (dual to Product) Definition. Given a category C, and two objects in it, X and Y, their Disjoint Union is such an object Z=X+Y, together with two functions, iX:X→Z and iY:Y→Z, that for any pair f:X→A and g:Y→A, f=h∘iX and g=h∘iY for some unique h. (this is its “universal property”) Disjoint union is unique up to an isomorphism. (proof?)
  • 18. Examples of Disjoint Unions • Sets: A+B = A∪B, and it is unique (by sets axioms) • Databases: select * from A union B; • Good programming languages, e.g. Scala: Either[A,B] val intOrString: Either[Int, String] = Left(42)// Right(“Hello 42”) • In a poset? It’s max(a,b)
  • 19. Equalizers Definition. Given a category C, two objects in it, X and Y, and two functions, f,g:X→Y, their Equalizer is such an object E=Eq(f,g), together with a function eq:E→X, such that that f∘eq=g∘eq for any m:O→X, m=eq∘u for some unique u. (this is its “universal property”) An equalizer is unique up to an isomorphism. (proof?)
  • 20. Pullbacks Definition. Given a category C, objects, X, Y and Z, and two functions, f:X→Z and g:X→Z, their Pullback is such an object X×ZY, together with functions pX:X×ZY→X and pY:X×ZY→Y, such that g∘pY = f∘pX, and for any pair x:U→X, y:U→Y, x=pX∘h and y=pY∘h for some unique h. (this is its “universal property”) A pullback is unique up to an isomorphism. (proof?)
  • 21. Examples of Pullbacks • Sets: {(x,y)|x∈X,y∈Y,f(x)=g(y)} • Databases: select * from A, B where A.f=B.g; e.g. select * from Person A, Person B where A.pet=B.pet; • In a poset? Same as min. • Cartesian products are pullbacks.