4 Questions for Homework 2 - Program Verification | CS 476, Lab Reports of Computer Science

Material Type: Lab; Class: Program Verification; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Fall 2006;

Typology: Lab Reports

Pre 2010

Uploaded on 03/11/2009

koofers-user-jbg
koofers-user-jbg 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 476 Homework #2 Due 10:45am on 9/21
Note: Answers to the exercises listed below should be handed to the instructor in hardcopy and in typewritten
form (latex formatting preferred) by the deadline mentioned above. You should also email to ([email protected])
the Maude code for the exercises requiring that.
1. Solve Ex2.2 in Lecture 2.
2. The theory of groups has one sort, say Group, a constant 1, a unary function ( )1and a binary function
and has equations:
x1 = x
x(yz) = (xy)z
x(x)1= 1
Use the rules of inference of Lecture 4 to give a detailed formal proof of each of the following theorems of group
theory:
(x) 1 x=x
(x) (x)1x= 1
(x, y) (xy)1=y
1x
1
3. Solve Exercise 89 (pg. 122) in Peter ¨
Olveczky’s Lecture Notes. Include your solution and evaluation of some
test cases in the hard copy, but email also the code and test cases to [email protected].
4. Consider the following module, defined for computing the smallest element of a multiset of numbers:
fmod NAT-MSET-MIN is
sorts Nat NatMSet .
subsort Nat < NatMSet .
op 0 : -> Nat [ctor] .
op s : Nat -> Nat [ctor] .
op _ _ : NatMSet NatMSet -> NatMSet [assoc comm ctor] .
op _<_ : Nat Nat -> Bool .
op min : NatMSet -> Nat .
vars N M : Nat .
var S : NatMSet .
eq 0 < s(N) = true .
eq s(N) < 0 = false .
eq s(N) < s(M) = N < M .
eq min(N N S) = min(N S) .
ceq min(N M S) = min(N S) if N < M .
ceq min(N M) = N if N < M .
eq min(N) = N .
endfm
This module has two functions that are not completely defined, that is, such that when invoked on some ground
terms do not reduce to constructors. (Note: for the sort Bool, the constructors are of course true and false).
Do the following:
1
pf2

Partial preview of the text

Download 4 Questions for Homework 2 - Program Verification | CS 476 and more Lab Reports Computer Science in PDF only on Docsity!

CS 476 Homework #2 Due 10:45am on 9/

Note: Answers to the exercises listed below should be handed to the instructor in hardcopy and in typewritten form (latex formatting preferred) by the deadline mentioned above. You should also email to ([email protected]) the Maude code for the exercises requiring that.

  1. Solve Ex2.2 in Lecture 2.
  2. The theory of groups has one sort, say Group, a constant 1, a unary function ( )−^1 and a binary function ◦ and has equations: - x ◦ 1 = x - x ◦ (y ◦ z) = (x ◦ y) ◦ z - x ◦ (x)−^1 = 1

Use the rules of inference of Lecture 4 to give a detailed formal proof of each of the following theorems of group theory:

  • (∀x) 1 ◦ x = x
  • (∀x) (x)−^1 ◦ x = 1
  • (∀x, y) (x ◦ y)−^1 = y−^1 ◦ x−^1
  1. Solve Exercise 89 (pg. 122) in Peter Olveczky’s Lecture Notes. Include your solution and evaluation of some¨ test cases in the hard copy, but email also the code and test cases to [email protected].
  2. Consider the following module, defined for computing the smallest element of a multiset of numbers:

fmod NAT-MSET-MIN is sorts Nat NatMSet. subsort Nat < NatMSet. op 0 : -> Nat [ctor]. op s : Nat -> Nat [ctor]. op _ _ : NatMSet NatMSet -> NatMSet [assoc comm ctor]. op < : Nat Nat -> Bool. op min : NatMSet -> Nat. vars N M : Nat. var S : NatMSet. eq 0 < s(N) = true. eq s(N) < 0 = false. eq s(N) < s(M) = N < M. eq min(N N S) = min(N S). ceq min(N M S) = min(N S) if N < M. ceq min(N M) = N if N < M. eq min(N) = N. endfm

This module has two functions that are not completely defined, that is, such that when invoked on some ground terms do not reduce to constructors. (Note: for the sort Bool, the constructors are of course true and false). Do the following:

  • identify the two functions that fail to be fully defined by evaluating them on suitable ground term argu- ments.
  • correct the specification by adding some equations so that all the functions in the module are now com- pletely defined.

Include both a screenshot of your evaluation of problematic expressions in the original module as well as the correct specification in your answer. Also, send a file with the correct module to [email protected]. You can retrieve the module itself from the course web page.