diff options
Diffstat (limited to 'comparison/Inpla/src')
| -rw-r--r-- | comparison/Inpla/src/bsort-40000-reuse.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/bsort-40000.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/isort-40000-reuse.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/isort-40000.in | 2 | ||||
| -rw-r--r-- | comparison/Inpla/src/msort-260000-reuse.in | 51 | ||||
| -rw-r--r-- | comparison/Inpla/src/msort-260000.in | 51 | ||||
| -rw-r--r-- | comparison/Inpla/src/qsort-260000-reuse.in | 44 | ||||
| -rw-r--r-- | comparison/Inpla/src/qsort-260000.in | 44 |
8 files changed, 194 insertions, 4 deletions
diff --git a/comparison/Inpla/src/bsort-40000-reuse.in b/comparison/Inpla/src/bsort-40000-reuse.in index 5908f83..d5b23ff 100644 --- a/comparison/Inpla/src/bsort-40000-reuse.in +++ b/comparison/Inpla/src/bsort-40000-reuse.in @@ -18,7 +18,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/bsort-40000.in b/comparison/Inpla/src/bsort-40000.in index d3c8267..58a63da 100644 --- a/comparison/Inpla/src/bsort-40000.in +++ b/comparison/Inpla/src/bsort-40000.in @@ -18,7 +18,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/isort-40000-reuse.in b/comparison/Inpla/src/isort-40000-reuse.in index 1f7153d..daedf3a 100644 --- a/comparison/Inpla/src/isort-40000-reuse.in +++ b/comparison/Inpla/src/isort-40000-reuse.in @@ -16,7 +16,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => (*L)valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/isort-40000.in b/comparison/Inpla/src/isort-40000.in index 0e3ed32..4947e28 100644 --- a/comparison/Inpla/src/isort-40000.in +++ b/comparison/Inpla/src/isort-40000.in @@ -16,7 +16,7 @@ make_RandList(ret) >< (int n) // validation checks -valid(ret) >< [] => ret~False; +valid(ret) >< [] => ret~True; valid(ret) >< x:xs => valid_Cons(ret,x)~xs; valid_Cons(ret, int x) >< [] => ret~True; diff --git a/comparison/Inpla/src/msort-260000-reuse.in b/comparison/Inpla/src/msort-260000-reuse.in new file mode 100644 index 0000000..7201ac7 --- /dev/null +++ b/comparison/Inpla/src/msort-260000-reuse.in @@ -0,0 +1,51 @@ +// Merge sort +msort(ret) >< [] => ret~[]; +msort(ret) >< x:xs => (*L)msort_tail(ret, x)~xs; + +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; + +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; + + +// 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~True; +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=260000; + +make_RandList(rndlist)~(LIST_ELEM), +msort(sorted)~rndlist, +valid(ret)~sorted; + +ret; diff --git a/comparison/Inpla/src/msort-260000.in b/comparison/Inpla/src/msort-260000.in new file mode 100644 index 0000000..efa464d --- /dev/null +++ b/comparison/Inpla/src/msort-260000.in @@ -0,0 +1,51 @@ +// Merge sort +msort(ret) >< [] => ret~[]; +msort(ret) >< x:xs => msort_tail(ret, x)~xs; + +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; + +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; + + +// 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~True; +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=260000; + +make_RandList(rndlist)~(LIST_ELEM), +msort(sorted)~rndlist, +valid(ret)~sorted; + +ret; diff --git a/comparison/Inpla/src/qsort-260000-reuse.in b/comparison/Inpla/src/qsort-260000-reuse.in new file mode 100644 index 0000000..b44e958 --- /dev/null +++ b/comparison/Inpla/src/qsort-260000-reuse.in @@ -0,0 +1,44 @@ +// Quick sort +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; + + +// 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~True; +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=260000; + +make_RandList(rndlist)~(LIST_ELEM), +qsort(sorted)~rndlist, +valid(ret)~sorted; + +ret; diff --git a/comparison/Inpla/src/qsort-260000.in b/comparison/Inpla/src/qsort-260000.in new file mode 100644 index 0000000..2f7d63c --- /dev/null +++ b/comparison/Inpla/src/qsort-260000.in @@ -0,0 +1,44 @@ +// Quick sort +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; + + +// 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~True; +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=260000; + +make_RandList(rndlist)~(LIST_ELEM), +qsort(sorted)~rndlist, +valid(ret)~sorted; + +ret; |
