YES We show the termination of the TRS R: app(nil(),k) -> k app(l,nil()) -> l app(cons(x,l),k) -> cons(x,app(l,k)) sum(cons(x,nil())) -> cons(x,nil()) sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) plus(zero(),y) -> y plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) id(x) -> x if(true(),x,y) -> x if(false(),x,y) -> y not(x) -> if(x,false(),true()) gt(s(x),zero()) -> true() gt(zero(),y) -> false() gt(s(x),s(y)) -> gt(x,y) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: app#(cons(x,l),k) -> app#(l,k) p2: sum#(cons(x,cons(y,l))) -> sum#(cons(plus(x,y),l)) p3: sum#(cons(x,cons(y,l))) -> plus#(x,y) p4: sum#(app(l,cons(x,cons(y,k)))) -> sum#(app(l,sum(cons(x,cons(y,k))))) p5: sum#(app(l,cons(x,cons(y,k)))) -> app#(l,sum(cons(x,cons(y,k)))) p6: sum#(app(l,cons(x,cons(y,k)))) -> sum#(cons(x,cons(y,k))) p7: plus#(s(x),s(y)) -> plus#(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))) p8: plus#(s(x),s(y)) -> if#(gt(x,y),x,y) p9: plus#(s(x),s(y)) -> gt#(x,y) p10: plus#(s(x),s(y)) -> if#(not(gt(x,y)),id(x),id(y)) p11: plus#(s(x),s(y)) -> not#(gt(x,y)) p12: plus#(s(x),s(y)) -> id#(x) p13: plus#(s(x),s(y)) -> id#(y) p14: plus#(s(x),x) -> plus#(if(gt(x,x),id(x),id(x)),s(x)) p15: plus#(s(x),x) -> if#(gt(x,x),id(x),id(x)) p16: plus#(s(x),x) -> gt#(x,x) p17: plus#(s(x),x) -> id#(x) p18: plus#(id(x),s(y)) -> plus#(x,if(gt(s(y),y),y,s(y))) p19: plus#(id(x),s(y)) -> if#(gt(s(y),y),y,s(y)) p20: plus#(id(x),s(y)) -> gt#(s(y),y) p21: not#(x) -> if#(x,false(),true()) p22: gt#(s(x),s(y)) -> gt#(x,y) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The estimated dependency graph contains the following SCCs: {p4} {p1} {p2} {p7, p14, p18} {p22} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: sum#(app(l,cons(x,cons(y,k)))) -> sum#(app(l,sum(cons(x,cons(y,k))))) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r1, r2, r3, r4, r5, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: sum#_A(x1) = ((1,0),(1,1)) x1 + (2,1) app_A(x1,x2) = x1 + ((1,0),(0,0)) x2 + (2,7) cons_A(x1,x2) = x2 + (4,3) sum_A(x1) = (5,5) id_A(x1) = x1 + (4,4) if_A(x1,x2,x3) = x2 + x3 + (5,4) true_A() = (0,4) false_A() = (1,6) not_A(x1) = (7,15) gt_A(x1,x2) = (2,3) s_A(x1) = (0,1) zero_A() = (2,5) nil_A() = (1,1) plus_A(x1,x2) = ((1,0),(0,0)) x2 + (3,2) precedence: sum = true = false = gt = s = plus > sum# = app = cons = not = zero = nil > id > if partial status: pi(sum#) = [1] pi(app) = [1] pi(cons) = [] pi(sum) = [] pi(id) = [1] pi(if) = [2, 3] pi(true) = [] pi(false) = [] pi(not) = [] pi(gt) = [] pi(s) = [] pi(zero) = [] pi(nil) = [] pi(plus) = [] 2. weighted path order base order: matrix interpretations: carrier: N^2 order: lexicographic order interpretations: sum#_A(x1) = ((0,0),(1,0)) x1 + (1,0) app_A(x1,x2) = x1 + (3,4) cons_A(x1,x2) = (2,4) sum_A(x1) = (2,4) id_A(x1) = x1 + (8,1) if_A(x1,x2,x3) = x2 + x3 + (3,2) true_A() = (1,1) false_A() = (1,1) not_A(x1) = (6,0) gt_A(x1,x2) = (0,0) s_A(x1) = (7,0) zero_A() = (2,2) nil_A() = (2,4) plus_A(x1,x2) = (9,0) precedence: sum = not = plus > if > sum# = app = cons = id = true = false = gt = s = zero = nil partial status: pi(sum#) = [] pi(app) = [] pi(cons) = [] pi(sum) = [] pi(id) = [1] pi(if) = [2, 3] pi(true) = [] pi(false) = [] pi(not) = [] pi(gt) = [] pi(s) = [] pi(zero) = [] pi(nil) = [] pi(plus) = [] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: app#(cons(x,l),k) -> app#(l,k) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = x1 + 1 cons_A(x1,x2) = max{x1, x2 + 1} precedence: app# = cons partial status: pi(app#) = [1] pi(cons) = [1, 2] 2. weighted path order base order: max/plus interpretations on natural numbers: app#_A(x1,x2) = max{0, x1 - 1} cons_A(x1,x2) = max{x1, x2} precedence: app# = cons partial status: pi(app#) = [] pi(cons) = [1, 2] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: sum#(cons(x,cons(y,l))) -> sum#(cons(plus(x,y),l)) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: sum#_A(x1) = max{79, x1 + 18} cons_A(x1,x2) = max{47, x2 + 31} plus_A(x1,x2) = max{x1 + 79, x2 + 83} id_A(x1) = max{2, x1 + 1} if_A(x1,x2,x3) = max{3, x1 - 89, x2 + 1, x3 + 1} true_A = 25 false_A = 25 not_A(x1) = max{84, x1 + 27} gt_A(x1,x2) = 73 s_A(x1) = 0 zero_A = 0 precedence: not > gt > sum# = cons > plus > false = s > if = zero > true > id partial status: pi(sum#) = [1] pi(cons) = [2] pi(plus) = [] pi(id) = [1] pi(if) = [2, 3] pi(true) = [] pi(false) = [] pi(not) = [1] pi(gt) = [] pi(s) = [] pi(zero) = [] 2. weighted path order base order: max/plus interpretations on natural numbers: sum#_A(x1) = 0 cons_A(x1,x2) = x2 + 29 plus_A(x1,x2) = 15 id_A(x1) = max{23, x1} if_A(x1,x2,x3) = max{46, x2 + 13, x3 + 13} true_A = 44 false_A = 33 not_A(x1) = x1 + 45 gt_A(x1,x2) = 20 s_A(x1) = 19 zero_A = 0 precedence: sum# = cons = plus = id = if = true = false = not = gt = s = zero partial status: pi(sum#) = [] pi(cons) = [2] pi(plus) = [] pi(id) = [1] pi(if) = [] pi(true) = [] pi(false) = [] pi(not) = [] pi(gt) = [] pi(s) = [] pi(zero) = [] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: plus#(s(x),s(y)) -> plus#(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))) p2: plus#(id(x),s(y)) -> plus#(x,if(gt(s(y),y),y,s(y))) p3: plus#(s(x),x) -> plus#(if(gt(x,x),id(x),id(x)),s(x)) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r11, r12, r13, r14, r15, r16, r17 Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: plus#_A(x1,x2) = max{64, x1 + 41, x2 + 33} s_A(x1) = max{32, x1 + 21} if_A(x1,x2,x3) = max{x2 + 10, x3} gt_A(x1,x2) = max{40, x2 + 20} not_A(x1) = x1 + 27 id_A(x1) = max{22, x1} true_A = 8 false_A = 0 zero_A = 9 precedence: s = not > plus# = if = gt = id = true = false = zero partial status: pi(plus#) = [1, 2] pi(s) = [1] pi(if) = [2, 3] pi(gt) = [2] pi(not) = [1] pi(id) = [1] pi(true) = [] pi(false) = [] pi(zero) = [] 2. weighted path order base order: max/plus interpretations on natural numbers: plus#_A(x1,x2) = max{139, x1 + 106, x2 + 75} s_A(x1) = x1 + 59 if_A(x1,x2,x3) = max{14, x2 + 2} gt_A(x1,x2) = x2 + 13 not_A(x1) = x1 + 13 id_A(x1) = x1 + 33 true_A = 12 false_A = 12 zero_A = 0 precedence: plus# = s = if = gt = not = id = true = false = zero partial status: pi(plus#) = [2] pi(s) = [1] pi(if) = [] pi(gt) = [2] pi(not) = [1] pi(id) = [] pi(true) = [] pi(false) = [] pi(zero) = [] The next rules are strictly ordered: p1, p2, p3 We remove them from the problem. Then no dependency pair remains. -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: gt#(s(x),s(y)) -> gt#(x,y) and R consists of: r1: app(nil(),k) -> k r2: app(l,nil()) -> l r3: app(cons(x,l),k) -> cons(x,app(l,k)) r4: sum(cons(x,nil())) -> cons(x,nil()) r5: sum(cons(x,cons(y,l))) -> sum(cons(plus(x,y),l)) r6: sum(app(l,cons(x,cons(y,k)))) -> sum(app(l,sum(cons(x,cons(y,k))))) r7: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r8: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r9: plus(zero(),y) -> y r10: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r11: id(x) -> x r12: if(true(),x,y) -> x r13: if(false(),x,y) -> y r14: not(x) -> if(x,false(),true()) r15: gt(s(x),zero()) -> true() r16: gt(zero(),y) -> false() r17: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of (no rules) Take the reduction pair: lexicographic combination of reduction pairs: 1. weighted path order base order: max/plus interpretations on natural numbers: gt#_A(x1,x2) = max{2, x1 - 1, x2 + 1} s_A(x1) = max{1, x1} precedence: gt# = s partial status: pi(gt#) = [2] pi(s) = [1] 2. weighted path order base order: max/plus interpretations on natural numbers: gt#_A(x1,x2) = 0 s_A(x1) = max{2, x1} precedence: gt# = s partial status: pi(gt#) = [] pi(s) = [1] The next rules are strictly ordered: p1 We remove them from the problem. Then no dependency pair remains.