0 Prolog
↳1 PrologToPiTRSProof (⇐)
↳2 PiTRS
↳3 DependencyPairsProof (⇔)
↳4 PiDP
↳5 DependencyGraphProof (⇔)
↳6 AND
↳7 PiDP
↳8 UsableRulesProof (⇔)
↳9 PiDP
↳10 PiDPToQDPProof (⇐)
↳11 QDP
↳12 NonTerminationProof (⇔)
↳13 FALSE
↳14 PiDP
↳15 UsableRulesProof (⇔)
↳16 PiDP
↳17 PiDPToQDPProof (⇐)
↳18 QDP
↳19 Narrowing (⇐)
↳20 QDP
↳21 UsableRulesProof (⇔)
↳22 QDP
↳23 QReductionProof (⇔)
↳24 QDP
↳25 NonTerminationProof (⇔)
↳26 FALSE
↳27 PiDP
↳28 UsableRulesProof (⇔)
↳29 PiDP
↳30 PiDPToQDPProof (⇐)
↳31 QDP
↳32 NonTerminationProof (⇔)
↳33 FALSE
↳34 PiDP
↳35 UsableRulesProof (⇔)
↳36 PiDP
↳37 PiDPToQDPProof (⇐)
↳38 QDP
↳39 Narrowing (⇐)
↳40 QDP
↳41 NonTerminationProof (⇔)
↳42 FALSE
↳43 PiDP
↳44 UsableRulesProof (⇔)
↳45 PiDP
↳46 PiDPToQDPProof (⇐)
↳47 QDP
↳48 QDPSizeChangeProof (⇔)
↳49 TRUE
↳50 PiDP
↳51 UsableRulesProof (⇔)
↳52 PiDP
↳53 PiDPToQDPProof (⇐)
↳54 QDP
↳55 QDPSizeChangeProof (⇔)
↳56 TRUE
↳57 PrologToPiTRSProof (⇐)
↳58 PiTRS
↳59 DependencyPairsProof (⇔)
↳60 PiDP
↳61 DependencyGraphProof (⇔)
↳62 AND
↳63 PiDP
↳64 UsableRulesProof (⇔)
↳65 PiDP
↳66 PiDPToQDPProof (⇐)
↳67 QDP
↳68 NonTerminationProof (⇔)
↳69 FALSE
↳70 PiDP
↳71 UsableRulesProof (⇔)
↳72 PiDP
↳73 PiDPToQDPProof (⇐)
↳74 QDP
↳75 Narrowing (⇐)
↳76 QDP
↳77 UsableRulesProof (⇔)
↳78 QDP
↳79 QReductionProof (⇔)
↳80 QDP
↳81 NonTerminationProof (⇔)
↳82 FALSE
↳83 PiDP
↳84 UsableRulesProof (⇔)
↳85 PiDP
↳86 PiDPToQDPProof (⇐)
↳87 QDP
↳88 NonTerminationProof (⇔)
↳89 FALSE
↳90 PiDP
↳91 UsableRulesProof (⇔)
↳92 PiDP
↳93 PiDPToQDPProof (⇐)
↳94 QDP
↳95 Narrowing (⇐)
↳96 QDP
↳97 NonTerminationProof (⇔)
↳98 FALSE
↳99 PiDP
↳100 UsableRulesProof (⇔)
↳101 PiDP
↳102 PiDPToQDPProof (⇐)
↳103 QDP
↳104 QDPSizeChangeProof (⇔)
↳105 TRUE
↳106 PiDP
↳107 UsableRulesProof (⇔)
↳108 PiDP
↳109 PiDPToQDPProof (⇐)
↳110 QDP
↳111 QDPSizeChangeProof (⇔)
↳112 TRUE
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
TEST_SNAKE_IN_GGG(Pattern, C, R) → U1_GGG(Pattern, C, R, s2l_in_ga(C, Cols))
TEST_SNAKE_IN_GGG(Pattern, C, R) → S2L_IN_GA(C, Cols)
S2L_IN_GA(s(X), cons(X1, Y)) → U4_GA(X, X1, Y, s2l_in_ga(X, Y))
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_GGG(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → S2L_IN_GA(R, Rows)
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_GGG(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → SNAKE_IN_GAA(Pattern, Cols, Rows)
SNAKE_IN_GAA(Pattern, Cols, Rows) → U5_GAA(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
SNAKE_IN_GAA(Pattern, Cols, Rows) → INFINITE_SNAKE_IN_GAA(Pattern, InfSnake, InfSnake)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → U8_GAA(A, R, T, S, infinite_snake_in_gaa(R, T, S))
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_GAA(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, InfSnake, Snake)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → PART_OF_SNAKE_IN_AAAA(Cols, InfSnake, NewInfSnake, Part)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_AAAA(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_GAA(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → COIL_IT_IN_AG(Snake, odd)
COIL_IT_IN_AG(cons(Line, Lines), odd) → U12_AG(Line, Lines, coil_it_in_ag(Lines, even))
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
COIL_IT_IN_AG(cons(Line, Lines), even) → REVERSE2_IN_AA(Line, Line1)
REVERSE2_IN_AA(List, Reversed) → U15_AA(List, Reversed, reverse_in_aga(List, nil, Reversed))
REVERSE2_IN_AA(List, Reversed) → REVERSE_IN_AGA(List, nil, Reversed)
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → U16_AGA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → U16_AAA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_AG(Line, Lines, coil_it_in_ag(Lines, odd))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
TEST_SNAKE_IN_GGG(Pattern, C, R) → U1_GGG(Pattern, C, R, s2l_in_ga(C, Cols))
TEST_SNAKE_IN_GGG(Pattern, C, R) → S2L_IN_GA(C, Cols)
S2L_IN_GA(s(X), cons(X1, Y)) → U4_GA(X, X1, Y, s2l_in_ga(X, Y))
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_GGG(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → S2L_IN_GA(R, Rows)
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_GGG(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → SNAKE_IN_GAA(Pattern, Cols, Rows)
SNAKE_IN_GAA(Pattern, Cols, Rows) → U5_GAA(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
SNAKE_IN_GAA(Pattern, Cols, Rows) → INFINITE_SNAKE_IN_GAA(Pattern, InfSnake, InfSnake)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → U8_GAA(A, R, T, S, infinite_snake_in_gaa(R, T, S))
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_GAA(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, InfSnake, Snake)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → PART_OF_SNAKE_IN_AAAA(Cols, InfSnake, NewInfSnake, Part)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_AAAA(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_GAA(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → COIL_IT_IN_AG(Snake, odd)
COIL_IT_IN_AG(cons(Line, Lines), odd) → U12_AG(Line, Lines, coil_it_in_ag(Lines, even))
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
COIL_IT_IN_AG(cons(Line, Lines), even) → REVERSE2_IN_AA(Line, Line1)
REVERSE2_IN_AA(List, Reversed) → U15_AA(List, Reversed, reverse_in_aga(List, nil, Reversed))
REVERSE2_IN_AA(List, Reversed) → REVERSE_IN_AGA(List, nil, Reversed)
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → U16_AGA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → U16_AAA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_AG(Line, Lines, coil_it_in_ag(Lines, odd))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA → REVERSE_IN_AAA
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
COIL_IT_IN_AG(even) → U13_AG(reverse2_in_aa)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
reverse2_in_aa → U15_aa(reverse_in_aga(nil))
U15_aa(reverse_out_aga(nil)) → reverse2_out_aa
reverse_in_aga(Reversed) → reverse_out_aga(Reversed)
reverse_in_aga(SoFar) → U16_aga(SoFar, reverse_in_aaa)
U16_aga(SoFar, reverse_out_aaa) → reverse_out_aga(SoFar)
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0, x1)
reverse_in_aaa
U16_aaa(x0)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse2_in_aa → U15_aa(reverse_in_aga(nil))
U15_aa(reverse_out_aga(nil)) → reverse2_out_aa
reverse_in_aga(Reversed) → reverse_out_aga(Reversed)
reverse_in_aga(SoFar) → U16_aga(SoFar, reverse_in_aaa)
U16_aga(SoFar, reverse_out_aaa) → reverse_out_aga(SoFar)
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0, x1)
reverse_in_aaa
U16_aaa(x0)
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse_in_aga(Reversed) → reverse_out_aga(Reversed)
reverse_in_aga(SoFar) → U16_aga(SoFar, reverse_in_aaa)
U15_aa(reverse_out_aga(nil)) → reverse2_out_aa
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aga(SoFar, reverse_out_aaa) → reverse_out_aga(SoFar)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0, x1)
reverse_in_aaa
U16_aaa(x0)
reverse2_in_aa
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse_in_aga(Reversed) → reverse_out_aga(Reversed)
reverse_in_aga(SoFar) → U16_aga(SoFar, reverse_in_aaa)
U15_aa(reverse_out_aga(nil)) → reverse2_out_aa
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aga(SoFar, reverse_out_aaa) → reverse_out_aga(SoFar)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0, x1)
reverse_in_aaa
U16_aaa(x0)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
PART_OF_SNAKE_IN_AAAA → PART_OF_SNAKE_IN_AAAA
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_AAAA(part_of_snake_out_aaaa) → PRODUCE_SNAKE_IN_AAAA
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_in_aaaa)
part_of_snake_in_aaaa → part_of_snake_out_aaaa
part_of_snake_in_aaaa → U11_aaaa(part_of_snake_in_aaaa)
U11_aaaa(part_of_snake_out_aaaa) → part_of_snake_out_aaaa
part_of_snake_in_aaaa
U11_aaaa(x0)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_out_aaaa)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(U11_aaaa(part_of_snake_in_aaaa))
U9_AAAA(part_of_snake_out_aaaa) → PRODUCE_SNAKE_IN_AAAA
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_out_aaaa)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(U11_aaaa(part_of_snake_in_aaaa))
part_of_snake_in_aaaa → part_of_snake_out_aaaa
part_of_snake_in_aaaa → U11_aaaa(part_of_snake_in_aaaa)
U11_aaaa(part_of_snake_out_aaaa) → part_of_snake_out_aaaa
part_of_snake_in_aaaa
U11_aaaa(x0)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
INFINITE_SNAKE_IN_GAA(cons(A, R)) → INFINITE_SNAKE_IN_GAA(R)
From the DPs we obtained the following set of size-change graphs:
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
S2L_IN_GA(s(X)) → S2L_IN_GA(X)
From the DPs we obtained the following set of size-change graphs:
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
TEST_SNAKE_IN_GGG(Pattern, C, R) → U1_GGG(Pattern, C, R, s2l_in_ga(C, Cols))
TEST_SNAKE_IN_GGG(Pattern, C, R) → S2L_IN_GA(C, Cols)
S2L_IN_GA(s(X), cons(X1, Y)) → U4_GA(X, X1, Y, s2l_in_ga(X, Y))
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_GGG(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → S2L_IN_GA(R, Rows)
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_GGG(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → SNAKE_IN_GAA(Pattern, Cols, Rows)
SNAKE_IN_GAA(Pattern, Cols, Rows) → U5_GAA(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
SNAKE_IN_GAA(Pattern, Cols, Rows) → INFINITE_SNAKE_IN_GAA(Pattern, InfSnake, InfSnake)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → U8_GAA(A, R, T, S, infinite_snake_in_gaa(R, T, S))
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_GAA(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, InfSnake, Snake)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → PART_OF_SNAKE_IN_AAAA(Cols, InfSnake, NewInfSnake, Part)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_AAAA(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_GAA(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → COIL_IT_IN_AG(Snake, odd)
COIL_IT_IN_AG(cons(Line, Lines), odd) → U12_AG(Line, Lines, coil_it_in_ag(Lines, even))
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
COIL_IT_IN_AG(cons(Line, Lines), even) → REVERSE2_IN_AA(Line, Line1)
REVERSE2_IN_AA(List, Reversed) → U15_AA(List, Reversed, reverse_in_aga(List, nil, Reversed))
REVERSE2_IN_AA(List, Reversed) → REVERSE_IN_AGA(List, nil, Reversed)
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → U16_AGA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → U16_AAA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_AG(Line, Lines, coil_it_in_ag(Lines, odd))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
TEST_SNAKE_IN_GGG(Pattern, C, R) → U1_GGG(Pattern, C, R, s2l_in_ga(C, Cols))
TEST_SNAKE_IN_GGG(Pattern, C, R) → S2L_IN_GA(C, Cols)
S2L_IN_GA(s(X), cons(X1, Y)) → U4_GA(X, X1, Y, s2l_in_ga(X, Y))
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_GGG(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U1_GGG(Pattern, C, R, s2l_out_ga(C, Cols)) → S2L_IN_GA(R, Rows)
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_GGG(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
U2_GGG(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → SNAKE_IN_GAA(Pattern, Cols, Rows)
SNAKE_IN_GAA(Pattern, Cols, Rows) → U5_GAA(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
SNAKE_IN_GAA(Pattern, Cols, Rows) → INFINITE_SNAKE_IN_GAA(Pattern, InfSnake, InfSnake)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → U8_GAA(A, R, T, S, infinite_snake_in_gaa(R, T, S))
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_GAA(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
U5_GAA(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, InfSnake, Snake)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → PART_OF_SNAKE_IN_AAAA(Cols, InfSnake, NewInfSnake, Part)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_AAAA(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_GAA(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
U6_GAA(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → COIL_IT_IN_AG(Snake, odd)
COIL_IT_IN_AG(cons(Line, Lines), odd) → U12_AG(Line, Lines, coil_it_in_ag(Lines, even))
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
COIL_IT_IN_AG(cons(Line, Lines), even) → REVERSE2_IN_AA(Line, Line1)
REVERSE2_IN_AA(List, Reversed) → U15_AA(List, Reversed, reverse_in_aga(List, nil, Reversed))
REVERSE2_IN_AA(List, Reversed) → REVERSE_IN_AGA(List, nil, Reversed)
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → U16_AGA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AGA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → U16_AAA(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_AG(Line, Lines, coil_it_in_ag(Lines, odd))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
REVERSE_IN_AAA(cons(Head, Tail), SoFar, Reversed) → REVERSE_IN_AAA(Tail, cons(Head, SoFar), Reversed)
REVERSE_IN_AAA → REVERSE_IN_AAA
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
COIL_IT_IN_AG(cons(Line, Lines), odd) → COIL_IT_IN_AG(Lines, even)
COIL_IT_IN_AG(cons(Line, Lines), even) → U13_AG(Line, Lines, reverse2_in_aa(Line, Line1))
U13_AG(Line, Lines, reverse2_out_aa(Line, Line1)) → COIL_IT_IN_AG(Lines, odd)
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
COIL_IT_IN_AG(even) → U13_AG(reverse2_in_aa)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
reverse2_in_aa → U15_aa(reverse_in_aga(nil))
U15_aa(reverse_out_aga) → reverse2_out_aa
reverse_in_aga(Reversed) → reverse_out_aga
reverse_in_aga(SoFar) → U16_aga(reverse_in_aaa)
U16_aga(reverse_out_aaa) → reverse_out_aga
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0)
reverse_in_aaa
U16_aaa(x0)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse2_in_aa → U15_aa(reverse_in_aga(nil))
U15_aa(reverse_out_aga) → reverse2_out_aa
reverse_in_aga(Reversed) → reverse_out_aga
reverse_in_aga(SoFar) → U16_aga(reverse_in_aaa)
U16_aga(reverse_out_aaa) → reverse_out_aga
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0)
reverse_in_aaa
U16_aaa(x0)
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse_in_aga(Reversed) → reverse_out_aga
reverse_in_aga(SoFar) → U16_aga(reverse_in_aaa)
U15_aa(reverse_out_aga) → reverse2_out_aa
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aga(reverse_out_aaa) → reverse_out_aga
U16_aaa(reverse_out_aaa) → reverse_out_aaa
reverse2_in_aa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0)
reverse_in_aaa
U16_aaa(x0)
reverse2_in_aa
COIL_IT_IN_AG(odd) → COIL_IT_IN_AG(even)
U13_AG(reverse2_out_aa) → COIL_IT_IN_AG(odd)
COIL_IT_IN_AG(even) → U13_AG(U15_aa(reverse_in_aga(nil)))
reverse_in_aga(Reversed) → reverse_out_aga
reverse_in_aga(SoFar) → U16_aga(reverse_in_aaa)
U15_aa(reverse_out_aga) → reverse2_out_aa
reverse_in_aaa → reverse_out_aaa
reverse_in_aaa → U16_aaa(reverse_in_aaa)
U16_aga(reverse_out_aaa) → reverse_out_aga
U16_aaa(reverse_out_aaa) → reverse_out_aaa
U15_aa(x0)
reverse_in_aga(x0)
U16_aga(x0)
reverse_in_aaa
U16_aaa(x0)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
PART_OF_SNAKE_IN_AAAA(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → PART_OF_SNAKE_IN_AAAA(R, Rings, RestSnake, RestRings)
PART_OF_SNAKE_IN_AAAA → PART_OF_SNAKE_IN_AAAA
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → PRODUCE_SNAKE_IN_AAAA(Rows, Cols, NewInfSnake, Tail)
PRODUCE_SNAKE_IN_AAAA(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_AAAA(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_AAAA(part_of_snake_out_aaaa) → PRODUCE_SNAKE_IN_AAAA
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_in_aaaa)
part_of_snake_in_aaaa → part_of_snake_out_aaaa
part_of_snake_in_aaaa → U11_aaaa(part_of_snake_in_aaaa)
U11_aaaa(part_of_snake_out_aaaa) → part_of_snake_out_aaaa
part_of_snake_in_aaaa
U11_aaaa(x0)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_out_aaaa)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(U11_aaaa(part_of_snake_in_aaaa))
U9_AAAA(part_of_snake_out_aaaa) → PRODUCE_SNAKE_IN_AAAA
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(part_of_snake_out_aaaa)
PRODUCE_SNAKE_IN_AAAA → U9_AAAA(U11_aaaa(part_of_snake_in_aaaa))
part_of_snake_in_aaaa → part_of_snake_out_aaaa
part_of_snake_in_aaaa → U11_aaaa(part_of_snake_in_aaaa)
U11_aaaa(part_of_snake_out_aaaa) → part_of_snake_out_aaaa
part_of_snake_in_aaaa
U11_aaaa(x0)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
INFINITE_SNAKE_IN_GAA(cons(A, R), cons(A, T), S) → INFINITE_SNAKE_IN_GAA(R, T, S)
INFINITE_SNAKE_IN_GAA(cons(A, R)) → INFINITE_SNAKE_IN_GAA(R)
From the DPs we obtained the following set of size-change graphs:
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
test_snake_in_ggg(Pattern, C, R) → U1_ggg(Pattern, C, R, s2l_in_ga(C, Cols))
s2l_in_ga(0, nil) → s2l_out_ga(0, nil)
s2l_in_ga(s(X), cons(X1, Y)) → U4_ga(X, X1, Y, s2l_in_ga(X, Y))
U4_ga(X, X1, Y, s2l_out_ga(X, Y)) → s2l_out_ga(s(X), cons(X1, Y))
U1_ggg(Pattern, C, R, s2l_out_ga(C, Cols)) → U2_ggg(Pattern, C, R, Cols, s2l_in_ga(R, Rows))
U2_ggg(Pattern, C, R, Cols, s2l_out_ga(R, Rows)) → U3_ggg(Pattern, C, R, snake_in_gaa(Pattern, Cols, Rows))
snake_in_gaa(Pattern, Cols, Rows) → U5_gaa(Pattern, Cols, Rows, infinite_snake_in_gaa(Pattern, InfSnake, InfSnake))
infinite_snake_in_gaa(nil, S, S) → infinite_snake_out_gaa(nil, S, S)
infinite_snake_in_gaa(cons(A, R), cons(A, T), S) → U8_gaa(A, R, T, S, infinite_snake_in_gaa(R, T, S))
U8_gaa(A, R, T, S, infinite_snake_out_gaa(R, T, S)) → infinite_snake_out_gaa(cons(A, R), cons(A, T), S)
U5_gaa(Pattern, Cols, Rows, infinite_snake_out_gaa(Pattern, InfSnake, InfSnake)) → U6_gaa(Pattern, Cols, Rows, produce_snake_in_aaaa(Rows, Cols, InfSnake, Snake))
produce_snake_in_aaaa(nil, X2, X3, nil) → produce_snake_out_aaaa(nil, X2, X3, nil)
produce_snake_in_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail)) → U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_in_aaaa(Cols, InfSnake, NewInfSnake, Part))
part_of_snake_in_aaaa(nil, RestSnake, RestSnake, nil) → part_of_snake_out_aaaa(nil, RestSnake, RestSnake, nil)
part_of_snake_in_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings)) → U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_in_aaaa(R, Rings, RestSnake, RestRings))
U11_aaaa(X5, R, Ring, Rings, RestSnake, RestRings, part_of_snake_out_aaaa(R, Rings, RestSnake, RestRings)) → part_of_snake_out_aaaa(cons(X5, R), cons(Ring, Rings), RestSnake, cons(Ring, RestRings))
U9_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, part_of_snake_out_aaaa(Cols, InfSnake, NewInfSnake, Part)) → U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_in_aaaa(Rows, Cols, NewInfSnake, Tail))
U10_aaaa(X4, Rows, Cols, InfSnake, Part, Tail, produce_snake_out_aaaa(Rows, Cols, NewInfSnake, Tail)) → produce_snake_out_aaaa(cons(X4, Rows), Cols, InfSnake, cons(Part, Tail))
U6_gaa(Pattern, Cols, Rows, produce_snake_out_aaaa(Rows, Cols, InfSnake, Snake)) → U7_gaa(Pattern, Cols, Rows, coil_it_in_ag(Snake, odd))
coil_it_in_ag(nil, X6) → coil_it_out_ag(nil, X6)
coil_it_in_ag(cons(Line, Lines), odd) → U12_ag(Line, Lines, coil_it_in_ag(Lines, even))
coil_it_in_ag(cons(Line, Lines), even) → U13_ag(Line, Lines, reverse2_in_aa(Line, Line1))
reverse2_in_aa(List, Reversed) → U15_aa(List, Reversed, reverse_in_aga(List, nil, Reversed))
reverse_in_aga(nil, Reversed, Reversed) → reverse_out_aga(nil, Reversed, Reversed)
reverse_in_aga(cons(Head, Tail), SoFar, Reversed) → U16_aga(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
reverse_in_aaa(nil, Reversed, Reversed) → reverse_out_aaa(nil, Reversed, Reversed)
reverse_in_aaa(cons(Head, Tail), SoFar, Reversed) → U16_aaa(Head, Tail, SoFar, Reversed, reverse_in_aaa(Tail, cons(Head, SoFar), Reversed))
U16_aaa(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aaa(cons(Head, Tail), SoFar, Reversed)
U16_aga(Head, Tail, SoFar, Reversed, reverse_out_aaa(Tail, cons(Head, SoFar), Reversed)) → reverse_out_aga(cons(Head, Tail), SoFar, Reversed)
U15_aa(List, Reversed, reverse_out_aga(List, nil, Reversed)) → reverse2_out_aa(List, Reversed)
U13_ag(Line, Lines, reverse2_out_aa(Line, Line1)) → U14_ag(Line, Lines, coil_it_in_ag(Lines, odd))
U14_ag(Line, Lines, coil_it_out_ag(Lines, odd)) → coil_it_out_ag(cons(Line, Lines), even)
U12_ag(Line, Lines, coil_it_out_ag(Lines, even)) → coil_it_out_ag(cons(Line, Lines), odd)
U7_gaa(Pattern, Cols, Rows, coil_it_out_ag(Snake, odd)) → snake_out_gaa(Pattern, Cols, Rows)
U3_ggg(Pattern, C, R, snake_out_gaa(Pattern, Cols, Rows)) → test_snake_out_ggg(Pattern, C, R)
S2L_IN_GA(s(X), cons(X1, Y)) → S2L_IN_GA(X, Y)
S2L_IN_GA(s(X)) → S2L_IN_GA(X)
From the DPs we obtained the following set of size-change graphs: