Automatic Resource Bound Analysis and Linear Optimization. Jan Hoffmann

Size: px
Start display at page:

Download "Automatic Resource Bound Analysis and Linear Optimization. Jan Hoffmann"

Transcription

1 Automatic Resource Bound Analysis and Linear Optimization Jan Hoffmann

2 Beyond worst-case analysis

3 Beyond worst-case analysis of algorithms

4 Beyond worst-case analysis of algorithms Resource bound analysis

5 Beyond worst-case analysis of algorithms Resource bound analysis of programs / software

6 Motivation: Why analyze resource usage of programs?

7 Resource Usage in Safety-Critical Systems Memory Usage Timing

8 Resource Usage in Safety-Critical Systems Memory Usage Timing Unintended acceleration in Toyota cars in the US

9 Resource Usage in Safety-Critical Systems Memory Usage Timing Unintended acceleration in Toyota cars in the US ICE 3 Velaro D delivery delayed by one year because of software performance issues in 2013.

10 Performance Bugs are Common and Expensive HealthCare.gov debacle has been mainly caused by performance issues. Google Apps Developer: Cannot test for performance bugs with regression test.

11 Software Security Algorithmic Complexity Attacks Side-Channel Attacks

12 Software Security Algorithmic Complexity Attacks Side-Channel Attacks Space/Time Analysis for Cybersecurity (STAC) October 2014 $ 53M program Our team: Computed Bound Actual Behavior Performance Quick Sort (Integers) 12n n + 3 O(n 2 ) 0.1 s Split and Sort 16n n + 9 O(n 2 ) 2.1 s

13 Static Resource Bound Analysis Given: Question: A program P What is the worst-case resource consumption of P as a function of the size of its inputs?

14 Static Resource Bound Analysis Given: A program P Clock cycles, heap space, power,... Question: What is the worst-case resource consumption of P as a function of the size of its inputs?

15 Static Resource Bound Analysis Given: A program P Clock cycles, heap space, power,... Question: What is the worst-case resource consumption of P as a function of the size of its inputs? Not only asymptotic bounds but concrete constant factors.

16 Automatic Static Resource Bound Analysis Given: A program P Clock cycles, heap space, power,... Question: What is the worst-case resource consumption of P as a function of the size of its inputs? Not only asymptotic bounds but concrete constant factors.

17 Automatic Static Resource Bound Analysis Undecidable problem Given: A program P Clock cycles, heap space, power,... Question: What is the worst-case resource consumption of P as a function of the size of its inputs? Not only asymptotic bounds but concrete constant factors.

18 Research Challenges Model and predict resource usage at development time. Source code

19 Research Challenges Model and predict resource usage at development time. Compiler Libraries Source code Run-time system Hardware

20 Research Challenges Help developers to reason about quantitative properties. Computer support: Modeling, specification, verification, automation and user interaction Compositionally: Track size changes and specify resource-usage of library code Language features: Concurrency, higher-order, data structures,

21 Why is this Related? 1. Beyond worst-case analysis of algorithms Automation Concrete (non-asymptotic) bounds for specific hardware 2. We face similar challenges in resource-bound analysis The worst-case behavior doesn t happen in practice. 3. We reduce bound inference to linear optimization Linear programs we get are solvable in linear time in practice Theoretical worst-case of the algorithm is exponential (simplex)

22 Outline Motivation How does automatic resource bound analysis work? How well does automatic resource bound analysis work? (implementation and experiments) What are the properties of the LP instances that we get?

23 Source Code 12n n +3 Resource Bound Bird s Eye View Type-Based Resource Analysis

24 Source Code 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

25 Source Code Compiler 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

26 Source Code Compiler Run-time system Hardware 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

27 Source Code Formal Cost Semantics Compiler Run-time system Hardware 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

28 Source Code Formal Cost Semantics Compiler ait WCET Analyzers Run-time system Hardware 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

29 Source Code CPLEX CLP Type Inference Formal Cost Semantics Compiler ait WCET Analyzers acc:int q v q 0 v acc:int,l:l p (int) (A:VAR) acc : int q q 0 ß(last) = (int,l p ß q (int))! ß /q 0 ß int acc:int, x:int,xs:l p q a (A:APP) (int) last(x,xs):int match l with nil! acc cons(x,xs)! last(x,xs):int (A:MATL) Type Derivation q 0 a Run-time system Hardware 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

30 Source Code CPLEX CLP Type Inference Formal Cost Semantics Compiler ait WCET Analyzers acc:int q v q 0 v acc:int,l:l p (int) (A:VAR) acc : int q q 0 ß(last) = (int,l p ß q (int))! ß /q 0 ß int acc:int, x:int,xs:l p q a (A:APP) (int) last(x,xs):int match l with nil! acc cons(x,xs)! last(x,xs):int (A:MATL) Type Derivation q 0 a Run-time system Hardware 12n n +3 Resource Bound applies to Machine Code Bird s Eye View Type-Based Resource Analysis

31 Source Code CPLEX Type Inference CLP acc:int q v q 0 v acc:int,l:l p (int) (A:VAR) acc : int q q 0 ß(last) = (int,l p ß q (int))! ß /q 0 ß int acc:int, x:int,xs:l p q a (A:APP) (int) last(x,xs):int match l with nil! acc cons(x,xs)! last(x,xs):int (A:MATL) Type Derivation q 0 a 12n n +3 Resource Bound Bird s Eye View Type-Based Resource Analysis

32 Source Code CPLEX Type Inference CLP Clear soundness theorem. acc:int q v q 0 v acc:int,l:l p (int) (A:VAR) acc : int q q 0 ß(last) = (int,l p ß q (int))! ß /q 0 ß int acc:int, x:int,xs:l p q a (A:APP) (int) last(x,xs):int match l with nil! acc cons(x,xs)! last(x,xs):int (A:MATL) Type Derivation q 0 a Naturally compositional. Efficient inference via LP solving. 12n n +3 Resource Bound Bird s Eye View Type-Based Resource Analysis

33 Idea: Automate Amortized Analysis Assign potential functions to data structures States are mapped to non-negative numbers (state) 0 Potential pays the resource consumption and the potential at the following program point (before) (after)+cost telescoping Initial potential is an upper bound (initial state) P cost

34 Idea: Automate Amortized Analysis Assign potential functions to data structures States are mapped to non-negative numbers (state) 0 Potential pays the resource consumption and the potential at the following program point (before) (after)+cost telescoping Initial potential is an upper bound (initial state) P cost Type systems for automatic analysis Fix a format of potential functions Develop type rules that manipulate potential functions

35 Idea: Automate Amortized Analysis Assign potential functions to data structures States are mapped to non-negative numbers (state) 0 Potential pays the resource consumption and the potential at the following program point (before) (after)+cost telescoping Initial potential is an upper bound (initial state) P cost Type systems for automatic analysis Fix a format of potential functions Potential is given by types. Develop type rules that manipulate potential functions

36 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer)

37 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation:

38 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d b e c

39 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d c b e c

40 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d c b b e c

41 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d c b a b e c

42 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d c b a append(x,y) b e c

43 Example: Append for Persistent Lists append(x,y) Heap-space usage is 2n if n is the length of list x One list element requires two heap cells (data and pointer) Example evaluation: x a y d c b a append(x,y) b e c Heap usage: 2*n = 2*3 = 6

44 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y

45 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a 4 y d b 4 e 2 2 c 4 z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

46 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a 4 y d b 4 e 2 2 append(x,y) c 4 z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

47 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a 4 y d b 4 e 2 2 c 2 append(x,y) c z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

48 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a 4 y d b e 2 2 c 2 b 2 append(x,y) c z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

49 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d b e 2 2 c 2 b 2 a 2 append(x,y) c z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

50 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d b e 2 2 c 2 b 2 a 2 t c z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

51 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d b e 2 2 c 2 b 2 a 2 t append(t,z) c z f Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

52 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d 2 c 2 b 2 a 2 t append(t,z) b e c z f e Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

53 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d c 2 b 2 a 2 t append(t,z) b e c z f e d Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

54 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d c b 2 a 2 t append(t,z) b e c z f e d c Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

55 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d c b a 2 t append(t,z) b e c z f e d c b Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

56 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d c b a t append(t,z) b e c z f e d c b a Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

57 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d c b a t b e c z f e d c b a append(t,z) Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

58 Example: Composing Calls of Append f(x,y,z) = { t = append(x,y); append(t,z) } Heap usage of f(x,y,z) is 2n + 2(n+m) if n is the length of list x m is the length of list y x a y d b e c b a t Implicit reasoning about size-changes. c z f e d c b a append(t,z) Initial potential: 4*n + 2*m = 4*3 + 2*2 = 16

59 Example: Composing Calls of Append f(x,y,z) = { 4 2 0/0 2 append: (L (int),l (int)) ----> L (int) t = append(x,y); append(t,z) 2 0 } append: (L (int),l (int)) ----> 0/0 0 L (int) The most general type of append is specialized at call-sites: q p append: (L (int),l (int)) ----> s/t r L (int) Φ Linear constraints.

60 Polynomial Potential Functions

61 Linear Potential Functions User-defined resource metrics (i.e., by tick(q) in the code) Naturally compositional: tracks size changes, types are specifications Bound inference by reduction to efficient LP solving Type derivations prove bounds with respect to the cost semantics Phd Thesis: Polynomial Potential Functions

62 User-defined resource metrics (i.e., by tick(q) in the code) Naturally compositional: tracks size changes, types are specifications Bound inference by reduction to efficient LP solving Type derivations prove bounds with respect to the cost semantics Linear Potential Functions Multivariate Polynomial Potential Functions Phd Thesis: Polynomial Potential Functions

63 For example m*n 2. User-defined resource metrics (i.e., by tick(q) in the code) Naturally compositional: tracks size changes, types are specifications Bound inference by reduction to efficient LP solving Type derivations prove bounds with respect to the cost semantics Linear Potential Functions Multivariate Polynomial Potential Functions Phd Thesis: Polynomial Potential Functions

64 For example m*n 2. User-defined resource metrics (i.e., by tick(q) in the code) Naturally compositional: tracks size changes, types are specifications Bound inference by reduction to efficient LP solving Type derivations prove bounds with respect to the cost semantics Linear Potential Functions Multivariate Polynomial Potential Functions Phd Thesis: Polynomial Potential Functions First automatic, type-based resource analysis for polynomial bounds.

65 Example: Polynomial Potential Functions t = append(xs,ys); quicksort(t) Computed time bound: 12m mn + 12n m + 22n + 11

66 Example: Polynomial Potential Functions t = append(xs,ys); quicksort(t) Computed time bound: 12m mn + 12n m + 22n + 11 append :((L(int), L(int)), ! )! (L(int), (3, 26, 24)) quicksort :(L(int), (3, 26, 24))! (L(int), (0, 0, 0))

67 Example: Polynomial Potential Functions t = append(xs,ys); quicksort(t) Computed time bound: 12m mn + 12n m + 22n + 11 append :((L(int), L(int)),! n m n + 26m nm )! (L(int), (3, 26, 24)) quicksort :(L(int), (3, 26, 24))! (L(int), (0, 0, 0))

68 Example: Polynomial Potential Functions t = append(xs,ys); quicksort(t) Computed time bound: 12m mn + 12n m + 22n + 11 Cost of append 8n +3 append :((L(int), L(int)),! n m n + 26m nm )! (L(int), (3, 26, 24)) quicksort :(L(int), (3, 26, 24))! (L(int), (0, 0, 0))

69 Example: Polynomial Potential Functions t = append(xs,ys); quicksort(t) Computed time bound: 12m mn + 12n m + 22n + 11 Cost of append append :((L(int), L(int)), 8n +3 n+m (n+m) + 24! )! (L(int), (3, 26, 24)) 24 n m n + 26m nm quicksort :(L(int), (3, 26, 24))! (L(int), (0, 0, 0))

70 Multivariate Resource Polynomials [POPL 11] Map data structures to non-negative rational numbers p : JAK! Q + 0 Are non-negative linear combinations of the following base polynomials: P(Int) ={a 1} P(A 1, A 2 )={(a 1, a 2 ) p 1 (a 1 ) p 2 (a 2 ) p i P(A i )} P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

71 Multivariate Resource Polynomials [POPL 11] Map data structures to non-negative rational numbers p : JAK! Q + 0 Are non-negative linear combinations of the following base polynomials: P(Int) ={a 1} Important innovation: sigma-pi formula for data structures P(A 1, A 2 )={(a 1, a 2 ) p 1 (a 1 ) p 2 (a 2 ) p i P(A i )} P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

72 Resource Polynomials: Examples P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky p i (a ji ) k N, p i P(A)} i=1

73 Resource Polynomials: Examples [a 1,...,a n ] 7! 8n +3 P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

74 Resource Polynomials: Examples [a 1,...,a n ] 7! 8n +3 n [a 1,...,a n ] 7! 36 3 n n +3 P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

75 Resource Polynomials: Examples [a 1,...,a n ] 7! 8n +3 n [a 1,...,a n ] 7! 36 3 n n +3 ([a 1,...,a n ], [b 1,...,b m ]) 7! 39mn +6m + 21n + 19 P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

76 Resource Polynomials: Examples [a 1,...,a n ] 7! 8n +3 n [a 1,...,a n ] 7! 36 3 n n +3 ([a 1,...,a n ], [b 1,...,b m ]) 7! 39mn +6m + 21n + 19 n [[a1,...,a 1 m 1 1 ],..., [a1,...a n m n n ]] 7! n +3+ X 1applei<japplen 12m i P(L(A)) = {[a 1,...,a n ] X 1 j 1 < <j k n ky i=1 p i (a ji ) k N, p i P(A)}

77 Automatic Computation of the Bounds 1. Fix a maximal degree of resource polynomials 2. Annotate each type with (yet unknown) coefficients for resource polynomials Example for degree 2: ((L(int), L(int)), q 0,0, q 1,0, q 2,0, q 1,1, q 0,1, q 0,2 ) General case: index system that enumerates resource polynomials 3. Extract linear constraints for the coefficients during type inference 4. Solve the constraints with an LP solver

78 Automatic Computation of the Bounds 1. Fix a maximal degree of resource polynomials 2. Annotate each type with (yet unknown) coefficients for resource polynomials q 0,0 + q 1,1 nm + q 1,0 n + q 2,0 n 2 + q 0,1 m + q 0,2 m 2 Example for degree 2: ((L(int), L(int)), q 0,0, q 1,0, q 2,0, q 1,1, q 0,1, q 0,2 ) General case: index system that enumerates resource polynomials 3. Extract linear constraints for the coefficients during type inference 4. Solve the constraints with an LP solver

79 Outline Motivation How does automatic resource bound analysis work? How well does automatic resource bound analysis work? (Implementation and experiments) What are the properties of the LP instances that we get?

80 Resource Aware ML Based on Inria s OCaml compiler ~12,000 lines of code (+ ~29,000 loc form the OCaml compiler) Currently we use Coin-Or s CLP C interface Features: Higher-order functions and polymorphism User defined inductive types Parallel evaluation Side effects User defined (non-monotone) resource metrics Upper and lower bounds

81 Resource Aware ML Web interface at Based on Inria s OCaml compiler ~12,000 lines of code (+ ~29,000 loc form the OCaml compiler) Currently we use Coin-Or s CLP C interface Features: Higher-order functions and polymorphism User defined inductive types Parallel evaluation Side effects User defined (non-monotone) resource metrics Upper and lower bounds

82 Experimental Evaluation

83 Computed Bound Actual Behavior Performance Quick Sort (Integers) 12n n + 3 O(n 2 ) 0.1 s Split and Sort 16n n + 9 O(n 2 ) 2.1 s Insertion Sort (Strings) 8n 2 m + 8n 2-8nm + 4n + 3 O(n 2 m) 0.91 s Duplicate Elimination 6n 2 m + 9n 2-6nm + 3n + 3 O(n 2 m) 0.97 s Longest Common Subsequence 39nm + 6m + 21n + 19 O(nm) 0.36 s Matrix Multiplication 28xmn + 32xm + 2x + 14n + 21 O(xmn) 1.96 s Breadth-First Matrix Multiplication Dijkstra s Shortest-Path Algorithm In-Place Quick Sort for Arrays 2yz + 15ynmx + 14ynm + 15yn + 104n + 51 O(ynmx) 4.98 s 79.5n n + 38 O(n 2 ) 2.50 s 12.25x x + 3 O(x 2 ) 0.64 s Micro Benchmarks Evaluation-Step Bounds

84 Quick Sort for Integers Evaluation-step bound vs. measured behavior

85 First tight bound for quick sort. Quick Sort for Integers Evaluation-step bound vs. measured behavior

86 Longest Common Subsequence Evaluation-step bound vs. measured behavior

87 First automatically derived bound for LCS. Longest Common Subsequence Evaluation-step bound vs. measured behavior

88 Insertion Sort for Strings Evaluation-step bound vs. measured behavior

89 First automatic bound for a sorting algorithm for strings. Insertion Sort for Strings Evaluation-step bound vs. measured behavior

90 Macro Benchmarks 1) OCaml s standard list library list.ml Evaluation-step bounds for 47 of 51 top-level functions 428 lines of code; 3.2 seconds on a Macbook Pro 2) CompCert C Compiler OCaml code extracted from the Coq specification Evaluation-step bounds for 13 topmost modules in the dependency graph 138 of 164 functions bounded; 2740 lines of code; 21min

91 Macro Benchmarks 1) OCaml s standard list library list.ml Evaluation-step bounds for 47 of 51 top-level functions 428 lines of code; 3.2 seconds on a Macbook Pro 2) CompCert C Compiler OCaml code extracted from the Coq specification Evaluation-step bounds for 13 topmost modules in the dependency graph 138 of 164 functions bounded; 2740 lines of code; 21min Problems: Modules and untyped code.

92 Metric #Funs LOC Time #Const #Lin #Quad #Cubic #Poly #Fail Asym. Tight steps s heap s tick s CompCert: tick s steps s Macro Benchmarks

93 How can we make predictions about compiled code?

94 Machine Learning Cost Models How to obtain realistic cost metrics for high-level analysis? Treat hardware, compiler, and runtime systems as black box Select training programs that cover relevant operations Use linear regression to obtain average time and memory costs of operations Combine time and memory predictions to get a time model for execution with garbage collection

95 Bound for List Append on x GHz Intel Core i5-5250u processor Error Actual Time Expected Time 35 Execution Time (ms)

96 Outline Motivation How does automatic resource bound analysis work? How well does automatic resource bound analysis work? (Implementation and experiments) What are the properties of the LP instances that we get?

97 Network-Flow Problems Constraints we derive are almost network-flow problems

98 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b i j

99 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b Inflow. i j

100 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b Inflow. i j Outflow.

101 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b Constant sink/ source. Inflow. i j Outflow.

102 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b Constant sink/ source. Inflow. i j Outflow. l i apple x i apple u i

103 Network-Flow Problems Constraints we derive are almost network-flow problems Network-flow constraints: X x i X x j = b Constant sink/ source. Inflow. i j Outflow. l i apple x i apple u i Flow capacity.

104 Linear Constraints have a Simple Form Pay for constant cost q = q 0 + c Account for size changes q 0 i = q i + q i+1 Recursive call q = p Conditional branches q p 1 q p 2

105 Linear Constraints have a Simple Form Pay for constant cost q = q 0 + c Network constraints. Account for size changes q 0 i = q i + q i+1 Recursive call q = p Conditional branches q p 1 q p 2

106 Linear Constraints have a Simple Form Pay for constant cost q = q 0 + c Network constraints. Account for size changes q 0 i = q i + q i+1 Flow through an edge is used twice. Recursive call q = p Conditional branches q p 1 q p 2

107 Linear Constraints have a Simple Form Pay for constant cost q = q 0 + c Network constraints. Account for size changes q 0 i = q i + q i+1 Flow through an edge is used twice. Recursive call q = p Account for cost recursively. Conditional branches q p 1 q p 2

108 Linear Constraints have a Simple Form Pay for constant cost q = q 0 + c Network constraints. Account for size changes q 0 i = q i + q i+1 Flow through an edge is used twice. Recursive call q = p Account for cost recursively. Conditional branches q p 1 q p 2 Cover cost in both branches (possible waste).

109 Accounting for Size Change List types: Potential: L (q 1,...,q k ) (A) (` : L (q 1,...,q k ) )= P i=1,...,k q i ` i Additive shift: C(q 1,...,q k )=(q 1 + q 2,...,q k 1 + q k, q k ) X i=1,...,k n +1 q i i = q 1 + X i=1,...,k 1 q i+1 n i + X i=1,...,k q i n i

110 Accounting for Size Change List types: Potential: L (q 1,...,q k ) (A) (` : L (q 1,...,q k ) )= P i=1,...,k q i ` i Additive shift: C(q 1,...,q k )=(q 1 + q 2,...,q k 1 + q k, q k ) potential of a list X i=1,...,k n +1 q i i = q 1 + X i=1,...,k 1 q i+1 n i + X i=1,...,k q i n i

111 Accounting for Size Change List types: Potential: L (q 1,...,q k ) (A) (` : L (q 1,...,q k ) )= P i=1,...,k q i ` i Additive shift: C(q 1,...,q k )=(q 1 + q 2,...,q k 1 + q k, q k ) potential of a list constant potential of the tail using the shift X i=1,...,k n +1 q i i = q 1 + X i=1,...,k 1 q i+1 n i + X i=1,...,k q i n i

112 Generation of Linear Constraints 1. It is easy to pass potential to list tails without loss ((x::xs) :L ~q )+c = (xs : L C(~q) )+(q 1 + c) 2. Pattern: one recursive call and polynomial spill ((x::xs):l ~q ) (xs:l ~q )= (xs:l (q 2,...,q k,0) )+q 1 3. It is easy to share potential when aliasing data (` : L ~q+~p )= (` : L ~q )+ (` : L ~p )

113 Generation of Linear Constraints 1. It is easy to pass potential to list tails without loss C(q 1,...,q k )=(q 1 + q 2,...,q k 1 + q k, q k ) ((x::xs) :L ~q )+c = (xs : L C(~q) )+(q 1 + c) 2. Pattern: one recursive call and polynomial spill ((x::xs):l ~q ) (xs:l ~q )= (xs:l (q 2,...,q k,0) )+q 1 3. It is easy to share potential when aliasing data (` : L ~q+~p )= (` : L ~q )+ (` : L ~p )

114 Most Complex Constraints: Sharing f(x) = g(x,x) Assume cost of g(x,y) is 10 x y Bound for f is given as X q i x i i

115 Most Complex Constraints: Sharing f(x) = g(x,x) Assume cost of g(x,y) is 10 x y Bound for f is given as Need to covert q x 2 X x q i i to i X x q i i i

116 Most Complex Constraints: Sharing f(x) = g(x,x) Assume cost of g(x,y) is 10 x y Bound for f is given as Need to covert q x 2 X x q i i to i X x q i i i Constraints: q 1 =1 q q 2 =2 q q k =0 q for k > 2

117 Most Complex Constraints: Sharing f(x) = g(x,x) Assume cost of g(x,y) is 10 x y Bound for f is given as Need to covert q x 2 Constraints: X to i q i x i X i q i x i q 1 =1 q q 2 =2 q q k =0 q for k > 2 Coefficients for change of basis.

118 Constraint Solving in Practice LP solving of our constraints is linear in practice CLP and CPLEX are similar; lp_solve is slow (non-linear) Large programs (with high degree search space) have around 1 million constraints Solving 1 million constraints takes about 1 minute with CLP Generating the constraints takes about as much time as solving them

119 Automatic Amortized Resource Analysis Precise: bounds are multivariate resource polynomials Efficient: inference via linear programming Reliable: formal soundness proof of the bounds Verifiable: type derivation is a certificate Current and future research: Non-polynomial bounds Garbage collection Concurrency Better hardware models

120 Automatic Amortized Resource Analysis Precise: bounds are multivariate resource polynomials Efficient: inference via linear programming Reliable: formal soundness proof of the bounds Verifiable: type derivation is a certificate Current and future research: Non-polynomial bounds Garbage collection Web interface at Concurrency Better hardware models

Worst-Case Execution Time Analysis. LS 12, TU Dortmund

Worst-Case Execution Time Analysis. LS 12, TU Dortmund Worst-Case Execution Time Analysis Prof. Dr. Jian-Jia Chen LS 12, TU Dortmund 02, 03 May 2016 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 1 / 53 Most Essential Assumptions for Real-Time Systems Upper

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

A Multivariate Amortized Resource Analysis

A Multivariate Amortized Resource Analysis A Multivariate Amortized Resource Analysis JAN HOFFMANN, Yale University KLAUS AEHLIG and MARTIN HOFMANN, Ludwig-Maximilians-Universität München We study the problem of automatically analyzing the worst-case

More information

Multivariate Amortized Resource Analysis

Multivariate Amortized Resource Analysis Multivariate Amortized Resource Analysis JAN HOFFMANN, Yale University KLAUS AEHLIG and MARTIN HOFMANN, Ludwig-Maximilians-Universität München We study the problem of automatically analyzing the worst-case

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

Evaluation and Validation

Evaluation and Validation Evaluation and Validation Jian-Jia Chen (Slides are based on Peter Marwedel) TU Dortmund, Informatik 12 Germany Springer, 2010 2016 年 01 月 05 日 These slides use Microsoft clip arts. Microsoft copyright

More information

Normalization by Evaluation

Normalization by Evaluation Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9

More information

Asymptotic Algorithm Analysis & Sorting

Asymptotic Algorithm Analysis & Sorting Asymptotic Algorithm Analysis & Sorting (Version of 5th March 2010) (Based on original slides by John Hamer and Yves Deville) We can analyse an algorithm without needing to run it, and in so doing we can

More information

Worst-Case Execution Time Analysis. LS 12, TU Dortmund

Worst-Case Execution Time Analysis. LS 12, TU Dortmund Worst-Case Execution Time Analysis Prof. Dr. Jian-Jia Chen LS 12, TU Dortmund 09/10, Jan., 2018 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 1 / 43 Most Essential Assumptions for Real-Time Systems Upper

More information

Algorithms and Their Complexity

Algorithms and Their Complexity CSCE 222 Discrete Structures for Computing David Kebo Houngninou Algorithms and Their Complexity Chapter 3 Algorithm An algorithm is a finite sequence of steps that solves a problem. Computational complexity

More information

Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics

Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics Jan Hoffmann Martin Hofmann Ludwig-Maximilians-Universität München {jan.hoffmann,martin.hofmann}@ifi.lmu.de

More information

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions

More information

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 CakeML Has: references, modules, datatypes, exceptions, a FFI,... Doesn t have:

More information

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure Measuring Goodness of an Algorithm Asymptotic Analysis of Algorithms EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG 1. Correctness : Does the algorithm produce the expected output?

More information

A Certified Denotational Abstract Interpreter (Proof Pearl)

A Certified Denotational Abstract Interpreter (Proof Pearl) A Certified Denotational Abstract Interpreter (Proof Pearl) David Pichardie INRIA Rennes David Cachera IRISA / ENS Cachan (Bretagne) Static Analysis Static Analysis Static analysis by abstract interpretation

More information

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size. 10 2.2. CLASSES OF COMPUTATIONAL COMPLEXITY An optimization problem is defined as a class of similar problems with different input parameters. Each individual case with fixed parameter values is called

More information

CS6901: review of Theory of Computation and Algorithms

CS6901: review of Theory of Computation and Algorithms CS6901: review of Theory of Computation and Algorithms Any mechanically (automatically) discretely computation of problem solving contains at least three components: - problem description - computational

More information

Formal Verification of Mathematical Algorithms

Formal Verification of Mathematical Algorithms Formal Verification of Mathematical Algorithms 1 Formal Verification of Mathematical Algorithms John Harrison Intel Corporation The cost of bugs Formal verification Levels of verification HOL Light Formalizing

More information

A Short Introduction to Hoare Logic

A Short Introduction to Hoare Logic A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking

More information

Information Flow Inference for ML

Information Flow Inference for ML POPL 02 INRIA Rocquencourt Projet Cristal Francois.Pottier@inria.fr http://cristal.inria.fr/~fpottier/ Vincent.Simonet@inria.fr http://cristal.inria.fr/~simonet/ Information flow analysis account number

More information

Abstractions and Decision Procedures for Effective Software Model Checking

Abstractions and Decision Procedures for Effective Software Model Checking Abstractions and Decision Procedures for Effective Software Model Checking Prof. Natasha Sharygina The University of Lugano, Carnegie Mellon University Microsoft Summer School, Moscow, July 2011 Lecture

More information

Differential Privacy and Verification. Marco Gaboardi University at Buffalo, SUNY

Differential Privacy and Verification. Marco Gaboardi University at Buffalo, SUNY Differential Privacy and Verification Marco Gaboardi University at Buffalo, SUNY Given a program P, is it differentially private? P Verification Tool yes? no? Proof P Verification Tool yes? no? Given a

More information

Topic 17. Analysis of Algorithms

Topic 17. Analysis of Algorithms Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm

More information

Average Case Analysis. October 11, 2011

Average Case Analysis. October 11, 2011 Average Case Analysis October 11, 2011 Worst-case analysis Worst-case analysis gives an upper bound for the running time of a single execution of an algorithm with a worst-case input and worst-case random

More information

CS 4407 Algorithms Lecture 2: Growth Functions

CS 4407 Algorithms Lecture 2: Growth Functions CS 4407 Algorithms Lecture 2: Growth Functions Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline Growth Functions Mathematical specification of growth functions

More information

Binary Decision Diagrams and Symbolic Model Checking

Binary Decision Diagrams and Symbolic Model Checking Binary Decision Diagrams and Symbolic Model Checking Randy Bryant Ed Clarke Ken McMillan Allen Emerson CMU CMU Cadence U Texas http://www.cs.cmu.edu/~bryant Binary Decision Diagrams Restricted Form of

More information

Arrays and References in Resource Aware ML

Arrays and References in Resource Aware ML Arrays and References in Resource Aware ML Benjamin Lichtman and Jan Hoffmann Carnegie Mellon University Abstract. This article introduces a technique to accurately perform static prediction of resource

More information

DryVR: Data-driven verification and compositional reasoning for automotive systems

DryVR: Data-driven verification and compositional reasoning for automotive systems DryVR: Data-driven verification and compositional reasoning for automotive systems Chuchu Fan, Bolun Qi, Sayan Mitra, Mahesh Viswannathan University of Illinois at Urbana-Champaign CAV 2017, Heidelberg,

More information

IS 709/809: Computational Methods in IS Research Fall Exam Review

IS 709/809: Computational Methods in IS Research Fall Exam Review IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm

More information

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013 Chapter 2 Reductions and NP CS 573: Algorithms, Fall 2013 August 29, 2013 2.1 Reductions Continued 2.1.1 The Satisfiability Problem SAT 2.1.1.1 Propositional Formulas Definition 2.1.1. Consider a set of

More information

CS3719 Theory of Computation and Algorithms

CS3719 Theory of Computation and Algorithms CS3719 Theory of Computation and Algorithms Any mechanically (automatically) discretely computation of problem solving contains at least three components: - problem description - computational tool - analysis

More information

Software Verification

Software Verification Software Verification Grégoire Sutre LaBRI, University of Bordeaux, CNRS, France Summer School on Verification Technology, Systems & Applications September 2008 Grégoire Sutre Software Verification VTSA

More information

Program Verification Using Separation Logic

Program Verification Using Separation Logic Program Verification Using Separation Logic Cristiano Calcagno Adapted from material by Dino Distefano Lecture 1 Goal of the course Study Separation Logic having automatic verification in mind Learn how

More information

Analysis of Algorithms

Analysis of Algorithms Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Analysis of Algorithms Input Algorithm Analysis

More information

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Limitations of Algorithms We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds

More information

CISC 235: Topic 1. Complexity of Iterative Algorithms

CISC 235: Topic 1. Complexity of Iterative Algorithms CISC 235: Topic 1 Complexity of Iterative Algorithms Outline Complexity Basics Big-Oh Notation Big-Ω and Big-θ Notation Summations Limitations of Big-Oh Analysis 2 Complexity Complexity is the study of

More information

Computer Sciences Department

Computer Sciences Department Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Computer Sciences Department 3 ADVANCED TOPICS IN C O M P U T A B I L I T Y

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=

More information

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Why analysis? We want to predict how the algorithm will behave (e.g. running time) on arbitrary inputs, and how it will

More information

Computational Complexity

Computational Complexity Computational Complexity S. V. N. Vishwanathan, Pinar Yanardag January 8, 016 1 Computational Complexity: What, Why, and How? Intuitively an algorithm is a well defined computational procedure that takes

More information

Certification of Safe Polynomial Memory Bounds (Extended Version)

Certification of Safe Polynomial Memory Bounds (Extended Version) Certification of Safe Polynomial Memory Bounds (Extended Version) Javier de Dios and Ricardo Peña Departamento de Sistemas Informáticos y Computación Universidad Complutense de Madrid, Spain jdcastro@aventia.com,

More information

Running Time. Overview. Case Study: Sorting. Sorting problem: Analysis of algorithms: framework for comparing algorithms and predicting performance.

Running Time. Overview. Case Study: Sorting. Sorting problem: Analysis of algorithms: framework for comparing algorithms and predicting performance. Running Time Analysis of Algorithms As soon as an Analytic Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will arise -

More information

Aside: Golden Ratio. Golden Ratio: A universal law. Golden ratio φ = lim n = 1+ b n = a n 1. a n+1 = a n + b n, a n+b n a n

Aside: Golden Ratio. Golden Ratio: A universal law. Golden ratio φ = lim n = 1+ b n = a n 1. a n+1 = a n + b n, a n+b n a n Aside: Golden Ratio Golden Ratio: A universal law. Golden ratio φ = lim n a n+b n a n = 1+ 5 2 a n+1 = a n + b n, b n = a n 1 Ruta (UIUC) CS473 1 Spring 2018 1 / 41 CS 473: Algorithms, Spring 2018 Dynamic

More information

Discrete Event Simulation. Motive

Discrete Event Simulation. Motive Discrete Event Simulation These slides are created by Dr. Yih Huang of George Mason University. Students registered in Dr. Huang's courses at GMU can make a single machine-readable copy and print a single

More information

Deductive Verification

Deductive Verification Deductive Verification Mooly Sagiv Slides from Zvonimir Rakamaric First-Order Logic A formal notation for mathematics, with expressions involving Propositional symbols Predicates Functions and constant

More information

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated

More information

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University Intelligent Agents Formal Characteristics of Planning Ute Schmid Cognitive Systems, Applied Computer Science, Bamberg University Extensions to the slides for chapter 3 of Dana Nau with contributions by

More information

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop

More information

Compiler Optimisation

Compiler Optimisation Compiler Optimisation 8 Dependence Analysis Hugh Leather IF 1.18a hleather@inf.ed.ac.uk Institute for Computing Systems Architecture School of Informatics University of Edinburgh 2018 Introduction This

More information

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40 Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike

More information

Quantum Functional Programming Language & Its Denotational Semantics

Quantum Functional Programming Language & Its Denotational Semantics Quantum Functional Programming Language & Its Denotational Semantics Ichiro Hasuo Dept. Computer Science University of Tokyo Naohiko Hoshino Research Inst. for Math. Sci. Kyoto University Talk based on:

More information

ICS 252 Introduction to Computer Design

ICS 252 Introduction to Computer Design ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]

More information

Bounded Expectations: Resource Analysis for Probabilistic Programs.

Bounded Expectations: Resource Analysis for Probabilistic Programs. Bounded Expectations: Resource Analysis for Probabilistic Programs Van Chan Ngo Carnegie Mellon University, USA Abstract This paper presents a new static analysis for deriving upper bounds on the expected

More information

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming Algorithms and Theory of Computation Lecture 9: Dynamic Programming Xiaohui Bei MAS 714 September 10, 2018 Nanyang Technological University MAS 714 September 10, 2018 1 / 21 Recursion in Algorithm Design

More information

ANALYZING REAL TIME LINEAR CONTROL SYSTEMS USING SOFTWARE VERIFICATION. Parasara Sridhar Duggirala UConn Mahesh Viswanathan UIUC

ANALYZING REAL TIME LINEAR CONTROL SYSTEMS USING SOFTWARE VERIFICATION. Parasara Sridhar Duggirala UConn Mahesh Viswanathan UIUC ANALYZING REAL TIME LINEAR CONTROL SYSTEMS USING SOFTWARE VERIFICATION Parasara Sridhar Duggirala UConn Mahesh Viswanathan UIUC Real-Time Systems Linear Control Systems Verification Verification Control

More information

Running Time Evaluation

Running Time Evaluation Running Time Evaluation Quadratic Vs. Linear Time Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 19 1 Running time 2 Examples 3 Big-Oh, Big-Omega, and Big-Theta Tools 4 Time

More information

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note

More information

Proof-producing decompilation and compilation

Proof-producing decompilation and compilation Proof-producing decompilation and compilation Magnus Myreen May 2008 Introduction This talk concerns verification of functional correctness of machine code for commercial processors (ARM, PowerPC, x86...

More information

Theory of Computer Science

Theory of Computer Science Theory of Computer Science E1. Complexity Theory: Motivation and Introduction Malte Helmert University of Basel May 18, 2016 Overview: Course contents of this course: logic How can knowledge be represented?

More information

Embedded Systems 23 BF - ES

Embedded Systems 23 BF - ES Embedded Systems 23-1 - Measurement vs. Analysis REVIEW Probability Best Case Execution Time Unsafe: Execution Time Measurement Worst Case Execution Time Upper bound Execution Time typically huge variations

More information

The Underlying Semantics of Transition Systems

The Underlying Semantics of Transition Systems The Underlying Semantics of Transition Systems J. M. Crawford D. M. Goldschlag Technical Report 17 December 1987 Computational Logic Inc. 1717 W. 6th St. Suite 290 Austin, Texas 78703 (512) 322-9951 1

More information

N/4 + N/2 + N = 2N 2.

N/4 + N/2 + N = 2N 2. CS61B Summer 2006 Instructor: Erin Korber Lecture 24, 7 Aug. 1 Amortized Analysis For some of the data structures we ve discussed (namely hash tables and splay trees), it was claimed that the average time

More information

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2 Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula

More information

Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2

Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula

More information

Algorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik

Algorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik Algorithms Grad Refresher Course 2011 University of British Columbia Ron Maharik maharik@cs.ubc.ca About this talk For those incoming grad students who Do not have a CS background, or Have a CS background

More information

19. Extending the Capacity of Formal Engines. Bottlenecks for Fully Automated Formal Verification of SoCs

19. Extending the Capacity of Formal Engines. Bottlenecks for Fully Automated Formal Verification of SoCs 19. Extending the Capacity of Formal Engines 1 19. Extending the Capacity of Formal Engines Jacob Abraham Department of Electrical and Computer Engineering The University of Texas at Austin Verification

More information

Theory of Computer Science. Theory of Computer Science. E1.1 Motivation. E1.2 How to Measure Runtime? E1.3 Decision Problems. E1.

Theory of Computer Science. Theory of Computer Science. E1.1 Motivation. E1.2 How to Measure Runtime? E1.3 Decision Problems. E1. Theory of Computer Science May 18, 2016 E1. Complexity Theory: Motivation and Introduction Theory of Computer Science E1. Complexity Theory: Motivation and Introduction Malte Helmert University of Basel

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture II: Chapter 2 R. Paul Wiegand George Mason University, Department of Computer Science February 1, 2006 Outline 1 Analysis Framework 2 Asymptotic

More information

Industrial Automation (Automação de Processos Industriais)

Industrial Automation (Automação de Processos Industriais) Industrial Automation (Automação de Processos Industriais) Discrete Event Systems http://users.isr.ist.utl.pt/~jag/courses/api1516/api1516.html Slides 2010/2011 Prof. Paulo Jorge Oliveira Rev. 2011-2015

More information

Computational Models Lecture 8 1

Computational Models Lecture 8 1 Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Introduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014

Introduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014 Introduction Pedro Cabalar Department of Computer Science University of Corunna, SPAIN cabalar@udc.es 2013/2014 P. Cabalar ( Department Introduction of Computer Science University of Corunna, SPAIN2013/2014

More information

Computation of Alias Sets from Shape Graphs for Comparison of Shape Analysis Precision

Computation of Alias Sets from Shape Graphs for Comparison of Shape Analysis Precision for Comparison of Shape Analysis Precision Viktor Pavlu, 1 Markus Schordan, 2 Andreas Krall 1 1 Vienna University of Technology 2 University of Applied Sciences Technikum Wien SCAM 2011, Williamsburg September

More information

Atomic Fragments of Petri Nets Extended Abstract

Atomic Fragments of Petri Nets Extended Abstract Atomic Fragments of Petri Nets Extended Abstract Monika Heiner 1, Harro Wimmel 2, and Karsten Wolf 2 1 Brunel University Uxbridge/London, on sabbatical leave from Brandenburgische Technische Universität

More information

Introduction. How can we say that one algorithm performs better than another? Quantify the resources required to execute:

Introduction. How can we say that one algorithm performs better than another? Quantify the resources required to execute: Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Section 2.3 of Rosen cse235@cse.unl.edu Introduction How can we say that one algorithm

More information

COMP 382: Reasoning about algorithms

COMP 382: Reasoning about algorithms Fall 2014 Unit 4: Basics of complexity analysis Correctness and efficiency So far, we have talked about correctness and termination of algorithms What about efficiency? Running time of an algorithm For

More information

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k. Complexity Theory Problems are divided into complexity classes. Informally: So far in this course, almost all algorithms had polynomial running time, i.e., on inputs of size n, worst-case running time

More information

Lecture: Workload Models (Advanced Topic)

Lecture: Workload Models (Advanced Topic) Lecture: Workload Models (Advanced Topic) Real-Time Systems, HT11 Martin Stigge 28. September 2011 Martin Stigge Workload Models 28. September 2011 1 System

More information

Probabilistic Guarded Commands Mechanized in HOL

Probabilistic Guarded Commands Mechanized in HOL Probabilistic Guarded Commands Mechanized in HOL Joe Hurd joe.hurd@comlab.ox.ac.uk Oxford University Joint work with Annabelle McIver (Macquarie University) and Carroll Morgan (University of New South

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms (2017F) Lecture4: Analysis of Algorithms Daijin Kim CSE, POSTECH dkim@postech.ac.kr Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically

More information

SAT, NP, NP-Completeness

SAT, NP, NP-Completeness CS 473: Algorithms, Spring 2018 SAT, NP, NP-Completeness Lecture 22 April 13, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Part I Reductions Continued Ruta (UIUC)

More information

Sparse Polynomial Multiplication and Division in Maple 14

Sparse Polynomial Multiplication and Division in Maple 14 Sparse Polynomial Multiplication and Division in Maple 4 Michael Monagan and Roman Pearce Department of Mathematics, Simon Fraser University Burnaby B.C. V5A S6, Canada October 5, 9 Abstract We report

More information

A point p is said to be dominated by point q if p.x=q.x&p.y=q.y 2 true. In RAM computation model, RAM stands for Random Access Model.

A point p is said to be dominated by point q if p.x=q.x&p.y=q.y 2 true. In RAM computation model, RAM stands for Random Access Model. In analysis the upper bound means the function grows asymptotically no faster than its largest term. 1 true A point p is said to be dominated by point q if p.x=q.x&p.y=q.y 2 true In RAM computation model,

More information

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes. Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci

More information

Inductive Theorem Proving

Inductive Theorem Proving Introduction Inductive Proofs Automation Conclusion Automated Reasoning P.Papapanagiotou@sms.ed.ac.uk 11 October 2012 Introduction Inductive Proofs Automation Conclusion General Induction Theorem Proving

More information

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office? N P NP Completeness Announcements Friday Four Square! Today at 4:15PM, outside Gates. Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Explore P, NP, and their connection. Did

More information

PetaBricks: Variable Accuracy and Online Learning

PetaBricks: Variable Accuracy and Online Learning PetaBricks: Variable Accuracy and Online Learning Jason Ansel MIT - CSAIL May 4, 2011 Jason Ansel (MIT) PetaBricks May 4, 2011 1 / 40 Outline 1 Motivating Example 2 PetaBricks Language Overview 3 Variable

More information

Problem-Solving via Search Lecture 3

Problem-Solving via Search Lecture 3 Lecture 3 What is a search problem? How do search algorithms work and how do we evaluate their performance? 1 Agenda An example task Problem formulation Infrastructure for search algorithms Complexity

More information

Effective Entropy for Memory Randomization Defenses

Effective Entropy for Memory Randomization Defenses Effective Entropy for Memory Randomization Defenses William Herlands, Thomas Hobson, Paula Donovan 7 th Workshop on Cyber Security Experimentation and Test 18 August 2014 This work is sponsored by Assistant

More information

Randomized algorithms. Inge Li Gørtz

Randomized algorithms. Inge Li Gørtz Randomized algorithms Inge Li Gørtz Randomized algorithms Today What are randomized algorithms? Properties of randomized algorithms Two examples: Median/Select. Quick-sort Randomized Algorithms Randomized

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

1 Introduction (January 21)

1 Introduction (January 21) CS 97: Concrete Models of Computation Spring Introduction (January ). Deterministic Complexity Consider a monotonically nondecreasing function f : {,,..., n} {, }, where f() = and f(n) =. We call f a step

More information

Kim Guldstrand Larsen DENMARK

Kim Guldstrand Larsen DENMARK Quantitative Modal Transition Systems Kim Guldstrand Larsen Aalborg University Aalborg University, DENMARK The Early Days Edinburgh 83-85 Kim Larsen [2] Milner Symposium, Edinburgh, April 16-18, 2012 Original

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Spring 2017-2018 Outline 1 Sorting Algorithms (contd.) Outline Sorting Algorithms (contd.) 1 Sorting Algorithms (contd.) Analysis of Quicksort Time to sort array of length

More information

Definition: Alternating time and space Game Semantics: State of machine determines who

Definition: Alternating time and space Game Semantics: State of machine determines who CMPSCI 601: Recall From Last Time Lecture 3 Definition: Alternating time and space Game Semantics: State of machine determines who controls, White wants it to accept, Black wants it to reject. White wins

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computational tractability asymptotic order of growth survey of common running times Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Time and Timed Petri Nets

Time and Timed Petri Nets Time and Timed Petri Nets Serge Haddad LSV ENS Cachan & CNRS & INRIA haddad@lsv.ens-cachan.fr DISC 11, June 9th 2011 1 Time and Petri Nets 2 Timed Models 3 Expressiveness 4 Analysis 1/36 Outline 1 Time

More information

Integer Clocks and Local Time Scales

Integer Clocks and Local Time Scales Integer Clocks and Local Time Scales Part I Part II Adrien Guatto ENS - PARKAS SYNCHRON 2014 Adrien Guatto (ENS - PARKAS) Integer Clocks and Local Time Scales SYNCHRON 2014 1 / 31 Part I Adrien Guatto

More information