spin.html 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490
  1. <html>
  2. <title>
  3. -
  4. </title>
  5. <body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#330088" ALINK="#FF0044">
  6. <H1>Using SPIN
  7. </H1>
  8. <DL><DD><I>Gerard J. Holzmann<br>
  9. gerard@plan9.bell-labs.com<br>
  10. </I></DL>
  11. <DL><DD><H4>ABSTRACT</H4>
  12. SPIN can be used for proving or disproving logical properties
  13. of concurrent systems.
  14. To render the proofs, a concurrent system is first
  15. modeled in a formal specification language called PROMELA.
  16. The language allows one to specify the behaviors
  17. of asynchronously executing
  18. processes that may interact through synchronous
  19. or asynchronous message passing, or through direct
  20. access to shared variables.
  21. <br>&#32;<br>
  22. System models specified in this way can be verified
  23. for both safety and liveness properties. The specification
  24. of general properties in linear time temporal logic is
  25. also supported.
  26. <br>&#32;<br>
  27. The first part of this manual
  28. discusses the basic features of the specification language PROMELA.
  29. The second part describes the verifier SPIN.
  30. </DL>
  31. <H4>1 The Language PROMELA
  32. </H4>
  33. <br>&#32;<br>
  34. PROMELA is short for Protocol Meta Language [Ho91].
  35. PROMELA is a <I>modeling</I> language, not a programming language.
  36. A formal model differs in two essential ways from an implementation.
  37. First, a model is meant to be an abstraction of a design
  38. that contains only those aspects of the design that are
  39. directly relevant to the properties one is interested in proving.
  40. Second, a formal model must contain things that are typically not part
  41. of an implementation, such as worst-case assumptions about
  42. the behavior of the environment that may interact with the
  43. system being studied, and a formal statement of relevant correctness
  44. properties. It is possible to mechanically extract abstract models
  45. from implementation level code, as discussed, for instance in [HS99].
  46. <br>&#32;<br>
  47. Verification with SPIN is often performed in a series of steps,
  48. with the construction of increasingly detailed models.
  49. Each model can be verified under different types of
  50. assumptions about the environment and for different
  51. types of correctness properties.
  52. If a property is not valid for the given assumptions about
  53. system behavior, the verifier can produce a counter-example
  54. that demonstrates how the property may be violated.
  55. If a property is valid, it may be possible to simplify the
  56. model based on that fact, and prove still other properties.
  57. <br>&#32;<br>
  58. Section 1.1 covers the basic building blocks of the language.
  59. Section 1.2 introduces the control flow structures.
  60. Section 1.3 explains how correctness properties are specified.
  61. Section 1.4 concludes the first part with a discussion of
  62. special predefined variables and functions that can be used to
  63. express some correctness properties.
  64. <br>&#32;<br>
  65. Up to date manual pages for SPIN can always be found online at:
  66. http://cm.bell-labs.com/cm/cs/what/spin/Man/
  67. <H4>1.1 Basics
  68. </H4>
  69. <br>&#32;<br>
  70. A PROMELA model can contain three different types of objects:
  71. <DL>
  72. <DT><DT>&#32;<DD>
  73. <DL><DD>
  74. * Processes (section 1.1.1),
  75. <br>
  76. * Variables (section 1.1.2),
  77. <br>
  78. * Message channels (section 1.1.3).
  79. </DL>
  80. </dl>
  81. <br>&#32;<br>
  82. All processes are global objects.
  83. For obvious reasons, a PROMELA model must contain at least one
  84. process to be meaningful.
  85. Since SPIN is specifically meant to prove properties of
  86. concurrent systems, a model typically contains more than
  87. one process.
  88. <br>&#32;<br>
  89. Message channels and variables, the two basic types of data objects,
  90. can be declared with either a global scope or a local scope.
  91. A data object with global scope can be referred to by all processes.
  92. A data object with a local scope can be referred to by just a
  93. single process: the process that declares and instantiates the object.
  94. As usual, all objects must be declared in the specification
  95. before they are referenced.
  96. <H4>1.1.1 Processes
  97. </H4>
  98. <br>&#32;<br>
  99. Here is a simple process that does nothing except print
  100. a line of text:
  101. <DL><DT><DD><TT><PRE>
  102. init {
  103. printf("it works\n")
  104. }
  105. </PRE></TT></DL>
  106. There are a few things to note.
  107. <TT>Init</TT>
  108. is a predefined keyword from the language.
  109. It can be used to declare and instantiate
  110. a single initial process in the model.
  111. (It is comparable to the
  112. <TT>main</TT>
  113. procedure of a C program.)
  114. The
  115. <TT>init</TT>
  116. process does not take arguments, but it can
  117. start up (instantiate) other processes that do.
  118. <TT>Printf</TT>
  119. is one of a few built-in procedures in the language.
  120. It behaves the same as the C version.
  121. Note, finally, that no semicolon follows the single
  122. <TT>printf</TT>
  123. statement in the above example.
  124. In PROMELA, semicolons are used as statement separators,
  125. not statement terminators. (The SPIN parser, however, is
  126. lenient on this issue.)
  127. <br>&#32;<br>
  128. Any process can start new processes by using another
  129. built-in procedure called
  130. <TT>run</TT>.
  131. For example,
  132. <DL><DT><DD><TT><PRE>
  133. proctype you_run(byte x)
  134. {
  135. printf("my x is: %d\n", x)
  136. }
  137. </PRE></TT></DL>
  138. <DL><DT><DD><TT><PRE>
  139. init {
  140. run you_run(1);
  141. run you_run(2)
  142. }
  143. </PRE></TT></DL>
  144. The word
  145. <TT>proctype</TT>
  146. is again a keyword that introduces the declaration
  147. of a new type of process.
  148. In this case, we have named that type
  149. <TT>you_run</TT>
  150. and declared that all instantiations of processes
  151. of this type will take one argument: a data object
  152. of type
  153. <TT>byte</TT>,
  154. that can be referred to within this process by the name
  155. <TT>x</TT>.
  156. Instances of a
  157. <TT>proctype</TT>
  158. can be created with the predefined procedure
  159. <TT>run</TT>,
  160. as shown in the example.
  161. When the
  162. <TT>run</TT>
  163. statement completes, a copy of the process
  164. has been started, and all its arguments have been
  165. initialized with the arguments provided.
  166. The process may, but need not, have performed
  167. any statement executions at this point.
  168. It is now part of the concurrent system,
  169. and its execution can be interleaved arbitrarily with
  170. those of the other, already executing processes.
  171. (More about the semantics of execution follows shortly.)
  172. <br>&#32;<br>
  173. In many cases, we are only interested in creating a
  174. single instance of each process type that is declared,
  175. and the processes require no arguments.
  176. We can define this by prefixing the keyword
  177. <TT>proctype</TT>
  178. from the process declaration with another keyword:
  179. <TT>active</TT>.
  180. Instances of all active proctypes are created when the
  181. system itself is initialized.
  182. We could, for instance, have avoided the use of
  183. <TT>init</TT>
  184. by declaring the corresponding process in the last example
  185. as follows:
  186. <DL><DT><DD><TT><PRE>
  187. active proctype main() {
  188. run you_run(1);
  189. run you_run(2)
  190. }
  191. </PRE></TT></DL>
  192. Note that there are no parameters to instantiate in this
  193. case. Had they been declared, they would default to a
  194. zero value, just like all other data objects
  195. that are not explicitly instantiated.
  196. <br>&#32;<br>
  197. Multiple copies of a process type can also be created in
  198. this way. For example:
  199. <DL><DT><DD><TT><PRE>
  200. active [4] proctype try_me() {
  201. printf("hi, i am process %d\n", _pid)
  202. }
  203. </PRE></TT></DL>
  204. creates four processes.
  205. A predefined variable
  206. <TT>_pid</TT>
  207. is assigned to each running process, and holds
  208. its unique process instantiation number.
  209. In some cases, this number is needed when a reference
  210. has to be made to a specific process.
  211. <br>&#32;<br>
  212. Summarizing: process behavior is declared in
  213. <TT>proctype</TT>
  214. definitions, and it is instantiated with either
  215. <TT>run</TT>
  216. statements or with the prefix
  217. <TT>active</TT>.
  218. Within a proctype declaration, statements are separated
  219. (not terminated) by semicolons.
  220. As we shall see in examples that follow, instead of the
  221. semicolon, one can also use the alternative separator
  222. <TT>-></TT>
  223. (arrow), wherever that may help to clarify the structure
  224. of a PROMELA model.
  225. <H4>Semantics of Execution
  226. </H4>
  227. <br>&#32;<br>
  228. In PROMELA there is no difference between a condition or
  229. expression and a statement.
  230. Fundamental to the semantics of the language is the
  231. notion of the <I>executability</I> of statements.
  232. Statements are either executable or blocked.
  233. Executability is the basic means of enforcing
  234. synchronization between the processes in a distributed system.
  235. A process can wait for an event to happen by waiting
  236. for a statement to become executable.
  237. For instance, instead of writing a busy wait loop:
  238. <DL><DT><DD><TT><PRE>
  239. while (a != b) /* not valid Promela syntax */
  240. skip; /* wait for a==b */
  241. ...
  242. </PRE></TT></DL>
  243. we achieve the same effect in PROMELA with the statement
  244. <DL><DT><DD><TT><PRE>
  245. (a == b);
  246. ...
  247. </PRE></TT></DL>
  248. Often we indicate that the continuation of an execution
  249. is conditional on the truth of some expression by using
  250. the alternate statement separator:
  251. <DL><DT><DD><TT><PRE>
  252. (a == b) -&#62; ...
  253. </PRE></TT></DL>
  254. Assignments and
  255. <TT>printf</TT>
  256. statements are always executable in PROMELA.
  257. A condition, however, can only be executed (passed) when it holds.
  258. If the condition does not hold, execution blocks until it does.
  259. There are similar rules for determining the executability
  260. of all other primitive and compound statements in the
  261. language.
  262. The semantics of each statement is defined in terms of
  263. rules for executability and effect.
  264. The rules for executability set a precondition on the state
  265. of the system in which a statement can be executed.
  266. The effect defines how a statement will alter a
  267. system state when executed.
  268. <br>&#32;<br>
  269. PROMELA assumes that all individual statements are executed
  270. atomically: that is, they model the smallest meaningful entities
  271. of execution in the system being studied.
  272. This means that PROMELA defines the standard asynchronous interleaving
  273. model of execution, where a supposed scheduler is free at
  274. each point in the execution to select any one of the processes
  275. to proceed by executing a single primitive statement.
  276. Synchronization constraints can be used to influence the
  277. interleaving patterns. It is the purpose of a concurrent system's
  278. design to constrain those patterns in such a way that no
  279. correctness requirements can be violated, and all service
  280. requirements are met. It is the purpose of the verifier
  281. either to find counter-examples to a designer's claim that this
  282. goal has been met, or to demonstrate that the claim is indeed valid.
  283. <H4>1.1.2 Variables
  284. </H4>
  285. <br>&#32;<br>
  286. The table summarizes the five basic data types used in PROMELA.
  287. <TT>Bit</TT>
  288. and
  289. <TT>bool</TT>
  290. are synonyms for a single bit of information.
  291. The first three types can store only unsigned quantities.
  292. The last two can hold either positive or negative values.
  293. The precise value ranges of variables of types
  294. <TT>short</TT>
  295. and
  296. <TT>int</TT>
  297. is implementation dependent, and corresponds
  298. to those of the same types in C programs
  299. that are compiled for the same hardware.
  300. The values given in the table are most common.
  301. <br><img src="-.22361.gif"><br>
  302. <br>&#32;<br>
  303. The following example program declares a array of
  304. two elements of type
  305. <TT>bool</TT>
  306. and a scalar variable
  307. <TT>turn</TT>
  308. of the same type.
  309. Note that the example relies on the fact that
  310. <TT>_pid</TT>
  311. is either 0 or 1 here.
  312. <DL><DT><DD><TT><PRE>
  313. /*
  314. * Peterson's algorithm for enforcing
  315. * mutual exclusion between two processes
  316. * competing for access to a critical section
  317. */
  318. bool turn, want[2];
  319. active [2] proctype user()
  320. {
  321. again:
  322. want[_pid] = 1; turn = _pid;
  323. /* wait until this condition holds: */
  324. (want[1 - _pid] == 0 || turn == 1 - _pid);
  325. /* enter */
  326. critical: skip;
  327. /* leave */
  328. want[_pid] = 0;
  329. goto again
  330. }
  331. </PRE></TT></DL>
  332. In the above case, all variables are initialized to zero.
  333. The general syntax for declaring and instantiating a
  334. variable, respectively for scalar and array variables, is:
  335. <DL><DT><DD><TT><PRE>
  336. type name = expression;
  337. type name[constant] = expression
  338. </PRE></TT></DL>
  339. In the latter case, all elements of the array are initialized
  340. to the value of the expression.
  341. A missing initializer fields defaults to the value zero.
  342. As usual, multiple variables of the same type can be grouped
  343. behind a single type name, as in:
  344. <DL><DT><DD><TT><PRE>
  345. byte a, b[3], c = 4
  346. </PRE></TT></DL>
  347. In this example, the variable
  348. <TT>c</TT>
  349. is initialized to the value 4; variable
  350. <TT>a</TT>
  351. and the elements of array
  352. <TT>b</TT>
  353. are all initialized to zero.
  354. <br>&#32;<br>
  355. Variables can also be declared as structures.
  356. For example:
  357. <DL><DT><DD><TT><PRE>
  358. typedef Field {
  359. short f = 3;
  360. byte g
  361. };
  362. typedef Msg {
  363. byte a[3];
  364. int fld1;
  365. Field fld2;
  366. chan p[3];
  367. bit b
  368. };
  369. Msg foo;
  370. </PRE></TT></DL>
  371. introduces two user-defined data types, the first named
  372. <TT>Field</TT>
  373. and the second named
  374. <TT>Msg</TT>.
  375. A single variable named
  376. <TT>foo</TT>
  377. of type
  378. <TT>Msg</TT>
  379. is declared.
  380. All fields of
  381. <TT>foo</TT>
  382. that are not explicitly initialized (in the example, all fields except
  383. <TT>foo.fld2.f</TT>)
  384. are initialized to zero.
  385. References to the elements of a structure are written as:
  386. <DL><DT><DD><TT><PRE>
  387. foo.a[2] = foo.fld2.f + 12
  388. </PRE></TT></DL>
  389. A variable of a user-defined type can be passed as a single
  390. argument to a new process in
  391. <TT>run</TT>
  392. statements.
  393. For instance,
  394. <DL><DT><DD><TT><PRE>
  395. proctype me(Msg z) {
  396. z.a[2] = 12
  397. }
  398. init {
  399. Msg foo;
  400. run me(foo)
  401. }
  402. </PRE></TT></DL>
  403. <br>&#32;<br>
  404. Note that even though PROMELA supports only one-dimensional arrays,
  405. a two-dimensional array can be created indirectly with user-defined
  406. structures, for instance as follows:
  407. <DL><DT><DD><TT><PRE>
  408. typedef Array {
  409. byte el[4]
  410. };
  411. Array a[4];
  412. </PRE></TT></DL>
  413. This creates a data structure of 16 elements that can be
  414. referenced, for instance, as
  415. <TT>a[i].el[j]</TT>.
  416. <br>&#32;<br>
  417. As in C, the indices of an array of
  418. <TT>N</TT>
  419. elements range from 0 to
  420. <TT>N-1</TT>.
  421. <H4>Expressions
  422. </H4>
  423. <br>&#32;<br>
  424. Expressions must be side-effect free in PROMELA.
  425. Specifically, this means that an expression cannot
  426. contain assignments, or send and receive operations (see section 1.1.3).
  427. <DL><DT><DD><TT><PRE>
  428. c = c + 1; c = c - 1
  429. </PRE></TT></DL>
  430. and
  431. <DL><DT><DD><TT><PRE>
  432. c++; c--
  433. </PRE></TT></DL>
  434. are assignments in PROMELA, with the same effects.
  435. But, unlike in C,
  436. <DL><DT><DD><TT><PRE>
  437. b = c++
  438. </PRE></TT></DL>
  439. is not a valid assignment, because the right-hand side
  440. operand is not a valid expression in PROMELA (it is not side-effect free).
  441. <br>&#32;<br>
  442. It is also possible to write a side-effect free conditional
  443. expression, with the following syntax:
  444. <DL><DT><DD><TT><PRE>
  445. (expr1 -&#62; expr2 : expr3)
  446. </PRE></TT></DL>
  447. The parentheses around the conditional expression are required to
  448. avoid misinterpretation of the arrow.
  449. The example expression has the value of <TT>expr2</TT> when <TT>expr1</TT>
  450. evaluates to a non-zero value, and the value of <TT>expr3</TT> otherwise.
  451. <br>&#32;<br>
  452. In assignments like
  453. <DL><DT><DD><TT><PRE>
  454. variable = expression
  455. </PRE></TT></DL>
  456. the values of all operands used inside the expression are first cast to
  457. signed integers before the operands are applied.
  458. After the evaluation of the expression completes, the value produced
  459. is cast to the type of the target variable before the assignment takes place.
  460. <H4>1.1.3 Message Channels
  461. </H4>
  462. <br>&#32;<br>
  463. Message channels are used to model the transfer of data
  464. between processes.
  465. They are declared either locally or globally,
  466. for instance as follows:
  467. <DL><DT><DD><TT><PRE>
  468. chan qname = [16] of { short, byte }
  469. </PRE></TT></DL>
  470. The keyword
  471. <TT>chan</TT>
  472. introduces a channel declaration.
  473. In this case, the channel is named
  474. <TT>qname</TT>,
  475. and it is declared to be capable of storing up
  476. to 16 messages.
  477. Each message stored in the channel is declared here to
  478. consist of two fields: one of type
  479. <TT>short</TT>
  480. and one of type
  481. <TT>byte</TT>.
  482. The fields of a message can be any one of the basic types
  483. <TT>bit</TT>,
  484. <TT>bool</TT>,
  485. <TT>byte</TT>,
  486. <TT>short</TT>,
  487. <TT>int</TT>,
  488. and
  489. <TT>chan</TT>,
  490. or any user-defined type.
  491. Message fields cannot be declared as arrays.
  492. <br>&#32;<br>
  493. A message field of type
  494. <TT>chan</TT>
  495. can be used to pass a channel identifier
  496. through a channel from one process to another.
  497. <br>&#32;<br>
  498. The statement
  499. <DL><DT><DD><TT><PRE>
  500. qname!expr1,expr2
  501. </PRE></TT></DL>
  502. sends the values of expressions
  503. <TT>expr1</TT>
  504. and
  505. <TT>expr2</TT>
  506. to the channel that we just created. It appends
  507. the message field created from the values of the two
  508. expressions (and cast to the appropriate types of the
  509. message fields declared for
  510. <TT>qname</TT>)
  511. to the tail of the message buffer of 16 slots that belongs
  512. to channel
  513. <TT>qname</TT>.
  514. By default the send statement is only executable if the target
  515. channel is non-full.
  516. (This default semantics can be changed in the verifier into
  517. one where the send statement is always executable, but the
  518. message will be lost when an attempt is made to append it to
  519. a full channel.)
  520. <br>&#32;<br>
  521. The statement
  522. <DL><DT><DD><TT><PRE>
  523. qname?var1,var2
  524. </PRE></TT></DL>
  525. retrieves a message from the head of the same buffer,
  526. and stores the two expressions in variables
  527. <TT>var1</TT>
  528. and
  529. <TT>var2</TT>.
  530. <br>&#32;<br>
  531. The receive statement is executable only if the source channel
  532. is non-empty.
  533. <br>&#32;<br>
  534. If more parameters are sent per message than were declared
  535. for the message channel, the redundant parameters are lost.
  536. If fewer parameters are sent than declared,
  537. the value of the remaining parameters is undefined.
  538. Similarly, if the receive operation tries to retrieve more
  539. parameters than available, the value of the extra parameters is
  540. undefined; if it receives fewer than the number of parameters
  541. sent, the extra information is lost.
  542. <br>&#32;<br>
  543. An alternative, and equivalent, notation for the
  544. send and receive operations is to structure the
  545. message fields with parentheses, as follows:
  546. <DL><DT><DD><TT><PRE>
  547. qname!expr1(expr2,expr3)
  548. qname?var1(var2,var3)
  549. </PRE></TT></DL>
  550. In the above case, we assume that
  551. <TT>qname</TT>
  552. was declared to hold messages consisting of three fields.
  553. <P>
  554. Some or all of the arguments of the receive operation
  555. can be given as constants instead of as variables:
  556. <DL><DT><DD><TT><PRE>
  557. qname?cons1,var2,cons2
  558. </PRE></TT></DL>
  559. In this case, an extra condition on the executability of the
  560. receive operation is that the value of all message fields
  561. specified as constants match the value of the corresponding
  562. fields in the message that is to be received.
  563. </P>
  564. <br>&#32;<br>
  565. Here is an example that uses some of the mechanisms introduced
  566. so far.
  567. <DL><DT><DD><TT><PRE>
  568. proctype A(chan q1)
  569. { chan q2;
  570. q1?q2;
  571. q2!123
  572. }
  573. </PRE></TT></DL>
  574. <DL><DT><DD><TT><PRE>
  575. proctype B(chan qforb)
  576. { int x;
  577. qforb?x;
  578. printf("x = %d\n", x)
  579. }
  580. </PRE></TT></DL>
  581. <DL><DT><DD><TT><PRE>
  582. init {
  583. chan qname = [1] of { chan };
  584. chan qforb = [1] of { int };
  585. run A(qname);
  586. run B(qforb);
  587. qname!qforb
  588. }
  589. </PRE></TT></DL>
  590. The value printed by the process of type
  591. <TT>B</TT>
  592. will be
  593. <TT>123</TT>.
  594. <br>&#32;<br>
  595. A predefined function
  596. <TT>len(qname)</TT>
  597. returns the number of messages currently
  598. stored in channel
  599. <TT>qname</TT>.
  600. Two shorthands for the most common uses of this
  601. function are
  602. <TT>empty(qname)</TT>
  603. and
  604. <TT>full(qname)</TT>,
  605. with the obvious connotations.
  606. <br>&#32;<br>
  607. Since all expressions must be side-effect free,
  608. it is not valid to say:
  609. <DL><DT><DD><TT><PRE>
  610. (qname?var == 0)
  611. </PRE></TT></DL>
  612. or
  613. <DL><DT><DD><TT><PRE>
  614. (a &#62; b &amp;&amp; qname!123)
  615. </PRE></TT></DL>
  616. We could rewrite the second example (using an atomic sequence,
  617. as explained further in section 1.2.1):
  618. <DL><DT><DD><TT><PRE>
  619. atomic { (a &#62; b &amp;&amp; !full(qname)) -&#62; qname!123 }
  620. </PRE></TT></DL>
  621. The meaning of the first example is ambiguous. It could mean
  622. that we want the condition to be true if the receive operation
  623. is unexecutable. In that case, we can rewrite it without
  624. side-effects as:
  625. <DL><DT><DD><TT><PRE>
  626. empty(qname)
  627. </PRE></TT></DL>
  628. It could also mean that we want the condition
  629. to be true when the channel does contain a message with
  630. value zero.
  631. We can specify that as follows:
  632. <DL><DT><DD><TT><PRE>
  633. atomic { qname?[0] -&#62; qname?var }
  634. </PRE></TT></DL>
  635. The first statement of this atomic sequence is
  636. an expression without side-effects that
  637. evaluates to a non-zero value only if the
  638. receive operation
  639. <DL><DT><DD><TT><PRE>
  640. qname?0
  641. </PRE></TT></DL>
  642. would have been executable at that
  643. point (i.e., channel
  644. <TT>qname</TT>
  645. contains at least one message and the oldest
  646. message stored consists of one message field
  647. equal to zero).
  648. Any receive statement can be turned into
  649. a side-effect free expression by placing square
  650. brackets around the list of all message parameters.
  651. The channel contents remain undisturbed by the
  652. evaluation of such expressions.
  653. <br>&#32;<br>
  654. Note carefully, however, that in non-atomic sequences
  655. of two statements such as
  656. <DL><DT><DD><TT><PRE>
  657. !full(qname) -&#62; qname!msgtype
  658. </PRE></TT></DL>
  659. and
  660. <DL><DT><DD><TT><PRE>
  661. qname?[msgtype] -&#62; qname?msgtype
  662. </PRE></TT></DL>
  663. the second statement is not necessarily executable
  664. after the first one has been executed.
  665. There may be race conditions when access to the channels
  666. is shared between several processes.
  667. Another process can send a message to the channel
  668. just after this process determined that it was not full,
  669. or another process can steal away the
  670. message just after our process determined its presence.
  671. <br>&#32;<br>
  672. Two other types of send and receive statements are used
  673. less frequently: sorted send and random receive.
  674. A sorted send operation is written with two, instead of one,
  675. exclamation marks, as follows:
  676. <DL><DT><DD><TT><PRE>
  677. qname!!msg
  678. </PRE></TT></DL>
  679. A sorted send operation will insert a message into the channel's buffer
  680. in numerical order, instead of in FIFO order.
  681. The channel contents are scanned from the first message towards the
  682. last, and the message is inserted immediately before the first message
  683. that follows it in numerical order.
  684. To determine the numerical order, all message fields are
  685. taken into account.
  686. <br>&#32;<br>
  687. The logical counterpart of the sorted send operation
  688. is the random receive.
  689. It is written with two, instead of one, question marks:
  690. <DL><DT><DD><TT><PRE>
  691. qname??msg
  692. </PRE></TT></DL>
  693. A random receive operation is executable if it is executable for <I>any</I>
  694. message that is currently buffered in a message channel (instead of
  695. only for the first message in the channel).
  696. Normal send and receive operations can freely be combined with
  697. sorted send and random receive operations.
  698. <H4>Rendezvous Communication
  699. </H4>
  700. <br>&#32;<br>
  701. So far we have talked about asynchronous communication between processes
  702. via message channels, declared in statements such as
  703. <DL><DT><DD><TT><PRE>
  704. chan qname = [N] of { byte }
  705. </PRE></TT></DL>
  706. where
  707. <TT>N</TT>
  708. is a positive constant that defines the buffer size.
  709. A logical extension is to allow for the declaration
  710. <DL><DT><DD><TT><PRE>
  711. chan port = [0] of { byte }
  712. </PRE></TT></DL>
  713. to define a rendezvous port.
  714. The channel size is zero, that is, the channel
  715. <TT>port</TT>
  716. can pass, but cannot store, messages.
  717. Message interactions via such rendezvous ports are
  718. by definition synchronous.
  719. Consider the following example:
  720. <DL><DT><DD><TT><PRE>
  721. #define msgtype 33
  722. chan name = [0] of { byte, byte };
  723. active proctype A()
  724. { name!msgtype(124);
  725. name!msgtype(121)
  726. }
  727. </PRE></TT></DL>
  728. <DL><DT><DD><TT><PRE>
  729. active proctype B()
  730. { byte state;
  731. name?msgtype(state)
  732. }
  733. </PRE></TT></DL>
  734. Channel
  735. <TT>name</TT>
  736. is a global rendezvous port.
  737. The two processes will synchronously execute their first statement:
  738. a handshake on message
  739. <TT>msgtype</TT>
  740. and a transfer of the value 124 to local variable
  741. <TT>state</TT>.
  742. The second statement in process
  743. <TT>A</TT>
  744. will be unexecutable,
  745. because there is no matching receive operation in process
  746. <TT>B</TT>.
  747. <br>&#32;<br>
  748. If the channel
  749. <TT>name</TT>
  750. is defined with a non-zero buffer capacity,
  751. the behavior is different.
  752. If the buffer size is at least 2, the process of type
  753. <TT>A</TT>
  754. can complete its execution, before its peer even starts.
  755. If the buffer size is 1, the sequence of events is as follows.
  756. The process of type
  757. <TT>A</TT>
  758. can complete its first send action, but it blocks on the
  759. second, because the channel is now filled to capacity.
  760. The process of type
  761. <TT>B</TT>
  762. can then retrieve the first message and complete.
  763. At this point
  764. <TT>A</TT>
  765. becomes executable again and completes,
  766. leaving its last message as a residual in the channel.
  767. <br>&#32;<br>
  768. Rendezvous communication is binary: only two processes,
  769. a sender and a receiver, can be synchronized in a
  770. rendezvous handshake.
  771. <br>&#32;<br>
  772. As the example shows, symbolic constants can be defined
  773. with preprocessor macros using
  774. <TT>#define</TT>.
  775. The source text of a PROMELA model is translated by the standard
  776. C preprocessor.
  777. The disadvantage of defining symbolic names in this way is,
  778. however, that the PROMELA parser will only see the expanded text,
  779. and cannot refer to the symbolic names themselves.
  780. To prevent that, PROMELA also supports another way to define
  781. symbolic names, which are preserved in error reports.
  782. For instance, by including the declaration
  783. <DL><DT><DD><TT><PRE>
  784. mtype = { ack, msg, error, data };
  785. </PRE></TT></DL>
  786. at the top of a PROMELA model, the names provided between the
  787. curly braces are equivalent to integers of type
  788. <TT>byte</TT>,
  789. but known by their symbolic names to the SPIN parser and the
  790. verifiers it generates.
  791. The constant values assigned start at 1, and count up.
  792. There can be only one
  793. <TT>mtype</TT>
  794. declaration per model.
  795. <H4>1.2 Control Flow
  796. </H4>
  797. <br>&#32;<br>
  798. So far, we have seen only some of the basic statements
  799. of PROMELA, and the way in which they can be combined to
  800. model process behaviors.
  801. The five types of statements we have mentioned are:
  802. <TT>printf</TT>,
  803. <TT>assignment</TT>,
  804. <TT>condition</TT>,
  805. <TT>send</TT>,
  806. and
  807. <TT>receive</TT>.
  808. <br>&#32;<br>
  809. The pseudo-statement
  810. <TT>skip</TT>
  811. is syntactically and semantically equivalent to the
  812. condition
  813. <TT>(1)</TT>
  814. (i.e., to true), and is in fact quietly replaced with this
  815. expression by the lexical analyzer of SPIN.
  816. <br>&#32;<br>
  817. There are also five types of compound statements.
  818. <DL>
  819. <DT><DT>&#32;<DD>
  820. <DL><DD>
  821. *
  822. Atomic sequences (section 1.2.1),
  823. <br>
  824. *
  825. Deterministic steps (section 1.2.2),
  826. <br>
  827. *
  828. Selections (section 1.2.3),
  829. <br>
  830. *
  831. Repetitions (section 1.2.4),
  832. <br>
  833. *
  834. Escape sequences (section 1.2.5).
  835. </DL>
  836. </dl>
  837. <br>&#32;<br>
  838. <H4>1.2.1 Atomic Sequences
  839. </H4>
  840. <br>&#32;<br>
  841. The simplest compound statement is the
  842. <TT>atomic</TT>
  843. sequence:
  844. <DL><DT><DD><TT><PRE>
  845. atomic { /* swap the values of a and b */
  846. tmp = b;
  847. b = a;
  848. a = tmp
  849. }
  850. </PRE></TT></DL>
  851. In the example, the values of two variables
  852. <TT>a</TT>
  853. and
  854. <TT>b</TT>
  855. are swapped in a sequence of statement executions
  856. that is defined to be uninterruptable.
  857. That is, in the interleaving of process executions, no
  858. other process can execute statements from the moment that
  859. the first statement of this sequence begins to execute until
  860. the last one has completed.
  861. <br>&#32;<br>
  862. It is often useful to use
  863. <TT>atomic</TT>
  864. sequences to start a series of processes in such a
  865. way that none of them can start executing statements
  866. until all of them have been initialized:
  867. <DL><DT><DD><TT><PRE>
  868. init {
  869. atomic {
  870. run A(1,2);
  871. run B(2,3);
  872. run C(3,1)
  873. }
  874. }
  875. </PRE></TT></DL>
  876. <TT>Atomic</TT>
  877. sequences may be non-deterministic.
  878. If any statement inside an
  879. <TT>atomic</TT>
  880. sequence is found to be unexecutable, however,
  881. the atomic chain is broken, and another process can take over
  882. control.
  883. When the blocking statement becomes executable later,
  884. control can non-deterministically return to the process,
  885. and the atomic execution of the sequence resumes as if
  886. it had not been interrupted.
  887. <H4>1.2.2 Deterministic Steps
  888. </H4>
  889. <br>&#32;<br>
  890. Another way to define an indivisible sequence of actions
  891. is to use the
  892. <TT>d_step</TT>
  893. statement.
  894. In the above case, for instance, we could also have written:
  895. <DL><DT><DD><TT><PRE>
  896. d_step { /* swap the values of a and b */
  897. tmp = b;
  898. b = a;
  899. a = tmp
  900. }
  901. </PRE></TT></DL>
  902. The difference between a
  903. <TT>d_step</TT>
  904. sequence
  905. and an
  906. <TT>atomic</TT>
  907. sequence are:
  908. <DL COMPACT>
  909. <DT>*<DD>
  910. A
  911. <TT>d_step</TT>
  912. sequence must be completely deterministic.
  913. (If non-determinism is nonetheless encountered,
  914. it is always resolved in a fixed and deterministic
  915. way: i.e., the first true guard in selection or
  916. repetition structures is always selected.)
  917. <DT>*<DD>
  918. No
  919. <TT>goto</TT>
  920. jumps into or out of a
  921. <TT>d_step</TT>
  922. sequence are permitted.
  923. <DT>*<DD>
  924. The execution of a
  925. <TT>d_step</TT>
  926. sequence cannot be interrupted when a
  927. blocking statement is encountered.
  928. It is an error if any statement other than
  929. the first one in a
  930. <TT>d_step</TT>
  931. sequence is found to be unexecutable.
  932. <DT>*<DD>
  933. A
  934. <TT>d_step</TT>
  935. sequence is executed as one single statement.
  936. In a way, it is a mechanism for adding new types
  937. of statements to the language.
  938. </dl>
  939. <br>&#32;<br>
  940. None of the items listed above apply to
  941. <TT>atomic</TT>
  942. sequences.
  943. This means that the keyword
  944. <TT>d_step</TT>
  945. can always be replaced with the keyword
  946. <TT>atomic</TT>,
  947. but the reverse is not true.
  948. (The main, perhaps the only, reason for using
  949. <TT>d_step</TT>
  950. sequences is to improve the efficiency of
  951. verifications.)
  952. <H4>1.2.3 Selection Structures
  953. </H4>
  954. <br>&#32;<br>
  955. A more interesting construct is the selection structure.
  956. Using the relative values of two variables
  957. <TT>a</TT>
  958. and
  959. <TT>b</TT>
  960. to choose between two options, for instance, we can write:
  961. <DL><DT><DD><TT><PRE>
  962. if
  963. :: (a != b) -&#62; option1
  964. :: (a == b) -&#62; option2
  965. fi
  966. </PRE></TT></DL>
  967. The selection structure above contains two execution sequences,
  968. each preceded by a double colon.
  969. Only one sequence from the list will be executed.
  970. A sequence can be selected only if its first statement is executable.
  971. The first statement is therefore called a <I>guard</I>.
  972. <br>&#32;<br>
  973. In the above example the guards are mutually exclusive, but they
  974. need not be.
  975. If more than one guard is executable, one of the corresponding sequences
  976. is selected nondeterministically.
  977. If all guards are unexecutable the process will block until at least
  978. one of them can be selected.
  979. There is no restriction on the type of statements that can be used
  980. as a guard: it may include sends or receives, assignments,
  981. <TT>printf</TT>,
  982. <TT>skip</TT>,
  983. etc.
  984. The rules of executability determine in each case what the semantics
  985. of the complete selection structure will be.
  986. The following example, for instance, uses receive statements
  987. as guards in a selection.
  988. <DL><DT><DD><TT><PRE>
  989. mtype = { a, b };
  990. chan ch = [1] of { byte };
  991. active proctype A()
  992. { ch!a
  993. }
  994. </PRE></TT></DL>
  995. <DL><DT><DD><TT><PRE>
  996. active proctype B()
  997. { ch!b
  998. }
  999. </PRE></TT></DL>
  1000. <DL><DT><DD><TT><PRE>
  1001. active proctype C()
  1002. { if
  1003. :: ch?a
  1004. :: ch?b
  1005. fi
  1006. }
  1007. </PRE></TT></DL>
  1008. The example defines three processes and one channel.
  1009. The first option in the selection structure of the process
  1010. of type
  1011. <TT>C</TT>
  1012. is executable if the channel contains
  1013. a message named
  1014. <TT>a</TT>,
  1015. where
  1016. <TT>a</TT>
  1017. is a symbolic constant defined in the
  1018. <TT>mtype</TT>
  1019. declaration at the start of the program.
  1020. The second option is executable if it contains a message
  1021. <TT>b</TT>,
  1022. where, similarly,
  1023. <TT>b</TT>
  1024. is a symbolic constant.
  1025. Which message will be available depends on the unknown
  1026. relative speeds of the processes.
  1027. <br>&#32;<br>
  1028. A process of the following type will either increment
  1029. or decrement the value of variable
  1030. <TT>count</TT>
  1031. once.
  1032. <DL><DT><DD><TT><PRE>
  1033. byte count;
  1034. active proctype counter()
  1035. {
  1036. if
  1037. :: count++
  1038. :: count--
  1039. fi
  1040. }
  1041. </PRE></TT></DL>
  1042. Assignments are always executable, so the choice made
  1043. here is truly a non-deterministic one that is independent
  1044. of the initial value of the variable (zero in this case).
  1045. <H4>1.2.4 Repetition Structures
  1046. </H4>
  1047. <br>&#32;<br>
  1048. We can modify the above program as follows, to obtain
  1049. a cyclic program that randomly changes the value of
  1050. the variable up or down, by replacing the selection
  1051. structure with a repetition.
  1052. <DL><DT><DD><TT><PRE>
  1053. byte count;
  1054. active proctype counter()
  1055. {
  1056. do
  1057. :: count++
  1058. :: count--
  1059. :: (count == 0) -&#62; break
  1060. od
  1061. }
  1062. </PRE></TT></DL>
  1063. Only one option can be selected for execution at a time.
  1064. After the option completes, the execution of the structure
  1065. is repeated.
  1066. The normal way to terminate the repetition structure is
  1067. with a
  1068. <TT>break</TT>
  1069. statement.
  1070. In the example, the loop can be
  1071. broken only when the count reaches zero.
  1072. Note, however, that it need not terminate since the other
  1073. two options remain executable.
  1074. To force termination we could modify the program as follows.
  1075. <DL><DT><DD><TT><PRE>
  1076. active proctype counter()
  1077. {
  1078. do
  1079. :: (count != 0) -&#62;
  1080. if
  1081. :: count++
  1082. :: count--
  1083. fi
  1084. :: (count == 0) -&#62; break
  1085. od
  1086. }
  1087. </PRE></TT></DL>
  1088. A special type of statement that is useful in selection
  1089. and repetition structures is the
  1090. <TT>else</TT>
  1091. statement.
  1092. An
  1093. <TT>else</TT>
  1094. statement becomes executable only if no other statement
  1095. within the same process, at the same control-flow point,
  1096. is executable.
  1097. We could try to use it in two places in the above example:
  1098. <DL><DT><DD><TT><PRE>
  1099. active proctype counter()
  1100. {
  1101. do
  1102. :: (count != 0) -&#62;
  1103. if
  1104. :: count++
  1105. :: count--
  1106. :: else
  1107. fi
  1108. :: else -&#62; break
  1109. od
  1110. }
  1111. </PRE></TT></DL>
  1112. The first
  1113. <TT>else</TT>,
  1114. inside the nested selection structure, can never become
  1115. executable though, and is therefore redundant (both alternative
  1116. guards of the selection are assignments, which are always
  1117. executable).
  1118. The second usage of the
  1119. <TT>else</TT>,
  1120. however, becomes executable exactly when
  1121. <TT>!(count != 0)</TT>
  1122. or
  1123. <TT>(count == 0)</TT>,
  1124. and is therefore equivalent to the latter to break from the loop.
  1125. <br>&#32;<br>
  1126. There is also an alternative way to exit the do-loop, without
  1127. using a
  1128. <TT>break</TT>
  1129. statement: the infamous
  1130. <TT>goto</TT>.
  1131. This is illustrated in the following implementation of
  1132. Euclid's algorithm for finding the greatest common divisor
  1133. of two non-zero, positive numbers:
  1134. <DL><DT><DD><TT><PRE>
  1135. proctype Euclid(int x, y)
  1136. {
  1137. do
  1138. :: (x &#62; y) -&#62; x = x - y
  1139. :: (x &#60; y) -&#62; y = y - x
  1140. :: (x == y) -&#62; goto done
  1141. od;
  1142. done:
  1143. skip
  1144. }
  1145. </PRE></TT></DL>
  1146. <DL><DT><DD><TT><PRE>
  1147. init { run Euclid(36, 12) }
  1148. </PRE></TT></DL>
  1149. The
  1150. <TT>goto</TT>
  1151. in this example jumps to a label named
  1152. <TT>done</TT>.
  1153. Since a label can only appear before a statement,
  1154. we have added the dummy statement
  1155. <TT>skip</TT>.
  1156. Like a
  1157. <TT>skip</TT>,
  1158. a
  1159. <TT>goto</TT>
  1160. statement is always executable and has no other
  1161. effect than to change the control-flow point
  1162. of the process that executes it.
  1163. <br>&#32;<br>
  1164. As a final example, consider the following implementation of
  1165. a Dijkstra semaphore, which is implemented with the help of
  1166. a synchronous channel.
  1167. <DL><DT><DD><TT><PRE>
  1168. #define p 0
  1169. #define v 1
  1170. chan sema = [0] of { bit };
  1171. </PRE></TT></DL>
  1172. <DL><DT><DD><TT><PRE>
  1173. active proctype Dijkstra()
  1174. { byte count = 1;
  1175. do
  1176. :: (count == 1) -&#62;
  1177. sema!p; count = 0
  1178. :: (count == 0) -&#62;
  1179. sema?v; count = 1
  1180. od
  1181. }
  1182. </PRE></TT></DL>
  1183. <DL><DT><DD><TT><PRE>
  1184. active [3] proctype user()
  1185. { do
  1186. :: sema?p;
  1187. /* critical section */
  1188. sema!v;
  1189. /* non-critical section */
  1190. od
  1191. }
  1192. </PRE></TT></DL>
  1193. The semaphore guarantees that only one of the three user processes
  1194. can enter its critical section at a time.
  1195. It does not necessarily prevent the monopolization of
  1196. the access to the critical section by one of the processes.
  1197. <br>&#32;<br>
  1198. PROMELA does not have a mechanism for defining functions or
  1199. procedures. Where necessary, though, these may be
  1200. modeled with the help of additional processes.
  1201. The return value of a function, for instance, can be passed
  1202. back to the calling process via global variables or messages.
  1203. The following program illustrates this by recursively
  1204. calculating the factorial of a number
  1205. <TT>n</TT>.
  1206. <DL><DT><DD><TT><PRE>
  1207. proctype fact(int n; chan p)
  1208. { chan child = [1] of { int };
  1209. int result;
  1210. if
  1211. :: (n &#60;= 1) -&#62; p!1
  1212. :: (n &#62;= 2) -&#62;
  1213. run fact(n-1, child);
  1214. child?result;
  1215. p!n*result
  1216. fi
  1217. }
  1218. </PRE></TT></DL>
  1219. <DL><DT><DD><TT><PRE>
  1220. init
  1221. { chan child = [1] of { int };
  1222. int result;
  1223. run fact(7, child);
  1224. child?result;
  1225. printf("result: %d\n", result)
  1226. }
  1227. </PRE></TT></DL>
  1228. Each process creates a private channel and uses it
  1229. to communicate with its direct descendant.
  1230. There are no input statements in PROMELA.
  1231. The reason is that models must always be complete to
  1232. allow for logical verifications, and input statements
  1233. would leave at least the source of some information unspecified.
  1234. A way to read input
  1235. would presuppose a source of information that is not
  1236. part of the model.
  1237. <br>&#32;<br>
  1238. We have already discussed a few special types of statement:
  1239. <TT>skip</TT>,
  1240. <TT>break</TT>,
  1241. and
  1242. <TT>else</TT>.
  1243. Another statement in this class is the
  1244. <TT>timeout</TT>.
  1245. The
  1246. <TT>timeout</TT>
  1247. is comparable to a system level
  1248. <TT>else</TT>
  1249. statement: it becomes executable if and only if no other
  1250. statement in any of the processes is executable.
  1251. <TT>Timeout</TT>
  1252. is a modeling feature that provides for an escape from a
  1253. potential deadlock state.
  1254. The
  1255. <TT>timeout</TT>
  1256. takes no parameters, because the types of properties we
  1257. would like to prove for PROMELA models must be proven independent
  1258. of all absolute and relative timing considerations.
  1259. In particular, the relative speeds of processes can never be
  1260. known with certainty in an asynchronous system.
  1261. <H4>1.2.5 Escape Sequences
  1262. </H4>
  1263. <br>&#32;<br>
  1264. The last type of compound structure to be discussed is the
  1265. <TT>unless</TT>
  1266. statement.
  1267. It is used as follows:
  1268. <DL><DT><DD><TT><PRE>
  1269. { P } unless { E }
  1270. </PRE></TT></DL>
  1271. where the letters
  1272. <TT>P</TT>
  1273. and
  1274. <TT>E</TT>
  1275. represent arbitrary PROMELA fragments.
  1276. Execution of the
  1277. <TT>unless</TT>
  1278. statement begins with the execution of statements from
  1279. <TT>P</TT>.
  1280. Before each statement execution in
  1281. <TT>P</TT>
  1282. the executability of the first statement of
  1283. <TT>E</TT>
  1284. is checked, using the normal PROMELA semantics of executability.
  1285. Execution of statements from
  1286. <TT>P</TT>
  1287. proceeds only while the first statement of
  1288. <TT>E</TT>
  1289. remains unexecutable.
  1290. The first time that this `guard of the escape sequence'
  1291. is found to be executable, control changes to it,
  1292. and execution continues as defined for
  1293. <TT>E</TT>.
  1294. Individual statement executions remain indivisible,
  1295. so control can only change from inside
  1296. <TT>P</TT>
  1297. to the start of
  1298. <TT>E</TT>
  1299. in between individual statement executions.
  1300. If the guard of the escape sequence
  1301. does not become executable during the
  1302. execution of
  1303. <TT>P</TT>,
  1304. then it is skipped entirely when
  1305. <TT>P</TT>
  1306. terminates.
  1307. <br>&#32;<br>
  1308. An example of the use of escape sequences is:
  1309. <DL><DT><DD><TT><PRE>
  1310. A;
  1311. do
  1312. :: b1 -&#62; B1
  1313. :: b2 -&#62; B2
  1314. ...
  1315. od
  1316. unless { c -&#62; C };
  1317. D
  1318. </PRE></TT></DL>
  1319. As shown in the example, the curly braces around the main sequence
  1320. (or the escape sequence) can be deleted if there can be no confusion
  1321. about which statements belong to those sequences.
  1322. In the example, condition
  1323. <TT>c</TT>
  1324. acts as a watchdog on the repetition construct from the main sequence.
  1325. Note that this is not necessarily equivalent to the construct
  1326. <DL><DT><DD><TT><PRE>
  1327. A;
  1328. do
  1329. :: b1 -&#62; B1
  1330. :: b2 -&#62; B2
  1331. ...
  1332. :: c -&#62; break
  1333. od;
  1334. C; D
  1335. </PRE></TT></DL>
  1336. if
  1337. <TT>B1</TT>
  1338. or
  1339. <TT>B2</TT>
  1340. are non-empty.
  1341. In the first version of the example, execution of the iteration can
  1342. be interrupted at <I>any</I> point inside each option sequence.
  1343. In the second version, execution can only be interrupted at the
  1344. start of the option sequences.
  1345. <H4>1.3 Correctness Properties
  1346. </H4>
  1347. <br>&#32;<br>
  1348. There are three ways to express correctness properties in PROMELA,
  1349. using:
  1350. <DL>
  1351. <DT><DT>&#32;<DD>
  1352. <DL><DD>
  1353. <br>
  1354. *
  1355. Assertions (section 1.3.1),
  1356. <br>
  1357. *
  1358. Special labels (section 1.3.2),
  1359. <br>
  1360. *
  1361. <TT>Never</TT>
  1362. claims (section 1.3.3).
  1363. </DL>
  1364. </dl>
  1365. <br>&#32;<br>
  1366. <H4>1.3.1 Assertions
  1367. </H4>
  1368. <br>&#32;<br>
  1369. Statements of the form
  1370. <DL><DT><DD><TT><PRE>
  1371. assert(expression)
  1372. </PRE></TT></DL>
  1373. are always executable.
  1374. If the expression evaluates to a non-zero value (i.e., the
  1375. corresponding condition holds), the statement has no effect
  1376. when executed.
  1377. The correctness property expressed, though, is that it is
  1378. impossible for the expression to evaluate to zero (i.e., for
  1379. the condition to be false).
  1380. A failing assertion will cause execution to be aborted.
  1381. <H4>1.3.2 Special Labels
  1382. </H4>
  1383. <br>&#32;<br>
  1384. Labels in a PROMELA specification ordinarily serve as
  1385. targets for unconditional
  1386. <TT>goto</TT>
  1387. jumps, as usual.
  1388. There are, however, also three types of labels that
  1389. have a special meaning to the verifier.
  1390. We discuss them in the next three subsections.
  1391. <H4>1.3.2.1 End-State Labels
  1392. </H4>
  1393. <br>&#32;<br>
  1394. When a PROMELA model is checked for reachable deadlock states
  1395. by the verifier, it must be able to distinguish valid <I>end state</I>s
  1396. from invalid ones.
  1397. By default, the only valid end states are those in which
  1398. every PROMELA process that was instantiated has reached the end of
  1399. its code.
  1400. Not all PROMELA processes, however, are meant to reach the
  1401. end of their code.
  1402. Some may very well linger in a known wait
  1403. state, or they may sit patiently in a loop
  1404. ready to spring into action when new input arrives.
  1405. <br>&#32;<br>
  1406. To make it clear to the verifier that these alternate end states
  1407. are also valid, we can define special end-state labels.
  1408. We can do so, for instance, in the process type
  1409. <TT>Dijkstra</TT>,
  1410. from an earlier example:
  1411. <DL><DT><DD><TT><PRE>
  1412. proctype Dijkstra()
  1413. { byte count = 1;
  1414. end: do
  1415. :: (count == 1) -&#62;
  1416. sema!p; count = 0
  1417. :: (count == 0) -&#62;
  1418. sema?v; count = 1
  1419. od
  1420. }
  1421. </PRE></TT></DL>
  1422. The label
  1423. <TT>end</TT>
  1424. defines that it is not an error if, at the end of an
  1425. execution sequence, a process of this type
  1426. has not reached its closing curly brace, but waits at the label.
  1427. Of course, such a state could still be part of a deadlock state, but
  1428. if so, it is not caused by this particular process.
  1429. <br>&#32;<br>
  1430. There may be more than one end-state label per PROMELA model.
  1431. If so, all labels that occur within the same process body must
  1432. be unique.
  1433. The rule is that every label name with the prefix
  1434. <TT>end</TT>
  1435. is taken to be an end-state label.
  1436. <H4>1.3.2.2 Progress-State Labels
  1437. </H4>
  1438. <br>&#32;<br>
  1439. In the same spirit, PROMELA also allows for the definition of
  1440. <TT>progress</TT>
  1441. labels.
  1442. Passing a progress label during an execution is interpreted
  1443. as a good thing: the process is not just idling while
  1444. waiting for things to happen elsewhere, but is making
  1445. effective progress in its execution.
  1446. The implicit correctness property expressed here is that any
  1447. infinite execution cycle allowed by the model that does not
  1448. pass through at least one of these progress labels is a
  1449. potential starvation loop.
  1450. In the
  1451. <TT>Dijkstra</TT>
  1452. example, for instance, we can label the
  1453. successful passing of a semaphore test as progress and
  1454. ask a verifier to make sure that there is no cycle elsewhere
  1455. in the system.
  1456. <DL><DT><DD><TT><PRE>
  1457. proctype Dijkstra()
  1458. { byte count = 1;
  1459. end: do
  1460. :: (count == 1) -&#62;
  1461. progress: sema!p; count = 0
  1462. :: (count == 0) -&#62;
  1463. sema?v; count = 1
  1464. od
  1465. }
  1466. </PRE></TT></DL>
  1467. If more than one state carries a progress label,
  1468. variations with a common prefix are again valid.
  1469. <H4>1.3.2.3 Accept-State Labels
  1470. </H4>
  1471. <br>&#32;<br>
  1472. The last type of label, the accept-state label, is used
  1473. primarily in combination with
  1474. <TT>never</TT>
  1475. claims.
  1476. Briefly, by labeling a state with any label starting
  1477. with the prefix
  1478. <TT>accept</TT>
  1479. we can ask the verifier to find all cycles that <I>do</I>
  1480. pass through at least one of those labels.
  1481. The implicit correctness claim is that this cannot happen.
  1482. The primary place where accept labels are used is inside
  1483. <TT>never</TT>
  1484. claims.
  1485. We discuss
  1486. <TT>never</TT>
  1487. claims next.
  1488. <H4>1.3.3 Never Claims
  1489. </H4>
  1490. <br>&#32;<br>
  1491. Up to this point we have talked about the specification
  1492. of correctness criteria with assertions
  1493. and with three special types of labels.
  1494. Powerful types of correctness criteria can already
  1495. be expressed with these tools, yet so far our only option is
  1496. to add them to individual
  1497. <TT>proctype</TT>
  1498. declarations.
  1499. We can, for instance, express the claim ``every system state
  1500. in which property
  1501. <TT>P</TT>
  1502. is true eventually leads to a system state in which property
  1503. <TT>Q</TT>
  1504. is true,'' with an extra monitor process, such as:
  1505. <DL><DT><DD><TT><PRE>
  1506. active proctype monitor()
  1507. {
  1508. progress:
  1509. do
  1510. :: P -&#62; Q
  1511. od
  1512. }
  1513. </PRE></TT></DL>
  1514. If we require that property
  1515. <TT>P</TT>
  1516. must <I>remain</I> true while we are waiting
  1517. <TT>Q</TT>
  1518. to become true, we can try to change this to:
  1519. <DL><DT><DD><TT><PRE>
  1520. active proctype monitor()
  1521. {
  1522. progress:
  1523. do
  1524. :: P -&#62; assert(P || Q)
  1525. od
  1526. }
  1527. </PRE></TT></DL>
  1528. but this does not quite do the job.
  1529. Note that we cannot make any assumptions about the
  1530. relative execution speeds of processes in a PROMELA model.
  1531. This means that if in the remainder of the system the
  1532. property
  1533. <TT>P</TT>
  1534. becomes true, we can move to the state just before the
  1535. <TT>assert</TT>,
  1536. and wait there for an unknown amount of time (anything between
  1537. a zero delay and an infinite delay is possible here, since
  1538. no other synchronizations apply).
  1539. If
  1540. <TT>Q</TT>
  1541. becomes true, we may pass the assertion, but we need not
  1542. do so.
  1543. Even if
  1544. <TT>P</TT>
  1545. becomes false only <I>after</I>
  1546. <TT>Q</TT>
  1547. has become true, we may still fail the assertion,
  1548. as long as there exists some later state where neither
  1549. <TT>P</TT>
  1550. nor
  1551. <TT>Q</TT>
  1552. is true.
  1553. This is clearly unsatisfactory, and we need another mechanism
  1554. to express these important types of liveness properties.
  1555. <H4>The Connection with Temporal Logic
  1556. </H4>
  1557. <br>&#32;<br>
  1558. A general way to express system properties of the type we
  1559. have just discussed is to use linear time temporal logic (LTL)
  1560. formulae.
  1561. Every PROMELA expression is automatically also a valid LTL formula.
  1562. An LTL formula can also contain the unary temporal operators &#164;
  1563. (pronounced always), &#186; (pronounced eventually), and
  1564. two binary temporal operators
  1565. <TT>U</TT>
  1566. (pronounced weak until) and
  1567. <B><I>U</I></B>
  1568. (pronounced strong until).
  1569. <br>&#32;<br>
  1570. Where the value of a PROMELA expression without temporal operators can be
  1571. defined uniquely for individual system states, without further context,
  1572. the truth value of an LTL formula is defined for sequences of states:
  1573. specifically, it is defined for the first state of a given infinite
  1574. sequence of system states (a trace).
  1575. Given, for instance, the sequence of system states:
  1576. <DL><DT><DD><TT><PRE>
  1577. s0;s1;s2;...
  1578. </PRE></TT></DL>
  1579. the LTL formula
  1580. <TT>pUq</TT>,
  1581. with
  1582. <TT>p</TT>
  1583. and
  1584. <TT>q</TT>
  1585. standard PROMELA expressions, is true for
  1586. <TT>s0</TT>
  1587. either if
  1588. <TT>q</TT>
  1589. is true in
  1590. <TT>s0</TT>,
  1591. or if
  1592. <TT>p</TT>
  1593. is true in
  1594. <TT>s0</TT>
  1595. and
  1596. <TT>pUq</TT>
  1597. holds for the remainder of the sequence after
  1598. <TT>s0</TT>.
  1599. <br>&#32;<br>
  1600. Informally,
  1601. <TT>pUq</TT>
  1602. says that
  1603. <TT>p</TT>
  1604. is required to hold at least until
  1605. <TT>q</TT>
  1606. becomes true.
  1607. If, instead, we would write <TT>p</TT><B><I>U</I></B><TT>q</TT>,
  1608. then we also require that there exists at least
  1609. one state in the sequence where
  1610. <TT>q</TT>
  1611. does indeed become true.
  1612. <br>&#32;<br>
  1613. The temporal operators &#164; and &#186;
  1614. can be defined in terms of the strong until operator
  1615. <B><I>U</I></B>,
  1616. as follows.
  1617. <DL><DT><DD><TT><PRE>
  1618. &#164; p = !&#186; !p = !(true <B><I>U</I></B><TT> !p)
  1619. </PRE></TT></DL>
  1620. Informally, &#164;
  1621. </TT><TT>p</TT><TT>
  1622. says that property
  1623. </TT><TT>p</TT><TT>
  1624. must hold in all states of a trace, and &#186;
  1625. </TT><TT>p</TT><TT>
  1626. says that
  1627. </TT><TT>p</TT><TT>
  1628. holds in at least one state of the trace.
  1629. </TT><br>&#32;<br>
  1630. To express our original example requirement: ``every system state
  1631. in which property
  1632. <TT>P</TT>
  1633. is true eventually leads to a system state in which property
  1634. <TT>Q</TT>
  1635. is true,''
  1636. we can write the LTL formula:
  1637. <DL><DT><DD><TT><PRE>
  1638. &#164; (P -&#62; &#186; Q)
  1639. </PRE></TT></DL>
  1640. where the logical implication symbol
  1641. <TT>-></TT>
  1642. is defined in the usual way as
  1643. <DL><DT><DD><TT><PRE>
  1644. P =&#62; Q means !P || Q
  1645. </PRE></TT></DL>
  1646. <H4>Mapping LTL Formulae onto Never Claims
  1647. </H4>
  1648. <br>&#32;<br>
  1649. PROMELA does not include syntax for specifying LTL formulae
  1650. directly, but it relies on the fact that every such
  1651. formula can be translated into a special type of
  1652. automaton, known as a B&uuml;chi automaton.
  1653. In the syntax of PROMELA this automaton is called a
  1654. <TT>never</TT>
  1655. claim.
  1656. If you don't care too much about the details of
  1657. <TT>never</TT>
  1658. claims, you can skip the remainder of this section and
  1659. simple remember that SPIN can convert any LTL formula
  1660. automatically into the proper never claim syntax with
  1661. the command:
  1662. <DL><DT><DD><TT><PRE>
  1663. spin -f "...formula..."
  1664. </PRE></TT></DL>
  1665. Here are the details.
  1666. The syntax of a never claim is:
  1667. <DL><DT><DD><TT><PRE>
  1668. never {
  1669. ...
  1670. }
  1671. </PRE></TT></DL>
  1672. where the dots can contain any PROMELA fragment, including
  1673. arbitrary repetition, selection, unless constructs,
  1674. jumps, etc.
  1675. <br>&#32;<br>
  1676. There is an important difference in semantics between a
  1677. <TT>proctype</TT>
  1678. declaration and a
  1679. <TT>never</TT>
  1680. claim.
  1681. Every statement inside a
  1682. <TT>never</TT>
  1683. claim is interpreted as a proposition, i.e., a condition.
  1684. A
  1685. <TT>never</TT>
  1686. claim should therefore only contain expressions and never
  1687. statements that can have side-effects (assignments, sends or
  1688. receives, run-statements, etc.)
  1689. <br>&#32;<br>
  1690. <TT>Never</TT>
  1691. claims are used to express behaviors that are considered
  1692. undesirable or illegal.
  1693. We say that a
  1694. <TT>never</TT>
  1695. claim is `matched' if the undesirable behavior can be realized,
  1696. contrary to the claim, and thus the correctness requirement violated.
  1697. The claims are evaluated over system executions, that is, the
  1698. propositions that are listed in the claim are evaluated over the
  1699. traces from the remainder of the system.
  1700. The claim, therefore, should not alter that behavior: it merely
  1701. monitors it.
  1702. Every time that the system reaches a new state, by asynchronously
  1703. executing statements from the model, the claim will evaluate the
  1704. appropriate propositions to determine if a counter-example can
  1705. be constructed to the implicit LTL formula that is specified.
  1706. <br>&#32;<br>
  1707. Since LTL formulae are only defined for infinite executions,
  1708. the behavior of a
  1709. <TT>never</TT>
  1710. claim can only be matched by an infinite system execution.
  1711. This by itself would restrict us to the use of progress labels
  1712. and accept labels as the only means we have discussed so far
  1713. for expressing properties of infinite behaviors.
  1714. To conform to standard omega automata theory, the behaviors of
  1715. <TT>never</TT>
  1716. claims are expressed exclusively with
  1717. <TT>accept</TT>
  1718. labels (never with
  1719. <TT>progress</TT>
  1720. labels).
  1721. To match a claim, therefore, an infinite sequence of true propositions
  1722. must exist, at least one of which is labeled with an
  1723. <TT>accept</TT>
  1724. label (inside the never claim).
  1725. <br>&#32;<br>
  1726. Since PROMELA models can also express terminating system behaviors,
  1727. we have to define the semantics of the
  1728. <TT>never</TT>
  1729. claims also for those behaviors.
  1730. To facilitate this, it is defined that a
  1731. <TT>never</TT>
  1732. claim can also be matched when it reaches its closing curly brace
  1733. (i.e., when it appears to terminate).
  1734. This semantics is based on what is usually referred to as a `stuttering
  1735. semantics.'
  1736. With stuttering semantics, any terminating execution can be extended
  1737. into an equivalent infinite execution (for the purposes of evaluating
  1738. LTL properties) by repeating (stuttering) the final state infinitely often.
  1739. As a syntactical convenience, the final state of a
  1740. <TT>never</TT>
  1741. claim is defined to be accepting, i.e., it could be replaced with
  1742. the explicit repetition construct:
  1743. <DL><DT><DD><TT><PRE>
  1744. accept: do :: skip od
  1745. </PRE></TT></DL>
  1746. Every process behavior, similarly, is (for the purposes of evaluating the
  1747. <TT>never</TT>
  1748. claims) thought to be extended with a dummy self-loop on all final states:
  1749. <DL><DT><DD><TT><PRE>
  1750. do :: skip od
  1751. </PRE></TT></DL>
  1752. (Note the
  1753. <TT>accept</TT>
  1754. labels only occur in the
  1755. <TT>never</TT>
  1756. claim, not in the system.)
  1757. <H4>The Semantics of a Never Claim
  1758. </H4>
  1759. <br>&#32;<br>
  1760. <TT>Never</TT>
  1761. claims are probably the hardest part of the language to understand,
  1762. so it is worth spending a few extra words on them.
  1763. On an initial reading, feel free to skip the remainder of this
  1764. section.
  1765. <br>&#32;<br>
  1766. The difference between a
  1767. <TT>never</TT>
  1768. claim and the remainder of a PROMELA system can be explained
  1769. as follows.
  1770. A PROMELA model defines an asynchronous interleaving product of the
  1771. behaviors of individual processes.
  1772. Given an arbitrary system state, its successor states are
  1773. conceptually obtained in two steps.
  1774. In a first step, all the executable statements in the
  1775. individual processes are identified.
  1776. In a second step, each one of these statements is executed,
  1777. each one producing one potential successor for the current state.
  1778. The complete system behavior is thus defined recursively and
  1779. represents all possible interleavings of the individual process behaviors.
  1780. It is this asynchronous product machine that we call the `global
  1781. system behavior'.
  1782. <br>&#32;<br>
  1783. The addition of a
  1784. <TT>never</TT>
  1785. claim defines a <I>synchronous</I> product of the global system behavior
  1786. with the behavior expressed in the claim.
  1787. This synchronous product can be thought of as the construction of a
  1788. new global state machine, in which every state is defined as a pair
  1789. <TT>(s,n)</TT>
  1790. with
  1791. <TT>s</TT>
  1792. a state from the global system (the asynchronous product of processes), and
  1793. <TT>n</TT>
  1794. a state from the claim.
  1795. Every transition in the new global machine is similarly defined by a pair
  1796. of transitions, with the first element a statement from the system, and the
  1797. second a proposition from the claim.
  1798. In other words, every transition in this final synchronous product is
  1799. defined as a joint transition of the system and the claim.
  1800. Of course, that transition can only occur if the proposition from the
  1801. second half of the transition pair evaluates to true in the current state
  1802. of the system (the first half of the state pair).
  1803. <H4>Examples
  1804. </H4>
  1805. <br>&#32;<br>
  1806. To manually translate an LTL formula into a
  1807. <TT>never</TT>
  1808. claim (e.g. foregoing the builtin translation that SPIN
  1809. offers), we must carefully consider whether the
  1810. formula expresses a positive or a negative property.
  1811. A positive property expresses a good behavior that we
  1812. would like our system to have.
  1813. A negative property expresses a bad behavior that we
  1814. claim the system does not have.
  1815. A
  1816. <TT>never</TT>
  1817. claim can express only negative claims, not positive ones.
  1818. Fortunately, the two are exchangeable: if we want to express
  1819. that a good behavior is unavoidable, we can formalize all
  1820. ways in which the good behavior could be violated, and express
  1821. that in the
  1822. <TT>never</TT>
  1823. claim.
  1824. <br>&#32;<br>
  1825. Suppose that the LTL formula &#186;&#164;
  1826. <TT>p</TT>,
  1827. with
  1828. <TT>p</TT>
  1829. a PROMELA expression, expresses a negative claim
  1830. (i.e., it is considered a correctness violation if
  1831. there exists any execution sequence in which
  1832. <TT>p</TT>
  1833. can eventually remain true infinitely long).
  1834. This can be written in a
  1835. <TT>never</TT>
  1836. claim as:
  1837. <DL><DT><DD><TT><PRE>
  1838. never { /* &#60;&#62;[]p */
  1839. do
  1840. :: skip /* after an arbitrarily long prefix */
  1841. :: p -&#62; break /* p becomes true */
  1842. od;
  1843. accept: do
  1844. :: p /* and remains true forever after */
  1845. od
  1846. }
  1847. </PRE></TT></DL>
  1848. Note that in this case the claim does not terminate, and
  1849. also does not necessarily match all system behaviors.
  1850. It is sufficient if it precisely captures all violations
  1851. of our correctness requirement, and no more.
  1852. <br>&#32;<br>
  1853. If the LTL formula expressed a positive property, we first
  1854. have to invert it to the corresponding negative property
  1855. <TT>&#186;!p</TT>
  1856. and translate that into a
  1857. <TT>never</TT>
  1858. claim.
  1859. The requirement now says that it is a violation if
  1860. <TT>p</TT>
  1861. does not hold infinitely long.
  1862. <DL><DT><DD><TT><PRE>
  1863. never { /* &#60;&#62;!p*/
  1864. do
  1865. :: skip
  1866. :: !p -&#62; break
  1867. od
  1868. }
  1869. </PRE></TT></DL>
  1870. We have used the implicit match of a claim upon reaching the
  1871. closing terminating brace.
  1872. Since the first violation of the property suffices to disprove
  1873. it, we could also have written:
  1874. <DL><DT><DD><TT><PRE>
  1875. never { /* &#60;&#62;!p*/
  1876. do
  1877. :: p
  1878. :: !p -&#62; break
  1879. od
  1880. }
  1881. </PRE></TT></DL>
  1882. or, if we abandon the connection with LTL for a moment,
  1883. even more tersely as:
  1884. <DL><DT><DD><TT><PRE>
  1885. never { do :: assert(p) od }
  1886. </PRE></TT></DL>
  1887. Suppose we wish to express that it is a violation of our
  1888. correctness requirements if there exists any execution in
  1889. the system where
  1890. <TT>&#164; (p -> &#186; q)</TT>
  1891. is violated (i.e., the negation of this formula is satisfied).
  1892. The following
  1893. <TT>never</TT>
  1894. claim expresses that property:
  1895. <DL><DT><DD><TT><PRE>
  1896. never {
  1897. do
  1898. :: skip
  1899. :: p &amp;&amp; !q -&#62; break
  1900. od;
  1901. accept:
  1902. do
  1903. :: !q
  1904. od
  1905. }
  1906. </PRE></TT></DL>
  1907. Note that using
  1908. <TT>(!p || q)</TT>
  1909. instead of
  1910. <TT>skip</TT>
  1911. in the first repetition construct would imply a check for just
  1912. the first occurrence of proposition
  1913. <TT>p</TT>
  1914. becoming true in the execution sequence, while
  1915. <TT>q</TT>
  1916. is false.
  1917. The above formalization checks for all occurrences, anywhere in a trace.
  1918. <br>&#32;<br>
  1919. Finally, consider a formalization of the LTL property
  1920. <TT>&#164; (p -> (q U r))</TT>.
  1921. The corresponding claim is:
  1922. <DL><DT><DD><TT><PRE>
  1923. never {
  1924. do
  1925. :: skip /* to match any occurrence */
  1926. :: p &amp;&amp; q &amp;&amp; !r -&#62; break
  1927. :: p &amp;&amp; !q &amp;&amp; !r -&#62; goto error
  1928. od;
  1929. do
  1930. :: q &amp;&amp; !r
  1931. :: !q &amp;&amp; !r -&#62; break
  1932. od;
  1933. error: skip
  1934. }
  1935. </PRE></TT></DL>
  1936. Note again the use of
  1937. <TT>skip</TT>
  1938. instead of
  1939. <TT>(!p || r)</TT>
  1940. to avoid matching just the first occurrence of
  1941. <TT>(p && !r)</TT>
  1942. in a trace.
  1943. <H4>1.4 Predefined Variables and Functions
  1944. </H4>
  1945. <br>&#32;<br>
  1946. The following predefined variables and functions
  1947. can be especially useful in
  1948. <TT>never</TT>
  1949. claims.
  1950. <br>&#32;<br>
  1951. The predefined variables are:
  1952. <TT>_pid</TT>
  1953. and
  1954. <TT>_last</TT>.
  1955. <br>&#32;<br>
  1956. <TT>_pid</TT>
  1957. is a predefined local variable in each process
  1958. that holds the unique instantiation number for
  1959. that process.
  1960. It is always a non-negative number.
  1961. <br>&#32;<br>
  1962. <TT>_last</TT>
  1963. is a predefined global variable that always holds the
  1964. instantiation number of the process that performed the last
  1965. step in the current execution sequence.
  1966. Its value is not part of the system state unless it is
  1967. explicitly used in a specification.
  1968. <DL><DT><DD><TT><PRE>
  1969. never {
  1970. /* it is not possible for the process with pid=1
  1971. * to execute precisely every other step forever
  1972. */
  1973. accept:
  1974. do
  1975. :: _last != 1 -&#62; _last == 1
  1976. od
  1977. }
  1978. </PRE></TT></DL>
  1979. The initial value of
  1980. <TT>_last</TT>
  1981. is zero.
  1982. <br>&#32;<br>
  1983. Three predefined functions are specifically intended to be used in
  1984. <TT>never</TT>
  1985. claims, and may not be used elsewhere in a model:
  1986. <TT>pc_value(pid)</TT>,
  1987. <TT>enabled(pid)</TT>,
  1988. <TT>procname[pid]@label</TT>.
  1989. <br>&#32;<br>
  1990. The function
  1991. <TT>pc_value(pid)</TT>
  1992. returns the current control state
  1993. of the process with instantiation number
  1994. <TT>pid</TT>,
  1995. or zero if no such process exists.
  1996. <br>&#32;<br>
  1997. Example:
  1998. <DL><DT><DD><TT><PRE>
  1999. never {
  2000. /* Whimsical use: claim that it is impossible
  2001. * for process 1 to remain in the same control
  2002. * state as process 2, or one with smaller value.
  2003. */
  2004. accept: do
  2005. :: pc_value(1) &#60;= pc_value(2)
  2006. od
  2007. }
  2008. </PRE></TT></DL>
  2009. The function
  2010. <TT>enabled(pid)</TT>
  2011. tells whether the process with instantiation number
  2012. <TT>pid</TT>
  2013. has an executable statement that it can execute next.
  2014. <br>&#32;<br>
  2015. Example:
  2016. <DL><DT><DD><TT><PRE>
  2017. never {
  2018. /* it is not possible for the process with pid=1
  2019. * to remain enabled without ever executing
  2020. */
  2021. accept:
  2022. do
  2023. :: _last != 1 &amp;&amp; enabled(1)
  2024. od
  2025. }
  2026. </PRE></TT></DL>
  2027. The last function
  2028. <TT>procname[pid]@label</TT>
  2029. tells whether the process with instantiation number
  2030. <TT>pid</TT>
  2031. is currently in the state labeled with
  2032. <TT>label</TT>
  2033. in
  2034. <TT>proctype procname</TT>.
  2035. It is an error if the process referred to is not an instantiation
  2036. of that proctype.
  2037. <H4>2 Verifications with SPIN
  2038. </H4>
  2039. <br>&#32;<br>
  2040. The easiest way to use SPIN is probably on a Windows terminal
  2041. with the Tcl/Tk implementation of XSPIN.
  2042. All functionality of SPIN, however, is accessible from
  2043. any plain ASCII terminal, and there is something to be
  2044. said for directly interacting with the tool itself.
  2045. <br>&#32;<br>
  2046. The description in this paper gives a short walk-through of
  2047. a common mode of operation in using the verifier.
  2048. A more tutorial style description of the verification
  2049. process can be found in [Ho93].
  2050. More detail on the verification of large systems with the
  2051. help of SPIN's supertrace (bitstate) verification algorithm
  2052. can be found in [Ho95].
  2053. <DL>
  2054. <DT><DT>&#32;<DD>
  2055. <DL><DD>
  2056. <br>
  2057. *
  2058. Random and interactive simulations (section 2.1),
  2059. <br>
  2060. *
  2061. Generating a verifier (section 2.2),
  2062. <br>
  2063. *
  2064. Compilation for different types of searches (section 2.3),
  2065. <br>
  2066. *
  2067. Performing the verification (section 2.4),
  2068. <br>
  2069. *
  2070. Inspecting error traces produced by the verifier (section 2.5),
  2071. <br>
  2072. *
  2073. Exploiting partial order reductions (section 2.6).
  2074. </DL>
  2075. </dl>
  2076. <br>&#32;<br>
  2077. <H4>2.1 Random and Interactive Simulations
  2078. </H4>
  2079. <br>&#32;<br>
  2080. Given a model in PROMELA, say stored in a file called
  2081. <TT>spec</TT>,
  2082. the easiest mode of operation is to perform a random simulation.
  2083. For instance,
  2084. <DL><DT><DD><TT><PRE>
  2085. spin -p spec
  2086. </PRE></TT></DL>
  2087. tells SPIN to perform a random simulation, while printing the
  2088. process moves selected for execution at each step (by default
  2089. nothing is printed, other than explicit
  2090. <TT>printf</TT>
  2091. statements that appear in the model itself).
  2092. A range of options exists to make the traces more verbose,
  2093. e.g., by adding printouts of local variables (add option
  2094. <TT>-l</TT>),
  2095. global variables (add option
  2096. <TT>-g</TT>),
  2097. send statements (add option
  2098. <TT>-s</TT>),
  2099. or receive statements (add option
  2100. <TT>-r</TT>).
  2101. Use option
  2102. <TT>-n</TT>N
  2103. (with N any number) to fix the seed on SPIN's internal
  2104. random number generator, and thus make the simulation runs
  2105. reproducible.
  2106. By default the current time is used to seed the random number
  2107. generator.
  2108. For instance:
  2109. <DL><DT><DD><TT><PRE>
  2110. spin -p -l -g -r -s -n1 spec
  2111. </PRE></TT></DL>
  2112. <br>&#32;<br>
  2113. If you don't like the system randomly resolving non-deterministic
  2114. choices for you, you can select an interactive simulation:
  2115. <DL><DT><DD><TT><PRE>
  2116. spin -i -p spec
  2117. </PRE></TT></DL>
  2118. In this case you will be offered a menu with choices each time
  2119. the execution could proceed in more than one way.
  2120. <br>&#32;<br>
  2121. Simulations, of course, are intended primarily for the
  2122. debugging of a model. They cannot prove anything about it.
  2123. Assertions will be evaluated during simulation runs, and
  2124. any violations that result will be reported, but none of
  2125. the other correctness requirements can be checked in this way.
  2126. <H4>2.2 Generating the Verifier
  2127. </H4>
  2128. <br>&#32;<br>
  2129. A model-specific verifier is generated as follows:
  2130. <DL><DT><DD><TT><PRE>
  2131. spin -a spec
  2132. </PRE></TT></DL>
  2133. This generates a C program in a number of files (with names
  2134. starting with
  2135. <TT>pan</TT>).
  2136. <H4>2.3 Compiling the Verifier
  2137. </H4>
  2138. <br>&#32;<br>
  2139. At this point it is good to know the physical limitations of
  2140. the computer system that you will run the verification on.
  2141. If you know how much physical (not virtual) memory your system
  2142. has, you can take advantage of that.
  2143. Initially, you can simply compile the verifier for a straight
  2144. exhaustive verification run (constituting the strongest type
  2145. of proof if it can be completed).
  2146. Compile as follows.
  2147. <DL><DT><DD><TT><PRE>
  2148. pcc -o pan pan.c # standard exhaustive search
  2149. </PRE></TT></DL>
  2150. If you know a memory bound that you want to restrict the run to
  2151. (e.g., to avoid paging), find the nearest power of 2 (e.g., 23
  2152. for the bound 2^23 bytes) and compile as follows.
  2153. <DL><DT><DD><TT><PRE>
  2154. pcc '-DMEMCNT=23' -o pan pan.c
  2155. </PRE></TT></DL>
  2156. or equivalently in terms of MegaBytes:
  2157. <DL><DT><DD><TT><PRE>
  2158. pcc '-DMEMLIM=8' -o pan pan.c
  2159. </PRE></TT></DL>
  2160. If the verifier runs out of memory before completing its task,
  2161. you can decide to increase the bound or to switch to a frugal
  2162. supertrace verification. In the latter case, compile as follows.
  2163. <DL><DT><DD><TT><PRE>
  2164. pcc -DBITSTATE -o pan pan.c
  2165. </PRE></TT></DL>
  2166. <H4>2.4 Performing the Verification
  2167. </H4>
  2168. <br>&#32;<br>
  2169. There are three specific decisions to make to
  2170. perform verifications optimally: estimating the
  2171. size of the reachable state space (section 2.4.1),
  2172. estimating the maximum length of a unique execution
  2173. sequence (2.4.2), and selecting the type of correctness
  2174. property (2.4.3).
  2175. No great harm is done if the estimates from the first two
  2176. steps are off. The feedback from the verifier usually provides
  2177. enough clues to determine quickly what the optimal settings
  2178. for peak performance should be.
  2179. <H4>2.4.1 Reachable States
  2180. </H4>
  2181. <br>&#32;<br>
  2182. For a standard exhaustive run, you can override the default choice
  2183. for the size for the hash table (2^18 slots) with option
  2184. <TT>-w</TT>.
  2185. For instance,
  2186. <DL><DT><DD><TT><PRE>
  2187. pan -w23
  2188. </PRE></TT></DL>
  2189. selects 2^23 slots.
  2190. The hash table size should optimally be roughly equal to the number of
  2191. reachable states you expect (within say a factor of two or three).
  2192. Too large a number merely wastes memory, too low a number wastes
  2193. CPU time, but neither can affect the correctness of the result.
  2194. <br>&#32;<br>
  2195. For a supertrace run, the hash table <I>is</I> the memory arena, and
  2196. you can override the default of 2^22 bits with any other number.
  2197. Set it to the maximum size of physical memory you can grab without
  2198. making the system page, again within a factor of say two or three.
  2199. Use, for instance
  2200. <TT>-w23</TT>
  2201. if you expect 8 million reachable states and have access to at least
  2202. 8 million (2^23) bits of memory (i.e., 2^20 or 1 Megabyte of RAM).
  2203. <H4>2.4.2 Search Depth
  2204. </H4>
  2205. <br>&#32;<br>
  2206. By default the analyzers have a search depth restriction of 10,000 steps.
  2207. If this isn't enough, the search will truncate at 9,999 steps (watch for
  2208. it in the printout).
  2209. Define a different search depth with the -m flag.
  2210. <DL><DT><DD><TT><PRE>
  2211. pan -m100000
  2212. </PRE></TT></DL>
  2213. If you exceed also this limit, it is probably good to take some
  2214. time to consider if the model you have specified is indeed finite.
  2215. Check, for instance, if no unbounded number of processes is created.
  2216. If satisfied that the model is finite, increase the search depth at
  2217. least as far as is required to avoid truncation completely.
  2218. <br>&#32;<br>
  2219. If you find a particularly nasty error that takes a large number of steps
  2220. to hit, you may also set lower search depths to find the shortest variant
  2221. of an error sequence.
  2222. <DL><DT><DD><TT><PRE>
  2223. pan -m40
  2224. </PRE></TT></DL>
  2225. Go up or down by powers of two until you find the place where the
  2226. error first appears or disappears and then home in on the first
  2227. depth where the error becomes apparent, and use the error trail of
  2228. that verification run for guided simulation.
  2229. <br>&#32;<br>
  2230. Note that if a run with a given search depth fails to find
  2231. an error, this does not necessarily mean that no violation of a
  2232. correctness requirement is possible within that number of steps.
  2233. The verifier performs its search for errors by using a standard
  2234. depth-first graph search. If the search is truncated at N steps,
  2235. and a state at level N-1 happens to be reachable also within fewer
  2236. steps from the initial state, the second time it is reached it
  2237. will not be explored again, and thus neither will its successors.
  2238. Those successors may contain errors states that are reachable within
  2239. N steps from the initial state.
  2240. Normally, the verification should be run in such a way that no
  2241. execution paths can be truncated, but to force the complete exploration
  2242. of also truncated searches one can override the defaults with a compile-time
  2243. flag
  2244. <TT>-DREACH</TT>.
  2245. When the verifier is compiled with that additional directive, the depth at
  2246. which each state is visited is remembered, and a state is now considered
  2247. unvisited if it is revisited via a shorter path later in the search.
  2248. (This option cannot be used with a supertrace search.)
  2249. <H4>2.4.3 Liveness or Safety Verification
  2250. </H4>
  2251. <br>&#32;<br>
  2252. For the last, and perhaps the most critical, runtime decision:
  2253. it must be decided if the system is to be checked for safety
  2254. violations or for liveness violations.
  2255. <DL><DT><DD><TT><PRE>
  2256. pan -l # search for non-progress cycles
  2257. pan -a # search for acceptance cycles
  2258. </PRE></TT></DL>
  2259. (In the first case, though, you must compile pan.c with -DNP as an
  2260. additional directive. If you forget, the executable will remind you.)
  2261. If you don't use either of the above two options, the default types of
  2262. correctness properties are checked (assertion violations,
  2263. completeness, race conditions, etc.).
  2264. Note that the use of a
  2265. <TT>never</TT>
  2266. claim that contains
  2267. <TT>accept</TT>
  2268. labels requires the use of the
  2269. <TT>-a</TT>
  2270. flag for complete verification.
  2271. <br>&#32;<br>
  2272. Adding option
  2273. <TT>-f</TT>
  2274. restricts the search for liveness properties further under
  2275. a standard <I>weak fairness</I> constraint:
  2276. <DL><DT><DD><TT><PRE>
  2277. pan -f -l # search for weakly fair non-progress cycles
  2278. pan -f -a # search for weakly fair acceptance cycles
  2279. </PRE></TT></DL>
  2280. With this constraint, each process is required to appear
  2281. infinitely often in the infinite trace that constitutes
  2282. the violation of a liveness property (e.g., a non-progress cycle
  2283. or an acceptance cycle), unless it is permanently blocked
  2284. (i.e., has no executable statements after a certain point in
  2285. the trace is reached).
  2286. Adding the fairness constraint increases the time complexity
  2287. of the verification by a factor that is linear in the number
  2288. of active processes.
  2289. <br>&#32;<br>
  2290. By default, the verifier will report on unreachable code in
  2291. the model only when a verification run is successfully
  2292. completed.
  2293. This default behavior can be turned off with the runtime option
  2294. <TT>-n</TT>,
  2295. as in:
  2296. <DL><DT><DD><TT><PRE>
  2297. pan -n -f -a
  2298. </PRE></TT></DL>
  2299. (The order in which the options such as these are listed is
  2300. always irrelevant.)
  2301. A brief explanation of these and other runtime options can
  2302. be determined by typing:
  2303. <DL><DT><DD><TT><PRE>
  2304. pan --
  2305. </PRE></TT></DL>
  2306. <H4>2.5 Inspecting Error Traces
  2307. </H4>
  2308. <br>&#32;<br>
  2309. If the verification run reports an error,
  2310. any error, SPIN dumps an error trail into a file named
  2311. <TT>spec.trail</TT>,
  2312. where
  2313. <TT>spec</TT>
  2314. is the name of your original PROMELA file.
  2315. To inspect the trail, and determine the cause of the error,
  2316. you must use the guided simulation option.
  2317. For instance:
  2318. <DL><DT><DD><TT><PRE>
  2319. spin -t -c spec
  2320. </PRE></TT></DL>
  2321. gives you a summary of message exchanges in the trail, or
  2322. <DL><DT><DD><TT><PRE>
  2323. spin -t -p spec
  2324. </PRE></TT></DL>
  2325. gives a printout of every single step executed.
  2326. Add as many extra or different options as you need to pin down the error:
  2327. <DL><DT><DD><TT><PRE>
  2328. spin -t -r -s -l -g spec
  2329. </PRE></TT></DL>
  2330. Make sure the file
  2331. <TT>spec</TT>
  2332. didn't change since you generated the analyzer from it.
  2333. <br>&#32;<br>
  2334. If you find non-progress cycles, add or delete progress labels
  2335. and repeat the verification until you are content that you have found what
  2336. you were looking for.
  2337. <br>&#32;<br>
  2338. If you are not interested in the first error reported,
  2339. use pan option
  2340. <TT>-c</TT>
  2341. to report on specific others:
  2342. <DL><DT><DD><TT><PRE>
  2343. pan -c3
  2344. </PRE></TT></DL>
  2345. ignores the first two errors and reports on the third one that
  2346. is discovered.
  2347. If you just want to count all errors and not see them, use
  2348. <DL><DT><DD><TT><PRE>
  2349. pan -c0
  2350. </PRE></TT></DL>
  2351. <H4>State Assignments
  2352. </H4>
  2353. <br>&#32;<br>
  2354. Internally, the verifiers produced by SPIN deal with a formalization of
  2355. a PROMELA model in terms of extended finite state machines.
  2356. SPIN therefore assigns state numbers to all statements in the model.
  2357. The state numbers are listed in all the relevant output to make it
  2358. completely unambiguous (source line references unfortunately do not
  2359. have that property).
  2360. To confirm the precise state assignments, there is a runtime option
  2361. to the analyzer generated:
  2362. <DL><DT><DD><TT><PRE>
  2363. pan -d # print state machines
  2364. </PRE></TT></DL>
  2365. which will print out a table with all state assignments for each
  2366. <TT>proctype</TT>
  2367. in the model.
  2368. <H4>2.6 Exploiting Partial Order Reductions
  2369. </H4>
  2370. <br>&#32;<br>
  2371. The search algorithm used by SPIN is optimized
  2372. according to the rules of a partial order theory explained in [HoPe94].
  2373. The effect of the reduction, however, can be increased considerably if the verifier
  2374. has extra information about the access of processes to global
  2375. message channels.
  2376. For this purpose, there are two keywords in the language that
  2377. allow one to assert that specific channels are used exclusively
  2378. by specific processes.
  2379. For example, the assertions
  2380. <DL><DT><DD><TT><PRE>
  2381. xr q1;
  2382. xs q2;
  2383. </PRE></TT></DL>
  2384. claim that the process that executes them is the <I>only</I> process
  2385. that will receive messages from channel
  2386. <TT>q1</TT>,
  2387. and the <I>only</I> process that will send messages to channel
  2388. <TT>q2</TT>.
  2389. <br>&#32;<br>
  2390. If an exclusive usage assertion turns out to be invalid, the
  2391. verifier will be able to detect this, and report it as a violation
  2392. of an implicit correctness requirement.
  2393. <br>&#32;<br>
  2394. Every read or write access to a message channel can introduce
  2395. new dependencies that may diminish the maximum effect of the
  2396. partial order reduction strategies.
  2397. If, for instance, a process uses the
  2398. <TT>len</TT>
  2399. function to check the number of messages stored in a channel,
  2400. this counts as a read access, which can in some cases invalidate
  2401. an exclusive access pattern that might otherwise exist.
  2402. There are two special functions that can be used to poll the
  2403. size of a channel in a safe way that is compatible with the
  2404. reduction strategy.
  2405. <br>&#32;<br>
  2406. The expression
  2407. <TT>nfull(qname)</TT>
  2408. returns true if channel
  2409. <TT>qname</TT>
  2410. is not full, and
  2411. <TT>nempty(qname)</TT>
  2412. returns true if channel
  2413. <TT>qname</TT>
  2414. contains at least one message.
  2415. Note that the parser will not recognize the free form expressions
  2416. <TT>!full(qname)</TT>
  2417. and
  2418. <TT>!empty(qname)</TT>
  2419. as equally safe, and it will forbid constructions such as
  2420. <TT>!nfull(qname)</TT>
  2421. or
  2422. <TT>!nempty(qname)</TT>.
  2423. More detail on this aspect of the reduction algorithms can be
  2424. found in [HoPe94].
  2425. <H4>Keywords
  2426. </H4>
  2427. <br>&#32;<br>
  2428. For reference, the following table contains all the keywords,
  2429. predefined functions, predefined variables, and
  2430. special label-prefixes of the language PROMELA,
  2431. and refers to the section of this paper in
  2432. which they were discussed.
  2433. <br><img src="-.22362.gif"><br>
  2434. <H4>References
  2435. </H4>
  2436. <br>&#32;<br>
  2437. [Ho91]
  2438. G.J. Holzmann,
  2439. Design and Validation of Computer Protocols,
  2440. Prentice Hall, 1991.
  2441. <br>&#32;<br>
  2442. [Ho93]
  2443. G.J. Holzmann, ``Tutorial: Design and Validation of Protocols,''
  2444. Computer Networks and ISDN Systems,
  2445. 1993, Vol. 25, No. 9, pp. 981-1017.
  2446. <br>&#32;<br>
  2447. [HoPe94]
  2448. G.J. Holzmann and D.A. Peled, ``An improvement in
  2449. formal verification,''
  2450. Proc. 7th Int. Conf. on Formal Description Techniques,
  2451. FORTE94, Berne, Switzerland. October 1994.
  2452. <br>&#32;<br>
  2453. [Ho95]
  2454. G.J. Holzmann, ``An Analysis of Bitstate Hashing,''
  2455. technical report 2/95, available from author.
  2456. <br>&#32;<br>
  2457. [HS99]
  2458. G.J. Holzmann, ``Software model checking: extracting
  2459. verification models from source code,''
  2460. Proc. Formal Methods in Software Engineering and Distributed
  2461. Systems,
  2462. PSTV/FORTE99, Beijng, China, Oct. 1999, Kluwer,pp. 481-497.
  2463. <br>&#32;<br>
  2464. <A href=http://www.lucent.com/copyright.html>
  2465. Copyright</A> &#169; 2000 Lucent Technologies Inc. All rights reserved.
  2466. </body></html>