# Sign Analysis for Expressions and Programs

## Sign Analysis for Expressions

Suppose we want to test quickly whether the result of an expression is positive, negative or zero.

What is (quickly) the sign of

Why?

What is (quickly) the sign of

Concrete domain:

Concrete operations:

Abstract domain:

Abstract operations: defined by tables:

## Sign Analysis for Programs

Abstract state , maps each variable to element of

We have possible states for variables.

Computation over control-flow graph for our example

- a more complex 'table' than above
- given
- an abstract state (sign or each var)
- a control-flow graph edge
- find state at the other end of the edge

- rules for merging abstract states

When is such computation correct?

What does it even mean for such computation to be correct?

### Abstract Domain

Special case of interval analysis

- Which intervals does it correspond to?
- What is the height of the lattice for one variable, and what if we have program points and variables?