Symbolic Analysis. Symbolic analysis tracks the values of variables in programs symbolically as expressions of input variables and other variables, which.

Slides:



Advertisements
Similar presentations
Instructions for using this template. Remember this is Jeopardy, so where I have written Answer this is the prompt the students will see, and where I.
Advertisements

Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Program Verification using Probabilistic Techniques Sumit Gulwani Microsoft Research Invited Talk: VSTTE Workshop August 2006 Joint work with George Necula.
Global Value Numbering using Random Interpretation Sumit Gulwani George C. Necula CS Department University of California, Berkeley.
COMP 110: Introduction to Programming Tyler Johnson Feb 11, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Precise Interprocedural Analysis using Random Interpretation Sumit Gulwani George Necula UC-Berkeley.
Program Analysis using Random Interpretation Sumit Gulwani UC-Berkeley March 2005.
Section 1.8 Homework questions?. Section Concepts 1.8 Linear Equations in Two Variables Slide 2 Copyright (c) The McGraw-Hill Companies, Inc. Permission.
SYSTEMS OF LINEAR EQUATIONS
ALGEBRAIC EXPRESSIONS
1 Program verification: flowchart programs (Book: chapter 7)
Brought To You By- Tutorial Services-The Math Center
Objective - To simplify expressions using the order of operations. Simplify each expression below. 1) 6 + 5(8 - 2) 2) 3) 4)
Discrete Controller Design
Lesson 6A – Loops By John B. Owen All rights reserved ©2011.
Iteration While / until/ for loop. Iteration: while/ Do-while loops Iteration continues until condition is false: 3 important points to remember: 1.Initalise.
Solving Equations How to Solve Them
Linear Least Squares Approximation Jami Durkee. Problem to be Solved Finding Ax=b where there are no solution y=x y=x+2 Interpolation of graphs where.
1 Review of AC Circuits Smith College, EGR 325 March 27, 2006.
What Are They? What Are They ?
Points on a Line Topic
1.1 Sets of Numbers.
Arrays.
7-1 Exponential Functions, Growth and Decay Warm Up
Functions, Domain and Range
Solving Systems of Linear Equations By Elimination
Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Bottoms Up Factoring. Start with the X-box 3-9 Product Sum
Computer Vision Lecture 7: The Fourier Transform
Control Structure There are two kind of control structure in GWBASIC one is iteration/loop or repetitive and second make decision/condition. Iteration/Loop.
Arrays and Strings.
L6:CSC © Dr. Basheer M. Nasef Lecture #6 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
1 Induction Variables Region-Based Analysis Meet and Closure of Transfer Functions Affine Functions of Reference Variables.
Jeffrey D. Ullman Stanford University. 2  A set of nodes N and edges E is a region if: 1.There is a header h in N that dominates all nodes in N. 2.If.
Bernstein’s Conditions. Techniques to Exploit Parallelism in Sequential Programming Hierarchy of levels of parallelism: Procedure or Methods Statements.
Unit 2 Marketing Math.
Rational Expressions Simplifying. Simplifying Rational Expressions The objective is to be able to simplify a rational expression.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
1.2 – Open Sentences and Graphs
Solving Rational Equations A Rational Equation is an equation that contains one or more rational expressions. The following are rational equations:
Absolute Value: A number’s distance from zero on a number line. A number’s absolute value is nonnegative.
Algebra 9.1 Square Roots I will use the inverse of perfect squares to find approximate values of square roots. I will use square roots to evaluate radical.
Linear Equations in One Variable Objective: To find solutions of linear equations.
Constant Propagation. The constant propagation framework is different from all the data-flow problems discussed so far, in that It has an unbounded set.
Writing Linear Equations
Vocabulary Chapter 4. In a relationship between variables, the variable that changes with respect to another variable is called the.
Real Numbers and Their Properties รายวิชา ค ความรู้พื้นฐานสำหรับแคลคูลัส 1 ภาคเรียนที่ 1 ปีการศึกษา 2552.
A line that intersects two or more lines. Transversal.
Machine-Independent Optimizations Ⅱ CS308 Compiler Theory1.
Objective: I can write linear equations that model real world data.
Do Now 10/26/10 In your notebook, explain how you know a function is a function. Then answer if the following three tables are functions or not. x
Array Dependence Analysis COMP 621 Special Topics By Nurudeen Lameed
Linear Equations in Two Variables A Linear Equation in Two Variables is any equation that can be written in the form where A and B are not both zero.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Copyright 2013, 2009, 2005, 2002 Pearson, Education, Inc.
Table of Contents Rational Expressions and Functions where P(x) and Q(x) are polynomials, Q(x) ≠ 0. Example 1: The following are examples of rational expressions:
Algebra 1. Don’t worry about #2.
1 Math Pacing Graphing Linear Equations. Equations as Relations A linear equation can be written in the standard form of a linear equation: Ax + By =
2-6 Special Functions Objectives Students will be able to: 1) identify and graph step, constant, and identity functions 2) Identify and graph absolute.
1 Sections 7.2 – 7.7 Nested Control Statements Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Quadratic and Other Nonlinear Inequalities
THE SUBSTITUTION METHOD
Preliminary Transformations
MSIS 655 Advanced Business Applications Programming
3.2 Linear Functions.
Systems of Inequalities and Linear Programming
§1—2 State-Variable Description The concept of state
Warm Up What three terms come next? 1. 9, 12, 15, 18, . . .
Warm Up What three terms come next? 1. 9, 12, 15, 18, . . .
Presentation transcript:

Symbolic Analysis

Symbolic analysis tracks the values of variables in programs symbolically as expressions of input variables and other variables, which we call reference variables. We may draw out useful information about relationships among variables that are expressed in terms of the same set of reference variables

An Example 1) x = input(); 2) y = x – 1; 3) z = y – 1; 4) A[x] = 10; 5) A[y] = 11; 6) if (z > x) 7) z = x; z = x – 2 &A[x]  &A[y] z > x is never true can be removed

Abstract Domain Since we cannot create succinct and closed- form symbolic expressions for all values computed, we choose an abstract domain and approximate the computations with the most precise expressions within the domain. Constant propagation: { constants, UNDEF, NAC } Symbolic analysis: { affine-expressions, NAA }

Affine Expressions An expression is affine with respect to variables v 1, v 2, …, v n if it can be expressed as c 0 + c 1 v 1 + … + c n v n, where c 0, c 1, …, c n are constants. An affine expression is linear if c 0 is zero.

Induction Variables An affine expression can also be written in terms of the count of iterations through the loop. Variables whose values can be expressed as c 1 i + c 0, where i is the count of iterations through the closest enclosing loop, are known as induction variables.

An Example for (m = 10; m < 20; m++) { x = m * 3; A[x] = 0; } x = 27; for (m = 10; m < 20; m++) { x = x + 3; A[x] = 0; } i, m = i + 10 x = * i for (x = &A + 30; x <= &A + 57; x = x + 3) { *x = 0; }

Other Reference Variables If a variable is not a linear function of the reference variables already chosen, we have the option of treating its value as reference for future operations. a = f(); b = a + 10; c = a + 11;

A Running Example a = 0; for (f = 100; f < 200; f++) { a = a + 1; b = 10 * a; c = 0; for (g = 10; g < 20; g++) { d = b + c; c = c + 1; } a = a + 1; b = 10 * a; c = 0; j = 1; B2B2 a = 0; i = 1; B1B1 d = b + c; c = c + 1; j = j + 1; if j <= 10 goto B 3 B3B3 i = i + 1; if i <= 100 goto B 2 B4B4 R5R5 R6R6 R7R7 R8R8

Data-Flow Values: Symbolic Maps The domain of data-flow values for symbolic analysis is symbolic maps, which are functions that map each variable in the program to a value. The value is either an affine function of reference values, or the special symbol NAA to represent a non-affine expression. If there is only one variable, the bottom value of the semilattice is a map that sends the variable to NAA. The semilattice for n variables is the product of the individual semillatices. We use m NAA to denote the bottom of the semilattice which maps all variables to NAA.

The Running Example var i = 1 1  i  100 j = 1, …, 10 j = 1, …, 10 a 1 i b 10 10i d 10, …, 19 10i, …, 10i + 9 c 1, …, 10 1, …, 10 a = a + 1; b = 10 * a; c = 0; j = 1; B2B2 a = 0; i = 1; B1B1 d = b + c; c = c + 1; j = j + 1; if j <= 10 goto B 3 B3B3 i = i + 1; if i <= 100 goto B 2 B4B4 R5R5 R6R6 R7R7 R8R8

The Running Example m m(a) m(b) m(c) m(d) IN[B 1 ] NAA NAA NAA NAA OUT[B 1 ] 0 NAA NAA NAA IN[B 2 ] i – 1 NAA NAA NAA OUT[B 2 ] i 10i 0 NAA IN[B 3 ] i 10i j – 1 NAA OUT[B 3 ] i 10i j 10i + j – 1 IN[B 4 ] i 10i j 10i + j – 1 OUT[B 4 ] i – 1 10i – 10 j 10i + j – 11

The Running Example a = 0; for (i = 1; i <= 100; i++) { a = i; b = 10 * i; c = 0; for (j = 1; j <= 10; j++) { d = 10 * i + j – 1; c = j; }

Transfer Functions The transfer functions in symbolic analysis send symbolic maps to symbolic maps. The transfer function of statement s, denoted f s, is defined as follows: If s is not an assignment, then f s = I. If s is an assignment to variable x, then f s ( m )( x ) m(v) for all variables v  x, = c 0 + c 1 m(y) + c 2 m(z) if x is assigned c 0 + c 1 y + c 2 z, NAA otherwise.

Composition of Transfer Functions If f 2 ( m )( v ) = NAA, then ( f 2 。 f 1 )( m )( v ) = NAA. If f 2 ( m )( v ) = c 0 +  i c i m(v i ), then ( f 2 。 f 1 )( m )( v ) NAA, if f 1 ( m ) (v i ) = NAA for some i  0, = c i  0 c 0 +  i c i f 1 ( m ) (v i ) otherwise

The Running Example f f (m)(a) f (m)(b) f (m)(c) f (m)(d) f B1 0 m(b) m(c) m(d) f B2 m(a) m(a) m(d) f B3 m(a) m(b) m(c) + 1 m(b) + m(c) f B4 m(a) m(b) m(c) m(d)

Solutions to Data-Flow Problem OUT[B k ] = f B (IN[B k ]), for all B k OUT[B 1 ]  IN 1 [B 2 ] OUT[B 2 ]  IN i,1 [B 3 ], 1  i  100 OUT i, j -1 [B 3 ]  IN i, j [B 3 ],1  i  100, 2  j  10 OUT i,10 [B 3 ]  IN i [B 4 ], 2  i  100 OUT i -1 [B 4 ]  IN i [B 2 ], 1  i  100

Meet of Transfer Functions The meet of two transfer functions: f 1 ( m )( v ) if f 1 ( m )( v ) = f 2 ( m )( v ) ( f 2  f 1 )( m )( v ) = NAA otherwise

Parameterized Function Compositions If f ( m )( x ) = m(x) + c, then f i ( m )( x ) = m(x) + ci for all i  0, x is a basic induction variable. If f ( m )( x ) = m(x), then f i ( m ) ( x ) = m(x) for all i  0, x is a symbolic constant. If f ( m )( x ) = c 0 + c 1 m(x 1 ) + … + c n m(x n ), where each x k is either a basic induction variable or a symbolic constant, then f i ( m )( x ) = c 0 + c 1 f i ( m ) (x 1 ) + … + c n f i ( m ) (x n ) for all i  0, x is an induction variable. In all other cases, f i ( m )( x ) = NAA.

Parameterized Function Compositions The effect of executing a fixed number of iterations is obtained by replacing i above by that number. If the number of iterations is unknown, the value at the start of the last iteration is given by f *. m ( v ) if f ( m )( v ) = m ( v ) f * ( m )( v ) = NAA otherwise

The Running Example m ( a ) if v = a m ( b ) if v = b f i B3 ( m )( v ) = m ( c ) + i if v = c m ( b ) + m ( c ) + i if v = d. m ( a ) if v = a m ( b ) if v = b f * B3 ( m )( v ) = NAA if v = c NAA if v = d.

A Region-Based Algorithm The effect of execution from the start of the loop region to the entry of the i th iteration f R, i,IN[ S ] = (  B  pred ( S ) f S,OUT[ B ] ) i -1 If the number of iterations of a region is known, replace i with the actual count. In the top-down pass, compute f R, i,IN[ B ]. If m ( v ) = NAA, introduce a new reference variable t, all references of m ( v ) are placed by t.

The Running Example f R 5, j,IN[ B3 ] = f j-1 B3 f R 5, j,OUT[ B3 ] = f j B3 f R 6,IN[ B2 ] = I f R 6,IN[ R5 ] = f B2 f R 6,OUT[ B4 ] = I 。 f R 5, 10,OUT[ B3 ] 。 f B2 f R 7, i,IN[ R6 ] = f i-1 R 6,OUT[ B4 ] f R 7, i,OUT[ B4 ] = f i R 6,OUT[ B4 ] f R 8,IN[ B1 ] = I f R 8,IN[ R7 ] = f B1 f R 8,OUT[ B4 ] = I 。 f R 7,100,OUT[ B4 ] 。 f B1

The Running Example f f (m)(a) f (m)(b) f (m)(c) f (m)(d) f R 5, j,IN[ B3 ] m(a) m(b) m(c)+ j -1 NAA f R 5, j,OUT[ B3 ] m(a) m(b) m(c)+ j m(b)+m(c)+ j -1 f R 6,IN[ B2 ] m(a) m(b) m(c) m(d) f R 6,IN[ R5 ] m(a)+1 10m(a)+10 0 m(d) f R 6,OUT[ B4 ] m(a)+1 10m(a) m(a)+9 f R 7, i,IN[ R6 ] m(a)+ i -1 NAANAA NAA f R 7, i,OUT[ B4 ] m(a)+ i 10m(a)+10 i 10 10m(a)+10 i +9 f R 8,IN[ B1 ] m(a) m(b) m(c) m(d) f R 8,IN[ R7 ] 0 m(b) m(c) m(d) f R 8,OUT[ B4 ]

The Running Example IN[B 1 ] = m NAA OUT[B 1 ] = f B1 (IN[B 1 ]) IN i [B 2 ] = f R 7, i,IN[ R6 ] (OUT[B 1 ]) OUT i [B 2 ] = f B2 (IN i [B 2 ]) IN i, j [B 3 ] = f R 5, j,IN[ B3 ] (OUT i [B 2 ]) OUT i, j [B 3 ] = f B2 (IN i, j [B 3 ])

The Running Example for (i = 1; i < n; i++) { a = input(); for (j = 1; j < 10; j++) { a = a – 1; b = j + a; a = a + 1; } for (i = 1; i < n; i++) { a = input(); t = a; for (j = 1; j < 10; j++) { a = t – 1; b = t – 1 + j; a = t; }