Distributive Categories yukita
-
Upload
douglas-york -
Category
Documents
-
view
220 -
download
0
Transcript of Distributive Categories yukita
Distributive Categories
http://cis.k.hosei.ac.jp/~yukita/
2
Products and Sums
• Products are concerned with operations on the data.
• Sums are concerned with control.– Decisions on which operation to perform
• How do they interact when both products and sums are involved?
3
The Distributive Law
.explicitly misomorphis thegive should We
.isomorphic are objects somesay just toenough not isIt
00 (ii)
)()()( (i)
saysit in Roughly,
X
ZXYXZYX
Sets
4
ZX YX ZXYX 2i1i
YX i1
ZX i1
)( ZYX
below. diagram in the as
definedy canonicall is )( ZYXZXYX
5
Axiom 1 [abstracted from Rule (i)]
• The arrow is an isomorphism.
• Rule (i) is not automatic in categories other than Sets.
6
Axiom 2 [abstracted from Rule (ii)]
object. initialan is since
,00:
arrow oneexactly always is There
m.isomorphisan is 00:
X
X
Remark.
7
)).1,(,()1),,((
))0,(,()0),,((
by defined is
,|))1,(,(,|))0,(,()(
,|)1),,((,|)0),,(()()(
zxzx
yxyx
ZzXxzxYyXxyxZYX
ZzXxzxYyXxyxZXYX
Sets 1. Ex.
8
Def. Distributive Categories
Sets
. a called is
2, and 1 Axiom satisfies which and exist, pairs of sums and products
in which objects, terminaland initial hashich category wA
Ex.2
category vedistributi
9
Ex. 3 Category 2X is distributive.
).()()(
thatnot true isit sincedifferent issituation the,In
).()()( that truealso isIt
. that says 2 Axiom
).()()( that says 1 Axiom
ZXYXZYX
WUVUWVU
U
WUVUWVU
Sets
Note.
10
. of examplefirst theis This
:
. , functions all Give
*. )1(*,
)0(*, *
are sum theof Injections
}.1,0{set or the },{set with theidentify often We
)}.1(*,),0{(*, and {*}Let
2
21
BB
BBBBQuestion.
B
B
BEx.4.
IIII
II
truefalse
III
twist
ii
11
.
consider tosufficient isit , arrowsconstruct To
.)()(
)()()()(
ms.isomorphis of sequence following heconsider t thissee To
. category, vedistributi aIn
2
2 1
B
BB
B
BB
IIII
IIIIIIII
IIIIIIIIII
IIII
12
In Sets
)3(*,))1(*,),1((*,)1,1(
)2(*,))1(*,),0((*,)1,0(
)1(*,))0(*,),1((*,)0,1(
)0(*,))0(*,),0((*,)0,0(
takes to from misomorphis The 2
IIIIB
13
The & function
)1(*,))1(*,),1((*,)1,1(
)0(*,))1(*,),0((*,)1,0(
)0(*,))0(*,),1((*,)0,1(
)0(*,))0(*,),0((*,)0,0(
takes to from misomorphis The 2
BB
14
Sets as a Distributive Category
• Using– sums– products– composition– distributive law– and some additional primitive functions,
• we can construct various functions.
15
Some Primitives in the category of Sets
if
if ),(
:
*
:
),(
:
),(
:
yxtrue
yxfalseyx
test
r
Ir
yxyx
multiply
yxyx
add
yx
BRR
R
RRR
RRR
16
Divide
0. if ,1)(
0 if false*,0)(
),(
:
yy
x
y
yx
Idivide
RRR
17
Ex. 5. Realization of testx>0
.0 if )1,(
0 if )0,(
:0
xx
xxx
testx
RRR
18
0 if )1,( 0 if )1,*),((
0 if )0,( 0 if )0,*),((
)()(
0 if )1,*),(( 0 if ),(
0 if )0,*),(( 0 if ),(
)()(
0 if ),(
0 if ),(),0,()0,,(
)0,,( ,*)( 1313
0
xxxx
xxxx
II
xxxtruex
xxxfalsex
II
xtruex
xfalsexxxxx
xxxx
I
yxtesttwist
RRRR
RRR
RRR
RRRRR
B
B
19
Imperative Programming
?)?,,!()0,,1(
gives eventuallywhich
)()(:
Factorial
program. theof called is
. called is function aSuch
,:,:
as dinterprete isiteration
,: function aGiven
xxf
IIIIf
X
f
XXfffXXff
XXf
n
RRRR
spacestate the
program imperative an
10 Ex.
20
Construction of factorial as an imperative program
.1 allfor )1,0,!()0,,1( Check that
.1or 1 if )1,,(
0 and 1 if )0,1,(),,(
:
)(
as dinterprete isiteration
,: function aGiven
xnxxf
tddp
tdddptdp
XXf
IIX
XXf
n
RR
21
Implementation of factorial in a distributive category
).1,,(),( clear that isIt
1. is flag that thecase in thefunction theis
0. is flag that thecase in thefunction theis
.: and :
functions twoconstruct tosafficesit Thus
.)(
have wecategory, vedistributi aIn
1
1
0
10
dpdpf
tf
tf
XfXf
IIX
RR
RRR
22
Construction of f0
.
composite theas :
. 1 if )1,,(
1 if )0,1,(),(
)(:
12110
1
220
B
B
xtest
xtest
ddp
dddpdp
IIf
RRRR
RR
R
R
23
Construction of h and f0
).(
composite theis
.
composite theas )1,(),(
:
2221222
21312
0
241102
22
1
II
f
ddpdp
h
h
test
addmult
x
RRRRRR
RRR
RRRRRR
RR
R
RR
R
B
B
24
Def. Imperative program
. of ),(),(,
sequence a is program imperative theof A
program.
imperative theof thecalled is function The
category. vedistributi ain available onsconstructi the
using functionsgiven ofset a from dconstructe
:
function a is program imperativeAn
2 Xxfxfx
f
XXf
behavior
action
25
Ex. 11. while t(y) is true do …
idling. toscorrespond 0 valueflag The
.)( and 1 if )1),((
)(or 0 if )0,(),(
)()(:
idle."then
),( to of value thechange true,is )( while"
:does which program imperativean Construct
.: test a and :function aGiven
t
trueytesttyg
falseytesttyty
IIYIIYf
ygyyt
YtYYg
B
26
Implementation of Ex. 11
.)(
.)( if )1),((
)( if )0,(
follows. asgiven is :
injection.first theis
. to from
. and construct tosufficesit ,)( Since
.: test a and :function aGiven
112
1
0
10
Y YYYYIIYYY
trueytestyg
falseytestyy
YYYf
f
YYY
ffYYIIY
YtYYg
gtest Y
B
27
Ex. 12. A Circuit with Feedback
nor
x
y
nor
u
v
28
unstable. isbehavior the(0,0,0,0), with Starting
point. fixed a is )0,1,1,0( with Starting
))or (),or (,,(),,,(
:
}1or 0,,,|),,,{(
is states possible all ofset The
44
4
uyvxyxvuyx
f
vuyxvuyx
BB
B
29
Ex. 13. Flow chart
4xtest
false
true
0 12x
2x2 3
30).3,()3,(
)3,()2,(
4 if )0,(
4 if )2,()1,(
)1,2()0,(
:
)}.3,{()}2,{()}1,{()}0,{(
4
is space state The
2
ww
zz
yy
yyy
xx
f
wzyx
X
31
Term Paper
• Implement the function in example 13.
• Use only – add– multiply– constants– constructions in a distributive category.