Docsity

3 Problems on Software Modeling and Analysis - Homework 2 | EECS 755, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EECS 755 - Systems Requirements Modeling
Fall Semester, 2007
Homework 2
September 17, 2007
In each problem below, you will define a theory and verify properties im-
plied by that theory. You may turn in a single theory for Problems 1 through
3. You may need additional theories to define a solution for Problem 4.
Remember that list types in Isabelle can be imported by including the Main
theory in your header. (You should include Main in virtually every Isabelle
theory that you write.)
1. Create a parameterized Isabelle datatype for queues. Use the alge-
braic type constructor, datatype for constructors and function def-
initions for observers. Minimally, your definition should include the
following definitions:
(a) add - adds an element to the end of a queue
(b) empty - the empty queue itself
(c) first - returns the first element of a queue
(d) rest - returns all the elements of a queue except the first
(e) isEmpty - returns true when a queue is empty
(f) size - returns the size of a queue
2. Using your definitions from Problem 1, prove the following:
(a) isEmpty(q) =โ‡’rest(add(x, q)) = q
(b) isEmpty(q) =โ‡’add(x, rest(add(y, q))) = add(x, q)
(c) rest(rest(add(x, add(y, empty )))) == rest(add(y, rest(add(x, empty))))
1
pf2

Partial preview of the text

Download 3 Problems on Software Modeling and Analysis - Homework 2 | EECS 755 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 755 - Systems Requirements Modeling

Fall Semester, 2007

Homework 2

September 17, 2007

In each problem below, you will define a theory and verify properties im- plied by that theory. You may turn in a single theory for Problems 1 through

  1. You may need additional theories to define a solution for Problem 4.

Remember that list types in Isabelle can be imported by including the M ain theory in your header. (You should include M ain in virtually every Isabelle theory that you write.)

  1. Create a parameterized Isabelle datatype for queues. Use the alge- braic type constructor, datatype for constructors and function def- initions for observers. Minimally, your definition should include the following definitions:

(a) add - adds an element to the end of a queue (b) empty - the empty queue itself (c) f irst - returns the first element of a queue (d) rest - returns all the elements of a queue except the first (e) isEmpty - returns true when a queue is empty (f) size - returns the size of a queue

  1. Using your definitions from Problem 1, prove the following:

(a) isEmpty(q) =โ‡’ rest(add(x, q)) = q (b) isEmpty(q) =โ‡’ add(x, rest(add(y, q))) = add(x, q) (c) rest(rest(add(x, add(y, empty)))) == rest(add(y, rest(add(x, empty))))

(d) not(isEmpty(add(x, q))) (e) size(q) = 0 =โ‡’ isEmpty(q)

  1. Create an Isabelle theory that defines a queue implementation using the built-in Isabelle list type. Using the definition from Problem 1 as requirements, prove that your new Isabelle queue implementation is in fact a queue. Identify in your documentation what you will verify and why it is sufficient.