

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; Class: SOFTWARE VERIF VALID; Subject: COMPUTER SCIENCE; University: Clemson University; Term: Spring 2007;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CpSc 873 Spring 2007
The goal of this assignment is to give you some practice reasoning about program termination. In particular, the assignment will help to improve your ability to reason rigorously about program termination using mathematical induction based on a variant function.
Choose two beans from the can. If they are the same color, toss them out and put in a white bean. If they are different colors, toss them out and put in a black bean. Assume that you have enough black and white beans laying around that you can always add a bean of either color.
(a) (1 points). Let w be the number of white beans in the can, and let b be the number of black beans in the can. Write the program corresponding to the previous informal description. (Your program should have only two variables, w and b.) (b) (1 points). Calculate the fixed point of this program, simplifying as much as possible. (c) (8 points). Prove, using a variant function, that this program terminates. Be as rigorous as possible.
program EIIP var A : array 0..N − 1 of integer assign ([]x : 0 ≤ x < N : 0 ≤ A[x] < N → A[x], A[A[x]] := A[A[x]], A[x]) (1)
(a) (2 points). Calculate the fixed point of this program, simplifying as much as possible. (b) (8 points). Prove, using a variant function, that this program terminates. Be as rigorous as possible.
The assignment is due at the start of class on March 15th. You are required to turn in a typed document, or alternatively, a document written using exceedingly legible handwriting.
CpSc 873 Spring 2007
Notes on Collaboration
You are required to work individually on this assignment. Please do not consult anyone other than me on any aspect of this assignment.
Assignment Attribution
The questions on this assignment were developed by Paul Sivilotti. Thanks Paul!