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, r16, r17, r18, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: sum#_A(x1) = x1 app_A(x1,x2) = x1 + x2 + 6 cons_A(x1,x2) = 5 sum_A(x1) = 5 nil_A() = 1 plus_A(x1,x2) = x2 + 4 s_A(x1) = 0 if_A(x1,x2,x3) = x2 + x3 + 5 gt_A(x1,x2) = 2 not_A(x1) = x1 + 8 id_A(x1) = x1 + 3 zero_A() = 2 true_A() = 1 false_A() = 1 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: sum#_A(x1) = max{0, x1 - 16} app_A(x1,x2) = max{15, x1 + 3, x2} cons_A(x1,x2) = max{11, x1 - 57, x2} sum_A(x1) = max{14, x1} nil_A = 2 plus_A(x1,x2) = max{56, x1, x2} s_A(x1) = max{4, x1} if_A(x1,x2,x3) = max{56, x1 - 57, x2, x3} gt_A(x1,x2) = max{33, x1 - 5, x2 - 5} not_A(x1) = max{56, x1} id_A(x1) = max{2, x1} zero_A = 4 true_A = 1 false_A = 1 sum#!_A(x1) = x1 + 59 app!_A(x1,x2) = max{x1 + 139, x2 + 64} cons!_A(x1,x2) = max{68, x2 + 66} sum!_A(x1) = 69 nil!_A = 67 plus!_A(x1,x2) = max{78, x1 + 22, x2 - 5} s!_A(x1) = max{7, x1 - 31} if!_A(x1,x2,x3) = max{78, x2 - 8, x3 - 32} gt!_A(x1,x2) = 2 not!_A(x1) = max{79, x1 - 35} id!_A(x1) = max{3, x1 - 30} zero!_A = 9 true!_A = 8 false!_A = 1 partial status: pi(sum#) = [1] pi(app) = [2] pi(cons) = [] pi(sum) = [] pi(nil) = [] pi(plus) = [] pi(s) = [] pi(if) = [] 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: 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 r17, r18 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: app#_A(x1,x2) = x1 + x2 cons_A(x1,x2) = x1 + x2 + 4 gt_A(x1,x2) = x1 + x2 + 7 s_A(x1) = x1 + 6 zero_A() = 2 true_A() = 1 false_A() = 1 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: app#_A(x1,x2) = max{0, x1 - 20} cons_A(x1,x2) = max{x1 + 19, x2 + 19} gt_A(x1,x2) = max{16, x1 - 16, x2 - 14} s_A(x1) = x1 + 15 zero_A = 0 true_A = 14 false_A = 14 app#!_A(x1,x2) = max{1, x1 - 20, x2 - 1} cons!_A(x1,x2) = max{0, x1 - 11, x2 - 13} gt!_A(x1,x2) = max{4, x1 - 11, x2 - 16} s!_A(x1) = 3 zero!_A = 3 true!_A = 2 false!_A = 0 partial status: pi(app#) = [1, 2] pi(cons) = [1, 2] pi(gt) = [] pi(s) = [] 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: 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 r13, r15, r17, r18, r19 Take the reduction pair: generalized weighted path order (>=MG, >G) base order 1: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: sum#_A(x1) = 3 cons_A(x1,x2) = 3 plus_A(x1,x2) = 5 id_A(x1) = x1 + 11 if_A(x1,x2,x3) = x3 + 3 false_A() = 0 gt_A(x1,x2) = x2 + 6 s_A(x1) = x1 + 7 zero_A() = 2 true_A() = 1 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: sum#_A(x1) = max{0, x1 - 80} cons_A(x1,x2) = x2 + 24 plus_A(x1,x2) = max{134, x1, x2} id_A(x1) = max{103, x1} if_A(x1,x2,x3) = max{136, x2, x3} false_A = 239 gt_A(x1,x2) = max{239, x1 - 104, x2 - 344} s_A(x1) = max{103, x1} zero_A = 0 true_A = 137 sum#!_A(x1) = max{1, x1 - 34} cons!_A(x1,x2) = max{3, x2 - 2} plus!_A(x1,x2) = x1 + 23 id!_A(x1) = x1 + 23 if!_A(x1,x2,x3) = max{129, x3 - 138} false!_A = 0 gt!_A(x1,x2) = max{127, x1 - 104, x2 - 104} s!_A(x1) = max{128, x1 - 7} zero!_A = 1 true!_A = 0 partial status: pi(sum#) = [] pi(cons) = [] pi(plus) = [] pi(id) = [1] pi(if) = [3] pi(false) = [] pi(gt) = [2] pi(s) = [1] pi(zero) = [] pi(true) = [] 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: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: plus#_A(x1,x2) = 17 s_A(x1) = 23 if_A(x1,x2,x3) = x2 + x3 + 1 gt_A(x1,x2) = 18 not_A(x1) = x1 + 4 id_A(x1) = x1 + 16 true_A() = 1 false_A() = 1 zero_A() = 2 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{0, x1 - 79, x2 - 84} s_A(x1) = x1 + 78 if_A(x1,x2,x3) = max{76, x1 - 228, x2 + 1, x3} gt_A(x1,x2) = max{224, x1 - 157, x2 - 79} not_A(x1) = max{76, x1 - 140} id_A(x1) = max{6, x1 + 2} true_A = 1 false_A = 2 zero_A = 0 plus#!_A(x1,x2) = max{x1 + 3, x2 + 2} s!_A(x1) = x1 + 145 if!_A(x1,x2,x3) = max{147, x1 - 77, x2 - 3, x3 + 146} gt!_A(x1,x2) = max{144, x1 - 79, x2 - 79} not!_A(x1) = max{146, x1 - 225} id!_A(x1) = max{146, x1 - 444} true!_A = 12 false!_A = 0 zero!_A = 13 partial status: pi(plus#) = [] pi(s) = [] pi(if) = [2, 3] pi(gt) = [] pi(not) = [1] pi(id) = [] 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: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: plus#_A(x1,x2) = 1 id_A(x1) = 22 s_A(x1) = x1 + 16 if_A(x1,x2,x3) = x2 + x3 + 12 gt_A(x1,x2) = x2 + 15 true_A() = 1 false_A() = 1 zero_A() = 2 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: plus#_A(x1,x2) = max{0, x1 - 345, x2 - 140} id_A(x1) = x1 + 8 s_A(x1) = x1 + 100 if_A(x1,x2,x3) = max{139, x1 - 1, x2 + 12, x3} gt_A(x1,x2) = max{21, x1 - 215, x2 - 101} true_A = 1 false_A = 10 zero_A = 0 plus#!_A(x1,x2) = max{2, x1 - 5} id!_A(x1) = max{1, x1 - 241} s!_A(x1) = x1 + 252 if!_A(x1,x2,x3) = max{253, x1 - 139, x2 - 11, x3 - 9} gt!_A(x1,x2) = max{16, x1 - 11, x2 - 101} true!_A = 8 false!_A = 0 zero!_A = 9 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: matrix interpretation with standard point-wise order: carrier: N^1 order: standard order interpretations: gt#_A(x1,x2) = x1 + x2 + 5 s_A(x1) = x1 + 4 base order 2: marked-algebra reduction triple (>=A, >=A!, >A!): max/plus interpretation on natural numbers: gt#_A(x1,x2) = 0 s_A(x1) = 42 gt#!_A(x1,x2) = max{43, x1 - 43, x2 - 43} s!_A(x1) = x1 + 42 partial status: pi(gt#) = [1] pi(s) = [1] The following rules are removed: p1 Then no dependency pair remains.