Docsity

CS 476 Homework 4: Solving Critical Pairs in Maude - Prof. Jose Meseguer, Assignments of Computer Science

Toggle sidebar
bg1
CS 476 Homework #4 Due 10:45am on 10/26
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 Ex. 3.1 in Lecture 3.
2. Solve Ex. 3.2 in Lecture 3.
3. Consider the following module, which was already used in Homework 3, of lists with an append constructor
function that is associative and has an identity, but where associativity and identity are explicitly defined by
equations:
(fmod LIST is
sort List .
ops a b c nil : -> List [ctor] .
op append : List List -> List [ctor] .
vars L P Q : List .
eq append(append(L, P), Q) = append(L, append(P, Q)) .
eq append(L, nil) = L .
eq append(nil, L) = L .
endfm)
In Homework 3 you were asked to use the Maude Church-Rosser Checker to establish the local confluence of
this module (which with termination implies confluence). But can you do it yourself? That is: you are asked
to:
•compute all the critical paris of this module, give a complete list of them, and explain what computations
you have performed to arrive at that list; and
•show that each critical pair can be joined; you can use Maude for this purpose, for example using the ==
operator to compute that for each critical pair (t, t0) both terms hace the same canonical form.
4. Consider the module
fmod LIST is
protecting INT .
---
op equal : Int Int -> Bool .
ceq equal(N, M)
= true
ifN<=M=true/\M<=N=true.
ceq equal(N, M)
= false
ifN<M=true.
ceq equal(N, M)
= false
ifM<N=true.
---
sorts List .
op nil : -> List [ctor] .
1
pf2

Partial preview of the text

Download CS 476 Homework 4: Solving Critical Pairs in Maude - Prof. Jose Meseguer and more Assignments Computer Science in PDF only on Docsity!

CS 476 Homework #4 Due 10:45am on 10/

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 Ex. 3.1 in Lecture 3.

2. Solve Ex. 3.2 in Lecture 3.

3. Consider the following module, which was already used in Homework 3, of lists with an append constructor

function that is associative and has an identity, but where associativity and identity are explicitly defined by

equations:

(fmod LIST is sort List. ops a b c nil : -> List [ctor]. op append : List List -> List [ctor]. vars L P Q : List. eq append(append(L, P), Q) = append(L, append(P, Q)). eq append(L, nil) = L. eq append(nil, L) = L. endfm)

In Homework 3 you were asked to use the Maude Church-Rosser Checker to establish the local confluence of

this module (which with termination implies confluence). But can you do it yourself? That is: you are asked

to:

  • compute all the critical paris of this module, give a complete list of them, and explain what computations

you have performed to arrive at that list; and

  • show that each critical pair can be joined; you can use Maude for this purpose, for example using the ==

operator to compute that for each critical pair (t, t′) both terms hace the same canonical form.

4. Consider the module

fmod LIST is protecting INT.


op equal : Int Int -> Bool. ceq equal(N, M) = true if N <= M = true /\ M <= N = true. ceq equal(N, M) = false if N < M = true. ceq equal(N, M) = false if M < N = true.


sorts List. op nil : -> List [ctor].

op : : Int List -> List [ctor]. op member : Int List -> Bool. op append : List List -> List. op rev : List -> List. vars N M N1 N2 : Int. vars L L1 L2 : List.


--- append

eq append(nil, L) = L. eq append(N : L1, L2) = N : append(L1, L2).


--- member

eq member(N, nil) = false. ceq member(N1, N2 : L) = true if equal(N1, N2) = true. ceq member(N1, N2 : L) = member(N1, L) if equal(N1, N2) = false.


--- rev

eq rev(nil) = nil. eq rev(N : L) = append(rev(L), N : nil). endfm

use the ITP to prove the following theorem:

(goal rev-append : LIST |- A{L1:List ; L2:List} ((rev(append(L1:List, L2:List))) = (append(rev(L2:List), rev(L1:List)))) .)

Note: You can retrieve both the module and the goal from the course web page.