Molecular Combinator Reference Manual

advertisement
Molecular Combinator Reference Manual
UPIM Report 2
Technical Report UT-CS-02-489
Bruce J. MacLennan
Department of Computer Science
University of Tennessee, Knoxville
www.cs.utk.edu/˜mclennan
November 5, 2002
Abstract
This report contains, in summary form, definitions, schematic reactions, and equivalences of all combinators in use by this project. It will be updated as new combinators,
equivalences, etc. are used.
This research is supported by Nanoscale Exploratory Research grant CCR-0210094 from the National
Science Foundation. It has been facilitated by a grant from the University of Tennessee, Knoxville, Center
for Information Technology Research. This report may be used for any non-profit purpose provided that the
source is credited.
1
Introduction
1. Most of the combinator definitions and equivalences (beyond those peculiar to molecular computation, such as , , and ) are from Curry and Feys [CFC58].
2. We follow the usual convention in combinatory logic of omitting parentheses that associate to the left. For example,
means
, and
means
.
3. In the definitions of the operators, variables are marked with primes (e.g., ) and
parenthesized superscripts (e.g.,
) to indicate shared complexes. See the description of the (Sharing) Primitive (Section 17).
!#"$
&%
%$
-,/.102.13
(powers of
4. Notice that the following are distinct and have different meanings:
combinators),
(polyadic combinators),
(sharing),
(deferred combinators),
(left reduction),
(polyadic extension); see Other Notation (p. 14).
is also used in the usual way to denote an element in a series
, . . . . When
subscripts and superscripts of any kind are combined, the subscripts take precedence;
thus
means
.
%
(' %*)
465%
9 :9
%$
' %+)
74 % 8 5
%
5. The size
of a nonprimitive combinator
is expressed in terms of the number
of , , and nodes that it contains. Since nonprimitive combinator definitions are
binary trees, if they contain no other nodes besides , , and , then the counts
satisfy
, and the total nodes are
.
; <
=
>?A@BDCFEHG
; <
=
IJ?AKL>MBGN?OKP
Q@RBMCSE:G
6. A combinator is called regular if it does not affect its first argument, thus,
T U,WVXVXVY ?UZ [,WVXVXVY
%
5]\
Most combinators (e.g., , ^ , , _ , < , ; , , ` , 4 , 4 , a ) are regular.
%
2
Definitions of Combinators
b
1
Primitive (Application Complex)
=T
T cN= T T The application ( ) complex represents the application of a combinator to its argument.
The application of to , written
, is represented by a molecular complex
, in
which the “operator” binding site of is linked to , the “operand” binding site is linked
to , and the “result” site is linked to , the complex into which the result of
will be
linked.
All (or most) of the non-terminal (interior) nodes of a combinator tree are nodes; the
terminals (leaves) are primitive combinators (e.g., and ). If the network is not a tree, but
has shared nodes or cycles, then (most of) the non-terminal nodes are and (sharing)
nodes. (We say “most” because later we may want to define additional interior node types.)
=
T
c
;
2
d
<
=
=
Combinator (Elementary Compositor)
Definition:
Reduction to
;^<
^e?UZfM
g
(1)
? ;U
<;h*<
(2)
:
Ki;jBkKl<mBDni=!?Ao
Size:
Equivalences:
total.
S ? T Qpqt _r+
Qpq_s
j
T
t
% m,WVXVXV % ?UZ -,^VXVXV % T
T
Notes: If is regular (p. 2), U,VXVXV ?UZfuv,^VXVXVY , then
%
5
Tjt ,hVXVXVY % ?UZ t uv,VXVXVY 5w\
t
T
That is, is applied to the result of applying to the arguments U,WVXVXVY
3
dyx
(3)
(4)
(5)
%.
Combinator (Permuting Compositor)
Definition:
J?UZzM
7w
(6)
? S
(7)
Equivalences:
Size:
?
oi;jBD{|<mBG}K~=(?eK€
total.
3
4

Combinator (Elementary Permutator)
Definition:
?UZfuw
(8)
? ;h
? ;
;h
8<6<‚
? piUƒX
QpiUƒ/
QpiUƒ„
(9)
(10)
(11)
Equivalences:
Size:
5
Š‰
i;jBM…†<mBD‡i=!?ˆGXo
total (Def. 9).
Combinator (Pure Permutator)
Definition:
Uƒˆ?UZ j
(12)
Equivalences:
Size:
6
Œ
{€;jBD{|<mBG€G=(?eKin
ƒ‹? S _
ƒ‹? pq_ _
(13)
(14)
total (Def. 13).
Primitive (Elementary Deleter)
Reaction:
U BJŽU E ŽqB‘
=B ‘(BJŽU E S’BJJ BŽ€=“0
vc ’BkKlŽU E c]’BŽW0 !B‘
vc]”BJŽU E Žc]”BJ‘
Notes: In Eq. 15,  represents any primitive combinator (e.g., ; or <
(15)
(16)
(17)
(18)
). Notice that in
Eq. 17, a deletion cancels a replication in progress. However, in Eq. 18, a deletion does not
affect a shared complex, except to cap the deleted sharing link.
Reaction Specification:
d: D, a: A, x, y, d’: D, p: P, q: Q, q’: Q.
d a, a_1 x, a_2 y, d’ q’, p q
=> (DeleteApplication)
d x, d y, p a, a_1 q, a_2 q’.
4
d: D, u, r: R, x, p: P, p’: P, q: Q, q’: Q.
d r_1, u r_2, r x, p q, p’ q’
=> (DeleteReplicator1)
u x, p r_1, p’ r_2, r q, d q’.
d: D, u, r: R, x, p: P, p’: P, q: Q, q’: Q.
d r_2, u r_1, r x, p q, p’ q’
=> (DeleteReplicator2)
u x, p r_1, p’ r_2, r q, d q’.
d: D, u, v: V, x, p: P, q: Q.
d v_1, u v_2, v x, p q
=> (DeleteSharing1)
p v_1, u v_2, v x, d q.
d: D, u, v: V, x, p: P, q: Q.
d v_2, u v_1, v x, p q
=> (DeleteSharing2)
p v_2, u v_1, v x, d q.
d: D, pc: Prim, p: P, q: Q.
d pc, p q
=> (DeletePrimitive)
p pc, d q.
Notes: In the last (DeletePrimitive) rule, ‘Prim’ stands for any primitive combinator. Therefore, at least at the present time, that rule must be repeated with ‘Prim’
replaced by each primitive combinator species in use (e.g., ‘K’, ‘S’).
7
•
Combinator (Elementary Identificator)
Definition:
Reduction to
;^<
_–—?^Zz
:
_˜? ;<™
Size: GX;jBkKl<mBkKL=!?A total (taking _š?A;^<‘<
Equivalences:
(19)
_˜? ‚ <™
_ ? k<
˜
5
(20)
).
(21)
(22)
›
8
Combinator
Definition:
ž
9
pic]?UZ c]M
œcw
(23)
Combinator (Elementary Cancellator)
Definition:
Reaction:
<ˆ?UZ (24)
cw=‚0X<™JBJ‘AE c]ŸB™=S0X< (25)
C % ,WVXVXV % ?UZ (26)
Equivalences:
Reaction Specification:
a: A, b: A, k: K, d: D, q: Q, u, x, y.
u a, a_1 b, b_1 k, b_2 x, a_2 y, d q
=> (Kreaction)
u x, d a, a_1 b, b_1 k, b_2 q, a_2 y.
¡
Combinator (Inert Complex)
10
¢
T -,VXVXV
%
The (inert) combinator is used when we want to prevent reduction, generally when we
are intending to produce a static structure. For example, if the structure
is
generated, then there is a risk that the reduction rules for will destroy the structure. This
is avoided by using the inert combinator, e.g.
. Since it is inert, there are no
reduction or reaction rules for it. Of course, in practice, there need not be just one inert
combinator, and any molecular species that does enter into the computational reactions
could be used.
T
¢-,VXVXV %
£
11
Primitive (Result Cap)
The result cap is inert; it is a place-holder for the “result” binding-site of any group.
12
¤
Primitive (Argument Cap)
The argument cap is inert; it is a place-holder for the “argument” binding-site of any group
(in particular, for the “operator” and “operand” sites of an complex).
=
6
¥
13
Primitive (Elementary Replicator)
Reaction:
BŽqBJŽU E c6Bk¦“BŽW0 
c
¦
c§¦ =‚JBJŽ€= 0‚BŽW0  E ¨cN=
Q¦©=+
BMn†ŽU
Notes: In Eq. 27,  represents any primitive combinator (e.g., ; or < ).
(27)
(28)
Reaction Specification:
r: R, a: A, u, v, x, y, r’: R, a’: A,
p: P, p’: P, p’’: P, q: Q, q’: Q, q’’: Q.
u r_1, v r_2, r a, a_1 x, a_2 y,
p r’_1, p’ r’_2, r’ q, p’’ a’, a’_1 q’, a’_2 q’’
=> (ReplicateApplication)
u a, v a’,
a_1 r_1, a’_1 r_2,
a_2 r’_1, a’_2 r’_2,
r x, r’ y,
p q, p’ q’, p’’ q’’.
r: R, pc: Prim, u, v, pc’: Prim, p: P, p’: P, q: Q.
u r_1, v r_2, r pc, p q, p’ pc’
=> (ReplicatePrimitive)
u pc, v pc’,
p r_1, p’ r_2, r q.
Notes: In the last (ReplicatePrimitive) rule, ‘Prim’ stands for any primitive
combinator. Therefore, at least at the present time, that rule must be repeated with ‘Prim’
replaced by each primitive combinator species in use (e.g., ‘K’, ‘S’).
14
ª
Combinator (Elementary Formalizer, Replicating)
Definition:
Reaction:
;|«?UZz
Q
(29)
cw=‚3/;|BŽW0 AEW cN= g=u
¬=y ­BŽ;BJŽU
(30)
Reaction Specification:
a: A, a’: A, a’’: A, s: S, r: R, p: P, p’: P, q: Q,
u, x, y, z.
7
u a, a_1 a’, a’_1 a’’, a’’_1 s, a’’_2 x, a’_2 y, a_2 z,
p r_1, p’ r_2, r q
=> (Sreaction)
u a, a_1 a’, a’_1 x, a’_2 r_1,
a_2 a’’, a’’_1 y, a’’_2 r_2,
r z,
p s, p’ q.
Equivalences:
; ? MY+
15
ª®
(31)
Combinator (Elementary Formalizer, Sharing)
¯
;|?UZfu Q
(32)
¯
cN=S3 ;†BJŽ0‚OEW cN= ¬=‚u+
g=y¨6MBJŽ^;©BŽ^
(33)
Definition:
Reaction:
Reaction Specification:
a: A, a’: A, a’’: A, s: Ssh, v: V, p: P, p’: P, q: Q,
u, x, y, z.
u a, a_1 a’, a’_1 a’’, a’’_1 s, a’’_2 x, a’_2 y, a_2 z,
p v_1, p’ v_2, v q
=> (SharingSreaction)
u a, a_1 a’, a’_1 x, a’_2 v_1,
a_2 a’’, a’’_1 y, a’’_2 v_2,
v z,
p s, p’ q.
Equivalences:
¯
¯
; ? ­„ (34)
Notes: See Sec. 19 for a discussion of this definition.
16
ª]°
Combinator (Polyadic Elementary Formalizer)
Definition:
; % «,VXVXVY % ±
?^Zzu
QU,^VXVXV
Q % 8
(35)
Reduction to
;^<
:
;²,³? ;
(36)
(37)
; %2´ ,³? ; %]µ ;
E GXBG total for ; % ¯ .
Size: 7
 ° E(…q;jBD…h
° E:G}/<mBD¶P
° EHG}8=(?˜GX‡h
° H
Notes: ; can be replicating or sharing depending on whether ; or ; is used in its
%
recursive definition. If it is sharing, it produces the following structure:
¯
; % U,VXVXVY % ?UZfu % $ QU, %L· , $ ^VXVXV2
g %~· , Q % (38)
Equivalences:
; % ? 4 %2´ ,+_
¸
17
(39)
Primitive (Sharing Complex)
¯ ¯
; ¯
The sharing primitive ( ) is used for constructing non-tree structures, including cyclic
structures. It is produced by sharing combinators such as , , and . Note that a
complex between a combinator and its arguments will block reduction of the combinator,
so complexes appear primarily in structured that are being treated as data.
Primes and parenthesized superscripts on variables are used to indicate informally the
sharing of structures. Thus, if there is a single sharing complex above , then the two links
to it will be called and . Notice that both will be “covered” by a sharing complex; if it
is necessary to make this explicit, the two links will be written
and . If one of these
links is replaced by another sharing complex, then the original link and the two new ones
will be called , ,
, and so forth. Obviously such a notation cannot capture all the
possible structures of sharing complexes, but it allows the convenient expression of chains
of complexes, which is the most common case. To go beyond this, diagrams should be
used.
`
s¹8$
& 18
º
Combinator (Elementary Duplicator, Replicating)
Definition:
!ˆ?UZz«
(40)
? ;U_
? ;
¨S_s
? ;P;
<6_#
(41)
(42)
(43)
Equivalences:
Size:
oi;jBD{|<mBG}K~=(?eK€
total (Def. 41 or 42).
9
19
º®
Combinator (Elementary Duplicator, Sharing)
Definition:
Reduction to
¯
Notes: M,g0
;^<
:
¯
and !0,
¯
ˆ?UZz (
(44)
¯
¯
D¯ ,g0‹? ¯ ;U_
(¯ 0,±? ;œ
¯ _#
D,g0‹? ; ;U
<6_s
(45)
(46)
(47)
¯
are two variants, functionally equivalent to , but producing differently ordered links to the sharing ( ) complex (see Equivalences below). In the absence
of subscripts, we will take to be
, since it is a little more convenient to use. Definition 47 is not very useful, because it needlessly begins replication of the first argument of
.
Notice that either or may be taken as a primitive sharing operation, since either can
be defined in terms of the other. At this time, it looks as though will be the best choice as
a primitive, so will be defined by Eq. 45 or 46.
Reaction:
(48)
¯
¯
M,g0
¯
¯
;
¯
D,g0
¯
;
¯
¯
¯
cw=‚0 (JBJŽ0Y‚AE cN=S0„&‘BJŽ »J
B ŽU
Reaction Specification:
w: Wsh, a: A, a’: A, u, x, y, v: V, p: P, p’: P, q: Q.
u a, a_1 a’, a’_1 w, a’_2 x, a_2 y, p v_1, p’ v_2, v q
=> (SharingWreaction)
u a, a_1 a’, a’_1 x, a’_2 v_1, a_2 v_2, v y, p’ w, p q.
¯
(49)
D¯ ,g0« ^? Z (50)
(¯ 0,¨« ^? Z © %,g0 « ^? Z ¼
½ % $ VXVX¾¨VY¿ À
(51)
,
%2´
Notes: The primes and superscripts on in Eq. 51 represent successive sharings of Equivalences:
(see Sec. 17).
20
º ‰
Combinator (Pure Duplicator)
Definition:
(ƒ»?UZz&
10
(52)
Equivalences:
Size:
Â
21
‡€;jBD‡|<mBG}~=(?n†G
(ƒÁ? H_
(53)
total.
Combinator (Elementary Fixed-point, Replicating)
` T ?UZ `‘u
Definition:
Reduction to
;^<
(54)
:
` ? ;P;^<v
Q;
8<[
g;P;
Q;U
Q;P;^<‚/<S
Size: ‡€;jBM…†<mBG€G=(?eKin total.
(55)
Equivalences:
` ? (
;
:
` ? ;P;U_Ã
Q;^
<v
Q;U__#
` ? where e?:
Q;U_#
` ? :_ µ µ ;^<
(56)
(57)
(58)
(59)
Notes: Definition 55 by John Tromp [LV97] may be the shortest definition in terms of
(12 combinators). Definitions by Curry and Turing are longer (18 and 20, respectively).
22
®Â
Combinator (Elementary Fixed-point, Sharing)
Definition:
Reaction:
¯
`6—?^Z Ä
where
Äy? T Ä ¯
¯
cN= `[’BJŽ0‚OE c]W=‚ŸBŽ `!
B Ž^
Reaction Specification:
y: Ysh, a: A, v: V, x, p: P, p’: P, q: Q.
u a, a_1 y, a_2 x, p v_1, p’ v_2, v q
=> (SharingYreaction)
u v_1, v a, a_1 x, a_2 v_2, p’ y, p q.
11
(60)
(61)
¯T
Notes: The following illustrates the self-sharing cycle created by
`
¯
`T
:
? ÄT
? T Ä T
? T T Ä ? T T Ä T ? T T T Ä ? Ä ..
.
? T T T T T #"$ T sÅ8$ VXVXV#
T
Of course, it is the = complex that is shared, not , as the notation suggests.
Æ
23
Combinators (Iterators or Church Numerals)
Definition:
Ç
?
<
6
_
¹
%X´ ,—? ;U %
Size: Qn ° BG};©Be
7K ° BMnš*<-BA
7 ° BDnš8=(?˜GXÈ ° Bko
Equivalences:
Ç
Ç ? %Ç Ç
Ç % ? Ç4 Ç
5SÇ ´†%
Ç Ç5 %
?
5%
5«µ %
?
%2É
5 %
24
Ê
Ç
Ç
(62)
(63)
Ç
total for
%.
(64)
(65)
(66)
(67)
Combinator (Dyadic Compositor)
Definition:
46Ëce?UZzM
Qc§+
7Ëc
(68)
Equivalences:
4 ? T
t ;P+
j
T
©
t
Ì
4%
- ,VXVXV8 % ?^Z m,VXVXV % Ì -,WVXVXV % Size: oi;jBD{|<mBG}K~=(?eK€ total (Def. 69).
12
(69)
(70)
ÊÍ°
25
Combinator (Polyadic Compositor)
Definition:
Reduction to
;^<
:
4 % U,WVXVXVY % J?UZzM
QU,^VXVXV
Q % 4 % ? ; %Nµ <
… 8¯ =(?˜GX‡ ° EMo total for 4 % .
¯
Size: 7 ° EK€;jBO
¬… ° E:G}/<mBA
g¶ ° E­q
Notes: 4 can be replicating or sharing ( 4 ), depending on whether ; or ;
%
%
% %
definition 72. If it is sharing, then the following structure is generated:
¯
4 % U,^VXVXV % ?UZfM
QU, %L· , $ ^VXVXV2
g %~· , Q % (71)
(72)
is used in
(73)
Equivalences:
4 %X´ , ? ; %Nµ 4 5% ,WVXVXV % v,WVXVXV„ 5 ?UZ QU,[,VXVXVY 5 ^VXVXVX
g % v,VXVXV„ 5 4 52% ´ , _–,WVXVXV % v,WVXVXV„ 5 ?UZ [,VXVXV„ 5 QU,v,^VXVXVY 5 ^VXVXV2
Q % v,VXVXV„ 5 26
Î
(74)
(75)
(76)
Combinator ( Î Formalizer)
Definition:
Reduction to
;^<
awyc¦ˆ?UZ M
gyc
g¦
(77)
:
a ? Size: Ki{€;jBDKL…P<-BM…š¶i=Í?A¶€¶ total.
13
(78)
Other Notation
27
Composition
Definition:
µ ˆ?¼^
Size: Ki;jBkKl<mBkL=!?e¶ total, plus 9 k9*B˜9 Ï9 .
(79)
Equivalences:
µ _˜? _ µ —?J
µ Q
µ ³? ¬ µ µ ¬ µ ³? ^ µ 28
(80)
(81)
(82)
Powers
Definition:
¹, ? _
, ? %X´ ? µ %
KP
° EMG};B­KP
° EDG}/<ÐB­†
° EMG}8=(?¶h
° EDG}
Size:
Equivalences:
(83)
(84)
(85)
(86)
total, plus
5 µ % ? 5‚´†%
5 % ? 5™%
^u 5 ? 5 29
° 9 k9 , for % , °Ñ G .
(87)
(88)
(89)
Deferred Combinators
Definition:
r¹8$ ? %X´ , $ ? ^ % $
Size:
K ° ;©BDK ° <-BM… ° =­?e‡ °
total, plus
9 :9 , for % $ .
14
(90)
(91)
(92)
Equivalences:
T -,VXVXV ?UZ T -,VXVXV8 %
%
%$ ¹
¹
5‚´†% $ ? 5 % $
T
T
Notes: If is regular (p. 2), U,VXVXV ?UZfuv,^VXVXVY , then
T t -,^VXVXV U,VXVXVY ?U% Z t -,VXVXV v5 ,VXVXV„
%
5]\
rÒY$
Ò
Ò
T
T
That is,
of by Ó steps. Since , , _ , < , and are regular:
rÒY$ defers the action
T
% $ T -,VXVXV % t ?UZ TT -,WVXVXV % t % $ m,VXVXV %  ?UZ -,WVXVXV % w
_ % $ ¹ VXVXV % ?UZ ¹ VXVXV8 %
< %T $ ¹ VXVXV8 % ?UZ T ¹ VXVXV8 %
% $ -,^VXVXV8 % ?UZ -,WVXVXV % 30
(93)
(94)
(95)
(96)
(97)
(98)
(99)
Left Reduction
Definition:
'¹ ) ? _
(100)
', ) ? (101)
' %2´ , ) ? ^ ' %+)iµ (102)
Size: …²
° E:G};jBD…h
° E:G}/<mBD¶P
° EHG}8=(?˜G}oP
° EHGX total, plus ° 9 k9 , for .
'
+
%
)
Equivalences:
T -,VXVXV ?UZ T T VXVXV2
T T -,¨10*^VXVXV ,8
(103)
%L· %
T ' %*, ) ¹ -,VXVXV % ?UZ T T m,810¹ VXVXV
(104)
' %2´ ) ¹
%
'% %+) ¹ %L· ,
%0
(105)
' %X´ , ) ? µ µ VXVXV µ µ ^ µ ' %X´ , ) ? % $ 0 µ %~· , $ µ VXVXV µ 0 $ µ , $ µ r¹8$ (106)
' %X´ , ) ? œ u % (107)
' 5‚´†%+) ? T 5 ' %+) µ ' 5™)
(108)
T
' %*) m,VXVXV % %X´ ,±?UZ %X´ ,7m,VXVXV %
(109)
; ' %+) ? ; %
(110)
T
T
can be called a left reduction [Mac90]. To see this, write in infix form,
'
*
%
)
T§Ô ÄyNotes:
©
Ô
Õ
? Ä and assume Õ associates to the left (so ÔÕ Ä ÕwÖ ?×
Ô©Õ Ä† ÕÖ ). Then:
T Ô Ô ,^VXVXV Ô ? Ô Õ]Ô , Õ VXVXV ÕNÔ
' %+) ¹
% ¹
%†\
T
For regular,
T ?¼
¨S 0 T *_
(111)
' %*)
15
31
Polyadic Extension
Definition:
' ¹, ) ? _
', ) ? ' %2´ ) ? µ ^ ' %*)
… ° E:G};jBD…h
° E:G}/<mBD¶P
° EHG}8=(?˜G}oP
° EHGX
Size: ²
Equivalences:
Notes: If
T
(112)
(113)
(114)
total, plus
, ) ? 0 ­ % '
2
%
´
' %*) T -,¨10VXVXV8 %2´ ,Ø?UZ T 1 0VXVXV %2´ ,¨-,
is regular,
T ' %*)
T ' %2´ , )
T ' %2´ , )
T ' 5S´†%*)
? T 0 ­T % _
? T µ T µ VXVXV µ % T T
? T s¹8$ µ , $ T µ VXVXV µ % $
? ' 5) µ 5 ' %+)
° 9 k9 , for (' %+) .
(115)
(116)
(117)
(118)
(119)
(120)
References
[Bar84] H. P. Barendregt. The Lambda Calculus: Its Syntax and Semantics. NorthHolland, Amsterdam, revised edition, 1984.
[Bur75] William H. Burge. Recursive Programming Techniques. Addison-Wesley, Reading, 1975.
[CFC58] H. B. Curry, R. Feys, and W. Craig. Combinatory Logic, Volume I. NorthHolland, Amsterdam, 1958.
[LV97]
M. Li and P. M. B. Vitanyi. An Introduction to Kolmogorov Complexity and its
Applications. Springer-Verlag, New York, second edition, 1997.
[Mac84] Bruce J. MacLennan. Computable real analysis. Technical Report NPS52-84024, Dept. of Computer Science, Naval Postgraduate School, 1984.
[Mac90] Bruce J. MacLennan. Functional Programming: Practice and Theory. AddisonWesley, Reading, 1990.
16
Download