WORST_CASE(Omega(n^1), O(n^1)) proof of /export/starexec/sandbox/benchmark/theBenchmark.xml # AProVE Commit ID: 794c25de1cacf0d048858bcd21c9a779e1221865 marcel 20200619 unpublished dirty The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). (0) CpxTRS (1) RelTrsToWeightedTrsProof [BOTH BOUNDS(ID, ID), 0 ms] (2) CpxWeightedTrs (3) TypeInferenceProof [BOTH BOUNDS(ID, ID), 0 ms] (4) CpxTypedWeightedTrs (5) CompletionProof [UPPER BOUND(ID), 0 ms] (6) CpxTypedWeightedCompleteTrs (7) CpxTypedWeightedTrsToRntsProof [UPPER BOUND(ID), 0 ms] (8) CpxRNTS (9) CompleteCoflocoProof [FINISHED, 213 ms] (10) BOUNDS(1, n^1) (11) RelTrsToDecreasingLoopProblemProof [LOWER BOUND(ID), 0 ms] (12) TRS for Loop Detection (13) DecreasingLoopProof [LOWER BOUND(ID), 0 ms] (14) BEST (15) proven lower bound (16) LowerBoundPropagationProof [FINISHED, 0 ms] (17) BOUNDS(n^1, INF) (18) TRS for Loop Detection ---------------------------------------- (0) Obligation: The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) foldr(a, Nil) -> a foldl(a, Nil) -> a notEmpty(Cons(x, xs)) -> True notEmpty(Nil) -> False op(x, S(0)) -> S(x) op(S(0), y) -> S(y) fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) S is empty. Rewrite Strategy: INNERMOST ---------------------------------------- (1) RelTrsToWeightedTrsProof (BOTH BOUNDS(ID, ID)) Transformed relative TRS to weighted TRS ---------------------------------------- (2) Obligation: The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1). The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) [1] foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) [1] foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) [1] foldr(a, Nil) -> a [1] foldl(a, Nil) -> a [1] notEmpty(Cons(x, xs)) -> True [1] notEmpty(Nil) -> False [1] op(x, S(0)) -> S(x) [1] op(S(0), y) -> S(y) [1] fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) [1] Rewrite Strategy: INNERMOST ---------------------------------------- (3) TypeInferenceProof (BOTH BOUNDS(ID, ID)) Infered types. ---------------------------------------- (4) Obligation: Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) [1] foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) [1] foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) [1] foldr(a, Nil) -> a [1] foldl(a, Nil) -> a [1] notEmpty(Cons(x, xs)) -> True [1] notEmpty(Nil) -> False [1] op(x, S(0)) -> S(x) [1] op(S(0), y) -> S(y) [1] fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) [1] The TRS has the following type information: foldl :: 0:S -> Cons:Nil -> 0:S Cons :: 0:S -> Cons:Nil -> Cons:Nil S :: 0:S -> 0:S 0 :: 0:S foldr :: 0:S -> Cons:Nil -> 0:S op :: 0:S -> 0:S -> 0:S Nil :: Cons:Nil notEmpty :: Cons:Nil -> True:False True :: True:False False :: True:False fold :: 0:S -> Cons:Nil -> Cons:Nil Rewrite Strategy: INNERMOST ---------------------------------------- (5) CompletionProof (UPPER BOUND(ID)) The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added: foldl(v0, v1) -> null_foldl [0] op(v0, v1) -> null_op [0] And the following fresh constants: null_foldl, null_op ---------------------------------------- (6) Obligation: Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is: Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) [1] foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) [1] foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) [1] foldr(a, Nil) -> a [1] foldl(a, Nil) -> a [1] notEmpty(Cons(x, xs)) -> True [1] notEmpty(Nil) -> False [1] op(x, S(0)) -> S(x) [1] op(S(0), y) -> S(y) [1] fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) [1] foldl(v0, v1) -> null_foldl [0] op(v0, v1) -> null_op [0] The TRS has the following type information: foldl :: 0:S:null_foldl:null_op -> Cons:Nil -> 0:S:null_foldl:null_op Cons :: 0:S:null_foldl:null_op -> Cons:Nil -> Cons:Nil S :: 0:S:null_foldl:null_op -> 0:S:null_foldl:null_op 0 :: 0:S:null_foldl:null_op foldr :: 0:S:null_foldl:null_op -> Cons:Nil -> 0:S:null_foldl:null_op op :: 0:S:null_foldl:null_op -> 0:S:null_foldl:null_op -> 0:S:null_foldl:null_op Nil :: Cons:Nil notEmpty :: Cons:Nil -> True:False True :: True:False False :: True:False fold :: 0:S:null_foldl:null_op -> Cons:Nil -> Cons:Nil null_foldl :: 0:S:null_foldl:null_op null_op :: 0:S:null_foldl:null_op Rewrite Strategy: INNERMOST ---------------------------------------- (7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID)) Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction. The constant constructors are abstracted as follows: 0 => 0 Nil => 0 True => 1 False => 0 null_foldl => 0 null_op => 0 ---------------------------------------- (8) Obligation: Complexity RNTS consisting of the following rules: fold(z, z') -{ 1 }-> 1 + foldl(a, xs) + (1 + foldr(a, xs) + 0) :|: z = a, xs >= 0, a >= 0, z' = xs foldl(z, z') -{ 1 }-> a :|: z = a, a >= 0, z' = 0 foldl(z, z') -{ 1 }-> foldl(1 + x, xs) :|: z' = 1 + (1 + 0) + xs, xs >= 0, x >= 0, z = x foldl(z, z') -{ 1 }-> foldl(1 + x, xs) :|: xs >= 0, z' = 1 + x + xs, z = 1 + 0, x >= 0 foldl(z, z') -{ 0 }-> 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1 foldr(z, z') -{ 1 }-> a :|: z = a, a >= 0, z' = 0 foldr(z, z') -{ 1 }-> op(x, foldr(a, xs)) :|: z = a, xs >= 0, z' = 1 + x + xs, a >= 0, x >= 0 notEmpty(z) -{ 1 }-> 1 :|: z = 1 + x + xs, xs >= 0, x >= 0 notEmpty(z) -{ 1 }-> 0 :|: z = 0 op(z, z') -{ 0 }-> 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1 op(z, z') -{ 1 }-> 1 + x :|: x >= 0, z' = 1 + 0, z = x op(z, z') -{ 1 }-> 1 + y :|: z = 1 + 0, y >= 0, z' = y Only complete derivations are relevant for the runtime complexity. ---------------------------------------- (9) CompleteCoflocoProof (FINISHED) Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo: eq(start(V1, V),0,[foldl(V1, V, Out)],[V1 >= 0,V >= 0]). eq(start(V1, V),0,[foldr(V1, V, Out)],[V1 >= 0,V >= 0]). eq(start(V1, V),0,[notEmpty(V1, Out)],[V1 >= 0]). eq(start(V1, V),0,[op(V1, V, Out)],[V1 >= 0,V >= 0]). eq(start(V1, V),0,[fold(V1, V, Out)],[V1 >= 0,V >= 0]). eq(foldl(V1, V, Out),1,[foldl(1 + V3, V2, Ret)],[Out = Ret,V = 2 + V2,V2 >= 0,V3 >= 0,V1 = V3]). eq(foldl(V1, V, Out),1,[foldl(1 + V4, V5, Ret1)],[Out = Ret1,V5 >= 0,V = 1 + V4 + V5,V1 = 1,V4 >= 0]). eq(foldr(V1, V, Out),1,[foldr(V7, V8, Ret11),op(V6, Ret11, Ret2)],[Out = Ret2,V1 = V7,V8 >= 0,V = 1 + V6 + V8,V7 >= 0,V6 >= 0]). eq(foldr(V1, V, Out),1,[],[Out = V9,V1 = V9,V9 >= 0,V = 0]). eq(foldl(V1, V, Out),1,[],[Out = V10,V1 = V10,V10 >= 0,V = 0]). eq(notEmpty(V1, Out),1,[],[Out = 1,V1 = 1 + V11 + V12,V12 >= 0,V11 >= 0]). eq(notEmpty(V1, Out),1,[],[Out = 0,V1 = 0]). eq(op(V1, V, Out),1,[],[Out = 1 + V13,V13 >= 0,V = 1,V1 = V13]). eq(op(V1, V, Out),1,[],[Out = 1 + V14,V1 = 1,V14 >= 0,V = V14]). eq(fold(V1, V, Out),1,[foldl(V16, V15, Ret01),foldr(V16, V15, Ret101)],[Out = 2 + Ret01 + Ret101,V1 = V16,V15 >= 0,V16 >= 0,V = V15]). eq(foldl(V1, V, Out),0,[],[Out = 0,V18 >= 0,V17 >= 0,V1 = V18,V = V17]). eq(op(V1, V, Out),0,[],[Out = 0,V20 >= 0,V19 >= 0,V1 = V20,V = V19]). input_output_vars(foldl(V1,V,Out),[V1,V],[Out]). input_output_vars(foldr(V1,V,Out),[V1,V],[Out]). input_output_vars(notEmpty(V1,Out),[V1],[Out]). input_output_vars(op(V1,V,Out),[V1,V],[Out]). input_output_vars(fold(V1,V,Out),[V1,V],[Out]). CoFloCo proof output: Preprocessing Cost Relations ===================================== #### Computed strongly connected components 0. recursive : [foldl/3] 1. non_recursive : [op/3] 2. recursive [non_tail] : [foldr/3] 3. non_recursive : [fold/3] 4. non_recursive : [notEmpty/2] 5. non_recursive : [start/2] #### Obtained direct recursion through partial evaluation 0. SCC is partially evaluated into foldl/3 1. SCC is partially evaluated into op/3 2. SCC is partially evaluated into foldr/3 3. SCC is partially evaluated into fold/3 4. SCC is partially evaluated into notEmpty/2 5. SCC is partially evaluated into start/2 Control-Flow Refinement of Cost Relations ===================================== ### Specialization of cost equations foldl/3 * CE 9 is refined into CE [18] * CE 8 is refined into CE [19] * CE 6 is refined into CE [20] * CE 7 is refined into CE [21] ### Cost equations --> "Loop" of foldl/3 * CEs [20] --> Loop 14 * CEs [21] --> Loop 15 * CEs [18] --> Loop 16 * CEs [19] --> Loop 17 ### Ranking functions of CR foldl(V1,V,Out) * RF of phase [14,15]: [V,V1+V-1] #### Partial ranking functions of CR foldl(V1,V,Out) * Partial RF of phase [14,15]: - RF of loop [14:1]: V/2-1/2 - RF of loop [15:1]: V V1+V-1 ### Specialization of cost equations op/3 * CE 16 is refined into CE [22] * CE 14 is refined into CE [23] * CE 15 is refined into CE [24] ### Cost equations --> "Loop" of op/3 * CEs [22] --> Loop 18 * CEs [23] --> Loop 19 * CEs [24] --> Loop 20 ### Ranking functions of CR op(V1,V,Out) #### Partial ranking functions of CR op(V1,V,Out) ### Specialization of cost equations foldr/3 * CE 11 is refined into CE [25] * CE 10 is refined into CE [26,27,28] ### Cost equations --> "Loop" of foldr/3 * CEs [26] --> Loop 21 * CEs [27] --> Loop 22 * CEs [28] --> Loop 23 * CEs [25] --> Loop 24 ### Ranking functions of CR foldr(V1,V,Out) * RF of phase [21,22,23]: [V] #### Partial ranking functions of CR foldr(V1,V,Out) * Partial RF of phase [21,22,23]: - RF of loop [21:1]: V-1 - RF of loop [22:1,23:1]: V ### Specialization of cost equations fold/3 * CE 17 is refined into CE [29,30,31,32] ### Cost equations --> "Loop" of fold/3 * CEs [32] --> Loop 25 * CEs [31] --> Loop 26 * CEs [29] --> Loop 27 * CEs [30] --> Loop 28 ### Ranking functions of CR fold(V1,V,Out) #### Partial ranking functions of CR fold(V1,V,Out) ### Specialization of cost equations notEmpty/2 * CE 12 is refined into CE [33] * CE 13 is refined into CE [34] ### Cost equations --> "Loop" of notEmpty/2 * CEs [33] --> Loop 29 * CEs [34] --> Loop 30 ### Ranking functions of CR notEmpty(V1,Out) #### Partial ranking functions of CR notEmpty(V1,Out) ### Specialization of cost equations start/2 * CE 1 is refined into CE [35,36,37] * CE 2 is refined into CE [38,39] * CE 3 is refined into CE [40,41] * CE 4 is refined into CE [42,43,44] * CE 5 is refined into CE [45,46,47,48] ### Cost equations --> "Loop" of start/2 * CEs [41] --> Loop 31 * CEs [43] --> Loop 32 * CEs [35,38,45,46] --> Loop 33 * CEs [36,37,39,42,44,47,48] --> Loop 34 * CEs [40] --> Loop 35 ### Ranking functions of CR start(V1,V) #### Partial ranking functions of CR start(V1,V) Computing Bounds ===================================== #### Cost of chains of foldl(V1,V,Out): * Chain [[14,15],17]: 1*it(14)+1*it(15)+1 Such that:aux(1) =< V1+V aux(2) =< V1+V-Out it(14) =< V/2 aux(5) =< V it(14) =< aux(1) it(15) =< aux(1) it(14) =< aux(2) it(15) =< aux(2) it(14) =< aux(5) it(15) =< aux(5) with precondition: [V1>=0,Out>=1,Out>=V1,V+V1>=Out+1] * Chain [[14,15],16]: 1*it(14)+1*it(15)+0 Such that:it(14) =< V/2 aux(6) =< V1+V aux(7) =< V it(14) =< aux(6) it(15) =< aux(6) it(14) =< aux(7) it(15) =< aux(7) with precondition: [Out=0,V1>=0,V>=1,V+V1>=2] * Chain [17]: 1 with precondition: [V=0,V1=Out,V1>=0] * Chain [16]: 0 with precondition: [Out=0,V1>=0,V>=0] #### Cost of chains of op(V1,V,Out): * Chain [20]: 1 with precondition: [V1=1,V+1=Out,V>=0] * Chain [19]: 1 with precondition: [V=1,V1+1=Out,V1>=0] * Chain [18]: 0 with precondition: [Out=0,V1>=0,V>=0] #### Cost of chains of foldr(V1,V,Out): * Chain [[21,22,23],24]: 5*it(21)+1 Such that:aux(10) =< V it(21) =< aux(10) with precondition: [V1>=0,V>=1,Out>=0,V+V1>=Out+1] * Chain [24]: 1 with precondition: [V=0,V1=Out,V1>=0] #### Cost of chains of fold(V1,V,Out): * Chain [28]: 2 with precondition: [V=0,V1+2=Out,V1>=0] * Chain [27]: 3 with precondition: [V=0,2*V1+2=Out,V1>=0] * Chain [26]: 1*s(11)+1*s(12)+5*s(14)+2 Such that:s(9) =< V1+V s(11) =< V/2 aux(12) =< V s(14) =< aux(12) s(11) =< s(9) s(12) =< s(9) s(11) =< aux(12) s(12) =< aux(12) with precondition: [V1>=0,V>=1,Out>=2,V+V1+1>=Out] * Chain [25]: 1*s(17)+1*s(19)+5*s(21)+3 Such that:s(17) =< V/2 aux(13) =< V1+V aux(14) =< V s(21) =< aux(14) s(17) =< aux(13) s(19) =< aux(13) s(17) =< aux(14) s(19) =< aux(14) with precondition: [V1>=0,V>=1,Out>=3,Out>=V1+2,V+V1>=2,2*V+2*V1>=Out] #### Cost of chains of notEmpty(V1,Out): * Chain [30]: 1 with precondition: [V1=0,Out=0] * Chain [29]: 1 with precondition: [Out=1,V1>=1] #### Cost of chains of start(V1,V): * Chain [35]: 1 with precondition: [V1=0] * Chain [34]: 4*s(24)+4*s(25)+15*s(32)+3 Such that:aux(16) =< V1+V aux(17) =< V aux(18) =< V/2 s(24) =< aux(18) s(24) =< aux(16) s(25) =< aux(16) s(24) =< aux(17) s(25) =< aux(17) s(32) =< aux(17) with precondition: [V1>=0,V>=0] * Chain [33]: 3 with precondition: [V=0,V1>=0] * Chain [32]: 1 with precondition: [V=1,V1>=0] * Chain [31]: 1 with precondition: [V1>=1] Closed-form bounds of start(V1,V): ------------------------------------- * Chain [35] with precondition: [V1=0] - Upper bound: 1 - Complexity: constant * Chain [34] with precondition: [V1>=0,V>=0] - Upper bound: 4*V1+21*V+3 - Complexity: n * Chain [33] with precondition: [V=0,V1>=0] - Upper bound: 3 - Complexity: constant * Chain [32] with precondition: [V=1,V1>=0] - Upper bound: 1 - Complexity: constant * Chain [31] with precondition: [V1>=1] - Upper bound: 1 - Complexity: constant ### Maximum cost of start(V1,V): max([2,nat(V)*15+2+nat(V1+V)*4+nat(V/2)*4])+1 Asymptotic class: n * Total analysis performed in 243 ms. ---------------------------------------- (10) BOUNDS(1, n^1) ---------------------------------------- (11) RelTrsToDecreasingLoopProblemProof (LOWER BOUND(ID)) Transformed a relative TRS into a decreasing-loop problem. ---------------------------------------- (12) Obligation: Analyzing the following TRS for decreasing loops: The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) foldr(a, Nil) -> a foldl(a, Nil) -> a notEmpty(Cons(x, xs)) -> True notEmpty(Nil) -> False op(x, S(0)) -> S(x) op(S(0), y) -> S(y) fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) S is empty. Rewrite Strategy: INNERMOST ---------------------------------------- (13) DecreasingLoopProof (LOWER BOUND(ID)) The following loop(s) give(s) rise to the lower bound Omega(n^1): The rewrite sequence foldl(x, Cons(S(0), xs)) ->^+ foldl(S(x), xs) gives rise to a decreasing loop by considering the right hand sides subterm at position []. The pumping substitution is [xs / Cons(S(0), xs)]. The result substitution is [x / S(x)]. ---------------------------------------- (14) Complex Obligation (BEST) ---------------------------------------- (15) Obligation: Proved the lower bound n^1 for the following obligation: The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) foldr(a, Nil) -> a foldl(a, Nil) -> a notEmpty(Cons(x, xs)) -> True notEmpty(Nil) -> False op(x, S(0)) -> S(x) op(S(0), y) -> S(y) fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) S is empty. Rewrite Strategy: INNERMOST ---------------------------------------- (16) LowerBoundPropagationProof (FINISHED) Propagated lower bound. ---------------------------------------- (17) BOUNDS(n^1, INF) ---------------------------------------- (18) Obligation: Analyzing the following TRS for decreasing loops: The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). The TRS R consists of the following rules: foldl(x, Cons(S(0), xs)) -> foldl(S(x), xs) foldl(S(0), Cons(x, xs)) -> foldl(S(x), xs) foldr(a, Cons(x, xs)) -> op(x, foldr(a, xs)) foldr(a, Nil) -> a foldl(a, Nil) -> a notEmpty(Cons(x, xs)) -> True notEmpty(Nil) -> False op(x, S(0)) -> S(x) op(S(0), y) -> S(y) fold(a, xs) -> Cons(foldl(a, xs), Cons(foldr(a, xs), Nil)) S is empty. Rewrite Strategy: INNERMOST