Tuesday and Thursday
11:00 AM - 12:15 PM
What's New (Home)
What's New Archives
CSCI 5828 Homework 3: Programming with Assertions
In-Class Due Date: Lecture 22, April 1, 1999
CATECS Due Date: April 8, 1999
Format for Assignment: Plain ASCII text, in the body of an e-mail message
Read the following paper:
D. S. Rosenblum. "A Practical Approach to Programming with Assertions. IEEE Transactions on Software Engineering, 21(1):19-31, January 1995.
Answer the following questions:
What are two examples of how APP has been integrated with C?
What is the difference between using APP and inserting your own print statements into the code?
APP currently works on C. C++ extends C with the concept of the "class". Briefly describe how you might think APP would need to be extended to handle C++ classes.
Below is Euclid's algorithm for finding the greatest common divisor.
function GCD (x: pos-integer; y: pos-integer) return pos-integer is
while x != y loop
if x > y then
x := x - y;
y := y - x;
a. Add assume and return annotations to the algorithm.
The return annotation is actually quite interesting, since it essentially defines the meaning of "greatest common divisor" as an axiomatic expression. One approach is to ensure that no integer between the common divisor and the smaller of the two input values wil divide both of the two input values.
b. If you were to take the approach described above to specifying the return annotation, it would be pretty heavy handed, and could add substantial overhead to the program. Once you gained confidence in the correctness of your implementation, you might want to be able to turn checking off. What mechanism does APP provide to let you do that?
c. Why is it not necessary to write any promise annotations for this algorithm?