The rewrite relation of the following TRS is considered.
app(app(times,x),0) | → | 0 | (1) |
app(app(times,x),app(s,y)) | → | app(app(plus,app(app(times,x),y)),x) | (2) |
app(app(plus,x),0) | → | x | (3) |
app(app(plus,0),x) | → | x | (4) |
app(app(plus,x),app(s,y)) | → | app(s,app(app(plus,x),y)) | (5) |
app(app(plus,app(s,x)),y) | → | app(s,app(app(plus,x),y)) | (6) |
app(app(map,f),nil) | → | nil | (7) |
app(app(map,f),app(app(cons,x),xs)) | → | app(app(cons,app(f,x)),app(app(map,f),xs)) | (8) |
app(app(filter,f),nil) | → | nil | (9) |
app(app(filter,f),app(app(cons,x),xs)) | → | app(app(app(app(filter2,app(f,x)),f),x),xs) | (10) |
app(app(app(app(filter2,true),f),x),xs) | → | app(app(cons,x),app(app(filter,f),xs)) | (11) |
app(app(app(app(filter2,false),f),x),xs) | → | app(app(filter,f),xs) | (12) |
We uncurry the binary symbol app in combination with the following symbol map which also determines the applicative arities of these symbols.
times | is mapped to | times, | times1(x1), | times2(x1, x2) | ||
0 | is mapped to | 0 | ||||
s | is mapped to | s, | s1(x1) | |||
plus | is mapped to | plus, | plus1(x1), | plus2(x1, x2) | ||
map | is mapped to | map, | map1(x1), | map2(x1, x2) | ||
nil | is mapped to | nil | ||||
cons | is mapped to | cons, | cons1(x1), | cons2(x1, x2) | ||
filter | is mapped to | filter, | filter1(x1), | filter3(x1, x2) | ||
filter2 | is mapped to | filter2, | filter21(x1), | filter22(x1, x2), | filter23(x1, x2, x3), | filter24(x1,...,x4) |
true | is mapped to | true | ||||
false | is mapped to | false |
times2(x,0) | → | 0 | (28) |
times2(x,s1(y)) | → | plus2(times2(x,y),x) | (29) |
plus2(x,0) | → | x | (30) |
plus2(0,x) | → | x | (31) |
plus2(x,s1(y)) | → | s1(plus2(x,y)) | (32) |
plus2(s1(x),y) | → | s1(plus2(x,y)) | (33) |
map2(f,nil) | → | nil | (34) |
map2(f,cons2(x,xs)) | → | cons2(app(f,x),map2(f,xs)) | (35) |
filter3(f,nil) | → | nil | (36) |
filter3(f,cons2(x,xs)) | → | filter24(app(f,x),f,x,xs) | (37) |
filter24(true,f,x,xs) | → | cons2(x,filter3(f,xs)) | (38) |
filter24(false,f,x,xs) | → | filter3(f,xs) | (39) |
app(times,y1) | → | times1(y1) | (13) |
app(times1(x0),y1) | → | times2(x0,y1) | (14) |
app(s,y1) | → | s1(y1) | (15) |
app(plus,y1) | → | plus1(y1) | (16) |
app(plus1(x0),y1) | → | plus2(x0,y1) | (17) |
app(map,y1) | → | map1(y1) | (18) |
app(map1(x0),y1) | → | map2(x0,y1) | (19) |
app(cons,y1) | → | cons1(y1) | (20) |
app(cons1(x0),y1) | → | cons2(x0,y1) | (21) |
app(filter,y1) | → | filter1(y1) | (22) |
app(filter1(x0),y1) | → | filter3(x0,y1) | (23) |
app(filter2,y1) | → | filter21(y1) | (24) |
app(filter21(x0),y1) | → | filter22(x0,y1) | (25) |
app(filter22(x0,x1),y1) | → | filter23(x0,x1,y1) | (26) |
app(filter23(x0,x1,x2),y1) | → | filter24(x0,x1,x2,y1) | (27) |
prec(times2) | = | 3 | stat(times2) | = | mul | |
prec(0) | = | 0 | stat(0) | = | mul | |
prec(s1) | = | 1 | stat(s1) | = | mul | |
prec(plus2) | = | 2 | stat(plus2) | = | mul | |
prec(map2) | = | 12 | stat(map2) | = | lex | |
prec(nil) | = | 4 | stat(nil) | = | mul | |
prec(cons2) | = | 5 | stat(cons2) | = | mul | |
prec(app) | = | 12 | stat(app) | = | lex | |
prec(filter3) | = | 12 | stat(filter3) | = | lex | |
prec(filter24) | = | 12 | stat(filter24) | = | lex | |
prec(true) | = | 13 | stat(true) | = | mul | |
prec(false) | = | 14 | stat(false) | = | mul | |
prec(times) | = | 15 | stat(times) | = | mul | |
prec(times1) | = | 6 | stat(times1) | = | lex | |
prec(s) | = | 16 | stat(s) | = | mul | |
prec(plus) | = | 17 | stat(plus) | = | mul | |
prec(map) | = | 18 | stat(map) | = | mul | |
prec(map1) | = | 7 | stat(map1) | = | lex | |
prec(cons) | = | 19 | stat(cons) | = | mul | |
prec(cons1) | = | 8 | stat(cons1) | = | mul | |
prec(filter) | = | 20 | stat(filter) | = | mul | |
prec(filter2) | = | 21 | stat(filter2) | = | mul | |
prec(filter21) | = | 11 | stat(filter21) | = | lex | |
prec(filter22) | = | 10 | stat(filter22) | = | lex | |
prec(filter23) | = | 9 | stat(filter23) | = | lex |
π(times2) | = | [1,2] |
π(0) | = | [] |
π(s1) | = | [1] |
π(plus2) | = | [1,2] |
π(map2) | = | [2,1] |
π(nil) | = | [] |
π(cons2) | = | [1,2] |
π(app) | = | [2,1] |
π(filter3) | = | [2,1] |
π(filter24) | = | [4,2,1,3] |
π(true) | = | [] |
π(false) | = | [] |
π(times) | = | [] |
π(times1) | = | [1] |
π(s) | = | [] |
π(plus) | = | [] |
π(plus1) | = | 1 |
π(map) | = | [] |
π(map1) | = | [1] |
π(cons) | = | [] |
π(cons1) | = | [1] |
π(filter) | = | [] |
π(filter1) | = | 1 |
π(filter2) | = | [] |
π(filter21) | = | [1] |
π(filter22) | = | [1,2] |
π(filter23) | = | [1,3,2] |
times2(x,0) | → | 0 | (28) |
times2(x,s1(y)) | → | plus2(times2(x,y),x) | (29) |
plus2(x,0) | → | x | (30) |
plus2(0,x) | → | x | (31) |
plus2(x,s1(y)) | → | s1(plus2(x,y)) | (32) |
plus2(s1(x),y) | → | s1(plus2(x,y)) | (33) |
map2(f,nil) | → | nil | (34) |
map2(f,cons2(x,xs)) | → | cons2(app(f,x),map2(f,xs)) | (35) |
filter3(f,nil) | → | nil | (36) |
filter3(f,cons2(x,xs)) | → | filter24(app(f,x),f,x,xs) | (37) |
filter24(true,f,x,xs) | → | cons2(x,filter3(f,xs)) | (38) |
filter24(false,f,x,xs) | → | filter3(f,xs) | (39) |
app(times,y1) | → | times1(y1) | (13) |
app(times1(x0),y1) | → | times2(x0,y1) | (14) |
app(s,y1) | → | s1(y1) | (15) |
app(plus,y1) | → | plus1(y1) | (16) |
app(plus1(x0),y1) | → | plus2(x0,y1) | (17) |
app(map,y1) | → | map1(y1) | (18) |
app(map1(x0),y1) | → | map2(x0,y1) | (19) |
app(cons,y1) | → | cons1(y1) | (20) |
app(cons1(x0),y1) | → | cons2(x0,y1) | (21) |
app(filter,y1) | → | filter1(y1) | (22) |
app(filter2,y1) | → | filter21(y1) | (24) |
app(filter21(x0),y1) | → | filter22(x0,y1) | (25) |
app(filter22(x0,x1),y1) | → | filter23(x0,x1,y1) | (26) |
app(filter23(x0,x1,x2),y1) | → | filter24(x0,x1,x2,y1) | (27) |
[app(x1, x2)] | = | 2 + 1 · x1 + 2 · x2 |
[filter1(x1)] | = | 1 + 2 · x1 |
[filter3(x1, x2)] | = | 2 · x1 + 2 · x2 |
app(filter1(x0),y1) | → | filter3(x0,y1) | (23) |
There are no rules in the TRS. Hence, it is terminating.