CSE403 Winter, 1999Homework #3 Due: In class, Monday, February 8

1. An alarm clock has the following behavior: When the alarm event occurs, i.e., the clock "goes off", a bell will ring for either 30 seconds or until the stop button is pressed, whichever happens first.

Express this behavioral property in real-time logic (RTL).

Let AC, BELL, and STOP be the names of the alarm event class, bell ringing action, and stop button event, repectively.

2. Suppose that file read and write requests are event classes, designated R and W, respectively. Instances of R and W must occur in sequence and satisfy the constraints: Instances of R must be separated by at least 2 time units from preceding instances of R and W, and at least one R must follow a W before another W event occurs. Express these constraints in Real-Time Logic (RTL).

3. Refer to the handout on Real-Time Logic (Chapter 4, Section 4.3), particularly Example 4 (pp.10-11) on the train crossing gate.

Express the given constraint in RTL.4. Asume that you are given the algebraic specification for an Unbounded Stack (class handout). Add a Bottom function to this specification. Bottom returns the first or bottom element of the stack.

 

5. Augment the specifications for the Set object with the operations Cardinality and Difference. Cardinality gives the number of elements in a set. Difference returns the difference between two sets:

Difference(S1, S2) = {x: x Î S1 and x ÏS2}. 6. Add a Reverse operation to the algebraic specification for strings, StringSpec ( pp. 220-221 in text). Reverse take a string as an input argument and returns the string in reverse order. For example, Reverse specifies an operation that would input a string "a b c" and return the string "c b a".

7. Change the specification of Set to Bag (also called Multiset). Do this by (a) modifying the Delete operation so that it only removes one instance of an element and (b) adding a inquiry function named Count. Count takes an item as argument, and returns the number of instances (repeats) of the item in a bag.