(0) Obligation:
Clauses:
countstack(empty, 0).
countstack(S, X) :- ','(no(empty_stack(S)), ','(pop(S, nil), ','(popped(S, Pd), countstack(Pd, X)))).
countstack(S, s(X)) :- ','(no(empty_stack(S)), ','(pop(S, P), ','(no(empty_list(P)), ','(head(P, H), ','(tail(P, T), ','(popped(S, Pd), countstack(push(H, push(T, Pd)), X))))))).
pop(empty, X1).
pop(push(P, X2), P).
popped(empty, empty).
popped(push(X3, Pd), Pd).
head(nil, X4).
head(cons(H, X5), H).
tail(nil, nil).
tail(cons(X6, T), T).
empty_stack(empty).
empty_list(nil).
no(X) :- ','(X, ','(!, failure(a))).
no(X7).
failure(b).
Query: countstack(g,a)
(1) PrologToCdtProblemTransformerProof (UPPER BOUND (ID) transformation)
Built complexity over-approximating cdt problems from derivation graph.
(2) Obligation:
Complexity Dependency Tuples Problem
Rules:
f2_in(empty) → f2_out1(0)
f2_in(push(nil, z0)) → U1(f104_in(z0), push(nil, z0))
f2_in(push(cons(z0, z1), z2)) → U2(f2_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U1(f104_out1(z0), push(nil, z1)) → f2_out1(z0)
U1(f104_out5(z0), push(nil, z1)) → f2_out1(z0)
U2(f2_out1(z0), push(cons(z1, z2), z3)) → f2_out1(s(z0))
f104_in(z0) → U3(f2_in(z0), f106_in(z0), z0)
U3(f2_out1(z0), z1, z2) → f104_out1(z0)
U3(z0, f106_out4(z1), z2) → f104_out5(z1)
Tuples:
F2_IN(push(nil, z0)) → c1(U1'(f104_in(z0), push(nil, z0)), F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(U2'(f2_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(U3'(f2_in(z0), f106_in(z0), z0), F2_IN(z0))
S tuples:
F2_IN(push(nil, z0)) → c1(U1'(f104_in(z0), push(nil, z0)), F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(U2'(f2_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(U3'(f2_in(z0), f106_in(z0), z0), F2_IN(z0))
K tuples:none
Defined Rule Symbols:
f2_in, U1, U2, f104_in, U3
Defined Pair Symbols:
F2_IN, F104_IN
Compound Symbols:
c1, c2, c6
(3) CdtGraphRemoveTrailingTuplepartsProof (BOTH BOUNDS(ID, ID) transformation)
Removed 3 trailing tuple parts
(4) Obligation:
Complexity Dependency Tuples Problem
Rules:
f2_in(empty) → f2_out1(0)
f2_in(push(nil, z0)) → U1(f104_in(z0), push(nil, z0))
f2_in(push(cons(z0, z1), z2)) → U2(f2_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U1(f104_out1(z0), push(nil, z1)) → f2_out1(z0)
U1(f104_out5(z0), push(nil, z1)) → f2_out1(z0)
U2(f2_out1(z0), push(cons(z1, z2), z3)) → f2_out1(s(z0))
f104_in(z0) → U3(f2_in(z0), f106_in(z0), z0)
U3(f2_out1(z0), z1, z2) → f104_out1(z0)
U3(z0, f106_out4(z1), z2) → f104_out5(z1)
Tuples:
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
S tuples:
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
K tuples:none
Defined Rule Symbols:
f2_in, U1, U2, f104_in, U3
Defined Pair Symbols:
F2_IN, F104_IN
Compound Symbols:
c1, c2, c6
(5) CdtPolyRedPairProof (UPPER BOUND (ADD(O(n^1))) transformation)
Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
We considered the (Usable) Rules:none
And the Tuples:
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
The order we found is given by the following interpretation:
Polynomial interpretation :
POL(F104_IN(x1)) = [1] + [2]x1
POL(F2_IN(x1)) = [2]x1
POL(c1(x1)) = x1
POL(c2(x1)) = x1
POL(c6(x1)) = x1
POL(cons(x1, x2)) = [1] + x1 + x2
POL(nil) = [2]
POL(push(x1, x2)) = x1 + x2
(6) Obligation:
Complexity Dependency Tuples Problem
Rules:
f2_in(empty) → f2_out1(0)
f2_in(push(nil, z0)) → U1(f104_in(z0), push(nil, z0))
f2_in(push(cons(z0, z1), z2)) → U2(f2_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U1(f104_out1(z0), push(nil, z1)) → f2_out1(z0)
U1(f104_out5(z0), push(nil, z1)) → f2_out1(z0)
U2(f2_out1(z0), push(cons(z1, z2), z3)) → f2_out1(s(z0))
f104_in(z0) → U3(f2_in(z0), f106_in(z0), z0)
U3(f2_out1(z0), z1, z2) → f104_out1(z0)
U3(z0, f106_out4(z1), z2) → f104_out5(z1)
Tuples:
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
S tuples:none
K tuples:
F2_IN(push(nil, z0)) → c1(F104_IN(z0))
F2_IN(push(cons(z0, z1), z2)) → c2(F2_IN(push(z0, push(z1, z2))))
F104_IN(z0) → c6(F2_IN(z0))
Defined Rule Symbols:
f2_in, U1, U2, f104_in, U3
Defined Pair Symbols:
F2_IN, F104_IN
Compound Symbols:
c1, c2, c6
(7) SIsEmptyProof (EQUIVALENT transformation)
The set S is empty
(8) BOUNDS(O(1), O(1))
(9) PrologToCdtProblemTransformerProof (UPPER BOUND (ID) transformation)
Built complexity over-approximating cdt problems from derivation graph.
(10) Obligation:
Complexity Dependency Tuples Problem
Rules:
f1_in(empty) → f1_out1(0)
f1_in(empty) → U1(f10_in, empty)
f1_in(z0) → U2(f8_in(z0), z0)
U1(f10_out1(z0), empty) → f1_out1(z0)
U1(f10_out2(z0), empty) → f1_out1(z0)
U2(f8_out1(z0), z1) → f1_out1(z0)
U2(f8_out2(z0), z1) → f1_out1(z0)
f55_in(push(nil, z0)) → U3(f1_in(z0), push(nil, z0))
U3(f1_out1(z0), push(nil, z1)) → f55_out1(z0)
f56_in(push(cons(z0, z1), z2)) → U4(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U4(f1_out1(z0), push(cons(z1, z2), z3)) → f56_out1(s(z0))
f8_in(z0) → U5(f55_in(z0), f56_in(z0), z0)
U5(f55_out1(z0), z1, z2) → f8_out1(z0)
U5(z0, f56_out1(z1), z2) → f8_out2(z1)
f10_in → U6(f12_in, f14_in)
U6(f12_out1(z0), z1) → f10_out1(z0)
U6(z0, f14_out1(z1)) → f10_out2(z1)
Tuples:
F1_IN(empty) → c1(U1'(f10_in, empty), F10_IN)
F1_IN(z0) → c2(U2'(f8_in(z0), z0), F8_IN(z0))
F55_IN(push(nil, z0)) → c7(U3'(f1_in(z0), push(nil, z0)), F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(U4'(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(U5'(f55_in(z0), f56_in(z0), z0), F55_IN(z0), F56_IN(z0))
F10_IN → c14(U6'(f12_in, f14_in))
S tuples:
F1_IN(empty) → c1(U1'(f10_in, empty), F10_IN)
F1_IN(z0) → c2(U2'(f8_in(z0), z0), F8_IN(z0))
F55_IN(push(nil, z0)) → c7(U3'(f1_in(z0), push(nil, z0)), F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(U4'(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(U5'(f55_in(z0), f56_in(z0), z0), F55_IN(z0), F56_IN(z0))
F10_IN → c14(U6'(f12_in, f14_in))
K tuples:none
Defined Rule Symbols:
f1_in, U1, U2, f55_in, U3, f56_in, U4, f8_in, U5, f10_in, U6
Defined Pair Symbols:
F1_IN, F55_IN, F56_IN, F8_IN, F10_IN
Compound Symbols:
c1, c2, c7, c9, c11, c14
(11) CdtGraphSplitRhsProof (BOTH BOUNDS(ID, ID) transformation)
Split RHS of tuples not part of any SCC
(12) Obligation:
Complexity Dependency Tuples Problem
Rules:
f1_in(empty) → f1_out1(0)
f1_in(empty) → U1(f10_in, empty)
f1_in(z0) → U2(f8_in(z0), z0)
U1(f10_out1(z0), empty) → f1_out1(z0)
U1(f10_out2(z0), empty) → f1_out1(z0)
U2(f8_out1(z0), z1) → f1_out1(z0)
U2(f8_out2(z0), z1) → f1_out1(z0)
f55_in(push(nil, z0)) → U3(f1_in(z0), push(nil, z0))
U3(f1_out1(z0), push(nil, z1)) → f55_out1(z0)
f56_in(push(cons(z0, z1), z2)) → U4(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U4(f1_out1(z0), push(cons(z1, z2), z3)) → f56_out1(s(z0))
f8_in(z0) → U5(f55_in(z0), f56_in(z0), z0)
U5(f55_out1(z0), z1, z2) → f8_out1(z0)
U5(z0, f56_out1(z1), z2) → f8_out2(z1)
f10_in → U6(f12_in, f14_in)
U6(f12_out1(z0), z1) → f10_out1(z0)
U6(z0, f14_out1(z1)) → f10_out2(z1)
Tuples:
F1_IN(z0) → c2(U2'(f8_in(z0), z0), F8_IN(z0))
F55_IN(push(nil, z0)) → c7(U3'(f1_in(z0), push(nil, z0)), F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(U4'(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(U5'(f55_in(z0), f56_in(z0), z0), F55_IN(z0), F56_IN(z0))
F10_IN → c14(U6'(f12_in, f14_in))
F1_IN(empty) → c(U1'(f10_in, empty))
F1_IN(empty) → c(F10_IN)
S tuples:
F1_IN(z0) → c2(U2'(f8_in(z0), z0), F8_IN(z0))
F55_IN(push(nil, z0)) → c7(U3'(f1_in(z0), push(nil, z0)), F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(U4'(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2)), F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(U5'(f55_in(z0), f56_in(z0), z0), F55_IN(z0), F56_IN(z0))
F10_IN → c14(U6'(f12_in, f14_in))
F1_IN(empty) → c(U1'(f10_in, empty))
F1_IN(empty) → c(F10_IN)
K tuples:none
Defined Rule Symbols:
f1_in, U1, U2, f55_in, U3, f56_in, U4, f8_in, U5, f10_in, U6
Defined Pair Symbols:
F1_IN, F55_IN, F56_IN, F8_IN, F10_IN
Compound Symbols:
c2, c7, c9, c11, c14, c
(13) CdtGraphRemoveTrailingTuplepartsProof (BOTH BOUNDS(ID, ID) transformation)
Removed 6 trailing tuple parts
(14) Obligation:
Complexity Dependency Tuples Problem
Rules:
f1_in(empty) → f1_out1(0)
f1_in(empty) → U1(f10_in, empty)
f1_in(z0) → U2(f8_in(z0), z0)
U1(f10_out1(z0), empty) → f1_out1(z0)
U1(f10_out2(z0), empty) → f1_out1(z0)
U2(f8_out1(z0), z1) → f1_out1(z0)
U2(f8_out2(z0), z1) → f1_out1(z0)
f55_in(push(nil, z0)) → U3(f1_in(z0), push(nil, z0))
U3(f1_out1(z0), push(nil, z1)) → f55_out1(z0)
f56_in(push(cons(z0, z1), z2)) → U4(f1_in(push(z0, push(z1, z2))), push(cons(z0, z1), z2))
U4(f1_out1(z0), push(cons(z1, z2), z3)) → f56_out1(s(z0))
f8_in(z0) → U5(f55_in(z0), f56_in(z0), z0)
U5(f55_out1(z0), z1, z2) → f8_out1(z0)
U5(z0, f56_out1(z1), z2) → f8_out2(z1)
f10_in → U6(f12_in, f14_in)
U6(f12_out1(z0), z1) → f10_out1(z0)
U6(z0, f14_out1(z1)) → f10_out2(z1)
Tuples:
F1_IN(empty) → c(F10_IN)
F1_IN(z0) → c2(F8_IN(z0))
F55_IN(push(nil, z0)) → c7(F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(F55_IN(z0), F56_IN(z0))
F10_IN → c14
F1_IN(empty) → c
S tuples:
F1_IN(empty) → c(F10_IN)
F1_IN(z0) → c2(F8_IN(z0))
F55_IN(push(nil, z0)) → c7(F1_IN(z0))
F56_IN(push(cons(z0, z1), z2)) → c9(F1_IN(push(z0, push(z1, z2))))
F8_IN(z0) → c11(F55_IN(z0), F56_IN(z0))
F10_IN → c14
F1_IN(empty) → c
K tuples:none
Defined Rule Symbols:
f1_in, U1, U2, f55_in, U3, f56_in, U4, f8_in, U5, f10_in, U6
Defined Pair Symbols:
F1_IN, F55_IN, F56_IN, F8_IN, F10_IN
Compound Symbols:
c, c2, c7, c9, c11, c14, c