CMU 15-671Models of Software SystemsFall 1995
State Machines
Garlan & Wing Homework 5 Due: 27 September 1995
Problem 1. A. Model the M&M dispenser on the third floor of Wean Hall. Write a 4-tuple description and draw out a state transition diagram.
Intuitively, you, the hungry customer, are the ``environment'' of this machine. The dispenser is the ``system''. Remember you are modeling the dispenser and its interactions with the customer. You don't have to model the customer.
So, your set of actions should include putting in a coin, which changes the state of the machine, and turning the knob, which has an effect on the environment (dispensing M&M's!) and changes the state of the machine.
According to your state machine description:
B. Now consider the the M&M machine in the Moose.
Problem 2.
The following problem description, very slightly modified, is sometimes referred to as ``Kemmerer's library problem.''
Consider a small library system with the following actions:
There are two types of users: staff users and ordinary borrowers. Actions listed in 2, 4, and 5 are restricted to staff users, except that ordinary borrowers can perform action 4 to find out the list of books currently borrowed by themselves.
The library system must satisfy the following invariants:
Since the above description is written in English, there are some natural ambiguities and you will need to resolve them in your formalization below. Thus, you may find that in doing Parts A-C, you iterate through different solutions for Part A. This is perfectly normal and in fact, expected!
A. Write a state machine description of the library system. Use pre- and post-conditions to specify the actions. Use a balance of both pre-conditions and exceptional termination conditions to best characterize the behavior of a library in real life. See the middle of p. 9 of Handout 5 for the template to use to describe your actions.
B. Given your formalization of the library in Part A, answer the following questions and explain your answer by referring to your state machine description.
C. Formally characterize each of the four invariants as an predicate. For each, show that your actions preserve it.