Interference freedom explained

In computer science, interference freedom is a technique for proving partial correctness ofconcurrent programs with shared variables. Hoare logic had been introduced earlierto prove correctness of sequential programs. In her PhD thesis[1] (and papers arising from it [2] [3]) under advisor David Gries, Susan Owicki extended this work to apply to concurrent programs.

Concurrent programming had been in use since the mid 1960s for coding operating systems as setsof concurrent processes (see, in particular, Dijkstra.), but there was noformal mechanism for proving correctness. Reasoning about interleaved executionsequences of the individual processes was difficult, was error prone,and didn't scale up. Interference freedomapplies to proofs instead of execution sequences;one shows that execution of one process cannot interfere with the correctness proof of another process.

A range of intricate concurrent programs have been proved correct using interferencefreedom, and interference freedom provides the basis for much of the ensuing work ondeveloping concurrent programs with shared variables and proving them correct.The Owicki-Gries paper An axiomatic proof technique for parallel programs I received the 1977 ACM Award for best paper in programming languages and systems.[4] [5]

Note. Lamport [6] presents a similar idea. He writes, "After writing theinitial version of this paper, we learned of the recent work of Owicki." His paper has not received as much attention as Owicki-Gries, perhaps because it usedflow charts instead of the text of programming constructs like the if statement and while loop.Lamport was generalizing Floyd's method [7] while Owicki-Gries was generalizingHoare's method.[8] Essentially all later work in this area uses text and not flow charts.Another difference is mentioned below in thesection on Auxiliary variables.

Dijkstra's Principle of non-interference

Edsger W. Dijkstra introduced the principle of non-interference in EWD 117, "Programming Considered as a Human Activity", written about 1965.[9] This principle states that:The correctness of the whole can be established by taking intoaccount only the exterior specifications (abbreviated specs throughout) of the parts, and not theirinterior construction. Dijkstra outlined the general steps in using this principle:

  1. Give a complete spec of each individual part.
  2. Check that the total problem is solved when program parts meeting their specs are available.
  3. Construct the individual parts to satisfy their specs, but independent of one another and the context in which they will be used.

He gave several examples of this principle outside of programming. Butits use in programming is a main concern. For example, a programmer using a method (subroutine, function, etc.) should rely only on its spec to determine what it does and how to call it, and never on its implementation.

Program specs are written in Hoare logic, introduced by Sir Tony Hoare, as exemplified in the specs of processes and :



Meaning: If execution of in a state in which precondition is true terminates, then upon termination, postcondition is true.

Now consider concurrent programming with shared variables. The specs of two (ormore) processes and are given in terms of their pre- and post-conditions,and we assume that implementations of and are given that satisfy theirspecs. But when executing their implementations in parallel, since they share variables,a race condition can occur; one process changes a shared variable to a valuethat is not anticipated in the proof of the other process, so the otherprocess does not work as intended.

Thus, Dijkstra's Principle of non-interference is violated.

In her PhD thesis of 1975 in Computer Science, Cornell University, written underadvisor David Gries, Susan Owicki developed the notion of interference freedom. If processes and satisfy interference freedom, then their parallel execution will work as planned.Dijkstra called this work the first significant step toward applying Hoare logic to concurrent processes.[10] To simplify discussions, we restrict attention to only two concurrent processes,although Owicki-Gries allows more.

Interference freedom in terms of proof outlines

Owicki-Gries introduced the proof outline for a Hoare triple . It contains all details needed for a proof of correctness of using the axioms and inference rules of Hoare logic. (This work uses the assignment statement, and statements, and the loop.) Hoare alluded to proof outlines in his early work; for interference freedom, it had to be formalized.

A proof outline for begins with precondition and ends with postcondition .Two assertions within braces appearing next to each other indicates that the first must imply the second.

Example: A proof outline for where is:












must hold,where stands for with everyoccurrence of replaced by . (In this example, and are basic statements, like an assignment statement, skip, or an await statement.)

Each statement in the proof outline is preceded by a precondition and followed by a postcondition, and must be provable using some axiom or inference rule of Hoare logic. Thus, the proof outline contains all the information necessary to prove that is correct.

Now consider two processes and executing in parallel, and their specs:



Proving that they work suitably in parallel will require restricting them as follows.Each expression in or may refer to at most one variable that can bechanged by the other process while is being evaluated, and may refer to at most once.A similar restriction holds for assignment statements .

With this convention, the only indivisible action need be the memory reference. For example, suppose process references variable while changes . The value receives for must be the value before or after changes, and not some spurious in-between value.

Definition of Interference-free

The important innovation of Owicki-Gries was to define what it means for a statement not to interfere with the proof of . If execution of cannot falsify any assertion given in the proof outline of, then that proof still holds even in the face of concurrent execution of and .

Definition. Statement with precondition does not interfere with the proof of if two conditions hold:

(1)
(2) Let be any statement within but not within an statement (see later section).Then .

Read the last Hoare triple like this: If the state is such that both and canbe executed, then execution of is not going to falsify .

Definition. Proof outlines for and are interference-free if the following holds.Let be an or assignment statement (that does not appear in an) of process . Then does not interfere with the proof of .Similarly for of process and .

Statements cobegin and await

Two statements were introduced to deal with concurrency. Execution of the statement executes and in parallel. It terminates when both and have terminated.

Execution of the statement is delayed until condition is true. Then, statement is executed as an indivisible action—evaluation of is part of that indivisible action. If two processes are waiting for the same condition, when it becomes true, one of them continues waiting while the other proceeds.

The statement cannot be implemented efficiently and is not proposed to be inserted into the programming language. Rather it provides a means of representing several standard primitives such as semaphores—first express the semaphore operations as, then apply the techniques described here.

Inference rules for and are:





Auxiliary variables

An auxiliary variable does not occur in the program but is introduced in the proof of correctness to make reasoning simpler —or even possible. Auxiliary variables are used only in assignments to auxiliary variables, so their introduction neither alters theprogram for any input nor affects the values of program variables. Typically,they are used either as program counters or to record histories of a computation.

Definition. Let be a set of variables that appear in only in assignments, where is in . Then is an auxiliary variable set for .

Since a set of auxiliary variables are used only in assignments to variables in, deleting all assignments to them doesn't change the program's correctness, and we have the inference rule elimination:

is an auxiliary variable set for . The variables in do not occur in or . is obtained from by deleting all assignments to the variables in .

Instead of using auxiliary variables, one can introduce a program counter into the proof system, but that adds complexity to the proof system.

Note: Apt [11] discusses the Owicki-Gries logic in the context of recursive assertions, that is,effectively computable assertions. He proves that all the assertions in proof outlinescan be recursive, but that this is no longer the case if auxiliary variables are used only as program counters and not to record histories of computation. Lamport, in his similar work, uses assertions about token positions instead of auxiliary variables, where a token on an edge of a flow chart is akin to a program counter. There is no notion of a history variable.This indicates that Owicki-Gries and Lamport's approach are not equivalentwhen restricted to recursive assertions.

Deadlock and termination

Owicki-Gries deals mainly with partial correctness: means: If executed ina state in which is true terminates, then is true of the state upon termination.However, Owicki-Gries also gives some practical techniques that use information obtainedfrom a partial correctness proof to derive other correctness properties,including freedom from deadlock, program termination, and mutual exclusion.

A program is in deadlock if all processes that have not terminated are executing statementsand none can proceed because their conditions are false.Owicki-Gries provides conditions under which deadlock cannot occur.

Owicki-Gries presents an inference rule for total correctness of the while loop. It usesa bound function that decreases with each iteration and is positive as long as theloop condition is true. Apt et al [12] show that this new inference rule does not satisfy interference freedom. The fact that the bound function is positive as long as the loop condition is true was notincluded in an interference test. They show two ways to rectify this mistake.

A simple example

Consider the statement://

The proof outline for it:







//






Proving that does not interfere with the proof of requires proving two Hoare triples:

(1) (2)

The precondition of (1) reduces to and the precondition of (2) reduces to . From this, it is easy to see that these Hoare triples hold. Two similar Hoare triples are required to show that does not interfere with the proof of .

Suppose is changed from the statement to the assignment . Then the proof outline does not satisfy the requirements, because the assignment contains two occurrences of shared variable . Indeed, the value of after execution of the statement could be 2 or 3.

Suppose is changed to the statement, so it is the same as . After execution of, should be 4. To prove this, because the two assignments are the same, two auxiliary variables are needed, one to indicate whether has been executed; the other, whether has been executed.We leave the change in the proof outline to the reader.

Examples of formally proved concurrent programs

A. Findpos. Write a program that finds the first positive element of an array (if there is one). One process checks all array elements at even positions of the array and terminates when it finds a positive value or when none is found. Similarly, the other process checks array elements at odd positions of the array. Thus, this example deals with while loops. It also has no statements.

This example comes from Barry K. Rosen.[13] The solution in Owicki-Gries, complete with program, proof outline, and discussion of interference freedom, takes less than two pages. Interference freedom is quite easy to check, since there is only one shared variable. In contrast, Rosen'sarticleuses as the single, running example in this 24 page paper.

An outline of both processes in a general environment:






//





B. Bounded buffer consumer/producer problem. A producer process generates values and puts them into bounded buffer of size ; a consumer process removes them. They proceed at variable rates. The producer must wait if buffer is full; the consumer must wait if buffer is empty. In Owicki-Gries, a solution in a general environment is shown; it is then embedded in a program that copies an array into an array .

This example exhibits a principle to reduce interference checks to a minimum: Place as much as possible in an assertion that is invariantly true everywhere in both processes. In this case the assertion is the definition of the bounded buffer and bounds on variables that indicate how many values have been added to and removed from the buffer. Besides buffer itself, two shared variables record the number of values added to the buffer and the number removed from the buffer.

C. Implementing semaphores.In his article on the THE multiprogramming system, Dijkstra introduces the semaphore as a synchronization primitive: is an integer variable that can be referenced in only two ways, shown below; each is an indivisible operation:

1. : Decrease by 1. If now, suspend the process and put it on a list of suspended processes associated with .

2. : Increase by 1. If now, remove one of the processes from the list of suspended processes associated with, so its dynamic progress is again permissible.

The implementation of and using statements is:


















Here, is an array of processes that are waiting because they have been suspended; initially, for every process . One could change the implementation to always waken the longest suspended process.

D. On-the-fly garbage collection. At the 1975 Summer School Marktoberdorf, Dijkstra discussed an on-the-fly garbage collector as an exercise in understanding parallelism. The data structure used in a conventional implementation of LISP is a directed graph in which each node has at most two outgoing edges, either of which may be missing: an outgoing left edge and an outgoing right edge. All nodes of the graph must be reachable from a known root. Changing a node may result in unreachable nodes, which can no longer be used and are called garbage. An on-the-fly garbage collector has two processes: the program itself and a garbage collector, whose task is to identify garbage nodes and put them on a free list so that they can be used again.

Gries felt that interference freedom could be used to prove the on-the-fly garbage collector correct.With help from Dijkstra and Hoare, he was able to give a presentation at the end of the Summer School,which resulted in an article in CACM.[14]

E. Verification of readers/writers solution with semaphores. Courtois et al[15] use semaphores to give two versions of the readers/writers problem, without proof. Write operations block both reads and writes, but read operations can occur in parallel. Owicki[16] provides a proof.

F. Peterson's algorithm, a solution to the 2-process mutual exclusionproblem, was published by Peterson in a 2-page article.[17] Schneider and Andrews provide a correctness proof.[18]

Dependencies on interference freedom

The image below, by Ilya Sergey, depicts the flow of ideas that have been implemented in logics that deal with concurrency. At the root is interference freedom. The file contains references. Below, we summarize the major advances.

Texts that discuss interference freedom

Implementations of interference freedom

Notes and References

  1. Owicki. Susan S.. August 1975. Axiomatic Proof Techniques for Parallel Programs. Cornell University. 1813/6393. PhD thesis. 2022-07-01.
  2. Owicki . Susan . Susan Owicki . Gries . David . David Gries . An axiomatic proof technique for parallel programs I . . 6 . 4 . 319 - 340 . Springer (Germany) . Berlin . 25 June 1976 . 10.1007/BF00268134 . 206773583 .
  3. Owicki . Susan . Susan Owicki . Gries . David . David Gries . Verifying properties of parallel programs: an axiomatic approach . 10.1145/360051.360224 . . 19 . 5 . 279 - 285 . May 1976 . 9099351 . free .
  4. Web site: Susan S Owicki. Awards.acm.org . 2022-07-01.
  5. Web site: David Gries . Awards.acm.org. 2022-07-01.
  6. Lamport . Leslie . Leslie Lamport . Proving the correctness of multiprocess programs . . SE-3 . 2 . 125 - 143 . March 1977 . 10.1109/TSE.1977.229904. 9985552 .
  7. Book: Floyd , Robert W. . Robert W. Floyd . 1967 . Assigning Meanings to Programs . //people.eecs.berkeley.edu/~necula/Papers/FloydMeaning.pdf . J.T. . Schwartz . Mathematical Aspects of Computer Science . American Mathematical Society . 0821867288 . 19–32 . Proceedings of Symposium on Applied Mathematics . 19 .
  8. Hoare . C. A. R. . C.A.R. Hoare . An axiomatic basis for computer programming . 10.1145/363235.363259 . . 12 . 10 . 576 - 580 . October 1969 . 207726175 . free .
  9. Web site: E. W. Dijkstra Archive. University of Texas . Programming Considered as a Human Activity.
  10. Book: Dijkstra , Edsger W. . Selected Writings on Computing: A Personal Perspective . Springer-Verlag . 1982 . Monographs in Computer Science . 0387906525 . EWD 554: A personal summary of the Gries-Owicki Theory . 188–199.
  11. Apt . Krzysztof R. . Recursive assertions and parallel programs . . 15 . 219 - 232 . June 1981 . 3 . 10.1007/BF00289262. 42470032 .
  12. Book: Apt. Krzysztof R.. de Boer. Frank S.. Olderog. Ernst-Rüdiger. Proving termination of parallel programs. Gries. D. . Feijen . W.H.J. . van Gasteren . A.J.M. . Misra . J. . 1990. 0 - 6 . Beauty is Our Business. Monographs in Computer Science. Springer Verlag. New York. 10.1007/978-1-4612-4476-9. 978-1-4612-8792-6. 24379938.
  13. Rosen. Barry K. 1976. Correctness of parallel programs: The Church-Rosser Approach.. Theoretical Computer Science. 2. 2. 183–207. 10.1016/0304-3975(76)90032-3. free.
  14. Gries . David . David Gries . An exercise in proving parallel programs correct . 10.1145/359897.359903 . . 20 . 12 . 921 - 930 . December 1977 . 3202388 . free .
  15. Courtois . P.J. . Heymans . F. . Parnas . D.L. . David Parnas . Concurrent control with "readers" and "writers" . 10.1145/362759.362813 . . 14 . 10 . 667 - 668 . October 1971 . 7540747 . free .
  16. Owicki . Susan . Susan Owicki . Verifying concurrent programs with shared data classes. 147 . Digital Systems Laboratory, Stanford University. August 1977. 2022-07-08.
  17. Peterson . Gary L. . Myths about the mutual exclusion problem . . 12 . 3 . 115 - 116 . June 1981 . 10.1016/0020-0190(81)90106-X.
  18. Schneider. Fred B.. Fred B. Schneider. Andrews. Gregory R.. Concepts for concurrent programming. 669 - 716. 1986. Current Trends in Concurrency. Lecture Notes in Computer Science. J.W. Bakker. W.P. de Roever. G. Rozenberg. 224. Noordwijkerhout, the Netherlands. Springer Verlag. 10.1007/BFb0027049. 978-3-540-16488-3.
  19. Jones. C.B.. Development Methods for Computer Programs including a Notion of Interference. June 1981. DPhil. Oxford University.
  20. Specification and design of (parallel) programs. Cliff B.. Jones. Cliff Jones (computer scientist). 1983. 9th IFIP World Computer Congress (Information Processing 83). R.E.A. Mason. North-Holland/IFIP . 321–332 . 0444867295.
  21. Xu . Qiwen . de Roever . Willem-Paul . He . Jifeng . The Rely-Guarantee method for verifying shared variable concurrent programs . 10.1007/BF01211617 . Formal Aspects of Computing . 9 . 149 - 174 . 1997 . 2 . 12148448 . free .
  22. Resources, Concurrency and Local Reasoning. Peter W.. O'Hearn. Peter O'Hearn. 2004-09-03 . CONCUR 2004. P. Gardner. N. Yoshida. CONCUR 2004 -- Concurrency Theory. Springer Verlag Berlin, Heidelberg. London, UK. 49 - 67. 978-3-540-28644-8. 10.1007/b100113. 2022-07-06.
  23. O'Hearn. Peter. Resources, Concurrency and Local Reasoning. Theoretical Computer Science. 2007. 375. 1–3. 271–307. 10.1016/j.tcs.2006.12.035. free.
  24. Extending the theory of Owicki and Gries with a logic of progress. Dongol. Brijesh. Goldson. Doug. Logical Methods in Computer Science. 2006. 2. January 12, 2005. Centre pour la Communication Scientifique Directe (CCSD). cs/0512012v3. 10.2168/lmcs-2(1:6)2006. 302420.
  25. Concurrent Program Design in the Extended Theory of Owicki and Gries. Goldson. Doug. Dongol. Brijesh. 41–50. January 2005. CATS '05: Proc 2005 Australasian Symp on Theory of Computing. Mike Atkinson. Frank Dehne. 41. Australian Computer Society, Inc..
  26. Progress in deriving concurrent programs: emphasizing the role of stable guards. Mooij. Arjan J. Dongol. Brijesh. 14–161. July 2006. MPC'06: Proc. 8th Int. Conf. on Mathematics of Program Construction. Tarmo Uustalu. 41. Springer Verlag, Berlin, Heidelberg. Kuressaare, Estonia. 10.1007/11783596_11.
  27. Dongol . Brijesh . Mooij. Arjan J . 2008. Streamlining progress-based derivations of concurrent program. Formal Aspects of Computing. 20. 2. 141–160. 10.1007/s00165-007-0037-4. 7024064 . free.
  28. Mooij. Arjan J.. 366–386. November 2007. ICFEM'07: Proc. Formal Engineering Methods 9th Int. Conf. on Formal Methods and Software Engineering. Michael Butler. Michael G. Hinchey. María M. Larrondo-Petrie. Boca Raton, Florida. Springer Verlag, Berlin, Heidelberg. 978-3540766483.
  29. Dongol. Brijesh. Hayes. Ian. April 2007. Trace semantics for the Owicki-Gries theory integrated with the progress logic from UNITY . . SSE-2007-02.
  30. Owicki-Gries reasoning for weak memory models. Ori. Lahav. Viktor. Vafeiadis. 2015. ICALP 2015. Halldórsson, M.. Iwama, K.. Kobayashi, N.. Speckmann, B.. 9135. Automata, Languages, and Programming. ICALP 2015. Lecture Notes in Computer Science. Springer. Berlin, Heidelberg. 311 - 323 . 10.1007/978-3-662-47666-6_25.
  31. Ying . Mingsheng . Zhou. Li. Li. Yangjia . Reasoning about Parallel Quantum Programs . 2018 . cs.LO . 1810.11334.
  32. Raad. Azalea. Lahav. Ori. Vafeiadis. Viktor. Persistent Owicki-Gries reasoning: a program logic for reasoning about persistent programs on Intel-x86. 13 November 2020. Proceedings of the ACM on Programming Languages. 4. OOPSLA. 1 - 28. ACM. 10.1145/3428219. free. 10044/1/97398. free.
  33. Book: Van Gasteren. A.J.M.. Feijen. W.H.J.. Gries . David. David Gries. Schneider. Fred B. . Fred B. Schneider . 1999. On A Method Of Multiprogramming. Monographs in Computer Science. Springer-Verlag New York Inc.. 370. 10.1007/978-1-4757-3126-2. 978-1-4757-3126-2. 13607884.
  34. Book: Schneider. Fred B.. Fred B. Schneider. Gries . David. David Gries. Schneider. Fred B. . Fred B. Schneider . 1997. On Concurrent Programming. Graduate Texts in Computer Science. Springer-Verlag New York Inc.. 10.1007/978-1-4612-1830-2. 978-1-4612-1830-2. 9980317.
  35. Book: Apt. Krzysztof R. . Olderog. Ernst-Rüdiger . Gries . David. David Gries . 1991. Verification of Sequential and Concurrent Programs. Texts in Computer Science. Springer-Verlag Germany.
  36. Book: Apt. Krzysztof R. . Olderog. Ernst-Rüdiger . Boer . Frank S. . Gries . David. David Gries. Schneider. Fred B. . Fred B. Schneider . 2009. 3rd. Verification of Sequential and Concurrent Programs. Texts in Computer Science. Springer-Verlag London. 502. 10.1007/978-1-84882-745-5. 2009vscp.book.....A . 978-1-84882-744-8.
  37. Book: de Roever. Willem-Paul. de Boer. Willem-Paul. Hanneman. Ulrich. Hooman. Jozef. Lakhnech. Yassine. Poel. Mannes. Zwiers. Job. Abramsky . S.. 2012. 800. Concurrency Verification: Introduction to Compositional and Non-Compositional Methods. Cambridge Tracts in Theoretical Computer Science. Cambridge University Press USA. 978-0521169325.
  38. Nieto. Leonor Prensa. Verification of Parallel Programs with the Owicki-Gries and Rely-Guarantee Methods in Isabelle/HOL. 2002-01-31. Dr. rer. nat.. Technischen Universitaet Muenchen. PhD thesis. 198. 2022-07-05.
  39. Nipkow. Tobias. Nieto. Leonor Prensa. Owicki/Gries in Isabelle/HOL. 1577. FASE 1999. Fundamental Approaches to Software Engineering. J.P. Finance. Springer Verlag. Berlin Heidelberg. Lecture Notes in Computer Science. 1999-03-22. 188 - 203. 978-3-540-49020-3. 10.1007/978-3-540-49020-3_13. free.
  40. Ábrahám. Erika. An Assertional Proof System for Multithreaded Java - Theory and Tool Support. 2005-01-20. PhD. Universiteit Leiden. PhD thesis. 220. 1887/584. 2022-07-05. 9090189084.
  41. Ábrahám. Erika. Boer. Frank, S., de. Roever. Willem-Paul, de. Martin. Steffen. An assertion-based proof system for multithreaded Java. Theoretical Computer Science. Elsevier. 331. 2005-02-25. 2–3. 251 - 290. 10.1016/j.tcs.2004.09.019. free.
  42. Denissen. P.E.J.G. Extending Dafny to Concurrency: Owicki-Gries style program verification for the Dafny program verifier. November 2017. Masters. Eindhoven University of Technology.
  43. Web site: Dafny Programming Language. 2022-07-20.
  44. COMPLX: A verification framework for concurrent imperative programs. S.. Amani. J.. Andronick. M.. Bortin. C.. Lewis. C.. Rizkallah. J.. Tuong. 16 January 2017. CPP 2017: Proc 6th ACM SIGPLAN Conference on Certified Programs and Proof. Yves Bertot. Viktor Vafeiadid. ACM. Paris, France. 138 - 150. 978-1-4503-4705-1. 10.1145/3018610.3018627.
  45. Dalvandi . Sadegh . Dongol . Brijesh . Doherty . Simon . Wehrheim . Heike . Integrating Owicki–Gries for C11-Style memory models into Isabelle/HOL . 10.1007/s10817-021-09610-2 . . 66 . 141 - 171 . February 2022 . 215238874 . free . 2004.02983 .
  46. Web site: Civl: A verifier for concurrent programs . 2022-07-22.
  47. Kragl. Bernhard. Qadeer. Shaz. Henzinger. Thomas A.. Refinement for structured concurrent programs. 2020. CAV 2020: Computer Aided Verification. Lecture Notes in Computer Science. S. Lahiri. C. Wang. 12224. Springer Verlag. 10.1007/978-3-030-53288-8_14. 978-3-030-53288-8. free.
  48. Esen. Zafer. Rümmer. Philipp. TRICERA Verifying C Programs Using the Theory of Heaps. October 2022. Proc. 22nd Conf. on Formal Methods in Computer-Aided Design – FMCAD 2022 . A. Griggio. N. Rungta . 360 - 391. TU Wien Academic Press. 10.34727/2022/isbn.978-3-85448-053-2_45. free.