WORST_CASE(Omega(n^1),O(n^1)) proof of /export/starexec/sandbox/benchmark/theBenchmark.trs # AProVE Commit ID: c69e44bd14796315568835c1ffa2502984884775 mhark 20210624 unpublished 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, 193 ms] (10) BOUNDS(1, n^1) (11) RenamingProof [BOTH BOUNDS(ID, ID), 0 ms] (12) CpxTRS (13) TypeInferenceProof [BOTH BOUNDS(ID, ID), 0 ms] (14) typed CpxTrs (15) OrderProof [LOWER BOUND(ID), 11 ms] (16) typed CpxTrs (17) RewriteLemmaProof [LOWER BOUND(ID), 393 ms] (18) proven lower bound (19) LowerBoundPropagationProof [FINISHED, 0 ms] (20) BOUNDS(n^1, INF) ---------------------------------------- (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: average(s(x), y) -> average(x, s(y)) average(x, s(s(s(y)))) -> s(average(s(x), y)) average(0, 0) -> 0 average(0, s(0)) -> 0 average(0, s(s(0))) -> s(0) 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: average(s(x), y) -> average(x, s(y)) [1] average(x, s(s(s(y)))) -> s(average(s(x), y)) [1] average(0, 0) -> 0 [1] average(0, s(0)) -> 0 [1] average(0, s(s(0))) -> s(0) [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: average(s(x), y) -> average(x, s(y)) [1] average(x, s(s(s(y)))) -> s(average(s(x), y)) [1] average(0, 0) -> 0 [1] average(0, s(0)) -> 0 [1] average(0, s(s(0))) -> s(0) [1] The TRS has the following type information: average :: s:0 -> s:0 -> s:0 s :: s:0 -> s:0 0 :: s:0 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: none And the following fresh constants: none ---------------------------------------- (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: average(s(x), y) -> average(x, s(y)) [1] average(x, s(s(s(y)))) -> s(average(s(x), y)) [1] average(0, 0) -> 0 [1] average(0, s(0)) -> 0 [1] average(0, s(s(0))) -> s(0) [1] The TRS has the following type information: average :: s:0 -> s:0 -> s:0 s :: s:0 -> s:0 0 :: s:0 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 ---------------------------------------- (8) Obligation: Complexity RNTS consisting of the following rules: average(z, z') -{ 1 }-> average(x, 1 + y) :|: x >= 0, y >= 0, z = 1 + x, z' = y average(z, z') -{ 1 }-> 0 :|: z = 0, z' = 0 average(z, z') -{ 1 }-> 0 :|: z' = 1 + 0, z = 0 average(z, z') -{ 1 }-> 1 + average(1 + x, y) :|: x >= 0, y >= 0, z' = 1 + (1 + (1 + y)), z = x average(z, z') -{ 1 }-> 1 + 0 :|: z' = 1 + (1 + 0), z = 0 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,[average(V1, V, Out)],[V1 >= 0,V >= 0]). eq(average(V1, V, Out),1,[average(V3, 1 + V2, Ret)],[Out = Ret,V3 >= 0,V2 >= 0,V1 = 1 + V3,V = V2]). eq(average(V1, V, Out),1,[average(1 + V4, V5, Ret1)],[Out = 1 + Ret1,V4 >= 0,V5 >= 0,V = 3 + V5,V1 = V4]). eq(average(V1, V, Out),1,[],[Out = 0,V1 = 0,V = 0]). eq(average(V1, V, Out),1,[],[Out = 0,V = 1,V1 = 0]). eq(average(V1, V, Out),1,[],[Out = 1,V = 2,V1 = 0]). input_output_vars(average(V1,V,Out),[V1,V],[Out]). CoFloCo proof output: Preprocessing Cost Relations ===================================== #### Computed strongly connected components 0. recursive : [average/3] 1. non_recursive : [start/2] #### Obtained direct recursion through partial evaluation 0. SCC is partially evaluated into average/3 1. SCC is partially evaluated into start/2 Control-Flow Refinement of Cost Relations ===================================== ### Specialization of cost equations average/3 * CE 6 is refined into CE [7] * CE 5 is refined into CE [8] * CE 4 is refined into CE [9] * CE 3 is refined into CE [10] * CE 2 is refined into CE [11] ### Cost equations --> "Loop" of average/3 * CEs [10] --> Loop 7 * CEs [11] --> Loop 8 * CEs [7] --> Loop 9 * CEs [8] --> Loop 10 * CEs [9] --> Loop 11 ### Ranking functions of CR average(V1,V,Out) * RF of phase [7,8]: [2*V1+V-1] #### Partial ranking functions of CR average(V1,V,Out) * Partial RF of phase [7,8]: - RF of loop [7:1]: V/3-2/3 depends on loops [8:1] - RF of loop [8:1]: V1 depends on loops [7:1] ### Specialization of cost equations start/2 * CE 1 is refined into CE [12,13,14,15,16] ### Cost equations --> "Loop" of start/2 * CEs [15,16] --> Loop 12 * CEs [14] --> Loop 13 * CEs [13] --> Loop 14 * CEs [12] --> Loop 15 ### Ranking functions of CR start(V1,V) #### Partial ranking functions of CR start(V1,V) Computing Bounds ===================================== #### Cost of chains of average(V1,V,Out): * Chain [[7,8],10]: 2*it(7)+1 Such that:aux(6) =< V1+2*Out aux(5) =< V1+2*Out+1 it(7) =< aux(5) it(7) =< aux(6) with precondition: [V+V1=2*Out+1,V1>=0,V>=0,V+3*V1>=3] * Chain [[7,8],9]: 2*it(7)+1 Such that:aux(7) =< -V+4*Out it(7) =< aux(7) with precondition: [V+V1=2*Out,V1>=0,V>=0,V+V1>=2,V+3*V1>=4] * Chain [11]: 1 with precondition: [V1=0,V=0,Out=0] * Chain [10]: 1 with precondition: [V1=0,V=1,Out=0] * Chain [9]: 1 with precondition: [V1=0,V=2,Out=1] #### Cost of chains of start(V1,V): * Chain [15]: 1 with precondition: [V1=0,V=0] * Chain [14]: 1 with precondition: [V1=0,V=1] * Chain [13]: 1 with precondition: [V1=0,V=2] * Chain [12]: 4*s(2)+1 Such that:aux(9) =< 2*V1+V s(2) =< aux(9) with precondition: [V1>=0,V>=0,V+3*V1>=3] Closed-form bounds of start(V1,V): ------------------------------------- * Chain [15] with precondition: [V1=0,V=0] - Upper bound: 1 - Complexity: constant * Chain [14] with precondition: [V1=0,V=1] - Upper bound: 1 - Complexity: constant * Chain [13] with precondition: [V1=0,V=2] - Upper bound: 1 - Complexity: constant * Chain [12] with precondition: [V1>=0,V>=0,V+3*V1>=3] - Upper bound: 8*V1+4*V+1 - Complexity: n ### Maximum cost of start(V1,V): 8*V1+4*V+1 Asymptotic class: n * Total analysis performed in 104 ms. ---------------------------------------- (10) BOUNDS(1, n^1) ---------------------------------------- (11) RenamingProof (BOTH BOUNDS(ID, ID)) Renamed function symbols to avoid clashes with predefined symbol. ---------------------------------------- (12) Obligation: The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, INF). The TRS R consists of the following rules: average(s(x), y) -> average(x, s(y)) average(x, s(s(s(y)))) -> s(average(s(x), y)) average(0', 0') -> 0' average(0', s(0')) -> 0' average(0', s(s(0'))) -> s(0') S is empty. Rewrite Strategy: INNERMOST ---------------------------------------- (13) TypeInferenceProof (BOTH BOUNDS(ID, ID)) Infered types. ---------------------------------------- (14) Obligation: Innermost TRS: Rules: average(s(x), y) -> average(x, s(y)) average(x, s(s(s(y)))) -> s(average(s(x), y)) average(0', 0') -> 0' average(0', s(0')) -> 0' average(0', s(s(0'))) -> s(0') Types: average :: s:0' -> s:0' -> s:0' s :: s:0' -> s:0' 0' :: s:0' hole_s:0'1_0 :: s:0' gen_s:0'2_0 :: Nat -> s:0' ---------------------------------------- (15) OrderProof (LOWER BOUND(ID)) Heuristically decided to analyse the following defined symbols: average ---------------------------------------- (16) Obligation: Innermost TRS: Rules: average(s(x), y) -> average(x, s(y)) average(x, s(s(s(y)))) -> s(average(s(x), y)) average(0', 0') -> 0' average(0', s(0')) -> 0' average(0', s(s(0'))) -> s(0') Types: average :: s:0' -> s:0' -> s:0' s :: s:0' -> s:0' 0' :: s:0' hole_s:0'1_0 :: s:0' gen_s:0'2_0 :: Nat -> s:0' Generator Equations: gen_s:0'2_0(0) <=> 0' gen_s:0'2_0(+(x, 1)) <=> s(gen_s:0'2_0(x)) The following defined symbols remain to be analysed: average ---------------------------------------- (17) RewriteLemmaProof (LOWER BOUND(ID)) Proved the following rewrite lemma: average(gen_s:0'2_0(+(1, n4_0)), gen_s:0'2_0(b)) -> *3_0, rt in Omega(n4_0) Induction Base: average(gen_s:0'2_0(+(1, 0)), gen_s:0'2_0(b)) Induction Step: average(gen_s:0'2_0(+(1, +(n4_0, 1))), gen_s:0'2_0(b)) ->_R^Omega(1) average(gen_s:0'2_0(+(1, n4_0)), s(gen_s:0'2_0(b))) ->_IH *3_0 We have rt in Omega(n^1) and sz in O(n). Thus, we have irc_R in Omega(n). ---------------------------------------- (18) Obligation: Proved the lower bound n^1 for the following obligation: Innermost TRS: Rules: average(s(x), y) -> average(x, s(y)) average(x, s(s(s(y)))) -> s(average(s(x), y)) average(0', 0') -> 0' average(0', s(0')) -> 0' average(0', s(s(0'))) -> s(0') Types: average :: s:0' -> s:0' -> s:0' s :: s:0' -> s:0' 0' :: s:0' hole_s:0'1_0 :: s:0' gen_s:0'2_0 :: Nat -> s:0' Generator Equations: gen_s:0'2_0(0) <=> 0' gen_s:0'2_0(+(x, 1)) <=> s(gen_s:0'2_0(x)) The following defined symbols remain to be analysed: average ---------------------------------------- (19) LowerBoundPropagationProof (FINISHED) Propagated lower bound. ---------------------------------------- (20) BOUNDS(n^1, INF)