

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Foster; Class: PROG ANLYS&UNDERSTANDING; Subject: Computer Science; University: University of Maryland; Term: Spring 2006;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


(a) Draw the dominator tree (b) List the dominance frontiers of each node (c) Put the control-flow graph in SSA form (you can eyeball this instead of running the algorithm by hand)
(Actually, in class the last inequality was an equality, which it usually is in practice; in that case, α and γ would form a Galois insertion.) Similarly, we say that two (arbitrary) functions α and γ form an adjunction if
S ≤ γ(A) iff α(S) ≤ A for all concrete S, abstract A
Show that α and γ form a Galois connection if and only if they form an adjunction.
fun fact n = if (n == 0) then 1 else n*(fact (n-1))
We wish to use abstract interpretation to prove that, given a non-negative integer as input, this function always produces a positive integer as output.
(a) Suppose we use as our abstract domain the rule of signs, so that numbers are represented as one of A = {+, −, 0 , ⊥, >}. We want to compute a function f act′^ : A → A in our abstract domain that soundly models f act. Ultimately, we would like to show that f act′(+) = f act′(0) = +. Since f act is a recursive function, we need to do this by computing a fixpoint. We will compute a series f act 0 , f act 1 , f act 2 ,... of successively more accurate models of f act until we reach a fixpoint. Let f act 0 (x) = ⊥ for all x ∈ A. (Note: We are starting with ⊥ for this problem, and we will use join instead of meet.) Written out in a tabular form, we have
x ⊥ > + − 0 f act 0 (x) ⊥ ⊥ ⊥ ⊥ ⊥
This is our first (rather poor) approximation. To compute the next approximation, f act 1 , for each possible input value of x, we will use abstract interpretation to evaluate f act. When we see the recursive call f act(n − 1), we use our previous approximation f act 0. Formally, we compute a series with f acti+1(x) = AEval(if (n == 0) then 1 else n ∗ (f acti (n − 1))) For example, using this formula to compute f act 1 , we get
x ⊥ > + − 0 f act 1 (x) ⊥ + ⊥ ⊥ +
(Remember that all operations, including the test at the if , are strict in ⊥, e.g., x ∗ ⊥ = ⊥.) Continue computing successive approximations of f act, writing each f acti in tabular form, until you reach a fixpoint f act′. Is it the case that f act′(+) = +? What went wrong? (b) Construct a new abstract domain A′^ for which we can show that f act is positive given non-negative input. Draw a picture showing the lattice structure for A′, and describe (briefly) operations in your new domain (if they are obvious, you can just say that you use the obvious abstract operations). Finally, compute a fixpoint approximation (i.e., give a sequence of tables, as above) for f act in your new abstract domain showing that f act is positive given non-negative input. Note: To get an answer to this problem, AEval() must treat if as precisely as possible, i.e., it must know that the test 0 == 0 is always true, and it must know that n is zero on the true branch of the test n == 0 and non-zero on the false branch.