YES We show the termination of the TRS R: app(app(mapbt(),f),app(leaf(),x)) -> app(leaf(),app(f,x)) app(app(mapbt(),f),app(app(app(branch(),x),l),r)) -> app(app(app(branch(),app(f,x)),app(app(mapbt(),f),l)),app(app(mapbt(),f),r)) Instead we prove termination of the uncurried system: app(branch_0(),y) -> branch_1(y) app(branch_1(x1),y) -> branch_2(x1,y) app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) app(leaf_0(),y) -> leaf_1(y) app(mapbt_0(),y) -> mapbt_1(y) app(mapbt_1(x1),y) -> mapbt_2(x1,y) mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: app#(mapbt_1(x1),y) -> mapbt_2#(x1,y) p2: mapbt_2#(f,leaf_1(x)) -> app#(f,x) p3: mapbt_2#(f,branch_3(x,l,r)) -> app#(f,x) p4: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p5: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The estimated dependency graph contains the following SCCs: {p1, p2, p3, p4, p5} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: app#(mapbt_1(x1),y) -> mapbt_2#(x1,y) p2: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) p3: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p4: mapbt_2#(f,branch_3(x,l,r)) -> app#(f,x) p5: mapbt_2#(f,leaf_1(x)) -> app#(f,x) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The set of usable rules consists of r1, r2, r4 Take the reduction pair: generalized weighted path order (>=MG, >MG) base order 1: max/plus interpretation on natural numbers: app#_A(x1,x2) = max{6, x1 - 7} mapbt_1_A(x1) = x1 + 15 mapbt_2#_A(x1,x2) = x1 + 7 branch_3_A(x1,x2,x3) = max{4, x1 - 18, x2 + 1, x3 - 18} leaf_1_A(x1) = max{2, x1 - 18} app_A(x1,x2) = max{17, x1 - 16, x2 - 7} branch_0_A = 1 branch_1_A(x1) = max{2, x1 - 8} branch_2_A(x1,x2) = max{3, x1 - 25, x2 - 8} leaf_0_A = 1 base order 2: precedence: mapbt_1 = mapbt_2# > app# = app = leaf_0 > branch_3 = leaf_1 > branch_2 > branch_1 > branch_0 partial status: pi(app#) = [] pi(mapbt_1) = [1] pi(mapbt_2#) = [1] pi(branch_3) = [2] pi(leaf_1) = [] pi(app) = [] pi(branch_0) = [] pi(branch_1) = [] pi(branch_2) = [] pi(leaf_0) = [] The following rules are removed: p5 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: app#(mapbt_1(x1),y) -> mapbt_2#(x1,y) p2: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) p3: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p4: mapbt_2#(f,branch_3(x,l,r)) -> app#(f,x) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The estimated dependency graph contains the following SCCs: {p1, p2, p3, p4} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: app#(mapbt_1(x1),y) -> mapbt_2#(x1,y) p2: mapbt_2#(f,branch_3(x,l,r)) -> app#(f,x) p3: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p4: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The set of usable rules consists of r1, r2, r3 Take the reduction pair: generalized weighted path order (>=MG, >MG) base order 1: max/plus interpretation on natural numbers: app#_A(x1,x2) = max{1, x1 - 2} mapbt_1_A(x1) = x1 + 4 mapbt_2#_A(x1,x2) = max{2, x1 - 1} branch_3_A(x1,x2,x3) = max{0, x1 - 23, x2 - 23, x3 - 23} app_A(x1,x2) = max{5, x1 - 5, x2 - 10} branch_0_A = 1 branch_1_A(x1) = max{2, x1 - 11} branch_2_A(x1,x2) = max{4, x1 - 17, x2 - 17} base order 2: precedence: app# = mapbt_1 > mapbt_2# = app > branch_3 > branch_2 > branch_1 > branch_0 partial status: pi(app#) = [] pi(mapbt_1) = [1] pi(mapbt_2#) = [] pi(branch_3) = [] pi(app) = [] pi(branch_0) = [] pi(branch_1) = [] pi(branch_2) = [] The following rules are removed: p2 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: app#(mapbt_1(x1),y) -> mapbt_2#(x1,y) p2: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p3: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The estimated dependency graph contains the following SCCs: {p2, p3} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) p2: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,r) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The set of usable rules consists of r1, r4 Take the reduction pair: generalized weighted path order (>=MG, >MG) base order 1: max/plus interpretation on natural numbers: mapbt_2#_A(x1,x2) = x2 branch_3_A(x1,x2,x3) = max{x1, x2, x3} app_A(x1,x2) = max{0, x1 - 3, x2 - 1} branch_0_A = 2 branch_1_A(x1) = max{0, x1 - 2} leaf_0_A = 2 leaf_1_A(x1) = max{0, x1 - 2} base order 2: precedence: branch_3 = app = branch_0 > mapbt_2# = leaf_1 > branch_1 = leaf_0 partial status: pi(mapbt_2#) = [2] pi(branch_3) = [2, 3] pi(app) = [] pi(branch_0) = [] pi(branch_1) = [] pi(leaf_0) = [] pi(leaf_1) = [] The following rules are removed: p2 -- SCC decomposition. Consider the dependency pair problem (P, R), where P consists of p1: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The estimated dependency graph contains the following SCCs: {p1} -- Reduction pair. Consider the dependency pair problem (P, R), where P consists of p1: mapbt_2#(f,branch_3(x,l,r)) -> mapbt_2#(f,l) and R consists of: r1: app(branch_0(),y) -> branch_1(y) r2: app(branch_1(x1),y) -> branch_2(x1,y) r3: app(branch_2(x1,x2),y) -> branch_3(x1,x2,y) r4: app(leaf_0(),y) -> leaf_1(y) r5: app(mapbt_0(),y) -> mapbt_1(y) r6: app(mapbt_1(x1),y) -> mapbt_2(x1,y) r7: mapbt_2(f,leaf_1(x)) -> leaf_1(app(f,x)) r8: mapbt_2(f,branch_3(x,l,r)) -> branch_3(app(f,x),mapbt_2(f,l),mapbt_2(f,r)) The set of usable rules consists of r5 Take the reduction pair: generalized weighted path order (>=MG, >MG) base order 1: max/plus interpretation on natural numbers: mapbt_2#_A(x1,x2) = x2 + 9 branch_3_A(x1,x2,x3) = max{x1 - 3, x2 + 10, x3 - 7} app_A(x1,x2) = max{2, x1 - 12, x2 - 19} mapbt_0_A = 26 mapbt_1_A(x1) = max{13, x1 - 20} base order 2: precedence: branch_3 = app > mapbt_2# = mapbt_1 > mapbt_0 partial status: pi(mapbt_2#) = [2] pi(branch_3) = [2] pi(app) = [] pi(mapbt_0) = [] pi(mapbt_1) = [] The following rules are removed: p1 Then no dependency pair remains.