0 CpxTRS
↳1 TrsToWeightedTrsProof (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 (⇔, 648 ms)
↳10 BOUNDS(1, n^1)
le(0, y) → true
le(s(x), 0) → false
le(s(x), s(y)) → le(x, y)
minus(x, 0) → x
minus(0, x) → 0
minus(s(x), s(y)) → minus(x, y)
gcd(0, y) → y
gcd(s(x), 0) → s(x)
gcd(s(x), s(y)) → if_gcd(le(y, x), s(x), s(y))
if_gcd(true, x, y) → gcd(minus(x, y), y)
if_gcd(false, x, y) → gcd(minus(y, x), x)
le(0, y) → true [1]
le(s(x), 0) → false [1]
le(s(x), s(y)) → le(x, y) [1]
minus(x, 0) → x [1]
minus(0, x) → 0 [1]
minus(s(x), s(y)) → minus(x, y) [1]
gcd(0, y) → y [1]
gcd(s(x), 0) → s(x) [1]
gcd(s(x), s(y)) → if_gcd(le(y, x), s(x), s(y)) [1]
if_gcd(true, x, y) → gcd(minus(x, y), y) [1]
if_gcd(false, x, y) → gcd(minus(y, x), x) [1]
le(0, y) → true [1]
le(s(x), 0) → false [1]
le(s(x), s(y)) → le(x, y) [1]
minus(x, 0) → x [1]
minus(0, x) → 0 [1]
minus(s(x), s(y)) → minus(x, y) [1]
gcd(0, y) → y [1]
gcd(s(x), 0) → s(x) [1]
gcd(s(x), s(y)) → if_gcd(le(y, x), s(x), s(y)) [1]
if_gcd(true, x, y) → gcd(minus(x, y), y) [1]
if_gcd(false, x, y) → gcd(minus(y, x), x) [1]
le :: 0:s → 0:s → true:false 0 :: 0:s true :: true:false s :: 0:s → 0:s false :: true:false minus :: 0:s → 0:s → 0:s gcd :: 0:s → 0:s → 0:s if_gcd :: true:false → 0:s → 0:s → 0:s |
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
true => 1
false => 0
gcd(z, z') -{ 1 }→ y :|: y >= 0, z = 0, z' = y
gcd(z, z') -{ 1 }→ if_gcd(le(y, x), 1 + x, 1 + y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gcd(z, z') -{ 1 }→ 1 + x :|: x >= 0, z = 1 + x, z' = 0
if_gcd(z, z', z'') -{ 1 }→ gcd(minus(x, y), y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
if_gcd(z, z', z'') -{ 1 }→ gcd(minus(y, x), x) :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
le(z, z') -{ 1 }→ le(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
le(z, z') -{ 1 }→ 1 :|: y >= 0, z = 0, z' = y
le(z, z') -{ 1 }→ 0 :|: x >= 0, z = 1 + x, z' = 0
minus(z, z') -{ 1 }→ x :|: x >= 0, z = x, z' = 0
minus(z, z') -{ 1 }→ minus(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
minus(z, z') -{ 1 }→ 0 :|: z' = x, x >= 0, z = 0
eq(start(V, V1, V14),0,[le(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V14),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V14),0,[gcd(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V14),0,[fun(V, V1, V14, Out)],[V >= 0,V1 >= 0,V14 >= 0]). eq(le(V, V1, Out),1,[],[Out = 1,V2 >= 0,V = 0,V1 = V2]). eq(le(V, V1, Out),1,[],[Out = 0,V3 >= 0,V = 1 + V3,V1 = 0]). eq(le(V, V1, Out),1,[le(V4, V5, Ret)],[Out = Ret,V1 = 1 + V5,V4 >= 0,V5 >= 0,V = 1 + V4]). eq(minus(V, V1, Out),1,[],[Out = V6,V6 >= 0,V = V6,V1 = 0]). eq(minus(V, V1, Out),1,[],[Out = 0,V1 = V7,V7 >= 0,V = 0]). eq(minus(V, V1, Out),1,[minus(V8, V9, Ret1)],[Out = Ret1,V1 = 1 + V9,V8 >= 0,V9 >= 0,V = 1 + V8]). eq(gcd(V, V1, Out),1,[],[Out = V10,V10 >= 0,V = 0,V1 = V10]). eq(gcd(V, V1, Out),1,[],[Out = 1 + V11,V11 >= 0,V = 1 + V11,V1 = 0]). eq(gcd(V, V1, Out),1,[le(V12, V13, Ret0),fun(Ret0, 1 + V13, 1 + V12, Ret2)],[Out = Ret2,V1 = 1 + V12,V13 >= 0,V12 >= 0,V = 1 + V13]). eq(fun(V, V1, V14, Out),1,[minus(V15, V16, Ret01),gcd(Ret01, V16, Ret3)],[Out = Ret3,V1 = V15,V14 = V16,V = 1,V15 >= 0,V16 >= 0]). eq(fun(V, V1, V14, Out),1,[minus(V17, V18, Ret02),gcd(Ret02, V18, Ret4)],[Out = Ret4,V1 = V18,V14 = V17,V18 >= 0,V17 >= 0,V = 0]). input_output_vars(le(V,V1,Out),[V,V1],[Out]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(gcd(V,V1,Out),[V,V1],[Out]). input_output_vars(fun(V,V1,V14,Out),[V,V1,V14],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [le/3]
1. recursive : [minus/3]
2. recursive : [fun/4,gcd/3]
3. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into le/3
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into gcd/3
3. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations le/3
* CE 16 is refined into CE [17]
* CE 15 is refined into CE [18]
* CE 14 is refined into CE [19]
### Cost equations --> "Loop" of le/3
* CEs [18] --> Loop 13
* CEs [19] --> Loop 14
* CEs [17] --> Loop 15
### Ranking functions of CR le(V,V1,Out)
* RF of phase [15]: [V,V1]
#### Partial ranking functions of CR le(V,V1,Out)
* Partial RF of phase [15]:
- RF of loop [15:1]:
V
V1
### Specialization of cost equations minus/3
* CE 9 is refined into CE [20]
* CE 7 is refined into CE [21]
* CE 8 is refined into CE [22]
### Cost equations --> "Loop" of minus/3
* CEs [21] --> Loop 16
* CEs [22] --> Loop 17
* CEs [20] --> Loop 18
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [18]: [V,V1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [18]:
- RF of loop [18:1]:
V
V1
### Specialization of cost equations gcd/3
* CE 13 is refined into CE [23]
* CE 12 is refined into CE [24]
* CE 11 is refined into CE [25,26,27,28]
* CE 10 is refined into CE [29,30]
### Cost equations --> "Loop" of gcd/3
* CEs [30] --> Loop 19
* CEs [27,28] --> Loop 20
* CEs [29] --> Loop 21
* CEs [25,26] --> Loop 22
* CEs [23] --> Loop 23
* CEs [24] --> Loop 24
### Ranking functions of CR gcd(V,V1,Out)
* RF of phase [19,20]: [V+V1-3]
* RF of phase [22]: [V]
#### Partial ranking functions of CR gcd(V,V1,Out)
* Partial RF of phase [19,20]:
- RF of loop [19:1]:
V/2+V1/2-2
V1-2
- RF of loop [20:1]:
V-1 depends on loops [19:1]
V-V1+1 depends on loops [19:1]
* Partial RF of phase [22]:
- RF of loop [22:1]:
V
### Specialization of cost equations start/3
* CE 3 is refined into CE [31,32,33,34,35,36,37,38,39]
* CE 2 is refined into CE [40,41,42,43,44,45,46,47,48]
* CE 4 is refined into CE [49,50,51,52]
* CE 5 is refined into CE [53,54,55,56]
* CE 6 is refined into CE [57,58,59,60,61,62]
### Cost equations --> "Loop" of start/3
* CEs [61,62] --> Loop 25
* CEs [51,56,60] --> Loop 26
* CEs [36] --> Loop 27
* CEs [34,35] --> Loop 28
* CEs [37,38,39,58] --> Loop 29
* CEs [33,52,55] --> Loop 30
* CEs [31,32] --> Loop 31
* CEs [44] --> Loop 32
* CEs [45] --> Loop 33
* CEs [46] --> Loop 34
* CEs [42,50,54,59] --> Loop 35
* CEs [40,41,43,47,48,49,53,57] --> Loop 36
### Ranking functions of CR start(V,V1,V14)
#### Partial ranking functions of CR start(V,V1,V14)
Computing Bounds
=====================================
#### Cost of chains of le(V,V1,Out):
* Chain [[15],14]: 1*it(15)+1
Such that:it(15) =< V
with precondition: [Out=1,V>=1,V1>=V]
* Chain [[15],13]: 1*it(15)+1
Such that:it(15) =< V1
with precondition: [Out=0,V1>=1,V>=V1+1]
* Chain [14]: 1
with precondition: [V=0,Out=1,V1>=0]
* Chain [13]: 1
with precondition: [V1=0,Out=0,V>=1]
#### Cost of chains of minus(V,V1,Out):
* Chain [[18],17]: 1*it(18)+1
Such that:it(18) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[18],16]: 1*it(18)+1
Such that:it(18) =< V1
with precondition: [V=Out+V1,V1>=1,V>=V1]
* Chain [17]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [16]: 1
with precondition: [V1=0,V=Out,V>=0]
#### Cost of chains of gcd(V,V1,Out):
* Chain [[22],24]: 6*it(22)+1
Such that:it(22) =< V
with precondition: [V1=1,Out=1,V>=1]
* Chain [[19,20],24]: 4*it(19)+4*it(20)+2*s(13)+4*s(15)+1
Such that:aux(9) =< V-V1+1
aux(21) =< V+V1
aux(22) =< V+V1-Out
it(19) =< V/2+V1/2
aux(24) =< V/2+V1/2-Out/2
aux(25) =< V1
aux(26) =< V1-Out
aux(8) =< 2*V1-2*Out
aux(27) =< V
it(19) =< aux(21)
it(20) =< aux(21)
s(14) =< aux(21)
it(19) =< aux(22)
it(20) =< aux(22)
s(14) =< aux(22)
it(19) =< aux(24)
it(20) =< aux(24)
aux(6) =< aux(25)
it(19) =< aux(25)
aux(6) =< aux(26)
it(19) =< aux(26)
it(20) =< aux(8)+aux(9)
it(20) =< aux(6)+aux(27)
s(16) =< aux(6)+aux(27)
s(16) =< it(20)*aux(25)
s(15) =< s(16)
s(13) =< s(14)
with precondition: [Out>=2,V>=Out,V1>=Out]
* Chain [[19,20],21,[22],24]: 4*it(19)+4*it(20)+6*it(22)+2*s(13)+4*s(15)+1*s(17)+5
Such that:s(17) =< 1
aux(9) =< V-V1+1
it(19) =< V/2+V1/2
aux(8) =< 2*V1
aux(28) =< V
aux(29) =< V+V1
aux(30) =< V1
it(22) =< aux(30)
it(19) =< aux(29)
it(20) =< aux(29)
it(19) =< aux(30)
it(20) =< aux(8)+aux(9)
it(20) =< aux(30)+aux(28)
s(16) =< aux(30)+aux(28)
s(16) =< it(20)*aux(30)
s(15) =< s(16)
s(13) =< aux(29)
with precondition: [Out=1,V>=2,V1>=2,V+V1>=5]
* Chain [24]: 1
with precondition: [V=0,V1=Out,V1>=0]
* Chain [23]: 1
with precondition: [V1=0,V=Out,V>=1]
* Chain [21,[22],24]: 6*it(22)+1*s(17)+5
Such that:s(17) =< 1
it(22) =< V1
with precondition: [V=1,Out=1,V1>=2]
#### Cost of chains of start(V,V1,V14):
* Chain [36]: 5*s(18)+8*s(19)+1*s(20)+8*s(22)+4*s(28)+4*s(30)+4*s(42)+4*s(46)+7
Such that:s(20) =< 1
aux(35) =< -2*V1+V14+1
aux(36) =< -V1+V14
aux(37) =< V1
aux(38) =< 2*V1
aux(39) =< V14
aux(40) =< V14/2
s(18) =< aux(39)
s(22) =< aux(40)
s(19) =< aux(37)
s(22) =< aux(39)
s(28) =< aux(39)
s(22) =< aux(37)
s(28) =< aux(38)+aux(35)
s(28) =< aux(37)+aux(36)
s(29) =< aux(37)+aux(36)
s(29) =< s(28)*aux(37)
s(30) =< s(29)
s(42) =< aux(39)
s(42) =< aux(40)
s(42) =< aux(38)+aux(35)
s(42) =< aux(37)+aux(36)
s(45) =< aux(37)+aux(36)
s(45) =< s(42)*aux(37)
s(46) =< s(45)
with precondition: [V=0,V1>=0]
* Chain [35]: 3
with precondition: [V1=0,V>=0]
* Chain [34]: 1*s(48)+6*s(49)+3
Such that:s(48) =< 1
s(49) =< V14
with precondition: [V=0,V1=1,V14>=2]
* Chain [33]: 7*s(50)+1*s(51)+7
Such that:s(51) =< 1
aux(41) =< V1
s(50) =< aux(41)
with precondition: [V=0,V1+1=V14,V1>=2]
* Chain [32]: 1*s(53)+3
Such that:s(53) =< V14
with precondition: [V=0,V1=V14,V1>=1]
* Chain [31]: 3
with precondition: [V=1,V1=0,V14>=0]
* Chain [30]: 2*s(54)+3
Such that:aux(42) =< V
s(54) =< aux(42)
with precondition: [V>=1,V1>=V]
* Chain [29]: 3*s(56)+16*s(57)+8*s(58)+8*s(61)+4*s(67)+4*s(69)+4*s(81)+4*s(85)+7
Such that:aux(47) =< 1
aux(48) =< V1
aux(49) =< V1-2*V14+1
aux(50) =< V1-V14
aux(51) =< V1/2
aux(52) =< V14
aux(53) =< 2*V14
s(56) =< aux(47)
s(57) =< aux(48)
s(61) =< aux(51)
s(58) =< aux(52)
s(61) =< aux(48)
s(67) =< aux(48)
s(61) =< aux(52)
s(67) =< aux(53)+aux(49)
s(67) =< aux(52)+aux(50)
s(68) =< aux(52)+aux(50)
s(68) =< s(67)*aux(52)
s(69) =< s(68)
s(81) =< aux(48)
s(81) =< aux(51)
s(81) =< aux(53)+aux(49)
s(81) =< aux(52)+aux(50)
s(84) =< aux(52)+aux(50)
s(84) =< s(81)*aux(52)
s(85) =< s(84)
with precondition: [V=1,V1>=2]
* Chain [28]: 1*s(89)+1*s(90)+3
Such that:s(89) =< V1
s(90) =< V14
with precondition: [V=1,V1>=1,V14>=V1]
* Chain [27]: 7*s(91)+1*s(92)+7
Such that:s(92) =< 1
aux(54) =< V1
s(91) =< aux(54)
with precondition: [V=1,V1=V14+1,V1>=3]
* Chain [26]: 2*s(94)+6*s(96)+1
Such that:s(96) =< V
aux(55) =< V1
s(94) =< aux(55)
with precondition: [V1>=1,V>=V1]
* Chain [25]: 1*s(97)+8*s(99)+6*s(104)+4*s(105)+4*s(107)+4*s(108)+4*s(118)+4*s(122)+5
Such that:s(97) =< 1
aux(59) =< V
aux(60) =< V-V1+1
aux(61) =< V+V1
aux(62) =< V/2+V1/2
aux(63) =< V1
aux(64) =< 2*V1
s(99) =< aux(62)
s(104) =< aux(63)
s(99) =< aux(61)
s(105) =< aux(61)
s(99) =< aux(63)
s(105) =< aux(64)+aux(60)
s(105) =< aux(63)+aux(59)
s(106) =< aux(63)+aux(59)
s(106) =< s(105)*aux(63)
s(107) =< s(106)
s(108) =< aux(61)
s(118) =< aux(61)
s(118) =< aux(62)
s(118) =< aux(64)+aux(60)
s(118) =< aux(63)+aux(59)
s(121) =< aux(63)+aux(59)
s(121) =< s(118)*aux(63)
s(122) =< s(121)
with precondition: [V>=2,V1>=2]
Closed-form bounds of start(V,V1,V14):
-------------------------------------
* Chain [36] with precondition: [V=0,V1>=0]
- Upper bound: 16*V1+8+nat(V14)*13+nat(-V1+V14)*8+nat(V14/2)*8
- Complexity: n
* Chain [35] with precondition: [V1=0,V>=0]
- Upper bound: 3
- Complexity: constant
* Chain [34] with precondition: [V=0,V1=1,V14>=2]
- Upper bound: 6*V14+4
- Complexity: n
* Chain [33] with precondition: [V=0,V1+1=V14,V1>=2]
- Upper bound: 7*V1+8
- Complexity: n
* Chain [32] with precondition: [V=0,V1=V14,V1>=1]
- Upper bound: V14+3
- Complexity: n
* Chain [31] with precondition: [V=1,V1=0,V14>=0]
- Upper bound: 3
- Complexity: constant
* Chain [30] with precondition: [V>=1,V1>=V]
- Upper bound: 2*V+3
- Complexity: n
* Chain [29] with precondition: [V=1,V1>=2]
- Upper bound: 24*V1+10+nat(V14)*16+nat(V1-V14)*8+4*V1
- Complexity: n
* Chain [28] with precondition: [V=1,V1>=1,V14>=V1]
- Upper bound: V1+V14+3
- Complexity: n
* Chain [27] with precondition: [V=1,V1=V14+1,V1>=3]
- Upper bound: 7*V1+8
- Complexity: n
* Chain [26] with precondition: [V1>=1,V>=V1]
- Upper bound: 6*V+2*V1+1
- Complexity: n
* Chain [25] with precondition: [V>=2,V1>=2]
- Upper bound: 24*V+30*V1+6
- Complexity: n
### Maximum cost of start(V,V1,V14): max([max([2*V,nat(V14)*5+1+nat(V14)])+2,max([max([6*V,5*V1+5+max([2,7*V1+max([24*V+16*V1,2*V1+2+nat(V14)*13+max([nat(V14/2)*8+nat(-V1+V14)*8,8*V1+2+nat(V14)*3+nat(V1-V14)*8+4*V1])])])])+V1,nat(V14)+2])+V1])+1
Asymptotic class: n
* Total analysis performed in 553 ms.