aboutsummaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2022-07-20 00:00:44 +0900
committerShinya Sato <shinnya.sato@gmail.com>2022-07-20 00:00:44 +0900
commitc57cb1fd511d2c69bf332324c73608f309bb4772 (patch)
tree634287f3becc3fae3f81b09cf808b95bba009cae /sample
parente9db0870164cfec10aa219cc0898c30f6a888f53 (diff)
parent633a31e251950349d3b8f9ae208af55667a4f9c4 (diff)
downloadinpla-c57cb1fd511d2c69bf332324c73608f309bb4772.tar.gz
inpla-c57cb1fd511d2c69bf332324c73608f309bb4772.zip
Merge branch 'develop'
Diffstat (limited to '')
-rw-r--r--sample/AckSZ-3_5.in12
-rw-r--r--sample/FibSZ_9.in16
-rw-r--r--sample/hanoi.in19
3 files changed, 26 insertions, 21 deletions
diff --git a/sample/AckSZ-3_5.in b/sample/AckSZ-3_5.in
index 41674d8..4f41966 100644
--- a/sample/AckSZ-3_5.in
+++ b/sample/AckSZ-3_5.in
@@ -20,26 +20,26 @@
// ack(r,y)>< Z => r~S(y);
// ack(r,y)>< S(x) => ack_Sx(r, x)~y;
// ack_Sx(r,x)>< Z => ack(r, S(Z))~x;
-// ack_Sx(r,x)>< S(y) => dup(x1,x2)~x, ack(r,cnt)~x1, ack(cnt,y)~S(x2);
+// ack_Sx(r,x)>< S(y) => Dup(x1,x2)~x, ack(r,cnt)~x1, ack(cnt,y)~S(x2);
// The last connection can be optimised by applying the rule ack><S,
// so finally we get the following as the result of the translation:
ack(r,y)>< Z => r~S(y);
ack(r,y)>< S(x) => ack_Sx(r, x)~y;
ack_Sx(r,x)>< Z => ack(r, S(Z))~x;
-ack_Sx(r,x)>< S(y) => dup(x1,x2)~x, ack(r,cnt)~x1, ack_Sx(cnt,x2)~y;
+ack_Sx(r,x)>< S(y) => Dup(x1,x2)~x, ack(r,cnt)~x1, ack_Sx(cnt,x2)~y;
// By the way, it is possible to write it by using abbreviation notation:
// ack(r,y)>< Z => r~S(y);
// ack(r,y)>< S(x) => r<<ack_Sx(x,y);
// ack_Sx(r,x)>< Z => r<<ack(S(Z),x);
-// ack_Sx(r,x)>< S(y) => x1,x2<<dup(x), r<<ack(cnt,x1), cnt<<ack_Sx(x2,y);
+// ack_Sx(r,x)>< S(y) => x1,x2<<Dup(x), r<<ack(cnt,x1), cnt<<ack_Sx(x2,y);
-
-dup(a1,a2)>< Z => a1~Z, a2~Z;
-dup(a1,a2)>< S(x) => a1~S(w1), a2~S(w2), dup(w1,w2)~x;
+// Dup is defined as built-in:
+// Dup(a1,a2)>< Z => a1~Z, a2~Z;
+// Dup(a1,a2)>< S(x) => a1~S(w1), a2~S(w2), Dup(w1,w2)~x;
// ack(result, y)~x
// For computation `ack 3 5', it is written as follows:
diff --git a/sample/FibSZ_9.in b/sample/FibSZ_9.in
index 288a8bc..b5a65a8 100644
--- a/sample/FibSZ_9.in
+++ b/sample/FibSZ_9.in
@@ -2,15 +2,10 @@
fib(r)><Z => r~Z;
fib(r)><S(x) => fibS(r)~x;
fibS(r)><Z => r~S(Z);
-fibS(r)><S(x) => dup(x1,x2)~x, add(r,r2)~r1, fib(r2)~x2, fibS(r1)~x1;
+fibS(r)><S(x) => Dup(x1,x2)~x, add(r,r2)~r1, fib(r2)~x2, fibS(r1)~x1;
-// ------ DUP ------
-dup(x1,x2)><Z => x1~Z, x2~Z;
-dup(x1,x2)><S(x) => x1~S(w1), x2~S(w2), dup(w1,w2)~x;
-
-
//------ ADD ------
//Add para
add(r,x)><Z => r~x;
@@ -21,6 +16,15 @@ add(r,x)><S(y) => r~S(w), add(w,x)~y;
//add(r,y)><S(x) => add(r, S(y))~x;
+// ------ DUP ------
+// Dup is defined as built-in:
+//
+// Dup(x1,x2)><Z => x1~Z, x2~Z;
+// Dup(x1,x2)><S(x) => x1~S(w1), x2~S(w2), Dup(w1,w2)~x;
+
+
+
+
// Execution
// Fib 9
fib(r)~S(S(S(S(S(S(S(S(S(Z)))))))));
diff --git a/sample/hanoi.in b/sample/hanoi.in
index 2801817..665b2da 100644
--- a/sample/hanoi.in
+++ b/sample/hanoi.in
@@ -3,17 +3,18 @@
// Rules
hanoi(return, source, target, auxiliary) >< (int n)
| n==0 => return~[], Eraser~source, Eraser~target, Eraser~auxiliary
-| _ => source ~ dup(src1, dup(src2, src3)),
- target ~ dup(tgt1, dup(tgt2, tgt3)),
- auxiliary ~ dup(aux1, aux2),
+| _ => source ~ Dup(src1, Dup(src2, src3)),
+ target ~ Dup(tgt1, Dup(tgt2, tgt3)),
+ auxiliary ~ Dup(aux1, aux2),
hanoi(ret1, src1, aux1, tgt1)~(n-1),
hanoi(ret2, aux2, tgt2, src2)~(n-1),
Append(return, (n,src3,tgt3):ret2)~ret1;
// This Append is a bulit-in agent.
-dup(a,b)><A => a~A, b~A;
-dup(a,b)><B => a~B, b~B;
-dup(a,b)><C => a~C, b~C;
+// The Dup is defined as built-in:
+// Dup(a,b)><A => a~A, b~A;
+// Dup(a,b)><B => a~B, b~B;
+// Dup(a,b)><C => a~C, b~C;
// The `Eraser' is defined as a built-in agent for any agents as follows:
//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
@@ -28,9 +29,9 @@ result; // should be [(1,A,C),(2,A,B),(1,C,B),(3,A,C),(1,B,A),(2,B,C),(1,A,C)]
// hanoi(return, source, target, auxiliary) >< (int n)
// | n==0 => return~[],
// << Eraser(source), << Eraser(target), << Eraser(auxiliary)
-// | _ => src1, dup(src2, src3) << dup(source),
-// tgt1, dup(tgt2, tgt3) << dup(target),
-// aux1, aux2 << dup(auxiliary),
+// | _ => src1, Dup(src2, src3) << Dup(source),
+// tgt1, Dup(tgt2, tgt3) << Dup(target),
+// aux1, aux2 << Dup(auxiliary),
// ret1 << hanoi(src1, aux1, tgt1, n-1),
// ret2 << hanoi(aux2, tgt2, src2, n-1),
// return << Append(ret1, (n,src3,tgt3):ret2);