Presentation is loading. Please wait.

Presentation is loading. Please wait.

תרגול 9 META LABELS. Basic types of claims State properties.

Similar presentations


Presentation on theme: "תרגול 9 META LABELS. Basic types of claims State properties."— Presentation transcript:

1 תרגול 9 META LABELS

2 Basic types of claims

3

4

5 State properties

6 Basic assertions

7 Path properties

8 labels Any statement can be preceded by a label. The label can be used as a destination of a goto or can be used in a remote reference. Label names must be unique. Any number of labels can be attached to a single statement. active proctype P() { S0: S1:do :: q!p -> S2: q?v :: true od /* S3 */ }

9 Remote reference use for testing the local control state of an active process We can check whether two user process are in the critical state user[1]@critical && user[2]@critical use for testing the value of a local variable in an active process We can refer to the variable count in process Dijkstra Dijkstra : count Normally reserved for use in never claim (see later) mtype {p,v} chan sema = [0] of {mtype} active proctype Dijkstra (){ byte count=1; do :: (count==1)-> sema!p; count=0 :: (count==0)-> sema?v; count=1 od } active [3] proctype user(){ do :: sema?p; critical: skip; sema!v; od }

10 Meta labels

11 End States

12 Example Spin check for valid end state by default. If the user is not interesting in these kind of errors, he can use the run time flag –E. mtype {p,v} chan sema = [0] of {mtype} active proctype Dijkstra (){ byte count=1; end:do :: (count==1)-> sema!p; count=0 :: (count==0)-> sema?v; count=1 od } active [3] proctype user(){ do :: sema?p; critical: skip; sema!v; od }

13 Progress states Mark statements in the model that accomplish something. require that the progress labels will be visited infinitely often in any infinite system execution. Any violation of this requirement can be reported by the verifier as a non-progress cycle.

14 Example active proctype Dijkstra (){ byte count=1; end:do :: (count==1)-> progress:sema!p; count=0 :: (count==0)-> sema?v; count=1 od } $ spin –a dijkstra.pml $cc –DNP –o pan pan.c $./pan -l active [3] proctype user(){ do :: sema?p; critical: skip; sema!v; od }

15 Another example byte x=2; active proctype A (){ do :: x=3-x; progress: skip od } active proctype B (){ do :: x=3-x; od }

16 The out put pan:1: non-progress cycle (at depth 2) pan: wrote fair.pml.trail (Spin Version 6.2.4 -- 8 March 2013) Warning: Search not completed + Partial Order Reduction Full statespace search for: never claim + (:np_:) assertion violations + (if within scope of claim) non-progress cycles + (fairness disabled) invalid end states - (disabled by never claim) State-vector 36 byte, depth reached 5, errors: 1 3 states, stored 0 states, matched 3 transitions (= stored+matched) 0 atomic steps hash conflicts: 0 (resolved) Stats on memory usage (in Megabytes): 0.000 equivalent memory usage for states (stored*(State-vector + overhead)) 0.292 actual memory usage for states 128.000 memory used for hash table (-w24) 0.534 memory used for DFS stack (-m10000) 128.730 total actual memory usage

17 The out put starting claim 2 spin: couldn't find claim 2 (ignored) using statement merging 2: proc 1 (B) fair.pml:10 (state 1) [x = (3-x)] >>>> 4: proc 1 (B) fair.pml:10 (state 1) [x = (3-x)] 6: proc 1 (B) fair.pml:10 (state 1) [x = (3-x)] spin: trail ends after 6 steps #processes: 2 x = 1 6: proc 1 (B) fair.pml:9 (state 2) 6: proc 0 (A) fair.pml:3 (state 3) 2 processes created

18 Fair cycles

19 The out put $ spin –a fair.pml $cc –DNP –o pan pan.c $./pan –l -f

20 The out put (Spin Version 6.2.4 -- 8 March 2013) + Partial Order Reduction Full statespace search for: never claim + (:np_:) assertion violations + (if within scope of claim) non-progress cycles + (fairness enabled) invalid end states - (disabled by never claim) State-vector 36 byte, depth reached 7, errors: 0 8 states, stored (10 visited) 7 states, matched 17 transitions (= visited+matched) 0 atomic steps hash conflicts: 0 (resolved) Stats on memory usage (in Megabytes): 0.000 equivalent memory usage for states (stored*(State-vector + overhead)) 0.292 actual memory usage for states 128.000 memory used for hash table (-w24) 0.534 memory used for DFS stack (-m10000) 128.730 total actual memory usage unreached in proctype A fair.pml:7, state 6, "-end-" (1 of 6 states) unreached in proctype B fair.pml:12, state 5, "-end-" (1 of 5 states)

21 Accept states $ spin –a fair_accept.pml $cc –o pan pan.c $./pan –a (or $./pan –a –f for fair accepted cycles only)

22 Inline-חוב מן העבר An inline definition works much like a preprocessor macro An inline definition must appear before its first use, and must always be defined globally. An invocation (an inline call) is performed with a syntax that is similar to a procedure call in C, but it does not define a new variable scope a inline cannot return a value to the caller. An inline definition may itself contain other inline calls, but it may not call itself recursively.

23 Example mtype = { msg0, msg1, ack0, ack1 }; chan sender = [1] of { mtype }; chan receiver = [1] of { mtype }; inline recv(cur_msg, cur_ack, lst_msg, lst_ack) { do :: receiver?cur_msg -> sender!cur_ack; break /* accept */ :: receiver?lst_msg -> sender!lst_ack od; } inline phase(msg, good_ack, bad_ack) { do :: sender?good_ack -> break :: sender?bad_ack :: timeout -> if :: receiver!msg; :: skip /* lose message */ fi; od } active proctype Sender() { do :: phase(msg1, ack1,ack0); phase(msg0, ack0, ack1) od } active proctype Receiver() { do :: recv(msg1, ack1, msg0, ack0); recv(msg0, ack0, msg1, ack1) od }


Download ppt "תרגול 9 META LABELS. Basic types of claims State properties."

Similar presentations


Ads by Google