WORST_CASE(?,O(n^1)) proof of input_YEkyqaiegG.trs # AProVE Commit ID: 5b976082cb74a395683ed8cc7acf94bd611ab29f fuhs 20230524 unpublished The Runtime Complexity (parallel-innermost) of the given CpxTRS could be proven to be BOUNDS(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), 0 ms] (8) CpxRNTS (9) CompleteCoflocoProof [FINISHED, 257 ms] (10) BOUNDS(1, n^1) ---------------------------------------- (0) Obligation: The Runtime Complexity (parallel-innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1). The TRS R consists of the following rules: or(true, y) -> true or(x, true) -> true or(false, false) -> false mem(x, nil) -> false mem(x, set(y)) -> =(x, y) mem(x, union(y, z)) -> or(mem(x, y), mem(x, z)) 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: or(true, y) -> true [1] or(x, true) -> true [1] or(false, false) -> false [1] mem(x, nil) -> false [1] mem(x, set(y)) -> =(x, y) [1] mem(x, union(y, z)) -> or(mem(x, y), mem(x, z)) [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: or(true, y) -> true [1] or(x, true) -> true [1] or(false, false) -> false [1] mem(x, nil) -> false [1] mem(x, set(y)) -> =(x, y) [1] mem(x, union(y, z)) -> or(mem(x, y), mem(x, z)) [1] The TRS has the following type information: or :: true:false:= -> true:false:= -> true:false:= true :: true:false:= false :: true:false:= mem :: a -> nil:set:union -> true:false:= nil :: nil:set:union set :: b -> nil:set:union = :: a -> b -> true:false:= union :: nil:set:union -> nil:set:union -> nil:set:union 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: or(v0, v1) -> null_or [0] And the following fresh constants: null_or, const, const1 ---------------------------------------- (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: or(true, y) -> true [1] or(x, true) -> true [1] or(false, false) -> false [1] mem(x, nil) -> false [1] mem(x, set(y)) -> =(x, y) [1] mem(x, union(y, z)) -> or(mem(x, y), mem(x, z)) [1] or(v0, v1) -> null_or [0] The TRS has the following type information: or :: true:false:=:null_or -> true:false:=:null_or -> true:false:=:null_or true :: true:false:=:null_or false :: true:false:=:null_or mem :: a -> nil:set:union -> true:false:=:null_or nil :: nil:set:union set :: b -> nil:set:union = :: a -> b -> true:false:=:null_or union :: nil:set:union -> nil:set:union -> nil:set:union null_or :: true:false:=:null_or const :: a const1 :: b 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: true => 1 false => 0 nil => 0 null_or => 0 const => 0 const1 => 0 ---------------------------------------- (8) Obligation: Complexity RNTS consisting of the following rules: mem(z', z'') -{ 1 }-> or(mem(x, y), mem(x, z)) :|: z >= 0, z' = x, x >= 0, y >= 0, z'' = 1 + y + z mem(z', z'') -{ 1 }-> 0 :|: z'' = 0, z' = x, x >= 0 mem(z', z'') -{ 1 }-> 1 + x + y :|: z' = x, x >= 0, y >= 0, z'' = 1 + y or(z', z'') -{ 1 }-> 1 :|: z'' = y, y >= 0, z' = 1 or(z', z'') -{ 1 }-> 1 :|: z' = x, x >= 0, z'' = 1 or(z', z'') -{ 1 }-> 0 :|: z'' = 0, z' = 0 or(z', z'') -{ 0 }-> 0 :|: v0 >= 0, v1 >= 0, z'' = v1, z' = v0 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, V1),0,[or(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[mem(V, V1, Out)],[V >= 0,V1 >= 0]). eq(or(V, V1, Out),1,[],[Out = 1,V1 = V2,V2 >= 0,V = 1]). eq(or(V, V1, Out),1,[],[Out = 1,V = V3,V3 >= 0,V1 = 1]). eq(or(V, V1, Out),1,[],[Out = 0,V1 = 0,V = 0]). eq(mem(V, V1, Out),1,[],[Out = 0,V1 = 0,V = V4,V4 >= 0]). eq(mem(V, V1, Out),1,[],[Out = 1 + V5 + V6,V = V5,V5 >= 0,V6 >= 0,V1 = 1 + V6]). eq(mem(V, V1, Out),1,[mem(V7, V8, Ret0),mem(V7, V9, Ret1),or(Ret0, Ret1, Ret)],[Out = Ret,V9 >= 0,V = V7,V7 >= 0,V8 >= 0,V1 = 1 + V8 + V9]). eq(or(V, V1, Out),0,[],[Out = 0,V11 >= 0,V10 >= 0,V1 = V10,V = V11]). input_output_vars(or(V,V1,Out),[V,V1],[Out]). input_output_vars(mem(V,V1,Out),[V,V1],[Out]). CoFloCo proof output: Preprocessing Cost Relations ===================================== #### Computed strongly connected components 0. non_recursive : [or/3] 1. recursive [non_tail,multiple] : [mem/3] 2. non_recursive : [start/2] #### Obtained direct recursion through partial evaluation 0. SCC is partially evaluated into or/3 1. SCC is partially evaluated into mem/3 2. SCC is partially evaluated into start/2 Control-Flow Refinement of Cost Relations ===================================== ### Specialization of cost equations or/3 * CE 4 is refined into CE [10] * CE 3 is refined into CE [11] * CE 5 is refined into CE [12] * CE 6 is refined into CE [13] ### Cost equations --> "Loop" of or/3 * CEs [10] --> Loop 8 * CEs [11] --> Loop 9 * CEs [12,13] --> Loop 10 ### Ranking functions of CR or(V,V1,Out) #### Partial ranking functions of CR or(V,V1,Out) ### Specialization of cost equations mem/3 * CE 9 is refined into CE [14,15,16] * CE 8 is refined into CE [17] * CE 7 is refined into CE [18] ### Cost equations --> "Loop" of mem/3 * CEs [17] --> Loop 11 * CEs [18] --> Loop 12 * CEs [15] --> Loop 13 * CEs [14] --> Loop 14 * CEs [16] --> Loop 15 ### Ranking functions of CR mem(V,V1,Out) * RF of phase [13,14,15]: [V1] #### Partial ranking functions of CR mem(V,V1,Out) * Partial RF of phase [13,14,15]: - RF of loop [13:1,13:2,14:1,14:2,15:1,15:2]: V1 ### Specialization of cost equations start/2 * CE 1 is refined into CE [19,20,21] * CE 2 is refined into CE [22,23,24] ### Cost equations --> "Loop" of start/2 * CEs [20] --> Loop 16 * CEs [22] --> Loop 17 * CEs [19,21,23,24] --> Loop 18 ### Ranking functions of CR start(V,V1) #### Partial ranking functions of CR start(V,V1) Computing Bounds ===================================== #### Cost of chains of or(V,V1,Out): * Chain [10]: 1 with precondition: [Out=0,V>=0,V1>=0] * Chain [9]: 1 with precondition: [V=1,Out=1,V1>=0] * Chain [8]: 1 with precondition: [V1=1,Out=1,V>=0] #### Cost of chains of mem(V,V1,Out): * Chain [12]: 1 with precondition: [V1=0,Out=0,V>=0] * Chain [11]: 1 with precondition: [V+V1=Out,V>=0,V1>=1] * Chain [multiple([13,14,15],[[12],[11]])]: 6*it(13)+1*it([11])+1*it([12])+0 Such that:it([12]) =< V1+1 it([11]) =< V1/2+1/2 aux(1) =< V1 it(13) =< aux(1) it([11]) =< aux(1) with precondition: [1>=Out,V>=0,V1>=1,Out>=0,V+V1>=Out+1] #### Cost of chains of start(V,V1): * Chain [18]: 1*s(1)+1*s(2)+6*s(4)+1 Such that:s(3) =< V1 s(1) =< V1+1 s(2) =< V1/2+1/2 s(4) =< s(3) s(2) =< s(3) with precondition: [V>=0,V1>=0] * Chain [17]: 1 with precondition: [V1=0,V>=0] * Chain [16]: 1 with precondition: [V1=1,V>=0] Closed-form bounds of start(V,V1): ------------------------------------- * Chain [18] with precondition: [V>=0,V1>=0] - Upper bound: 15/2*V1+5/2 - Complexity: n * Chain [17] with precondition: [V1=0,V>=0] - Upper bound: 1 - Complexity: constant * Chain [16] with precondition: [V1=1,V>=0] - Upper bound: 1 - Complexity: constant ### Maximum cost of start(V,V1): 15/2*V1+5/2 Asymptotic class: n * Total analysis performed in 171 ms. ---------------------------------------- (10) BOUNDS(1, n^1)