aboutsummaryrefslogtreecommitdiff
path: root/comparison/Inpla/src
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:41:58 +0900
committerShinya Sato <shinnya.sato@gmail.com>2022-04-28 21:41:58 +0900
commiteddac153a064648bee2aef6fb733ab6820bb96c3 (patch)
treec12f212dc501e6053ec034d1a9f4734b8b94b4d2 /comparison/Inpla/src
parent1c9344fa14cc018558ec9ebfbf1215a772960b6e (diff)
downloadinpla-eddac153a064648bee2aef6fb733ab6820bb96c3.tar.gz
inpla-eddac153a064648bee2aef6fb733ab6820bb96c3.zip
v0.8.2
Diffstat (limited to 'comparison/Inpla/src')
-rw-r--r--comparison/Inpla/src/bsort-40000-reuse.in35
-rw-r--r--comparison/Inpla/src/bsort-40000.in35
-rw-r--r--comparison/Inpla/src/isort-40000-reuse.in34
-rw-r--r--comparison/Inpla/src/isort-40000.in34
-rw-r--r--comparison/Inpla/src/msort-800000-reuse.in59
-rw-r--r--comparison/Inpla/src/msort-800000.in59
-rw-r--r--comparison/Inpla/src/qsort-800000-reuse.in46
-rw-r--r--comparison/Inpla/src/qsort-800000.in46
8 files changed, 244 insertions, 104 deletions
diff --git a/comparison/Inpla/src/bsort-40000-reuse.in b/comparison/Inpla/src/bsort-40000-reuse.in
index 3abd0ec..5908f83 100644
--- a/comparison/Inpla/src/bsort-40000-reuse.in
+++ b/comparison/Inpla/src/bsort-40000-reuse.in
@@ -1,7 +1,7 @@
// Bubble sort
-BS(ret) >< [] => ret~[];
-BS(ret) >< x:xs => (*L)BS(ret)~cnt, (*R)B(cnt, x)~xs;
-BS(ret) >< M(x) => ret~x;
+bsort(ret) >< [] => ret~[];
+bsort(ret) >< x:xs => (*L)bsort(ret)~cnt, (*R)B(cnt, x)~xs;
+bsort(ret) >< M(x) => ret~x;
B(ret, int x) >< [] => ret~M([x]);
B(ret, int x) >< M(w) => ret~M(x:w);
@@ -10,14 +10,31 @@ B(ret, int x) >< (int y):ys
| _ => ret~(*R)(y:cnt), (*L)B(cnt, x)~ys;
+// Creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=40000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+bsort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-BS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/bsort-40000.in b/comparison/Inpla/src/bsort-40000.in
index d0a5e1c..d3c8267 100644
--- a/comparison/Inpla/src/bsort-40000.in
+++ b/comparison/Inpla/src/bsort-40000.in
@@ -1,7 +1,7 @@
// Bubble sort
-BS(ret) >< [] => ret~[];
-BS(ret) >< x:xs => BS(ret)~cnt, B(cnt, x)~xs;
-BS(ret) >< M(x) => ret~x;
+bsort(ret) >< [] => ret~[];
+bsort(ret) >< x:xs => bsort(ret)~cnt, B(cnt, x)~xs;
+bsort(ret) >< M(x) => ret~x;
B(ret, int x) >< [] => ret~M([x]);
B(ret, int x) >< M(w) => ret~M(x:w);
@@ -10,14 +10,31 @@ B(ret, int x) >< (int y):ys
| _ => ret~(y:cnt), B(cnt, x)~ys;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=40000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+bsort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-BS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/isort-40000-reuse.in b/comparison/Inpla/src/isort-40000-reuse.in
index 3e7e2d2..1f7153d 100644
--- a/comparison/Inpla/src/isort-40000-reuse.in
+++ b/comparison/Inpla/src/isort-40000-reuse.in
@@ -1,6 +1,6 @@
// Insertion sort
-IS(ret) >< [] => ret~[];
-IS(ret) >< x:xs => (*L)I(ret, x)~cnt, (*R)IS(cnt)~xs;
+isort(ret) >< [] => ret~[];
+isort(ret) >< x:xs => (*L)I(ret, x)~cnt, (*R)isort(cnt)~xs;
I(ret, int x) >< [] => ret~[x];
I(ret, int x) >< (int y):ys
@@ -8,13 +8,31 @@ I(ret, int x) >< (int y):ys
| _ => ret~(*L)(y:cnt), (*R)I(cnt, x)~ys;
-const LIST_ELEM=40000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-IS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=40000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+isort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/isort-40000.in b/comparison/Inpla/src/isort-40000.in
index 295f6f4..0e3ed32 100644
--- a/comparison/Inpla/src/isort-40000.in
+++ b/comparison/Inpla/src/isort-40000.in
@@ -1,6 +1,6 @@
// Insertion sort
-IS(ret) >< [] => ret~[];
-IS(ret) >< x:xs => I(ret, x)~cnt, IS(cnt)~xs;
+isort(ret) >< [] => ret~[];
+isort(ret) >< x:xs => I(ret, x)~cnt, isort(cnt)~xs;
I(ret, int x) >< [] => ret~[x];
I(ret, int x) >< (int y):ys
@@ -8,13 +8,31 @@ I(ret, int x) >< (int y):ys
| _ => ret~(y:cnt), I(cnt, x)~ys;
-const LIST_ELEM=40000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-IS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=40000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+isort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/msort-800000-reuse.in b/comparison/Inpla/src/msort-800000-reuse.in
index 5f57484..4572623 100644
--- a/comparison/Inpla/src/msort-800000-reuse.in
+++ b/comparison/Inpla/src/msort-800000-reuse.in
@@ -1,34 +1,51 @@
// Merge sort
-MS(ret) >< [] => ret~[];
-MS(ret) >< x:xs => (*L)MS_tail(ret, x)~xs;
+msort(ret) >< [] => ret~[];
+msort(ret) >< x:xs => (*L)msort_tail(ret, x)~xs;
-MS_tail(ret, int n) >< [] => ret~[n];
-MS_tail(ret, int n) >< x:xs =>
- Split(left,right) ~ (*R)(n:x:xs),
- MS(a)~left, MS(b)~right, (*L)Merge(ret,b)~a;
+msort_tail(ret, int n) >< [] => ret~[n];
+msort_tail(ret, int n) >< x:xs =>
+ split(left,right) ~ (*R)(n:x:xs),
+ msort(a)~left, msort(b)~right, (*L)merge(ret,b)~a;
-Merge(ret, snd) >< [] => ret~snd;
-Merge(ret, snd) >< x:xs => (*L)MergeCC(ret, x, xs)~snd;
+merge(ret, snd) >< [] => ret~snd;
+merge(ret, snd) >< x:xs => (*L)mergeCC(ret, x, xs)~snd;
-MergeCC(ret, int y, ys) >< [] => ret~(*R)(y:ys);
-MergeCC(ret, int y, ys) >< (int x):xs
-| x <= y => ret~(x:cnt), (*L)MergeCC(cnt, y, ys) ~ xs
-| _ => ret~(y:cnt), (*L)MergeCC(cnt, x, xs) ~ ys;
+mergeCC(ret, int y, ys) >< [] => ret~(*R)(y:ys);
+mergeCC(ret, int y, ys) >< (int x):xs
+| x <= y => ret~(x:cnt), (*L)mergeCC(cnt, y, ys) ~ xs
+| _ => ret~(y:cnt), (*L)mergeCC(cnt, x, xs) ~ ys;
-Split(right,left) >< [] => right~[], left~[];
-Split(right,left) >< x:xs =>
- right~(*R)(x:cntl), left~cntr, (*L)Split(cntr,cntl)~xs;
+split(right,left) >< [] => right~[], left~[];
+split(right,left) >< x:xs =>
+ right~(*R)(x:cntl), left~cntr, (*L)split(cntr,cntl)~xs;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=800000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+msort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-MS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/msort-800000.in b/comparison/Inpla/src/msort-800000.in
index b77f353..3c43aa6 100644
--- a/comparison/Inpla/src/msort-800000.in
+++ b/comparison/Inpla/src/msort-800000.in
@@ -1,34 +1,51 @@
// Merge sort
-MS(ret) >< [] => ret~[];
-MS(ret) >< x:xs => MS_tail(ret, x)~xs;
+msort(ret) >< [] => ret~[];
+msort(ret) >< x:xs => msort_tail(ret, x)~xs;
-MS_tail(ret, int n) >< [] => ret~[n];
-MS_tail(ret, int n) >< x:xs =>
- Split(left,right) ~ (n:x:xs),
- MS(a)~left, MS(b)~right, Merge(ret,b)~a;
+msort_tail(ret, int n) >< [] => ret~[n];
+msort_tail(ret, int n) >< x:xs =>
+ split(left,right) ~ (n:x:xs),
+ msort(a)~left, msort(b)~right, merge(ret,b)~a;
-Merge(ret, snd) >< [] => ret~snd;
-Merge(ret, snd) >< x:xs => MergeCC(ret, x, xs)~snd;
+merge(ret, snd) >< [] => ret~snd;
+merge(ret, snd) >< x:xs => mergeCC(ret, x, xs)~snd;
-MergeCC(ret, int y, ys) >< [] => ret~(y:ys);
-MergeCC(ret, int y, ys) >< (int x):xs
-| x <= y => ret~(x:cnt), MergeCC(cnt, y, ys) ~ xs
-| _ => ret~(y:cnt), MergeCC(cnt, x, xs) ~ ys;
+mergeCC(ret, int y, ys) >< [] => ret~(y:ys);
+mergeCC(ret, int y, ys) >< (int x):xs
+| x <= y => ret~(x:cnt), mergeCC(cnt, y, ys) ~ xs
+| _ => ret~(y:cnt), mergeCC(cnt, x, xs) ~ ys;
-Split(right,left) >< [] => right~[], left~[];
-Split(right,left) >< x:xs =>
- right~(x:cntl), left~cntr, Split(cntr,cntl)~xs;
+split(right,left) >< [] => right~[], left~[];
+split(right,left) >< x:xs =>
+ right~(x:cntl), left~cntr, split(cntr,cntl)~xs;
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
+ where rd=rand(10000)
+| _ => ret~[];
+
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
const LIST_ELEM=800000;
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
- where rd=rand(10000)
-| _ => ret~[];
+make_RandList(rndlist)~(LIST_ELEM),
+msort(sorted)~rndlist,
+valid(ret)~sorted;
-MkRandList(cnt)~(LIST_ELEM),
-MS(ret)~cnt;
ret;
diff --git a/comparison/Inpla/src/qsort-800000-reuse.in b/comparison/Inpla/src/qsort-800000-reuse.in
index 810e446..7f41045 100644
--- a/comparison/Inpla/src/qsort-800000-reuse.in
+++ b/comparison/Inpla/src/qsort-800000-reuse.in
@@ -1,26 +1,44 @@
// Quick sort
-QS(ret) >< [] => ret~(*R)[];
-QS(ret) >< (int x):xs =>
- (*R)Part(x, left, right)~xs,
- (*L)QS(cntl)~left, QS(cntr)~right,
+qsort(ret) >< [] => ret~(*R)[];
+qsort(ret) >< (int x):xs =>
+ (*R)part(x, left, right)~xs,
+ (*L)qsort(cntl)~left, qsort(cntr)~right,
Append(ret, x:cntl)~cntr;
// Note: `Append' is implemented as built-in.
-Part(int x, a, b) >< [] => a~(*L)[], b~(*R)[];
-Part(int x, a, b) >< (int y):ys
-| y<x => b~(*R)(y:cnt), (*L)Part(x, a, cnt)~ys
-| _ => a~(*R)(y:cnt), (*L)Part(x, cnt, b)~ys;
+part(int x, a, b) >< [] => a~(*L)[], b~(*R)[];
+part(int x, a, b) >< (int y):ys
+| y<x => b~(*R)(y:cnt), (*L)part(x, a, cnt)~ys
+| _ => a~(*R)(y:cnt), (*L)part(x, cnt, b)~ys;
-const LIST_ELEM=800000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), (*L)MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), (*L)make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-QS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => (*L)valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=800000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+qsort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;
diff --git a/comparison/Inpla/src/qsort-800000.in b/comparison/Inpla/src/qsort-800000.in
index 8226655..6d28245 100644
--- a/comparison/Inpla/src/qsort-800000.in
+++ b/comparison/Inpla/src/qsort-800000.in
@@ -1,26 +1,44 @@
// Quick sort
-QS(ret) >< [] => ret~[];
-QS(ret) >< (int x):xs =>
- Part(x, left, right)~xs,
- QS(cntl)~left, QS(cntr)~right,
+qsort(ret) >< [] => ret~[];
+qsort(ret) >< (int x):xs =>
+ part(x, left, right)~xs,
+ qsort(cntl)~left, qsort(cntr)~right,
Append(ret, x:cntl)~cntr;
// Note: `Append' is implemented as built-in.
-Part(int x, a, b) >< [] => a~[], b~[];
-Part(int x, a, b) >< (int y):ys
-| y<x => b~(y:cnt), Part(x, a, cnt)~ys
-| _ => a~(y:cnt), Part(x, cnt, b)~ys;
+part(int x, a, b) >< [] => a~[], b~[];
+part(int x, a, b) >< (int y):ys
+| y<x => b~(y:cnt), part(x, a, cnt)~ys
+| _ => a~(y:cnt), part(x, cnt, b)~ys;
-const LIST_ELEM=800000;
-
-MkRandList(ret) >< (int n)
-| n>0 => ret~(rd:cnt), MkRandList(cnt)~(n-1)
+// creates a random list
+make_RandList(ret) >< (int n)
+| n>0 => ret~(rd:cnt), make_RandList(cnt)~(n-1)
where rd=rand(10000)
| _ => ret~[];
-MkRandList(cnt)~(LIST_ELEM),
-QS(ret)~cnt;
+
+// validation checks
+valid(ret) >< [] => ret~False;
+valid(ret) >< x:xs => valid_Cons(ret,x)~xs;
+
+valid_Cons(ret, int x) >< [] => ret~True;
+valid_Cons(ret, int x) >< (int y):ys
+| x<=y => valid_Cons(ret,y)~ys
+| _ => ret~False, Eraser~ys;
+
+// The `Eraser' is a built-in agent defined for any agents as follows:
+//Eraser >< Alpha(a1, ..., a5) => Eraser~a1, ..., Eraser~a5;
+
+
+// Main
+const LIST_ELEM=800000;
+
+make_RandList(rndlist)~(LIST_ELEM),
+qsort(sorted)~rndlist,
+valid(ret)~sorted;
+
ret;