% $B4pK\35G0(B

\chapter{ $BJ,;6(B KL1 $B8@8l$ND)@o(B \Comment{(the Language)} }
\label{KLIC}

$BA0>O$G$O!"J,;6%W%m%0%i%_%s%0$N8=>u$HLdBjE@$K$D$$$F=R$Y$?!#(B
%
$BK\>O$G$O!"$=$l$i$NLdBjE@$r2r7h$9$k$?$a$K(B
$BK\8&5f$,4pAC$H$7$F$$$k(B KL1 $B8@8l$H4{B8$N(B KL1 $B8@8l=hM}7O$K$D$$$F=R$Y$k!#(B


\section{ KL1 $B8@8l$H$O(B }

KL1 $B8@8l$H$O!"(B
CLP (Concurrent Logic Programming),
CCP (Concurrent Constraint Programming),
CBC (Constraint-based Concurrency)
$B$J$I$H8F$P$l$k%W%m%0%i%_%s%0%Q%i%@%$%`$K4p$E$/(B
$B8@8l!J7W;;%b%G%k!KB2$N$&$A$G!":G$bC1=c$J$b$N$G$"$k!#(B

KL1 $B8@8l$O:G$bC1=c$JJB9TO@M}7?8@8l$N0l$D$G$"$k!#(B
%
$B=R8l8F$S=P$7$K$h$C$FJB9T%W%m%;%9$rF0E*@8@.$7!"(B
$BO@M}JQ?t$rDL?.O)$H$7$FHsF14|%W%m%;%94VDL?.$r9T$&!#(B
%
$BO@M}JQ?t$r4^$`%a%C%;!<%8$rDL?.O)$KN.$9$3$H$K$h$C$F!"(B
$BO@M}%M%C%H%o!<%/$rF0E*9=@.$9$k$3$H$,$G$-$k!#(B

$B%f!<%6$d1s3V%W%m%;%9$b$^$?!"JB9T%W%m%;%9$N0l<o$G$"$k$H9M$($i$l$k!#(B
%
$B=>$C$F!"JB9T%W%m%;%9$HHsF14|%W%m%;%94VDL?.$rMQ$$$k(B
KL1 $B8@8l$N%W%m%0%i%_%s%0%9%?%$%k$O!"(B
$BJ,;6%W%m%;%9$K$h$k6(D4=hM}$N5-=R$KE,$7$F$$$k$H8@$($k!#(B


\section{ KL1 $B8@8l$N35MW(B \Comment{Syntax, Semantics} }

\newcommand{\var}[1]{{\it #1}}
\newcommand{\Head}{\var{Head}}
\newcommand{\Guard}{\var{Guard}}
\newcommand{\Body}{\var{Body}}

KL1 $B%W%m%0%i%`$O=R8l$N=89g$+$i@.$j!"(B
\term{$B=R8l(B (predicate)} $B$O@a$N=89g$+$i@.$k!#(B
\term{$B@a(B (clause)} $B$O<!$N$h$&$J7A$r$7$F$$$k!#(B
\begin{quote}
{\Head} :- {\Guard} \(|\) {\Body} .
\end{quote}
$B$3$3$G!"(B\Head $B$O0l3,=R8lO@M}$N86;RO@M}<0$G$"$j!"(B
\Guard $B$H(B \Body $B$O86;RO@M}<0$N%^%k%A=89g$G$"$k!#(B
\Head $B$H(B \Guard $B$O$=$N@a$,<B9T$5$l$k$?$a$N>r7o$rI=$7!"(B
\Body $BFb$N86;RO@M}<0$O(B\term{$B=R8l8F=P$7(B}$B!"(B
$B$9$J$o$A(B\term{$B%4!<%k(B (goal)}$B$rI=$9!#(B

$BNc$($P!"6d9T8}:B$rI=$9=R8l$O<!$N$h$&$K=q$1$k!#(B
\begin{verbatim}
account(Request, State) :- Request = [balance(Balance)|Request1] |
  Balance := State,
  account(Request1, State).
account(Request, State) :- Request = [exchange(Amount)|Request1] |
  State1 := State + Amount,
  account(Request1, State1).
\end{verbatim}

$B$3$N=R8l$O(B account $B$H$$$&L>A0$r;}$A!"(B
$B0z?t$N8D?t(B (arity) $B$,Fs$D$G$"$k$?$a!"(B
account/2 $B=R8l$H8F$P$l$k!#(B

State $B$O8}:B$N;D9b$rI=$9!#(B
%
$B$3$N8}:B$KBP$9$k=hM}MW5a$O(B Request $B$X(B
$B%a%C%;!<%8$r=q$-9~$`$3$H$K$h$C$FI=8=$9$k!#(B
%
$BNc$($P!"(Bbalance/1 $B%a%C%;!<%8$O8=:_$N;D9b$r;2>H$9$k!#(B
$B0z?t(B Balance $B$K8=:_$N;D9b$,JV$5$l$k!#(B
%
$B$^$?!"(Bexchange/1 $B%a%C%;!<%8$O$3$N8}:B$KBP$7$F(B
Amount $B1_$N?6$j9~$_!JIi?t$J$i0z$-=P$7!K$r9T$&!#(B

exchange/1 $B%a%C%;!<%8$N=hM}$,Bh(B\ref{dist}$B>O$N(B
$BIT2DJ,$J?6$j9~$_!&0z$-=P$7=hM}$KAjEv$9$k$3$H$KCm0U$;$h!#(B
%
balance/1 $B%a%C%;!<%8$N=hM}$OIT2DJ,$J?6$j9~$_!&0z$-=P$7(B
$B=hM}$N0lIt$G$"$kFI$_9~$_A`:n$N$_$r9T$&$h$&$J=hM}$G$"$k!#(B


\section{ $B8@8l3K$KAH$_9~$^$l$?F14|$H<+F0GSB>@)8f(B }

account/2 $B=R8l$N?6$j9~$_=hM}$O!"<jB3$-7?$N%W%m%0%i%`$N$h$&$K(B
$B;D9b$rI=$9JQ?t(B State $B$rD>@\=q$-49$($kBe$o$j$K!"(B
$B=q$-49$(8e$N;D9b$rI=$9JQ?t(B State1 $B$rF3F~$7$F$$$k!#(B
%
$B0lHL$K!"(B\term{$BC10lBeF~JQ?t(B}$B$r;}$D=c4X?t7?8@8l$d(B
$BO@M}7?8@8l$G>uBV$r=q$-49$($k;~$K$O!"(B
$B$3$N$h$&$K<!>uBVJQ?t$rF3F~$9$k!#(B

% continuation
State $B$N3F>uBV$O8}:B;D9b$NMzNr$G$"$j!"(B
Request $B$O8}:B$KBP$9$kA`:n$NMzNr(B (journal)
$B$G$"$k$H9M$($k$3$H$,$G$-$k!#(B

KL1 $B8@8l$G$O!"A4$F$N%4!<%k$OJB9T$K<B9T$5$l$k$,!"(B
\Head $B$d(B \Guard $B$GL$Dj5AJQ?t$N6qBNCM$rFI$_9~$`$H!"(B
$B$=$N@a$N<B9T$O6qBNCM$,7hDj$9$k$^$GCfCG$9$k$3$H$K$J$C$F$$$k!#(B

$BNc$($P!"(B
\begin{verbatim}
  State1 := State + Amount,
\end{verbatim}
$B$,<B9T$5$l$k$^$G(B State1 $B$N6qBNCM$O7hDj$5$l$J$$!#(B
%
$B=>$C$F!"(Bexchange/1 $B%a%C%;!<%8$ND>8e$KB>$N%a%C%;!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\ref{type-mode}$B$G=R$Y$k%b!<%IIU$1$K$h$C$F(B
$B@EE*$JGSB>@)8f$r9T$&$Y$-$G$"$k!#(B


\section{ $BDL?.O)(B (Channels) }

KL1 $B8@8l$NJQ?t$OC10lBeF~$G$"$k$@$1$G$J$/!"(B
first-class $B$N(B\term{$BO@M}JQ?t(B}$B$G$"$k!#(B
%
$B$9$J$o$A!"O@M}JQ?t$O6qBNCM$N7hDj$7$F$$$J$$L$Dj5A>uBV$N$^$^!"(B
\term{$B9`(B (term)}$B$H8F$P$l$k(B KL1 $B8@8l$N(B
$B%G!<%?I=8=LZ$N0lIt$H$7$FB>$N%W%m%;%9$KEO$9$3$H$,$G$-$k!#(B

$BNc$($P!"(Bbalance/1 $B%a%C%;!<%8$NH/?.<T$O;D9b$rCN$i$J$$$N$G!"(B
$B0z?t(B Balance $B$rL$Dj5A$N$^$^(B account/2 $B=R8l$KEO$9!#(B
%
account/2 $B=R8l$O0z?t(B Balance $B$K(B
$B;D9b$r=q$-9~$`$3$H$K$h$C$FJV;v$r$9$k!#(B
%
Balance $B$N$h$&$K7k2L$rJV$9$?$a$NJQ?t$rJV?.H"(B (Reply Boxes) $B$H8F$V!#(B

$B$^$?Nc$($P!"(Baccount/2 $B=R8l$X(B exchange/1 $B%a%C%;!<%8$rAw$k$3$H$O!"(B
$B0z?t(B Request $B$K6qBNCM(B {\tt[exchange(Amount)|Request1]}
$B$r=q$-9~$`$3$H$K$h$C$FI=8=$9$k$,!"(B
$B$3$N$H$-B3$/%a%C%;!<%8Ns(B Request1 $B$O$^$@L$Dj5A$G$"$m$&!#(B
%
Request $B$N$h$&$K=y!9$K=q$-9~$^$l$F$f$/%a%C%;!<%8Ns$r(B
\term{$B%9%H%j!<%`(B (stream)} $B$H8F$V!#(B

% single-assignment channel
% channel mobility (cf. $\pi$-calculus)
% channel $\in$ Message
% channel fusion

$BO@M}JQ?t$ODL?.O)$G$"$k!#(B
%
$BNc$($P!"<!$N(B append/3 $B=R8l$O(B
$B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O@M}JQ?t$NM"=PF~$H(B
$BJ,;6C10l2=$r<B8=$7$J$1$l$P$J$i$J$$!#(B


\section{
 Type / Mode
 % / Linearity
 System }
\label{type-mode}

$BK\@a$G$O!"(B
KL1 $B8@8l$K$*$1$k9bEY$J@EE*2r@O$NBN7O$K$D$$$F2r@b$9$k!#(B

$B7?BN7O$O!"=c4X?t7?8@8l$K$*$$$F8&5f$,@9$s$G$"$k!#(B
%
KL1 $B8@8l$G$O%W%m%0%i%^$,JQ?t$N7?$rL@<(E*$K@k8@$9$k$3$H$O$J$/!"(B
$B=>$C$F!"(BKL1 $B%W%m%0%i%`$NJQ?t$K$O7?$,$J$$(B (type-less) $B$,!"(B
$B%W%m%0%i%`$N@EE*2r@O$K$h$k7?:F9=@.$,2DG=$G$"$k!#(B

$BNc$($P!"(Baccount/2 $B=R8l$N(B State $B0z?t$O!"(B
\begin{verbatim}
  State1 := State + Amount,
\end{verbatim}
$B$+$iJ,$+$k$h$&$K?tCM7?$r;}$D!#(B
%
$B$^$?!"(BRequest $B0z?t$O(B
\begin{verbatim}
account(Request, State) :- Request = [exchange(Amount)|Request1] |
\end{verbatim}
$B$+$iJ,$+$k$h$&$K!"%3%s%9!J%j%9%H%;%k!K7?$r;}$D!#(B

$B$3$N$h$&$KJQ?t$,FCDj$N7?$N6qBNCM$N$_$r$H$k$3$H$O(B
$BNI$$%W%m%0%i%`$N@-<A$G$"$j!"7?IU$-(B (well-typed) $B$H8@$o$l$k!#(B
%
$BA0=R$N<+F08m$j=$@57O(B Kima $B$O(B
$B%W%m%0%i%`$N7?IU$-$G$J$$ItJ,$rJs9p$7!"=$@50F$rDs<($9$k!#(B

$B%b!<%IBN7O$O!"JQ?t$KBP$9$kFI$_=q$-$N(B
$B%b!<%I!JJ}8~!K$K4X$9$kBN7O$G$"$k!#(B

$BNc$($P!"(Bbalance/1 $B%a%C%;!<%8$N0z?t(B Balance $B$N=q$-<j$O(B
balance/1 $B%a%C%;!<%8$NH/?.<T$G$J$/!"(Baccount/2 $B=R8l$G$"$k!#(B
%
$B=>$C$F!"(Baccount/2 $B=R8l$K$H$C$F(B Balance $B$N%b!<%I$O=q$-9~$_(B
(out) $B$G$"$k!#(B
%
$B5U$K!"(Bbalance/1 $B%a%C%;!<%8$NH/?.<T$K$H$C$F(B
Balance $B$N%b!<%I$OFI$_9~$_(B (in) $B$G$"$k!#(B

$B$3$N$h$&$KF10l$NJQ?t$KBP$9$k%b!<%I$O=q$-<j$HFI$_<j$N4V$G5UE>$9$k!#(B
%
$BJQ?t$X$N=q$-<j$,$?$@0l?M$G$"$k$3$H$ONI$$%W%m%0%i%`$N@-<A$G$"$j!"(B
$B%b!<%IIU$-(B (well-moded) $B$H8@$o$l$k!#(B
%
$B<+F08m$j=$@57O(B Kima $B$O%W%m%0%i%`$N%b!<%IIU$-(B
$B$G$J$$ItJ,$rJs9p$7!"=$@50F$rDs<($9$k!#(B

$B@EE*$KGSB>@)8f$5$l$F$$$J$$%b!<%I$J$7$N%W%m%0%i%`$NB?$/$O!"(B
$B$=$l$HEy2A$J7W;;$r9T$J$&%b!<%IIU$-$N!J@EE*$KGSB>@)8f$5$l$?!K(B
$B%W%m%0%i%`$K=q$-49$($k$3$H$,$G$-$k!#(B
%
$B%b!<%I$J$7$N%W%m%0%i%`$rEy2A$J%b!<%IIU$-$N%W%m%0%i%`$K(B
$B=q$-49$($kJ}K!$K$D$$$F$O!"IUO?(B\ref{moding}$B$r;2>H$;$h!#(B


\Comment{
\section{ $B@lMQJBNs5!(B PIM $B>e$N=hM}7O(B }
$B%*%Z%l!<%F%#%s%0%7%9%F%`(B PIMOS
$BAq1`(B
} % end Comment


\section{ KLIC $B=hM}7O(B }

KLIC $B=hM}7O$O4{B8$N(B KL1 $B8@8l=hM}7O$N0l$D$G$"$k!#(B

KLIC $B=hM}7O$OF10l$N5!<o!"%*%Z%l!<%F%#%s%0%7%9%F%`$r;}$D(B
$BJ#?t$N%[%9%H$GF0:n$9$k(B PVM (Parallel Virtual Machine)
$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