Data flow analysis. DataFlow analysis

Size: px
Start display at page:

Download "Data flow analysis. DataFlow analysis"

Transcription

1 Data flow analysis DataFlow analysis compile time reasoning about the runtime flow of values in the program represent facts about runtime behavior represent effect of executing each basic block propagate facts around control flow graph

2 Dataflow Analysis Used to determine properties of program that involve multiple basic blocks Typically used to enable transformations common sub-expression elimination constant and copy propagation dead code elimination Analysis and transformation often come in pairs Reaching Definitions Concept of definition and use a = x+y is a definition of a is a use of x and y A definition reaches a use if value written by definition may be read by use

3 Reaching Definitions s = 0; a = 4; i = 0; k == 0 b = 1; b = 2; i < n s = s + a*b; i = i + 1; return s Reaching Definitions and Constant Propagation Is a use of a variable a constant? Check all reaching definitions If all assign variable to same constant Then use is in fact a constant Can replace variable with constant

4 Is a Constant in s = s+a*b? s = 0; a = 4; i = 0; k == 0 b = 1; b = 2; Yes! On all reaching definitions a = 4 i < n s = s + a*b; i = i + 1; return s Constant Propagation Transform s = 0; a = 4; i = 0; k == 0 b = 1; b = 2; Yes! On all reaching definitions a = 4 i < n s = s + 4*b; i = i + 1; return s

5 Is b Constant in s = s+a*b? s = 0; a = 4; i = 0; k == 0 b = 1; b = 2; i < n No! One reaching definition with b = 1 One reaching definition with b = 2 s = s + a*b; i = i + 1; return s Computing Reaching Definitions Compute with sets of definitions represent sets using bit vectors each definition has a position in bit vector At each basic block, compute definitions that reach start of block definitions that reach end of block Do computation by simulating execution of program until reach fixed point

6 : s = 0; 2: a = 4; 3: i = 0; k == : b = 1; 5: b = 2; : s = s + a*b; 7: i = i + 1; i < n return s Formalizing Analysis Each basic block has IN - set of definitions that reach beginning of block OUT - set of definitions that reach end of block GEN - set of definitions generated in block KILL - set of definitions killed in in block GEN[s = s + a*b; i = i + 1;] = KILL[s = s + a*b; i = i + 1;] = Compiler scans each basic block to derive GEN and KILL sets

7 Dataflow Equations IN[b] = OUT[b1] U... U OUT[bn] where b1,..., bn are predecessors of b in CFG OUT[b] = (IN[b] - KILL[b]) U GEN[b] IN[entry] = Result: system of equations Solving Equations Use fixed point algorithm Initialize with solution of OUT[b] = Repeatedly apply equations IN[b] = OUT[b1] U... U OUT[bn] OUT[b] = (IN[b] - KILL[b]) U GEN[b] Until reach fixed point Until equation application has no further effect Use a worklist to track which equation applications may have a further effect

8 Reaching Definitions Algorithm for all nodes n in N OUT[n] = emptyset; // OUT[n] = GEN[n]; Changed = D; // D = all definitions in graph while (Changed!= emptyset) choose a node n in Changed; Changed = Changed - { n }; IN[n] = emptyset; for all nodes p in predecessors(n) IN[n] = IN[n] U OUT[p]; OUT[n] = GEN[n] U (IN[n] - KILL[n]); if (OUT[n] changed) for all nodes s in successors(n) Changed = Changed U { s }; Questions Does the algorithm halt? yes, because transfer function is monotonic if increase IN, increase OUT in limit, all bits are 1 If bit is 1, is there always an execution in which corresponding definition reaches basic block? If bit is 0, does the corresponding definition ever reach basic block? Concept of conservative analysis

9 Available Expressions An expression x+y is available at a point p if every path from the initial node to p evaluates x+y before reaching p, and there are no assignments to x or y after the evaluation but before p. Available Expression information can be used to do global (across basic blocks) CSE If expression is available at use, no need to reevaluate it Computing Available Expressions Represent sets of expressions using bit vectors Each expression corresponds to a bit Run dataflow algorithm similar to reaching definitions Big difference definition reaches a basic block if it comes from ANY predecessor in CFG expression is available at a basic block only if it is available from ALL predecessors in CFG

10 Expressions 1: x+y 2: i<n 3: i+c 4: x== x = z; b = x+y; a = x+y; x == 0 i = x+y; i < n c = x+y; d = x+y i = i+c; Global CSE Transform Expressions 1: x+y 2: i<n 3: i+c 4: x==0 must use same temp for CSE in all blocks 1001 x = z; b = x+y; t = b; a = x+y; t = a; x == 0 i = t; i < n c = t; d = t; i = i+c;

11 Formalizing Analysis Each basic block has IN - set of expressions available at start of block OUT - set of expressions available at end of block GEN - set of expressions computed in block KILL - set of expressions killed in in block GEN[x = z; b = x+y] = 1000 KILL[x = z; b = x+y] = 1001 Compiler scans each basic block to derive GEN and KILL sets Dataflow Equations IN[b] = OUT[b1] intersect... intersect OUT[bn] where b1,..., bn are predecessors of b in CFG OUT[b] = (IN[b] - KILL[b]) U GEN[b] IN[entry] = 0000 Result: system of equations

12 Solving Equations Use fixed point algorithm IN[entry] = 0000 Initialize OUT[b] = 1111 Repeatedly apply equations IN[b] = OUT[b1] intersect... intersect OUT[bn] OUT[b] = (IN[b] - KILL[b]) U GEN[b] Use a worklist algorithm to reach fixed point Available Expressions Algorithm for all nodes n in N OUT[n] = E; // OUT[n] = E - KILL[n]; IN[Entry] = emptyset; OUT[Entry] = GEN[Entry]; Changed = N - { Entry }; // N = all nodes in graph while (Changed!= emptyset) choose a node n in Changed; Changed = Changed - { n }; IN[n] = E; // E is set of all expressions for all nodes p in predecessors(n) IN[n] = IN[n] intersect OUT[p]; OUT[n] = GEN[n] U (IN[n] - KILL[n]); if (OUT[n] changed) for all nodes s in successors(n) Changed = Changed U { s };

13 Questions Does algorithm always halt? If expression is available in some execution, is it always marked as available in analysis? If expression is not available in some execution, can it be marked as available in analysis? In what sense is algorithm conservative? Duality In Two Algorithms Reaching definitions Confluence operation is set union OUT[b] initialized to empty set Available expressions Confluence operation is set intersection OUT[b] initialized to set of available expressions General framework for dataflow algorithms. Build parameterized dataflow analyzer once, use for all dataflow problems

14 Liveness Analysis A variable v is live at point p if v is used along some path starting at p, and no definition of v along the path before the use. When is a variable v dead at point p? No use of v on any path from p to exit node, or If all paths from p redefine v before using v. What Use is Liveness information? Register allocation. If a variable is dead, can reassign its register Dead code elimination. Eliminate assignments to variables not read later. But must not eliminate last assignment to variable (such as instance variable) visible outside CFG. Can eliminate other dead assignments. Handle by making all externally visible variables live on exit from CFG

15 Conceptual Idea of Analysis Simulate execution But start from exit and go backwards in CFG Compute liveness information from end to beginning of basic blocks Liveness Example Assume a,b,c visible outside method So are live on exit Assume x,y,z,t not visible Represent Liveness Using Bit Vector order is abcxyzt b = t+z; a = x+y; t = a; c = a+x; x == 0 c = y+1;

16 Dead Code Elimination Assume a,b,c visible outside method So are live on exit Assume x,y,z,t not visible Represent Liveness Using Bit Vector order is abcxyzt b = t+z; a = x+y; t = a; x == 0 c = y+1; Formalizing Analysis Each basic block has IN - set of variables live at start of block OUT - set of variables live at end of block USE - set of variables with upwards exposed uses in block DEF - set of variables defined in block USE[x = z; x = x+1;] = { z } (x not in USE) DEF[x = z; x = x+1;y = 1;] = {x, y} Compiler scans each basic block to derive GEN and KILL sets

17 Algorithm out[exit] = emptyset; in[exit] = use[n]; for all nodes n in N - { Exit } in[n] = emptyset; Changed = N - { Exit }; while (Changed!= emptyset) choose a node n in Changed; Changed = Changed - { n }; out[n] = emptyset; for all nodes s in successors(n) out[n] = out[n] U in[p]; in[n] = use[n] U (out[n] - def[n]); if (in[n] changed) for all nodes p in predecessors(n) Changed = Changed U { p }; Similar to Other Dataflow Algorithms Backwards analysis, not forwards Still have transfer functions Still have confluence operators Can generalize framework to work for both forwards and backwards analyses

18 Analysis Information Inside Basic Blocks One detail: Given dataflow information at IN and OUT of node Also need to compute information at each statement of basic block Simple propagation algorithm usually works fine Can be viewed as restricted case of dataflow analysis Summary Basic Blocks and Basic Block Optimizations Copy and constant propagation Common sub-expression elimination Dead code elimination Dataflow Analysis Control flow graph IN[b], OUT[b], transfer functions, join points Paired analyses and transformations Reaching definitions/constant propagation Available expressions/common sub-expression elimination Liveness analysis/dead code elimination Stacked analysis and transformations work together

19

20 Available expressions Definition An expression is defined at point p if its value is computed at p An expression is killed at a point p if one of its argument variables is defined at p An expression e is available at a point p in a procedure if every path leading to p contains a prior definition of e that is not killed between its definition and p

21 Global common subexpression elimination If at some definition point for p e e is available with name x we can replace the evaluation with a reference to x requires a global naming scheme natural analog to parts of value numbering For a block b let AVAIL(b) be the set of expressions available on entry to b let KILL(b) be the set of expressions killed in b let GEN(b) be the set of expressions dened in b and not subsequently killed in b Note GEN(b) is AVAILTAB from value numbering KILL(b) is harder to construct

22 Now AVAIL can be defined as Note initializations must be conservative

23 Foundations of Dataflow Analysis

24 Dataflow Analysis Compile-Time Reasoning About Run-Time Values of Variables or Expressions At Different Program Points Which assignment statements produced value of variable at this point? Which variables contain values that are no longer used after this program point? What is the range of possible values of variable at this program point? Program Representation Control Flow Graph Nodes N statements of program Edges E flow of control pred(n) = set of all predecessors of n succ(n) = set of all successors of n Start node n 0 Set of final nodes N final

25 Program Points One program point before each node One program point after each node Join point point with multiple predecessors Split point point with multiple successors Basic Idea Information about program represented using values from algebraic structure called lattice Analysis produces lattice value for each program point Two flavors of analysis Forward dataflow analysis Backward dataflow analysis

26 Forward Dataflow Analysis Analysis propagates values forward through control flow graph with flow of control Each node has a transfer function f Input value at program point before node Output new value at program point after node Values flow from program points after predecessor nodes to program points before successor nodes At join points, values are combined using a merge function Backward Dataflow Analysis Analysis propagates values backward through control flow graph against flow of control Each node has a transfer function f Input value at program point after node Output new value at program point before node Values flow from program points before successor nodes to program points after predecessor nodes At split points, values are combined using a merge function Canonical Example: Live Variables

27 Partial Orders Set P Partial order such that x,y,z P x x (reflexive) x y and y x implies x = y (asymmetric) x y and y z implies x z (transitive) Upper Bounds If S P then x P is an upper bound of S if y S. y x x P is the least upper bound of S if x is an upper bound of S, and x y for all upper bounds y of S - join, least upper bound, lub, supremum, sup S is the least upper bound of S x y is the least upper bound of {x,y}

28 If S P then Lower Bounds x P is a lower bound of S if y S. x y x P is the greatest lower bound of S if x is a lower bound of S, and y x for all lower bounds y of S - meet, greatest lower bound, glb, infimum, inf S is the greatest lower bound of S x y is the greatest lower bound of {x,y} Covering x< y if x y and x y x is covered by y (y covers x) if x < y, and x z < y implies x = z Conceptually, y covers x if there are no elements between x and y

29 Example P = { 000, 001, 010, 011, 100, 101, 110, 111} (standard boolean lattice, also called hypercube) x y if (x bitwise and y) = x Hasse Diagram If y covers x Line from y to x y above x in diagram Lattices If x y and x y exist for all x,y P, then P is a lattice. If S and S exist for all S P, then P is a complete lattice. All finite lattices are complete Example of a lattice that is not complete Integers I For any x, y I, x y = max(x,y), x y = min(x,y) But I and I do not exist I {+, } is a complete lattice

30 Top and Bottom Greatest element of P (if it exists) is top Least element of P (if it exists) is bottom ( ) Connection Between,, and The following 3 properties are equivalent: x y x y = y x y = x Will prove: x y implies x y = y and x y = x x y = y implies x y x y = x implies x y Then by transitivity, can obtain x y = y implies x y = x x y = x implies x y = y

31 Connecting Lemma Proofs Proof of x y implies x y = y x y implies y is an upper bound of {x,y}. Any upper bound z of {x,y} must satisfy y z. So y is least upper bound of {x,y} and x y = y Proof of x y implies x y = x x y implies x is a lower bound of {x,y}. Any lower bound z of {x,y} must satisfy z x. So x is greatest lower bound of {x,y} and x y = x Connecting Lemma Proofs Proof of x y = y implies x y y is an upper bound of {x,y} implies x y Proof of x y = x implies x y x is a lower bound of {x,y} implies x y

32 Lattices as Algebraic Structures Have defined and in terms of Will now define in terms of and Start with and as arbitrary algebraic operations that satisfy associative, commutative, idempotence, and absorption laws Will define using and Will show that is a partial order Algebraic Properties of Lattices Assume arbitrary operations and such that (x y) z = x (y z) (associativity of ) (x y) z = x (y z) (associativity of ) x y = y x (commutativity of ) x y = y x (commutativity of ) x x = x (idempotence of ) x x = x (idempotence of ) x (x y) = x (absorption of over ) x (x y) x (absorption of over )

33 Connection Between and x y = y if and only if x y = x Proof of x y = y implies x = x y x = x (x y) (by absorption) = x y (by assumption) Proof of x y = x implies y = x y y = y (y x) (by absorption) = y (x y) (by commutativity) = y x (by assumption) = x y (by commutativity) Properties of Define x yif x y = y Proof of transitive property. Must show that x y = y and y z = z implies x z = z x z = x (y z) (by assumption) = (x y) z (by associativity) = y z (by assumption) = z (by assumption)

34 Properties of Proof of asymmetry property. Must show that x y = y and y x = x implies x = y x = y x (by assumption) = x y (by commutativity) = y (by assumption) Proof of reflexivity property. Must show that x x = x Properties of Induced operation agrees with original definitions of and, i.e., x y = sup {x, y} x y = inf {x, y}

35 Proof of x y = sup {x, y} Consider any upper bound u for x and y. Given x u = u and y u = u, must show x y u, i.e., (x y) u = u u = x u (by assumption) = x (y u) (by assumption) = (x y) u (by associativity) Proof of x y = inf {x, y} Consider any lower bound l for x and y. Given x l = l and y l = l, must show l x y, i.e., (x y) l = l l = x l (by assumption) = x (y l) (by assumption) = (x y) l (by associativity)

36 Chains A set S is a chain if x,y S. y x or x y P has no infinite chains if every chain in P is finite P satisfies the ascending chain condition if for all sequences x 1 x 2 there exists n such that x n = x n+1 = Application to Dataflow Analysis Dataflow information will be lattice values Transfer functions operate on lattice values Solution algorithm will generate increasing sequence of values at each program point Ascending chain condition will ensure termination Will use to combine values at controlflow join points

37 Transfer Functions Transfer function f: P P for each node in control flow graph f models effect of the node on the program information Transfer Functions Each dataflow analysis problem has a set F of transfer functions f: P P Identity function i F F must be closed under composition: f,g F. the function h = λx.f(g(x)) F Each f F must be monotone: x y implies f(x) f(y) Sometimes all f F are distributive: f(x y) = f(x) f(y) Distributivity implies monotonicity

38 Distributivity Implies Monotonicity Proof of distributivity implies monotonicity Assume f(x y) = f(x) f(y) Must show: x y = y implies f(x) f(y) = f(y) f(y) = f(x y) (by assumption) = f(x) f(y) (by distributivity) Putting Pieces Together Forward Dataflow Analysis Framework Simulates execution of program forward with flow of control

39 Forward Dataflow Analysis Simulates execution of program forward with flow of control For each node n, have in n value at program point before n out n value at program point after n f n transfer function for n (given in n, computes out n ) Require that solution satisfy n. out n = f n (in n ) n n 0. in n = { out m. m in pred(n) } in n0 = I Where I summarizes information at start of program Dataflow Equations Compiler processes program to obtain a set of dataflow equations out n := f n (in n ) in n := { out m. m in pred(n) } Conceptually separates analysis problem from program

40 Worklist Algorithm for Solving Forward Dataflow Equations for each n do out n := f n ( ) in n0 := I; out n0 := f n (I) worklist := N - { n 0 } while worklist do remove a node n from worklist in n := { out m. m in pred(n) } out n := f n (in n ) if out n changed then worklist := worklist succ(n) Correctness Argument Why result satisfies dataflow equations Whenever process a node n, set out n := f n (in n ) Algorithm ensures that out n = f n (in n ) Whenever out m changes, put succ(m) on worklist. Consider any node n succ(m). It will eventually come off worklist and algorithm will set in n := { out m. m in pred(n) } to ensure that in n = { out m. m in pred(n) } So final solution will satisfy dataflow equations

41 Termination Argument Why does algorithm terminate? Sequence of values taken on by in n or out n is a chain. If values stop increasing, worklist empties and algorithm terminates. If lattice has ascending chain property, algorithm terminates Algorithm terminates for finite lattices For lattices without ascending chain property, use widening operator Widening Operators Detect lattice values that may be part of infinitely ascending chain Artificially raise value to least upper bound of chain Example: Lattice is set of all subsets of integers Could be used to collect possible values taken on by variable during execution of program Widening operator might raise all sets of size t t TOP (lik l t b f l f

42 Reaching Definitions P = powerset of set of all definitions in program (all subsets of set of definitions in program) = (order is ) = I = in n0 = F = all functions f of the form f(x) = a (x-b) b is set of definitions that node kills a is set of definitions that node generates General pattern for many transfer functions f(x) = GEN (x-kill) Does Reaching Definitions Framework Satisfy Properties? satisfies conditions for x y and y z implies x z (associativity) x y and y x implies y = x (asymmetry) x x (idempotence) F satisfies transfer function conditions λx. (x- ) = λx.x F (identity) Will show f(x y) = f(x) f(y) (distributivity) f(x) f(y) = (a (x b)) (a (y b)) = a (x b) (y b) = a ((x y) b) = f(x y)

43 Does Reaching Definitions Framework Satisfy Properties? What about composition? Given f 1 (x) = a 1 (x-b 1 ) and f 2 (x) = a 2 (x-b 2 ) Must show f 1 (f 2 (x)) can be expressed as a (x - b) f 1 (f 2 (x)) = a 1 ((a 2 (x-b 2 )) - b 1 ) = a 1 ((a 2 -b 1 ) ((x-b 2 ) - b 1 )) = (a 1 (a 2 -b 1 )) ((x-b 2 ) - b 1 )) = (a 1 (a 2 -b 1 )) (x-(b 2 b 1 )) Let a = (a 1 (a 2 -b 1 )) and b = b 2 b 1 Then f 1 (f 2 (x)) = a (x b) General Result All GEN/KILL transfer function frameworks satisfy Identity Distributivity Composition Properties

44 Available Expressions P = powerset of set of all expressions in program (all subsets of set of expressions) = (order is ) = P I = in n0 = F = all functions f of the form f(x) = a (xb) b is set of expressions that node kills a is set of expressions that node generates Another GEN/KILL analysis Concept of Conservatism Reaching definitions use as join Optimizations must take into account all definitions that reach along ANY path Available expressions use as join Optimization requires expression to reach along ALL paths Optimizations must conservatively take all possible executions into account. Structure of analysis varies according to way analysis used

45 Backward Dataflow Analysis Simulates execution of program backward against the flow of control For each node n, have in n value at program point before n out n value at program point after n f n transfer function for n (given out n, computes in n ) Require that solution satisfy n. in n = f n (out n ) n N final. out n = { in m. m in succ(n) } n N final = out n = O Where O summarizes information at end of program Worklist Algorithm for Solving Backward Dataflow Equations for each n do in n := f n ( ) for each n N final do out n := O; in n := f n (O) worklist := N - N final while worklist do remove a node n from worklist out n := { in m. m in succ(n) } in n := f n (out n ) if in n changed then worklist := worklist pred(n)

46 Live Variables P = powerset of set of all variables in program (all subsets of set of variables in program) = (order is ) = O = F = all functions f of the form f(x) = a (xb) b is set of variables that node kills Meaning of Dataflow Results Concept of program state s for control-flow graphs Program point n where execution located (n is node that will execute next) Values of variables in program Each execution generates a trajectory of states: s 0 ;s 1 ; ;s k,where each s i ST s i+1 generated from s i by executing basic block to Update variable values

47 Relating States to Analysis Result Meaning of analysis results is given by an abstraction function AF:ST P Correctness condition: require that for all states s AF(s) in n where n is the next statement to execute in state s Sign Analysis Example Sign analysis - compute sign of each variable v Base Lattice: P = flat lattice on {-,0,+} TOP BOT Actual lattice records a value for each variable Example element: [a +, b 0, c -]

48 Interpretation of Lattice Values If value of v in lattice is: BOT: no information about sign of v -: variable v is negative 0: variable v is 0 +: variable v is positive TOP: v may be positive or negative Operation on Lattice BOT TOP BOT BOT TOP TOP TOP TOP TOP TOP 0 TOP TOP

49 Transfer Functions If n of the form v = c f n (x) = x[v +] if c is positive f n (x) = x[v 0] if c is 0 f n (x) = x[v -] if c is negative If n of the form v 1 = v 2 *v 3 f n (x) = x[v 1 x[v 2 ] x[v 3 ]] I = TOP (uninitialized variables may have any sign) Example a = 1 [a +] [a +] b = -1 b = 1 [a +, b -] [a +, b +] [a +, b TOP] c = a*b [a +, b TOP,c TOP]

50 Imprecision In Example Abstraction Imprecision: [a 1] abstracted as [a +] a = 1 [a +] [a +] b = -1 b = 1 [a +, b -] [a +, b +] [a +, b TOP] Control Flow Imprecision: c = a*b [b TOP] summarizes results of all executions. In any execution state s, AF(s)[b] TOP General Sources of Imprecision Abstraction Imprecision Concrete values (integers) abstracted as lattice values (-,0, and +) Lattice values less precise than execution values Abstraction function throws away information Control Flow Imprecision One lattice value for all possible control flow paths Analysis result has a single lattice value to summarize results of multiple concrete executions Join operation moves up in lattice to combine values from different execution paths Typically if x y, then x is more precise than y

51 Why Have Imprecision Make analysis tractable Unbounded sets of values in execution Typically abstracted by finite set of lattice values Execution may visit unbounded set of states Abstracted by computing joins of different paths Abstraction Function AF(s)[v] = sign of v AF(n,[a 5, b 0, c -2]) = [a +, b 0, c -] Establishes meaning of the analysis results If analysis says variable has a given sign Always has that sign in actual execution Correctness condition: v. AF(s)[v] in n [v] (n is node for s) Reflects possibility of imprecision

52 Abstraction Function Soundness Will show v. AF(s)[v] in n [v] (n is node for s) by induction on length of computation that produced s Base case: v. in n0 [v] = TOP, which implies that v. AF(s)[v] TOP Induction Step Assume v. AF(s)[v] in n [v] for computations of length k Prove for computations of length k+1 Proof: Given s (state), n (node to execute next), and in n Find p (the node that just executed), s p (the previous state), and in p By induction hypothesis v. AF(s p )[v] in p [v] Case analysis on form of n If n of the form v = c, then s[v] = c and out p [v] = sign(c), so AF(s)[v] = sign(c) = out p [v] in n [v] If x v, s[x] = s p [x] and out p [x] = in p [x], so AF(s)[x] = AF(s p )[x] in p [x] = out p [x] in n [x] Similar reasoning if n of the form v 1 = v 2 *v 3

53 Augmented Execution States Abstraction functions for some analyses require augmented execution states Reaching definitions: states are augmented with definition that created each value Available expressions: states are augmented with expression for each value Meet Over Paths Solution What solution would be ideal for a forward dataflow analysis problem? Consider a path p = n 0, n 1,, n k, n to a node n (note that for all i n i pred(n i+1 )) The solution must take this path into account: f p ( ) = (f nk (f nk-1 ( f n1 (f n0 ( )) )) in n So the solution must have the property that {f p ( ). p is a path to n} in n and ideally {f p ( ). p is a path to n} = in n

54 Soundness Proof of Analysis Algorithm Property to prove: For all paths p to n, f p ( ) in n Proof is by induction on length of p Uses monotonicity of transfer functions Uses following lemma Lemma: Worklist algorithm produces a solution such that f n (in n ) = out n if n pred(m) then out n in m Proof Base case: p is of length 1 Then p = n 0 and f p ( ) = = in n0 Induction step: Assume theorem for all paths of length k Show for an arbitrary path p of length k+1

55 Induction Step Proof p = n 0,, n k, n Must show f k (f k-1 ( f n1 (f n0 ( )) )) in n By induction (f k-1 ( f n1 (f n0 ( )) )) in nk Appy f k to both sides, by monotonicity we get f k (f k-1 ( f n1 (f n0 ( )) )) f k (in nk ) By lemma, f k (in nk ) = out nk By lemma, out nk in n By transitivity, f k (f k-1 ( f n1 (f n0 ( )) )) in n Distributivity Distributivity preserves precision If framework is distributive, then worklist algorithm produces the meet over paths solution For all n: {f p ( ). p is a path to n} = in n

56 Lack of Distributivity Example Constant Calculator Flat Lattice on Integers TOP BOT Actual lattice records a value for each variable E l l t [ 3 b 2 5] Transfer Functions If n of the form v = c f n (x) = x[v c] If n of the form v 1 = v 2 +v 3 f n (x) = x[v 1 x[v 2 ] + x[v 3 ]] Lack of distributivity Consider transfer function f for c = a + b f([a 3, b 2]) f([a 2, b 3]) = [a TOP, b TOP, c 5] f([a 3, b 2] [a 2, b 3]) = f([a TOP, b TOP]) = [a TOP, b TOP, c TOP]

57 Lack of Distributivity Anomaly [a 2, b 3] a = 2 b = 3 a = 3 b = 2 [a 3, b 2] [a TOP, b TOP] Lack of Distributivity Imprecision: c = a+b [a TOP, b TOP, c 5] more precise [a TOP, b TOP, c TOP] Summary Formal dataflow analysis framework Lattices, partial orders Transfer functions, joins and splits Dataflow equations and fixed point solutions Connection with program Abstraction function AF: S P For any state s and program point n, AF(s) in n Meet over paths solutions, distributivity

MIT Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology

MIT Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology MIT 6.035 Foundations of Dataflow Analysis Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Dataflow Analysis Compile-Time Reasoning About Run-Time Values of Variables

More information

Dataflow analysis. Theory and Applications. cs6463 1

Dataflow analysis. Theory and Applications. cs6463 1 Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows

More information

Compiler Design. Data Flow Analysis. Hwansoo Han

Compiler Design. Data Flow Analysis. Hwansoo Han Compiler Design Data Flow Analysis Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential

More information

Dataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4

Dataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4 Dataflow Analysis Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub area of static program analysis Used in the compiler back end for optimizations of three address code and

More information

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between

More information

Topic-I-C Dataflow Analysis

Topic-I-C Dataflow Analysis Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code

More information

CSC D70: Compiler Optimization Dataflow-2 and Loops

CSC D70: Compiler Optimization Dataflow-2 and Loops CSC D70: Compiler Optimization Dataflow-2 and Loops Prof. Gennady Pekhimenko University of Toronto Winter 2018 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip Gibbons

More information

Introduction to data-flow analysis. Data-flow analysis. Control-flow graphs. Data-flow analysis. Example: liveness. Requirements

Introduction to data-flow analysis. Data-flow analysis. Control-flow graphs. Data-flow analysis. Example: liveness. Requirements Data-flow analysis Michel Schinz based on material by Erik Stenman and Michael Schwartzbach Introduction to data-flow analysis Data-flow analysis Example: liveness Data-flow analysis is a global analysis

More information

Lecture 5 Introduction to Data Flow Analysis

Lecture 5 Introduction to Data Flow Analysis Lecture 5 Introduction to Data Flow Analysis I. Structure of data flow analysis II. III. IV. Example 1: Reaching definition analysis Example 2: Liveness analysis Framework Phillip B. Gibbons 15-745: Intro

More information

Data Flow Analysis (I)

Data Flow Analysis (I) Compiler Design Data Flow Analysis (I) Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential

More information

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation -74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation

More information

Dataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {

Dataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) { -4 Lecture Dataflow Analysis Basic Blocks Related Optimizations Copyright Seth Copen Goldstein 00 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation Common

More information

Dataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4

Dataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 Dataflow Analysis Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub-area of static program analysis Used in the compiler back end for optimizations of three-address

More information

Lecture 4 Introduc-on to Data Flow Analysis

Lecture 4 Introduc-on to Data Flow Analysis Lecture 4 Introduc-on to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching defini?on analysis III. Example 2: Liveness analysis IV. Generaliza?on 15-745: Intro to Data Flow

More information

Monotone Data Flow Analysis Framework

Monotone Data Flow Analysis Framework Monotone Data Flow Analysis Framework Definition. A relation R on a set S is (a) reflexive iff ( x S)[xRx], (b) antisymmetric iff [xry yrx x=y] (c) transitive iff ( x,y,z S) [xry yrz xrz] Definition. A

More information

Generalizing Data-flow Analysis

Generalizing Data-flow Analysis Generalizing Data-flow Analysis Announcements PA1 grades have been posted Today Other types of data-flow analysis Reaching definitions, available expressions, reaching constants Abstracting data-flow analysis

More information

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1 Data Flow Analysis Lecture 6 ECS 240 ECS 240 Data Flow Analysis 1 The Plan Introduce a few example analyses Generalize to see the underlying theory Discuss some more advanced issues ECS 240 Data Flow Analysis

More information

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled

More information

We define a dataflow framework. A dataflow framework consists of:

We define a dataflow framework. A dataflow framework consists of: So far been talking about various dataflow problems (e.g. reaching definitions, live variable analysis) in very informal terms. Now we will discuss a more fundamental approach to handle many of the dataflow

More information

(b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15;

(b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15; (a). Translate the program into three address code as defined in Section 6.2, dragon book. (1) i := 2 (2) if i > n goto (7) (3) a[i] := TRUE (4) t2 := i+1 (5) i := t2 (6) goto (2) (7) count := 0 (8) s

More information

The Meet-Over-All-Paths Solution to Data-Flow Problems

The Meet-Over-All-Paths Solution to Data-Flow Problems The Meet-Over-All-Paths Solution to Data-Flow Problems Consider a monotone dataflow framework (L,,F). Assume that the functions f B F represent the effect of a basic block on the sets conatining data for

More information

Goal. Partially-ordered set. Game plan 2/2/2013. Solving fixpoint equations

Goal. Partially-ordered set. Game plan 2/2/2013. Solving fixpoint equations Goal Solving fixpoint equations Many problems in programming languages can be formulated as the solution of a set of mutually recursive equations: D: set, f,g:dxd D x = f(x,y) y = g(x,y) Examples Parsing:

More information

3/11/18. Final Code Generation and Code Optimization

3/11/18. Final Code Generation and Code Optimization Final Code Generation and Code Optimization 1 2 3 for ( i=0; i < N; i++) { base = &a[0]; crt = *(base + i); } original code base = &a[0]; for ( i=0; i < N; i++) { crt = *(base + i); } optimized code e1

More information

Reading: Chapter 9.3. Carnegie Mellon

Reading: Chapter 9.3. Carnegie Mellon I II Lecture 3 Foundation of Data Flow Analysis Semi-lattice (set of values, meet operator) Transfer functions III Correctness, precision and convergence IV Meaning of Data Flow Solution Reading: Chapter

More information

MIT Loop Optimizations. Martin Rinard

MIT Loop Optimizations. Martin Rinard MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination

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

Sets and Motivation for Boolean algebra

Sets and Motivation for Boolean algebra SET THEORY Basic concepts Notations Subset Algebra of sets The power set Ordered pairs and Cartesian product Relations on sets Types of relations and their properties Relational matrix and the graph of

More information

Lecture 10: Data Flow Analysis II

Lecture 10: Data Flow Analysis II CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang

More information

Adventures in Dataflow Analysis

Adventures in Dataflow Analysis Adventures in Dataflow Analysis CSE 401 Section 9-ish Jack Eggleston, Aaron Johnston, & Nate Yazdani Announcements - Code Generation due Announcements - Code Generation due - Compiler Additions due next

More information

Lecture 11: Data Flow Analysis III

Lecture 11: Data Flow Analysis III CS 515 Programming Language and Compilers I Lecture 11: Data Flow Analysis III (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang

More information

2MA105 Algebraic Structures I

2MA105 Algebraic Structures I 2MA105 Algebraic Structures I Per-Anders Svensson http://homepage.lnu.se/staff/psvmsi/2ma105.html Lecture 12 Partially Ordered Sets Lattices Bounded Lattices Distributive Lattices Complemented Lattices

More information

Scalar Optimisation Part 2

Scalar Optimisation Part 2 Scalar Optimisation Part 2 Michael O Boyle January 2014 1 Course Structure L1 Introduction and Recap 4-5 lectures on classical optimisation 2 lectures on scalar optimisation Last lecture on redundant expressions

More information

Compiler Design Spring 2017

Compiler Design Spring 2017 Compiler Design Spring 2017 8.6 Live variables Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Last lecture Definition: A variable V is live at point P if there is a path

More information

Dataflow Analysis - 2. Monotone Dataflow Frameworks

Dataflow Analysis - 2. Monotone Dataflow Frameworks Dataflow Analysis - 2 Monotone dataflow frameworks Definition Convergence Safety Relation of MOP to MFP Constant propagation Categorization of dataflow problems DataflowAnalysis 2, Sp06 BGRyder 1 Monotone

More information

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University Set Theory CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 Set theory Abstract set theory is one of the foundations of mathematical thought Most mathematical

More information

Class Notes on Poset Theory Johan G. Belinfante Revised 1995 May 21

Class Notes on Poset Theory Johan G. Belinfante Revised 1995 May 21 Class Notes on Poset Theory Johan G Belinfante Revised 1995 May 21 Introduction These notes were originally prepared in July 1972 as a handout for a class in modern algebra taught at the Carnegie-Mellon

More information

DFA of non-distributive properties

DFA of non-distributive properties DFA of non-distributive properties The general pattern of Dataflow Analysis GA (p)= i if p E { GA (q) q F } otherwise GA (p)= f p ( GA (p) ) where : E is the set of initial/final points of the control-flow

More information

Space-aware data flow analysis

Space-aware data flow analysis Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it

More information

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed Another Form of Data-Flow Analysis Propagation of values for a variable reference, where is the value produced? for a variable definition, where is the value consumed? Possible answers reaching definitions,

More information

Definitions & Theorems

Definitions & Theorems Definitions & Theorems Math 147, Fall 2009 December 19, 2010 Contents 1 Logic 2 1.1 Sets.................................................. 2 1.2 The Peano axioms..........................................

More information

Lecture Notes: Selected Topics in Discrete Structures. Ulf Nilsson

Lecture Notes: Selected Topics in Discrete Structures. Ulf Nilsson Lecture Notes: Selected Topics in Discrete Structures Ulf Nilsson Dept of Computer and Information Science Linköping University 581 83 Linköping, Sweden ulfni@ida.liu.se 2004-03-09 Contents Chapter 1.

More information

Discrete Fixpoint Approximation Methods in Program Static Analysis

Discrete Fixpoint Approximation Methods in Program Static Analysis Discrete Fixpoint Approximation Methods in Program Static Analysis P. Cousot Département de Mathématiques et Informatique École Normale Supérieure Paris

More information

Answer: A. Answer: C. 3. If (G,.) is a group such that a2 = e, a G, then G is A. abelian group B. non-abelian group C. semi group D.

Answer: A. Answer: C. 3. If (G,.) is a group such that a2 = e, a G, then G is A. abelian group B. non-abelian group C. semi group D. 1. The set of all real numbers under the usual multiplication operation is not a group since A. zero has no inverse B. identity element does not exist C. multiplication is not associative D. multiplication

More information

MAT 570 REAL ANALYSIS LECTURE NOTES. Contents. 1. Sets Functions Countability Axiom of choice Equivalence relations 9

MAT 570 REAL ANALYSIS LECTURE NOTES. Contents. 1. Sets Functions Countability Axiom of choice Equivalence relations 9 MAT 570 REAL ANALYSIS LECTURE NOTES PROFESSOR: JOHN QUIGG SEMESTER: FALL 204 Contents. Sets 2 2. Functions 5 3. Countability 7 4. Axiom of choice 8 5. Equivalence relations 9 6. Real numbers 9 7. Extended

More information

Structure of R. Chapter Algebraic and Order Properties of R

Structure of R. Chapter Algebraic and Order Properties of R Chapter Structure of R We will re-assemble calculus by first making assumptions about the real numbers. All subsequent results will be rigorously derived from these assumptions. Most of the assumptions

More information

Metric Spaces and Topology

Metric Spaces and Topology Chapter 2 Metric Spaces and Topology From an engineering perspective, the most important way to construct a topology on a set is to define the topology in terms of a metric on the set. This approach underlies

More information

Department of Computer Science and Engineering, IIT Kanpur, INDIA. Code Optimization. Sanjeev K Aggarwal Code Optimization 1 of I

Department of Computer Science and Engineering, IIT Kanpur, INDIA. Code Optimization. Sanjeev K Aggarwal Code Optimization 1 of I Code Optimization Sanjeev K Aggarwal Code Optimization 1 of 23 2007-08-I Code Optimization int a,b,c,d ldw a,r1 add r1,r2,r3 c = a+b ldw b,r2 add r3,1,r4 d = c+1 add r1,r2,r3 stw r3,c ldw c,r3 add r3,1,r4

More information

Completeness of Star-Continuity

Completeness of Star-Continuity Introduction to Kleene Algebra Lecture 5 CS786 Spring 2004 February 9, 2004 Completeness of Star-Continuity We argued in the previous lecture that the equational theory of each of the following classes

More information

Intra-procedural Data Flow Analysis Backwards analyses

Intra-procedural Data Flow Analysis Backwards analyses Live variables Dead code elimination Very Busy Expressions Code hoisting Bitvector frameworks Monotone frameworks Intra-procedural Data Flow Analysis Backwards analyses Hanne Riis Nielson and Flemming

More information

3. Abstract Boolean Algebras

3. Abstract Boolean Algebras 3. ABSTRACT BOOLEAN ALGEBRAS 123 3. Abstract Boolean Algebras 3.1. Abstract Boolean Algebra. Definition 3.1.1. An abstract Boolean algebra is defined as a set B containing two distinct elements 0 and 1,

More information

2.2 Some Consequences of the Completeness Axiom

2.2 Some Consequences of the Completeness Axiom 60 CHAPTER 2. IMPORTANT PROPERTIES OF R 2.2 Some Consequences of the Completeness Axiom In this section, we use the fact that R is complete to establish some important results. First, we will prove that

More information

Static Analysis of Programs: A Heap-Centric View

Static Analysis of Programs: A Heap-Centric View Static Analysis of Programs: A Heap-Centric View (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 5 April 2008 Part 1 Introduction ETAPS

More information

Compiler Design Spring 2017

Compiler Design Spring 2017 Compiler Design Spring 2017 8.5 Reaching definitions Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Admin issues Brief reminder: Code review takes place today @ 15:15 You

More information

Boolean Algebras. Chapter 2

Boolean Algebras. Chapter 2 Chapter 2 Boolean Algebras Let X be an arbitrary set and let P(X) be the class of all subsets of X (the power set of X). Three natural set-theoretic operations on P(X) are the binary operations of union

More information

1 The Real Number System

1 The Real Number System 1 The Real Number System The rational numbers are beautiful, but are not big enough for various purposes, and the set R of real numbers was constructed in the late nineteenth century, as a kind of an envelope

More information

Boolean Algebra CHAPTER 15

Boolean Algebra CHAPTER 15 CHAPTER 15 Boolean Algebra 15.1 INTRODUCTION Both sets and propositions satisfy similar laws, which are listed in Tables 1-1 and 4-1 (in Chapters 1 and 4, respectively). These laws are used to define an

More information

CMSC 631 Program Analysis and Understanding Fall Abstract Interpretation

CMSC 631 Program Analysis and Understanding Fall Abstract Interpretation Program Analysis and Understanding Fall 2017 Abstract Interpretation Based on lectures by David Schmidt, Alex Aiken, Tom Ball, and Cousot & Cousot What is an Abstraction? A property from some domain Blue

More information

Lattices and Orders in Isabelle/HOL

Lattices and Orders in Isabelle/HOL Lattices and Orders in Isabelle/HOL Markus Wenzel TU München October 8, 2017 Abstract We consider abstract structures of orders and lattices. Many fundamental concepts of lattice theory are developed,

More information

Model Checking & Program Analysis

Model Checking & Program Analysis Model Checking & Program Analysis Markus Müller-Olm Dortmund University Overview Introduction Model Checking Flow Analysis Some Links between MC and FA Conclusion Apology for not giving proper credit to

More information

Introduction to Abstract Interpretation. ECE 584 Sayan Mitra Lecture 18

Introduction to Abstract Interpretation. ECE 584 Sayan Mitra Lecture 18 Introduction to Abstract Interpretation ECE 584 Sayan Mitra Lecture 18 References Patrick Cousot,RadhiaCousot:Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction

More information

Probabilistic Model Checking and [Program] Analysis (CO469)

Probabilistic Model Checking and [Program] Analysis (CO469) Probabilistic Model Checking and [Program] Analysis (CO469) Program Analysis Herbert Wiklicky herbert@doc.ic.ac.uk Spring 208 / 64 Overview Topics we will cover in this part will include:. Language WHILE

More information

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions Today s Topics Set identities Methods of proof Relationships to logical equivalences Functions Important definitions Relationships to sets, relations Special functions Set identities help us manipulate

More information

Section Summary. Relations and Functions Properties of Relations. Combining Relations

Section Summary. Relations and Functions Properties of Relations. Combining Relations Chapter 9 Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations Closures of Relations (not currently included

More information

Lecture Notes: Program Analysis Correctness

Lecture Notes: Program Analysis Correctness Lecture Notes: Program Analysis Correctness 15-819O: Program Analysis Jonathan Aldrich jonathan.aldrich@cs.cmu.edu Lecture 5 1 Termination As we think about the correctness of program analysis, let us

More information

Mechanics of Static Analysis

Mechanics of Static Analysis Escuela 03 III / 1 Mechanics of Static Analysis David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Escuela 03 III / 2 Outline 1. Small-step semantics: trace generation 2. State generation and

More information

Scalar Optimisation Part 1

Scalar Optimisation Part 1 calar Optimisation Part 1 Michael O Boyle January, 2014 1 Course tructure L1 Introduction and Recap 4/5 lectures on classical optimisation 2 lectures on scalar optimisation Today example optimisations

More information

Lecture 1: Lattice(I)

Lecture 1: Lattice(I) Discrete Mathematics (II) Spring 207 Lecture : Lattice(I) Lecturer: Yi Li Lattice is a special algebra structure. It is also a part of theoretic foundation of model theory, which formalizes the semantics

More information

Lecture Notes in Real Analysis Anant R. Shastri Department of Mathematics Indian Institute of Technology Bombay

Lecture Notes in Real Analysis Anant R. Shastri Department of Mathematics Indian Institute of Technology Bombay Lecture Notes in Real Analysis 2010 Anant R. Shastri Department of Mathematics Indian Institute of Technology Bombay August 6, 2010 Lectures 1-3 (I-week) Lecture 1 Why real numbers? Example 1 Gaps in the

More information

1. Supremum and Infimum Remark: In this sections, all the subsets of R are assumed to be nonempty.

1. Supremum and Infimum Remark: In this sections, all the subsets of R are assumed to be nonempty. 1. Supremum and Infimum Remark: In this sections, all the subsets of R are assumed to be nonempty. Let E be a subset of R. We say that E is bounded above if there exists a real number U such that x U for

More information

MATH 131A: REAL ANALYSIS (BIG IDEAS)

MATH 131A: REAL ANALYSIS (BIG IDEAS) MATH 131A: REAL ANALYSIS (BIG IDEAS) Theorem 1 (The Triangle Inequality). For all x, y R we have x + y x + y. Proposition 2 (The Archimedean property). For each x R there exists an n N such that n > x.

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

MATH41011/MATH61011: FOURIER SERIES AND LEBESGUE INTEGRATION. Extra Reading Material for Level 4 and Level 6

MATH41011/MATH61011: FOURIER SERIES AND LEBESGUE INTEGRATION. Extra Reading Material for Level 4 and Level 6 MATH41011/MATH61011: FOURIER SERIES AND LEBESGUE INTEGRATION Extra Reading Material for Level 4 and Level 6 Part A: Construction of Lebesgue Measure The first part the extra material consists of the construction

More information

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Leopoldo Bertossi 1, Solmaz Kolahi 2, and Laks V. S. Lakshmanan 2 1 Carleton University, Ottawa, Canada. bertossi@scs.carleton.ca

More information

Discrete Mathematics. 2. Relations

Discrete Mathematics. 2. Relations Discrete Mathematics 2. Relations Binary Relations Let A, B be any two sets. A binary relation R from A to B is a subset of A B. E.g., Let < : N N : {(n,m) n < m} The notation a R b or arb means (a,b)îr.

More information

REAL VARIABLES: PROBLEM SET 1. = x limsup E k

REAL VARIABLES: PROBLEM SET 1. = x limsup E k REAL VARIABLES: PROBLEM SET 1 BEN ELDER 1. Problem 1.1a First let s prove that limsup E k consists of those points which belong to infinitely many E k. From equation 1.1: limsup E k = E k For limsup E

More information

AAA616: Program Analysis. Lecture 3 Denotational Semantics

AAA616: Program Analysis. Lecture 3 Denotational Semantics AAA616: Program Analysis Lecture 3 Denotational Semantics Hakjoo Oh 2018 Spring Hakjoo Oh AAA616 2018 Spring, Lecture 3 March 28, 2018 1 / 33 Denotational Semantics In denotational semantics, we are interested

More information

Lecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation

Lecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation 1 Lecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation [Chapter 9] 2 SSA Revisited It is desirable to use

More information

Complete Partial Orders, PCF, and Control

Complete Partial Orders, PCF, and Control Complete Partial Orders, PCF, and Control Andrew R. Plummer TIE Report Draft January 2010 Abstract We develop the theory of directed complete partial orders and complete partial orders. We review the syntax

More information

Cantor-Bendixson, socle, and atomicity H. Simmons

Cantor-Bendixson, socle, and atomicity H. Simmons Cantor-Bendixson, socle, and atomicity H. Simmons The University, Manchester, England Harold.Simmons @ manchester.ac.uk This document is the second in the series [1] [7], concerned with the use of lattices

More information

Causal Dataflow Analysis for Concurrent Programs

Causal Dataflow Analysis for Concurrent Programs Causal Dataflow Analysis for Concurrent Programs Azadeh Farzan P. Madhusudan Department of Computer Science, University of Illinois at Urbana-Champaign. {afarzan,madhu}@cs.uiuc.edu Abstract. We define

More information

Foundations of Abstract Interpretation

Foundations of Abstract Interpretation Escuela 03 II / 1 Foundations of Abstract Interpretation David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Escuela 03 II / 2 Outline 1. Lattices and continuous functions 2. Galois connections,

More information

Chapter 1. Sets and Numbers

Chapter 1. Sets and Numbers Chapter 1. Sets and Numbers 1. Sets A set is considered to be a collection of objects (elements). If A is a set and x is an element of the set A, we say x is a member of A or x belongs to A, and we write

More information

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion CHAPTER 1 Relations 1. Relations and Their Properties 1.1. Definition of a Relation. Definition 1.1.1. A binary relation from a set A to a set B is a subset R A B. If (a, b) R we say a is Related to b

More information

{a, b, c} {a, b} {a, c} {b, c} {a}

{a, b, c} {a, b} {a, c} {b, c} {a} Section 4.3 Order Relations A binary relation is an partial order if it transitive and antisymmetric. If R is a partial order over the set S, we also say, S is a partially ordered set or S is a poset.

More information

That is, there is an element

That is, there is an element Section 3.1: Mathematical Induction Let N denote the set of natural numbers (positive integers). N = {1, 2, 3, 4, } Axiom: If S is a nonempty subset of N, then S has a least element. That is, there is

More information

MATH 102 INTRODUCTION TO MATHEMATICAL ANALYSIS. 1. Some Fundamentals

MATH 102 INTRODUCTION TO MATHEMATICAL ANALYSIS. 1. Some Fundamentals MATH 02 INTRODUCTION TO MATHEMATICAL ANALYSIS Properties of Real Numbers Some Fundamentals The whole course will be based entirely on the study of sequence of numbers and functions defined on the real

More information

Register machines L2 18

Register machines L2 18 Register machines L2 18 Algorithms, informally L2 19 No precise definition of algorithm at the time Hilbert posed the Entscheidungsproblem, just examples. Common features of the examples: finite description

More information

: Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland

: Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland 252-210: Compiler Design 9.5 Live variables 9.6 Available expressions Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Outline Warp up reaching definifons Live variables Available expressions

More information

In N we can do addition, but in order to do subtraction we need to extend N to the integers

In N we can do addition, but in order to do subtraction we need to extend N to the integers Chapter The Real Numbers.. Some Preliminaries Discussion: The Irrationality of 2. We begin with the natural numbers N = {, 2, 3, }. In N we can do addition, but in order to do subtraction we need to extend

More information

Real Analysis - Notes and After Notes Fall 2008

Real Analysis - Notes and After Notes Fall 2008 Real Analysis - Notes and After Notes Fall 2008 October 29, 2008 1 Introduction into proof August 20, 2008 First we will go through some simple proofs to learn how one writes a rigorous proof. Let start

More information

Second-Order Abstract Interpretation via Kleene Algebra

Second-Order Abstract Interpretation via Kleene Algebra Second-Order Abstract Interpretation via Kleene Algebra Łucja Kot lucja@cs.cornell.edu Department of Computer Science Cornell University Ithaca, New York 14853-7501, USA Dexter Kozen kozen@cs.cornell.edu

More information

Iterative Dataflow Analysis

Iterative Dataflow Analysis Iterative Dataflow Analysis CS 352 9/24/07 Slides adapted from Nielson, Nielson, Hankin Principles of Program Analysis Key Ideas Need a mechanism to evaluate (statically) statements in a program Problem:

More information

Denotational Semantics

Denotational Semantics 5 Denotational Semantics In the operational approach, we were interested in how a program is executed. This is contrary to the denotational approach, where we are merely interested in the effect of executing

More information

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

More information

In N we can do addition, but in order to do subtraction we need to extend N to the integers

In N we can do addition, but in order to do subtraction we need to extend N to the integers Chapter 1 The Real Numbers 1.1. Some Preliminaries Discussion: The Irrationality of 2. We begin with the natural numbers N = {1, 2, 3, }. In N we can do addition, but in order to do subtraction we need

More information

Real Analysis. Joe Patten August 12, 2018

Real Analysis. Joe Patten August 12, 2018 Real Analysis Joe Patten August 12, 2018 1 Relations and Functions 1.1 Relations A (binary) relation, R, from set A to set B is a subset of A B. Since R is a subset of A B, it is a set of ordered pairs.

More information

Lecture 4. Algebra, continued Section 2: Lattices and Boolean algebras

Lecture 4. Algebra, continued Section 2: Lattices and Boolean algebras V. Borschev and B. Partee, September 21-26, 2006 p. 1 Lecture 4. Algebra, continued Section 2: Lattices and Boolean algebras CONTENTS 1. Lattices.... 1 1.0. Why lattices?... 1 1.1. Posets... 1 1.1.1. Upper

More information

Optimizing Finite Automata

Optimizing Finite Automata Optimizing Finite Automata We can improve the DFA created by MakeDeterministic. Sometimes a DFA will have more states than necessary. For every DFA there is a unique smallest equivalent DFA (fewest states

More information

Concrete Domains. Gilles Kahn INRIA Sophia Antipolis Gordon D. Plotkin University of Edinburgh

Concrete Domains. Gilles Kahn INRIA Sophia Antipolis Gordon D. Plotkin University of Edinburgh Concrete Domains Gilles Kahn INRIA Sophia Antipolis Gordon D. Plotkin University of Edinburgh May 21, 1993 Abstract This paper introduces the theory of a particular kind of computation domains called concrete

More information

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

Definition: A binary relation R from a set A to a set B is a subset R A B. Example: Chapter 9 1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R A B. Example: Let A = {0,1,2} and B = {a,b} {(0, a), (0, b), (1,a), (2, b)} is a relation from A to B.

More information