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))))) sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) pred(cons(s(x),nil())) -> cons(x,nil()) 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: sum#(plus(cons(|0|(),x),cons(y,l))) -> pred#(sum(cons(s(x),cons(y,l)))) p8: sum#(plus(cons(|0|(),x),cons(y,l))) -> sum#(cons(s(x),cons(y,l))) p9: plus#(s(x),s(y)) -> plus#(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))) p10: plus#(s(x),s(y)) -> if#(gt(x,y),x,y) p11: plus#(s(x),s(y)) -> gt#(x,y) p12: plus#(s(x),s(y)) -> if#(not(gt(x,y)),id(x),id(y)) p13: plus#(s(x),s(y)) -> not#(gt(x,y)) p14: plus#(s(x),s(y)) -> id#(x) p15: plus#(s(x),s(y)) -> id#(y) p16: plus#(s(x),x) -> plus#(if(gt(x,x),id(x),id(x)),s(x)) p17: plus#(s(x),x) -> if#(gt(x,x),id(x),id(x)) p18: plus#(s(x),x) -> gt#(x,x) p19: plus#(s(x),x) -> id#(x) p20: plus#(id(x),s(y)) -> plus#(x,if(gt(s(y),y),y,s(y))) p21: plus#(id(x),s(y)) -> if#(gt(s(y),y),y,s(y)) p22: plus#(id(x),s(y)) -> gt#(s(y),y) p23: not#(x) -> if#(x,false(),true()) p24: 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The estimated dependency graph contains the following SCCs: {p4} {p1} {p2} {p9, p16, p20} {p24} -- 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r1, r2, r3, r4, r5, r9, r10, r11, r12, r13, r14, r15, r18 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: sum#_A(x1) = max{1, x1} app_A(x1,x2) = max{x1 + 4, x2 + 7} cons_A(x1,x2) = 0 sum_A(x1) = max{0, x1 - 5} nil_A = 1 plus_A(x1,x2) = x2 + 26 s_A(x1) = 0 if_A(x1,x2,x3) = max{x2 + 1, x3 + 42} gt_A(x1,x2) = max{x1 + 27, x2 - 39} not_A(x1) = max{0, x1 - 77} id_A(x1) = x1 + 41 zero_A = 1 true_A = 0 false_A = 0 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: sum#_A(x1) = 0 app_A(x1,x2) = max{x1 + 3, x2 + 2} cons_A(x1,x2) = max{92, x1 - 5, x2} sum_A(x1) = max{9, x1 + 8} nil_A = 42 plus_A(x1,x2) = max{97, x1 - 9, x2} s_A(x1) = 10 if_A(x1,x2,x3) = max{44, x2 + 9, x3 + 8} gt_A(x1,x2) = max{x1 + 59, x2 - 17} not_A(x1) = 44 id_A(x1) = max{87, x1} zero_A = 0 true_A = 70 false_A = 29 sum#!_A(x1) = 8 app!_A(x1,x2) = max{99, x1 + 7} cons!_A(x1,x2) = x2 + 14 sum!_A(x1) = 58 nil!_A = 57 plus!_A(x1,x2) = 15 s!_A(x1) = max{56, x1 - 40} if!_A(x1,x2,x3) = max{57, x2 - 30, x3 - 71} gt!_A(x1,x2) = max{57, x1 - 11, x2 + 4} not!_A(x1) = 56 id!_A(x1) = max{0, x1 - 39} zero!_A = 6 true!_A = 5 false!_A = 5 partial status: pi(sum#) = [1] pi(app) = [2] pi(cons) = [] pi(sum) = [] pi(nil) = [] pi(plus) = [] pi(s) = [] pi(if) = [] pi(gt) = [1] pi(not) = [] pi(id) = [1] pi(zero) = [] pi(true) = [] pi(false) = [] The following rules are removed: p1 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of (no rules) Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: app#_A(x1,x2) = max{4, x2 + 1} cons_A(x1,x2) = max{3, x1 - 300, x2 - 108} base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: app#_A(x1,x2) = max{0, x1 - 8} cons_A(x1,x2) = max{264, x1 - 120, x2 + 7} app#!_A(x1,x2) = max{4, x1 - 8} cons!_A(x1,x2) = max{3, x1 - 3201, x2 - 3464} partial status: pi(app#) = [] pi(cons) = [] The following rules are removed: p1 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: sum#_A(x1) = max{18, x1 + 2} cons_A(x1,x2) = x2 + 17 plus_A(x1,x2) = max{x1 + 12, x2 + 12} s_A(x1) = x1 if_A(x1,x2,x3) = max{x2, x3} gt_A(x1,x2) = max{0, x2 - 12} not_A(x1) = x1 + 11 id_A(x1) = x1 zero_A = 12 true_A = 0 false_A = 0 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: sum#_A(x1) = max{0, x1 - 177} cons_A(x1,x2) = max{x1 + 10, x2 + 88} plus_A(x1,x2) = max{78, x1, x2} s_A(x1) = max{48, x1} if_A(x1,x2,x3) = max{25, x1 - 50, x2, x3} gt_A(x1,x2) = max{1, x1 - 46, x2 - 2} not_A(x1) = x1 + 48 id_A(x1) = max{48, x1} zero_A = 1 true_A = 2 false_A = 1 sum#!_A(x1) = 93 cons!_A(x1,x2) = max{x1 + 3, x2 + 88} plus!_A(x1,x2) = max{94, x1 + 22, x2 + 46} s!_A(x1) = 72 if!_A(x1,x2,x3) = max{2, x1 - 2, x2 - 49, x3 - 49} gt!_A(x1,x2) = 71 not!_A(x1) = max{95, x1 + 3} id!_A(x1) = max{1, x1 - 4} zero!_A = 5 true!_A = 4 false!_A = 4 partial status: pi(sum#) = [1] pi(cons) = [] pi(plus) = [] pi(s) = [] pi(if) = [2, 3] pi(gt) = [] pi(not) = [1] pi(id) = [1] pi(zero) = [] pi(true) = [] pi(false) = [] The following rules are removed: p1 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r13, r14, r15, r16, r17, r18, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{11, x1 - 111, x2 - 130} s_A(x1) = x1 + 123 if_A(x1,x2,x3) = max{109, x1 - 5, x2, x3} gt_A(x1,x2) = max{2, x1 - 119, x2 - 131} not_A(x1) = max{129, x1 - 3} id_A(x1) = x1 + 111 true_A = 3 false_A = 1 zero_A = 118 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{0, x1 - 590, x2 - 590} s_A(x1) = x1 + 34 if_A(x1,x2,x3) = max{18, x1 - 102, x2, x3} gt_A(x1,x2) = max{65, x1 - 66, x2 - 35} not_A(x1) = max{691, x1 - 102} id_A(x1) = max{25, x1} true_A = 65 false_A = 1 zero_A = 0 plus#!_A(x1,x2) = max{728, x1 - 1187, x2 - 1179} s!_A(x1) = max{728, x1 - 587} if!_A(x1,x2,x3) = max{164, x1 - 1117, x2 - 586, x3 - 1180} gt!_A(x1,x2) = max{167, x1 - 1152, x2 - 1153} not!_A(x1) = max{165, x1 - 1116} id!_A(x1) = max{727, x1 - 1481} true!_A = 0 false!_A = 0 zero!_A = 1 partial status: pi(plus#) = [] pi(s) = [1] pi(if) = [2, 3] pi(gt) = [] pi(not) = [] pi(id) = [1] pi(true) = [] pi(false) = [] pi(zero) = [] The following rules are removed: p1, p3 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: plus#(id(x),s(y)) -> plus#(x,if(gt(s(y),y),y,s(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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The estimated dependency graph contains the following SCCs: {p1} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: plus#(id(x),s(y)) -> plus#(x,if(gt(s(y),y),y,s(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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of r14, r15, r17, r18, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{0, x2 - 84} id_A(x1) = max{18, x1 - 87} s_A(x1) = x1 + 28 if_A(x1,x2,x3) = max{45, x1 - 6, x2 + 14, x3} gt_A(x1,x2) = max{4, x1 - 77, x2 - 29} true_A = 3 false_A = 0 zero_A = 28 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{0, x1 - 4153, x2 - 3685} id_A(x1) = max{465, x1 + 172} s_A(x1) = max{557, x1 + 370} if_A(x1,x2,x3) = max{3684, x1 - 1, x2 + 365, x3} gt_A(x1,x2) = max{194, x1 - 558, x2 - 371} true_A = 194 false_A = 194 zero_A = 0 plus#!_A(x1,x2) = max{3, x1 - 168} id!_A(x1) = max{1, x1 - 1018} s!_A(x1) = max{2, x1 - 554} if!_A(x1,x2,x3) = max{300, x1 - 274, x2 - 466, x3 - 925} gt!_A(x1,x2) = max{298, x1 - 4975, x2 - 4975} true!_A = 0 false!_A = 0 zero!_A = 1 partial status: pi(plus#) = [] pi(id) = [] pi(s) = [1] pi(if) = [3] pi(gt) = [] pi(true) = [] pi(false) = [] pi(zero) = [] The following rules are removed: p1 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: sum(plus(cons(|0|(),x),cons(y,l))) -> pred(sum(cons(s(x),cons(y,l)))) r8: pred(cons(s(x),nil())) -> cons(x,nil()) r9: plus(s(x),s(y)) -> s(s(plus(if(gt(x,y),x,y),if(not(gt(x,y)),id(x),id(y))))) r10: plus(s(x),x) -> plus(if(gt(x,x),id(x),id(x)),s(x)) r11: plus(zero(),y) -> y r12: plus(id(x),s(y)) -> s(plus(x,if(gt(s(y),y),y,s(y)))) r13: id(x) -> x r14: if(true(),x,y) -> x r15: if(false(),x,y) -> y r16: not(x) -> if(x,false(),true()) r17: gt(s(x),zero()) -> true() r18: gt(zero(),y) -> false() r19: gt(s(x),s(y)) -> gt(x,y) The set of usable rules consists of (no rules) Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: max/plus interpretation on natural numbers: gt#_A(x1,x2) = 1 s_A(x1) = max{9, x1 - 154} base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: gt#_A(x1,x2) = max{0, x1 - 56, x2 - 56} s_A(x1) = max{64, x1 + 55} gt#!_A(x1,x2) = max{7, x1 - 56, x2 - 65} s!_A(x1) = max{6, x1 - 304} partial status: pi(gt#) = [] pi(s) = [] The following rules are removed: p1 Then no dependency pair remains.