SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
Formal Methods in
Software
Lecture 8. Category Theory
Vlad Patryshev
SCU
2014
In This Lecture
● functors and examples (diagrams; product; exponentiations);
● currying/yoneda lemma;
● example with integers/rationals;
● monad
Example: Parametric Class
trait List[A] extends Iterable[A] {
def map[A](f:A=>B):List[B]
}
Functor
Given categories A and B, a functor F: A → B
consists of mappings F: Obj(A) → Obj(B)
and F: Fun(A) → Fun(B) ,
so that
F(idX
)=idF(X)
and F(f∘g)=F(f)∘F(g)
More Examples
● A= 3 , B=Sets; what is a functor 3 → Sets?
Have to define: sets F(0), F(1), F(2); functions F(f), F(g), F(gf)
● Any f:X→Y in category C is a functor from 2 to C.
Cartesian Product is a Functor
Fix an object A.
X ↦ X×A is a functor.
How does it work on functions?
f:X→Y ↦ f×idA
: X×A → Y×A
+1 is a Functor
In Sets, take X ↦ X+1. f: X→Y ↦ (f+1): X+1 → Y+1
This functor is called Option[T].
Category of Categories
Take functors F:A→B, G:B→C; their composition H=G∘F is also a functor.
H(idX
) = G(F(idX
)) = G(idF(X)
) = idG(F(X))
H(p∘q) = G(F(p∘q)) = G(F(p)∘F(q)) = G(F(p)) ∘G(F(q)) = H(p) ∘H(q)
Identity functor IdA
:A→A Id(f) = f
Cat - a category of all categories.
No barber problems, nobody shaves nobody.
Exponential Functor
A, B - objects in category C. BA
- an object of functions from A to B, if such
exists.
E.g. in Set, {f:A→B}.
In Scala In Java (Guava) (https://code.google.com/p/guava-
libraries/wiki/FunctionalExplained)
trait Function[X,Y] {
def apply(x:X): Y
}
interface Function<X,Y> {
Y apply(X x);
}
val len:Function[String, Int] = _.length Function<String, Integer> lengthFunction = new
Function<String, Integer>() {
public Integer apply(String string) {
return string.length();
}
};
Define Exponential via Currying
In Set, f:A→CB
≡ f’:A×B→C
f(x)(b) = f’(x,b)
Very similar to P⊢(Q→R) ≡ P∧Q ⊢ R
Actually… it’s the same thing.
Take posets, for example, Boolean lattice,
where a×b ≡ min(a,b) /*see lecture 7*/ ≡ a∧b
a∧b ≤ c ≡ a ≤ (b→c)
Currying: Yoneda Lemma
Fun(A×B, C) ≡ Fun(A, CB
)
(Caveat: what is Fun? A set? It’s not always available as a set)
Example with Numbers
Category Z = (Z,≤); category Q = (Q,≤)
Inclusion iz
: Z ↣ Q - preserves order, so is a functor.
How about Q → Z? Upb: q ↦ Upb(q)
Upb(q) ≤ n /* this is in Z */ ≡ q ≤ n /* this is in Q */
Take composition q ↦ iZ
(Upb(q)), call it Mint.
We see two properties:
● q ≤ Mint(q)
● Mint(Mint(q)) ≤ Mint(q) /* actually equal */
Example with Lists
Category Scala
Take functor List.
We see two properties:
● singleton: X → List[X]
● flatten: List[List[X]] → List[X]
Do you see similarity?
Monad
* f:F(X)->G(X) is natural if for all p:X→ Y
Given a category C, an endofunctor M: C → C
is called a Monad if it has two features:
● unitX
: X → M(X)
● flattenX
: M(M(X)) → M(X)
These two functions should be natural*
References
http://www.amazon.com/Category-Computer-Scientists-Foundations-Computing/dp/0262660717
http://fundeps.com/tables/FromSemigroupToMonads.pdf
Wikipedia
Formal methods   8 - category theory (last one)

Más contenido relacionado

La actualidad más candente

Advanced matlab codigos matematicos
Advanced matlab codigos matematicosAdvanced matlab codigos matematicos
Advanced matlab codigos matematicosKmilo Bolaños
 
Automatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesAutomatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesTomasz Kusmierczyk
 
Abstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAbstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAshwin Rao
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a categorysamthemonad
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskellLuca Molteni
 
mathematical functions
mathematical functions mathematical functions
mathematical functions Anshul gour
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskellfaradjpour
 
Refresher algebra-calculus
Refresher algebra-calculusRefresher algebra-calculus
Refresher algebra-calculusSteve Nouri
 
3.2 Derivative as a Function
3.2 Derivative as a Function3.2 Derivative as a Function
3.2 Derivative as a Functiongregcross22
 
Reading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsReading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsKeisuke OTAKI
 
Functionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleFunctionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleShiwani Gupta
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Philip Schwarz
 
Integration+using+u-substitutions
Integration+using+u-substitutionsIntegration+using+u-substitutions
Integration+using+u-substitutionstutorcircle1
 
Rules of Derivative
Rules of Derivative Rules of Derivative
Rules of Derivative Alishba Saeed
 
Website designing company in delhi ncr
Website designing company in delhi ncrWebsite designing company in delhi ncr
Website designing company in delhi ncrCss Founder
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learningSteve Nouri
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdfAmir Saleh
 
Lesson 28: The Fundamental Theorem of Calculus
Lesson 28: The Fundamental Theorem of CalculusLesson 28: The Fundamental Theorem of Calculus
Lesson 28: The Fundamental Theorem of CalculusMatthew Leingang
 

La actualidad más candente (20)

Advanced matlab codigos matematicos
Advanced matlab codigos matematicosAdvanced matlab codigos matematicos
Advanced matlab codigos matematicos
 
Automatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesAutomatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variables
 
Abstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAbstract Algebra in 3 Hours
Abstract Algebra in 3 Hours
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a category
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskell
 
Functions
FunctionsFunctions
Functions
 
mathematical functions
mathematical functions mathematical functions
mathematical functions
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskell
 
Refresher algebra-calculus
Refresher algebra-calculusRefresher algebra-calculus
Refresher algebra-calculus
 
3.2 Derivative as a Function
3.2 Derivative as a Function3.2 Derivative as a Function
3.2 Derivative as a Function
 
Reading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGsReading Seminar (140515) Spectral Learning of L-PCFGs
Reading Seminar (140515) Spectral Learning of L-PCFGs
 
Functionsandpigeonholeprinciple
FunctionsandpigeonholeprincipleFunctionsandpigeonholeprinciple
Functionsandpigeonholeprinciple
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...
 
Integration+using+u-substitutions
Integration+using+u-substitutionsIntegration+using+u-substitutions
Integration+using+u-substitutions
 
Rules of Derivative
Rules of Derivative Rules of Derivative
Rules of Derivative
 
Website designing company in delhi ncr
Website designing company in delhi ncrWebsite designing company in delhi ncr
Website designing company in delhi ncr
 
Ch03
Ch03Ch03
Ch03
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learning
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdf
 
Lesson 28: The Fundamental Theorem of Calculus
Lesson 28: The Fundamental Theorem of CalculusLesson 28: The Fundamental Theorem of Calculus
Lesson 28: The Fundamental Theorem of Calculus
 

Destacado

Scalable Data Science and Deep Learning with H2O
Scalable Data Science and Deep Learning with H2OScalable Data Science and Deep Learning with H2O
Scalable Data Science and Deep Learning with H2Oodsc
 
H2O.ai - Road Ahead - keynote presentation by Sri Ambati
H2O.ai - Road Ahead - keynote presentation by Sri AmbatiH2O.ai - Road Ahead - keynote presentation by Sri Ambati
H2O.ai - Road Ahead - keynote presentation by Sri AmbatiSri Ambati
 
Data Science, Machine Learning, and H2O
Data Science, Machine Learning, and H2OData Science, Machine Learning, and H2O
Data Science, Machine Learning, and H2OSri Ambati
 
H2O Big Data Environments
H2O Big Data EnvironmentsH2O Big Data Environments
H2O Big Data EnvironmentsSri Ambati
 
Sparkling Water 2.0 - Michal Malohlava
Sparkling Water 2.0 - Michal MalohlavaSparkling Water 2.0 - Michal Malohlava
Sparkling Water 2.0 - Michal MalohlavaSri Ambati
 
Build Your Own Recommendation Engine
Build Your Own Recommendation EngineBuild Your Own Recommendation Engine
Build Your Own Recommendation EngineSri Ambati
 
Deep Water - GPU Deep Learning for H2O - Arno Candel
Deep Water - GPU Deep Learning for H2O - Arno CandelDeep Water - GPU Deep Learning for H2O - Arno Candel
Deep Water - GPU Deep Learning for H2O - Arno CandelSri Ambati
 
H2O PySparkling Water
H2O PySparkling WaterH2O PySparkling Water
H2O PySparkling WaterSri Ambati
 
H2O AutoML roadmap - Ray Peck
H2O AutoML roadmap - Ray PeckH2O AutoML roadmap - Ray Peck
H2O AutoML roadmap - Ray PeckSri Ambati
 
Intro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSIntro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSSri Ambati
 
H2O Distributed Deep Learning by Arno Candel 071614
H2O Distributed Deep Learning by Arno Candel 071614H2O Distributed Deep Learning by Arno Candel 071614
H2O Distributed Deep Learning by Arno Candel 071614Sri Ambati
 

Destacado (11)

Scalable Data Science and Deep Learning with H2O
Scalable Data Science and Deep Learning with H2OScalable Data Science and Deep Learning with H2O
Scalable Data Science and Deep Learning with H2O
 
H2O.ai - Road Ahead - keynote presentation by Sri Ambati
H2O.ai - Road Ahead - keynote presentation by Sri AmbatiH2O.ai - Road Ahead - keynote presentation by Sri Ambati
H2O.ai - Road Ahead - keynote presentation by Sri Ambati
 
Data Science, Machine Learning, and H2O
Data Science, Machine Learning, and H2OData Science, Machine Learning, and H2O
Data Science, Machine Learning, and H2O
 
H2O Big Data Environments
H2O Big Data EnvironmentsH2O Big Data Environments
H2O Big Data Environments
 
Sparkling Water 2.0 - Michal Malohlava
Sparkling Water 2.0 - Michal MalohlavaSparkling Water 2.0 - Michal Malohlava
Sparkling Water 2.0 - Michal Malohlava
 
Build Your Own Recommendation Engine
Build Your Own Recommendation EngineBuild Your Own Recommendation Engine
Build Your Own Recommendation Engine
 
Deep Water - GPU Deep Learning for H2O - Arno Candel
Deep Water - GPU Deep Learning for H2O - Arno CandelDeep Water - GPU Deep Learning for H2O - Arno Candel
Deep Water - GPU Deep Learning for H2O - Arno Candel
 
H2O PySparkling Water
H2O PySparkling WaterH2O PySparkling Water
H2O PySparkling Water
 
H2O AutoML roadmap - Ray Peck
H2O AutoML roadmap - Ray PeckH2O AutoML roadmap - Ray Peck
H2O AutoML roadmap - Ray Peck
 
Intro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWSIntro to Machine Learning with H2O and AWS
Intro to Machine Learning with H2O and AWS
 
H2O Distributed Deep Learning by Arno Candel 071614
H2O Distributed Deep Learning by Arno Candel 071614H2O Distributed Deep Learning by Arno Candel 071614
H2O Distributed Deep Learning by Arno Candel 071614
 

Similar a Formal methods 8 - category theory (last one)

Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2Hang Zhao
 
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEEIntroductory part of function for class 12th JEE
Introductory part of function for class 12th JEEMohanSonawane
 
Algebras for programming languages
Algebras for programming languagesAlgebras for programming languages
Algebras for programming languagesYoshihiro Mizoguchi
 
Prerequisite for metric space
Prerequisite for metric spacePrerequisite for metric space
Prerequisite for metric spaceROHAN GAIKWAD
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdfRajuSingh806014
 
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLES
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLESTYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLES
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLESMohanSonawane
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...HidenoriOgata
 
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...7anantsharma7
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheoryMeetu Maltiar
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheoryKnoldus Inc.
 
02-Basic Structures .ppt
02-Basic Structures .ppt02-Basic Structures .ppt
02-Basic Structures .pptAcct4
 
Complex Analysis And ita real life problems solution
Complex Analysis And ita real life problems solutionComplex Analysis And ita real life problems solution
Complex Analysis And ita real life problems solutionNaeemAhmad289736
 

Similar a Formal methods 8 - category theory (last one) (20)

Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2
 
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEEIntroductory part of function for class 12th JEE
Introductory part of function for class 12th JEE
 
Algebras for programming languages
Algebras for programming languagesAlgebras for programming languages
Algebras for programming languages
 
Chap4
Chap4Chap4
Chap4
 
Pertemuan 3
Pertemuan 3Pertemuan 3
Pertemuan 3
 
Prerequisite for metric space
Prerequisite for metric spacePrerequisite for metric space
Prerequisite for metric space
 
Hay hay
Hay hayHay hay
Hay hay
 
Functions
FunctionsFunctions
Functions
 
Funcionesreales 160109205602
Funcionesreales 160109205602Funcionesreales 160109205602
Funcionesreales 160109205602
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf
 
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLES
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLESTYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLES
TYPES OF FUNCTION FOR JEE PREPARATION WITH EXAMPLES
 
The integral
The integralThe integral
The integral
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...
 
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
JEE+Crash+course+_+Phase+I+_+Session+1+_+Sets+and++Relations+&+Functions+_+7t...
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
 
Aa4
Aa4Aa4
Aa4
 
Introductory calculus
Introductory calculusIntroductory calculus
Introductory calculus
 
02-Basic Structures .ppt
02-Basic Structures .ppt02-Basic Structures .ppt
02-Basic Structures .ppt
 
Complex Analysis And ita real life problems solution
Complex Analysis And ita real life problems solutionComplex Analysis And ita real life problems solution
Complex Analysis And ita real life problems solution
 

Más de Vlad Patryshev

Formal methods 6 - elements of algebra
Formal methods   6 - elements of algebraFormal methods   6 - elements of algebra
Formal methods 6 - elements of algebraVlad Patryshev
 
Formal methods 1 - introduction
Formal methods   1 - introductionFormal methods   1 - introduction
Formal methods 1 - introductionVlad Patryshev
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theoryVlad Patryshev
 
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)Vlad Patryshev
 
Truth, deduction, computation lecture h
Truth, deduction, computation   lecture hTruth, deduction, computation   lecture h
Truth, deduction, computation lecture hVlad Patryshev
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture gVlad Patryshev
 
Truth, deduction, computation lecture f
Truth, deduction, computation   lecture fTruth, deduction, computation   lecture f
Truth, deduction, computation lecture fVlad Patryshev
 
Truth, deduction, computation lecture e
Truth, deduction, computation   lecture eTruth, deduction, computation   lecture e
Truth, deduction, computation lecture eVlad Patryshev
 
Truth, deduction, computation lecture d
Truth, deduction, computation   lecture dTruth, deduction, computation   lecture d
Truth, deduction, computation lecture dVlad Patryshev
 
Truth, deduction, computation lecture c
Truth, deduction, computation   lecture cTruth, deduction, computation   lecture c
Truth, deduction, computation lecture cVlad Patryshev
 
Truth, deduction, computation lecture b
Truth, deduction, computation   lecture bTruth, deduction, computation   lecture b
Truth, deduction, computation lecture bVlad Patryshev
 
Truth, deduction, computation lecture a
Truth, deduction, computation   lecture aTruth, deduction, computation   lecture a
Truth, deduction, computation lecture aVlad Patryshev
 
Truth, deduction, computation lecture 9
Truth, deduction, computation   lecture 9Truth, deduction, computation   lecture 9
Truth, deduction, computation lecture 9Vlad Patryshev
 
Truth, deduction, computation lecture 8
Truth, deduction, computation   lecture 8Truth, deduction, computation   lecture 8
Truth, deduction, computation lecture 8Vlad Patryshev
 
Truth, deduction, computation lecture 7
Truth, deduction, computation   lecture 7Truth, deduction, computation   lecture 7
Truth, deduction, computation lecture 7Vlad Patryshev
 
Truth, deduction, computation lecture 6
Truth, deduction, computation   lecture 6Truth, deduction, computation   lecture 6
Truth, deduction, computation lecture 6Vlad Patryshev
 
Truth, deduction, computation; lecture 5
Truth, deduction, computation;  lecture 5Truth, deduction, computation;  lecture 5
Truth, deduction, computation; lecture 5Vlad Patryshev
 
Truth, deduction, computation; lecture 4
Truth, deduction, computation;  lecture 4Truth, deduction, computation;  lecture 4
Truth, deduction, computation; lecture 4Vlad Patryshev
 
Truth, deduction, computation; lecture 3
Truth, deduction, computation;  lecture 3Truth, deduction, computation;  lecture 3
Truth, deduction, computation; lecture 3Vlad Patryshev
 
Truth, deduction, computation; lecture 2
Truth, deduction, computation;   lecture 2Truth, deduction, computation;   lecture 2
Truth, deduction, computation; lecture 2Vlad Patryshev
 

Más de Vlad Patryshev (20)

Formal methods 6 - elements of algebra
Formal methods   6 - elements of algebraFormal methods   6 - elements of algebra
Formal methods 6 - elements of algebra
 
Formal methods 1 - introduction
Formal methods   1 - introductionFormal methods   1 - introduction
Formal methods 1 - introduction
 
Formal methods 7 - category theory
Formal methods   7 - category theoryFormal methods   7 - category theory
Formal methods 7 - category theory
 
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
 
Truth, deduction, computation; lecture 3
Truth, deduction, computation;  lecture 3Truth, deduction, computation;  lecture 3
Truth, deduction, computation; lecture 3
 
Truth, deduction, computation; lecture 2
Truth, deduction, computation;   lecture 2Truth, deduction, computation;   lecture 2
Truth, deduction, computation; lecture 2
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
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 ConsultingTechSoup
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Último (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
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
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

Formal methods 8 - category theory (last one)

  • 1. Formal Methods in Software Lecture 8. Category Theory Vlad Patryshev SCU 2014
  • 2. In This Lecture ● functors and examples (diagrams; product; exponentiations); ● currying/yoneda lemma; ● example with integers/rationals; ● monad
  • 3. Example: Parametric Class trait List[A] extends Iterable[A] { def map[A](f:A=>B):List[B] }
  • 4. Functor Given categories A and B, a functor F: A → B consists of mappings F: Obj(A) → Obj(B) and F: Fun(A) → Fun(B) , so that F(idX )=idF(X) and F(f∘g)=F(f)∘F(g)
  • 5. More Examples ● A= 3 , B=Sets; what is a functor 3 → Sets? Have to define: sets F(0), F(1), F(2); functions F(f), F(g), F(gf) ● Any f:X→Y in category C is a functor from 2 to C.
  • 6. Cartesian Product is a Functor Fix an object A. X ↦ X×A is a functor. How does it work on functions? f:X→Y ↦ f×idA : X×A → Y×A
  • 7. +1 is a Functor In Sets, take X ↦ X+1. f: X→Y ↦ (f+1): X+1 → Y+1 This functor is called Option[T].
  • 8. Category of Categories Take functors F:A→B, G:B→C; their composition H=G∘F is also a functor. H(idX ) = G(F(idX )) = G(idF(X) ) = idG(F(X)) H(p∘q) = G(F(p∘q)) = G(F(p)∘F(q)) = G(F(p)) ∘G(F(q)) = H(p) ∘H(q) Identity functor IdA :A→A Id(f) = f Cat - a category of all categories. No barber problems, nobody shaves nobody.
  • 9. Exponential Functor A, B - objects in category C. BA - an object of functions from A to B, if such exists. E.g. in Set, {f:A→B}. In Scala In Java (Guava) (https://code.google.com/p/guava- libraries/wiki/FunctionalExplained) trait Function[X,Y] { def apply(x:X): Y } interface Function<X,Y> { Y apply(X x); } val len:Function[String, Int] = _.length Function<String, Integer> lengthFunction = new Function<String, Integer>() { public Integer apply(String string) { return string.length(); } };
  • 10. Define Exponential via Currying In Set, f:A→CB ≡ f’:A×B→C f(x)(b) = f’(x,b) Very similar to P⊢(Q→R) ≡ P∧Q ⊢ R Actually… it’s the same thing. Take posets, for example, Boolean lattice, where a×b ≡ min(a,b) /*see lecture 7*/ ≡ a∧b a∧b ≤ c ≡ a ≤ (b→c)
  • 11. Currying: Yoneda Lemma Fun(A×B, C) ≡ Fun(A, CB ) (Caveat: what is Fun? A set? It’s not always available as a set)
  • 12. Example with Numbers Category Z = (Z,≤); category Q = (Q,≤) Inclusion iz : Z ↣ Q - preserves order, so is a functor. How about Q → Z? Upb: q ↦ Upb(q) Upb(q) ≤ n /* this is in Z */ ≡ q ≤ n /* this is in Q */ Take composition q ↦ iZ (Upb(q)), call it Mint. We see two properties: ● q ≤ Mint(q) ● Mint(Mint(q)) ≤ Mint(q) /* actually equal */
  • 13. Example with Lists Category Scala Take functor List. We see two properties: ● singleton: X → List[X] ● flatten: List[List[X]] → List[X] Do you see similarity?
  • 14. Monad * f:F(X)->G(X) is natural if for all p:X→ Y Given a category C, an endofunctor M: C → C is called a Monad if it has two features: ● unitX : X → M(X) ● flattenX : M(M(X)) → M(X) These two functions should be natural*
  • 15.