Temporal Logic Model- checking with SPIN COMP6004 Stéphane Lo Presti Part 3: The PROMELA Semantics
Last Lecture PROMELA Syntax Process Variables Channels Statements/Conditions
Semantics of PROMELA Operational model based on: Processes (Labelled transition Systems) Variables Channels Semantics engine
What is a semantics? FOLDOC: The meaning of a string in some language, as opposed to syntax which describes how symbols may be combined independent of their meaning. SPIN semantics is operational (i.e. execution) and not denotational (i.e. mathematical)
Semantics engine Derive from the PROMELA model a labelled transition system (LTS) “Executes” step by step the model Check the executability of statements select an executable statement Apply the statement effects Until no statements (either no processes, or end-state)
Variables Defined by Name Scope Domain Initial value Current value
Channels Defined by ID Number of slots Contents, i.e. ordered set of messages (ordered set of variables)
Processes Defined by ID Local variables Local states Initial state Current state Transition relation
LTS (1) Transition ID Source and target local states Boolean condition Effect function (special: unless statement, synchronous communication)
LTS (2) System state Global variables Local variables Set of channels Execution variables Exclusive Handshake Timeout Else Stutter
LTS (3) Initial system state Processes in their initial state Global variables at their initial values Channels with empty contents Execution variables are zero/ false
Overview of the SPIN algorithm (1) while ((E = executable(s)) != {}) {for some {p,t} from E {s’ = apply(t.effect,s) if (handshake == 0) {p.curstate = t.target s=s’ } else { E’= executable(s’) for some {p’,t’} from E’ {p.curstate = t.target s = apply(t’.effect,s’) p’.curstate = t’.target} handshake = 0 }}} while (stutter) {s = s }
Overview of the SPIN algorithm (2) Set executable(State s) { new Set E = {}; new Set e; timeout = False AllProcs: for each active process p {if (exclusive == 0 or exclusive == p.pid) {for u from high to low { e = {}; else = False OneProc:for each transition t in p.trans {if (t.source == p.curstate and t.prty == u and (handshake == 0 or handshake == t.rv) and eval(t.cond) == True) { add {p,t} to set e} } if (e != {}){break add all elements of e to E} else if (else == False) {else = True goto OneProc} } } } if (E == {} and exclusive != 0){exclusive = True goto AllProcs} if (E == {} and timeout == False){timeout = True goto AllProcs} return E}