Docsity

Homework Assignment for CMSC 631, Spring 2006: Monotonic Functions and Lattices - Prof. Je, Assignments of Computer Science

Toggle sidebar
bg1
CMSC 631, Spring 2006
Homework 1
Due Thursday, February 9, in class
1. Let Sbe a finite set, and let Lbe the lattice of subsets of S, with order ⊆. Show that any function
f(x) constructed from union, intersection, and constant sets is monotonic. Here, I mean that f(x) = e
where ecan be specified by the grammar
e::= x|S0|e∪e|e∩e
where S0is any subset of S. Your proof should be by induction on the structure of e.
2. Suppose that we extend the grammar for efrom problem 1 to include the complement operator !e,
where !T=S−T. Is fstill guaranteed to be monotonic? If it is, justify your answer. If it’s not,
explain why a transfer function defined by Out(stmt) = Gen(stmt)∪(In(stmt)−K ill(stmt)), which
seems to include negation, is monotonic.
3. Let Abe a lattice, with order ≤. Define A→Ato be the set of all functions from Ato A, and define
f≤0gif f(x)≤g(x) for all x∈A.
•Show that A→Awith order ≤0is also a lattice. That is, show that for all f, g ∈A→A,ftg
and fugalways exist.
•Suppose lattice Ahas height hand that Ais finite with nelements. What is the height of the
lattice (A→A, ≤0)? (When counting height, count “edges” rather than “nodes,” e.g., if Awere
the lattice {a, b}with a < b, then its height would be 1.)
4. (ASU, exercise 10.35) In class we talked about how an analysis is conservative if it models the behavior
of the program in a way that is safe. As it turns out, “safe” is in the eye of the beholder.
When performing dataflow analysis to estimate the following properties, determine whether too-large
or too-small estimates are conservative. Explain your answer in terms of the intended use of the
information. (Hint: This is a bit of a trick question.)
(a) Available expressions
(b) Variables changed by a procedure
(c) Variables not changed by a procedure
(d) Copy statements reaching a given program point
1

Partial preview of the text

Download Homework Assignment for CMSC 631, Spring 2006: Monotonic Functions and Lattices - Prof. Je and more Assignments Computer Science in PDF only on Docsity!

CMSC 631, Spring 2006

Homework 1

Due Thursday, February 9, in class

  1. Let S be a finite set, and let L be the lattice of subsets of S, with order ⊆. Show that any function f (x) constructed from union, intersection, and constant sets is monotonic. Here, I mean that f (x) = e where e can be specified by the grammar

e ::= x | S′^ | e ∪ e | e ∩ e

where S′^ is any subset of S. Your proof should be by induction on the structure of e.

  1. Suppose that we extend the grammar for e from problem 1 to include the complement operator !e, where !T = S − T. Is f still guaranteed to be monotonic? If it is, justify your answer. If it’s not, explain why a transfer function defined by Out(stmt) = Gen(stmt) ∪ (In(stmt) − Kill(stmt)), which seems to include negation, is monotonic.
  2. Let A be a lattice, with order ≤. Define A → A to be the set of all functions from A to A, and define f ≤′^ g if f (x) ≤ g(x) for all x ∈ A. - Show that A → A with order ≤′^ is also a lattice. That is, show that for all f, g ∈ A → A, f t g and f u g always exist. - Suppose lattice A has height h and that A is finite with n elements. What is the height of the lattice (A → A, ≤′)? (When counting height, count “edges” rather than “nodes,” e.g., if A were the lattice {a, b} with a < b, then its height would be 1.)
  3. (ASU, exercise 10.35) In class we talked about how an analysis is conservative if it models the behavior of the program in a way that is safe. As it turns out, “safe” is in the eye of the beholder. When performing dataflow analysis to estimate the following properties, determine whether too-large or too-small estimates are conservative. Explain your answer in terms of the intended use of the information. (Hint: This is a bit of a trick question.)

(a) Available expressions (b) Variables changed by a procedure (c) Variables not changed by a procedure (d) Copy statements reaching a given program point