Answers to Self-Study Questions

Test Yourself #1

Question 1

Question 2: Show that alpha and gamma form a Galois connection.

First, we will show that Relationship 1 holds: given an arbitrary concrete element c (a set of int values), for every abstract element a such that a > α(c), c ⊆ γ(a). We will do this using cases on concrete element c.

Case 1: c contains only positive ints.

Case 2: c contains only negative ints.

Case 3: c contains only 0.

Case 4: c is some other subset of int vaues.

Now we will show that Relationship 2 holds: given an arbitrary abstract element a, α(γ(a)) ≤ a. We will do this using cases on abstract element a. Here is the first case:

Case 1: a is num.

The other three cases (a is zero, neg, pos) are just as trivial: in all cases, α(γ(a)) = a. We will not provide every excrutiating detail here...


Test Yourself #2

The rule-of-signs abstract interpretation of an expression exp is the result of applying the abstract valuation function to exp: Eabs[[exp]]. This gives us some abstract value a. Applying gamma to a gives us some concrete value, S, a set of (integer) values.

The actual meaning of the expression is the result of applying the standard evaluation function to exp: E[[exp]]. This produces a single (integer) value c -- the value of the expression.

What might be the relationship between c and S, and which of these possible relationships would we consider to be OK, i.e., in which cases would we say that our abstract interpretation is sound, though possibly imprecise?

  1. S = { c }
  2. c ∈ S
  3. not (c ∈ S)
{ E[[exp]] } ⊆ γ(Eabs[[exp]]) only for cases 1 and 2. Therefore, if we can show that this relationship holds, we have shown that our abstract interpretation is consistent with the standard semantics.


Test Yourself #3

.

Test Yourself #4

In the example, there were a finite number of possible execution paths for the given CFG. If we changed the while condition to while (1) or if we added a node read(n) between nodes 3 and 4 and changed node 4 to while (a < n), the number of possible execution paths would either be infinite or could not be determined. This would cause the fixed-point iteration to be infinite (and thus, not computable).


Test Yourself #5

We need to show that, forall a in the abstract domain A:

We will prove this by cases on a. All cases simply use the definitions of α and γ.

Case (1) a = ⊥

So, a = α(γ(a))

Now, without loss of generality, we will assume that there is only one variable v in the program.

Case (2): a maps v to a constant value c.

So, a = α(γ(a))

Case (3): a maps v to ?

So, a = α(γ(a))