Course Location
1B 28
Course Time
Tuesday and Thursday
11:00 AM - 12:15 PM
Topics
What's New (Home)
Class Schedule
Lectures
Assignments
Contact Information
Evaluation Criteria |
CSCI 5828 Homework 3: Programming with Assertions
In-Class Due Date: Lecture 13, February 29, 2000
CATECS Due Date: March 7, 2000
Format for Assignment: Plain ASCII text, in the body of an e-mail message
Assignment
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
begin
while x != y loop
if x > y then
x := x - y;
else
y := y - x;
end if;
end loop;
return x;
end GCD;
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 will 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?
|