Software Analysis (POPA Sec , )

Size: px
Start display at page:

Download "Software Analysis (POPA Sec , )"

Transcription

1 Software Analysis (POPA Sec , ) Klaus Ostermann Based on slides by Jurriaan Hage

2 Overview Correctness proof Live Variables Analysis The While language with procedures

3 Live Variables Analysis (slight return) Determine for every program point, the set of variables whose value may still be used later (i.e. after the exit of the point). [x := 2] 1 ; [y := 4] 2 ; [x := 1] 3 ; (if [y>0] 4 then [z := y] 5 else [z := x*x] 6 ); [x := z] 7 ; x is not live at the exit of 1, but it is at the exit of 3 May/backward analysis: take the union of live variables of the statements following the current one. The lattice consists of sets of variables from the program.

4 Transfer functions (the ones from the book) kill LV ([x := a] l ) kill LV ([skip] l ) kill LV ([b] l ) gen LV ([x := a] l ) gen LV ([skip] l ) gen LV ([b] l ) = {x} = = = FV (a) = = FV (b) LV exit (l) = { if l final(s ) {LV entry(l ) (l, l) flow R (S )} otherwise LVentry(l) = (LV exit (l) kill LV (B l )) gen LV (B l )

5 What do we prove? For every program, if two states σ 1 and σ 2 have the same values for the variables which are live at the start of the program, then the result is the same whether we use σ 1 or σ 2. Try to keep this goal in mind. Implies the soundness of the following optimization: If a variable becomes live: allocate memory for it If a variable disappears from the set (for a while at least), you may reuse its memory space. The proof is by induction on the structure of the execution: Every step in the program preserves the correctness of the outcome.

6 The proof step by step Turn the equation system into an equivalent constraint based system Prove that the two systems have the same least solution Prove a number of small, but useful lemma s Prove preservation of semantically correct liveness information under each single step of the execution. Conclude that it holds for all executions (finite and infinite)

7 Constraint based version { if l final(s ) LV exit (l)= {LV entry(l ) (l, l) flow R (S )} otherwise LVentry(l)=(LV exit (l) kill LV (B l )) gen LV (B l ) is changed to { if l final(s ) LV exit (l) {LV entry(l ) (l, l) flow R (S )} otherwise LVentry(l) (LV exit (l) kill LV (B l )) gen LV (B l ) The least solutions are the same, so we can use either one Intuition: we write = all the time, but we use it one sided only. Motivation: makes the proof easier. Tarski again (Prop. A.10): lfp(f ) = Red(f ) The smallest fixpoint and smallest reductive point coincide.

8 The proof step by step Turn the equation system into an equivalent contraint based system Prove that the two systems have the same least solution Prove a number of small, but useful lemma s Prove preservation of semantically correct liveness information under each single step of the execution. Conclude that it holds for all executions (finite and infinite)

9 Lemma 2.16 We write X, N = LV (S) if the functions X : Lab P(Var ) and N : Lab P(Var ) are a solution of the constraint system. In the book X, N are first called live exit and live entry. Lemma 2.16: If X, N = LV (S 1 ) (S 1 uniquely labelled) and S 2 a subprogram of S 1, then X, N = LV (S 2 ) and S 2 uniquelly labelled. Intuitively: a solution to a program is also one for its sub programs, By sub program we mean not only proper syntactic subprograms but also programs assembled from parts of the program (see Lemma 2.14 in the book) Reason: We can say that reduction produces subprograms. because a subprogram never gives more constraints (but maybe less)

10 Lemma 2.16 illustrated Program 1: [x := 10] 1 ; [z := x+1] 2 ; has equations X (2) = N(2) = (X (2) {z}) {x} X (1) = N(2) N(1) = X (1) {x}. Least fixed point: [x := 10] 1 {x}; {x} [z := x+1] 2 ; Program 2: [x := 10] 1 ; has equations X (1) = and N(1) = X (1) {x}. Least fixed point: [x := 10] 1 ; Solution program 1 is not a solution for program 2. Subset constraints for program 2: X (1) and N(1) X (1) {x}. Solution program 1 does satisfy subset constraints for program 2. Solution is not the best; it implies keeping the value for x while it is not live,...but it is safe.

11 Corollary 2.17 Corollary 2.17: step using operational semantics preserves solution: If X, N = LV (S) and S, σ S, σ, then X, N = LV (S ). Proof Reduction relation produces subprograms. a subprogram gives fewer (or the same) constraints (Lemma 2.16) Does unrolling a while loop give a subprogram? Yes! Code is duplicated, but no new labels and no new edges

12 The proof step by step Turn the equation system into an equivalent contraint based system Prove that the two systems have the same least solution Prove a number of small, but useful lemma s Prove preservation of semantically correct liveness information under each single step of the execution. Conclude that it holds for all executions (finite and infinite)

13 Equivalent environments σ 1 V σ 2 if and only if x V : σ 1 (x) = σ 2 (x) σ1 and σ 2 are V -equivalent. Environments are considered equal if and only if they store the same values for variables in V. We shall prove: the executions of S with two V -equivalent environments give the same result, if V = N(init(S)). Example: {y} [x := 10] 1 {y,x}; {y,x} [y := y+x] 2 ; Execute with environments σ1 = [x 12; y 0; z 5] σ 2 = [x 38; y 0; z 0]

14 Theorem 2.21 Before execution, the analysis is performed, and we have sets X (l) and N(l) available in every program point. Given that we have a solution for S: X, N = LV (S). Theorem 2.21: If S, σ 1 σ 1 and σ 1 N(init(S)) σ 2, then there exists σ 2 such that S, σ 2 σ 2 and σ 1 X (init(s)) σ 2. Intuition: if we have correspondence before the (terminating) execution step, we can find corresponding environments after the (terminating) execution step. Similarly for the non-terminating execution steps. We will only show the two sample cases of the proof; full details are in the book. Theorem 2.21 has another case for the 4-ary reduction relation, see next but one slide.

15 A base case for Theorem 2.21 Given that we have a solution for S: X, N = LV (S). Theorem 2.21: If S, σ 1 σ 1 and σ 1 N(init(S)) σ 2, then there exists σ 2 such that S, σ 2 σ 2 and σ 1 X (init(s)) σ 2. Assignment case S = x := a: By the semantics σ 1 = σ 1 [x A a σ 1 ] Choose σ 2 = σ 2 [x A a σ 2 ]. From the constraints: N(init(S)) (X (init(s)) {x}) FV(a). Hence σ 1 and σ 2 correspond on all variables in a. Because of σ 1 N(init(S)) σ2 Hence A a σ1 = A a σ 2, because a s value depends only on variables occuring in it and these variables are in the set of variables live before the assignment So σ 1 X (init(s)) σ 2, as required.

16 An inductive case for Theorem 2.21 Assume we have a solution for S: X, N = LV (S). Theorem 2.21: If S, σ 1 S, σ 1 and σ 1 σ N(init(S)) 2, then there exists σ 2 such that S, σ 2 S, σ 2 and σ 1 N(init(S )) σ 2. seq 1 : S 1 ; S 2, σ 1 S 1 ; S 2, σ 1 (so S = S 1; S 2 and S = S 1 ; S 2). Operational semantics implies S 1, σ 1 S 1, σ 1. S 1 is a subprogram of S 1 ; S 2 : Lemma 2.16 implies solution for S 1 ; S 2 is also one for S 1. Apply Theorem 2.21 to smaller program fragment S 1 : If X, N = LV (S 1 ) then if S 1, σ 1 S 1, σ 1 and σ 1 N(init(S 1 )) σ 2, then there exists σ such that S 1, σ 2 S 1, σ 2 and σ 1 N(init(S 1 )) σ 2 Take σ 2 equal to σ 2. This works, because N(init(S 1 )) = N(init(S 1 ; S 2 )) and N(init(S 1 )) = N(init(S 1 ; S 2) 2

17 The proof step by step Turn the equation system into an equivalent contraint based system Prove that the two systems have the same least solution Prove a number of small, but useful lemma s Prove preservation of semantically correct liveness information under each single step of the execution. Conclude that it holds for all executions (finite and infinite)

18 The main result and some reflections If we start with two possibly different environments σ 1 and σ 2 that correspond on the initially live variables, then the two executions still give equivalent answers. Follows by induction on the length of the derivation/execution. Validates various optimizations: restrict environment to live variables. Extend and shrink along the way as needed. Assignments to non-live variables can be skipped. Maximum memory use is the maximum of the memory usage over all sets of live variables X (l) and N(l).

19 More reflections Soundness proof boils down to systematically checking that all equations are correct by examining all different types of execution steps. For instance: if we had wrongly chosen gen LV ([x := a] l ) =, then it is possible that A a σ 1 A a σ 2, because σ 1 and σ 2 could differ on some variables in a. Important to figure out is what you need to prove. The actual soundness result is formulated differently for each analysis. But the structure is usually the same.

20 Procedural programming Any sensible programming language supports procedures or functions in some form. The main complications that will arise are: The semantics should include a stack (of some kind). How do we propagate analysis information into and from procedures? A procedure can be jumped to from arbitrarily many locations. Do we join the results over all possible callers? How do we know where to return? What if we blindly propagate a single analysis result to all return locations? There is a focus on forward analysis for the procedural While.

21 Adding procedures to While Extend the While-language with procedures A program takes the form: begin D S end D is a sequence of procedure declarations: proc p(val x, res y) is ln S end lx x and y are formal parameters and local to p A procedure call is a statement: [call p(a,z)] lc l r a is passed by-value and can be any arithmetic expression z is call-by-result: it can only be used to pass the result back

22 Information about programs New block types: is, end and call (...) Entry and exit labels attached to is and end Call and return labels attached to call Add new kind of flow: (lc ; l n ) for procedure call/entry (lx ; l r ) for procedure exit/return Assume all programs are statically correct: only calls to existing procedures, all labels and procedure names unique.

23 An example program begin proc fib(val z, u, res v) is 1 if [z<3] 2 then [v := 1] 3 else ([call fib(z-2,0,u)] 4 5 ; [call fib(z-1,0,v)] 6 7 ; [v := v+u] 11 ) end 8 ; [call fib(x,0,y)] 9 10 end For notational simplicity, the syntax allows one by-value argument and one return parameter. In examples we do not hold to this restriction. Mimicking local variables: add by-value parameters (like u) Variables x and y have global scope The scope of u, v and z is limited to the body of fib.

24 The flow graph [call fib(x,0,y)] 9 10 is 1 [z<3] 2 yes [v := 1] 3 no [call fib(z-2,0,u)] 4 5 [call fib(z-1,0,v)] 6 7 end 8 [v := u+v] 11

25 A different memory model Recursion implies multiple instances of local variables may exist. To distinguish these, we use multiple locations for a variable Every location ξ Loc contains an integer An environment ρ Env = Var Loc maps each variable currently in scope to its unique location. Only one occurrence of a variable can be in scope at any time. ς Store = Loc fin Z describes the store (memory) of a program execution: only finite memory in use at all times. Given a variable x currently in scope, its value is ς(ρ(x)): The environment ρ tells us the location, The store ς gives us the value at that location. To access different incarnations of x we use a modified environment ρ, but the same store ς. We assume ς ρ : Var Z is total: every variable in use has a location

26 Changing the old operational semantics ass [x := a] l, σ σ[x A a σ] assnew ρ [x := a] l, ς ς[ρ(x) A a (ς ρ)] Recall: ς = ς[y n] is such that ς (y) = n and ς (x) = ς(x) for x y. Evaluation is within the context of a given environment ρ environment = symbol table for the current scope Values of variables are computed using ς ρ This is the environment σ of the old set up. Updates on x are performed on the store ς at location ρ(x) Assignment changes the store, not the environment.

27 Executing procedure calls Main effect is to modify the environment: Reserve locations in the store for the new instances of local variables. Update the environment to reflect the fact that these variables possibly replace previously allocated ones with the same name. Store the value of the expression in the location of the by-value parameter. Remember where the variables now out of scope reside. ρ [call p(a,z)] lc l r, ς bind ρ[x ξ 1, y ξ 2 ] in S then z := y, ς where proc p(val x, res y) in S end is a procedure declaration. ξ1, ξ 2 are fresh locations for x and y, ς = ς[ξ 1 A a (ς ρ), ξ 2 v], v is an arbitrary value (could be 0). Bindings call stack with activation records.

28 Executing within a new environment Execution of the code continues with the new environment: ρ S, ς S, ς ρ bind ρ in S then z := y, ς bind ρ in S then z := y, ς Rule for bind guarantees environment of innermost bind is used to execute statements. When the procedure finishes, the outer environment will be used again after assigning the result of the procedure execution to the correct location: ρ S, ς ς ρ bind ρ in S then z := y, ς ς [ρ(z) ς (ρ (y))] Note the use of the two different environments on exiting the procedure. In implementations, the store is usually a globally accessible memory which is continually updated. Executing fib(x, 0, y) with x 3 and y 0

29 Meet over all valid paths: MVP We first generalize the utopian MOP ctx and MOP efct solutions to the more precise MVP ctx and MVP efct. Afterwards we shall consider how to adapt monotone frameworks. Paths up to l: vpath ctx (l) = {[l 1,..., l n 1 ] n 1, l n = l, [l 1,..., l n ] a valid path} MVP ctx (l) = {f l (ι) l vpath ctx (l)} Similarly for the closed case, MVP efct (l). But what is a valid path?

30 Unbalance and poisoning begin proc neg(val z, res u) is 1 [u := -z] 2 ) end 3 ; [call neg(-1,p)] 5 6 ; [call neg(1,n)] 7 8 end Blindly extending path ctx and path efct to also include edges like (5; 1) also yields impossible execution paths like [5, 1, 2, 3, 8] Suppose we want to track the signs of all variables. One call to neg influences (poisons) all others. Information about the first call to neg also flows to the second call. Is that reasonable? path ctx and path efct do not guarantee that the label of a call is paired correctly with the label of the return. Instead, we want to consider only valid paths, that are balanced. In the book valid paths are generated by a context free

31 Use valid paths and context instead Issues when defining valid paths As we just saw, executions must be balanced. During analysis we only consider finite prefixes of executions, but should not forget finite prefixes of infinite executions. Context will be used to enforce balance: It can simulate the behaviour of a stack for calling procedures. Even if we disallow unbalanced paths, there is still an influence between different calls, unless we make sure each call has its own analysis result. For that we can use context too!

32 Interprocedural flows The previous slides motivate a need to distinguish interprocedural and intraprocedural flow. For the fibonacci program: flow(s ) = {(1, 2), (2, 3), (3, 8), (2, 4), (4; 1), (8; 5), (5, 6), (6; 1), (8; 7), (7, 11), (11, 8), (9; 1), (8; 10)} Interprocedural: inter-flow(s ) = {(9, 1, 8, 10), (4, 1, 8, 5), (6, 1, 8, 7)} 4-tuples of call and corresponding return information. (9, 1, 8, 5) / inter-flow(s ) init(s ) = 9 and final(s ) = {10} Backward variants exist: flow R and inter-flow R

33 The flow graph again [call fib(x,0,y)] 9 10 is 1 [z<3] 2 yes [v := 1] 3 no [call fib(z-2,0,u)] 4 5 [call fib(z-1,0,v)] 6 7 end 8 [v := u+v] 11

34 Intermediate summary Changes to the programming language have now been made. syntax, scoping rules, semantics, MOP is generalized to MVP Now come the changes to the monotone framework reuse as much as possible of intraprocedural monotone framework, transfer functions for the new statements, distinguish between certain execution paths via context.

Software Analysis (POPA Sec. 2.5.3, 2.5.4, 2.5.6)

Software Analysis (POPA Sec. 2.5.3, 2.5.4, 2.5.6) Software Analysis (POPA Sec. 2.5.3, 2.5.4, 2.5.6) Klaus Ostermann Based on slides by Jurriaan Hage Towards embellished monotone frameworks From monotone framework to embellished monotone framework. We

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

[Refer Slide Time: 05:10]

[Refer Slide Time: 05:10] Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

The Graphical Method: An Example

The Graphical Method: An Example The Graphical Method: An Example Consider the following linear program: Maximize 4x 1 +3x 2 Subject to: 2x 1 +3x 2 6 (1) 3x 1 +2x 2 3 (2) 2x 2 5 (3) 2x 1 +x 2 4 (4) x 1, x 2 0, where, for ease of reference,

More information

15-150 Lecture 11: Tail Recursion; Continuations

15-150 Lecture 11: Tail Recursion; Continuations 15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail

More information

CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

More information

1 if 1 x 0 1 if 0 x 1

1 if 1 x 0 1 if 0 x 1 Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

More information

Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007

Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007 Constant Propagation Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007 Osnat Minz and Mati Shomrat Introduction This

More information

Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series

Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series Sequences and Series Overview Number of instruction days: 4 6 (1 day = 53 minutes) Content to Be Learned Write arithmetic and geometric sequences both recursively and with an explicit formula, use them

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1. MATH10212 Linear Algebra Textbook: D. Poole, Linear Algebra: A Modern Introduction. Thompson, 2006. ISBN 0-534-40596-7. Systems of Linear Equations Definition. An n-dimensional vector is a row or a column

More information

each college c i C has a capacity q i - the maximum number of students it will admit

each college c i C has a capacity q i - the maximum number of students it will admit n colleges in a set C, m applicants in a set A, where m is much larger than n. each college c i C has a capacity q i - the maximum number of students it will admit each college c i has a strict order i

More information

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution 16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

More information

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010 CS 598CSC: Combinatorial Optimization Lecture date: /4/010 Instructor: Chandra Chekuri Scribe: David Morrison Gomory-Hu Trees (The work in this section closely follows [3]) Let G = (V, E) be an undirected

More information

C H A P T E R Regular Expressions regular expression

C H A P T E R Regular Expressions regular expression 7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

More information

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES 136 TER 4. INDUCTION, GRHS ND TREES 4.3 Graphs In this chapter we introduce a fundamental structural idea of discrete mathematics, that of a graph. Many situations in the applications of discrete mathematics

More information

Triangle deletion. Ernie Croot. February 3, 2010

Triangle deletion. Ernie Croot. February 3, 2010 Triangle deletion Ernie Croot February 3, 2010 1 Introduction The purpose of this note is to give an intuitive outline of the triangle deletion theorem of Ruzsa and Szemerédi, which says that if G = (V,

More information

On strong fairness in UNITY

On strong fairness in UNITY On strong fairness in UNITY H.P.Gumm, D.Zhukov Fachbereich Mathematik und Informatik Philipps Universität Marburg {gumm,shukov}@mathematik.uni-marburg.de Abstract. In [6] Tsay and Bagrodia present a correct

More information

A Propositional Dynamic Logic for CCS Programs

A Propositional Dynamic Logic for CCS Programs A Propositional Dynamic Logic for CCS Programs Mario R. F. Benevides and L. Menasché Schechter {mario,luis}@cos.ufrj.br Abstract This work presents a Propositional Dynamic Logic in which the programs are

More information

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

More information

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION TAKE-AWAY GAMES ALLEN J. SCHWENK California Institute of Technology, Pasadena, California L INTRODUCTION Several games of Tf take-away?f have become popular. The purpose of this paper is to determine the

More information

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 Proofs Intuitively, the concept of proof should already be familiar We all like to assert things, and few of us

More information

Cartesian Products and Relations

Cartesian Products and Relations Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

More information

facultad de informática universidad politécnica de madrid

facultad de informática universidad politécnica de madrid facultad de informática universidad politécnica de madrid On the Confluence of CHR Analytical Semantics Rémy Haemmerlé Universidad olitécnica de Madrid & IMDEA Software Institute, Spain TR Number CLI2/2014.0

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

More information

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES I GROUPS: BASIC DEFINITIONS AND EXAMPLES Definition 1: An operation on a set G is a function : G G G Definition 2: A group is a set G which is equipped with an operation and a special element e G, called

More information

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac. Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free

More information

Static Analysis. Find the Bug! 15-654: Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled

Static Analysis. Find the Bug! 15-654: Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled Static Analysis 15-654: Analysis of Software Artifacts Jonathan Aldrich 1 Find the Bug! Source: Engler et al., Checking System Rules Using System-Specific, Programmer-Written Compiler Extensions, OSDI

More information

Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links)

Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links) Class 9 Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links) Readings on pointer analysis Problem Set 5: due 9/22/09 Project proposal

More information

Lecture 17 : Equivalence and Order Relations DRAFT

Lecture 17 : Equivalence and Order Relations DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/31/2011 Lecture 17 : Equivalence and Order Relations Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last lecture we introduced the notion

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

Fairness in Routing and Load Balancing

Fairness in Routing and Load Balancing Fairness in Routing and Load Balancing Jon Kleinberg Yuval Rabani Éva Tardos Abstract We consider the issue of network routing subject to explicit fairness conditions. The optimization of fairness criteria

More information

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

More information

Chapter 9. Systems of Linear Equations

Chapter 9. Systems of Linear Equations Chapter 9. Systems of Linear Equations 9.1. Solve Systems of Linear Equations by Graphing KYOTE Standards: CR 21; CA 13 In this section we discuss how to solve systems of two linear equations in two variables

More information

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

More information

9.2 Summation Notation

9.2 Summation Notation 9. Summation Notation 66 9. Summation Notation In the previous section, we introduced sequences and now we shall present notation and theorems concerning the sum of terms of a sequence. We begin with a

More information

Static Taint-Analysis on Binary Executables

Static Taint-Analysis on Binary Executables Static Taint-Analysis on Binary Executables Sanjay Rawat, Laurent Mounier, Marie-Laure Potet VERIMAG University of Grenoble October 2011 Static Taint-Analysis on Binary Executables 1/29 Outline 1 Introduction

More information

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion CHAPTER 5 Number Theory 1. Integers and Division 1.1. Divisibility. Definition 1.1.1. Given two integers a and b we say a divides b if there is an integer c such that b = ac. If a divides b, we write a

More information

1 Definition of a Turing machine

1 Definition of a Turing machine Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

More information

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements. 3. Axioms of Set theory Before presenting the axioms of set theory, we first make a few basic comments about the relevant first order logic. We will give a somewhat more detailed discussion later, but

More information

Simulation-Based Security with Inexhaustible Interactive Turing Machines

Simulation-Based Security with Inexhaustible Interactive Turing Machines Simulation-Based Security with Inexhaustible Interactive Turing Machines Ralf Küsters Institut für Informatik Christian-Albrechts-Universität zu Kiel 24098 Kiel, Germany kuesters@ti.informatik.uni-kiel.de

More information

2) Write in detail the issues in the design of code generator.

2) Write in detail the issues in the design of code generator. COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

More information

The Halting Problem is Undecidable

The Halting Problem is Undecidable 185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

More information

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by SUBGROUPS OF CYCLIC GROUPS KEITH CONRAD 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by g = {g k : k Z}. If G = g, then G itself is cyclic, with g as a generator. Examples

More information

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: ω-automata ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: in verification, as encodings of non-terminating executions of a program. in arithmetic,

More information

Creating, Solving, and Graphing Systems of Linear Equations and Linear Inequalities

Creating, Solving, and Graphing Systems of Linear Equations and Linear Inequalities Algebra 1, Quarter 2, Unit 2.1 Creating, Solving, and Graphing Systems of Linear Equations and Linear Inequalities Overview Number of instructional days: 15 (1 day = 45 60 minutes) Content to be learned

More information

Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

More information

SECTION 10-2 Mathematical Induction

SECTION 10-2 Mathematical Induction 73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

Handout #1: Mathematical Reasoning

Handout #1: Mathematical Reasoning Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

More information

Turing Machines: An Introduction

Turing Machines: An Introduction CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

More information

The countdown problem

The countdown problem JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON

More information

1 Operational Semantics for While

1 Operational Semantics for While Models of Computation, 2010 1 1 Operational Semantics for While The language While of simple while programs has a grammar consisting of three syntactic categories: numeric expressions, which represent

More information

Competitive Analysis of On line Randomized Call Control in Cellular Networks

Competitive Analysis of On line Randomized Call Control in Cellular Networks Competitive Analysis of On line Randomized Call Control in Cellular Networks Ioannis Caragiannis Christos Kaklamanis Evi Papaioannou Abstract In this paper we address an important communication issue arising

More information

Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.

(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine. (LMCS, p. 317) V.1 First Order Logic This is the most powerful, most expressive logic that we will examine. Our version of first-order logic will use the following symbols: variables connectives (,,,,

More information

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

More information

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS STEVEN P. LALLEY AND ANDREW NOBEL Abstract. It is shown that there are no consistent decision rules for the hypothesis testing problem

More information

6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.080/6.089 GITCS Feb 12, 2008. Lecture 3 6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

More information

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system 1. Systems of linear equations We are interested in the solutions to systems of linear equations. A linear equation is of the form 3x 5y + 2z + w = 3. The key thing is that we don t multiply the variables

More information

GRAPH THEORY LECTURE 4: TREES

GRAPH THEORY LECTURE 4: TREES GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection

More information

How Asymmetry Helps Load Balancing

How Asymmetry Helps Load Balancing How Asymmetry Helps oad Balancing Berthold Vöcking nternational Computer Science nstitute Berkeley, CA 947041198 voecking@icsiberkeleyedu Abstract This paper deals with balls and bins processes related

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

A Survey of Static Program Analysis Techniques

A Survey of Static Program Analysis Techniques A Survey of Static Program Analysis Techniques Wolfgang Wögerer Technische Universität Wien October 18, 2005 Abstract Computer program analysis is the process of automatically analysing the bahavior of

More information

LIMITS AND CONTINUITY

LIMITS AND CONTINUITY LIMITS AND CONTINUITY 1 The concept of it Eample 11 Let f() = 2 4 Eamine the behavior of f() as approaches 2 2 Solution Let us compute some values of f() for close to 2, as in the tables below We see from

More information

sin(x) < x sin(x) x < tan(x) sin(x) x cos(x) 1 < sin(x) sin(x) 1 < 1 cos(x) 1 cos(x) = 1 cos2 (x) 1 + cos(x) = sin2 (x) 1 < x 2

sin(x) < x sin(x) x < tan(x) sin(x) x cos(x) 1 < sin(x) sin(x) 1 < 1 cos(x) 1 cos(x) = 1 cos2 (x) 1 + cos(x) = sin2 (x) 1 < x 2 . Problem Show that using an ɛ δ proof. sin() lim = 0 Solution: One can see that the following inequalities are true for values close to zero, both positive and negative. This in turn implies that On the

More information

Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 11 Semantics of Programming Languages Denotational Semantics Meaning of a program is defined as the mathematical

More information

An example of a computable

An example of a computable An example of a computable absolutely normal number Verónica Becher Santiago Figueira Abstract The first example of an absolutely normal number was given by Sierpinski in 96, twenty years before the concept

More information

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs CSE599s: Extremal Combinatorics November 21, 2011 Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs Lecturer: Anup Rao 1 An Arithmetic Circuit Lower Bound An arithmetic circuit is just like

More information

Student Outcomes. Lesson Notes. Classwork. Discussion (10 minutes)

Student Outcomes. Lesson Notes. Classwork. Discussion (10 minutes) NYS COMMON CORE MATHEMATICS CURRICULUM Lesson 5 8 Student Outcomes Students know the definition of a number raised to a negative exponent. Students simplify and write equivalent expressions that contain

More information

Computability Theory

Computability Theory CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

More information

Markov random fields and Gibbs measures

Markov random fields and Gibbs measures Chapter Markov random fields and Gibbs measures 1. Conditional independence Suppose X i is a random element of (X i, B i ), for i = 1, 2, 3, with all X i defined on the same probability space (.F, P).

More information

6.3 Conditional Probability and Independence

6.3 Conditional Probability and Independence 222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

More information

Notes from Week 1: Algorithms for sequential prediction

Notes from Week 1: Algorithms for sequential prediction CS 683 Learning, Games, and Electronic Markets Spring 2007 Notes from Week 1: Algorithms for sequential prediction Instructor: Robert Kleinberg 22-26 Jan 2007 1 Introduction In this course we will be looking

More information

Scheduling Real-time Tasks: Algorithms and Complexity

Scheduling Real-time Tasks: Algorithms and Complexity Scheduling Real-time Tasks: Algorithms and Complexity Sanjoy Baruah The University of North Carolina at Chapel Hill Email: baruah@cs.unc.edu Joël Goossens Université Libre de Bruxelles Email: joel.goossens@ulb.ac.be

More information

Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

More information

How To Understand The Theory Of Computer Science

How To Understand The Theory Of Computer Science Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked

More information

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation: CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm

More information

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

More information

Stochastic Inventory Control

Stochastic Inventory Control Chapter 3 Stochastic Inventory Control 1 In this chapter, we consider in much greater details certain dynamic inventory control problems of the type already encountered in section 1.3. In addition to the

More information

Approximation Algorithms

Approximation Algorithms Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

More information

The Goldberg Rao Algorithm for the Maximum Flow Problem

The Goldberg Rao Algorithm for the Maximum Flow Problem The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }

More information

A first step towards modeling semistructured data in hybrid multimodal logic

A first step towards modeling semistructured data in hybrid multimodal logic A first step towards modeling semistructured data in hybrid multimodal logic Nicole Bidoit * Serenella Cerrito ** Virginie Thion * * LRI UMR CNRS 8623, Université Paris 11, Centre d Orsay. ** LaMI UMR

More information

No: 10 04. Bilkent University. Monotonic Extension. Farhad Husseinov. Discussion Papers. Department of Economics

No: 10 04. Bilkent University. Monotonic Extension. Farhad Husseinov. Discussion Papers. Department of Economics No: 10 04 Bilkent University Monotonic Extension Farhad Husseinov Discussion Papers Department of Economics The Discussion Papers of the Department of Economics are intended to make the initial results

More information

MATH 289 PROBLEM SET 4: NUMBER THEORY

MATH 289 PROBLEM SET 4: NUMBER THEORY MATH 289 PROBLEM SET 4: NUMBER THEORY 1. The greatest common divisor If d and n are integers, then we say that d divides n if and only if there exists an integer q such that n = qd. Notice that if d divides

More information

CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

More information

Turing Degrees and Definability of the Jump. Theodore A. Slaman. University of California, Berkeley. CJuly, 2005

Turing Degrees and Definability of the Jump. Theodore A. Slaman. University of California, Berkeley. CJuly, 2005 Turing Degrees and Definability of the Jump Theodore A. Slaman University of California, Berkeley CJuly, 2005 Outline Lecture 1 Forcing in arithmetic Coding and decoding theorems Automorphisms of countable

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

Lab Experience 17. Programming Language Translation

Lab Experience 17. Programming Language Translation Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly

More information

COUNTING SUBSETS OF A SET: COMBINATIONS

COUNTING SUBSETS OF A SET: COMBINATIONS COUNTING SUBSETS OF A SET: COMBINATIONS DEFINITION 1: Let n, r be nonnegative integers with r n. An r-combination of a set of n elements is a subset of r of the n elements. EXAMPLE 1: Let S {a, b, c, d}.

More information

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)! Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

More information

Policy Analysis for Administrative Role Based Access Control without Separate Administration

Policy Analysis for Administrative Role Based Access Control without Separate Administration Policy nalysis for dministrative Role Based ccess Control without Separate dministration Ping Yang Department of Computer Science, State University of New York at Binghamton, US Mikhail I. Gofman Department

More information

Lecture 2: Universality

Lecture 2: Universality CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

More information