Left Termination of the query pattern perm(b,f) w.r.t. the given Prolog program could successfully be proven:



PROLOG
  ↳ PrologToPiTRSProof

perm2({}0, {}0).
perm2(.2(X, L), Z) :- perm2(L, Y), insert3(X, Y, Z).
insert3(X, {}0, .2(X, {}0)).
insert3(X, L, .2(X, L)).
insert3(X, .2(H, L1), .2(H, L2)) :- insert3(X, L1, L2).


With regard to the inferred argument filtering the predicates were used in the following modes:
perm2: (b,f)
insert3: (b,b,f)
Transforming PROLOG into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:


perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of PROLOG



↳ PROLOG
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)


Pi DP problem:
The TRS P consists of the following rules:

PERM_2_IN_GA2(._22(X, L), Z) -> IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_in_ga2(L, Y))
PERM_2_IN_GA2(._22(X, L), Z) -> PERM_2_IN_GA2(L, Y)
IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_out_ga2(L, Y)) -> IF_PERM_2_IN_2_GA5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_out_ga2(L, Y)) -> INSERT_3_IN_GGA3(X, Y, Z)
INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> IF_INSERT_3_IN_1_GGA5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> INSERT_3_IN_GGA3(X, L1, L2)

The TRS R consists of the following rules:

perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)
INSERT_3_IN_GGA3(x1, x2, x3)  =  INSERT_3_IN_GGA2(x1, x2)
IF_INSERT_3_IN_1_GGA5(x1, x2, x3, x4, x5)  =  IF_INSERT_3_IN_1_GGA2(x2, x5)
PERM_2_IN_GA2(x1, x2)  =  PERM_2_IN_GA1(x1)
IF_PERM_2_IN_2_GA5(x1, x2, x3, x4, x5)  =  IF_PERM_2_IN_2_GA1(x5)
IF_PERM_2_IN_1_GA4(x1, x2, x3, x4)  =  IF_PERM_2_IN_1_GA2(x1, x4)

We have to consider all (P,R,Pi)-chains

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

PERM_2_IN_GA2(._22(X, L), Z) -> IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_in_ga2(L, Y))
PERM_2_IN_GA2(._22(X, L), Z) -> PERM_2_IN_GA2(L, Y)
IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_out_ga2(L, Y)) -> IF_PERM_2_IN_2_GA5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
IF_PERM_2_IN_1_GA4(X, L, Z, perm_2_out_ga2(L, Y)) -> INSERT_3_IN_GGA3(X, Y, Z)
INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> IF_INSERT_3_IN_1_GGA5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> INSERT_3_IN_GGA3(X, L1, L2)

The TRS R consists of the following rules:

perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)
INSERT_3_IN_GGA3(x1, x2, x3)  =  INSERT_3_IN_GGA2(x1, x2)
IF_INSERT_3_IN_1_GGA5(x1, x2, x3, x4, x5)  =  IF_INSERT_3_IN_1_GGA2(x2, x5)
PERM_2_IN_GA2(x1, x2)  =  PERM_2_IN_GA1(x1)
IF_PERM_2_IN_2_GA5(x1, x2, x3, x4, x5)  =  IF_PERM_2_IN_2_GA1(x5)
IF_PERM_2_IN_1_GA4(x1, x2, x3, x4)  =  IF_PERM_2_IN_1_GA2(x1, x4)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph contains 2 SCCs with 4 less nodes.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
PiDP
                ↳ UsableRulesProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> INSERT_3_IN_GGA3(X, L1, L2)

The TRS R consists of the following rules:

perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)
INSERT_3_IN_GGA3(x1, x2, x3)  =  INSERT_3_IN_GGA2(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting we can delete all non-usable rules from R.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

INSERT_3_IN_GGA3(X, ._22(H, L1), ._22(H, L2)) -> INSERT_3_IN_GGA3(X, L1, L2)

R is empty.
The argument filtering Pi contains the following mapping:
._22(x1, x2)  =  ._22(x1, x2)
INSERT_3_IN_GGA3(x1, x2, x3)  =  INSERT_3_IN_GGA2(x1, x2)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem into ordinary QDP problem by application of Pi.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP

Q DP problem:
The TRS P consists of the following rules:

INSERT_3_IN_GGA2(X, ._22(H, L1)) -> INSERT_3_IN_GGA2(X, L1)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
The head symbols of this DP problem are {INSERT_3_IN_GGA2}.
By using the subterm criterion together with the size-change analysis we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
PiDP
                ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

PERM_2_IN_GA2(._22(X, L), Z) -> PERM_2_IN_GA2(L, Y)

The TRS R consists of the following rules:

perm_2_in_ga2([]_0, []_0) -> perm_2_out_ga2([]_0, []_0)
perm_2_in_ga2(._22(X, L), Z) -> if_perm_2_in_1_ga4(X, L, Z, perm_2_in_ga2(L, Y))
if_perm_2_in_1_ga4(X, L, Z, perm_2_out_ga2(L, Y)) -> if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_in_gga3(X, Y, Z))
insert_3_in_gga3(X, []_0, ._22(X, []_0)) -> insert_3_out_gga3(X, []_0, ._22(X, []_0))
insert_3_in_gga3(X, L, ._22(X, L)) -> insert_3_out_gga3(X, L, ._22(X, L))
insert_3_in_gga3(X, ._22(H, L1), ._22(H, L2)) -> if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_in_gga3(X, L1, L2))
if_insert_3_in_1_gga5(X, H, L1, L2, insert_3_out_gga3(X, L1, L2)) -> insert_3_out_gga3(X, ._22(H, L1), ._22(H, L2))
if_perm_2_in_2_ga5(X, L, Z, Y, insert_3_out_gga3(X, Y, Z)) -> perm_2_out_ga2(._22(X, L), Z)

The argument filtering Pi contains the following mapping:
perm_2_in_ga2(x1, x2)  =  perm_2_in_ga1(x1)
[]_0  =  []_0
._22(x1, x2)  =  ._22(x1, x2)
perm_2_out_ga2(x1, x2)  =  perm_2_out_ga1(x2)
if_perm_2_in_1_ga4(x1, x2, x3, x4)  =  if_perm_2_in_1_ga2(x1, x4)
if_perm_2_in_2_ga5(x1, x2, x3, x4, x5)  =  if_perm_2_in_2_ga1(x5)
insert_3_in_gga3(x1, x2, x3)  =  insert_3_in_gga2(x1, x2)
insert_3_out_gga3(x1, x2, x3)  =  insert_3_out_gga1(x3)
if_insert_3_in_1_gga5(x1, x2, x3, x4, x5)  =  if_insert_3_in_1_gga2(x2, x5)
PERM_2_IN_GA2(x1, x2)  =  PERM_2_IN_GA1(x1)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting we can delete all non-usable rules from R.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

PERM_2_IN_GA2(._22(X, L), Z) -> PERM_2_IN_GA2(L, Y)

R is empty.
The argument filtering Pi contains the following mapping:
._22(x1, x2)  =  ._22(x1, x2)
PERM_2_IN_GA2(x1, x2)  =  PERM_2_IN_GA1(x1)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem into ordinary QDP problem by application of Pi.

↳ PROLOG
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof

Q DP problem:
The TRS P consists of the following rules:

PERM_2_IN_GA1(._22(X, L)) -> PERM_2_IN_GA1(L)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
The head symbols of this DP problem are {PERM_2_IN_GA1}.
By using the subterm criterion together with the size-change analysis we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs: