SlideShare a Scribd company logo
1 of 67
Download to read offline
A Transformational Approach to Resource Analysis
with Typed-Norms
Elvira Albert1, Samir Genaim1, and Ra´ul Guti´errez2,3
1Universidad Complutense de Madrid
2Universidad Polit´ecnica de Madrid
3Universitat Polit`ecnica de Val`encia
Universidad Complutense de Madrid
June 14, 2016
Madrid, Spain
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 1 / 25
Motivation
Automated resource analysis needs to infer how the sizes of data are
modified along program’s execution.
Norms define how the size of term are computed (list-length,
tree-depth, term-size, . . . ).
Type-norms allow defining norms based on type information.
The choice of the right norm is crucial to obtain a proof for
termination and get accurate upper and lower bounds.
Allowing multiple norms simultaneously give us more chances to
success, but the efficiency of the analysis can be degraded
considerably.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 2 / 25
Main Contribution
1 We propose a transformational approach to use multiple type-norms
in resource analysis:
1 transform the program into an intermediate abstract program in which
the relation among data and control flow are preserved,
2 from such intermediate abstract program, together with a the size
relations, we obtain a cost relation system, in which each variable is
abstracted with respect to all considered norms valid for its type,
3 if a solution if obtained from the cost relation system constraints (using
a constraint solver), then the solution is transformed into upper and
lower resource bounds automatically.
2 we outline an algorithm for the inference of typed-norms which can
detect which norms are useful to later infer the resource consumption,
and discard norms that are useless for this purpose.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 3 / 25
Outline
1 Leading Example
2 Size Abstraction using Typed-Norms
3 Inference of Typed-Norms
4 Experiments
5 Conclusions
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 4 / 25
Example: A Simple Functional Language
1 def Int fibonacci(Int n)
2 = case (n <= 0) {
3 true => case n {
4 0 => 0 ;
5 1 => 1 ;
6 m => fibonacci(m − 1) + fibonacci(m − 2) ;
7 } ;
8 false => −1 ;
9 };
10
11 def List<Int> fibonacci list(List<Int> l)
12 = case l {
13 Nil => Nil ;
14 Cons(n,rest l) => Cons(fibonacci(n),fibonacci list(rest l)) ;
15 };
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 5 / 25
Intermediate Form: An Abstract Syntax
r ::= m(¯x, y) → g, b1, . . . , bn.
b ::= x:=t | m(¯x, y)
g ::= true | g ∧ g | e op e | match(x, t) | nonmatch(x, t)
t ::= e | Co(¯t)
e ::= x | n | e+e | e−e
where op ∈ {>, =, ≥}, m(¯x, ¯y) is the head of the rule, g specifies the
conditions for the rule to be applicable and b1, . . . , bn is the rule’s body.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 6 / 25
Example: Intermediate Representation
fibonacci list(xs,ys)
→ case0(xs,ys).
case0(xs,ys)
→ match(xs,Nil),
ys := Nil.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs)),
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws).
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 7 / 25
Outline
1 Leading Example
2 Size Abstraction using Typed-Norms
3 Inference of Typed-Norms
4 Experiments
5 Conclusions
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 8 / 25
Term Size Norm
t ts =
1 + n
i=1 ti ts if t = Co(t1, . . . , tn)
1 otherwise
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
Term Size Norm
t ts =
1 + n
i=1 ti ts if t = Co(t1, . . . , tn)
1 otherwise
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
Term Size Norm
t ts =
1 + n
i=1 ti ts if t = Co(t1, . . . , tn)
1 otherwise
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
Term Size Norm
t ts =
1 + n
i=1 ti ts if t = Co(t1, . . . , tn)
1 otherwise
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
O(lts × 2lts )
Complexity (Upper Bound): Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
n
i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
maxn
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
maxn
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
Typed-Norms
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
maxn
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
Size Abstraction Transformation
Given a program P, its size abstraction Pα is a program obtained by
replacing each rule p(x, y) → g, b1, . . . , bn ∈ P by
p(X, Y ) → gα, bα
1 , . . . , bα
n where:
g1 ∧ g2 is transformed into gα
1 ∧ gα
2 ,
nonmatch(x, t) is transformed into true,
p(¯x, ¯y) is transformed into p( ¯X, ¯Y ),
match(x, t) and x := t is transformed into
∧{Xσ = t σ | σ ∈ typed norms(x)}, where typed norms(x)
corresponds to the set of types we want x to be measured,
e1 op e2 is transformed into (e1 op e2)[y/YInt] if
Int ∈ typed norms(x) and true otherwise.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 12 / 25
Example: Size Abstraction
fibonacci list(xs,ys)
→ case0(xs,ys).
case0(xs,ys)
→ match(xs,Nil),
ys := Nil.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(xs,ys)
→ case0(xs,ys).
case0(xs,ys)
→ match(xs,Nil),
ys := Nil.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(xs,ys)
→ match(xs,Nil),
ys := Nil.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
ys := Nil.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{YSL = 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(xs,ys)
→ nonmatch(xs,Nil),
match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case0(XSI ,XSL,YSI ,YSL)
→ true,
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ match(xs,Cons(n,zs))
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(n,x),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
fibonacci(NI ,XI ),
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(zs,ws),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
fibonacci list(ZSI ,ZSL,WSI ,WSL),
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
ys := Cons(x,ws)
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(n,m)
→ x := 0,
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
fibonacci(NI ,MI )
→ {XI = 0},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(x,n,m).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case1(XI ,NI ,MI ).
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(x,n,m)
→ n ≥ x,
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case1(XI ,NI ,MI )
→ {NI ≥ XI },
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(n,m).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case2(NI ,MI ).
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(x,n,m)
→ n < x,
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
m := -1.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{MI = −1}.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(n,m)
→ match(n,0),
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case2(NI ,MI )
→ {NI = 0},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
m := 0.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{MI = 0}.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(n,m)
→ nonmatch(n,0),
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case2(NI ,MI )
→ true,
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
match(n,1),
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{NI = 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
m := 1.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{MI = 1}.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(n,m)
→ nonmatch(n,0),
nonmatch(n,1),
match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
case2(NI ,MI )
→ true,
true,
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ match(n,x),
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{NI = XI },
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
y := x - 1,
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
{YI = XI − 1},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
{YI = XI − 1},
fibonacci(y,z),
v := x - 2,
fibonacci(v,w),
m := z + w.
fibonacci(YI ,ZI ),
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
{YI = XI − 1},
fibonacci(YI ,ZI ),
v := x - 2,
fibonacci(v,w),
m := z + w.
{VI = XI − 2},
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
{YI = XI − 1},
fibonacci(YI ,ZI ),
{VI = XI − 2},
fibonacci(v,w),
m := z + w.
fibonacci(VI ,WI ),
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
{YI = XI − 1},
fibonacci(YI ,ZI ),
{VI = XI − 2},
fibonacci(VI ,WI ),
m := z + w.
{MI = ZI + WI },
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Size Abstraction
fibonacci list(XSI ,XSL,YSI ,YSL)
→ case0(XSI ,XSL,YSI ,YSL).
case0(XSI ,XSL,YSI ,YSL)
→ {XSL = 1},
{YSL = 1}.
case0(XSI ,XSL,YSI ,YSL)
→ {XSI ≥ NI , XSI ≥ ZSI ,
XSL = ZSL + 1, ZSL ≥ 1},
fibonacci(NI ,XI ),
fibonacci list(ZSI ,ZSL,WSI ,WSL),
{YSI ≥ XI , YSI ≥ WSI ,
YSL = WSL + 1, WSL ≥ 1},
fibonacci(NI ,MI )
→ {XI = 0},
case1(XI ,NI ,MI ).
case1(XI ,NI ,MI )
→ {NI ≥ XI },
case2(NI ,MI ).
case1(XI ,NI ,MI )
→ {XI ≥ NI + 1},
{MI = −1}.
case2(NI ,MI )
→ {NI = 0},
{MI = 0}.
case2(NI ,MI )
{NI = 1},
{MI = 1}.
case2(NI ,MI )
→ {NI = XI },
{YI = XI − 1},
fibonacci(YI ,ZI ),
{VI = XI − 2},
fibonacci(VI ,WI ),
{MI = ZI + WI }.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
Example: Complexity
t σ =



t σ = Int and t is an integer
length(t) σ = String and t is an string
1 +
n
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
maxn
i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ
2 3 1 3 4 1 5 2 5 4
Example: Fibonacci List
O(lList<Int> × 2lInt )
Complexity (Upper Bound): Fibonacci List
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 14 / 25
Outline
1 Leading Example
2 Size Abstraction using Typed-Norms
3 Inference of Typed-Norms
4 Experiments
5 Conclusions
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 15 / 25
Inference of Typed-Norms
Automated resource analysis needs to infer how the sizes of data are
modified along program’s execution.
Norms define how the size of term are computed (list-length,
tree-depth, term-size, . . . ).
Type-norms allow defining norms based on type information.
The choice of the right norm is crucial to obtain a proof for
termination and get accurate upper and lower bounds.
Allowing multiple norms simultaneously give us more chances to
success, but the efficiency of the analysis can be degraded
considerably.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 16 / 25
Inference of Typed-Norms
Allowing multiple norms simultaneously give us more chances to
success, but the efficiency of the analysis can be degraded
considerably.
Goal: develop an analysis that eliminates useless abstractions:
Remove variables that do not affect the cost.
Remove useless (typed) size information.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 16 / 25
Inference of Typed-Norms: Algorithm
Initialization. This step starts by setting typed norms(x) to ∅ for each
variable x in the program. Then, it identifies the set of
cost-significant guards, and uses each such guard to modify related
typed norms(x) as follows:
If the guard is match(x, t), variable x has a type T, and T is a recursive
type, then T is added to typed norms(x).
If the guard is of the form e1 op e2, and variable x appears in e1 or e2,
then Int is added to typed norms(x).
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 17 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs∅,ys∅)
→ case0(xs∅,ys∅).
case0(xs∅,ys∅)
→ match(xs{L},Nil),
ys∅ := Nil.
case0(xs∅,ys∅)
→ nonmatch(xs∅,Nil),
match(xs{L},Cons(n∅,zs∅)),
fibonacci(n∅,x∅),
fibonacci list(zs∅,ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n∅,m∅)
→ x∅ := 0,
case1(x∅,n∅,m∅).
case1(x∅,n∅,m∅)
→ n{I} ≥ x{I},
case2(n∅,m∅).
case1(x∅,n∅,m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n∅,m∅)
→ match(n{I},0),
m∅ := 0.
case2(n∅,m∅)
→ nonmatch(n∅,0),
match(n{I},1),
m∅ := 1.
case2(n∅,m∅)
→ nonmatch(n∅,0),
nonmatch(n∅,1),
match(n{I},x∅),
y := x∅ - 1,
fibonacci(y∅,z∅),
v∅ := x∅ - 2,
fibonacci(v∅,w∅),
m := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 18 / 25
Inference of Typed-Norms: Algorithm
Propagation. The initial information computed in the first step must
be propagated backwards to other variables in the program:
For match(x,t) and nonmatch(x,t), if y in vars(t), and T in
typed norms(y), then we add T to typed norms(x).
For x := t, if T in typed norms(x) we add T to typed norms(y) for
each variable y in vars(t) as far as type(y) ≤ T.
Built-in functions propagate norms to its arguments.
All other instructions do not modify any information.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 19 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs∅,ys∅)
→ case0(xs∅,ys∅).
case0(xs∅,ys∅)
→ match(xs{L},Nil),
ys∅ := Nil.
case0(xs∅,ys∅)
→ nonmatch(xs∅,Nil),
match(xs{L},Cons(n∅,zs∅)),
fibonacci(n∅,x∅),
fibonacci list(zs∅,ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n∅,m∅)
→ x∅ := 0,
case1(x∅,n∅,m∅).
case1(x∅,n∅,m∅)
→ n{I} ≥ x{I},
case2(n∅,m∅).
case1(x∅,n∅,m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n∅,m∅)
→ match(n{I},0),
m∅ := 0.
case2(n∅,m∅)
→ nonmatch(n∅,0),
match(n{I},1),
m∅ := 1.
case2(n∅,m∅)
→ nonmatch(n∅,0),
nonmatch(n∅,1),
match(n{I},x∅),
y∅ := x∅ - 1,
fibonacci(y∅,z∅),
v∅ := x∅ - 2,
fibonacci(v∅,w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs∅,ys∅)
→ case0(xs∅,ys∅).
case0(xs{L},ys∅)
→ match(xs{L},Nil),
ys∅ := Nil.
case0(xs{L},ys∅)
→ nonmatch(xs{L},Nil),
match(xs{L},Cons(n∅,zs∅)),
fibonacci(n∅,x∅),
fibonacci list(zs∅,ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n∅,m∅)
→ x∅ := 0,
case1(x∅,n∅,m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x∅),
y∅ := x∅ - 1,
fibonacci(y∅,z∅),
v∅ := x∅ - 2,
fibonacci(v∅,w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{L},ys∅)
→ case0(xs{L},ys∅).
case0(xs{L},ys∅)
→ match(xs{L},Nil),
ys∅ := Nil.
case0(xs{L},ys∅)
→ nonmatch(xs{L},Nil),
match(xs{L},Cons(n∅,zs∅)),
fibonacci(n∅,x∅),
fibonacci list(zs∅,ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x∅),
y∅ := x∅ - 1,
fibonacci(y∅,z∅),
v∅ := x∅ - 2,
fibonacci(v∅,w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{L},ys∅)
→ case0(xs{L},ys∅).
case0(xs{L},ys∅)
→ match(xs{L},Nil),
ys∅ := Nil.
case0(xs{L},ys∅)
→ nonmatch(xs{L},Nil),
match(xs{L},Cons(n{I},zs{L})),
fibonacci(n{I},x∅),
fibonacci list(zs{L},ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x∅),
y{I} := x∅ - 1,
fibonacci(y{I},z∅),
v{I} := x∅ - 2,
fibonacci(v{I},w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{L},ys∅)
→ case0(xs{L},ys∅).
case0(xs{I,L},ys∅)
→ match(xs{I,L},Nil),
ys∅ := Nil.
case0(xs{I,L},ys∅)
→ nonmatch(xs{I,L},Nil),
match(xs{I,L},Cons(n{I},zs{L})),
fibonacci(n{I},x∅),
fibonacci list(zs{L},ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x{I}),
y{I} := x{I} - 1,
fibonacci(y{I},z∅),
v{I} := x{I} - 2,
fibonacci(v{I},w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{I,L},ys∅)
→ case0(xs{I,L},ys∅).
case0(xs{I,L},ys∅)
→ match(xs{I,L},Nil),
ys∅ := Nil.
case0(xs{I,L},ys∅)
→ nonmatch(xs{I,L},Nil),
match(xs{I,L},Cons(n{I},zs{L})),
fibonacci(n{I},x∅),
fibonacci list(zs{L},ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x{I}),
y{I} := x{I} - 1,
fibonacci(y{I},z∅),
v{I} := x{I} - 2,
fibonacci(v{I},w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{I,L},ys∅)
→ case0(xs{I,L},ys∅).
case0(xs{I,L},ys∅)
→ match(xs{I,L},Nil),
ys∅ := Nil.
case0(xs{I,L},ys∅)
→ nonmatch(xs{I,L},Nil),
match(xs{I,L},Cons(n{I},zs{I,L})),
fibonacci(n{I},x∅),
fibonacci list(zs{I,L},ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x{I}),
y{I} := x{I} - 1,
fibonacci(y{I},z∅),
v{I} := x{I} - 2,
fibonacci(v{I},w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Inference of Typed-Norms: Algorithm
fibonacci list(xs{I,L},ys∅)
→ case0(xs{I,L},ys∅).
case0(xs{I,L},ys∅)
→ match(xs{I,L},Nil),
ys∅ := Nil.
case0(xs{I,L},ys∅)
→ nonmatch(xs{I,L},Nil),
match(xs{I,L},Cons(n{I},zs{I,L})),
fibonacci(n{I},x∅),
fibonacci list(zs{I,L},ws∅),
ys∅ := Cons(x∅,ws∅).
fibonacci(n{I},m∅)
→ x{I} := 0,
case1(x{I},n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} ≥ x{I},
case2(n{I},m∅).
case1(x{I},n{I},m∅)
→ n{I} < x{I},
m∅ := -1.
case2(n{I},m∅)
→ match(n{I},0),
m∅ := 0.
case2(n{I},m∅)
→ nonmatch(n{I},0),
match(n{I},1),
m∅ := 1.
case2(n{I},m∅)
→ nonmatch(n{I},0),
nonmatch(n{I},1),
match(n{I},x{I}),
y{I} := x{I} - 1,
fibonacci(y{I},z∅),
v{I} := x{I} - 2,
fibonacci(v{I},w∅),
m∅ := z∅ + w∅.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
Outline
1 Leading Example
2 Size Abstraction using Typed-Norms
3 Inference of Typed-Norms
4 Experiments
5 Conclusions
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 21 / 25
Experiments
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
0 5 10 15 20 25 30 35
TypeNorm/TermSize
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 22 / 25
Experiments
The experiments have been performed on an Intel Core 2 Duo at 2.4GHz
with 8GB of RAM, running OS X 10.9.
Table: Run-Time statistics (in ms.) on 61 functions: (1) using term-size; (2)
using all type-norms; and (3) using only significant typed-norms. Total is
Tsa+Tac +Tub.
Configuration Tsa Av. Tsa Tac Av. Tac Tub Av. Tub Total
(1) 0 0 120 2 3911 65 4031
(2) 1633 27 631 11 14230 234 16494
(3) 2161 36 255 5 4488 74 6904
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 23 / 25
Outline
1 Leading Example
2 Size Abstraction using Typed-Norms
3 Inference of Typed-Norms
4 Experiments
5 Conclusions
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 24 / 25
Conclusions
We have presented a novel transformational approach to resource
analysis with typed-norms.
This transformation has the advantage that its formalization can be
done by only adapting the first phase of cost analysis in which the
program is transformed into an intermediate abstract program.
We also outlined an algorithm for the inference of typed-norms which
can detect automatically which norms are useful to later infer the
resource consumption.
Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 25 / 25

More Related Content

What's hot

What's hot (12)

Appendex c
Appendex cAppendex c
Appendex c
 
Discussion of ABC talk by Stefano Cabras, Padova, March 21, 2013
Discussion of ABC talk by Stefano Cabras, Padova, March 21, 2013Discussion of ABC talk by Stefano Cabras, Padova, March 21, 2013
Discussion of ABC talk by Stefano Cabras, Padova, March 21, 2013
 
Reinforcement Learning in Economics and Finance
Reinforcement Learning in Economics and FinanceReinforcement Learning in Economics and Finance
Reinforcement Learning in Economics and Finance
 
20130928 automated theorem_proving_harrison
20130928 automated theorem_proving_harrison20130928 automated theorem_proving_harrison
20130928 automated theorem_proving_harrison
 
Sildes buenos aires
Sildes buenos airesSildes buenos aires
Sildes buenos aires
 
1 polar coordinates
1 polar coordinates1 polar coordinates
1 polar coordinates
 
Hands-On Algorithms for Predictive Modeling
Hands-On Algorithms for Predictive ModelingHands-On Algorithms for Predictive Modeling
Hands-On Algorithms for Predictive Modeling
 
Optimization
OptimizationOptimization
Optimization
 
Slides econ-lm
Slides econ-lmSlides econ-lm
Slides econ-lm
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Option local and volatility 2 25 2014
Option local and volatility 2 25 2014Option local and volatility 2 25 2014
Option local and volatility 2 25 2014
 
MEAN VALUE THEOREM
MEAN VALUE THEOREMMEAN VALUE THEOREM
MEAN VALUE THEOREM
 

Similar to A Transformational Approach to Resource Analysis with Typed-Norms

Contextual Bandit Survey
Contextual Bandit SurveyContextual Bandit Survey
Contextual Bandit SurveySangwoo Mo
 
Normality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfNormality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfVasudha Singh
 
Learning for exploration-exploitation in reinforcement learning. The dusk of ...
Learning for exploration-exploitation in reinforcement learning. The dusk of ...Learning for exploration-exploitation in reinforcement learning. The dusk of ...
Learning for exploration-exploitation in reinforcement learning. The dusk of ...Université de Liège (ULg)
 
Meta-learning of exploration-exploitation strategies in reinforcement learning
Meta-learning of exploration-exploitation strategies in reinforcement learningMeta-learning of exploration-exploitation strategies in reinforcement learning
Meta-learning of exploration-exploitation strategies in reinforcement learningUniversité de Liège (ULg)
 
Interactive Visualization in Human Time -StampedeCon 2015
Interactive Visualization in Human Time -StampedeCon 2015Interactive Visualization in Human Time -StampedeCon 2015
Interactive Visualization in Human Time -StampedeCon 2015StampedeCon
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)Eric Zhang
 
Chapter_09_ParameterEstimation.pptx
Chapter_09_ParameterEstimation.pptxChapter_09_ParameterEstimation.pptx
Chapter_09_ParameterEstimation.pptxVimalMehta19
 
Digital Signal Processing[ECEG-3171]-Ch1_L07
Digital Signal Processing[ECEG-3171]-Ch1_L07Digital Signal Processing[ECEG-3171]-Ch1_L07
Digital Signal Processing[ECEG-3171]-Ch1_L07Rediet Moges
 
Research internship on optimal stochastic theory with financial application u...
Research internship on optimal stochastic theory with financial application u...Research internship on optimal stochastic theory with financial application u...
Research internship on optimal stochastic theory with financial application u...Asma Ben Slimene
 
Presentation on stochastic control problem with financial applications (Merto...
Presentation on stochastic control problem with financial applications (Merto...Presentation on stochastic control problem with financial applications (Merto...
Presentation on stochastic control problem with financial applications (Merto...Asma Ben Slimene
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural SimulationClarkTony
 
An investigation of inference of the generalized extreme value distribution b...
An investigation of inference of the generalized extreme value distribution b...An investigation of inference of the generalized extreme value distribution b...
An investigation of inference of the generalized extreme value distribution b...Alexander Decker
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in Rhtstatistics
 
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...SYRTO Project
 
Clustering Financial Time Series: How Long is Enough?
Clustering Financial Time Series: How Long is Enough?Clustering Financial Time Series: How Long is Enough?
Clustering Financial Time Series: How Long is Enough?Gautier Marti
 
Slides econometrics-2017-graduate-2
Slides econometrics-2017-graduate-2Slides econometrics-2017-graduate-2
Slides econometrics-2017-graduate-2Arthur Charpentier
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 

Similar to A Transformational Approach to Resource Analysis with Typed-Norms (20)

Contextual Bandit Survey
Contextual Bandit SurveyContextual Bandit Survey
Contextual Bandit Survey
 
Normality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdfNormality_assumption_for_the_log_re.pdf
Normality_assumption_for_the_log_re.pdf
 
Learning for exploration-exploitation in reinforcement learning. The dusk of ...
Learning for exploration-exploitation in reinforcement learning. The dusk of ...Learning for exploration-exploitation in reinforcement learning. The dusk of ...
Learning for exploration-exploitation in reinforcement learning. The dusk of ...
 
Meta-learning of exploration-exploitation strategies in reinforcement learning
Meta-learning of exploration-exploitation strategies in reinforcement learningMeta-learning of exploration-exploitation strategies in reinforcement learning
Meta-learning of exploration-exploitation strategies in reinforcement learning
 
Interactive Visualization in Human Time -StampedeCon 2015
Interactive Visualization in Human Time -StampedeCon 2015Interactive Visualization in Human Time -StampedeCon 2015
Interactive Visualization in Human Time -StampedeCon 2015
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)
 
Chapter_09_ParameterEstimation.pptx
Chapter_09_ParameterEstimation.pptxChapter_09_ParameterEstimation.pptx
Chapter_09_ParameterEstimation.pptx
 
Digital Signal Processing[ECEG-3171]-Ch1_L07
Digital Signal Processing[ECEG-3171]-Ch1_L07Digital Signal Processing[ECEG-3171]-Ch1_L07
Digital Signal Processing[ECEG-3171]-Ch1_L07
 
Research internship on optimal stochastic theory with financial application u...
Research internship on optimal stochastic theory with financial application u...Research internship on optimal stochastic theory with financial application u...
Research internship on optimal stochastic theory with financial application u...
 
Presentation on stochastic control problem with financial applications (Merto...
Presentation on stochastic control problem with financial applications (Merto...Presentation on stochastic control problem with financial applications (Merto...
Presentation on stochastic control problem with financial applications (Merto...
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural Simulation
 
An investigation of inference of the generalized extreme value distribution b...
An investigation of inference of the generalized extreme value distribution b...An investigation of inference of the generalized extreme value distribution b...
An investigation of inference of the generalized extreme value distribution b...
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in R
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Slide2
Slide2Slide2
Slide2
 
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
 
Clustering Financial Time Series: How Long is Enough?
Clustering Financial Time Series: How Long is Enough?Clustering Financial Time Series: How Long is Enough?
Clustering Financial Time Series: How Long is Enough?
 
Slides econometrics-2017-graduate-2
Slides econometrics-2017-graduate-2Slides econometrics-2017-graduate-2
Slides econometrics-2017-graduate-2
 
lecture 1
lecture 1lecture 1
lecture 1
 

More from Facultad de Informática UCM

¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?Facultad de Informática UCM
 
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...Facultad de Informática UCM
 
DRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation ComputersDRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation ComputersFacultad de Informática UCM
 
Tendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura ArmTendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura ArmFacultad de Informática UCM
 
Introduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented ComputingIntroduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented ComputingFacultad de Informática UCM
 
Inteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuroInteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuroFacultad de Informática UCM
 
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
 Design Automation Approaches for Real-Time Edge Computing for Science Applic... Design Automation Approaches for Real-Time Edge Computing for Science Applic...
Design Automation Approaches for Real-Time Edge Computing for Science Applic...Facultad de Informática UCM
 
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...Facultad de Informática UCM
 
Fault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error CorrectionFault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error CorrectionFacultad de Informática UCM
 
Cómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intentoCómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intentoFacultad de Informática UCM
 
Automatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPCAutomatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPCFacultad de Informática UCM
 
Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...Facultad de Informática UCM
 
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...Facultad de Informática UCM
 
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.Facultad de Informática UCM
 
Challenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore windChallenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore windFacultad de Informática UCM
 

More from Facultad de Informática UCM (20)

¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?
 
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
 
DRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation ComputersDRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation Computers
 
uElectronics ongoing activities at ESA
uElectronics ongoing activities at ESAuElectronics ongoing activities at ESA
uElectronics ongoing activities at ESA
 
Tendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura ArmTendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura Arm
 
Formalizing Mathematics in Lean
Formalizing Mathematics in LeanFormalizing Mathematics in Lean
Formalizing Mathematics in Lean
 
Introduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented ComputingIntroduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented Computing
 
Computer Design Concepts for Machine Learning
Computer Design Concepts for Machine LearningComputer Design Concepts for Machine Learning
Computer Design Concepts for Machine Learning
 
Inteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuroInteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuro
 
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
 Design Automation Approaches for Real-Time Edge Computing for Science Applic... Design Automation Approaches for Real-Time Edge Computing for Science Applic...
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
 
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
 
Fault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error CorrectionFault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error Correction
 
Cómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intentoCómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intento
 
Automatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPCAutomatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPC
 
Type and proof structures for concurrency
Type and proof structures for concurrencyType and proof structures for concurrency
Type and proof structures for concurrency
 
Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...
 
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
 
Do you trust your artificial intelligence system?
Do you trust your artificial intelligence system?Do you trust your artificial intelligence system?
Do you trust your artificial intelligence system?
 
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
 
Challenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore windChallenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore wind
 

Recently uploaded

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptxNikhil Raut
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsDILIPKUMARMONDAL6
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 

Recently uploaded (20)

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teams
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 

A Transformational Approach to Resource Analysis with Typed-Norms

  • 1. A Transformational Approach to Resource Analysis with Typed-Norms Elvira Albert1, Samir Genaim1, and Ra´ul Guti´errez2,3 1Universidad Complutense de Madrid 2Universidad Polit´ecnica de Madrid 3Universitat Polit`ecnica de Val`encia Universidad Complutense de Madrid June 14, 2016 Madrid, Spain Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 1 / 25
  • 2. Motivation Automated resource analysis needs to infer how the sizes of data are modified along program’s execution. Norms define how the size of term are computed (list-length, tree-depth, term-size, . . . ). Type-norms allow defining norms based on type information. The choice of the right norm is crucial to obtain a proof for termination and get accurate upper and lower bounds. Allowing multiple norms simultaneously give us more chances to success, but the efficiency of the analysis can be degraded considerably. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 2 / 25
  • 3. Main Contribution 1 We propose a transformational approach to use multiple type-norms in resource analysis: 1 transform the program into an intermediate abstract program in which the relation among data and control flow are preserved, 2 from such intermediate abstract program, together with a the size relations, we obtain a cost relation system, in which each variable is abstracted with respect to all considered norms valid for its type, 3 if a solution if obtained from the cost relation system constraints (using a constraint solver), then the solution is transformed into upper and lower resource bounds automatically. 2 we outline an algorithm for the inference of typed-norms which can detect which norms are useful to later infer the resource consumption, and discard norms that are useless for this purpose. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 3 / 25
  • 4. Outline 1 Leading Example 2 Size Abstraction using Typed-Norms 3 Inference of Typed-Norms 4 Experiments 5 Conclusions Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 4 / 25
  • 5. Example: A Simple Functional Language 1 def Int fibonacci(Int n) 2 = case (n <= 0) { 3 true => case n { 4 0 => 0 ; 5 1 => 1 ; 6 m => fibonacci(m − 1) + fibonacci(m − 2) ; 7 } ; 8 false => −1 ; 9 }; 10 11 def List<Int> fibonacci list(List<Int> l) 12 = case l { 13 Nil => Nil ; 14 Cons(n,rest l) => Cons(fibonacci(n),fibonacci list(rest l)) ; 15 }; Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 5 / 25
  • 6. Intermediate Form: An Abstract Syntax r ::= m(¯x, y) → g, b1, . . . , bn. b ::= x:=t | m(¯x, y) g ::= true | g ∧ g | e op e | match(x, t) | nonmatch(x, t) t ::= e | Co(¯t) e ::= x | n | e+e | e−e where op ∈ {>, =, ≥}, m(¯x, ¯y) is the head of the rule, g specifies the conditions for the rule to be applicable and b1, . . . , bn is the rule’s body. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 6 / 25
  • 7. Example: Intermediate Representation fibonacci list(xs,ys) → case0(xs,ys). case0(xs,ys) → match(xs,Nil), ys := Nil. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)), fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws). fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 7 / 25
  • 8. Outline 1 Leading Example 2 Size Abstraction using Typed-Norms 3 Inference of Typed-Norms 4 Experiments 5 Conclusions Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 8 / 25
  • 9. Term Size Norm t ts = 1 + n i=1 ti ts if t = Co(t1, . . . , tn) 1 otherwise 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
  • 10. Term Size Norm t ts = 1 + n i=1 ti ts if t = Co(t1, . . . , tn) 1 otherwise 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
  • 11. Term Size Norm t ts = 1 + n i=1 ti ts if t = Co(t1, . . . , tn) 1 otherwise 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
  • 12. Term Size Norm t ts = 1 + n i=1 ti ts if t = Co(t1, . . . , tn) 1 otherwise 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List O(lts × 2lts ) Complexity (Upper Bound): Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 9 / 25
  • 13. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
  • 14. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
  • 15. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ n i=1 ti σ if t = Co(t1, . . . , tn) and type(t) = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 10 / 25
  • 16. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ maxn i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
  • 17. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ maxn i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
  • 18. Typed-Norms t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ maxn i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 11 / 25
  • 19. Size Abstraction Transformation Given a program P, its size abstraction Pα is a program obtained by replacing each rule p(x, y) → g, b1, . . . , bn ∈ P by p(X, Y ) → gα, bα 1 , . . . , bα n where: g1 ∧ g2 is transformed into gα 1 ∧ gα 2 , nonmatch(x, t) is transformed into true, p(¯x, ¯y) is transformed into p( ¯X, ¯Y ), match(x, t) and x := t is transformed into ∧{Xσ = t σ | σ ∈ typed norms(x)}, where typed norms(x) corresponds to the set of types we want x to be measured, e1 op e2 is transformed into (e1 op e2)[y/YInt] if Int ∈ typed norms(x) and true otherwise. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 12 / 25
  • 20. Example: Size Abstraction fibonacci list(xs,ys) → case0(xs,ys). case0(xs,ys) → match(xs,Nil), ys := Nil. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 21. Example: Size Abstraction fibonacci list(xs,ys) → case0(xs,ys). case0(xs,ys) → match(xs,Nil), ys := Nil. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 22. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(xs,ys) → match(xs,Nil), ys := Nil. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 23. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, ys := Nil. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {YSL = 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 24. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(xs,ys) → nonmatch(xs,Nil), match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case0(XSI ,XSL,YSI ,YSL) → true, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 25. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → match(xs,Cons(n,zs)) fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 26. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(n,x), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. fibonacci(NI ,XI ), Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 27. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(zs,ws), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. fibonacci list(ZSI ,ZSL,WSI ,WSL), Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 28. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), ys := Cons(x,ws) fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 29. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(n,m) → x := 0, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. fibonacci(NI ,MI ) → {XI = 0}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 30. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(x,n,m). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case1(XI ,NI ,MI ). Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 31. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(x,n,m) → n ≥ x, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case1(XI ,NI ,MI ) → {NI ≥ XI }, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 32. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(n,m). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case2(NI ,MI ). Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 33. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(x,n,m) → n < x, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 34. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, m := -1. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {MI = −1}. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 35. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(n,m) → match(n,0), m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case2(NI ,MI ) → {NI = 0}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 36. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, m := 0. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {MI = 0}. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 37. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(n,m) → nonmatch(n,0), match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case2(NI ,MI ) → true, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 38. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) match(n,1), m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {NI = 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 39. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, m := 1. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {MI = 1}. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 40. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(n,m) → nonmatch(n,0), nonmatch(n,1), match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. case2(NI ,MI ) → true, true, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 41. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → match(n,x), y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {NI = XI }, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 42. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, y := x - 1, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. {YI = XI − 1}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 43. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, {YI = XI − 1}, fibonacci(y,z), v := x - 2, fibonacci(v,w), m := z + w. fibonacci(YI ,ZI ), Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 44. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, {YI = XI − 1}, fibonacci(YI ,ZI ), v := x - 2, fibonacci(v,w), m := z + w. {VI = XI − 2}, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 45. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, {YI = XI − 1}, fibonacci(YI ,ZI ), {VI = XI − 2}, fibonacci(v,w), m := z + w. fibonacci(VI ,WI ), Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 46. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, {YI = XI − 1}, fibonacci(YI ,ZI ), {VI = XI − 2}, fibonacci(VI ,WI ), m := z + w. {MI = ZI + WI }, Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 47. Example: Size Abstraction fibonacci list(XSI ,XSL,YSI ,YSL) → case0(XSI ,XSL,YSI ,YSL). case0(XSI ,XSL,YSI ,YSL) → {XSL = 1}, {YSL = 1}. case0(XSI ,XSL,YSI ,YSL) → {XSI ≥ NI , XSI ≥ ZSI , XSL = ZSL + 1, ZSL ≥ 1}, fibonacci(NI ,XI ), fibonacci list(ZSI ,ZSL,WSI ,WSL), {YSI ≥ XI , YSI ≥ WSI , YSL = WSL + 1, WSL ≥ 1}, fibonacci(NI ,MI ) → {XI = 0}, case1(XI ,NI ,MI ). case1(XI ,NI ,MI ) → {NI ≥ XI }, case2(NI ,MI ). case1(XI ,NI ,MI ) → {XI ≥ NI + 1}, {MI = −1}. case2(NI ,MI ) → {NI = 0}, {MI = 0}. case2(NI ,MI ) {NI = 1}, {MI = 1}. case2(NI ,MI ) → {NI = XI }, {YI = XI − 1}, fibonacci(YI ,ZI ), {VI = XI − 2}, fibonacci(VI ,WI ), {MI = ZI + WI }. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 13 / 25
  • 48. Example: Complexity t σ =    t σ = Int and t is an integer length(t) σ = String and t is an string 1 + n i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ maxn i=1 ti σ if t = Co(t1, . . . , tn) and typet = σ 2 3 1 3 4 1 5 2 5 4 Example: Fibonacci List O(lList<Int> × 2lInt ) Complexity (Upper Bound): Fibonacci List Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 14 / 25
  • 49. Outline 1 Leading Example 2 Size Abstraction using Typed-Norms 3 Inference of Typed-Norms 4 Experiments 5 Conclusions Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 15 / 25
  • 50. Inference of Typed-Norms Automated resource analysis needs to infer how the sizes of data are modified along program’s execution. Norms define how the size of term are computed (list-length, tree-depth, term-size, . . . ). Type-norms allow defining norms based on type information. The choice of the right norm is crucial to obtain a proof for termination and get accurate upper and lower bounds. Allowing multiple norms simultaneously give us more chances to success, but the efficiency of the analysis can be degraded considerably. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 16 / 25
  • 51. Inference of Typed-Norms Allowing multiple norms simultaneously give us more chances to success, but the efficiency of the analysis can be degraded considerably. Goal: develop an analysis that eliminates useless abstractions: Remove variables that do not affect the cost. Remove useless (typed) size information. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 16 / 25
  • 52. Inference of Typed-Norms: Algorithm Initialization. This step starts by setting typed norms(x) to ∅ for each variable x in the program. Then, it identifies the set of cost-significant guards, and uses each such guard to modify related typed norms(x) as follows: If the guard is match(x, t), variable x has a type T, and T is a recursive type, then T is added to typed norms(x). If the guard is of the form e1 op e2, and variable x appears in e1 or e2, then Int is added to typed norms(x). Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 17 / 25
  • 53. Inference of Typed-Norms: Algorithm fibonacci list(xs∅,ys∅) → case0(xs∅,ys∅). case0(xs∅,ys∅) → match(xs{L},Nil), ys∅ := Nil. case0(xs∅,ys∅) → nonmatch(xs∅,Nil), match(xs{L},Cons(n∅,zs∅)), fibonacci(n∅,x∅), fibonacci list(zs∅,ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n∅,m∅) → x∅ := 0, case1(x∅,n∅,m∅). case1(x∅,n∅,m∅) → n{I} ≥ x{I}, case2(n∅,m∅). case1(x∅,n∅,m∅) → n{I} < x{I}, m∅ := -1. case2(n∅,m∅) → match(n{I},0), m∅ := 0. case2(n∅,m∅) → nonmatch(n∅,0), match(n{I},1), m∅ := 1. case2(n∅,m∅) → nonmatch(n∅,0), nonmatch(n∅,1), match(n{I},x∅), y := x∅ - 1, fibonacci(y∅,z∅), v∅ := x∅ - 2, fibonacci(v∅,w∅), m := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 18 / 25
  • 54. Inference of Typed-Norms: Algorithm Propagation. The initial information computed in the first step must be propagated backwards to other variables in the program: For match(x,t) and nonmatch(x,t), if y in vars(t), and T in typed norms(y), then we add T to typed norms(x). For x := t, if T in typed norms(x) we add T to typed norms(y) for each variable y in vars(t) as far as type(y) ≤ T. Built-in functions propagate norms to its arguments. All other instructions do not modify any information. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 19 / 25
  • 55. Inference of Typed-Norms: Algorithm fibonacci list(xs∅,ys∅) → case0(xs∅,ys∅). case0(xs∅,ys∅) → match(xs{L},Nil), ys∅ := Nil. case0(xs∅,ys∅) → nonmatch(xs∅,Nil), match(xs{L},Cons(n∅,zs∅)), fibonacci(n∅,x∅), fibonacci list(zs∅,ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n∅,m∅) → x∅ := 0, case1(x∅,n∅,m∅). case1(x∅,n∅,m∅) → n{I} ≥ x{I}, case2(n∅,m∅). case1(x∅,n∅,m∅) → n{I} < x{I}, m∅ := -1. case2(n∅,m∅) → match(n{I},0), m∅ := 0. case2(n∅,m∅) → nonmatch(n∅,0), match(n{I},1), m∅ := 1. case2(n∅,m∅) → nonmatch(n∅,0), nonmatch(n∅,1), match(n{I},x∅), y∅ := x∅ - 1, fibonacci(y∅,z∅), v∅ := x∅ - 2, fibonacci(v∅,w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 56. Inference of Typed-Norms: Algorithm fibonacci list(xs∅,ys∅) → case0(xs∅,ys∅). case0(xs{L},ys∅) → match(xs{L},Nil), ys∅ := Nil. case0(xs{L},ys∅) → nonmatch(xs{L},Nil), match(xs{L},Cons(n∅,zs∅)), fibonacci(n∅,x∅), fibonacci list(zs∅,ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n∅,m∅) → x∅ := 0, case1(x∅,n∅,m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x∅), y∅ := x∅ - 1, fibonacci(y∅,z∅), v∅ := x∅ - 2, fibonacci(v∅,w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 57. Inference of Typed-Norms: Algorithm fibonacci list(xs{L},ys∅) → case0(xs{L},ys∅). case0(xs{L},ys∅) → match(xs{L},Nil), ys∅ := Nil. case0(xs{L},ys∅) → nonmatch(xs{L},Nil), match(xs{L},Cons(n∅,zs∅)), fibonacci(n∅,x∅), fibonacci list(zs∅,ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x∅), y∅ := x∅ - 1, fibonacci(y∅,z∅), v∅ := x∅ - 2, fibonacci(v∅,w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 58. Inference of Typed-Norms: Algorithm fibonacci list(xs{L},ys∅) → case0(xs{L},ys∅). case0(xs{L},ys∅) → match(xs{L},Nil), ys∅ := Nil. case0(xs{L},ys∅) → nonmatch(xs{L},Nil), match(xs{L},Cons(n{I},zs{L})), fibonacci(n{I},x∅), fibonacci list(zs{L},ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x∅), y{I} := x∅ - 1, fibonacci(y{I},z∅), v{I} := x∅ - 2, fibonacci(v{I},w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 59. Inference of Typed-Norms: Algorithm fibonacci list(xs{L},ys∅) → case0(xs{L},ys∅). case0(xs{I,L},ys∅) → match(xs{I,L},Nil), ys∅ := Nil. case0(xs{I,L},ys∅) → nonmatch(xs{I,L},Nil), match(xs{I,L},Cons(n{I},zs{L})), fibonacci(n{I},x∅), fibonacci list(zs{L},ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x{I}), y{I} := x{I} - 1, fibonacci(y{I},z∅), v{I} := x{I} - 2, fibonacci(v{I},w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 60. Inference of Typed-Norms: Algorithm fibonacci list(xs{I,L},ys∅) → case0(xs{I,L},ys∅). case0(xs{I,L},ys∅) → match(xs{I,L},Nil), ys∅ := Nil. case0(xs{I,L},ys∅) → nonmatch(xs{I,L},Nil), match(xs{I,L},Cons(n{I},zs{L})), fibonacci(n{I},x∅), fibonacci list(zs{L},ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x{I}), y{I} := x{I} - 1, fibonacci(y{I},z∅), v{I} := x{I} - 2, fibonacci(v{I},w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 61. Inference of Typed-Norms: Algorithm fibonacci list(xs{I,L},ys∅) → case0(xs{I,L},ys∅). case0(xs{I,L},ys∅) → match(xs{I,L},Nil), ys∅ := Nil. case0(xs{I,L},ys∅) → nonmatch(xs{I,L},Nil), match(xs{I,L},Cons(n{I},zs{I,L})), fibonacci(n{I},x∅), fibonacci list(zs{I,L},ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x{I}), y{I} := x{I} - 1, fibonacci(y{I},z∅), v{I} := x{I} - 2, fibonacci(v{I},w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 62. Inference of Typed-Norms: Algorithm fibonacci list(xs{I,L},ys∅) → case0(xs{I,L},ys∅). case0(xs{I,L},ys∅) → match(xs{I,L},Nil), ys∅ := Nil. case0(xs{I,L},ys∅) → nonmatch(xs{I,L},Nil), match(xs{I,L},Cons(n{I},zs{I,L})), fibonacci(n{I},x∅), fibonacci list(zs{I,L},ws∅), ys∅ := Cons(x∅,ws∅). fibonacci(n{I},m∅) → x{I} := 0, case1(x{I},n{I},m∅). case1(x{I},n{I},m∅) → n{I} ≥ x{I}, case2(n{I},m∅). case1(x{I},n{I},m∅) → n{I} < x{I}, m∅ := -1. case2(n{I},m∅) → match(n{I},0), m∅ := 0. case2(n{I},m∅) → nonmatch(n{I},0), match(n{I},1), m∅ := 1. case2(n{I},m∅) → nonmatch(n{I},0), nonmatch(n{I},1), match(n{I},x{I}), y{I} := x{I} - 1, fibonacci(y{I},z∅), v{I} := x{I} - 2, fibonacci(v{I},w∅), m∅ := z∅ + w∅. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 20 / 25
  • 63. Outline 1 Leading Example 2 Size Abstraction using Typed-Norms 3 Inference of Typed-Norms 4 Experiments 5 Conclusions Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 21 / 25
  • 64. Experiments 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 0 5 10 15 20 25 30 35 TypeNorm/TermSize Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 22 / 25
  • 65. Experiments The experiments have been performed on an Intel Core 2 Duo at 2.4GHz with 8GB of RAM, running OS X 10.9. Table: Run-Time statistics (in ms.) on 61 functions: (1) using term-size; (2) using all type-norms; and (3) using only significant typed-norms. Total is Tsa+Tac +Tub. Configuration Tsa Av. Tsa Tac Av. Tac Tub Av. Tub Total (1) 0 0 120 2 3911 65 4031 (2) 1633 27 631 11 14230 234 16494 (3) 2161 36 255 5 4488 74 6904 Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 23 / 25
  • 66. Outline 1 Leading Example 2 Size Abstraction using Typed-Norms 3 Inference of Typed-Norms 4 Experiments 5 Conclusions Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 24 / 25
  • 67. Conclusions We have presented a novel transformational approach to resource analysis with typed-norms. This transformation has the advantage that its formalization can be done by only adapting the first phase of cost analysis in which the program is transformed into an intermediate abstract program. We also outlined an algorithm for the inference of typed-norms which can detect automatically which norms are useful to later infer the resource consumption. Albert, Genaim, Guti´errez Resource Analysis with Typed-Norms UCM - Madrid 25 / 25