Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / test / src / kind_fmcad08 / simulation / PRODUCER_CONSUMMER_luke_1.lus @ 22fe1c93

History | View | Annotate | Download (1.43 KB)

1
node First( X : int ) returns ( First : int );
2
let
3
    First = X -> pre First;
4
tel
5

    
6
node Sofar( X : bool ) returns ( Sofar : bool );
7
let
8
    Sofar = X -> X and pre Sofar;
9
tel
10

    
11
node excludes3( X1, X2, X3 : bool ) returns ( excludes : bool );
12
let
13
    excludes = not ( X1 and X2 or X1 and X3 or X2 and X3 );
14
tel
15

    
16
--const a_init = 20;
17

    
18
node PRODUCER_CONSUMMER(etat1, etat2, etat3 : bool; a_init : int
19
) returns(i, b, a, o1, o2 : int);
20
var
21
	garde1, garde2, garde3 : bool;
22
let
23
	garde1 = pre i >= 1;
24
	garde2 = pre b >= 1;
25
	garde3 = pre b >= 1;
26

    
27
--	assert #(etat1, etat2, etat3);
28
--	assert a_init >= 0;
29

    
30
	i = a ->
31
	if(etat1) then if(garde1) then pre i -1 else pre i else 
32
	pre i;
33

    
34
	b = 0 -> 
35
	if(etat1) then if(garde1) then pre b+1 else pre b else 
36
	if(etat2) then if(garde2) then pre b-1 else pre b else 
37
	if(garde3) then pre b-1 else pre b;
38

    
39
	a = a_init -> pre a;
40

    
41
	o1 = 0 -> 
42
	if(etat2) then if(garde2) then pre o1+1 else pre o1 else 
43
	pre o1;
44

    
45
	o2 = 0 -> 
46
	if(etat3) then if(garde3) then pre o2+1 else pre o2 else
47
	pre o2;
48

    
49
tel
50
		
51
node top( etat1, etat2, etat3 : bool; a_init : int )
52
returns ( OK : bool );
53
    var i, b, a, o1, o2 : int;
54
        env : bool;
55
let
56
    ( i, b, a, o1, o2 ) = PRODUCER_CONSUMMER (etat1, etat2, etat3, a_init );
57
    env = Sofar( excludes3( etat1, etat2, etat3 ) ) and
58
          First( a_init ) > 0;
59
    OK = env and (not etat1 -> true) =>
60
         (true -> pre etat1 and etat2 => o1 = pre o1 + 1);
61
    --%PROPERTY OK=true;
62
    --%MAIN;
63
tel