WORST_CASE(Omega(n^1),O(n^1)) proof of input_IlMNWXNrCt.trs # AProVE Commit ID: aff8ecad908e01718a4c36e68d2e55d5e0f16e15 fuhs 20220216 unpublished The Runtime Complexity (parallel-innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). (0) CpxTRS (1) RelTrsToWeightedTrsProof [UPPER BOUND(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), 5 ms] (8) CpxRNTS (9) CompleteCoflocoProof [FINISHED, 158 ms] (10) BOUNDS(1, n^1) (11) CpxTrsToCdtProof [BOTH BOUNDS(ID, ID), 0 ms] (12) CdtProblem (13) CdtToCpxRelTrsProof [BOTH BOUNDS(ID, ID), 0 ms] (14) CpxRelTRS (15) RenamingProof [BOTH BOUNDS(ID, ID), 0 ms] (16) CpxRelTRS (17) TypeInferenceProof [BOTH BOUNDS(ID, ID), 0 ms] (18) typed CpxTrs (19) OrderProof [LOWER BOUND(ID), 0 ms] (20) typed CpxTrs (21) RewriteLemmaProof [LOWER BOUND(ID), 341 ms] (22) BEST (23) proven lower bound (24) LowerBoundPropagationProof [FINISHED, 0 ms] (25) BOUNDS(n^1, INF) (26) typed CpxTrs (27) RewriteLemmaProof [LOWER BOUND(ID), 91 ms] (28) typed CpxTrs ---------------------------------------- (0) Obligation: The Runtime Complexity (parallel-innermost) of the given CpxTRS could be proven to be BOUNDS(n^1, n^1). The TRS R consists of the following rules: half(0) -> 0 half(s(0)) -> 0 half(s(s(x))) -> s(half(x)) bits(0) -> 0 bits(s(x)) -> s(bits(half(s(x)))) S is empty. Rewrite Strategy: PARALLEL_INNERMOST ---------------------------------------- (1) RelTrsToWeightedTrsProof (UPPER BOUND(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: half(0) -> 0 [1] half(s(0)) -> 0 [1] half(s(s(x))) -> s(half(x)) [1] bits(0) -> 0 [1] bits(s(x)) -> s(bits(half(s(x)))) [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: half(0) -> 0 [1] half(s(0)) -> 0 [1] half(s(s(x))) -> s(half(x)) [1] bits(0) -> 0 [1] bits(s(x)) -> s(bits(half(s(x)))) [1] The TRS has the following type information: half :: 0:s -> 0:s 0 :: 0:s s :: 0:s -> 0:s bits :: 0:s -> 0:s 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: half(0) -> 0 [1] half(s(0)) -> 0 [1] half(s(s(x))) -> s(half(x)) [1] bits(0) -> 0 [1] bits(s(x)) -> s(bits(half(s(x)))) [1] The TRS has the following type information: half :: 0:s -> 0:s 0 :: 0:s s :: 0:s -> 0:s bits :: 0:s -> 0:s 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: bits(z) -{ 1 }-> 0 :|: z = 0 bits(z) -{ 1 }-> 1 + bits(half(1 + x)) :|: x >= 0, z = 1 + x half(z) -{ 1 }-> 0 :|: z = 0 half(z) -{ 1 }-> 0 :|: z = 1 + 0 half(z) -{ 1 }-> 1 + half(x) :|: x >= 0, z = 1 + (1 + x) 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(V),0,[half(V, Out)],[V >= 0]). eq(start(V),0,[bits(V, Out)],[V >= 0]). eq(half(V, Out),1,[],[Out = 0,V = 0]). eq(half(V, Out),1,[],[Out = 0,V = 1]). eq(half(V, Out),1,[half(V1, Ret1)],[Out = 1 + Ret1,V1 >= 0,V = 2 + V1]). eq(bits(V, Out),1,[],[Out = 0,V = 0]). eq(bits(V, Out),1,[half(1 + V2, Ret10),bits(Ret10, Ret11)],[Out = 1 + Ret11,V2 >= 0,V = 1 + V2]). input_output_vars(half(V,Out),[V],[Out]). input_output_vars(bits(V,Out),[V],[Out]). CoFloCo proof output: Preprocessing Cost Relations ===================================== #### Computed strongly connected components 0. recursive : [half/2] 1. recursive : [bits/2] 2. non_recursive : [start/1] #### Obtained direct recursion through partial evaluation 0. SCC is partially evaluated into half/2 1. SCC is partially evaluated into bits/2 2. SCC is partially evaluated into start/1 Control-Flow Refinement of Cost Relations ===================================== ### Specialization of cost equations half/2 * CE 5 is refined into CE [8] * CE 4 is refined into CE [9] * CE 3 is refined into CE [10] ### Cost equations --> "Loop" of half/2 * CEs [9] --> Loop 7 * CEs [10] --> Loop 8 * CEs [8] --> Loop 9 ### Ranking functions of CR half(V,Out) * RF of phase [9]: [V-1] #### Partial ranking functions of CR half(V,Out) * Partial RF of phase [9]: - RF of loop [9:1]: V-1 ### Specialization of cost equations bits/2 * CE 7 is refined into CE [11,12,13] * CE 6 is refined into CE [14] ### Cost equations --> "Loop" of bits/2 * CEs [14] --> Loop 10 * CEs [13] --> Loop 11 * CEs [12] --> Loop 12 * CEs [11] --> Loop 13 ### Ranking functions of CR bits(V,Out) * RF of phase [11,12]: [V-1] #### Partial ranking functions of CR bits(V,Out) * Partial RF of phase [11,12]: - RF of loop [11:1]: V/2-1 - RF of loop [12:1]: V-1 ### Specialization of cost equations start/1 * CE 1 is refined into CE [15,16,17,18] * CE 2 is refined into CE [19,20,21] ### Cost equations --> "Loop" of start/1 * CEs [17,18,21] --> Loop 14 * CEs [16,20] --> Loop 15 * CEs [15,19] --> Loop 16 ### Ranking functions of CR start(V) #### Partial ranking functions of CR start(V) Computing Bounds ===================================== #### Cost of chains of half(V,Out): * Chain [[9],8]: 1*it(9)+1 Such that:it(9) =< 2*Out with precondition: [V=2*Out,V>=2] * Chain [[9],7]: 1*it(9)+1 Such that:it(9) =< 2*Out with precondition: [V=2*Out+1,V>=3] * Chain [8]: 1 with precondition: [V=0,Out=0] * Chain [7]: 1 with precondition: [V=1,Out=0] #### Cost of chains of bits(V,Out): * Chain [[11,12],13,10]: 2*it(11)+2*it(12)+2*s(5)+3 Such that:it(11) =< V/2 aux(5) =< V aux(6) =< 2*V it(11) =< aux(5) it(12) =< aux(5) it(12) =< aux(6) s(5) =< aux(6) with precondition: [Out>=2,V+2>=2*Out] * Chain [13,10]: 3 with precondition: [V=1,Out=1] * Chain [10]: 1 with precondition: [V=0,Out=0] #### Cost of chains of start(V): * Chain [16]: 1 with precondition: [V=0] * Chain [15]: 3 with precondition: [V=1] * Chain [14]: 2*s(7)+2*s(9)+2*s(12)+2*s(13)+3 Such that:s(11) =< 2*V s(9) =< V/2 aux(7) =< V s(7) =< aux(7) s(9) =< aux(7) s(12) =< aux(7) s(12) =< s(11) s(13) =< s(11) with precondition: [V>=2] Closed-form bounds of start(V): ------------------------------------- * Chain [16] with precondition: [V=0] - Upper bound: 1 - Complexity: constant * Chain [15] with precondition: [V=1] - Upper bound: 3 - Complexity: constant * Chain [14] with precondition: [V>=2] - Upper bound: 9*V+3 - Complexity: n ### Maximum cost of start(V): 9*V+3 Asymptotic class: n * Total analysis performed in 105 ms. ---------------------------------------- (10) BOUNDS(1, n^1) ---------------------------------------- (11) CpxTrsToCdtProof (BOTH BOUNDS(ID, ID)) Converted Cpx (relative) TRS with rewrite strategy PARALLEL_INNERMOST to CDT ---------------------------------------- (12) Obligation: Complexity Dependency Tuples Problem Rules: half(0) -> 0 half(s(0)) -> 0 half(s(s(z0))) -> s(half(z0)) bits(0) -> 0 bits(s(z0)) -> s(bits(half(s(z0)))) Tuples: HALF(0) -> c HALF(s(0)) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0) -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) S tuples: HALF(0) -> c HALF(s(0)) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0) -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) K tuples:none Defined Rule Symbols: half_1, bits_1 Defined Pair Symbols: HALF_1, BITS_1 Compound Symbols: c, c1, c2_1, c3, c4_2 ---------------------------------------- (13) CdtToCpxRelTrsProof (BOTH BOUNDS(ID, ID)) Converted S to standard rules, and D \ S as well as R to relative rules. ---------------------------------------- (14) Obligation: The Runtime Complexity (innermost) of the given CpxRelTRS could be proven to be BOUNDS(n^1, INF). The TRS R consists of the following rules: HALF(0) -> c HALF(s(0)) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0) -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) The (relative) TRS S consists of the following rules: half(0) -> 0 half(s(0)) -> 0 half(s(s(z0))) -> s(half(z0)) bits(0) -> 0 bits(s(z0)) -> s(bits(half(s(z0)))) Rewrite Strategy: INNERMOST ---------------------------------------- (15) RenamingProof (BOTH BOUNDS(ID, ID)) Renamed function symbols to avoid clashes with predefined symbol. ---------------------------------------- (16) Obligation: The Runtime Complexity (innermost) of the given CpxRelTRS could be proven to be BOUNDS(n^1, INF). The TRS R consists of the following rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) The (relative) TRS S consists of the following rules: half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Rewrite Strategy: INNERMOST ---------------------------------------- (17) TypeInferenceProof (BOTH BOUNDS(ID, ID)) Inferred types. ---------------------------------------- (18) Obligation: Innermost TRS: Rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Types: HALF :: 0':s -> c:c1:c2 0' :: 0':s c :: c:c1:c2 s :: 0':s -> 0':s c1 :: c:c1:c2 c2 :: c:c1:c2 -> c:c1:c2 BITS :: 0':s -> c3:c4 c3 :: c3:c4 c4 :: c3:c4 -> c:c1:c2 -> c3:c4 half :: 0':s -> 0':s bits :: 0':s -> 0':s hole_c:c1:c21_5 :: c:c1:c2 hole_0':s2_5 :: 0':s hole_c3:c43_5 :: c3:c4 gen_c:c1:c24_5 :: Nat -> c:c1:c2 gen_0':s5_5 :: Nat -> 0':s gen_c3:c46_5 :: Nat -> c3:c4 ---------------------------------------- (19) OrderProof (LOWER BOUND(ID)) Heuristically decided to analyse the following defined symbols: HALF, BITS, half, bits They will be analysed ascendingly in the following order: HALF < BITS half < BITS half < bits ---------------------------------------- (20) Obligation: Innermost TRS: Rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Types: HALF :: 0':s -> c:c1:c2 0' :: 0':s c :: c:c1:c2 s :: 0':s -> 0':s c1 :: c:c1:c2 c2 :: c:c1:c2 -> c:c1:c2 BITS :: 0':s -> c3:c4 c3 :: c3:c4 c4 :: c3:c4 -> c:c1:c2 -> c3:c4 half :: 0':s -> 0':s bits :: 0':s -> 0':s hole_c:c1:c21_5 :: c:c1:c2 hole_0':s2_5 :: 0':s hole_c3:c43_5 :: c3:c4 gen_c:c1:c24_5 :: Nat -> c:c1:c2 gen_0':s5_5 :: Nat -> 0':s gen_c3:c46_5 :: Nat -> c3:c4 Generator Equations: gen_c:c1:c24_5(0) <=> c gen_c:c1:c24_5(+(x, 1)) <=> c2(gen_c:c1:c24_5(x)) gen_0':s5_5(0) <=> 0' gen_0':s5_5(+(x, 1)) <=> s(gen_0':s5_5(x)) gen_c3:c46_5(0) <=> c3 gen_c3:c46_5(+(x, 1)) <=> c4(gen_c3:c46_5(x), c) The following defined symbols remain to be analysed: HALF, BITS, half, bits They will be analysed ascendingly in the following order: HALF < BITS half < BITS half < bits ---------------------------------------- (21) RewriteLemmaProof (LOWER BOUND(ID)) Proved the following rewrite lemma: HALF(gen_0':s5_5(*(2, n8_5))) -> gen_c:c1:c24_5(n8_5), rt in Omega(1 + n8_5) Induction Base: HALF(gen_0':s5_5(*(2, 0))) ->_R^Omega(1) c Induction Step: HALF(gen_0':s5_5(*(2, +(n8_5, 1)))) ->_R^Omega(1) c2(HALF(gen_0':s5_5(*(2, n8_5)))) ->_IH c2(gen_c:c1:c24_5(c9_5)) We have rt in Omega(n^1) and sz in O(n). Thus, we have irc_R in Omega(n). ---------------------------------------- (22) Complex Obligation (BEST) ---------------------------------------- (23) Obligation: Proved the lower bound n^1 for the following obligation: Innermost TRS: Rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Types: HALF :: 0':s -> c:c1:c2 0' :: 0':s c :: c:c1:c2 s :: 0':s -> 0':s c1 :: c:c1:c2 c2 :: c:c1:c2 -> c:c1:c2 BITS :: 0':s -> c3:c4 c3 :: c3:c4 c4 :: c3:c4 -> c:c1:c2 -> c3:c4 half :: 0':s -> 0':s bits :: 0':s -> 0':s hole_c:c1:c21_5 :: c:c1:c2 hole_0':s2_5 :: 0':s hole_c3:c43_5 :: c3:c4 gen_c:c1:c24_5 :: Nat -> c:c1:c2 gen_0':s5_5 :: Nat -> 0':s gen_c3:c46_5 :: Nat -> c3:c4 Generator Equations: gen_c:c1:c24_5(0) <=> c gen_c:c1:c24_5(+(x, 1)) <=> c2(gen_c:c1:c24_5(x)) gen_0':s5_5(0) <=> 0' gen_0':s5_5(+(x, 1)) <=> s(gen_0':s5_5(x)) gen_c3:c46_5(0) <=> c3 gen_c3:c46_5(+(x, 1)) <=> c4(gen_c3:c46_5(x), c) The following defined symbols remain to be analysed: HALF, BITS, half, bits They will be analysed ascendingly in the following order: HALF < BITS half < BITS half < bits ---------------------------------------- (24) LowerBoundPropagationProof (FINISHED) Propagated lower bound. ---------------------------------------- (25) BOUNDS(n^1, INF) ---------------------------------------- (26) Obligation: Innermost TRS: Rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Types: HALF :: 0':s -> c:c1:c2 0' :: 0':s c :: c:c1:c2 s :: 0':s -> 0':s c1 :: c:c1:c2 c2 :: c:c1:c2 -> c:c1:c2 BITS :: 0':s -> c3:c4 c3 :: c3:c4 c4 :: c3:c4 -> c:c1:c2 -> c3:c4 half :: 0':s -> 0':s bits :: 0':s -> 0':s hole_c:c1:c21_5 :: c:c1:c2 hole_0':s2_5 :: 0':s hole_c3:c43_5 :: c3:c4 gen_c:c1:c24_5 :: Nat -> c:c1:c2 gen_0':s5_5 :: Nat -> 0':s gen_c3:c46_5 :: Nat -> c3:c4 Lemmas: HALF(gen_0':s5_5(*(2, n8_5))) -> gen_c:c1:c24_5(n8_5), rt in Omega(1 + n8_5) Generator Equations: gen_c:c1:c24_5(0) <=> c gen_c:c1:c24_5(+(x, 1)) <=> c2(gen_c:c1:c24_5(x)) gen_0':s5_5(0) <=> 0' gen_0':s5_5(+(x, 1)) <=> s(gen_0':s5_5(x)) gen_c3:c46_5(0) <=> c3 gen_c3:c46_5(+(x, 1)) <=> c4(gen_c3:c46_5(x), c) The following defined symbols remain to be analysed: half, BITS, bits They will be analysed ascendingly in the following order: half < BITS half < bits ---------------------------------------- (27) RewriteLemmaProof (LOWER BOUND(ID)) Proved the following rewrite lemma: half(gen_0':s5_5(*(2, n379_5))) -> gen_0':s5_5(n379_5), rt in Omega(0) Induction Base: half(gen_0':s5_5(*(2, 0))) ->_R^Omega(0) 0' Induction Step: half(gen_0':s5_5(*(2, +(n379_5, 1)))) ->_R^Omega(0) s(half(gen_0':s5_5(*(2, n379_5)))) ->_IH s(gen_0':s5_5(c380_5)) We have rt in Omega(1) and sz in O(n). Thus, we have irc_R in Omega(n^0). ---------------------------------------- (28) Obligation: Innermost TRS: Rules: HALF(0') -> c HALF(s(0')) -> c1 HALF(s(s(z0))) -> c2(HALF(z0)) BITS(0') -> c3 BITS(s(z0)) -> c4(BITS(half(s(z0))), HALF(s(z0))) half(0') -> 0' half(s(0')) -> 0' half(s(s(z0))) -> s(half(z0)) bits(0') -> 0' bits(s(z0)) -> s(bits(half(s(z0)))) Types: HALF :: 0':s -> c:c1:c2 0' :: 0':s c :: c:c1:c2 s :: 0':s -> 0':s c1 :: c:c1:c2 c2 :: c:c1:c2 -> c:c1:c2 BITS :: 0':s -> c3:c4 c3 :: c3:c4 c4 :: c3:c4 -> c:c1:c2 -> c3:c4 half :: 0':s -> 0':s bits :: 0':s -> 0':s hole_c:c1:c21_5 :: c:c1:c2 hole_0':s2_5 :: 0':s hole_c3:c43_5 :: c3:c4 gen_c:c1:c24_5 :: Nat -> c:c1:c2 gen_0':s5_5 :: Nat -> 0':s gen_c3:c46_5 :: Nat -> c3:c4 Lemmas: HALF(gen_0':s5_5(*(2, n8_5))) -> gen_c:c1:c24_5(n8_5), rt in Omega(1 + n8_5) half(gen_0':s5_5(*(2, n379_5))) -> gen_0':s5_5(n379_5), rt in Omega(0) Generator Equations: gen_c:c1:c24_5(0) <=> c gen_c:c1:c24_5(+(x, 1)) <=> c2(gen_c:c1:c24_5(x)) gen_0':s5_5(0) <=> 0' gen_0':s5_5(+(x, 1)) <=> s(gen_0':s5_5(x)) gen_c3:c46_5(0) <=> c3 gen_c3:c46_5(+(x, 1)) <=> c4(gen_c3:c46_5(x), c) The following defined symbols remain to be analysed: BITS, bits