(0) Obligation:
Clauses:
right(tree(X, XS1, XS2), XS2).
flat(niltree, nil).
flat(tree(X, niltree, XS), cons(X, YS)) :- ','(right(tree(X, niltree, XS), ZS), flat(ZS, YS)).
flat(tree(X, tree(Y, YS1, YS2), XS), ZS) :- flat(tree(Y, YS1, tree(X, YS2, XS)), ZS).
Queries:
flat(a,g).
(1) PrologToDTProblemTransformerProof (SOUND transformation)
Built DT problem from termination graph.
(2) Obligation:
Triples:
flat1(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) :- flat1(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil).
flat1(tree(T84, niltree, T86), cons(T84, T72)) :- flat1(T86, T72).
flat1(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) :- flat1(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107)).
flat1(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) :- flat1(tree(T181, T182, T183), T159).
flat1(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) :- flat1(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210).
Clauses:
flatc1(niltree, nil).
flatc1(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) :- flatc1(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil).
flatc1(tree(T84, niltree, T86), cons(T84, T72)) :- flatc1(T86, T72).
flatc1(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) :- flatc1(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107)).
flatc1(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) :- flatc1(tree(T181, T182, T183), T159).
flatc1(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) :- flatc1(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210).
Afs:
flat1(x1, x2) = flat1(x2)
(3) TriplesToPiDPProof (SOUND transformation)
We use the technique of [LOPSTR]. With regard to the inferred argument filtering the predicates were used in the following modes:
flat1_in: (f,b)
Transforming
TRIPLES into the following
Term Rewriting System:
Pi DP problem:
The TRS P consists of the following rules:
FLAT1_IN_AG(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) → U1_AG(T49, T47, T45, T46, T48, T50, T51, flat1_in_ag(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil))
FLAT1_IN_AG(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) → FLAT1_IN_AG(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil)
FLAT1_IN_AG(tree(T84, niltree, T86), cons(T84, T72)) → U2_AG(T84, T86, T72, flat1_in_ag(T86, T72))
FLAT1_IN_AG(tree(T84, niltree, T86), cons(T84, T72)) → FLAT1_IN_AG(T86, T72)
FLAT1_IN_AG(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) → U3_AG(T110, T108, T109, T111, T112, T106, T107, flat1_in_ag(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107)))
FLAT1_IN_AG(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) → FLAT1_IN_AG(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107))
FLAT1_IN_AG(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) → U4_AG(T181, T177, T182, T183, T159, flat1_in_ag(tree(T181, T182, T183), T159))
FLAT1_IN_AG(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) → FLAT1_IN_AG(tree(T181, T182, T183), T159)
FLAT1_IN_AG(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) → U5_AG(T215, T213, T211, T212, T214, T216, T217, T210, flat1_in_ag(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210))
FLAT1_IN_AG(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) → FLAT1_IN_AG(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210)
R is empty.
The argument filtering Pi contains the following mapping:
flat1_in_ag(
x1,
x2) =
flat1_in_ag(
x2)
nil =
nil
tree(
x1,
x2,
x3) =
tree(
x2,
x3)
cons(
x1,
x2) =
cons(
x1,
x2)
niltree =
niltree
FLAT1_IN_AG(
x1,
x2) =
FLAT1_IN_AG(
x2)
U1_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8) =
U1_AG(
x8)
U2_AG(
x1,
x2,
x3,
x4) =
U2_AG(
x1,
x3,
x4)
U3_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8) =
U3_AG(
x6,
x7,
x8)
U4_AG(
x1,
x2,
x3,
x4,
x5,
x6) =
U4_AG(
x2,
x5,
x6)
U5_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8,
x9) =
U5_AG(
x8,
x9)
We have to consider all (P,R,Pi)-chains
Infinitary Constructor Rewriting Termination of PiDP implies Termination of TRIPLES
(4) Obligation:
Pi DP problem:
The TRS P consists of the following rules:
FLAT1_IN_AG(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) → U1_AG(T49, T47, T45, T46, T48, T50, T51, flat1_in_ag(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil))
FLAT1_IN_AG(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) → FLAT1_IN_AG(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil)
FLAT1_IN_AG(tree(T84, niltree, T86), cons(T84, T72)) → U2_AG(T84, T86, T72, flat1_in_ag(T86, T72))
FLAT1_IN_AG(tree(T84, niltree, T86), cons(T84, T72)) → FLAT1_IN_AG(T86, T72)
FLAT1_IN_AG(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) → U3_AG(T110, T108, T109, T111, T112, T106, T107, flat1_in_ag(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107)))
FLAT1_IN_AG(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) → FLAT1_IN_AG(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107))
FLAT1_IN_AG(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) → U4_AG(T181, T177, T182, T183, T159, flat1_in_ag(tree(T181, T182, T183), T159))
FLAT1_IN_AG(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) → FLAT1_IN_AG(tree(T181, T182, T183), T159)
FLAT1_IN_AG(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) → U5_AG(T215, T213, T211, T212, T214, T216, T217, T210, flat1_in_ag(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210))
FLAT1_IN_AG(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) → FLAT1_IN_AG(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210)
R is empty.
The argument filtering Pi contains the following mapping:
flat1_in_ag(
x1,
x2) =
flat1_in_ag(
x2)
nil =
nil
tree(
x1,
x2,
x3) =
tree(
x2,
x3)
cons(
x1,
x2) =
cons(
x1,
x2)
niltree =
niltree
FLAT1_IN_AG(
x1,
x2) =
FLAT1_IN_AG(
x2)
U1_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8) =
U1_AG(
x8)
U2_AG(
x1,
x2,
x3,
x4) =
U2_AG(
x1,
x3,
x4)
U3_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8) =
U3_AG(
x6,
x7,
x8)
U4_AG(
x1,
x2,
x3,
x4,
x5,
x6) =
U4_AG(
x2,
x5,
x6)
U5_AG(
x1,
x2,
x3,
x4,
x5,
x6,
x7,
x8,
x9) =
U5_AG(
x8,
x9)
We have to consider all (P,R,Pi)-chains
(5) DependencyGraphProof (EQUIVALENT transformation)
The approximation of the Dependency Graph [LOPSTR] contains 1 SCC with 5 less nodes.
(6) Obligation:
Pi DP problem:
The TRS P consists of the following rules:
FLAT1_IN_AG(tree(T215, tree(T213, tree(T211, T212, T214), T216), T217), T210) → FLAT1_IN_AG(tree(T211, T212, tree(T213, T214, tree(T215, T216, T217))), T210)
FLAT1_IN_AG(tree(T49, tree(T47, tree(T45, T46, T48), T50), T51), nil) → FLAT1_IN_AG(tree(T45, T46, tree(T47, T48, tree(T49, T50, T51))), nil)
FLAT1_IN_AG(tree(T84, niltree, T86), cons(T84, T72)) → FLAT1_IN_AG(T86, T72)
FLAT1_IN_AG(tree(T110, tree(T108, T109, T111), T112), cons(T106, T107)) → FLAT1_IN_AG(tree(T108, T109, tree(T110, T111, T112)), cons(T106, T107))
FLAT1_IN_AG(tree(T181, tree(T177, niltree, T182), T183), cons(T177, T159)) → FLAT1_IN_AG(tree(T181, T182, T183), T159)
R is empty.
The argument filtering Pi contains the following mapping:
nil =
nil
tree(
x1,
x2,
x3) =
tree(
x2,
x3)
cons(
x1,
x2) =
cons(
x1,
x2)
niltree =
niltree
FLAT1_IN_AG(
x1,
x2) =
FLAT1_IN_AG(
x2)
We have to consider all (P,R,Pi)-chains
(7) PiDPToQDPProof (SOUND transformation)
Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.
(8) Obligation:
Q DP problem:
The TRS P consists of the following rules:
FLAT1_IN_AG(T210) → FLAT1_IN_AG(T210)
FLAT1_IN_AG(nil) → FLAT1_IN_AG(nil)
FLAT1_IN_AG(cons(T84, T72)) → FLAT1_IN_AG(T72)
FLAT1_IN_AG(cons(T106, T107)) → FLAT1_IN_AG(cons(T106, T107))
R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
(9) MRRProof (EQUIVALENT transformation)
By using the rule removal processor [LPAR04] with the following ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:
FLAT1_IN_AG(cons(T84, T72)) → FLAT1_IN_AG(T72)
Used ordering: Polynomial interpretation [POLO]:
POL(FLAT1_IN_AG(x1)) = x1
POL(cons(x1, x2)) = 1 + x1 + x2
POL(nil) = 0
(10) Obligation:
Q DP problem:
The TRS P consists of the following rules:
FLAT1_IN_AG(T210) → FLAT1_IN_AG(T210)
FLAT1_IN_AG(nil) → FLAT1_IN_AG(nil)
FLAT1_IN_AG(cons(T106, T107)) → FLAT1_IN_AG(cons(T106, T107))
R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
(11) NonTerminationProof (EQUIVALENT transformation)
We used the non-termination processor [FROCOS05] to show that the DP problem is infinite.
Found a loop by semiunifying a rule from P directly.
s =
FLAT1_IN_AG(
T210) evaluates to t =
FLAT1_IN_AG(
T210)
Thus s starts an infinite chain as s semiunifies with t with the following substitutions:
- Semiunifier: [ ]
- Matcher: [ ]
Rewriting sequenceThe DP semiunifies directly so there is only one rewrite step from FLAT1_IN_AG(T210) to FLAT1_IN_AG(T210).
(12) NO