



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Note1: Should hand by the above deadline a hardcopy in latex, or similar formatting language, to Ms. Andrea Whitesell, my administrative assistant, who is in office SC 2106. Should likewise email the corresponding working code by the same deadline to [email protected]. The Maude specifications and all auxiliary files needed for Exercises 3–6 can be retrieved from the course web page.
fmod INT-LIST is protecting INT. sorts List. op nil : -> List [ctor]. op : : Int List -> List [ctor]. endfm
fmod FRAME-SORTING-REQUIREMENTS is protecting INT-LIST. sort Multiset. subsort Int < Multiset. op sorted : List -> Bool. op null : -> Multiset. op __ : Multiset Multiset -> Multiset [assoc comm id: null]. op mset : List -> Multiset. var L : List. vars N M : Int. eq sorted(nil) = true. eq sorted(N : nil) = true. ceq sorted(N : M : L) = sorted(M : L) if (N <= M) = true. ceq sorted(N : M : L) = false if N <= M = false. eq mset(nil) = null. eq mset(N : L) = N mset(L). endfm
fmod INSERT-SORT is protecting INT-LIST. op ins : Int List -> List. op sort : List -> List. vars N M : Int. var L : List. eq ins(N, nil) = N : nil. ceq ins(N, M : L) = N : M : L if N <= M = true. ceq ins(N, M : L) = M : ins(N, L) if N <= M = false.
eq sort(nil) = nil. eq sort(N : L) = ins(N, sort(L)). endfm
fmod INSERT-SORT-VERIFICATION is protecting INSERT-SORT. protecting FRAME-SORTING-REQUIREMENTS. endfm
Use the version of the Maude ITP available on the course web page (not the one for the Java+ITP tool, but the version you used for a similar exercise in Homework 5) to prove the following goal about the above sorting specification (the goal itself you can also download from the course web page):
select ITP-TOOL. loop init-itp.
(goal ins1 : INSERT-SORT-VERIFICATION |- A{L:List}((sorted(sort(L:List))) = (true)) .)
Please, include both the proof as a list of commands to the ITP, and a printout of your interaction with the ITP in your hardcopy.
fmod NATURAL is sort Natural. op zero : -> Natural [ctor]. op s : Natural -> Natural [ctor]. ops rem2 quo2 : Natural -> Natural. op +’ : Natural Natural -> Natural. op *’ : Natural Natural -> Natural. vars N M : Natural. eq N +’ zero = N. eq N +’ s(M) = s(N +’ M). eq N *’ zero = zero. eq N *’ s(M) = N +’ (N *’ M). eq rem2(s(s(N))) = rem2(N). eq rem2(s(zero)) = s(zero). eq rem2(zero) = zero. eq quo2(s(s(N))) = s(quo2(N)). eq quo2(s(zero)) = zero. eq quo2(zero) = zero. endfm
mod DAMS is protecting NATURAL. sorts Mode System. ops think eat : -> Mode [ctor]. op st : Mode Mode Natural -> System [ctor]. vars L1 L2 : Mode. vars M N : Natural. crl st(think, L2, N) => st(eat, L2, N) if rem2(N)= s(zero).
(e) the original module is deadlock-free.
Indeed, because of (d), even though we originally had an infinite number of initial states, in the abstract system they will be represented by a finite number of initial states, so it is enough to model check the properties for each of those initial states to conclude that they hold for all the (infinitely many) initial states in the original system. You should do that using the Maude model checker. You should also check properties (a)–(c) above using the SCC, MTT, Church-Rosser Checker and Coherence Checker tools, and give a printout of each tool’s output. Note that by Theorem 2 in page 16 of Lecture 26 (a similar argument was used for abstractions for invariants in pg. 14, Lecture 23), checking (c) above in the context of (a) and (b) boils down to checking that the sort Bool (when using the tools you will need the sort NewBool) is protected, which can be done automatically using the SCC, MTT, Church-Rosser Checker tools, as explained in those lectures. Property (b) is the trickiest, and the one where you should do some careful thinking. You should try to check ground coherence of your abstraction giving the command “check ground coherence” for your abstraction module to the ground coherence tool. It is quite possible that the tool will give you some critical pairs it could not check. You now have to:
to convince me you need not give a mechanical proof, since it may be the case that the coherence checker cannot establish ground coherence even after you add some extra rules. What you need to do is to give a sound mathematical argument of why your rules are ground coherent; without that, any model checking results will be bogus. Regarding property (e) above, it is not necessary for you to use the theory transformation explained in Lecture 26, pages 65 and following. It is enough to convince yourself and me that the original module is deadlock-free. Please note the following:
class ThreadGame { public static void main(String[] args) { (new Process(1)).start() ; (new Process(1)).start() ; } }
class Process extends Thread { static int c;
public Process(int i) { c = i ; }
public void run() { while (true) { c = c + c ; } } }
is a simple multithreaded Java program which shows the possible data races between two threads accessing a common variable (you saw a variant of this in Lecture 27). Each thread reads the value of the static variable c twice and writes the sum of the two values back to c. The question is what values can c possibly hold during the infinite execution of the program. Theoretically, it has been proved that all natural numbers can be achieved. Here we want to use JavaFAN to verify this conclusion for a specific natural number using the search command. More specifically, for the natural number 999, please write a search command to find a possible execution during which the value of c becomes 999 at some moment. Hint: the deadlock search function provided by JavaFAN gives a good starting point and the property translation shows the way to extract the value of a static field from the JavaState. Remember how in the last lecture on JavaFAN it was explained how you can see the Maude command corresponding to invoking a JavaFAN search command for deadlocks. You can then modify this Maude command to obtain the search command you need.
class Main { static public void main (String argv[]) { Connector c1, c2, c3; c1 = new Connector(); c2 = new Connector(); c3 = new Connector(); (new Stage(1, c1, c2)).start(); (new Stage(2, c2, c3)).start(); (new Listener(c3)).start(); for (int i=1; i<2; i=i+1) c1.add(i); c1.stop(); } }
class Connector { public int queue = -1; public synchronized int take(){ int value; while ( queue < 0 ) try {wait();} catch (InterruptedException ex) {} value = queue; queue = -1; return value; } public synchronized void add(int o) { queue = o; notifyAll(); } public synchronized void stop(){ queue = 0; notifyAll(); } }
class Stage extends Thread { int id; Connector c1, c2;