원시데이터 수집 시스템
선정목록으로

Optimal dynamic partial order reduction with context-sensitive independence and observers

관련 산업용 섬유 · (8) HDPE 섬유(FORPE)

기본 정보

저자
  1. Elvira Albert — Universidad Complutense de Madrid, Spain
  2. María García de la Banda — Faculty of IT, Monash University, Australia
  3. Miguel Gómez‐Zamalloa — Universidad Complutense de Madrid, Spain
  4. Miguel Isabel — Universidad Complutense de Madrid, Spain
  5. Peter J. Stuckey — Faculty of IT, Monash University, Australia
DOI
10.1016/j.jss.2023.111730
저널
Journal of Systems and Software
발행년도
2023
발행기관
Elsevier BV
피인용수
2
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1016/j.jss.2023.111730
토픽
Fuel Cells and Related Materials
OpenAlex ID
W4367301512

평가 내용

관련도
관련
사업분야
산업용 섬유 · (8) HDPE 섬유(FORPE)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '산업용 섬유 > HDPE 섬유(FORPE)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

Dynamic Partial Order Reduction (DPOR) algorithms are used in stateless model checking of concurrent programs to avoid the exploration of equivalent execution sequences. In order to detect equivalence, DPOR relies on the notion of independence between execution steps. As this notion must be approximated, it can lose precision and thus treat execution steps as interfering when they are not. Our work is inspired by recent progress in the area that has introduced more accurate ways to exploit conditional notions of independence: Context-Sensitive DPOR considers two steps p and t independent in the current state if the states obtained by executing p⋅t and t⋅p are the same; Optimal DPOR with Observers makes their dependency conditional to the existence of future events that observe their operations. This article introduces a new algorithm, Optimal Context-Sensitive DPOR with Observers, that combines these two notions of conditional independence, and goes beyond them by exploiting their synergies. The implementation of our algorithm has been undertaken within the Nidhugg model checking tool. Our experimental evaluation, using benchmarks from the previous works, shows that our algorithm is able to effectively combine the benefits of both context-sensitive and observers-based independence and that it can produce exponential reductions over both of them.

본문 156,189자

본문 펼치기
The Journal of Systems & [Software](https://doi.org/10.1016/j.jss.2023.111730) 202 (2023) 111730 Contents lists available at [ScienceDirect](https://www.elsevier.com/locate/jss) # The Journal of Systems & Software journal homepage: [www.elsevier.com/locate/jss](http://www.elsevier.com/locate/jss) # Optimal dynamic partial order reduction with context-sensitive independence and observers ✩ Elvira Albert <sup>a</sup>, Maria Garcia de la Banda <sup>b</sup>, Miguel Gómez-Zamalloa <sup>a</sup>, Miguel Isabel <sup>a,∗</sup>, Peter Stuckey <sup>b</sup> a _Universidad_ _Complutense_ _de_ _Madrid,_ _Spain_ b _Faculty_ _of_ _IT,_ _Monash_ _University,_ _Australia_ a r t i c l e i n f _Article_ _history:_ Received 18 March 2022 Received in revised form 24 November 2022 Accepted 24 April 2023 Available online 29 April 2023 _Keywords:_ Software verification Concurrent programs Stateless model checking Partial order reduction 1. Introduction a b s t r a c t Dynamic Partial Order Reduction (DPOR) algorithms are used in stateless model checking of concurrent programs to avoid the exploration of equivalent execution sequences. In order to detect equivalence, DPOR relies on the notion of _independence_ between execution steps. As this notion must be approximated, it can lose precision and thus treat execution steps as interfering when they are not. Our work is inspired by recent progress in the area that has introduced more accurate ways to exploit conditional notions of independence: Context-Sensitive DPOR considers two steps _p_ and _t_ independent in the current state if the states obtained by executing _p_ - _t_ and _t_ - _p_ are the same; Optimal DPOR with Observers makes their dependency conditional to the existence of future events that observe their operations. This article introduces a new algorithm, Optimal Context-Sensitive DPOR with Observers, that combines these two notions of conditional independence, and goes beyond them by exploiting their synergies. The implementation of our algorithm has been undertaken within the Nidhugg model checking tool. Our experimental evaluation, using benchmarks from the previous works, shows that our algorithm is able to effectively combine the benefits of both context-sensitive and observers-based independence and that it can produce exponential reductions over both of them. © 2023 The Author(s). Published by Elsevier Inc. This is an open access article under the CC BY-NC-ND [license (http://creativecommons.org/licenses/by-nc-nd/4.0/).](http://creativecommons.org/licenses/by-nc-nd/4.0/) A fundamental challenge in the verification and testing of concurrent programs arises from the combinatorial explosion that results from exploring the different ways in which processes/threads can interleave. There are several proposals to reduce the number of explored interleavings, such as depth- and contextbounding (Musuvathi and Qadeer, 2007). Among all proposals, Dynamic Partial Order reduction (DPOR) stands out due to its proven scalability, which results from being a _stateless_ approach, i.e., one where global states do not need to be explicitly stored. DPOR is the dynamic realization of Partial-Order Reduction (POR) (Godefroid, 1991, 1996; Clarke et al., 1999). POR is a general theory that provides full coverage of all possible executions of concurrent programs by identifying equivalence classes of redundant executions, and only exploring one representative of ✩ Editor: Earl Barr. ∗ Correspondence to: Department of Sistemas Informáticos y Computación , C/ Profesor José García Santesmases, s/n Complutense University of Madrid, E-28040 Madrid, Spain. _E-mail_ _addresses:_ [elvira@sip.ucm.es](mailto:elvira@sip.ucm.es) (E. Albert), [maria.garciadelabanda@monash.edu](mailto:maria.garciadelabanda@monash.edu) (M.G. de la Banda), [mzamalloa@ucm.es](mailto:mzamalloa@ucm.es) (M. Gómez-Zamalloa), [miguelis@ucm.es](mailto:miguelis@ucm.es) (M. Isabel), [peter.stuckey@monash.edu](mailto:peter.stuckey@monash.edu) (P. Stuckey). each class. POR considers two execution sequences equivalent if one can be obtained from the other by swapping adjacent, _independent_ execution steps. Each such equivalence class is called a Mazurkiewicz (Mazurkiewicz, 1986) trace, and POR guarantees that exploring one sequence per equivalence class is sufficient to cover all. Early POR algorithms (Godefroid, 1996; Clarke et al., 1999; Valmari, 1989) relied on static approximations of independence. The Dynamic-POR (DPOR) algorithm (Flanagan and Godefroid, 2005) was a breakthrough because it uses the information witnessed during the actual execution of the sequence to decide dynamically what to explore. Thus, it often explores less sequences than approaches based on static approximations. As a result, DPOR is considered one of the most scalable techniques for software verification. The cornerstone of DPOR is the notion of _(in)dependence_, which is used to decide if two concurrent execution steps _p_ and _t_ (do not) interfere with each other and, thus, both sequences _p_ followed by _t_ (written _p.t_ ) and the reversed _t.p_ must (not) be explored. To guarantee soundness, DPOR approximates independence and, thus, can lose precision if it treats execution steps as interfering when they are not. Optimal DPOR (ODPOR) (Abdulla et al., 2014) ensures optimality, that is, only one sequence per equivalence class is explored and the exploration of any equivalent execution sequence is not even initiated. However, this is [https://doi.org/10.1016/j.jss.2023.111730](https://doi.org/10.1016/j.jss.2023.111730) 0164-1212/© 2023 The Author(s). Published by Elsevier Inc. This is an open access article under the CC BY-NC-ND license [(http://creativecommons.org/licenses/by-](http://creativecommons.org/licenses/by-nc-nd/4.0/) [nc-nd/4.0/).](http://creativecommons.org/licenses/by-nc-nd/4.0/) _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ done w.r.t. a restricted notion of independence, which usually requires execution steps to be independent in any possible state during the current execution. In practice, syntactic approximations are used to detect independence: typically, two execution steps are considered dependent if both access the same variable and at least one modifies it. Any DPOR algorithm can thus improve its efficiency by using a more accurate independence notion (Godefroid and Pirottin, 1993). Two recent approaches - DPOR _cs_ (Context-Sensitive DPOR) (Albert et al., 2017) and ODPOR <sup>_ob_</sup> (Optimal-DPOR with Observers) (Aronis et al., 2018) - have achieved this by integrating orthogonal notions of _conditional_ _independence_ into DPOR: - _DPORcs_ introduced the notion of _context-sensitive_ independence, which only requires execution steps _p_ and _t_ be independent in the state _s_ where they appear. This is determined by executing sequences _p.t_ and _t.p_ in _s_, and checking if the two states reached are equal. Let us consider the following simple example, borrowed from Aronis et al. (2018), with three concurrent processes _p_, _q_ and _r_ (each containing a single instruction) where the global variable x is initialized to 0: int x = 0; process _p_ : x = 1; process _q_ : x = 2; process _r_ : assert (x _<_ 3); Assume _p_ is scheduled first and we reach a state _s_ where _x_ ==1. Executing either _q.r_ or _r.q_ from _s_ yields the same final state: _x_ ==2 and the assertion holds. Thus, DPOR _cs_ considers _r_ and _q_ independent in _s_ (e.g., in _x_ ==1). - _ODPOR_ <sup>_ob_</sup> introduced the notion of _observability_, where dependencies between execution steps _p_ and _t_ are conditional to the existence of future steps, called observers, which read the values modified by _p_ and _t_ . Consider again the three concurrent processes _p_, _q_ and _r_ above. Assume _r_ is scheduled first reaching a state _s_ where _x_ ==0 and the assertion holds. ODPOR <sup>_ob_</sup> considers _q_ and _p_ independent in _s_ since, while their interleaved execution leads to different final states, variable _x_ is not observed later. _1.1._ _Summary_ _of_ _contributions_ DPOR _cs_ and ODPOR <sup>_ob_</sup> modified the DPOR algorithm to exploit their notions of independence. As our overall contribution, we present a further modification of DPOR, called Optimal ContextSensitive DPOR with Observers (ODPOR <sup>_ob_</sup> _cs_ <sup>),</sup> <sup>that</sup> <sup>not</sup> <sup>only</sup> <sup>com-</sup> bines and exploits these two powerful notions, but also takes advantage of their synergy to gain further pruning. Let us consider again the same three processes and the trace _p.q.r_ . DPOR _cs_ does not consider _p_ and _q_ independent in this trace, as they give different values to variable _x_ . ODPOR <sup>_ob_</sup> does not consider them independent either, as _r_ observes the different values they give to _x_ . However, ODPOR <sup>_ob_</sup> _cs_ <sup>does</sup> <sup>consider</sup> <sup>them</sup> <sup>as</sup> <sup>independent</sup> <sup>in</sup> this trace, as the assertion of observer _r_ evaluates to _true_ after executing either _p.q_ or _q.p_ . The following major contributions are needed for this: 1. _Optimal_ _Context-Sensitive_ _DPOR._ DPOR _cs_ was originally formulated in Albert et al. (2017) over Source-DPOR (Abdulla et al., 2014). Thus, it did not include the extension of _wakeup_ _trees_ used by ODPOR to ensure optimality, and later used to handle observers. Our first contribution is the formulation of DPOR _cs_ over ODPOR, which we name _Optimal_ _Context-Sensitive_ _DPOR_ (ODPOR _cs_ ). This article revises and extends a previous conference paper published in the proceedings of ISSTA’19 (Albert et al., 2019). In addition to fixing some errors, extending the explanations and intuitions, discussing the most recent related work and adding new and more detailed examples, we have important improvements both on the practical and theoretical sides of the work. On the practical one, rather than using our implementations within the SYCO tool (Albert et al., 2016), we have reimplemented the ODPOR <sup>_ob_</sup> _cs_ <sup>,</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>and</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>algorithms</sup> <sup>within</sup> <sup>their</sup> <sup>Nid-</sup> hugg model checking tool (Lang and Leonardsson, 2015). This very significant effort was necessary to facilitate the comparison with algorithms other than ours, particularly ODPOR (Abdulla et al., 2014) and ODPOR <sup>_ob_</sup> (Aronis et al., 2018). We then performed a new and more detailed experimental evaluation using some of the original benchmarks of Aronis et al. (2018) and new encodings of those of Albert et al. (2017). This also required implementing the necessary support to handle atomic blocks, which are needed to encode the actors based concurrency of the benchmarks in Albert et al. (2017). On the theoretical side, we have made three major improvements. First, we have added correctness proofs of both the ODPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>algorithms.</sup> Second, we have proposed a refined and more efficient contextsensitive check that can be exploited not only in ODPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>,</sup> <sup>but</sup> <sup>also</sup> <sup>in</sup> <sup>the</sup> <sup>original</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>of</sup> <sup>Albert</sup> <sup>et</sup> <sup>al.</sup> <sup>(2017).</sup> And third, we have developed a simpler and more accurate definition of the notion of equivalence modulo observability which is key in ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> _1.2._ _Structure_ _of_ _the_ _article_ The rest of the article is organized as follows. Section 2 introduces the technical notation and recalls background knowledge on the DPOR and ODPOR formalisms. Section 3 first describes the original DPOR _cs_ approach and then introduces the modifications and extensions needed to define ODPOR _cs_, as well as the associated proofs of soundness and optimality. Section 4 presents ODPOR <sup>_ob_</sup> _cs_ <sup>:</sup> <sup>the</sup> <sup>integration</sup> <sup>of</sup> <sup>observability</sup> <sup>into</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>.</sup> The results of our implementation and experimental evaluation are reported in Section 5. Finally, Section 6 discusses related work and our final conclusions. 2. Background _2.1._ _Basics_ _of_ _DPOR_ As previous work on DPOR, we assume the state space does not contain cycles, executions have finite unbounded length and processes are deterministic (i.e., at a given time there is at most one event a process can execute). An _execution_ _sequence_ _E_ is a finite sequence of _execution_ _steps_ of the system processes that is performed from the initial state. We denote by _s_ [ _E_ ] the, uniquely 2. _Extending_ _1_ _with_ _observers._ Our second contribution is to integrate observability into ODPOR _cs_, obtaining ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> For this, we modify context-sensitive independence to be _modulo_ _observability_, which only requires equivalence for variables affected by future observers. 3. _Implementation_ _and_ _experiments._ We have implemented ODPOR <sup>_ob_</sup> _cs_ <sup>,</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>and</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>within</sup> <sup>the</sup> <sup>Nidhugg</sup> <sup>model</sup> checking tool (Lang and Leonardsson, 2015) and performed an experimental evaluation with benchmarks from Albert et al. (2017) and Aronis et al. (2018). Our experimental results show that ODPOR <sup>_ob_</sup> _cs_ <sup>can produce exponential reduc-</sup> tions over both DPOR _cs_ and ODPOR <sup>_ob_</sup>, and that, in the worst cases, it scales similarly as the best of the other systems for the considered benchmark. 2 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ defined, state after executing sequence _E_ . We use _ϵ_ to denote the empty sequence and . to denote concatenation of sequences of process steps. E.g., _p.p.q_ denotes the execution sequence where first _p_ performs two steps, followed by a step of _q_ . An _event_ _pi_ of execution sequence _E_ represents the _i_ th occurrence of process _p_ in _E_, e.g., event _p_ 2 denotes the second execution step of process _p_ in the previous sequence. Running Example. Let us consider an extension of the example in Section 1. The program contains two global variables x and y which are initialized to 0, and three processes, _p_, _q_ and _r_ . Process _p_ contains two assignments over variables y and x respectively. Process _q_ only includes an assignment over variable x. Finally, process _r_ includes two assertions that check if variable x is less than 3 and 2, respectively. <u>Int</u> <u>x</u> <u>=</u> <u>0;</u> <u>Int</u> <u>y</u> <u>=</u> <u>0;</u> process _p_ : process _q_ : process _r_ : y = 1; x = 2; assert x _<_ 3; x = 1; assert x _<_ 2; In this example the first assert always holds, while the second can either hold or not depending on whether x has been assigned to 2 when _r_ 2 executes. For instance, given execution sequence _E_ 1 = _q.p.p.r.r_, both asserts hold in _s_ [ _E_ 1]. This is also the case for sequence _E_ 2 = _p.p.r.r.q_, even though we have _x_ = 2 in _s_ [ _E_ 2] and _x_ = 1 in _s_ [ _E_ 1]. In contrast, for sequence _E_ 3 = _p.p.q.r.r_, the second assert does not hold since process _q_ writes 2 over variable x before process _r_ reads it. We use _e_ _<E_ _e_ <sup>′</sup> to denote that event _e_ occurs before event _e_ <sup>′</sup> two events _p_ and _q_ are considered _dependent_ if either one _enable_ s the other (i.e., executing _E.p_ introduces _q_, or vice versa), or if both access the same variable and at least one modifies it. The happens-before relation is also used for defining the notion of _race_ . Event _e_ is said to be in race with event _e_ <sup>′</sup> in execution _E_, written _e_ ⋖ _E_ _e_ <sup>′</sup>, if the events belong to different processes, _e_ happens-before _e_ <sup>′</sup> in _E_ ( _e_ → _E_ _e_ <sup>′</sup> ), and the two events are ‘‘concurrent’’ (∃ _E_ <sup>′</sup> s.t. _E_ <sup>′</sup> ≃ _E_ and the two events are adjacent in _E_ <sup>′</sup> ). This implies that there is no intermediate event _e_ <sup>′′</sup> in _E_ such that _e_ → _E_ _e_ <sup>′′</sup> → _E_ _e_ <sup>′</sup> . We also write _e_ ≾ _E_ _e_ <sup>′</sup> to denote that _e_ is in a reversible race with _e_ <sup>′</sup>, i.e., _e_ is in a race with _e_ <sup>′</sup> and the two can be reversed (∀ _E_ <sup>′</sup> s.t. _E_ <sup>′</sup> ≃ _E_ and _e_ appears immediately before _e_ <sup>′</sup>, _e_ <sup>′</sup> is not blocked). These are the only races the algorithms need to dynamically check for independence. Example 2. In both sequences _E_ 1 and _E_ 1 <sup>′</sup> <sup>of our running example,</sup> we have _q_ 1 ≾ _E_ 1 _p_ 2, i.e., event _q_ 1 is in a reversible race with event _p_ 2. This is because the events belong to different processes, they are concurrent, i.e., ∃ _E_ <sup>′</sup> s.t. _E_ <sup>′</sup> ≃ _E_ 1 where the two events are adjacent (namely, _E_ <sup>′</sup> = _p.q.p.r.r_ ), and none of them can block the other one. Other notation we use includes: _e_ ˆ, denoting the process of event _e_ (e.g., _q_ ˆ1 is _q_ in our example); _enabled(s)_, the set of processes that can perform an execution step from state _s_ (e.g., a locking operation can be enabled if the lock is not taken, or disabled when it is taken); and _pre_ <sup>+</sup> ( _E, e_ ), respectively _pre_ ( _E, e_ ), the prefix of sequence _E_ up to _e_, including and not including _e_ (e.g., _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, p_ 2) is _p.q.p_ and _pre_ ( _E_ <sup>′</sup> _, p_ 2) is _p.q_ in the previous example). _2.2._ _Optimal_ _DPOR_ The code in black of Algorithm 1 (excluding underlined blue parts) corresponds to the ODPOR algorithm (Abdulla et al., 2014) adapted so that it does not make use of sleep-sets, as proposed in Aronis et al. (2018). ODPOR carries out a depth-first exploration of the execution tree from an (initially empty) execution sequence _E_ . Essentially, it dynamically finds reversible races and is able to backtrack at the appropriate scheduling points to reverse them. For this purpose, it keeps two sets for every sequence _E_ explored: the _wakeup_ _tree_ of _E_ containing the execution sequences that must be explored from _E_, and the set of processes that are _done_ from _E_, that is, have already been explored from it. Wakeup Trees. A wakeup tree is an _ordered_ _tree_ ⟨ _B,_ ≺⟩, where the set of nodes _B_ is a finite prefix-closed set of sequences of processes, with the empty sequence _ϵ_ at the root. The children of node _w_ are ordered by ≺ and have the form _w.p_ for some set of processes _p_ . We write _wut_ ( _E_ ) to denote the wakeup tree of sequence _E_ . Intuitively, _wut_ ( _E_ ) is composed of partial execution sequences that must be explored from _E_, as they (a) reverse the order of detected races, and (b) are not provably equivalent. The algorithm makes use of the following functions over wakeup trees: - _insert_ [ _E_ ]( _v, wut_ ( _E_ )) returns the extension of _wut_ ( _E_ ) with a new sequence _v_ . - _subtree_ (⟨ _B,_ ≺⟩ _, p_ ) returns the subtree of wakeup tree ⟨ _B,_ ≺⟩ rooted at process _p_ ∈ _B_, i.e., the tree ⟨ _B_ <sup>′</sup> _,_ ≺ <sup>′</sup> ⟩, where _B_ <sup>′</sup> = { _w_ | _p.w_ ∈ _B_ } and ≺ <sup>′</sup> is the restriction of ≺ to _B_ <sup>′</sup> . ODPOR starts by selecting (line 14) the leftmost process _p_ in the wakeup tree, according to its order ≺, that is enabled by state _s_ [ _E_ ] (due to line 4). If there is such a process, it sets _WuT_ <sup>′</sup> as the subtree of _wut_ ( _E_ ) with root _p_ (line 18), and recursively explores every sequence in _WuT_ <sup>′</sup> from _E.p_ (line 21). Note that _wut_ ( _E_ ) might grow as this recursion progresses, due to later executions in sequence _E_, s.t. _<E_ establishes a total order between events in _E_ . The core concept in DPOR is that of the _happens-before_ partial order among the events in execution sequence _E_, denoted by → _E_ . This relation is used to define a subset of the _<E_ total order, such that any two sequences with the same happensbefore order are equivalent. Let _dom_ ( _E_ ) denote the set of events in _E_ . Any linearization _E_ <sup>′</sup> of → _E_ on _dom_ ( _E_ ) is an execution sequence with the same happens-before relation → _E_ ′ as → _E_ . Thus, → _E_ induces a set of equivalent execution sequences, all with the same happens-before relation. We use _E_ ≃ _E_ <sup>′</sup> to denote that _E_ and _E_ <sup>′</sup> are equivalent. DPOR algorithms use this relation to reduce the number of equivalent execution sequences explored, with ODPOR ensuring that only one execution sequence in each equivalence class is explored. Example 1. Let us consider again sequence _E_ 1 = _q.p.p.r.r_ of our running example. Its total order of events is: _q_ 1 _<E_ 1 _p_ 1 _<E_ 1 _p_ 2 _<E_ 1 _r_ 1 _<E_ 1 _r_ 2. Its happens-before relation is as follows: _q_ 1 _E_ 1 `→` _p_ 2 _E_ 1 `→` _r_ 1 _E_ 1 `→` _r_ 2 _p_ 1 _E_ 1 Another possible linearization of this happens-before relation is hence _E_ 1 <sup>′</sup> <sup>=</sup> <sup>_p.q.p.r.r_</sup> <sup>.</sup> <sup>Since</sup> <sup>both</sup> <sup>_E_</sup> <sup>1</sup> <sup>and</sup> <sup>_E_</sup> 1 <sup>′</sup> <sup>have</sup> <sup>the</sup> <sup>same</sup> happens-before relation we have _E_ 1 ≃ _E_ 1 <sup>′</sup> <sup>.</sup> As done in Abdulla et al. (2014) to support any computation model, our approach assumes the existence of a _happens-before_ _assignment_ function that assigns a happens-before relation to any execution sequence. The precision of such function can vary as long as it satisfies the set of properties specified in Abdulla et al. (2014). For the examples throughout the paper we assume a happens-before assignment based on the traditional approximation of dependency for programs with shared variables. Namely, 3 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Algorithm 1 ODPOR _<u>cs</u>_ algorithm 1: procedure Explore( _E_, _WuT_, _<u>DnD</u>_ <u>)</u> 2: _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>) :=</u> _<u>DnD</u>_ <u>;</u> 3: done( _E_ ) := ∅; 4: if _enabled_ ( _s_ [ _E_ ]) = ∅ then _RaceDetection_ ( _E_ ); 5: else if _WuT_ ̸ = ⟨{ _ϵ_ } _,_ ∅⟩ then 6: _wut_ ( _E_ ) := _WuT_ ; 7: else if _enabled_ ( _s_ [ _<u>E</u>_ ])\ _dnd_ ( _E_ ) = ∅ then 8: <u>for</u> <u>each</u> _<u>p</u>_ ∈ _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>)</u> <u>such</u> <u>that</u> | _<u>p</u>_ | = <u>1</u> <u>:</u> 9: _<u>RaceDetection</u>_ <u>(</u> _<u>E.p</u>_ <u>);</u> 10: else 11: choose _p_ ∈ _enabled_ ( _s_ [ _E_ ])\ _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>);</u> 12: _wut_ ( _E_ ) := ⟨{ _ϵ, p_ } _,_ {( _p, ϵ_ )}⟩; 13: while ∃ _p_ ∈ _wut_ ( _E_ ) do 14: let _p_ = _min_ ≺{ _p_ ∈ _wut_ ( _E_ )}; 15: if _<u>p</u>_ ∈ _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>)</u> then 16: _<u>RaceDetection</u>_ <u>(</u> _<u>E.p</u>_ <u>);</u> 17: else 18: let _WuT_ <sup>′</sup> = _subtree_ ( _wut_ ( _E_ ) _, p_ ); 19: <u>let</u> _<u>DnD</u>_ <sup>′</sup> = { _<u>v</u>_ | _<u>v</u>_ ∈ _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>)</u> _<u>, p</u>_ ̸ ∈ _<u>v, E</u>_ |� _<u>p</u>_ ⋄ _<u>v</u>_ } 20: ∪{ _<u>v</u>_ | <u>(</u> _<u>p.v</u>_ <u>) ∈</u> _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <u>)};</u> 21: _Explore_ ( _E.p, WuT_ <sup>′</sup> _, DnD_ <sup>′</sup> ); 22: add _p_ to _done_ ( _E_ ); 23: remove all sequences of form _p.w_ from _wut_ ( _E_ ); 24: procedure RaceDetection( _E_ ) 25: for all _e, e_ <sup>′</sup> ∈ _dom_ ( _E_ ) such that _e_ ≾ _E_ _e_ <sup>′</sup> do 26: let _E_ <sup>′</sup> = _pre_ ( _E, e_ ); <u>let</u> _<u>dont</u>_ <u>=</u> _<u>ϵ</u>_ <u>;</u> 27: let _v_ = _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> ; _<u>v</u>_ := _<u>v.I</u>_ <u>fut(</u> _<u>E</u>_ <sup>′</sup> _<u>, v, E</u>_ <u>);</u> 28: if _s_ [ _pre_ +( _E,e_ ′)] = _s_ [ _E_ ′ _._ ( _v.suc_ ( _e,E_ ))≤ _e_ ′ ] <sup>then</sup> ] <sup>then</sup> _<u>E</u>_ 29: _<u>dont</u>_ <u>:=</u> _<u>v.e</u>_ <u>ˆ;</u> 30: if _v_ ̸ ∈ _redundant_ ( _E_ <sup>′</sup> _, done_ ) then 31: _wut_ ( _E_ <sup>′</sup> ) := _insert_ [ _E_ ′]( _v, wut_ ( _E_ <sup>′</sup> )); 32: <u>add</u> _<u>dont</u>_ <u>to</u> _<u>dnd</u>_ <u>(</u> _<u>E</u>_ <sup>′</sup> <u>);</u> of line 31. After the recursion finishes, it adds _p_ to _done_ ( _E_ ), removes from _wut_ ( _E_ ) all sequences that start with _p_, and iterates selecting a new _p_ . Once a _complete_ sequence _E_ has been explored ( _E_ is said to be complete if _enabled_ ( _s_ [ _E_ ]) = ∅), the algorithm performs the race detection phase (line 4). This starts by finding all pairs of events _e_ and _e_ <sup>′</sup> in _dom_ ( _E_ ) such that _e_ ≾ _E_ _e_ <sup>′</sup>, that is, _e_ is in a reversible race with _e_ <sup>′</sup> . For each such pair, it sets _E_ <sup>′</sup> to _pre_ ( _E, e_ ) and _v_ to _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> (line 27), where _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) <sup>1</sup> is the subsequence of processes _e_ <sup>ˆ′′</sup> of _E_ such that _e_ _<E_ _e_ <sup>′′</sup> and _e_ ↛ _E_ _e_ <sup>′′</sup>, that is, _e_ occurs before _e_ <sup>′′</sup> in _E_ but does not happenbefore it. Let us explain the intuition of this construction. In order to reverse the race, we need to explore a sequence in which _e_ <sup>′</sup> is executed before _e_ without changing any other happens-before relation. Such sequence must start by _E_ <sup>′</sup> _.v.e_ <sup>′</sup> where _v_ includes all events that are dependent with _e_ <sup>′</sup> . In order to ensure optimality, _v_ might also need to include other events. The sequence computed by _notdep_ <sup>∗</sup> includes all events that are independent with _e_ and, therefore, all events that are dependent with _e_ <sup>′</sup> (otherwise there would be no race) and also those that might be needed to ensure optimality. That is, it includes those events that are necessary and possibly more. Later, _notdep_ <sup>∗</sup> will be refined to include the shortest sequence that is needed. Finally, if the exploration of _v_ in _E_ <sup>′</sup> is not redundant w.r.t already explored sequences (line 30), i.e., it does not lead to equivalent explorations, it is inserted into _wut_ ( _E_ <sup>′</sup> ) (line 31). Redundancy is detected by means of the so called _weak_ _initials_ sets (Abdulla et al., 2014). The weak initials set of sequence _w_ from execution _E_, denoted _WI_ [ _E_ ]( _w_ ), contains any process (in _w_ 1 The ∗ in functions _notdep_ ∗ indicates that it will be redefined later. Function _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) does not use parameter _e_ <sup>′</sup>, it will be used once redefined. or not) with no happens-before predecessors in _dom_ [ _E_ ]( _w_ ), where _dom_ [ _E_ ]( _w_ ) denotes the subset of events in execution sequence _E.w_ that are in _w_, i.e., _dom_ ( _E.w_ )\ _dom_ ( _E_ ). Example 3. In our running example, the set _dom_ [ _q.p_ ]( _p.r.r_ ) contains the events executed by sequence _p.r.r_ after executing _q.p_, that is, { _p_ 2 _, r_ 1 _, r_ 2}. The weak initials set _WI_ [ _ϵ_ ]( _q.p.p.r.r_ ) contains _q_ since it does not have happens-before predecessors in { _p_ 2 _, r_ 1 _, r_ 2}; and _p_ since _p_ 1 does not have happens-before predecessors in { _p_ 2 _, r_ 1 _, r_ 2} either (as can be seen in Example 1). The redundancy check of line 30 is then defined as follows: _v_ ∈ _redundant_ ( _E_ <sup>′</sup> _, done_ ) iff _E_ <sup>′</sup> _.v_ is an execution sequence and there is a partitioning _E_ <sup>′</sup> = _w.w_ <sup>′</sup> such that _done_ ( _w_ ) ∩ _WI_ [ _w_ ]( _w_ <sup>′</sup> _.v_ )̸ = ∅. Intuitively, this check determines if the algorithm has already explored a subsequence that is equivalent to _E_ <sup>′</sup> _.v_, by succeeding if a process without happens-before predecessors in the subset of events of _E_ <sup>′</sup> _.v_ that are in _w_ <sup>′</sup> _.v_, has already been explored (done) from sequence _w_ . This is shown in action later in Example 4 (in the RaceDetection at state 15). Note that in the original ODPOR algorithm (Abdulla et al., 2014) this check is implemented using sleep-sets. However, (Aronis et al., 2018) shows that sleep-sets are not suitable as a mechanism to avoid redundant exploration in the presence of observers, and proposes this alternative definition that, as we have seen, relies on the done and weak-initials sets. We have therefore adopted this solution to ensure the ODPOR algorithm is ready for the integration of observers. Example 4. The execution tree that ODPOR explores for the running example is shown in Fig. 1. Each node in the tree corresponds to a different call to Explore. The meaning of the different labels is explained in the figure caption. The lower node labels (in blue) and the boxes labeled P1-P6 should be ignored for now. They correspond, respectively, to don’t-do sets (see Section 3.1), and to prunings that the other algorithms perform. Fig. 2 lists the main actions that are carried out by the algorithm showing, for each of them, the state, the cause (i.e. the reversible race) and the effects of the action (i.e. the updates on wakeup trees). ODPOR starts with both _E_ and _WuT_ empty (state 0). Let us assume the algorithm first explores sequence _q.p.p.r.r_ (by picking respectively these processes in each recursive call in line 11), thus reaching state 5 and invoking RaceDetection (line 4). Since the happens-before relation of this explored execution is the one shown in Example 1, a reversible race between _p_ 2 and _r_ 1 is detected ( _p_ 2 happens-before _r_ 1, appears immediately before _r_ 1 and does not block it) setting _E_ <sup>′</sup> to _q.p_ and _v_ to _r_ . This causes the addition of _r_ to _wut_ ( _q.p_ ) (see upper label of state 2), indicating the algorithm will eventually have to backtrack to state 2 to explore process _r_ . A reversible race between _q_ 1 and _p_ 2 is also detected, setting _E_ <sup>′</sup> to _ϵ_ and _v_ to _p.p_ (line 27), thus adding _p.p_ to _wut_ ( _ϵ_ ) (upper label of state 0). The algorithm then backtracks to state 2 (the first one with non-empty _wut_ ), along the way adding _r_ to the _done_ sets of states 4 and 3, and _p_ to the _done_ set of state 2 (line 22). Then it explores _q.p.r_ (as determined by its _wut_, which has _r_ ) reaching state 6. Let us assume it then explores _q.p.r.p.r_ thus reaching state 8 and invoking RaceDetection. Two reversible races are detected: one between _r_ 2 and _p_ 2, which causes the addition of _r_ to _wut_ ( _q.p.r_ ) (upper label of state 6), and one between _r_ 1 and _q_ 1, which causes the addition of _p.r_ to _wut_ ( _ϵ_ ) (upper label of state 0). The algorithm then backtracks to state 6 whose non-empty _wut_ has _r_ (adding the appropriate processes to the _done_ sets), explores _q.p.r.r.p_ and invokes RaceDetection at state 10, which detects no new races. Fig. 3 shows the _wut_ ( _ϵ_ ) at this point, both in textual and graphical forms. Node _q_ will be deleted from it when backtracking to state 0 and hence sequences _p.p_ and _p.r_ remain to be explored. 4 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Fig. 1. Execution tree computed by the ODPOR algorithms for our running example. Subtrees P1 to P4 (dashed boxes in blue) are pruned by ODPOR _cs_ and DPOR _cs_ ; P5 (dotted box) is pruned by ODPOR <sup>_ob_</sup> and P1–P6 are all pruned by ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> <sup>Arrow</sup> <sup>labels</sup> <sup>indicate</sup> <sup>the</sup> <sup>scheduled</sup> <sup>process;</sup> <sup>upper</sup> <sup>node</sup> <sup>labels</sup> <sup>the</sup> <sup>wakeup</sup> <sup>trees</sup> ( _v_ + _w_ is a tree with two traces); and lower node labels (in blue) the don’t-do sets (dnd). (For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.) _E_ <sup>′</sup> = _w.w_ <sup>′</sup>, in this case let _w_ = _ϵ_ and _w_ <sup>′</sup> = _p_, such that we have a non-empty intersection between _done_ ( _ϵ_ ) = { _q_ } and _WI_ [ _ϵ_ ]( _p.q_ ) = { _p, q_ }. Fig. 2. Main actions performed by ODPOR on Example 4. Fig. 3. _wut_ ( _ϵ_ ) at state 10 in Example 4. The algorithm now backtracks to state 0 (removing _r_ from the _wut_ of states 6 and 2 on the way due to line 23, and appropriately updating the _done_ sets as before) whose _wut_ has both _p.p_ and _p.r_ . Let us assume _p.p_ is explored first, reaching _p.p.q.r.r_ (at state 15) and invoking RaceDetection. It detects two reversible races: one between _r_ 1 and _q_ 1, which causes the addition of _r_ to _wut_ ( _p.p_ ) (state 12), and one between _q_ 1 and _p_ 2. In this latter case _q_ is not added to _wut_ ( _p_ ) (state 11) because we have _q_ ∈ _redundant_ ( _p, done_ ) (line 30), which means the exploration that would be performed from _p.q_ is redundant to that already performed from _q.p_ . Applying the above definition of _redundant_, _E_ <sup>′</sup> _.v_, in this case let _E_ <sup>′</sup> = _p_ and _v_ = _q_, is an execution sequence and there is a partitioning The algorithm then backtracks to state 12 (updating the _wut_ and _done_ sets of intermediate states as usual) whose _wut_ has _r_, and explores _p.p.r.q.r_ reaching state 18. The invocation to RaceDetection detects two reversible races: one between _r_ 2 and _q_ 1, which causes the addition of _r_ to _wut_ ( _p.p.r_ ) (and the subsequent exploration of sequence _p.p.r.r.q_ ), and one between _r_ 1 and _p_ 2, which causes the addition of _r_ to _wut_ ( _p_ ) (though this has no effect since _r_ is already inherited down to _wut_ ( _p_ ) from _wut_ ( _ϵ_ )). The algorithm then backtracks to state 11 whose _wut_ now only has _r_ and explores the subtree rooted at state 21. Let us just list the reversible races that are responsible for updating the wakeup trees of states 21,22 and 27: At state 24 two reversible races are detected: one between _r_ 2 and _q_ 1, which causes the addition of _r_ to _wut_ ( _p.r.p_ ), and one between _q_ 1 and _p_ 2, which causes the addition of _q_ to _wut_ ( _p.r_ ). At state 26 the reversible race between _r_ 2 and _p_ 2 causes the addition of _r_ to _wut_ ( _p.r_ ). At state 29 the reversible race between _r_ 2 and _p_ 2 causes the addition of _r_ to _wut_ ( _p.r.q_ ). Finally, at state 34 the reversible race between _q_ 1 and _p_ 2 causes the addition of _q_ to _wut_ ( _p.r.r_ ). Overall, ODPOR has explored 12 executions that matches the 12 possible happens-before relations corresponding to all ordering combinations of events _q_, _p_ 2, _r_ 1 and _r_ 2, with the restriction that _r_ 1 cannot go after _r_ 2. A full systematic exploration would have to explore 30 executions. Note also that ODPOR has not even had to initiate any redundant exploration. Instead, the original DPOR algorithm very often needs to explore partial executions before noticing they lead to redundant explorations (the so called sleep-set-blocked explorations). 3. Optimal context-sensitive DPOR _3.1._ _Context-sensitive_ _DPOR_ The first algorithm that has used notions of conditional independence within the state of the art DPOR algorithm is ContextSensitive DPOR (Albert et al., 2017) (DPOR _cs_ ). This algorithm exploits _context-sensitive_ _independence_, which requires checking the commutativity in the current state (the context) of every two 5 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ events that are in race. If they commute, the algorithm prevents the exploration of the reversed race by adding information to the sleep set. DPOR _cs_ was built in Albert et al. (2017) on top of SourceDPOR (Abdulla et al., 2014) and includes the following two main features: - Sleep-set extension. Sequences of processes are more expressive than single processes, thus sleep sets are generalized to contain sequences of processes. We denote this new kind of set as the _don’t-do_ set. Sequences in the don’t-do sets are ignored, as they are proven to lead to redundant exploration thanks to context-sensitive independence. - State equivalence check. When a reversible race _e_ ≾ _E_ _e_ <sup>′</sup> is detected, in addition to recording the required information to ensure the race is reversed on backtracking, the algorithm also checks whether events _e_ and _e_ <sup>′</sup> are independent in the current context _E_, that is, whether _s_ [ _E.e_ ˆ _._ ˆ _e_ ′] = _s_ [ _E._ ˆ _e_ ′ _.e_ ˆ]. If so, the corresponding don’t-do set is extended with the sequence of the reversed race to avoid its exploration. Example 5. Let us consider the exploration of sequence _q.p.p.r.r_ in the example of Fig. 1. When DPOR _cs_ reaches state 4, it realizes _p_ 2 and _r_ 1 can be regarded as independent in context _q.p_, as _s_ [ _q.p.p.r_ ] = _s_ [ _q.p.r.p_ ], even though they are dependent according to the happens-before relation in Abdulla et al. (2014) with the usual syntactic approximation, since _p_ 2 writes global variable _x_ and _r_ 1 reads it. Hence, it adds _r.p_ to the don’t-do set of state 2 (see its lower label, which is shown in negative form, i.e., ¬ _r.p_ ). Once _r_ is explored, _p_ is not executed because it is in the don’tdo set of state 6 (don’t-do sets are propagated downwards in the tree by eliminating the explored process - in this case _r_ - from the sequence - in this case from _r.p_ ), which prevents the full exploration of _q.p.r.p.r_ . As mentioned before, our first contribution is the reformulation of DPOR _cs_ as an extension of ODPOR, rather than of SourceDPOR. This yields an optimal DPOR _cs_ algorithm (see below), referred to as ODPOR _cs_, which enables the integration of the notion of observers (as done in Section 4). Reformulating DPOR _cs_ in terms of ODPOR is challenging due to two main problems: - Challenge I: While Source-DPOR performs race detection at every state, ODPOR must delay race detections until the sequence being explored is complete. - Challenge II: As shown in Albert et al. (2017), the effectiveness of DPOR _cs_ is highly dependent on exploring don’t-do sequences as soon as possible. Indeed, DPOR _cs_ uses these sequences to guide the selection of the next process to be explored. However, the wakeup trees of ODPOR fix part of these decisions, which can affect guidance. The ODPOR _cs_ algorithm corresponds to the full code of Algorithm 1 (both black and underlined in blue). The algorithm is discussed in detail in Sections 3.2 and 3.3, which explain how challenges I and II, respectively, have been faced. In addition, Section 3.4 proposes a refinement to the context-sensitive check of both ODPOR _cs_ and DPOR _cs_ that makes it potentially much more efficient in certain cases. The proofs of correctness and optimality for ODPOR _cs_ are provided in Appendix A. _3.2._ _Challenge_ _I_ Delaying race detections until the entire sequence is explored, complicates the implementation of the context-sensitive checks, as they need access to intermediate states. One could recover these states by, for example, re-executing the sequence of events to reach them, or storing them, either in full or by means of incremental state updates, to be undone on backtracking. One ecutes the same events as _pre_ <sup>+</sup> ( _E, e_ <sup>′</sup> ) but with the race reversed. Assuming we have access to _s_ [ _pre_ +( _E,e_ )] and _s_ [ _E_ ′], we only need to compute the state after the sequence ( _v.suc_ ( _e, E_ ))≤ _eE_ ′ <sup>from</sup> <sup>_s_</sup> <sup>[</sup> <sup>_E_</sup> <sup>′].</sup> <sup>If</sup> the check succeeds and _v_ is not redundant for _E_ <sup>′</sup>, sequence _v.e_ ˆ is added to the don’t-do set _dnd_ ( _E_ <sup>′</sup> ) (line 32). Note that, unlike in the original DPOR _cs_, _v_ contains the processes of events executed after _e_ <sup>′</sup> in _E_, that do not happen-after _e_ and, thus, neither happen-after _e_ <sup>′</sup> . This issue is further discussed in Section 3.3. As in the original DPOR _cs_, if a sequence _w_ is added to the don’tdo set of state _s_, _w_ can be inherited down once we backtrack to _s_, possibly being reduced until it eventually becomes a unitary sequence and the exploration stops (referred to as a _don’t-do_ _set_ _blocked_ _exploration_ ). In that case, race detection must be forced explicitly. This is the task of the new _if_ statement in lines 15 and 16. Similarly, if every process enabled in _s_ [ _E_ ] is also in _dnd_ ( _E_ ) for sequence _E_, then the exploration of _E_ stops and race detection is forced explicitly, in this case for every unitary sequence in _dnd_ ( _E_ ) (lines 7, 8 and 9). The support to inherit down don’t-do sequences is the same as in the original DPOR _cs_, corresponding to lines 19 and 20. Essentially, _E.p_ inherits each sequence _v_ where _p.v_ ∈ _dnd_ ( _E_ ) (line 20), and where every process in _v_ (line 19) is independent of _p_ in _E_ (denoted as _E_ |� _p_ ⋄ _v_ ), i.e, where the event in _dom_ [ _E_ ]( _p_ ) does not happen-before any event in _dom_ [ _E.p_ ]( _v_ ). Example 6. Let us explain the exploration performed by ODPOR _cs_ on our running example, which is shown in Fig. 1. The lower node labels (in blue) that start with ¬ indicate sequences in the corresponding don’t-do sets, and the nodes within dashed boxes (labeled P1, P2, P3 and P4) correspond to nodes that are not explored and hence are pruned by ODPOR _cs_ . Sequences starting with ¬ in parenthesis should be ignored by now. In the following we explain the most relevant additional actions that ODPOR _cs_ performs w.r.t ODPOR, some of which lead to the above-mentioned prunings. Fig. 4 lists such actions, showing, for each of them, the state, the cause (i.e. the result of the context-sensitive check or the inherited sequence in the don’t-do set, where ⇐ should be read as ‘‘inherited from’’) and the effects of the action (i.e. the updates on don’t-do sets or the pruning carried out). In the invocation to RaceDetection at state 5, i.e., after exploring sequence _q.p.p.r.r_, for the race between _p_ 2 and _r_ 1, the new context-sensitive check at line 28 checks if _s_ [ _q.p.p.r_ ] = _s_ [ _q.p.r.p_ ]. Since the check succeeds _r.p_ is added to _dnd_ ( _q.p_ ) (lines 29 and 32). Also at state 5, for the race between _p_ 2 and _q_ 1, ODPOR _cs_ checks whether _s_ [ _q.p.p_ ] = _s_ [ _p.p.q_ ], but this time the check fails and, hence, nothing is added to _dnd_ ( _ϵ_ ). When backtracking to state 2 with _r_, sequence _r.p_ in _dnd_ ( _q.p_ ) is inherited down as _p_ in _dnd_ ( _q.p.r_ ) (line 20). This causes the could also perform (part of) the checks on the fly during the exploration, instead of at the end, thus reducing the number of intermediate states needed. The preferred strategy will depend on the available memory and the concrete language features. In any case, the following assumes access to all states of the current sequence. The new context-sensitive check corresponds to the underlined blue code in line 28 of Algorithm 1 (for now, we use the black code for _v_ in line 27; it will be redefined in Section 3.3). Recall that the black code of Algorithm 1 is common to both ODPOR and ODPOR <sup>_ob_</sup>, and was described in Section 2.2. Intuitively, given a reversible race _e_ ≾ _E_ _e_ <sup>′</sup> for events _e_ and _e_ <sup>′</sup>, the new check succeeds if the state right after the race, _s_ [ _pre_ +( _E,e_ ′)], is the same as that obtained when the race is reversed, _s_ [ _E_ ′ _._ ( _v.suc_ ( _e,E_ ))≤ _e_ ′ ] <sup>, where</sup> _E_ _suc_ ( _e, E_ ) is the subsequence _w_ of _E_ that starts with ˆ _e_ and contains all _e_ <sup>ˆ′′</sup> s.t. _e_ → _E_ _e_ <sup>′′</sup>, and _w_ ≤ _eE_ ′ <sup>is</sup> <sup>the</sup> <sup>subsequence</sup> <sup>of</sup> <sup>_w_</sup> <sup>in</sup> <sup>_E_</sup> <sup>of</sup> processes that execute events up to, and including, _e_ <sup>′</sup> (i.e., keeps ] <sup>, where</sup> _E_ _eE_ ′ <sup>is</sup> <sup>the</sup> <sup>subsequence</sup> <sup>of</sup> <sup>_w_</sup> <sup>in</sup> <sup>_E_</sup> <sup>of</sup> _e_ ˆ <sup>′′</sup> only if _e_ <sup>′′</sup> ≤ _E_ _e_ <sup>′</sup> ). As a result, the sequence _E_ <sup>′</sup> _._ ( _v.suc_ ( _e, E_ ))≤ _e_ ′ _E_ _e_ ′ _E_ <sup>ex-</sup> _eE_ ′ <sup>from</sup> <sup>_s_</sup> <sup>[</sup> <sup>_E_</sup> <sup>′].</sup> <sup>If</sup> 6 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Fig. 4. Main actions performed by ODPOR _cs_ on Example 6. pruning of box P1. At state 6, _r_ is chosen to be explored, because _p_ is in _dnd_ ( _q.p.r_ ). _p_ is then removed from _dnd_ ( _q.p.r.r_ ) in line 19 since _p_ 2 and _r_ 1 are dependent (i.e., we do not have _q.p.r_ |� _p_ ⋄ _r_ ). The algorithm fully explores sequence _q.p.r.r.p_ and then invokes again RaceDetection at state 10. For the reversible race between _q_ 1 and _r_ 1, the check _s_ [ _q.p.r_ ] = _s_ [ _p.r.q_ ] succeeds and, hence, _p.r.q_ is added to _dnd_ ( _ϵ_ ). The race between _r_ 2 and _p_ 2 causes the addition of _p_ to _wut_ ( _q.p.r_ ). Hence, when the algorithm backtracks to state 6, and since _p_ is both in _wut_ ( _q.p.r_ ) and _dnd_ ( _q.p.r_ ), RaceDetection is explicitly invoked (lines 15 and 16), though this time nothing new is added to any wakeup-tree nor any don’t-do set. ODPOR _cs_ then fully explores sequence _p.p.q.r.r_ and invokes RaceDetection at state 15. For the race between _r_ 1 and _q_ 1 the algorithm checks whether _s_ [ _p.p.q.r_ ] = _s_ [ _p.p.r.q_ ], and since the check succeeds _r.q_ is added to _dnd_ ( _p.p_ ). This causes the pruning of box P2. The algorithm then backtracks to state 12 with _r_, explores sequence _p.p.r.r.q_ and invokes RaceDetection at state 20. For the race between _r_ 1 and _p_ 2 the algorithm now checks whether _s_ [ _p.p.r_ ] = _s_ [ _p.r.p_ ], and since the check succeeds _r.p_ is added to _dnd_ ( _p_ ) (which already had _r.q_ in it). The algorithm then backtracks to state 11 with _r_ . It inherits down _r.p_ and _r.q_ to state 21 as _p_ and _q_ respectively, hence forcing it to select process _r_ at state 21, causing the prunings of P3 and P4. Finally, sequences _p.r.r.p.q_ and _p.r.r.q.p_ are explored as in ODPOR. Overall, ODPOR _cs_ has explored 6 executions (instead of the 12 explored by ODPOR), plus the additional explorations that need to be computed by the new context-sensitive checks. _3.3._ _Challenge_ _II_ the original DPOR) does not record the sequence to be explored upon backtracking but, rather, an initial event to explore plus the sequences that should not be selected (by means of the so called _backtrack-set_ and _sleep-set_ ). This allows using don’t-do sequences to guide DPOR _cs_ decisions regarding what to explore, achieving earlier and more effective context-sensitive prunings. However, wakeup trees are essential for ODPOR to achieve optimality. Therefore, the challenge is to determine whether it is possible to keep optimality, while at the same time being able to exploit don’t-do sequences at least as effectively as DPOR _cs_ . In order to reverse race _e_ ≾ _E_ _e_ <sup>′</sup>, it suffices to have all ancestors of _e_ <sup>′</sup> before it. Let us then re-define _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) as _ance_ ( _e, e_ <sup>′</sup> _, E_ ), the subsequence of _E_ containing the processes whose events occur after _e_ and happen-before _e_ <sup>ˆ′</sup> (and thus, are independent with _e_, since otherwise _e_ and _e_ <sup>′</sup> would not be in race). This solves the problem in the above example: for the race between _t_ and _t_ <sup>′</sup> in _E_ 1, the sequences added to _wut_ ( _ϵ_ ) and _dnd_ ( _ϵ_ ) would be _t_ <sup>′</sup> and _t_ <sup>′</sup> _.t_, respectively. However, it is not enough since, in order to achieve optimality, _v_ needs to include part of the processes of _E_ whose corresponding events are independent with the ones in _v_, thus being detected as redundant in line 28. Let us define the set of _future initials_, written _I_ fut( _E_ <sup>′</sup> _, v, E_ ), that contains any process with no ‘‘happens-before’’ predecessors in _dom_ [ _E_ ′ _.v_ ]( _w_ ) (i.e., _WI_ [ _E_ ′]( _w_ ) \ _v_ ), where _E_ = _E_ <sup>′</sup> _.w_ . Intuitively, every event executed in _w_ is dependent with one in _v.I_ fut( _E_ <sup>′</sup> _, v, E_ ) (i.e., ∀ˆ _e_ ∈ _w,_ ∃ _e_ <sup>ˆ′</sup> ∈ _v.I_ fut( _E_ <sup>′</sup> _, v, E_ ) such that _e_ <sup>′</sup> → _E_ _e_ ). Indeed, the future initials are also required in sequence _v_, so that when an exploration is stopped by a don’t-do sequence (line 16), the corresponding race detection phase has enough information to build the appropriate sequences for each detected new race. As a result, we redefine _v_ as _notdep_ <sup>∗</sup> ( _e_ <sup>′</sup> _, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.I_ fut( _E_ <sup>′</sup> _, v, E_ ) (line 27) with _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) = _ance_ ( _e, e_ <sup>′</sup> _, E_ ). In the example above, for the race between _t_ and _t_ <sup>′</sup> in _E_ 1, the new sequences added to _wut_ ( _ϵ_ ) and _dnd_ ( _ϵ_ ) are _t_ <sup>′</sup> _.p_ and _t_ <sup>′</sup> _.p.t_, respectively. _3.4._ _A_ _more_ _efficient_ _context-sensitive_ _check_ _eE_ ′ <sup>. The computation of these alternative se-</sup> To illustrate this challenge, let us consider the processes _p_ and _q_ from our running example, and the initial exploration _E_ 1 = _t.t_ <sup>′</sup> _.p.p.q_, where _t_ is a process defined as _t_ : _z_ = 1; and _t_ <sup>′</sup> is another instance of the same process _t_ . Let us assume, for now, that ODPOR _cs_ uses the original definition of sequence _v_ (line 27), that is, _v_ = _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> . For the reversible race between _p_ 2 and _q_ 1, ODPOR _cs_ adds _q_ to _wut_ ( _t.t_ <sup>′</sup> _.p_ ). Hence, upon backtracking to _t.t_ <sup>′</sup> _.p_, it will explore _E_ 2 = _t.t_ <sup>′</sup> _.p.q.p_ . For the reversible race between _t_ 1 and _t_ 1 <sup>′</sup> <sup>,</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>sets</sup> <sup>_v_</sup> <sup>to</sup> <sup>_p.p.q.t_</sup> <sup>′</sup> <sup>(since</sup> <sup>all</sup> <sup>_p_</sup> <sup>1,</sup> <sup>_p_</sup> <sup>2</sup> <sup>and</sup> _E_ 1 between _t_ 1 and _t_ 1 <sup>′</sup> <sup>,</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>sets</sup> <sup>_v_</sup> <sup>to</sup> <sup>_p.p.q.t_</sup> <sup>′</sup> <sup>(since</sup> <sup>all</sup> <sup>_p_</sup> <sup>1,</sup> <sup>_p_</sup> <sup>2</sup> <sup>and</sup> _q_ are independent of _t_ 1, and also of _t_ 1 <sup>′</sup> <sup>)</sup> <sup>and</sup> <sup>adds</sup> <sup>it</sup> <sup>to</sup> <sup>_wut_</sup> <sup>(</sup> <sup>_ϵ_</sup> <sup>).</sup> _q_ are independent of _t_ 1, and also of _t_ 1 <sup>′</sup> <sup>)</sup> <sup>and</sup> <sup>adds</sup> <sup>it</sup> <sup>to</sup> <sup>_wut_</sup> <sup>(</sup> <sup>_ϵ_</sup> <sup>).</sup> Also, since _s_ [ _t.t_ ′] = _s_ [ _t_ ′ _.t_ ], it adds _p.p.q.t_ <sup>′</sup> _.t_ to _dnd_ ( _ϵ_ ). Later, when backtracking to _ϵ_ and exploring _p.p.q.t_ <sup>′</sup>, sequence _t_ <sup>′</sup> _.t_ is inherited down to _dnd_ ( _p.p.q_ ), which in turn causes _t_ to be inherited down to _dnd_ ( _p.p.q.t_ <sup>′</sup> ), causing the exploration to stop and the racedetection phase to start (line 16) for _p.p.q.t_ <sup>′</sup> _.t_ . This detects a race between _p_ 2 and _q_ 1, causing the exploration of _t_ <sup>′</sup> _.t.p.q.p_, which is redundant to _E_ 2 (as _s_ [ _t.t_ ′] = _s_ [ _t_ ′ _.t_ ]). Such a redundant trace would not have been explored by DPOR _cs_ . This is because DPOR _cs_ (as well as Source-DPOR and As explained above, for any given race, the state equivalence check of ODPOR _cs_ (and DPOR _cs_ ) compares the state of the current execution sequence right after the race ( _pre_ <sup>+</sup> ( _E, e_ <sup>′</sup> )) against that of an alternative sequence that executes the same events but with the race reversed. To ensure this, such an alternative sequence includes, after the reversed race, events that are not related to the race, namely _suc_ ( _e, E_ )≤ _eE_ ′ <sup>. The computation of these alternative se-</sup> quences may produce an overhead on the ODPOR _cs_ (and DPOR _cs_ ) algorithm. Therefore, we would like to make them as efficient as possible without compromising the effectiveness of the prunings performed due to the context-sensitive checks. To illustrate this, let us consider the process _p_ from our running example, a new process _t_ defined as _t_ : _y_ = 1 and an initial exploration _E_ 1 = _p.p.t_ . For the race between _p_ 1 and _t_ 1 the state equivalence check compares the states for _E_ 1 and _E_ 2 = _t.p.p_ and succeeds. We can observe that in _E_ 2 the second step of _p_ (that is _suc_ ( _p_ 1 _, E_ 1)≤ _t_ ) is completely unrelated to the race between _p_ 1 _E_ 1 and _t_ 1 but it has been added to ensure both _E_ 1 and _E_ 2 have the same events. Indeed, if we take it out from _E_ 2 the check would fail, i.e. _s_ [ _p.p.t_ ]̸ = _s_ [ _t.p_ ]. However, if the check would focus only on the variables (memory addresses) which are involved in the race, in this case variable _x_, then the check will succeed even with the shortened sequence _t.p_ . To illustrate the potential impact this improvement may have in the algorithm, let us consider a generalization of the above pattern with a process _p_ <sup>′</sup> : _for_ ( _i_ = 0; _i_ _<_ _n_ ; _i_ ++) _a_ [ _i_ ] = 0; that initializes the first _n_ elements of an array _a_, a process _t_ <sup>′</sup> : _a_ [0] = 0; that simply writes on the first position of the array, and the initial exploration _E_ 1 <sup>′</sup> <sup>=</sup> <sup>_p_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_. . . . p_</sup> <sup>′</sup> <sup>_.t_</sup> <sup>′</sup> <sup>(where</sup> <sup>all</sup> <sup>steps</sup> <sup>of</sup> <sup>process</sup> To illustrate the potential impact this improvement may have in the algorithm, let us consider a generalization of the above pattern with a process _p_ <sup>′</sup> : _for_ ( _i_ = 0; _i_ _<_ _n_ ; _i_ ++) _a_ [ _i_ ] = 0; that initializes the first _n_ elements of an array _a_, a process _t_ <sup>′</sup> : _a_ [0] = 0; that simply writes on the first position of the array, and the initial exploration _E_ 1 <sup>′</sup> <sup>=</sup> <sup>_p_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_. . . . p_</sup> <sup>′</sup> <sup>_.t_</sup> <sup>′</sup> <sup>(where</sup> <sup>all</sup> <sup>steps</sup> <sup>of</sup> <sup>process</sup> 7 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ _p_ <sup>′</sup> are executed before process _t_ <sup>′</sup> ). For the race between _p_ <sup>′</sup> 1 _p_ <sup>′</sup> are executed before process _t_ <sup>′</sup> ). For the race between _p_ <sup>′</sup> 1 <sup>and</sup> _t_ 1 <sup>′</sup> <sup>the</sup> <sup>state</sup> <sup>equivalence</sup> <sup>check</sup> <sup>would</sup> <sup>compare</sup> <sup>the</sup> <sup>states</sup> <sup>of</sup> <sup>_E_</sup> 1 <sup>′</sup> and _E_ 2 <sup>′</sup> <sup>=</sup> <sup>_t_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_. . . . p_</sup> <sup>′</sup> <sup>and</sup> <sup>succeed.</sup> <sup>Here</sup> <sup>we</sup> <sup>can</sup> <sup>observe</sup> <sup>the</sup> 1 and _E_ 2 <sup>′</sup> <sup>=</sup> <sup>_t_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′</sup> <sup>_. . . . p_</sup> <sup>′</sup> <sup>and</sup> <sup>succeed.</sup> <sup>Here</sup> <sup>we</sup> <sup>can</sup> <sup>observe</sup> <sup>the</sup> potential overhead that we may have in the computation of _E_ 2 <sup>′</sup> <sup>.</sup> The proposal is to take out from _E_ 2 <sup>′</sup> <sup>the events that are not related</sup> to the race, hence considering instead _E_ 2 <sup>′</sup> <sup>=</sup> <sup>_t_</sup> <sup>′</sup> <sup>_.p_</sup> <sup>′,</sup> <sup>and</sup> <sup>make</sup> <sup>the</sup> state equivalence check focus only on variable _a_ [0], otherwise the check would fail. To accomplish this, we rewrite line 27 of Algorithm 1 as: _V_ <sup>_e,e_</sup> <sup>′</sup> _s_ [ _pre_ +( _E,e_ ′)] = _E_ _s_ [ _E_ ′ _._ ( _v.e_ ˆ)≤ _e_ ′ ] _E_ where _suc_ ( _e, E_ )≤ _eE_ ′ _eE_ ′ <sup>has</sup> <sup>been</sup> <sup>taken</sup> <sup>out</sup> <sup>from</sup> <sup>the</sup> <sup>sequence</sup> <sup>of</sup> <sup>the</sup> right-hand side, and _VE_ <sup>_e,e_</sup> <sup>′</sup> _E_ <sup>_e,e_</sup> <sup>′</sup> added on top of the equality, indicating the equality is checked on the subset of variables _VE_ <sup>_e,e_</sup> <sup>′</sup> the equality is checked on the subset of variables _VE_ <sup>_e,e_</sup> <sup>′</sup>, which is defined as follows. Let _WE_ ( _e_ ) and _WE_ ({ _e_ 1 _, . . ., en_ }) denote the set of variables (memory addresses) written in execution _E_ by event _e_ and by the set of events { _e_ 1 _, . . ., en_ }, respectively. Let _IE_ <sup>_e_</sup> <sup>(</sup> <sup>_x_</sup> <sup>) be the</sup> set of variables written by event _e_ in execution _E_ whose written value has been affected by variable _x_ . We use _E_ <sup>¯</sup> to denote the alternative sequence including event _e_, that is, _E_ <sup>′</sup> _._ ( _v_ )≤ _eE_ ′ <sup>_.e_</sup> <sup>ˆ,</sup> <sup>where</sup> _E_ <sup>′</sup> and _v_ are as defined in lines 26 and 27 of Algorithm 1. We define the set of variables involved in a race between _e_ and _e_ <sup>′</sup> in execution _E_, written _VE_ <sup>_e,e_</sup> <sup>′</sup>, as: _VE_ <sup>_e,e_</sup> <sup>′</sup> = ( _WE_ ( _e_ ) ∩ _WE_ ( _e_ <sup>′</sup> )) ∪ (1) _eE_ ′ <sup>_.e_</sup> <sup>ˆ,</sup> <sup>where</sup> Note that in the case of assertion statements, the result of an assertion is assumed to be written to a memory address and thus it is included in the _W_ and _I_ sets. For instance, consider events _e_ : _x_ = 1; and _e_ <sup>′</sup> : _assert_ _x_ _>_ 0; with execution sequence _E_ = _e.e_ <sup>′</sup> . The result of the assertion is obviously involved in the race between _e_ and _e_ <sup>′</sup> and should be included in _VE_ <sup>_e,e_</sup> <sup>′</sup> . This is captured by term (2) since the memory address where the result of the assertion is written to is assumed to belong to _IE_ <sup>_e_</sup> <sup>′</sup> <sup>(</sup> <sup>_x_</sup> <sup>).</sup> <sup>The</sup> rest of the terms produce the empty set in this case. _3.5._ _Correctness_ _and_ _optimality_ The following theorem ensures the soundness of our ODPOR _cs_ extension. Theorem 1 ( _Soundness of ODPORcs_ ) . _For each Mazurkiewicz trace T_ _defined_ _by_ _the_ _happens-before_ _relation,_ _Explore(ϵ,_ ⟨{ _ϵ_ } _,_ ∅⟩ _,_ ∅ _)_ _of_ _Algorithm_ _1_ _explores_ _a_ _complete_ _execu-_ _tion sequence that either implements T, or reaches an identical state_ _to_ _one_ _that_ _implements_ _T._ The optimality of ODPOR _cs_ with respect to the Mazurkiewicz traces based on the context-sensitive notion of independence is in general not guaranteed, since it only detects certain cases of context-sensitive independence. However, it has analogous optimality results as the ODPOR algorithm (i.e., for the Mazurkiewicz traces based on the notion of independence of Abdulla et al. (2014)): if ODPOR _cs_ explores a don’t-do set blocked execution _E_, then ODPOR explores completely an execution with the same happens-before relation than _E_ . Theorem 2 ( _Optimality of ODPORcs_ ) . _Algorithm 1 never explores two_ _complete execution sequences that are equivalent, and never initiates_ _redundant_ _executions._ The proofs of the above theorems can be found in Appendix A. 4. Optimal context-sensitive DPOR with observers _E_ <sup>_e,e_</sup> <sup>′</sup>, as: _VE_ <sup>_e,e_</sup> <sup>′</sup> _IE_ <sup>_e_</sup> <sup>′</sup> <sup>(</sup> <sup>_x_</sup> <sup>))</sup> <sup>∪</sup> (2) _IE_ <sup>_e_</sup> ¯ <sup>(</sup> <sup>_x_</sup> <sup>))</sup> <sup>∪</sup> (3) ( ( ⋃ _x_ ∈ _WE_ ( _e_ ) ⋃ _x_ ∈ _WE_ ¯ ( _e_ <sup>′</sup> ) ( _WE_ ({ _e, e_ <sup>′</sup> }) \ _WE_ ¯ ({ _e, e_ <sup>′</sup> })) ∪ (4) ( _WE_ ¯ ({ _e, e_ <sup>′</sup> }) \ _WE_ ({ _e, e_ <sup>′</sup> })) (5) The first term, labeled (1), includes the variables that are written in both events. The second and third terms include, for the original and the alternative executions _E_ and _E_ <sup>¯</sup> respectively, the variables written by the second event in the race whose written value has been affected by a variable written in the first event of the race in the corresponding execution. Finally, the fourth and fifth terms include the variables that are written by either _e_ or _e_ <sup>′</sup> in one of the executions that are not written by _e_ nor _e_ <sup>′</sup> in the other execution. Example 7. Let us illustrate the need for each of the terms above with the following examples of events _e, e_ <sup>′</sup> and execution sequence _E_ = _e.e_ <sup>′</sup> : - Consider _e_ : _x_ = 1; and _e_ <sup>′</sup> : _x_ = 2;. Since variable _x_ is involved in a race between _e_ and _e_ <sup>′</sup>, it should be included in _VE_ <sup>_e,e_</sup> <sup>′</sup> . This is captured by term (1). - Consider _e_ : _x_ = 1; and _e_ <sup>′</sup> : _y_ = _x_ ;. In this case term (2) produces { _y_ } since the value written to _y_ depends on whether _e_ is executed before or not. The other terms produce the empty set. We hence get _VE_ <sup>_e,e_</sup> <sup>′</sup> = { _y_ }. - Consider _e_ : _i_ = 1; and _e_ <sup>′</sup> : _v_ [ _i_ ] = 1; with an initial state where _i_ = 0. Term (4) produces { _v_ [1]} whereas term (5) produces { _v_ [0]}. The other terms produce the empty set. We hence get _VE_ <sup>_e,e_</sup> <sup>′</sup> = { _v_ [0] _, v_ [1]}. If we instead consider an _E_ <sup>_e,e_</sup> <sup>′</sup> = { _v_ [0] _, v_ [1]}. If we instead consider an This section presents Optimal Context-Sensitive DPOR with Observers (ODPOR <sup>_ob_</sup> _cs_ <sup>),</sup> <sup>our</sup> <sup>new</sup> <sup>DPOR</sup> <sup>algorithm</sup> <sup>that</sup> <sup>not</sup> <sup>only</sup> combines and exploits the notions of context-sensitive independence and observability, but also takes advantage of their synergy to gain further pruning. First, Section 4.1 recalls the formal notion of observability and the Optimal DPOR with Observers (ODPOR <sup>_ob_</sup> ) algorithm of Aronis et al. (2018). Then, Section 4.2 presents the basic ODPOR <sup>_ob_</sup> _cs_ algorithm that simply joins the ODPOR <sup>_ob_</sup> and ODPOR _cs_ algorithms. Sections 4.3 and 4.4 present two enhancements that exploit the combination and the synergy between the notions of context-sensitive independence and observability. Finally, Section 4.5 studies the soundness of the enhanced ODPOR <sup>_ob_</sup> _cs_ algorithm. _4.1._ _Optimal_ _DPOR_ _with_ _observers_ The notion of observability (Aronis et al., 2018) allows dependencies between execution events to be conditional to the existence of later events called observers. The typical example in the context of programs with shared variables occurs when there are two events _e_ and _e_ <sup>′</sup> that write over the same variable, but the written value is not later read or observed. In such a case the idea is not to consider the two events as interfering and, hence, _e_ does not happen-before _e_ <sup>′</sup> . The intuition behind this approach is that only operations that observe a value (e.g. assertions or receives) can influence the control flow and lead to erroneous or unexpected behaviors, whereas other operations (e.g., writes initial state with _i_ = 1, we would get _VE_ <sup>_e,e_</sup> <sup>′</sup> initial state with _i_ = 1, we would get _VE_ <sup>_e,e_</sup> <sup>′</sup> = {} since in this case both executions write _v_ [1] with a value that does not depend on event _e_ . If we consider _e_ <sup>′</sup> : _v_ [ _i_ ] = _i_ ; (with initial state _i_ = 1) then term (2) would produce { _v_ [1]} since the written value now depends on event _e_ . 8 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ or sends) cannot affect program behavior if no future operation observes their effects. Again, as in Abdulla et al. (2014), in order not to restrict to any specific computation model, Aronis et al. (2018) assume the existence of a _happens-before_ _assignment_ function that assigns a happens-before relation to any execution sequence. The precision of such function can vary as long as it satisfies a set of properties, which relax those of Abdulla et al. (2014) in order to consider the notion of observability. Let us recall the new properties related to the notion of observability. Definition 1 ( _observers_ ( _e, e_ <sup>′</sup> _, E_ ) _Aronis_ _et_ _al.,_ _2018_ ) . Given an execution sequence _E_, and any two events _e, e_ <sup>′</sup> ∈ _dom_ ( _E_ ) where _e_ ⋖ _E_ _e_ <sup>′</sup>, there exists a set _O_ = _observers_ ( _e, e_ <sup>′</sup> _, E_ ) ⊆ _dom_ ( _E_ ) such that: 1. For all _o_ ∈ _O_, it holds that _e_ → _E_ _o_, _o_ ̸ = _e_ <sup>′</sup>, and _o_ ↛ _E_ _e_ <sup>′</sup> . 2. For all _o, o_ <sup>′</sup> ∈ _O_, it holds that _o_ ↛ _E_ _o_ <sup>′</sup> . 3. If _E_ <sup>′</sup> ≃ _E_, then _observers_ ( _e, e_ <sup>′</sup> _, E_ <sup>′</sup> ) = _O_ . 4. For every prefix _E_ <sup>′</sup> of _E_ such that _e, e_ <sup>′</sup> ∈ _dom_ ( _E_ <sup>′</sup> ): - If _O_ is empty, then _e_ → _E_ ′ _e_ <sup>′</sup> . - If _O_ is nonempty, then _e_ → _E_ ′ _e_ <sup>′</sup> iff _dom_ ( _E_ <sup>′</sup> ) ∩ _O_ ̸ = ∅. 5. If _e_ ≾ _E_ _e_ <sup>′</sup>, for all sequences _w_ s.t. _E.w_ is a sequence, and all events _e_ <sup>′′</sup> ∈ _dom_ ( _E_ ): - If _e_ ↛ _E_ _e_ <sup>′′</sup>, then _e_ ⋖ _E.we_ <sup>′′</sup> . - If _e_ <sup>′′</sup> ↛ _E_ _e_ <sup>′</sup>, then _e_ <sup>′′</sup> ⋖ _E.we_ <sup>′</sup> . 6. For all _e_ <sup>′′</sup> ∈ _dom_ ( _E_ ) such that _e_ <sup>′</sup> → _E_ _e_ <sup>′′</sup>, it holds that _O_ ∩ _observers_ ( _e_ <sup>′</sup> _, e_ <sup>′′</sup> _, E_ )=∅. 7. If _O_ = { _o_ } and _E_ = _E_ <sup>′</sup> _.o_ ˆ for some _o_ and _E_ <sup>′</sup>, then for any _E_ <sup>′′</sup> ≃ _E_ <sup>′</sup>, either _e_ → _E_ ′′ _.o_ ˆ _e_ <sup>′</sup> or _e_ <sup>′</sup> → _E_ ′′ _.o_ ˆ _e_ . Intuitively, in the usual particular case of variable reads and writes, _observers_ ( _e, e_ <sup>′</sup> _, E_ ) is the set of other events in _E_, independent of each other (by Property 2), that read the value written by _e_ ( _e_ <sup>′</sup> ) for any variable also written by _e_ <sup>′</sup> ( _e_ ) (by Property 4). By an abuse of notation, we will sometimes treat this set as a sequence. From this point on, the presented algorithms will rely on such a generic happens-before assignment, i.e., one that considers observability and satisfies the above properties. In the examples we will continue to assume a concrete happens-before assignment based on the traditional approximation of dependency for programs with shared variables, extended to consider observability as follows. Two events _p_ and _q_ are considered _dependent_ _modulo_ _observability_ if: (i) one _enable_ s the other, or (ii) one writes over a variable that the other reads, or (iii) both write over a variable that is later read by an observer. Example 8. Let us consider sequence _E_ 1 = _q.p.p.r.r_ . We have _q_ 1 → _E_ 1 _p_ 2 since event _r_ 1 is an observer of the race. However, event _r_ 2 is not an observer in spite of reading variable _x_ . This is because of Condition 2 of Definition 1 ( _r_ 1 is already an observer). On the other hand, _r_ 2 is an observer of the race between _q_ 1 and _p_ 2 in sequence _E_ 2 = _p.r.q.p.r_ and hence we have _q_ 1 → _E_ 2 _p_ 2. Finally, in sequence _E_ 3 = _p.r.r.p.q_ we have _p_ 2 ↛ _E_ 3 _q_ 1 since there is not an observer after them that reads the written value on variable _x_ . The ODPOR <sup>_ob_</sup> algorithm of Aronis et al. (2018) corresponds to the code in black of procedure Explore of Algorithm 1 (excluding underlined blue parts) and the new RaceDetection procedure of Fig. 5 with the original definition of _notdep_ <sup>∗</sup> of Section 2.2. Apart from the new happens-before assignment, the new support for handling observers corresponds to lines 4–6 of Fig. 5. Specifically, if the race between _e_ and _e_ <sup>′</sup> is _observed_ (line 4), the race must be reversed and observed by the same observers. Thus, the last ( _maxE_ ) observer _o_ executed in _E_ is selected (line 5) and used to Fig. 5. RaceDetection of ODPOR <sup>_ob_</sup> (Aronis et al., 2018). compute _v_ (line 6), where _notobs_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) <sup>2</sup> denotes the subsequence of _E_ containing any process _e_ <sup>ˆ′′</sup> such that _e_ → _E_ _e_ <sup>′′</sup>, but _e_ <sup>′′</sup> does not observe the race _e_ ≾ _E_ _e_ <sup>′</sup>, and _o_ <sup>′</sup> ↛ _E_ _e_ <sup>′′</sup> for any observer _o_ <sup>′</sup> of the race. There is a small change in line 5 with respect to Aronis et al. (2018): we select _o_ as the last (rather than an arbitrary) observer from _observers_ ( _e, e_ <sup>′</sup> _, E_ ). The reason for this will be clear in Section 4.3. Example 9. The exploration of ODPOR <sup>_ob_</sup> on our working example proceeds exactly the same as that of ODPOR (see Example 4) until state 34. This is because all write-write races until this point have a subsequent observer that reads the written value. As an example, see sequences _E_ 2 and _E_ 3 of Example 8. However, after exploring sequence _p.r.r.p.q_ at state 34, ODPOR <sup>_ob_</sup> does not consider a race between _p_ 2 and _q_ 1 (since there is not a later observer) and hence it does not backtrack to state 32 to explore _p.r.r.q.p_ (pruning _P_ 5 of Fig. 1). Note that while the final value of variable _x_ in these sequences is different ( _x_ = 1 vs. _x_ = 2), ODPOR <sup>_ob_</sup> considers that this does not affect the program behavior, as the value is not read later. _4.2._ _The_ _basic_ _‘‘union’’_ _algorithm_ The ODPOR _cs_ and ODPOR <sup>_ob_</sup> algorithms of Sections 3 and 4.1 can be combined simply by joining their codes together, that is, the code of procedure Explore of Algorithm 1 (including underlined blue parts) and the new RaceDetection procedure of Fig. 5, adding the underlined blue code of the RaceDetection of Algorithm 1, including the enhancements of Sections 3.2–3.4 and relying on the happens-before relation of Section 4.1. The exploration performed by such a ‘‘union’’ algorithm would be the intersection of the explorations of ODPOR _cs_ and ODPOR <sup>_ob_</sup>, and its prunings the union of the ODPOR _cs_ and ODPOR <sup>_ob_</sup> prunings. Example 10. In our working example such basic ‘‘union’’ algorithm proceeds as the ODPOR _cs_ algorithm until state 34 and then, as ODPOR _cs_ (see Example 9), it does not backtrack to state 32 to explore _p.r.r.q.p_ . It is hence able to avoid the exploration of the states in boxes _P_ 1, _P_ 2, _P_ 3, _P_ 4 and _P_ 5 of Fig. 1. This ‘‘union’’ algorithm can be seen in Algorithm 2, if we ignore the code underlined in red (which corresponds to the enhancements of Sections 4.3 and 4.4) and we take lines 76, 77 and 78 outside the scope of the else (as explained in Section 4.3). These modifications to the ‘‘union’’ algorithm are performed to exploit the synergy between the notions of context-sensitive independence and observability. The resulting algorithm is ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> 2 The mark ∗ in function _notobs_ ∗ indicates that it will be redefined later. 9 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Algorithm 2 ODPOR <sup>_ob_</sup> _<u>cs</u>_ <sup>algorithm</sup> 43: procedure explore( _E_, _WuT_, _DnD_ ) 44: _dnd_ ( _E_ ) := _DnD_ ; 45: done( _E_ ) := ∅; 46: if _enabled_ ( _s_ [ _E_ ]) = ∅ then _RaceDetection_ ( _E_ ); 47: else if _WuT_ ̸ = ⟨{ _ϵ_ } _,_ ∅⟩ then 48: _wut_ ( _E_ ) := _WuT_ ; 49: else if _enabled_ ( _s_ [ _E_ ])\ _dnd_ ( _E_ ) = ∅ then 50: for each _p_ ∈ _dnd_ ( _E_ ) such that | _p_ | = 1 : 51: _RaceDetection_ ( _E.p_ ); 52: else 53: choose _p_ ∈ _enabled_ ( _s_ [ _E_ ])\ _dnd_ ( _E_ ); 54: _wut_ ( _E_ ) := ⟨{ _ϵ, p_ } _,_ {( _p, ϵ_ )}⟩; 55: while ∃ _p_ ∈ _wut_ ( _E_ ) do 56: let _p_ = _min_ ≺{ _p_ ∈ _wut_ ( _E_ )}; 57: if _p_ ∈ _dnd_ ( _E_ ) then 58: _RaceDetection_ ( _E.p_ ); 59: else 60: let _WuT_ <sup>′</sup> = _subtree_ ( _wut_ ( _E_ ) _, p_ ); 61: let _DnD_ <sup>′</sup> = { _v_ | _v_ ∈ _dnd_ ( _E_ ) _, p_ ̸ ∈ _v, E_ |� _p_ ⋄ _v_ } 62: ∪{( _u.v_ ) | ( _u.p.v_ ) ∈ _dnd_ ( _E_ ) _<u>, E</u>_ |� _u.p.v_ _p_ ⋄ _u_ }; 63: _Explore_ ( _E.p, WuT_ <sup>′</sup> _, DnD_ <sup>′</sup> ); 64: add _p_ to _done_ ( _E_ ); 65: remove all sequences of form _p.w_ from _wut_ ( _E_ ); 66: procedure RaceDetection( _E_ ) 67: for all _e, e_ <sup>′</sup> ∈ _dom_ ( _E_ ) such that _e_ ≾ _E_ _e_ <sup>′</sup> do 68: let _E_ <sup>′</sup> = _pre_ ( _E, e_ ); let _dont_ = _ϵ_ ; 69: if _observers_ ( _e, e_ <sup>′</sup> _, E_ )̸ = ∅ then 70: let _o_ = _maxE_ ( _observers_ ( _e, e_ <sup>′</sup> _, E_ )); 71: let _v_ = _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.e_ ˆ _._ ( _notobs_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ )\ _e_ <sup>ˆ′</sup> ) _.o_ ˆ; 72: <u>let</u> _<u>os</u>_ = _<u>observers</u>_ <u>(</u> _<u>e, e</u>_ <sup>′</sup> _<u>, E</u>_ <u>);</u> _<u>v</u>_ := _<u>v.I</u>_ <u>fut(</u> _<u>E</u>_ <sup>′</sup> _<u>, v, E</u>_ <u>));</u> _._ ( _o_ ˆ _s_ \ˆ _o_ )] <sup>then</sup> 73: if <sup><u>⋀</u></sup> _o_ <sup>′</sup> ∈ _os_ _s_ [ _pre_ +( _E,o_ ′)]= <sup>_e_</sup> _o_ <sup>_,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> <sup>_e_</sup> _o_ <sup>_,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> <sup>_s_</sup> <sup>[</sup> <sup>_E_</sup> <sup>′</sup> <sup>_.v_</sup> ≤ <sup>_o_</sup> _E_ 74: _<u>dont</u>_ := _<u>v.</u>_ <u>(</u> _<u>o</u>_ ˆ _<u>s</u>_ \ˆ _<u>o</u>_ <u>);</u> 75: else 76: let _v_ = _notdep_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> ; _v_ := _v.I_ fut( _E_ <sup>′</sup> _, v, E_ ); _V_ <sup>_e,e_</sup> <sup>′</sup> 77: if _s_ [ _pre_ +( _E,e_ ′)] = _E_ _s_ [ _E_ ′ _._ ( _v_ )≤ _e_ ′ ] <sup>then</sup> 78: _dont_ := _v.e_ ˆ; _E_ 79: if _v_ ̸ ∈ _redundant_ ( _E_ <sup>′</sup> _, done_ ) then 80: _wut_ ( _E_ <sup>′</sup> ) := _insert_ [ _E_ ′]( _v, wut_ ( _E_ <sup>′</sup> )); 81: add _dont_ to _dnd_ ( _E_ <sup>′</sup> ); _4.3._ _Refining_ _the_ _context-sensitive_ _check_ _for_ _write-write_ _races_ Consider again the race detection phase on our running example of Fig. 1 after exploring sequence _q.p.p.r.r_ . The ‘‘union’’ algorithm finds a reversible race _q_ 1 ≾ _E_ _p_ 2 observed by _r_ 1. After setting _v_ to _p.p.q.r_ in line 71, the check _s_ [ _q.p.p_ ] = _s_ [ _p.p.q_ ] in line 77 fails (recall this line is temporarily assumed to be outside the else scope). Hence, nothing is added at this time to _dnd_ ( _ϵ_ ) and _p.p.q.r_ is added to _wut_ ( _ϵ_ ). Interestingly, sequence _p.p.q.r.r_ is equivalent to the already explored _q.p.p.r.r_ from the point of view of the observer _r_ 1. I.e., although the value of variable _x_ is different, the assert executed by _r_ 1 holds in both cases. Note that this is not the case for the assert of _r_ 2 (it holds in _q.p.p.r.r_ but it does not in _p.p.q.r.r_ ), but since it is not an observer (due to Condition 2 of Definition 1) it does not need to be considered in this sequence (see Example 8). It thus seems natural in this case to perform an enhanced context-sensitive check that compares the states _modulo_ _observ-_ _ability_, e.g., compares _s_ [ _p.p.q.r_ ] and _s_ [ _q.p.p.r_ ] only considering the effect of the observation performed by _r_ 1. Since in both cases it has the same effect (the assert holds), _p.p.q.r_ could be added to _dnd_ ( _ϵ_ ), thus stopping the exploration of the fourth derivation at state 13. More precisely, given a race _e_ ≾ _E_ _e_ <sup>′</sup> observed by _o_, we say that two states _s_ and _s_ <sup>′</sup> are _equivalent_ _modulo_ _observability_, _WE_ ( _o_ ) written _s_ =W _E_ ( _o_ ) _s_ <sup>′</sup> (following the notation of Section 3.4), if the variables that are written by _o_ have the same values in _s_ and _s_ <sup>′</sup> . Let us recall that in the case of observers with assertion statements, the result of the assertion is assumed to be written to a memory address and thus included in the _WE_ ( _o_ ) set. In the example above with _E_ = _q.p.p.r.r_, the equality between _s_ [ _p.p.q.r_ ] and _s_ [ _q.p.p.r_ ] is performed only looking at the result of the assertion in _r_ 1. The implementation of the refined check corresponds to the underlined red code in lines 72, 73 and 74 of Algorithm 2. First, it sets _os_ to the subsequence of observer processes _observers_ ( _e, e_ <sup>′</sup> _,_ _E_ ). Then, after extending _v_ with the required processes (see explanation below), it checks that for every observer process _o_ <sup>′</sup> in _os_ (this time treated as a set), the state after executing _o_ <sup>′</sup> is equivalent modulo observability to the state obtained by the alternative sequence _E_ <sup>′</sup> _.v_ ≤ <sup>_o_</sup> _E_ <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\</sup> <sup>_o_</sup> <sup>ˆ),</sup> <sup>which</sup> <sup>contains</sup> <sup>the</sup> <sup>reversed</sup> race, followed by observer _o_ and the remaining observers. As with the original context-sensitive check (see Section 3.3), in order to be effective, it is important not to include in _v_ unnecessary processes before the reversed race, while at the same time including at the end those that are necessary to keep optimality. The solution is analogous to that of Section 3.3. First, unnecessary processes are taken away from sequence _v_ (line 71). In particular, _notdep_ <sup>∗</sup> inherits the redefinition of Section 3.3, and _notobs_ <sup>∗</sup> ( _e, e_ <sup>′</sup> _, E_ ) is redefined as the subsequence of processes of _E_, excluding the occurrence _e_, whose events happen-before those in _observers_ ( _e, e_ <sup>′</sup> _, E_ ). Finally, to ensure optimality, _v_ is extended with _I_ fut( _E_ <sup>′</sup> _, v, E_ ) (line 71), to ensure it has enough information to detect redundancies. Note that all the predecessors of other observers are in _v_ ≤ <sup>_o_</sup> _E_ <sup>,</sup> thanks to the choice of _o_ as _maxE_ ( _observers_ ( _e, e_ <sup>′</sup> _, E_ )). Thus, we can execute _o_ ˆ _s_ \ _o_ ˆ ( _o_ ˆ is already in _v_ ) without problem after _E_ <sup>′</sup> _.v_ ≤ <sup>_o_</sup> _E_ <sup>.</sup> Note also that we cannot use _s_ [ _pre_ +( _E,o_ )] to perform all the checks because, after every _o_ <sup>′</sup> ∈ _os_ has been executed, there may be another event _e_ <sup>′′</sup> _<_ _o_ ∈ _E_ such that _o_ <sup>′</sup> → _E_ _e_ <sup>′′</sup>, which would invalidate the check by modifying the value of the variables used in the check. That is why we use _s_ [ _pre_ +( _E,o_ ′)] for each _o_ <sup>′</sup> ∈ _os_ to perform each check in line 73. Another possibility, which could be more efficient in certain contexts (and does not require accessing these intermediate states), would be to perform all the checks with the state _s_ [ _notdep_ ∗( _e,e_ ′ _,E_ ) _.e_ ˆ _._ ˆ _e_ ′ _._ ( _notobs_ ∗( _e,e_ ′ _,E_ )\{ˆ _e_ }) _.o_ ˆ _s_ ], where the race between _e_ and _e_ <sup>′</sup> has not been reversed. The following provides the intuition behind the need to consider every observer _o_ <sup>′</sup> ∈ _observers_ ( _e, e_ <sup>′</sup> _, E_ ) for the new check, rather than just the selected one _o_ . Consider our running example with a simple modification: the instruction _assert_ ( _x_ _<_ 2); is executed by a different process _r_ <sup>′</sup>, enabled from the initial state. Let the sequence _E_ = _q.p.p.r.r_ <sup>′</sup> be the initial exploration of the algorithm. For the race between _q_ 1 and _p_ 2 we have that _observers_ ( _q_ 1 _, p_ 2 _, E_ ) = { _r_ 1 _, r_ 1 <sup>′</sup> <sup>}. Let us assume the algorithm selects</sup> _o_ := _r_ . If the new check only considers event _o_ 1 (instead of every _o_ <sup>′</sup> ∈ _os_ ), the check succeeds (the assert holds in both cases) and, hence, _p.p.q.r_ is added to _dnd_ ( _ϵ_ ). This would prevent the exploration of sequence _p.p.q.r.r_ <sup>′</sup> (where the assert of _r_ 1 <sup>′</sup> <sup>does not hold)</sup> which is not equivalent to any previously explored sequence. In this concrete example, this does not cause us to lose any different final result (the assert of _r_ 1 <sup>′</sup> <sup>also</sup> <sup>fails</sup> <sup>in</sup> <sup>other</sup> <sup>combinations).</sup> However, this would not be the case in an example where the only possibility for the assert of _r_ 1 <sup>′</sup> <sup>to</sup> <sup>fail</sup> <sup>would</sup> <sup>be</sup> <sup>to</sup> <sup>execute</sup> <sup>it</sup> after _q.p.p_ . Note that the new enhanced check is only applied in the case of write-write races followed by an observer (i.e. when the algorithm enters the if of line 69) and that it can only be more precise than the original check. That is why in the final algorithm, the code of lines 76, 77 and 78 goes within the else scope, hence 10 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ replacing the original check for the case of write-write races. For races that are not observed, the original check is still applied in lines 77 and 78. Example 11. Let us consider the exploration performed by ODPOR <sup>_ob_</sup> _cs_ <sup>on</sup> <sup>our</sup> <sup>running</sup> <sup>example</sup> <sup>of</sup> <sup>Fig.</sup> <sup>1</sup> <sup>(recall</sup> <sup>that</sup> <sup>frag-</sup> ments in all boxes are pruned by ODPOR <sup>_ob_</sup> _cs_ <sup>).</sup> <sup>In</sup> <sup>the</sup> <sup>invocation</sup> to RaceDetection at state 5, i.e., after exploring sequence _q.p.p.r.r_, for the write-write race between _q_ 1 and _p_ 2, the new enhanced context-sensitive check of line 73 only checks if the result of the assertion of _r_ 1 is the same in both _s_ [ _q.p.p.r_ ] and _s_ [ _p.p.q.r_ ] (since we have _observers_ ( _q_ 1 _, p_ 2 _, q.p.p.r.r_ ) = { _r_ 1}), ignoring the value of variable _x_ which is different. Since the check succeeds _p.p.q.r_ is added to _dnd_ ( _ϵ_ ). This causes the pruning of box _P_ 6. The rest of the exploration proceeds as the ‘‘union’’ algorithm (see Example 10). Note that the enhanced check is also executed in the call to RaceDetection at state 24, i.e., after exploring sequence _p.r.p.q.r_, for the write-write race between _p_ 2 and _q_ 1, but this time it fails since the assert of observer _r_ 2 fails after _p.r.p.q.r_ (where _x_ = 2) but instead it succeeds in _p.r.q.p.r_ (where _x_ = 1). _4.4._ _Refining_ _the_ _inheritance_ _of_ _don’t-do_ _sequences_ One could expect that whenever a sequence _w_ is added to a _dnd_ ( _E_ <sup>′</sup> ) set of sequence _E_ <sup>′</sup> due to the new refined check, a prefix of _w_ be also added to _wut_ ( _E_ <sup>′</sup> ). Indeed, if the refined check of line 73 succeeds, sequence _v._ ( _o_ ˆ _s_ \ _o_ ˆ) is added to _dnd_ ( _E_ <sup>′</sup> ), and sequence _v_ is inserted to _wut_ ( _E_ <sup>′</sup> ). However, it is possible for the later sequence not to be added to _wut_ ( _E_ <sup>′</sup> ) if it already contains an equivalent sequence (which had been added before). In such cases, the _dnd_ sequence might not be propagated successfully during the exploration of the corresponding sequence in _wut_ ( _E_ <sup>′</sup> ), resulting in unnecessary exploration. Example 12. Let us consider our running example but replacing process _r_ by _r_ : _o_ = _x_ ; and exploring first sequence _E_ 1 = _p.q.q_ <sup>′</sup> _.p.r_, where _q_ <sup>′</sup> is another instance of the same process _q_ . For the race between _q_ 1 and _p_ 2, the refined check builds the alternative sequence _p.q_ <sup>′</sup> _.p.q.r_ (note that _q_ <sup>′</sup> happens-before _q_ in _E_ 1). The obtained observation is _o_ = 2, whereas in the original _E_ 1 it was _o_ = 1, hence _q_ <sup>′</sup> _.p.q.r_ is added to _wut_ ( _p_ ) but not to _dnd_ ( _p_ ). The algorithm explores four more sequences before backtracking to the root, including sequence _E_ 2 = _p.q.p.q_ <sup>′</sup> _.r_ . In this case, for the race between _q_ and _q_ <sup>′</sup>, the refined check builds the alternative sequence _p.p.q_ <sup>′</sup> _.q.r_ (note that _p_ happens-before _q_ <sup>′</sup> in _E_ 2). The obtained observation both in _E_ 2 and _p.p.q_ <sup>′</sup> _.q.r_ is _o_ = 2. Hence, _p.q_ <sup>′</sup> _.q.r_ is added to _dnd_ ( _p_ ) but not to _wut_ ( _p_ ), since it is equivalent to _q_ <sup>′</sup> _.p.q.r_, which was added before. The propagation of _dnd_ sequences in Algorithm 1 (underlined blue code of lines 19 and 20) is not able to propagate down _p.q_ <sup>′</sup> _.q.r_ when exploring _q_ <sup>′</sup> _.p.q.r_, even though they are equivalent sequences. The refined propagation allows us to generalize the previous propagation of _dnd_ sequences, which can be seen in the underlined red code of line 62 of Algorithm 2. Essentially, a sequence _u.p.v_ will now be propagated as _u.v_, if _p_ is independent of all processes in _u_ . In addition, the new case can take advantage of observability using the information of the trace _E_ <sup>′</sup> _.u.p.v_ . We define _E_ |� _u.q.p.v_ _q_ ⋄ _p_ if _E.u_ |� _q_ ⋄ _p_, (i.e., they are unconditional independent), or ∃ˆ _w_ ∈ _v_, such that the set of variables written both by _p_ and _q_ is overwritten by _w_ and ∀ˆ _r_ ∈ _v_ that observes any of these variables, _w_ _<E.u.q.p.v_ _r_ . Intuitively, this refined propagation allows transitively propagating equivalences between the _dnd_ set and the _WuT_ of a state. In the case of Example 12, when backtracking to _p_ to explore _q_ <sup>′</sup> _.p.q.r_, the sequence _p.q_ <sup>′</sup> _.q.r_ in _dnd_ ( _p_ ) is propagated down to _dnd_ ( _p.q_ <sup>′</sup> ) as _p.q.r_ . This allows detecting _p.q_ <sup>′</sup> _.p.q.r_ as redundant. Indeed, _p_ |� _p.q_ ′ _.q.r_ _p_ 2 ⋄ _q_ <sup>′</sup> 1 <sup>in</sup> <sup>_p.q_</sup> <sup>′</sup> <sup>_.q.r_</sup> <sup>since</sup> <sup>_r_</sup> <sup>1</sup> <sup>is</sup> <sup>not</sup> <sup>observing</sup> <sup>their</sup> effect (it observes the subsequent write _q_ 1), whereas they would be dependent with the traditional notion of dependency. Let us finally point out that this refinement is also applicable to the ODPOR _cs_ algorithm of Section 3.1, and also to the original DPOR _cs_ algorithm of Albert et al. (2017), although in these contexts it would be much less likely to be applied. _4.5._ _Correctness_ _and_ _optimality_ The theorem for ODPOR <sup>_ob_</sup> _cs_ is analogous to the one in Appendix A, but using the definition of _equivalence_ _modulo_ _ob-_ _servability_, introduced in Section 4.3. Theorem 3 ( _Soundness_ _of_ _ODPOR_ <sup>_ob_</sup> _cs_ <sup>)</sup> <sup>.</sup> <sup>_For_</sup> <sup>_each_</sup> <sup>_Mazurkiewicz_</sup> <sup>_trace_</sup> _T_ _defined_ _by_ _the_ _happens-before_ _relation,_ _Explore(ϵ,_ ⟨{ _ϵ_ } _,_ ∅⟩ _,_ ∅ _)_ _of_ _Algorithm_ _2_ _explores_ _a_ _complete_ _exe-_ _cution_ _sequence_ _that_ _either_ _implements_ _T,_ _or_ _reaches_ _an_ _equivalent_ _state_ _modulo_ _observability_ _as_ _one_ _that_ _implements_ _T._ Theorem 4 ( _Optimality_ _of_ _ODPOR_ <sup>_ob_</sup> _cs_ <sup>)</sup> <sup>.</sup> _Algorithm_ _2_ _never_ _explores_ _two_ _complete_ _execution_ _sequences_ _that_ _are_ _equivalent._ The proofs of the above theorems can be found in Appendix B. 5. Experiments This section reports on our experimental comparison of the performance of ODPOR (Abdulla et al., 2014), ODPOR <sup>_ob_</sup> (Aronis et al., 2018), DPOR _cs_ (Albert et al., 2017) and our proposed ODPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> <sup>The</sup> <sup>major</sup> <sup>part</sup> <sup>of</sup> <sup>the</sup> <sup>experiments</sup> <sup>are</sup> performed using the Nidhugg tool (Lang and Leonardsson, 2015), a stateless model checker for shared-memory pthreads programs written in C/C++ that operates by interpreting the LLVM intermediate representation. It is important to note that Nidhugg was developed and it is maintained by some of the authors of Abdulla et al. (2014) and Aronis et al. (2018), and it is indeed used in the experimental evaluation of Aronis et al. (2018). It therefore includes implementations of the ODPOR and ODPOR <sup>_ob_</sup> algorithms. Our experimental evaluation has hence required the implementation and integration within the Nidhugg framework of the DPOR _cs_, ODPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>,</sup> <sup>as</sup> <sup>well</sup> <sup>as</sup> <sup>the</sup> <sup>implementation</sup> <sup>of</sup> <sup>the</sup> support to handle atomic blocks. We also use the SYCO tool (Albert et al., 2016), a systematic testing tool for message-passing concurrent programs written in the ABS modeling language (Johnsen et al., 2012), for the two largest benchmarks of Albert et al. (2019) which were unsuitable to be translated into C/C++. _5.1._ _Goals_ _of_ _the_ _experimental_ _evaluation_ The goals of our experimental evaluation are the following: G1 Study the overall effectiveness in terms of scalability of ODPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>w.r.t</sup> <sup>ODPOR,</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>and</sup> <sup>ODPOR</sup> <sup>_ob_</sup> <sup>.</sup> We expect cases where ODPOR <sup>_ob_</sup> _cs_ <sup>produces</sup> <sup>exponential</sup> <sup>re-</sup> ductions over ODPOR <sup>_ob_</sup> and behaves similarly to DPOR _cs_ and ODPOR _cs_ (G1a), cases where it produces exponential reductions over DPOR _cs_ and ODPOR _cs_, and behaves similarly to ODPOR <sup>_ob_</sup> (G1b), and, cases where it produces exponential reductions over all DPOR _cs_, ODPOR _cs_ and ODPOR <sup>_ob_</sup> (G1c). We also expect cases where ODPOR <sup>_ob_</sup> _cs_ <sup>may</sup> <sup>behave</sup> <sup>worse</sup> <sup>than</sup> either DPOR _cs_ or ODPOR <sup>_ob_</sup> due to the overhead of either the observers or the context-sensitive part whenever it is not effective (G1d). Overall, we expect that ODPOR <sup>_ob_</sup> _cs_ <sup>will</sup> <sup>often</sup> outperform or, at least, scale similarly than the best of the other algorithms. As regards ODPOR _cs_, we expect it to perform essentially equivalent to DPOR _cs_ for most benchmarks (G1e). An explanation for this is found below in Section 5.3. 11 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Table 1 <u>Experimental</u> <u>evaluation</u> <u>results.</u> <u>First</u> <u>set</u> <u>of</u> <u>benchmarks.</u> Benchmark LE/LT ODPOR ODPOR <sup>_ob_</sup> DPOR _cs_ ODPOR <sup>_ob_</sup> _<u>cs</u>_ Speed-up E T E T E T E T G <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> G <sup>_cs_</sup> _<u>cs</u>_ <sup>−</sup> <sup>_ob_</sup> _<u>ob</u>_ _<u>cs</u>_ pipesort (N = 3) 13/442 6 0.01 s 4 0.02 s 2 0.01 s 2 0.01 s 1.0 1.0 pipesort (N = 7) 57/1746 - - 64 0.30 s 329 4.73 s 13 0.23 s 1.3 20.57 pipesort (N = 9) 91/2719 - - 256 1.94 s - - 34 1.06 s 1.83 _>_ 141.51 pipesort (N = 11) 133/3906 - - 1 024 13.00 s - - 89 4.63 s 2.81 pi (N = 5) 11/251 120 0.09 s 120 0.09 s 16 0.05 s 16 0.05 s 1.8 1.0 pi (N = 6) 13/297 720 0.56 s 720 0.60 s 61 0.17 s 61 0.19 s 3.16 0.89 pi (N = 7) 15/343 5 040 5.28 s 5 040 5.63 s 272 0.83 s 272 0.94 s 5.99 0.88 pi (N = 8) 17/389 40 320 121.74 s 40 320 123.36 s 1 385 5.30 s 1 385 6.04 s 20.42 0.88 quicksort (N = 2) 23/3491 32 0.29 s 32 0.33 s 1 0.24 s 2 0.15 s 2.2 1.6 quicksort (N = 3) 27/4230 64 0.70 s 64 0.95 s 1 0.38 s 6 0.41 s 2.32 0.93 quicksort (N = 4) 31/4947 128 2.32 s 128 2.01 s 1 0.53 s 1 0.42 s 4.79 1.26 quicksort (N = 5) 35/5864 256 4.86 s 256 5.46 s 1 2.06 s 34 2.92 s 1.87 0.71 mergesort (N = 4) 15/4722 8 0.15 s 8 0.15 s 1 0.07 s 1 0.07 s 2.14 1.0 mergesort (N = 5) 19/7745 16 0.53 s 16 0.56 s 1 0.19 s 2 0.20 s 2.8 0.95 mergesort (N = 6) 31/13 993 128 9.77 s 128 10.21 s 1 1.40 s 1 1.21 s 8.44 1.16 mergesort (N = 7) 31/18 131 - - - - 1 1.76 s 1 1.77 s _>_ 84.75 0.99 fib (N = 2) 7/155 2 0.01 s 2 0.01 s 1 0.01 s 1 0.01 s 1.0 1.0 fib (N = 3) 11/276 4 0.01 s 4 0.01 s 1 0.01 s 1 0.01 s 1.0 1.0 fib (N = 4) 19/511 16 0.03 s 16 0.03 s 1 0.03 s 2 0.02 s 1.5 1.5 fib (N = 5) 35/868 128 0.27 s 128 0.28 s 1 0.19 s 16 0.22 s 1.27 0.86 boundedbuffer (N = 7) 15/401 3 432 3.09 s 3 432 3.24 s 550 1.16 s 550 1.26 s 2.57 0.92 boundedbuffer (N = 8) 17/458 12 870 14.28 s 12 870 14.88 s 1 487 3.69 s 1 487 4.05 s 3.67 0.91 boundedbuffer (N = 9) 19/515 - - - - 4 036 11.67 s 4 036 13.81 s _>_ 10.86 0.85 boundedbuffer (N = 10) 21/572 - - - - 10 981 38.23 s 10 981 42.84 s - 0.89 G2 Observe the potential overheads that both the context sensitive part (G2a) and the observers part (G2b) of the algorithm may produce. G3 Study the effectiveness of the context-sensitive check re finements of Sections 3.4 and 4.3. _5.2._ _Description_ _of_ _the_ _experiments_ We have used three sets of benchmarks: The first one is a subset of the classical concurrent programs used in Albert et al. (2017) to compare Source-DPOR and DPOR _cs_ . They feature typical distributed and concurrent algorithmic patterns, in which computations are split into smaller atomic subcomputations that concurrently interleave their executions, and work on shared data. Our set includes three concurrent sorting algorithms (pipesort, mergesort and quicksort), a distributed workers algorithm (pi), a concurrent fibonacci algorithm (fib), and a producer–consumer algorithm (boundedbuffer). Our second set of benchmarks contains the synthetic programs used in Aronis et al. (2018) to compare ODPOR and ODPOR <sup>_ob_</sup> and some variations of them. Benchmarks lastwrite, floatingread and lastzero correspond to benchmarks of the same name in Aronis et al. (2018), and abs corresponds to the running example of Aronis et al. (2018)’s Fig. 1 generalized for _n_ processes. Benchmarks ending with -2phases and -dif are variations of the above for the corresponding prefix. Specifically, the -2phases variations perform 2 repetitions of the code pattern in each process so that potential exploration reductions can be better observed. The -dif variations write different values to all shared variables, hence context-sensitive checks cannot take advantage of contextsensitive dependencies. That allows us to reason about the worstcase scenario for the context-sensitive part of the algorithms. We also include in this second set arraywrite, a synthetic benchmark to illustrate the potential impact of the refined check of Section 3.4, which consists of 4 ∗ _N_ processes writing an _N_ -array and two processes reading the first two positions. Each benchmark is executed for a series of increasing input parameters in order to observe the impact of the reductions and computed by dividing their respective times by that of ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> A timeout of 150 s is set. When reached, we write —, except for the speedups of the first input for which the timeout is reached, in such case we write _>X_ to indicate that the speedup would be _X_ if the process finishes right in the timeout, and hence it is guaranteed to be greater than _X_ . Finally, our third set of benchmarks (Table 3) are run within the SYCO tool and include two larger programs implemented in the ABS modeling language using active objects and messagepassing: MapRed, an implementation of a map-reduce model developed by a company (440 lines of code); and SDN (Albert et al., 2018b), a model of a software-defined network featuring a safety policy violation (490 lines). _5.3._ _Analysis_ _of_ _the_ _results_ We have confirmed that ODPOR _cs_ performs basically equivalent to DPOR _cs_ (goal G1e). The number of finished execution sequences is exactly the same for all benchmarks. The execution time is also basically the same with a very slight overhead (of at overheads on bigger explorations. Tables 1 and 2 show the results of the executions of ODPOR, ODPOR <sup>_ob_</sup>, DPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>for</sup> the first and second set of benchmarks respectively. The results for ODPOR _cs_ are not shown in the tables since they are basically the same as those of DPOR _cs_ . Column _LE/LT_ shows the length of the longest execution sequence in terms of execution steps ( _LE_ ) and the length of the longest trace in terms of LLVM instructions ( _LT_ ). Note that such a longest execution sequence and corresponding trace is the same on every algorithm. This gives an idea on the complexity and depth of the exploration which is carried out. Also, the difference between the _LE_ and _LT_ values on a given exploration provides an indication on the length of the atomic blocks of the benchmark (the bigger the difference the longer the atomic blocks). Columns labeled with _E_ show the number of finished execution sequences whereas those with _T_ show the time in seconds of the whole exploration. Times are obtained on an Intel(R) Core(TM) i7 CPU at 2.5 GHz with 8 GB of RAM (Linux Kernel 5.4.0). Columns _G_ <sup>_cs_</sup> _cs_ <sup>−</sup> <sup>_ob_</sup> and _G_ <sup>_cs_</sup> _ob_ <sup>−</sup> <sup>_ob_</sup> show the time speedup of ODPOR <sup>_ob_</sup> _cs_ <sup>over DPOR</sup> <sup>_cs_</sup> <sup>and ODPOR</sup> <sup>_ob_</sup> <sup>, respectively,</sup> computed by dividing their respective times by that of ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> <sup>_cs_</sup> _cs_ <sup>−</sup> <sup>_ob_</sup> and _G_ <sup>_cs_</sup> _ob_ <sup>−</sup> <sup>_ob_</sup> <sup>_cs_</sup> _ob_ <sup>−</sup> <sup>_ob_</sup> show the time speedup of ODPOR <sup>_ob_</sup> _cs_ 12 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Table 2 <u>Experimental</u> <u>evaluation</u> <u>results.</u> <u>Second</u> <u>set</u> <u>of</u> <u>benchmarks.</u> Benchmark LE/LT ODPOR ODPOR <sup>_ob_</sup> DPOR _cs_ ODPOR <sup>_ob_</sup> _<u>cs</u>_ Speed-up E T E T E T E T G <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> G <sup>_cs_</sup> _<u>cs</u>_ <sup>−</sup> <sup>_ob_</sup> _<u>ob</u>_ _<u>cs</u>_ lastwrite (N = 4) 82/175 24 0.01 s 4 0.01 s 5 0.01 s 1 0.01 s 1.0 1.0 lastwrite (N = 8) 150/319 40 320 15.93 s 8 0.01 s 1 385 3.54 s 1 0.03 s 0.33 118.0 lastwrite (N = 12) 218/463 - - 12 0.02 s - - 1 0.08 s 0.25 _>_ 1875.00 lastwrite (N = 16) 286/607 - - 16 0.05 s - - 1 0.18 s 0.28 lastwrite-dif (N = 4) 86/187 24 0.01 s 4 0.01 s 24 0.02 s 4 0.01 s 1.0 2.0 lastwrite-dif (N = 8) 158/343 40 320 16.16 s 8 0.01 s 40 320 105.98 s 8 0.03 s 0.33 3532.67 lastwrite-dif (N = 12) 230/499 - - 12 0.02 s - - 12 0.06 s 0.33 _>_ 2500.00 lastwrite-dif (N = 16) 302/655 - - 16 0.05 s - - 16 0.13 s 0.38 lastwrite-2phases (N = 4) 233/495 13 824 8.32 s 64 0.06 s 125 0.51 s 1 0.03 s 2.0 17.0 lastwrite-2phases (N = 6) 335/711 - - 216 0.31 s - - 1 0.07 s 4.43 _>_ 2142.86 lastwrite-2phases (N = 8) 437/927 - - 512 1.10 s - - 1 0.14 s 7.86 lastwrite-2phases (N = 10) 539/1143 - - 1 000 3.22 s - - 1 0.26 s 12.38 floatingread (N = 4) 97/196 120 0.06 s 33 0.02 s 16 0.04 s 1 0.07 s 0.29 0.57 floatingread (N = 5) 116/233 720 0.36 s 81 0.06 s 61 0.18 s 1 0.26 s 0.23 0.69 floatingread (N = 6) 135/270 5 040 3.28 s 193 0.18 s 272 0.90 s 1 1.33 s 0.14 0.68 floatingread (N = 7) 154/307 40 320 29.19 s 449 0.38 s 1 385 6.10 s 1 6.86 s 0.06 0.89 floatingread-dif (N = 4) 97/196 120 0.05 s 33 0.02 s 120 0.11 s 33 0.06 s 0.33 1.83 floatingread-dif (N = 5) 116/233 720 0.29 s 81 0.05 s 720 0.66 s 81 0.17 s 0.29 3.88 floatingread-dif (N = 6) 135/270 5 040 2.30 s 193 0.12 s 5 040 6.09 s 193 0.92 s 0.13 6.62 floatingread-dif (N = 7) 154/307 40 320 21.36 s 449 0.30 s - - 449 4.88 s 0.06 _>_ 30.74 floatingread-2phases (N = 3) 152/310 576 0.30 s 169 0.11 s 25 0.10 s 1 0.05 s 2.2 2.0 floatingread-2phases (N = 4) 190/384 14 400 9.35 s 1 089 0.82 s 256 0.97 s 1 0.15 s 5.47 6.47 floatingread-2phases (N = 5) 228/458 - - 6 561 6.12 s 3 721 19.56 s 1 0.61 s 10.03 32.07 floatingread-2phases (N = 6) 266/532 - - 37 249 42.60 s - - 1 2.76 s 15.43 _>_ 54.35 abs (N = 3) 13/198 36 0.03 s 9 0.02 s 4 0.02 s 1 0.02 s 1.0 1.0 abs (N = 4) 17/254 576 0.45 s 16 0.03 s 25 0.10 s 1 0.05 s 0.6 2.0 abs (N = 5) 21/310 14 400 19.20 s 25 0.04 s 256 1.05 s 1 0.12 s 0.33 8.75 abs (N = 6) 25/366 - - 36 0.09 s - - 1 0.29 s 0.31 _>_ 517.24 abs-dif (N = 3) 13/198 36 0.03 s 9 0.01 s 36 0.04 s 9 0.02 s 0.5 2.0 abs-dif (N = 4) 17/254 576 0.46 s 16 0.02 s 576 0.65 s 16 0.04 s 0.5 16.25 abs-dif (N = 5) 21/310 14 400 19.30 s 25 0.05 s 14 400 25.26 s 25 0.08 s 0.63 315.75 abs-dif (N = 6) 25/366 - - 36 0.09 s - - 36 0.15 s 0.6 _>_ 1000.00 abs-2phases (N = 2) 17/276 16 0.02 s 16 0.02 s 1 0.01 s 1 0.02 s 1.0 0.5 abs-2phases (N = 3) 25/388 1 296 1.41 s 81 0.14 s 16 0.11 s 1 0.05 s 2.8 2.2 abs-2phases (N = 4) 33/500 - - 256 0.66 s - - 1 0.14 s 4.71 _>_ 1071.42 abs-2phases (N = 5) 41/612 - - 625 2.44 s - - 1 0.34 s 7.18 arraywrite (N = 5) 89/1659 16 0.07 s 16 0.07 s 1 0.03 s 1 0.03 s 2.33 1.0 arraywrite (N = 10) 421/7969 1 024 25.09 s 1 024 25.99 s 1 0.31 s 1 0.32 s 81.21 0.97 arraywrite (N = 15) 869/16 539 - - - - 1 1.30 s 1 1.45 s _>_ 103.45 0.90 arraywrite (N = 20) 1641/31 319 - - - - 1 5.91 s 1 6.80 s - 0.87 Table 3 <u>Experimental</u> <u>evaluation</u> <u>results.</u> <u>Third</u> <u>set</u> <u>of</u> <u>benchmarks.</u> Bench. DPOR _cs_ ODPOR <sup>_ob_</sup> ODPOR <sup>_ob_</sup> _<u>cs</u>_ Speed-up feature exponential reductions over ODPOR and that ODPOR <sup>_ob_</sup> _cs_ E T E T E T G <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> <sup>_cs_</sup> _<u>ob</u>_ <sup>−</sup> <sup>_ob_</sup> G <sup>_cs_</sup> _<u>cs</u>_ <sup>−</sup> <sup>_ob_</sup> _<u>ob</u>_ _<u>cs</u>_ MapRed 9 114 118 2961 9 185 0.6x 16.0x SDN 22 83 58 229 16 52 1.6x 4.4x most 4%) due to the handling of the wakeup trees. An exception for this is the lastzero benchmark where ODPOR _cs_ outperforms DPOR _cs_ (e.g., for _N_ = 6, ODPOR _cs_ takes 0 _._ 24 s vs. the 0.34 of DPOR _cs_ ). It is already shown in Abdulla et al. (2014) that even though optimality provides a very relevant and strong theoretical result, it is difficult to find examples where ODPOR produces significant improvements in practice over Source-DPOR. The lastzero benchmark is indeed the only case where this happens in Abdulla et al. (2014). Note also that the primary goal of the development of ODPOR _cs_ is to serve as an intermediate and necessary step towards the development of our finally proposed algorithm which is ODPOR <sup>_ob_</sup> _cs_ <sup>.</sup> Looking at the results on our first set of benchmarks (see Table 1) we clearly observe that ODPOR <sup>_ob_</sup> _cs_ <sup>always</sup> <sup>outperforms</sup> <sup>or</sup> behaves similarly to the best of the other algorithms (goal G1). For instance, in pipesort we observe that ODPOR <sup>_ob_</sup> and DPOR _cs_ both feature exponential reductions over ODPOR and that ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> able to produce exponential reductions over both of them (goal G1c). This is due to the benefits of combining the orthogonal reductions of ODPOR <sup>_ob_</sup> and DPOR _cs_ and, also to the synergy of the combination (namely the refinement of Section 4.3) (goal G3). In quicksort, mergesort, fib and boundedbuffer we can observe that ODPOR <sup>_ob_</sup> performs almost identically to ODPOR since there are no observers to take advantage of. We also observe exponential reductions of both DPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>over</sup> <sup>both</sup> <sup>ODPOR</sup> <sup>and</sup> ODPOR <sup>_ob_</sup> due to context-sensitive dependencies (goal G1a). We can hence observe the overhead of the observers part of the algorithms in isolation (goal G2b) which is very low (see e.g. the times of ODPOR <sup>_ob_</sup> _cs_ <sup>versus</sup> <sup>those</sup> <sup>of</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>).</sup> In pi we have a different situation. We observe exponential reductions of both ODPOR <sup>_ob_</sup> and DPOR _cs_ w.r.t ODPOR indicating there are both observers-based independences and also context-sensitive independences. In this case, the combination of the reductions due to both kind of independences produced by ODPOR <sup>_ob_</sup> _cs_ <sup>features</sup> <sup>exponential</sup> <sup>reductions</sup> <sup>over</sup> <sup>ODPOR</sup> <sup>_ob_</sup> <sup>but,</sup> <sup>in-</sup> ODPOR <sup>_ob_</sup> _cs_ <sup>features</sup> <sup>exponential</sup> <sup>reductions</sup> <sup>over</sup> <sup>ODPOR</sup> <sup>_ob_</sup> <sup>but,</sup> <sup>in-</sup> terestingly, not over DPOR _cs_, which behaves similarly to ODPOR <sup>_ob_</sup> _cs_ (goal G1). This indicates that the prunings performed by ODPOR <sup>_ob_</sup> are in this case a subset of those produced by DPOR _cs_, hence joining them does not produce an improvement over the best of both algorithms (here DPOR _cs_ ). 13 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ In the second set of benchmarks (see Table 2) we can observe exponential reductions in the number of finished executions in ODPOR <sup>_ob_</sup> _cs_ <sup>w.r.t</sup> <sup>all</sup> <sup>ODPOR,</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>and</sup> <sup>ODPOR</sup> <sup>_ob_</sup> <sup>.</sup> <sup>Note</sup> that ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>able</sup> <sup>to</sup> <sup>catch</sup> <sup>all</sup> <sup>redundant</sup> <sup>executions</sup> <sup>hence</sup> obtaining only 1 finished execution. Again, that is possible both due to the combination of ODPOR <sup>_ob_</sup> and DPOR _cs_ and, also to the new refined check of Section 4.3 (goal G3). However, such a reduction over ODPOR <sup>_ob_</sup> does not have a direct correlation to a corresponding reduction in time in neither lastwrite nor floatingread nor abs. This indicates that the overhead of the context-sensitive part of the algorithm does not pay-off in these cases, mainly because the reductions are being done at the very end of the executions and hence few states are being pruned (goal G1d). This can indeed be observed looking at the results we get in the -dif variations of the benchmarks where the variable writes are all done with different values, hence making all contextsensitive checks to fail. We observe that in these cases ODPOR <sup>_ob_</sup> _cs_ performs similar, and even better, as it does with the original benchmarks in terms of exploration time, clearly indicating that the prunings being made are not saving exploration effort. This is because of the overhead due to the handling and inheritance of the don’t-do sets, which in the case of the -dif variations is not produced since there are no don’t-do sets to be handled (goal G2a). Although it is not shown in the tables (in order not to overload them with more data) we are also measuring the number of executions which are cut due to don’t-do sets (don’t-do set blocked executions, DDSBs). Note that the number of DDSBs with ODPOR <sup>_ob_</sup> _cs_ <sup>would</sup> <sup>be</sup> <sup>always</sup> <sup>bounded</sup> <sup>(above)</sup> <sup>by</sup> <sup>the</sup> <sup>difference</sup> between the number finished execution sequences of ODPOR <sup>_ob_</sup> For MapRed, both ODPOR <sup>_ob_</sup> _cs_ For MapRed, both ODPOR <sup>_ob_</sup> _cs_ <sup>and</sup> <sup>DPOR</sup> <sup>_cs_</sup> <sup>explore</sup> <sup>9</sup> <sup>executions</sup> <sup>in</sup> 185 ms. and 114 ms. respectively, while ODPOR <sup>_ob_</sup> explores 118 executions and takes almost 3 s, since there is no gain in using observers in this case. For SDN, ODPOR <sup>_ob_</sup> _cs_ <sup>explores</sup> <sup>16</sup> <sup>executions</sup> in 52 ms., whereas DPOR _cs_ explores 22 executions in 83 ms. and ODPOR <sup>_ob_</sup> 58 in 229 ms. Finally, in order to illustrate the potential impact of the refined check of Section 3.4 in isolation, the following table shows the exploration times of ODPOR <sup>_ob_</sup> _cs_ <sup>with and without the refined check</sup> (columns labeled respectively With 3.4 and Without 3.4) on the arraywrite benchmark for a series of increasing inputs (column N ), and the corresponding speedups. Finally, in order to illustrate the potential impact of the refined check of Section 3.4 in isolation, the following table shows the exploration times of ODPOR <sup>_ob_</sup> _cs_ <sup>with and without the refined check</sup> and ODPOR <sup>_ob_</sup> _cs_ <sup>(and</sup> <sup>the</sup> <sup>same</sup> <sup>with</sup> <sup>ODPOR</sup> <sup>_cs_</sup> <sup>and</sup> <sup>ODPOR,</sup> <sup>respec-</sup> tively). But it could be much less than that because by blocking a partial execution, we can be avoiding the exploration of several redundant complete executions that will be explored by ODPOR <sup>_ob_</sup> (or ODPOR). Indeed, the number of DDSBs would be a direct indication of the effectiveness of the context-sensitive checks. The more close to the above upper bound the less effective are the checks since that would mean that the total number of explored executions (including the DDSBs) would be close to the total number of executions explored by ODPOR <sup>_ob_</sup> . E.g., in the case of pi for _N_ = 7, the number of DDSBs is 750 which means that ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>exploring</sup> <sup>a</sup> <sup>total</sup> <sup>of</sup> <sup>1022</sup> <sup>executions</sup> <sup>(including</sup> <sup>the</sup> DDSBs) whereas ODPOR <sup>_ob_</sup> is exploring 5040. However, in the case of lastwrite we get 3 _,_ 7 _,_ 11 and 15 as the numbers of DDSBs for the four runs respectively, which means that ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>exploring</sup> the same number of executions as ODPOR <sup>_ob_</sup> although most of them are cut at the end (since they are redundant). The results on the rest of the benchmarks confirm this claim: in the cases where _G_ <sup>_cs_</sup> _ob_ <sup>−</sup> <sup>_ob_</sup> ≤ 1, the total number of explored executions of ODPOR <sup>_ob_</sup> _cs_ <sup>(including</sup> <sup>DDSBs)</sup> <sup>is</sup> <sup>close</sup> <sup>(or</sup> <sup>even</sup> <sup>equal,</sup> <sup>as</sup> <sup>in</sup> <sup>the</sup> case of lastwrite) to the number of explorations performed by ODPOR <sup>_ob_</sup>, whereas in the cases where _G_ <sup>_cs_</sup> _ob_ <sup>−</sup> <sup>_ob_</sup> grows, such number is much lower. The fact that ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>able</sup> <sup>to</sup> <sup>catch</sup> <sup>many</sup> <sup>more</sup> <sup>redundant</sup> <u>N</u> <u>With</u> <u>3.4</u> <u>Without</u> <u>3.4</u> <u>Speed-up</u> 5 0.03 s 0.03 s 1.00 10 0.32 s 0.41 s 1.29 15 1.45 s 2.13 s 1.51 20 6.80 s 9.63 s 1.42 25 18.15 s 25.13 s 1.39 30 53.77 s 76.26 1.42 In conclusion, our experimental results show that our algorithm ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>able</sup> <sup>to</sup> <sup>effectively</sup> <sup>combine</sup> <sup>the</sup> <sup>benefits</sup> <sup>of</sup> both DPOR _cs_ and ODPOR <sup>_ob_</sup> . On the other hand, we can observe that it also inherits their associated overheads. Whereas in the case of ODPOR <sup>_ob_</sup> the overhead is very low, our results show notable overheads in DPOR _cs_ and hence ODPOR <sup>_ob_</sup> _cs_ <sup>,</sup> <sup>which</sup> <sup>in</sup> <sup>some</sup> cases do not pay-off even though they do not seem to affect the overall scalability. In this sense, we believe that the integration of the optimizations proposed in Albert et al. (2017) could help. Specifically, we have measured that nearly half of the exploration time in both DPOR _cs_ and ODPOR <sup>_ob_</sup> _cs_ <sup>is</sup> <sup>spent</sup> <sup>in</sup> <sup>the</sup> <sup>computation</sup> of the alternative execution sequences for the context-sensitive checks (that are later recomputed during the normal exploration), which we believe could be avoided (at least in part) by integrating the support to avoid recomputations described in Albert et al. (2017). Finally, let us conclude this section by noting that DPOR _cs_, ODPOR _cs_, and, consequently, ODPOR <sup>_ob_</sup> _cs_ <sup>are likely to be highly ben-</sup> eficial for programs with large atomic code sections (e.g., monitors, concurrent objects, and message-passing systems), where the usual approximation of dependency based on variable accesses, even if it is computed dynamically, can be rather imprecise. They are also likely to be beneficial for programs with assertions, as these only result in two possibly (local) states: either the assertion holds or it does not. Hence, the contextsensitive independence check is more likely to succeed. 6. Conclusions and related work DPOR is one of the most scalable techniques used in the verification of concurrent systems. Recent work has introduced orthogonal notions of conditional independence into DPOR: DPOR _cs_ (Albert et al., 2017) proposes a context-sensitive check in the current state to detect more accurately independence among processes, ODPOR <sup>_ob_</sup> (Aronis et al., 2018) proposes a finer notion of independence which is conditional to the existence of observers that read the values written by the processes. We propose a seamless integration of DPOR _cs_ and ODPOR <sup>_ob_</sup>, via two major technical extensions to DPOR _cs_ : (1) incorporating (and using effectively) the notion of _wakeup_ _tree_ used by ODPOR <sup>_ob_</sup>, and (2) refining the context-sensitive check (and the sequences computed with it) to take observers into account. As shown in our experimental evaluation, the resulting algorithm achieves prunings that go beyond the combination of the individual algorithms. Other recent approaches have considered alternative ways of refining the detection of independence. Data-Centric DPOR executions than ODPOR <sup>_ob_</sup>, as we have seen, does not necessarily indicate a reduction on the overall exploration time (due to the associated overheads). However, this indicates the potential of ODPOR <sup>_ob_</sup> _cs_ <sup>to</sup> <sup>produce</sup> <sup>exponential</sup> <sup>reductions.</sup> <sup>That</sup> <sup>will</sup> <sup>happen</sup> <sup>as</sup> soon as the pattern where the reduction takes place is followed by non-trivial explorations, in such case such upcoming explorations will be effectively pruned. This can be observed looking at the results obtained in the -2phases variations of the benchmarks where we can see such exponential reductions of ODPOR <sup>_ob_</sup> _cs_ <sup>w.r.t</sup> both ODPOR <sup>_ob_</sup> and DPOR _cs_ (goal G1). The results from the third set of benchmarks give evidence of the potential of our algorithm when applied over larger programs. 14 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ (Chalupa et al., 2018) was the first work to focus on the _reads-from_ relation. It defines two traces to be observationally equivalent if every read event observes the same write event in both traces. In contrast, we use the notion of observability introduced by Aronis et al. (2018), which is based on observing interference of operations, not just individual writes. The equivalence relation used by Data-Centric is proven in Chalupa et al. (2018) to see more traces as equivalent than the one based on Mazurkiewicz traces, which is the one used in our work and in all other variants of the DPOR algorithm of Flanagan and Godefroid (2005). Note that this is more unlikely to happen in programs with bigger atomic blocks like our first and third set of benchmarks (where we have indeed seen that the reads-from relation would not be exploited). A drawback of Data-Centric DPOR is that it is not always optimal. Recently, there have been other works proposing optimal DPOR algorithms based on the reads-from relation, either for sequential consistency (Abdulla et al., 2019), for the release-acquire semantics (Abdulla et al., 2018) or for the C/C++ concurrency. Also, (Kokologiannakis et al., 2019b) proposes an optimal algorithm for the reads-from relation which is parametric in the choice of the memory model under a set of basic assumptions. This has been recently further extended to handle locks efficiently (Kokologiannakis et al., 2019a) and, for the first time, to ensure linear memory consumption per equivalence class while at the same time allowing parallelization (Kokologiannakis et al., 2022). It remains to be studied whether our context-sensitive dependency can be successfully integrated within these approaches based on the reads-from relation since their underlying algorithms are fundamentally different as the classical DPOR algorithm and its variants (including Aronis et al., 2018). Another approach is to generate _independence constraints_ (ICs), which ensure the independence of each pair of processes in the program. The work in Wang et al. (2008), Kahlon et al. (2009) generated for the first time ICs for processes with a single instruction following some predefined patterns. Constrained DPOR (Albert et al., 2018a) proposed to generate ICs in a pre-phase, using a SMT solver. The generated ICs are then used within DPOR in a similar way to our context-sensitive checks. In addition, it can perform another type of pruning using the notion of _transi-_ _tive_ _uniform_ conditional independence - which ensures the ICs hold along the whole execution trace (and ensures uniformity as defined in Katz and Peled (1992) and Godefroid and Pirottin (1993)). The extension of Constrained DPOR with observers, to the best of our knowledge, has not been studied yet. We believe the integration of wakeup trees could be done similarly to our proposal in Section 3.1, and the enhancements in Section 4 would be applicable also in the Constrained DPOR framework. Still, the combination of transitive uniformity and observability remains to be investigated. An orthogonal approach to increase scalability, introduced in Quasi-Optimal POR (Nguyen et al., 2018), is to approximate the optimal exploration using a provided constant _k_ . In essence, by using approximation, alternatives are computed in polynomial time, rather than making an NP-complete exploration, as in ODPOR. Another orthogonal improvement is to inspect dependencies over event chains (Rodríguez C. Sousa et al., 2015). This work has been recently extended to the context of symbolic execution (Schemmel et al., 2020), where cut-off events are used to detect program states already visited in order to handle non-terminating executions. Finally, there is a large body of related work in the context of dynamic runtime verification that include similar ideas for race and deadlock detection (Pavlogiannis, 2020; Cai et al., 2021; Park et al., 2020). For instance, Pavlogiannis (2020) proposes a complete and sound algorithm that predicts all data races of a given trace but without considering observability, whereas (Cai et al., 2021) improves it by taking into account observability. CRediT authorship contribution statement Elvira Albert: Conceptualization, Methodology, Writing – original draft, Investigation. Maria Garcia de la Banda: Conceptualization, Methodology, Writing - original draft, Investigation. Miguel Gómez-Zamalloa: Conceptualization, Methodology, Writing - original draft, Investigation. Miguel Isabel: Conceptualization, Methodology, Writing - original draft, Investigation, Software. Peter Stuckey: Conceptualization, Methodology, Writing - original draft, Investigation. Declaration of competing interest The authors declare the following financial interests/personal relationships which may be considered as potential competing interests: Miguel Isabel reports financial support was provided by Government of Spain Ministry of Education and Vocational Training (FPU15/04313). Elvira Albert reports financial support was provided by Government of Spain Ministry of Education and Vocational Training (RTI2018-094403-B-C31 and RTI2018-094403B- C33). Elvira Albert reports financial support was provided by Comunidad de Madrid Direccion General de Universidades e Investigacion (S2018/TCS-4314). Maria Garcia de la Banda y Peter Stuckey reports financial support was provided by the Australian ARC project DP180100151. Data availability No data was used for the research described in the article. Acknowledgments This work was funded partially by the Spanish MICINN/FEDER, UE projects PID2021-122830OB-C41, the CM project S2018/TCS4314 and the Australian ARC project DP180100151. Appendix A. Proofs of correctness and optimality of ODPOR _cs_ Let us claim some auxiliary lemmas and definitions before proving the main theorems of soundness and optimality. First, we claim a lemma needed to prove the correctness of the new context-sensitive check. Let the sequence _E_ <sup>′</sup> = _E_ 0 _.e_ ˆ _.w.e_ <sup>ˆ′</sup> _.w_ <sup>′</sup> is explored by Algorithm 1 and the race _e_ ≾ _E_ ′ _e_ <sup>′</sup> . According to the algorithm’s definitions: _E_ 0 = _pre_ ( _E_ <sup>′</sup> _, e_ ) and _v_ = _notdep_ ( _e, e_ <sup>′</sup> _, E_ <sup>′</sup> ). Lemma 1. _If_ _the_ _following_ _check_ _of_ _Algorithm_ _1_ _succeeds_ _e,e_ <sup>′</sup> _E_ <sup>′</sup> <sup>_s_</sup> <sup>[</sup> <sup>_E_</sup> 0 <sup>_._</sup> <sup>(</sup> <sup>_v.e_</sup> <sup>ˆ)</sup> ≤ _e_ <sup>′</sup> _E_ <sup>′</sup> _V_ <sup>_e,e_</sup> <sup>′</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)] _=E_ <sup>′</sup> _s_ [ _E_ 0 _._ ( _v.e_ ˆ)≤ _e_ ′ ] <sup>_,_</sup> <sup>_then_</sup> _E_ <sup>′</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)] = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ _E_ <sup>′</sup> ] <sup>_._</sup> Proof. First, we know that _E_ <sup>′</sup> = _E_ 0 _.e_ ˆ _.w.e_ <sup>ˆ′</sup> _.w_ <sup>′</sup>, then _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, e_ <sup>′</sup> ) = _E_ 0 _.e_ ˆ _.w.e_ <sup>ˆ′</sup>, and sequence _e_ ˆ _.w_, can be divided in two sets _notdep_ ( _e, e_ <sup>′</sup> _, E_ <sup>′</sup> ) and _suc_ ( _e, E_ <sup>′</sup> ). Let us introduce a simple notation _suc_ <sup>−</sup> ( _e, E_ <sup>′</sup> ) to denote the sequence _suc_ ( _e, E_ <sup>′</sup> ) without the first process _e_ ˆ. Then, _E_ 0 _.e_ ˆ _.w.e_ <sup>ˆ′</sup> ≃ _E_ 0 _.e_ ˆ _.notdep_ ( _e, e_ <sup>′</sup> _, E_ <sup>′</sup> ) _.suc_ <sup>−</sup> ( _e, E_ <sup>′</sup> ) _.e_ <sup>ˆ′</sup> ≃ _E_ 0 _.notdep_ ( _e, e_ <sup>′</sup> _, E_ ) _.e_ ˆ _.e_ <sup>ˆ′</sup> _.suc_ ( _e, E_ <sup>′</sup> ) (taking into account that after _E_ 0 _.notdep_ ( _e, e_ <sup>′</sup> _, E_ ) _.e_ ˆ, we have _e_ <sup>ˆ′</sup> ⋄ _suc_ <sup>−</sup> ( _e, E_ <sup>′</sup> )). Because of the hypothesis, we know that _s_ [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _.e_ ˆ _.e_ ˆ′ _.suc_ −( _e,E_ ′)] = _s_ [ _pre_ +( _E_ ′ _,e_ ′)] _V_ <sup>_e,e_</sup> <sup>′</sup> = _E_ <sup>′</sup> _V_ _e,e_ <sup>′</sup> _E_ <sup>′</sup> ] <sup>=</sup> <sup>_s_</sup> [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _._ ˆ _e_ ′ _.e_ ˆ] <sup>.</sup> 15 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Let us suppose there exists a variable _y_ such that ̸ ] <sup>(</sup> <sup>_y_</sup> <sup>)</sup> <sup>_._</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)]( _y_ )̸ = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ _E_ <sup>′</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)]( _y_ )̸ = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ Then, _s_ [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _.e_ ˆ _._ ˆ _e_ ′ _.suc_ −( _e,E_ ′)]( _y_ )̸ = _s_ [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _.e_ ˆ′ _.suc_ ( _e,E_ ′)]( _y_ ). Two cases can be distinguished: - If _y_ ∈ _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> <sup>,</sup> <sup>then</sup> <sup>because</sup> <sup>of</sup> <sup>the</sup> <sup>hypothesis</sup> <sup>we</sup> <sup>know</sup> that the value of _y_ is not modified by _suc_ <sup>−</sup> ( _e, E_ <sup>′</sup> ) at state _s_ [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _.e_ ˆ _.e_ ˆ′]. But it is modified by _suc_ <sup>−</sup> ( _e, E_ <sup>′</sup> ) at state _s_ [ _E_ 0 _.notdep_ ( _e,e_ ′ _,E_ ) _._ ˆ _e_ ′ _.e_ ˆ], then the write instruction must depend on a value of another variable _x_ in a condition. This variable must be different in both states after the execution of _e_ ˆ _.e_ <sup>ˆ′</sup> (if it is possible, from the wakeup tree) that would not be blocked by the _don’t-do_ set in the extended algorithm, wherever possible. This is exactly the ODPOR algorithm of Abdulla et al. (2014) which is guaranteed to explore a complete execution sequence that implements each _T_ (Mazurkiewicz, 1986). Suppose that some Mazurkiewicz trace _T_ is omitted by ODPOR _cs_, _C_ is the complete execution sequence that implements _T_ ( _T_ =→ _C_ ) and is explored by the original ODPOR algorithm. This sequence must be cut by our algorithm. Thus, it must be of the form _C_ = _E_ <sup>′</sup> _.v_ <sup>′</sup> _.e_ ˆ _.y_, where our algorithm added _v.e_ ˆ to _dnd_ ( _E_ <sup>′</sup> ) after succeeding in the check and _e_ <sup>ˆ′</sup> _.e_ ˆ, respectively. However, this is not possible since _x_ must be modified by _e_ or _e_ <sup>′</sup> and then, _x_ ∈ _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> <sup>,</sup> <sup>and,</sup> _V_ <sup>_e,e_</sup> <sup>′</sup> = _C_ <sup>′′</sup> _s_ [ _E_ ′ _._ ( _v.e_ ˆ)≤ _e_ ′ ] _x_ must be modified by _e_ or _e_ <sup>′</sup> and then, _x_ ∈ _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> <sup>,</sup> <sup>and,</sup> thus, by the initial hypothesis, _x_ should have the same value, producing the same result in the condition of variable _y_ . We get a contradiction. - If _y_ ̸ ∈ _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> we get a similar contradiction. Since they write _s_ [ _pre_ +( _C_ ′′ _,e_ ′)] _C_ <sup>′′</sup> If _y_ ̸ ∈ _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> we get a similar contradiction. Since they write different values over variable _y_, and both executions share the same prefix _E_ 0 _.notdep_ ( _e, e_ <sup>′</sup> _, E_ ), there must be a variable in _VE_ <sup>_e,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> with a different value. Otherwise, the value of _y_ must be the same in both executions. Consequently, we have that for every program variable _y_ ] <sup>(</sup> <sup>_y_</sup> <sup>)</sup> <sup>_._</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)]( _y_ ) = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ _E_ <sup>′</sup> _s_ [ _pre_ +( _E_ ′ _,e_ ′)]( _y_ ) = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ The correctness of the ODPOR _cs_ algorithm follows from the correctness of ODPOR, and the fact that context-sensitive checks only remove equivalent Mazurkiewicz traces. Lemma 2. _If the following check of Algorithm 1 succeeds s_ [ _pre_ +( _E_ ′ _,e_ ′)] = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ ] <sup>_,_</sup> <sup>_then_</sup> <sup>_for_</sup> <sup>_any_</sup> <sup>_complete_</sup> <sup>_sequence_</sup> <sup>_E_</sup> <sup>_of_</sup> <sup>_the_</sup> <sup>_form_</sup> _E_ <sup>′</sup> _E_ = _E_ 0 _.v.e_ ˆ _.u_ <sup>′</sup> _.w_ <sup>′</sup> _that_ _contains_ _a_ _race_ _e_ <sup>′</sup> ≾ _E_ _e,_ _there_ _is_ _a_ _complete_ _sequence_ _E_ <sup>′′</sup> = _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, e_ <sup>′</sup> ) _.w_ _that_ _defines_ _a_ _different_ _Mazurkiewicz_ _trace_ _T_ <sup>′</sup> =→ _E_ ′ _and_ _leads_ _to_ _an_ _identical_ _final_ _state._ Proof. Let _E_ = _E_ 0 _.v.e_ ˆ _.u_ <sup>′</sup> _.w_ <sup>′</sup> be a complete execution sequence. Let us notice here that ] <sup>_,_</sup> <sup>_then_</sup> <sup>_for_</sup> <sup>_any_</sup> <sup>_complete_</sup> <sup>_sequence_</sup> <sup>_E_</sup> <sup>_of_</sup> <sup>_the_</sup> <sup>_form_</sup> _E_ <sup>′</sup> 1. _E_ 0 _.v_ ≃ _E_ 0 _.v_ ≤ _eE_ ′ <sup>′</sup> ≤ _eE_ ′ <sup>′</sup> <sup>_.v>e_</sup> _E_ <sup>′′</sup> <sup>_e_</sup> _E_ <sup>′′,</sup> 2. _E_ 0 _.v.e_ ˆ _.u_ <sup>′</sup> ≃ _E_ 0 _.v.suc_ ( _e, E_ <sup>′</sup> ) _<eE_ ′ <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.w_</sup> <sup>′′,</sup> <sup>where</sup> <sup>_w_</sup> <sup>′′</sup> <sup>are</sup> _eE_ ′ <sup>′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> possibly some events added that do not depend on any event in _dom_ [ _E_ 0 _.v_ ]( _suc_ ( _e, E_ <sup>′</sup> )) and 3. _E_ 0 _.v_ ≤ _eE_ ′ <sup>′</sup> <sup>|�</sup> <sup>_v>e_</sup> _E_ <sup>′′</sup> <sup>⋄</sup> <sup>_suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_<e_</sup> _E_ <sup>′′ .</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>⋄</sup> <sup>_suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_<e_</sup> _E_ <sup>′′</sup> _eE_ ′ <sup>′</sup> <sup>|�</sup> <sup>_v>e_</sup> _E_ <sup>′′</sup> <sup>_e_</sup> _E_ <sup>′′ .</sup> Now, _E_ ≃ <sup>1</sup> <sup>_,_</sup> <sup>2</sup> _E_ 0 _.v_ ≤ _eE_ ′ ≤ _eE_ ′ <sup>′</sup> <sup>_.v>e_</sup> _E_ <sup>′′</sup> ≃ <sup>3</sup> _E_ 0 _.v_ ≤ _eE_ ′ <sup>′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_<e_</sup> _E_ <sup>′′</sup> _eE_ ′ <sup>′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_<e_</sup> _E_ <sup>′′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.w_</sup> <sup>′′</sup> <sup>_.w_</sup> <sup>′</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> <sup>_.w_</sup> <sup>′′</sup> <sup>_.w_</sup> <sup>′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.w_</sup> <sup>′′</sup> <sup>_.w_</sup> <sup>′</sup> ≃ _E_ 0 _._ ( _v.suc_ ( _e, E_ <sup>′</sup> ))≤ _eE_ ′ <sup>′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.v>e_</sup> _E_ <sup>′′</sup> <sup>_._</sup> _eE_ ′ <sup>′</sup> <sup>_.v>e_</sup> _E_ <sup>′′</sup> <sup>_<e_</sup> _E_ <sup>′′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> Since _s_ [ _pre_ +( _E_ ′ _,e_ ′)] = _s_ [ _E_ 0 _._ ( _v.suc_ ( _e,E_ ′))≤ _e_ ′ ] <sup>,</sup> <sup>we</sup> <sup>have</sup> <sup>that</sup> <sup>_s_</sup> [ _E_ <sup>′′</sup> ] <sup>=</sup> <sup>_s_</sup> [ _E_ ] _E_ <sup>′</sup> _eE_ ′ <sup>′</sup> <sup>_.suc_</sup> <sup>(</sup> <sup>_e, E_</sup> <sup>′)</sup> <sup>_>e_</sup> _E_ <sup>′′</sup> where _E_ <sup>′′</sup> = _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, e_ <sup>′</sup> ) _.w_ and _w_ = _vE_ <sup>′</sup> _>eE_ ′ <sup>_e_</sup> _E_ <sup>′′</sup> <sup>_.w_</sup> <sup>′′</sup> <sup>_.w_</sup> <sup>′. Note</sup> exploring a sequence _C_ <sup>′′</sup>, and _v_ <sup>′</sup> _.e_ ˆ is _v.e_ ˆ possibly having added some events that do not depend on any event in _dom_ [ _E_ ′]( _v.e_ ˆ), as otherwise the _don’t-do_ entry would have been removed. Hence, there exists a complete execution sequence _E_ <sup>′</sup> _.v.e_ ˆ _.w.y_ with the same happens-before relation as _C_, obtained by moving after _v.e_ ˆ events that are independent of _v.e_ ˆ (those with processes in _w_ ). By Lemma 1, we can apply Lemma 2 and we get that there is a different trace _T_ <sup>′</sup> which leads to the same state as _C_ . Since ODPOR explores a complete execution sequence for each Mazurkiewicz trace, it must include a complete execution sequence _C_ <sup>′</sup> that implements _T_ <sup>′</sup> . Note that _C_ <sup>′</sup> has the same happens-before relation as _C_ <sup>′′</sup> = _pre_ <sup>+</sup> ( _C_ <sup>′′</sup> _, e_ <sup>′</sup> ) _.w.y_ . We now show that _C_ <sup>′</sup> must have been explored before _C_, i.e. it appears to the left of _C_ in the ODPOR exploration tree. Sequence _pre_ <sup>+</sup> ( _C_ <sup>′′</sup> _, e_ <sup>′</sup> ) clearly appears to the left of _C_ in the ODPOR tree, or it could not be used to add the _don’t-do_ entry that blocked _C_ . Let us suppose instead that _C_ <sup>′</sup> appears to the right of _C_ in the exploration tree. Let _E_ <sup>′′</sup> be the largest common prefix of _C_ and _C_ <sup>′</sup> . Now _C_ = _E_ <sup>′′</sup> _.q.w_ <sup>′</sup> for some _q_ . Since _C_ <sup>′</sup> appears to the right of _C_, then _q_ will be in the _don’t-do_ sets for (the remainder of) sequence _C_ <sup>′</sup> unless it is removed by some dependent event. Let _e_ <sup>′</sup> = _next_ [ _E_ ′′]( _q_ ), that is, the next event that _q_ executes after _E_ <sup>′′</sup> . Suppose that _E_ <sup>′′</sup> _.q_ ≤ _E_ <sup>′</sup>, then the first change is above _E_ <sup>′</sup> . The happens-before relation for _C_ <sup>′</sup> must then have some event _e_ <sup>′′</sup> (after _E_ <sup>′′</sup> _.q_ ) such that _e_ <sup>′′</sup> → _C_ ′ _e_ <sup>′</sup>, but this cannot be the case since → _C_ ′ =→ _pre_ +( _C_ ′′ _,e_ ′) _.w.y_ where this does not occur. Suppose that _E_ <sup>′</sup> ≤ _E_ <sup>′′</sup> and, thus, the first change is at, or after, the point where _pre_ <sup>+</sup> ( _C_ <sup>′′</sup> _, e_ <sup>′′</sup> ) and _E_ <sup>′</sup> _.v.e_ ˆ differ. Clearly _C_ <sup>′</sup> must appear to the right of _E_ <sup>′</sup> _._ <sup>ˆ</sup> ( _e_ ) in the tree (otherwise it would be to the left of _C_ ). Hence, ˆ _e_ is in the _don’t-do_ set (for the remainder) of _C_ <sup>′</sup> after _E_ <sup>′</sup> until removed by dependent events. Suppose event _e_ <sup>′′</sup> removes _e_ ˆ. Then, we have that _e_ <sup>′′</sup> → _C_ ′ _e_ . This is a contradiction since this does not occur in _pre_ <sup>+</sup> ( _C_ <sup>′′</sup> _, e_ <sup>′</sup> ) _.w.y_ . Hence, _C_ <sup>′</sup> must appear to the left of _C_ in the ODPOR tree. If _C_ <sup>′</sup> exists in the tree visited by ODPOR _cs_ we are done, since we have found an equivalent complete sequence. Otherwise, we can apply the same construction to discover an equivalent complete sequence that occurs to the left in the original tree. The procedure must terminate since, eventually, we reach the leftmost branch, which cannot be removed by the context-sensitive additions to the algorithm. Now, let us claim a lemma needed for the optimality theorem. Lemma 3. _Let_ _E_ = _E_ <sup>′</sup> _.e_ ˆ _.w.e_ <sup>ˆ′</sup> _.w_ _be_ _an_ _execution_ _such_ _that_ _e_ ≾ _E_ _e_ <sup>′</sup> _._ _Let_ _v_ <sup>′</sup> _and_ _v_ _be_ _dep_ ( _e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.Ifut_ ( _E_ <sup>′</sup> _, v, E_ ) _and_ _notdep_ <sup>∗</sup> ( _e, E_ ) _.e_ <sup>ˆ′</sup> _,_ _respectively._ _v_ ̸ ∈ _redundant_ ( _E_ <sup>′</sup> _, done_ ) ⇔ _v_ <sup>′̸</sup> ∈ _redundant_ ( _E_ <sup>′</sup> _, done_ ) Finally, let us sketch the proof of Theorem 2. that in execution sequence _E_ we have _e_ <sup>′</sup> → _E_ _e_, whereas in _E_ <sup>′</sup>, we have _e_ → _E_ ′ _e_ <sup>′</sup> . After claiming the previous lemmas, let us prove now the soundness of ODPOR _cs_ . Proof of Theorem 1 ( _Soundness_ _of_ _ODPORcs_ ) . Consider an execution of Explore( _ϵ,_ ⟨{ _ϵ_ } _,_ ∅⟩ _,_ ∅) without the additions for contextsensitivity, and assuming we always choose an enabled process 16 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Proof of Theorem 2 ( _Optimality_ _of_ _ODPORcs_ ) . This theorem follows from: (1) the optimality of ODPOR, (2) the fact that the algorithm can cut executions that are not happens-before equivalent but whose result is the same as that of other complete executions already explored (Lemma 2), and (3) the fact that races found in cut executions have enough information to detect redundancies correctly (Lemma 3). By Lemma 3, we detect the same redundancies than ODPOR, whenever ODPOR _cs_ explores a don’t-do set blocked execution _E_ . Then, when detecting a race in _E_, the wakeup tree is updated if and only if it would also be updated in case _E_ would have been completely explored. Consequently, if both algorithms detect the same redundancies, and ODPOR does not initiates any of them, ODPOR _cs_ does not either. The happens-before relation used in ODPOR requires (by the soundness of ODPOR) to explore an equivalent execution to _E_ . Let us notice that _E_ does not have the same happens-before relation than any execution explored by ODPOR _cs_ . Appendix B. Proofs of correctness and optimality of ODPOR <sup>_ob_</sup> _cs_ Let us prove two lemmas that are the key for the soundness and optimality of Algorithm 2. Lemma 4. _If_ _Algorithm_ _2_ _checks_ _that_ _s_ [ _pre_ +( _E_ ′ _,o_ ′)] = <sup>_e_</sup> _o_ <sup>_,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> _o_ <sup>′</sup> _s_ [ _E_ 0 _.v_ ≤ _oE_ <sup>′</sup> <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)]</sup> ∀ _o_ <sup>′</sup> ∈ _os,_ _then_ _for_ _any_ _complete_ _oE_ <sup>′</sup> <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)]</sup> ∀ _o_ <sup>′</sup> ∈ _os,_ _then_ _for_ _any_ _complete_ _sequence_ _E_ _of_ _the_ _form_ _E_ = _E_ 0 _.v._ ( _o_ ˆ _s_ \ˆ _o_ ) _.w_ <sup>′</sup> _that_ _contains_ _a_ _race_ _e_ <sup>′</sup> ≾ _E_ _e_ _observed_ _by_ _os_ = _observers_ ( _e, e_ <sup>′</sup> _, E_ ) _and_ _o_ = _maxE_ ( _os_ ) _,_ _there_ _is_ _a_ _complete_ _sequence_ _E_ <sup>′</sup> = _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, o_ ) _.w_ _that_ _defines_ _a_ _different_ _Mazurkiewicz_ _trace_ _T_ <sup>′</sup> =→ _E_ ′ _and_ _leads_ _to_ _an_ _identical_ _final_ _state_ _modulo_ _observability._ Proof. Let _E_ = _E_ 0 _.v._ ( _o_ ˆ _s_ \ˆ _o_ ) _.w_ <sup>′</sup> be a complete execution sequence. Here, let us denote _notobs_ ( _e, e_ <sup>′</sup> _, E_ ) as _notobs_ and notice that _E_ = _E_ 0 _.v._ ( _o_ ˆ _s_ \ˆ _o_ ) _.w_ <sup>′</sup> ∼ _E_ 0 _.ance_ ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.e_ ˆ _.notobs.o_ ˆ _._ ( _o_ ˆ _s_ \ˆ _o_ ) _.w_ <sup>′</sup> ∼ _E_ 0 _.ance_ ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.e_ ˆ _.notobs<_ <sup>_o_</sup> _E_ ∼ _E_ 0 _.ance_ ( _e, e_ <sup>′</sup> _, E_ ) _.e_ <sup>ˆ′</sup> _.e_ ˆ _.notobs<_ <sup>_o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_.o_</sup> <sup>ˆ</sup> <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)</sup> <sup>_.w_</sup> <sup>′</sup> <sup>_o_</sup> _E_ <sup>_.notobs>o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)</sup> <sup>_.w_</sup> <sup>′</sup> ∼ _E_ 0 _.v_ ≤ <sup>_o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)</sup> <sup>_.v>o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_.w_</sup> <sup>′</sup> <sup>=</sup> <sup>_E_</sup> <sup>0</sup> <sup>_.v_</sup> <sup>≤</sup> <sup>_o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_.o_</sup> <sup>ˆ</sup> <sup>_.notobs>o_</sup> _E_ <sup>_o_</sup> _E_ <sup>_._</sup> <sup>(</sup> <sup>_o_</sup> <sup>ˆ</sup> <sup>_s_</sup> <sup>\ˆ</sup> <sup>_o_</sup> <sup>)</sup> <sup>_.w_</sup> Since _s_ [ _pre_ +( _E_ ′ _,o_ ′)] = <sup>_e_</sup> _o_ <sup>_,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> References Abdulla, P.A., Aronis, S., Jonsson, B., [Sagonas,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb1) K.F., 2014. Optimal dynamic partial order reduction. In: Jagannathan, S., [Sewell,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb1) P. (Eds.), The 41st Annual ACM SIGPLAN-SIGACT Symposium on [Principles](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb1) of Programming Languages, POPL ’14, San Diego, CA, USA, January 20-21, 2014. ACM, pp. 373–384. Abdulla, P.A., Atig, M.F., Jonsson, B., Lång, M., Ngo, T.P., Sagonas, K., 2019. Op timal stateless model checking for reads-from equivalence under sequential consistency. Proc. ACM Program. Lang. 3, 150:1–150:29. [http://dx.doi.org/10.](http://dx.doi.org/10.1145/3360576) [1145/3360576.](http://dx.doi.org/10.1145/3360576) Abdulla, P.A., Atig, M.F., Jonsson, B., Ngo, T.P., 2018. Optimal stateless model checking under the release-acquire semantics. Proc. ACM Program. Lang. 2, 135:1–135:29. [http://dx.doi.org/10.1145/3276505.](http://dx.doi.org/10.1145/3276505) Albert, E., Arenas, P., de la Banda, M.G., Gómez-Zamalloa, M., Stuckey, P., 2017. Context sensitive dynamic partial order reduction. In: Kuncak, V., Majumdar, R. (Eds.), 29th International Conference on Computer Aided Verification (CAV 2017). Springer, pp. 526–543. [http://dx.doi.org/10.1007/](http://dx.doi.org/10.1007/978-3-319-63387-9_26) [978-3-319-63387-9_26.](http://dx.doi.org/10.1007/978-3-319-63387-9_26) Albert, E., de la Banda, M.G., Gómez-Zamalloa, M., Isabel, M., Stuckey, P.J., 2019. Optimal context-sensitive dynamic partial order reduction with observers. In: Proceedings of the ACM SIGSOFT International Symposium on Software Testing and Analysis 2019 (ISSTA’19). pp. 352–362. [http://dx.doi.org/10.1145/](http://dx.doi.org/10.1145/3293882.3330565) [3293882.3330565.](http://dx.doi.org/10.1145/3293882.3330565) Albert, E., Gómez-Zamalloa, M., Isabel, M., 2016. Syco: A systematic testing tool for concurrent objects. In: Zaks, A., Hermenegildo, M.V. (Eds.), Proceedings of the 25th International Conference on Compiler Construction, CC 2016, Barcelona, Spain, March 12-18, 2016. ACM, pp. 269–270. [http://dx.doi.org/](http://dx.doi.org/10.1145/2892208.2892236) [10.1145/2892208.2892236.](http://dx.doi.org/10.1145/2892208.2892236) Albert, E., Gómez-Zamalloa, M., Isabel, M., Rubio, A., 2018a. Constrained dynamic partial order reduction. In: Computer Aided Verification - 30th International Conference, CAV 2018, Held As Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July (2018) 14-17, Proceedings, Part II. Springer pp. 392–410. [http://dx.doi.org/10.1007/978-3-319-96142-2_24.](http://dx.doi.org/10.1007/978-3-319-96142-2_24) Albert, E., Gómez-Zamalloa, M., Rubio, A., Sammartino, M., Silva, A., 2018b. Sdn actors: Modeling and verification of SDN programs. In: Formal Methods 22nd International Symposium, FM 2018, Held As Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July (2018) 15-17, Proceedings pp. 550–567. [http://dx.doi.org/10.1007/978-3-319-95582-7_33.](http://dx.doi.org/10.1007/978-3-319-95582-7_33) Aronis, S., Jonsson, B., Lång, M., Sagonas, K., 2018. Optimal dynamic partial order reduction with observers. In: Tools and Algorithms for the Construction and Analysis of Systems - 24th International Conference, TACAS 2018, Held As Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2018, Thessaloniki, Greece, April (2018) 14-20, Proceedings, Part II. pp. 229–248. [http://dx.doi.org/10.1007/978-3-319-89963-3_14.](http://dx.doi.org/10.1007/978-3-319-89963-3_14) Cai, Y., Yun, H., Wang, J., Qiao, L., Palsberg, J., 2021. Sound and efficient concur rency bug prediction. In: Spinellis, D., Gousios, G., Chechik, M., Penta, M.D. (Eds.), ESEC/FSE’21: 29th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering, Athens, Greece, August 23-28, 2021. ACM, pp. 255–267. [http://dx.doi.org/10.1145/](http://dx.doi.org/10.1145/3468264.3468549) [3468264.3468549.](http://dx.doi.org/10.1145/3468264.3468549) Chalupa, M., Chatterjee, K., Pavlogiannis, A., Sinha, N., Vaidya, K., 2018. Data centric dynamic partial order reduction. Proc. ACM Program. Lang. 2, 31:1–31:30. [http://dx.doi.org/10.1145/3158119.](http://dx.doi.org/10.1145/3158119) Clarke, E.M., Grumberg, O., Minea, M., [Peled,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb12) D.A., 1999. State space reduction using partial order techniques. Int. J. Softw. Tools Technol. Transfer 2, [279–287.](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb12) Flanagan, C., Godefroid, P., 2005. [Dynamic](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb13) partial-order reduction for model checking software. In: Palsberg, J., [Abadi,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb13) M. (Eds.), Proceedings of the 32nd ACM SIGPLAN-SIGACT [Symposium](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb13) on Principles of Programming Languages, POPL 2005, Long Beach, [California,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb13) USA, January 12-14, 2005. ACM pp. [110–121.](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb13) Godefroid, P., 1991. Using partial [orders](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb14) to improve automatic verification methods. In: Proc. of [CAV’91.](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb14) Springer, pp. 176–185. Godefroid, P., 1996. Partial-Order Methods for the Verification of Concurrent Systems - an Approach to the State-Explosion Problem. In: LNCS, vol. 1032, Springer, [http://dx.doi.org/10.1007/3-540-60761-7.](http://dx.doi.org/10.1007/3-540-60761-7) Godefroid, P., Pirottin, D., 1993. [Refining](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb16) dependencies improves partial-order verification methods (extended abstract). In: CAV. pp. 438–449. Johnsen, E.B., Hähnle, R., Schäfer, J., [Schlatte,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb17) R., Steffen, M., 2012. ABS: A Core language for abstract [behavioral](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb17) specification. In: Aichernig, B.K., de Boer, F.S., Bonsangue, M.M. (Eds.), [Formal](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb17) Methods for Components and Objects - 9th International [Symposium,](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb17) FMCO 2010, Graz, Austria, November 29 - December 1, 2010. [Revised](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb17) Papers. Springer, pp. 142–164. Kahlon, V., Wang, C., Gupta, A., 2009. Monotonic partial order reduction: An optimal symbolic partial order [reduction](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb18) technique. In: CAV. pp. 398–413. Katz, S., Peled, D.A., 1992. Defining [conditional](http://refhub.elsevier.com/S0164-1212%0x2823%0x2900125-5/sb19) independence using collapses. TCS 101, 337–359. <sup>_e_</sup> _o_ <sup>_,_</sup> <sup>′</sup> <sup>_e_</sup> <sup>′</sup> _s_ [ _E_ 0 _.v_ ≤ _o_ _E_ _._ ( _o_ ˆ _s_ \ˆ _o_ )] <sup>∀</sup> <sup>_o_</sup> <sup>′</sup> <sup>∈</sup> <sup>_o_</sup> _s_ <sup>,</sup> <sup>we</sup> <sup>have</sup> <sup>that</sup> <sup>_s_</sup> [ _E_ ] <sup>is</sup> equivalent to _s_ [ _E_ ′] modulo observability where _E_ _E_ <sup>′</sup> = _pre_ <sup>+</sup> ( _E_ <sup>′</sup> _, o_ ) _.w_ . Note that in _E_ we have _e_ <sup>′</sup> → _E_ _e_, whereas in _E_ <sup>′</sup> we instead have _e_ → _E_ ′ _e_ <sup>′</sup> . Lemma 5 ( _Soundness_ _of_ _New_ _Inheritance_ ) . _Let_ _E_ <sup>′</sup> _be_ _an_ _execution_ _such_ _that_ _p.q.u_ ∈ _wut_ ( _E_ <sup>′</sup> ) _,_ _q.p.u.v_ ∈ _dnd_ ( _E_ <sup>′</sup> ) _,_ _and_ _E_ <sup>′</sup> |� _q.p.u.v_ _p_ ⋄ _q._ _If_ _E_ = _E_ <sup>′</sup> _.p.q.u.v_ _and_ _E_ <sup>′′</sup> = _E_ <sup>′</sup> _.q.p.u.v,_ _then_ _s_ [ _E_ ] = _s_ [ _E_ ′′] _modulo_ _observability._ Proof. Let us distinguish two cases depending on _E_ <sup>′</sup> |� _q.p.u.v_ _p_ ⋄ _q_ : - If _E_ <sup>′</sup> |� _q.p.u.v_ _p_ ⋄ _q_ holds because _E_ <sup>′</sup> |� _p_ ⋄ _q_, then they are independent, hence _E_ <sup>′</sup> _.p.q_ ∼ _E_ <sup>′</sup> _.q.p_ ⇒ _s_ [ _E_ ′ _.p.q_ ] = _s_ [ _E_ ′ _.q.p_ ] ⇒ _s_ [ _E_ ] = _s_ [ _E_ ′′]. - Otherwise, _E_ <sup>′</sup> |� _q.p.u.v_ _p_ ⋄ _q_ holds because it takes advantage of observability, (i.e., ∃ˆ _w_ ∈ _u.v_ such that the set of variables written by both _p_ and _q_ is overwritten by _w_ and ∀ˆ _r_ ∈ _u.v_ that observes any of these variables, _w_ _<E_ ′ _.q.p.u.v_ _r_ ). Then, _u.v_ is of the form _u_ 1 _._ ˆ _w.u_ 2 _.r_ ˆ _.v_ 3 for all _r_ ˆ ∈ _u.v_, and, although _s_ [ _E_ ′ _.p.q_ ] may be different to _s_ [ _E_ ′ _.q.p_ ], we know that _s_ [ _E_ ′ _.p.q.u_ 1 _._ ˆ _w_ ] = _s_ [ _E_ ′ _.q.p.u_ 1 _.w_ ˆ ] and hence _s_ [ _E_ ] = _s_ [ _E_ ′′] modulo observability. The proofs of soundness and optimality of ODPOR <sup>_ob_</sup> _cs_ <sup>are</sup> <sup>anal-</sup> ogous to those of the soundness and optimality theorems of ODPOR _cs_ relying on Lemmas 4 and 5. 17 _E._ _Albert,_ _M.G._ _de_ _la_ _Banda,_ _M._ _Gómez-Zamalloa_ _et_ _al._ _The_ _Journal_ _of_ _Systems_ _&_ _Software_ _202_ _(2023)_ _111730_ Kokologiannakis, M., Marmanis, I., Gladstein, V., Vafeiadis, V., 2022. Truly stateless, optimal dynamic partial order reduction. Proc. ACM Program. Lang. 6, 1–28. [http://dx.doi.org/10.1145/3498711.](http://dx.doi.org/10.1145/3498711) Kokologiannakis, M., Raad, A., Vafeiadis, V., 2019a. Effective lock handling in stateless model checking. Proc. ACM Program. Lang. 3, 173:1–173:26. [http:](http://dx.doi.org/10.1145/3360599) [//dx.doi.org/10.1145/3360599.](http://dx.doi.org/10.1145/3360599) Kokologiannakis, M., Raad, A., Vafeiadis, V., 2019b. Model checking for weakly consistent libraries. In: McKinley, K.S., Fisher, K. (Eds.), Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2019, Phoenix, AZ, USA, June 22-26, 2019. ACM pp. 96–110. [http://dx.doi.org/10.1145/3314221.3314609.](http://dx.doi.org/10.1145/3314221.3314609) [Lang,](https://github.com/nidhugg/nidhugg) M., Leonardsson, C., 2015. Nidhugg. URL [https://github.com/nidhugg/](https://github.com/nidhugg/nidhugg) [nidhugg.](https://github.com/nidhugg/nidhugg) Mazurkiewicz, A.W., 1986. Trace theory. In: Petri Nets: Central Models and their Properties, Advances in Petri Nets 1986, Part II, Proceedings of an Advanced Course, Bad Honnef, Germany, 8-19 September 1986. pp. 279–324. [http://dx.doi.org/10.1007/3-540-17906-2_30.](http://dx.doi.org/10.1007/3-540-17906-2_30) Musuvathi, M., Qadeer, S., 2007. Iterative context bounding for systematic testing of multithreaded programs. In: Ferrante, J., McKinley, K.S. (Eds.), Proceedings of the ACM SIGPLAN 2007 Conference on Programming Language Design and Implementation, San Diego, California, USA, June 10-13, 2007. ACM pp. 446–455. [http://dx.doi.org/10.1145/1250734.1250785.](http://dx.doi.org/10.1145/1250734.1250785) Nguyen, H.T.T., Rodríguez, C., Sousa, M., Coti, C., Petrucci, L., 2018. Quasi-optimal partial order reduction. In: Chockler, H., Weissenbacher, G. (Eds.), Computer Aided Verification - 30th International Conference, CAV 2018, Held as Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July 14-17, 2018 Proceedings, Part II. Springer, pp. 354–371. [http://dx.doi.org/10.1007/978-3-](http://dx.doi.org/10.1007/978-3-319-96142-2_22) [319-96142-2_22.](http://dx.doi.org/10.1007/978-3-319-96142-2_22) Park, J., Choi, B., Jang, S.Y., 2020. Dynamic analysis method for concurrency bugs in multi-process/multi-thread environments. Int. J. Parallel Program. 48, 1032–1060. [http://dx.doi.org/10.1007/s10766-020-00661-3.](http://dx.doi.org/10.1007/s10766-020-00661-3) Pavlogiannis, A., 2020. Fast, sound, and effectively complete dynamic race prediction. Proc. ACM Program. Lang. 4, 17:1–17:29. [http://dx.doi.org/10.](http://dx.doi.org/10.1145/3371085) [1145/3371085.](http://dx.doi.org/10.1145/3371085) Rodríguez C. Sousa, M., Sharma, S., Kroening, D., 2015. Unfolding-based partial order reduction. In: 26th International Conference on Concurrency Theory, CONCUR 2015, Madrid, Spain, September 1.4, 2015. pp. 456–469. [http:](http://dx.doi.org/10.4230/LIPIcs.CONCUR.2015.456) [//dx.doi.org/10.4230/LIPIcs.CONCUR.2015.456.](http://dx.doi.org/10.4230/LIPIcs.CONCUR.2015.456) Schemmel, D., Büning, J., Rodríguez, C., Laprell, D., Wehrle, K., 2020. Symbolic partial-order execution for testing multi-threaded programs. In: Lahiri, S.K., Wang, C. (Eds.), Computer Aided Verification - 32nd International Conference, CAV 2020, Los Angeles, CA, USA, July 21-24, 2020 Proceedings, Part I. Springer, pp. 376–400. [http://dx.doi.org/10.1007/978-3-030-53288-8_18.](http://dx.doi.org/10.1007/978-3-030-53288-8_18) Valmari, A., 1989. Stubborn sets for reduced state space generation. In: Rozen berg, G. (Ed.), Advances in Petri Nets 1990 10th International Conference on Applications and Theory of Petri Nets, Bonn, Germany, 1989, Proceedings. Springer, pp. 491–515. [http://dx.doi.org/10.1007/3-540-53863-1_36.](http://dx.doi.org/10.1007/3-540-53863-1_36) Wang, C., Yang, Z., Kahlon, V., Gupta, A., 2008. Peephole partial order re duction. In: Ramakrishnan, C.R., Rehof, J. (Eds.), Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings. Springer, pp. 382–396. [http://dx.doi.org/10.1007/978-](http://dx.doi.org/10.1007/978-3-540-78800-3_29) [3-540-78800-3_29.](http://dx.doi.org/10.1007/978-3-540-78800-3_29) Elvira Albert holds a position as a Professor at Complutense University of Madrid (UCM). Her main research includes the development of techniques and tools for automated analysis of smart contracts, testing and analysis of concurrent programs, and verification. Elvira is an author of more than 150 publications in international journals and conferences. Her work has received more than 3500 citations according to Google Scholar. Maria Garcia de la Banda holds a position as a Professor at Monash University. Her main research includes constraint programming, optimization, logic programming, parallelism and bioinformatics. Maria is an author of more than 90 publications in international journals and conferences. Her work has received more than 3000 citations according to Google Scholar. Miguel Gómez-Zamalloa currently holds a permanent position as a senior lecturer. His main research focus has been on the development of techniques and tools for automated analysis, testing and verification. Miguel is an author of more than 50 publications in international journals and conferences. His work has received more than 900 citations according to Google Scholar. Miguel Isabel received a Ph.D. in Computer Science in 2020 from Complutense University of Madrid. He is currently working as an assistant teacher at Technical University of Madrid in the area of computer networks. His research interests include testing of concurrent programs, deadlock analysis, partial order reduction and software verification. Peter Stuckey holds a position as a Professor at Monash University. His main research includes constraint programming, logic programming, artificial intelligence, and discrete optimization. Peter is an author of more than 400 publications in international journals and conferences. His work has received more than 16000 citations according to Google Scholar. 18

섹션 본문 204문단 · 95,507자

(제목 없음)

1Dynamic Partial Order Reduction (DPOR) algorithms are used in stateless model checking of concurrent programs to avoid the exploration of equivalent execution sequences.In order to detect equivalence, DPOR relies on the notion of independence between execution steps.As this notion must be approximated, it can lose precision and thus treat execution steps as interfering when they are not.Our work is inspired by recent progress in the area that has introduced more accurate ways to exploit conditional notions of independence: Context-Sensitive DPOR considers two steps p and t independent in the current state if the states obtained by executing p • t and t • p are the same; Optimal DPOR with Observers makes their dependency conditional to the existence of future events that observe their operations.This article introduces a new algorithm, Optimal Context-Sensitive DPOR with Observers, that combines these two notions of conditional independence, and goes beyond them by exploiting their synergies.The implementation of our algorithm has been undertaken within the Nidhugg model checking tool.Our experimental evaluation, using benchmarks from the previous works, shows that our algorithm is able to effectively combine the benefits of both context-sensitive and observers-based independence and that it can produce exponential reductions over both of them.

Introduction

2A fundamental challenge in the verification and testing of concurrent programs arises from the combinatorial explosion that results from exploring the different ways in which processes/threads can interleave.There are several proposals to reduce the number of explored interleavings, such as depth-and context-bounding [25].Among all proposals, Dynamic Partial Order reduction (DPOR) stands out due to its proven scalability, which results from being a stateless approach, i.e., one where global states do not need to be explicitly stored.DPOR is the dynamic realization of Partial-Order Reduction (POR) [14,15,12].POR is a general theory that provides full coverage of all possible executions of concurrent programs by identifying equivalence classes of redundant executions, and only exploring one representative of each class.POR considers two execution sequences equivalent if one can be obtained from the other by swapping adjacent, independent execution steps.Each such equivalence class is called a Mazurkiewicz [24] trace, and POR guarantees that exploring one sequence per equivalence class is sufficient to cover all.Early POR algorithms [15,12,31] re-lied on static approximations of independence.The Dynamic-POR (DPOR) algorithm [13] was a breakthrough because it uses the information witnessed during the actual execution of the sequence to decide dynamically what to explore.Thus, it often explores less sequences than approaches based on static approximations.As a result, DPOR is considered one of the most scalable techniques for software verification.

3The cornerstone of DPOR is the notion of (in)dependence, which is used to decide if two concurrent execution steps p and t (do not) interfere with each other and, thus, both sequences p followed by t (written p.t) and the reversed t.p must (not) be explored.To guarantee soundness, DPOR approximates independence and, thus, can lose precision if it treats execution steps as interfering when they are not.Optimal DPOR (ODPOR) [1] ensures optimality, that is, only one sequence per equivalence class is explored and the exploration of any equivalent execution sequence is not even initiated.However, this is done w.r.t. a restricted notion of independence, which usually requires execution steps to be independent in any possible state during the current execution.In practice, syntactic approximations are used to detect independence: typically, two execution steps are considered dependent if both access the same variable and at least one modifies it.

4Any DPOR algorithm can thus improve its efficiency by using a more accurate independence notion [16].Two recent approaches -DPOR cs (Context-Sensitive DPOR) [4] and ODPOR ob (Optimal-DPOR with Observers) [9] -have achieved this by integrating orthogonal notions of conditional independence into DPOR:

5• DPOR cs introduced the notion of context-sensitive independence, which only requires execution steps p and t be independent in the state s where they appear.This is determined by executing sequences p.t and t.p in s, and checking if the two states reached are equal.Let us consider the following simple example, borrowed from [9], with three concurrent processes p, q and r (each containing a single instruction) where the global variable x is initialized to 0: int x = 0; process p: x = 1; process q: x = 2; process r: assert (x < 3);

6Assume p is scheduled first and we reach a state s where x==1.Executing either q.r or r.q from s yields the same final state: x==2 and the assertion holds.Thus, DPOR cs considers r and q independent in s (e.g., in x==1).

7• ODPOR ob introduced the notion of observability, where dependencies between execution steps p and t are conditional to the existence of future steps, called observers, which read the values modified by p and t.Consider again the three concurrent processes p, q and r above.Assume r is scheduled first reaching a state s where x==0 and the assertion holds.ODPOR ob considers q and p independent in s since, while their interleaved execution leads to different final states, variable x is not observed later.

Summary of Contributions

8DPOR cs and ODPOR ob modified the DPOR algorithm to exploit their notions of independence.As our overall contribution, we present a further modification of DPOR, called Optimal Context-Sensitive DPOR with Observers (ODPOR ob cs ), that not only combines and exploits these two powerful notions, but also takes advantage of their synergy to gain further pruning.Let us consider again the same three processes and the trace p.q.r.DPOR cs does not consider p and q independent in this trace, as they give different values to variable x.ODPOR ob does not consider them independent either, as r observes the different values they give to x.However, ODPOR ob cs does consider them as independent in this trace, as the assertion of observer r evaluates to true after executing either p.q or q.p.The following major contributions are needed for this:

91. Optimal Context-Sensitive DPOR.DPOR cs was originally formulated in [4] over Source-DPOR [1].Thus, it did not include the extension of wakeup trees used by ODPOR to ensure optimality, and later used to handle observers.Our first contribution is the formulation of DPOR cs over ODPOR, which we name Optimal Context-Sensitive DPOR (ODPOR cs ). 2. Extending 1 with observers.Our second contribution is to integrate observability into ODPOR cs , obtaining ODPOR ob cs .For this, we modify context-sensitive independence to be modulo observability, which only requires equivalence for variables affected by future observers.

103. Implementation and experiments.We have implemented ODPOR ob cs , DPOR cs and ODPOR cs within the Nidhugg model checking tool [23] and performed an experimental evaluation with benchmarks from [4] and [9].Our experimental results show that ODPOR ob cs can produce exponential reductions over both DPOR cs and ODPOR ob , and that, in the worst cases, it scales similarly as the best of the other systems for the considered benchmark.This article revises and extends a previous conference paper published in the proceedings of ISSTA'19 [5].In addition to fixing some errors, extending the explanations and intuitions, discussing the most recent related work and adding new and more detailed examples, we have important improvements both on the practical and theoretical sides of the work.On the practical one, rather than using our implementations within the SYCO tool [6], we have reimplemented the ODPOR ob cs , DPOR cs and ODPOR cs algorithms within their Nidhugg model checking tool [23].This very significant effort was necessary to facilitate the comparison with algorithms other than ours, particularly ODPOR [1] and ODPOR ob [9].We then performed a new and more detailed experimental evaluation using some of the original benchmarks of [9] and new encodings of those of [4].This also required implementing the necessary support to handle atomic blocks, which are needed to encode the actors based concurrency of the benchmarks in [4].On the theoretical side, we have made three major improvements.First, we have added correctness proofs of both the ODPOR cs and ODPOR ob cs algorithms.Second, we have proposed a refined and more efficient context-sensitive check that can be exploited not only in ODPOR cs and ODPOR ob cs , but also in the original DPOR cs of [4].And third, we have developed a simpler and more accurate definition of the notion of equivalence modulo observability which is key in ODPOR ob cs .

Structure of the Article

11The rest of the article is organized as follows.Section 2 introduces the technical notation and recalls background knowledge on the DPOR and ODPOR formalisms.Section 3 first describes the original DPOR cs approach and then introduces the modifications and extensions needed to define ODPOR cs , as well as the associated proofs of soundness and optimality.Section 4 presents ODPOR ob cs : the integration of observability into ODPOR cs .The results of our implementation and experimental evaluation are reported in Section 5. Finally, Section 6 discusses related work and our final conclusions.

Basics of DPOR

12As previous work on DPOR, we assume the state space does not contain cycles, executions have finite unbounded length and processes are deterministic (i.e., at a given time there is at most one event a process can execute).An execution sequence E is a finite sequence of execution steps of the system processes that is performed from the initial state.We denote by s [E] the, uniquely defined, state after executing sequence E. We use ϵ to denote the empty sequence and .to denote concatenation of sequences of process steps.E.g., p.p.q denotes the execution sequence where first p performs two steps, followed by a step of q.An event p i of execution sequence E represents the i-th occurrence of process p in E, e.g., event p 2 denotes the second execution step of process p in the previous sequence.

13Running Example.Let us consider an extension of the example in Section 1.The program contains two global variables x and y which are initialized to 0, and three processes, p, q and r.Process p contains two assignments over variables y and x respectively.Process q only includes an assignment over variable x.Finally, process r includes two assertions that check if variable x is less than 3 and 2, respectively.Int x = 0; Int y = 0; process p : process q : process r : y = 1; x = 2; assert x < 3;

14x = 1; assert x < 2;

15In this example the first assert always holds, while the second can either hold or not depending on whether x has been assigned to 2 when r 2 executes.For instance, given execution sequence E 1 = q.p.p.r.r, both asserts hold in s

16. This is also the case for sequence E 2 = p.p.r.r.q, even though we have

17In contrast, for sequence E 3 = p.p.q.r.r, the second assert does not hold since process q writes 2 over variable x before process r reads it.

18We use e < E e ′ to denote that event e occurs before event e ′ in sequence E, s.t.< E establishes a total order between events in E. The core concept in DPOR is that of the happens-before partial order among the events in execution sequence E, denoted by → E .This relation is used to define a subset of the < E total order, such that any two sequences with the same happens-before order are equivalent.Let dom(E) denote the set of events in E.

19Any linearization E ′ of → E on dom(E) is an execution sequence with the same happens-before relation → E ′ as → E .Thus, → E induces a set of equivalent execution sequences, all with the same happens-before relation.We use E ≃ E ′ to denote that E and E ′ are equivalent.DPOR algorithms use this relation to reduce the number of equivalent execution sequences explored, with ODPOR ensuring that only one execution sequence in each equivalence class is explored.

20Example 1.Let us consider again sequence E 1 = q.p.p.r.r of our running example.Its total order of events is: q

21Its happens-before relation is as follows:

22Another possible linearization of this happens-before relation is hence E ′ 1 = p.q.p.r.r.Since both E 1 and E ′ 1 have the same happens-before relation we have

23As done in [1] to support any computation model, our approach assumes the existence of a happens-before assignment function that assigns a happens-before relation to any execution sequence.The precision of such function can vary as long as it satisfies the set of properties specified in [1].For the examples throughout the paper we assume a happens-before assignment based on the traditional approximation of dependency for programs with shared variables.Namely, two events p and q are considered dependent if either one enables the other (i.e., executing E.p introduces q, or vice versa), or if both access the same variable and at least one modifies it.

24The happens-before relation is also used for defining the notion of race.Event e is said to be in race with event e ′ in execution E, written e ⋖ E e ′ , if the events belong to different processes, e happens-before e ′ in E (e → E e ′ ), and the two events are "concurrent" (∃E ′ s.t.E ′ ≃ E and the two events are adjacent in E ′ ).This implies that there is no intermediate event e ′′ in E such that e → E e ′′ → E e ′ .We also write e ≾ E e ′ to denote that e is in a reversible race with e ′ , i.e., e is in a race with e ′ and the two can be reversed (∀E ′ s.t.E ′ ≃ E and e appears immediately before e ′ , e ′ is not blocked).These are the only races the algorithms need to dynamically check for independence.

25Example 2. In both sequences E 1 and E ′ 1 of our running example, we have q 1 ≾ E 1 p 2 , i.e., event q 1 is in a reversible race with event p 2 .This is because the events belong to different processes, they are concurrent, i.e., ∃E ′ s.t.E ′ ≃ E 1 where the two events are adjacent (namely, E ′ = p.q.p.r.r), and none of them can block the other one.

26Other notation we use includes: ê, denoting the process of event e (e.g., q1 is q in our example); enabled(s), the set of processes that can perform an execution step from state s (e.g., a locking operation can be enabled if the lock is not taken, or disabled when it is taken); and pre + (E, e), respectively pre(E, e), the prefix of sequence E up to e, including and not including e (e.g., pre + (E ′ , p 2 ) is p.q.p and pre(E ′ , p 2 ) is p.q in the previous example).

Optimal DPOR

27The code in black of Algorithm 1 (excluding underlined blue parts) corresponds to the ODPOR algorithm [1] adapted so that it does not make use of sleep-sets, as proposed in [9].ODPOR carries out a depth-first exploration of the execution tree from an (initially empty) execution sequence E. Essentially, it dynamically finds reversible races and is able to backtrack at the appropriate scheduling points to reverse them.For this purpose, it keeps two sets for every sequence E explored: the wakeup tree of E containing the execution sequences that must be explored from E, and the set of processes that are done from E, that is, have already been explored from it.

28Wakeup Trees.A wakeup tree is an ordered tree ⟨B, ≺ ⟩, where the set of nodes B is a finite prefix-closed set of sequences of processes, with the empty sequence ϵ at the root.The children of node w are ordered by ≺ and have the form w.p for some set of processes p.We write wut(E) to denote the wakeup tree of sequence E. Intuitively, wut(E) is composed of partial execution sequences that must be explored from E, as they (a) reverse the order of detected races, and (b) are not provably equivalent.

29The algorithm makes use of the following functions over wakeup trees:

30• insert [E] (v, wut(E)) returns the extension of wut(E) with a new sequence v.

31• subtree(⟨B, ≺ ⟩, p) returns the subtree of wakeup tree ⟨B, ≺ ⟩ rooted at process p ∈ B, i.e., the tree ⟨B ′ , ≺ ′ ⟩, where B ′ = {w|p.w∈ B} and ≺ ′ is the restriction of ≺ to B ′ .

32Algorithm 1 ODPOR cs algorithm dnd(E) := DnD; wut(E) := WuT ; 7:

33for each p ∈ dnd(E) such that |p| = 1 :

34RaceDetection(E.p); wut(E) := ⟨{ϵ, p}, {(p, ϵ)}⟩;

3513:

36while ∃p ∈ wut(E) do 14:

37if p ∈ dnd(E) then 16:

38RaceDetection(E.p); let WuT ′ = subtree(wut(E), p);

39∪ {v | (p.v) ∈ dnd(E)};

21:

40Explore(E.p,WuT ′ , DnD ′ );

22:

41add p to done(E);

23:

42remove all sequences of form p.w from wut(E);

4324: procedure RaceDetection(E)

25:

44for all e, e ′ ∈ dom(E) such that e ≾ E e ′ do 26:

45let E ′ = pre(E, e); let dont = ϵ;

4627:

47] then

29:

48dont := v.ê;

49add dont to dnd(E ′ );

50ODPOR starts by selecting (line 14) the leftmost process p in the wakeup tree, according to its order ≺, that is enabled by state s [E] (due to line 4).If there is such a process, it sets WuT ′ as the subtree of wut(E) with root p (line 18), and recursively explores every sequence in WuT ′ from E.p (line 21).Note that wut(E) might grow as this recursion progresses, due to later executions of line 31.After the recursion finishes, it adds p to done(E), removes from wut(E) all sequences that start with p, and iterates selecting a new p.Once a complete sequence E has been explored (E is said to be complete if enabled(s [E] ) = ∅), the algorithm performs the race detection phase (line 4).This starts by finding all pairs of events e and e ′ in dom(E) such that e ≾ E e ′ , that is, e is in a reversible race with e ′ .For each such pair, it sets E ′ to pre(E, e) and v to notdep * (e, e ′ , E). ê′ (line 27), where notdep * (e, e ′ , E)1 is the subsequence of processes ê′′ of E such that e < E e ′′ and e ↛ E e ′′ , that is, e occurs before e ′′ in E but does not happen-before it.Let us explain the intuition of this construction.In order to reverse the race, we need to explore a sequence in which e ′ is executed before e without changing any other happens-before relation.Such sequence must start by E ′ .v.e ′ where v includes all events that are dependent with e ′ .In order to ensure optimality, v might also need to include other events.The sequence computed by notdep * includes all events that are independent with e and, therefore, all events that are dependent with e ′ (otherwise there would be no race) and also those that might be needed to ensure optimality.That is, it includes those events that are necessary and possibly more.Later, notdep * will be refined to include the shortest sequence that is needed.

51Finally, if the exploration of v in E ′ is not redundant w.r.t already explored sequences (line 30), i.e., it does not lead to equivalent explorations, it is inserted into wut(E ′ ) (line 31).Redundancy is detected by means of the so called weak initials sets [1].The weak initials set of sequence w from execution E, denoted WI [E] (w), contains any process (in w or not) with no happens-before predecessors in dom [E] (w), where dom [E] (w) denotes the subset of events in execution sequence E.w that are in w, i.e., dom(E.w)\dom(E).

52Example 3. In our running example, the set dom [q.p] (p.r.r) contains the events executed by sequence p.r.r after executing q.p, that is, {p 2 , r 1 , r 2 }.The weak initials set WI [ϵ] (q.p.p.r.r) contains q since it does not have happens-before predecessors in {p 2 , r 1 , r 2 }; and p since p 1 does not have happens-before predecessors in {p 2 , r 1 , r 2 } either (as can be seen in Example 1).

53The redundancy check of line 30 is then defined as follows: v ∈ redundant(E ′ , done) iff E ′ .v is an execution sequence and there is a partitioning E ′ = w.w′ such that done(w) ∩ WI [w] (w ′ .v)∅.Intuitively, this check determines if the algorithm has already explored a subsequence that is equivalent to E ′ .v,by succeeding if a process without happens-before predecessors in the subset of events of E ′ .vthat are in w ′ .v,has already been explored (done) from sequence w.This is shown in action later in Example 4 (in the RaceDetection at state 15).

54Note that in the original ODPOR algorithm [1] this check is implemented using sleep-sets.However, [9] shows that sleepsets are not suitable as a mechanism to avoid redundant exploration in the presence of observers, and proposes this alternative definition that, as we have seen, relies on the done and weakinitials sets.We have therefore adopted this solution to ensure the ODPOR algorithm is ready for the integration of observers.

55Example 4. The execution tree that ODPOR explores for the running example is shown in Figure 1.Each node in the tree

State Cause

56Effects 5 p 2 ≾ E r 1 (access to x) r added to wut(q.p) 5 q 1 ≾ E p 2 (write to x) p.p added to wut(ϵ) 8 p 2 ≾ E r 2 (access to x) r added to wut(q.p.r) 8 q 1 ≾ E r 1 (access to x) p.r added to wut(ϵ) 15 q 1 ≾ E r 1 (access to x) r added to wut(p.p) 15 p 2 ≾ E q 1 (write to x) q not added to wut(p) 18 q 1 ≾ E r 2 (access to x) r added to wut(p.p.r) 18 p 2 ≾ E r 1 (access to x) r added to wut(p) 24 q 1 ≾ E r 2 (access to x) r added to wut(p.r.p) 24 p 2 ≾ E q 1 (write to x) q added to wut(p.r) 26 p 2 ≾ E r 2 (access to x) r added to wut(p.r)29 p 2 ≾ E r 2 (access to x) r added to wut(p.r.q) 34 p 2 ≾ E q 1 (write to x) q added to wut(p.r.r) wut(ϵ) = ⟨{ϵ, q, p, p.p, p.r}, {(q, p.p), (p.p, p.r)}⟩ q ϵ p.p p p.r corresponds to a different call to Explore.The meaning of the different labels is explained in the figure caption.The lower node labels (in blue) and the boxes labeled P1-P6 should be ignored for now.They correspond, respectively, to don't-do sets (see Section 3.1), and to prunings that the other algorithms per-form.Figure 2 lists the main actions that are carried out by the algorithm showing, for each of them, the state, the cause (i.e. the reversible race) and the effects of the action (i.e. the updates on wakeup trees).

57ODPOR starts with both E and WuT empty (state 0).Let us assume the algorithm first explores sequence q.p.p.r.r (by picking respectively these processes in each recursive call in line 11), thus reaching state 5 and invoking RaceDetection (line 4).Since the happens-before relation of this explored execution is the one shown in Example 1, a reversible race between p 2 and r 1 is detected (p 2 happens-before r 1 , appears immediately before r 1 and does not block it) setting E ′ to q.p and v to r.This causes the addition of r to wut(q.p)(see upper label of state 2), indicating the algorithm will eventually have to backtrack to state 2 to explore process r.A reversible race between q 1 and p 2 is also detected, setting E ′ to ϵ and v to p.p (line 27), thus adding p.p to wut(ϵ) (upper label of state 0).The algorithm then backtracks to state 2 (the first one with nonempty wut), along the way adding r to the done sets of states 4 and 3, and p to the done set of state 2 (line 22).Then it explores q.p.r (as determined by its wut, which has r) reaching state 6.Let's assume it then explores q.p.r.p.r thus reaching state 8 and invoking RaceDetection.Two reversible races are detected: one between r 2 and p 2 , which causes the addition of r to wut(q.p.r) (upper label of state 6), and one between r 1 and q 1 , which causes the addition of p.r to wut(ϵ) (upper label of state 0).The algorithm then backtracks to state 6 whose non-empty wut has r (adding the appropriate processes to the done sets), explores q.p.r.r.p and invokes RaceDetection at state 10, which detects no new races.Figure 3 shows the wut(ϵ) at this point, both in textual and graphical forms.Node q will be deleted from it when backtracking to state 0 and hence sequences p.p and p.r remain to be explored.

58The algorithm now backtracks to state 0 (removing r from the wut of states 6 and 2 on the way due to line 23, and appropriately updating the done sets as before) whose wut has both p.p and p.r.Let us assume p.p is explored first, reaching p.p.q.r.r (at state 15) and invoking RaceDetection.It detects two reversible races: one between r 1 and q 1 , which causes the addition of r to wut(p.p)(state 12), and one between q 1 and p 2 .In this latter case q is not added to wut(p) (state 11) because we have q ∈ redundant(p, done) (line 30), which means the exploration that would be performed from p.q is redundant to that already performed from q.p.Applying the above definition of redundant, E ′ .v, in this case let E ′ = p and v = q, is an execution sequence and there is a partitioning E ′ = w.w′ , in this case let w = ϵ and w ′ = p, such that we have a non-empty intersection between done(ϵ) = {q} and WI [ϵ] (p.q) = {p, q}.

59The algorithm then backtracks to state 12 (updating the wut and done sets of intermediate states as usual) whose wut has r, and explores p.p.r.q.r reaching state 18.The invocation to RaceDetection detects two reversible races: one between r 2 and q 1 , which causes the addition of r to wut(p.p.r) (and the subsequent exploration of sequence p.p.r.r.q), and one between r 1 and p 2 , which causes the addition of r to wut(p) (though this has no effect since r is already inherited down to wut(p) from wut(ϵ)).The algorithm then backtracks to state 11 whose wut now only has r and explores the subtree rooted at state 21.Let us just list the reversible races that are responsible for updating the wakeup trees of states 21, 22 and 27: At state 24 two reversible races are detected: one between r 2 and q 1 , which causes the addition of r to wut(p.r.p), and one between q 1 and p 2 , which causes the addition of q to wut(p.r).At state 26 the reversible race between r 2 and p 2 causes the addition of r to wut(p.r).At state 29 the reversible race between r 2 and p 2 causes the addition of r to wut(p.r.q).Finally, at state 34 the reversible race between q 1 and p 2 causes the addition of q to wut(p.r.r).

60Overall, ODPOR has explored 12 executions that matches the 12 possible happens-before relations corresponding to all ordering combinations of events q, p 2 , r 1 and r 2 , with the restriction that r 1 cannot go after r 2 .A full systematic exploration would have to explore 30 executions.Note also that ODPOR has not even had to initiate any redundant exploration.Instead, the original DPOR algorithm very often needs to explore partial executions before noticing they lead to redundant explorations (the so called sleep-set-blocked explorations).

Context-Sensitive DPOR

61The first algorithm that has used notions of conditional independence within the state of the art DPOR algorithm is Context-Sensitive DPOR [4] (DPOR cs ).This algorithm exploits contextsensitive independence, which requires checking the commutativity in the current state (the context) of every two events that are in race.If they commute, the algorithm prevents the exploration of the reversed race by adding information to the sleep set.DPOR cs was built in [4] on top of Source-DPOR [1] and includes the following two main features:

62• Sleep-set extension.Sequences of processes are more expressive than single processes, thus sleep sets are generalized to contain sequences of processes.We denote this new kind of set as the don't-do set.Sequences in the don'tdo sets are ignored, as they are proven to lead to redundant exploration thanks to context-sensitive independence.

63• State equivalence check.When a reversible race e ≾ E e ′ is detected, in addition to recording the required information to ensure the race is reversed on backtracking, the algorithm also checks whether events e and e ′ are independent in the current context E, that is, whether

64If so, the corresponding don't-do set is extended with the sequence of the reversed race to avoid its exploration.

65Example 5. Let us consider the exploration of sequence q.p.p.r.r in the example of Figure 1.When DPOR cs reaches state 4, it realizes p 2 and r 1 can be regarded as independent in context q.p, as s [q.p.p.r] = s [q.p.r.p] , even though they are dependent according to the happens-before relation in [1] with the usual syntactic approximation, since p 2 writes global variable x and r 1 reads it.Hence, it adds r.p to the don't-do set of state 2 (see its lower label, which is shown in negative form, i.e., ¬r.p).

66Once r is explored, p is not executed because it is in the don'tdo set of state 6 (don't-do sets are propagated downwards in the tree by eliminating the explored process -in this case rfrom the sequence -in this case from r.p), which prevents the full exploration of q.p.r.p.r.

67As mentioned before, our first contribution is the reformulation of DPOR cs as an extension of ODPOR, rather than of Source-DPOR.This yields an optimal DPOR cs algorithm (see below), referred to as ODPOR cs , which enables the integration of the notion of observers (as done in Section 4).Reformulating DPOR cs in terms of ODPOR is challenging due to two main problems:

68• Challenge I: While Source-DPOR performs race detection at every state, ODPOR must delay race detections until the sequence being explored is complete.

69• Challenge II: As shown in [4], the effectiveness of DPOR cs is highly dependent on exploring don't-do sequences as soon as possible.Indeed, DPOR cs uses these sequences to guide the selection of the next process to be explored.However, the wakeup trees of ODPOR fix part of these decisions, which can affect guidance.

70The ODPOR cs algorithm corresponds to the full code of Algorithm 1 (both black and underlined in blue).The algorithm is discussed in detail in Sections 3.2 and 3.3, which explain how challenges I and II, respectively, have been faced.In addition, Section 3.4 proposes a refinement to the context-sensitive check of both ODPOR cs and DPOR cs that makes it potentially much more efficient in certain cases.The proofs of correctness and optimality for ODPOR cs are provided in Appendix A.

Challenge I

71Delaying race detections until the entire sequence is explored, complicates the implementation of the context-sensitive checks, as they need access to intermediate states.One could recover these states by, for example, re-executing the sequence of events to reach them, or storing them, either in full or by means of incremental state updates, to be undone on backtracking.One could also perform (part of) the checks on the fly during the exploration, instead of at the end, thus reducing the number of intermediate states needed.The preferred strategy will depend on the available memory and the concrete language features.In any case, the following assumes access to all states of the current sequence.

72The new context-sensitive check corresponds to the underlined blue code in line 28 of Algorithm 1 (for now, we use the black code for v in line 27; it will be redefined in Section 3.3).Recall that the black code of Algorithm 1 is common to both ODPOR and ODPOR ob , and was described in Section 2.2.Intuitively, given a reversible race e ≾ E e ′ for events e and e ′ , the new check succeeds if the state right after the race, s [pre + (E,e ′ )] , is the same as that obtained when the race is reversed,

73, where suc(e, E) is the subsequence w of E that starts with ê and contains all ê′′ s.t. e → E e ′′ , and w ≤ e ′ E is the subsequence of w in E of processes that execute events up to, and including, e ′ (i.e., keeps ê′′ only if e ′′ ≤ E e ′ ).As a result, the sequence E ′ .(v.suc(e, E)) ≤ e ′ E executes the same events as pre + (E, e ′ ) but with the race reversed.Assuming we have access to s [pre + (E,e)] and s [E ′ ] , we only need to compute the state after the sequence (v.suc(e,E))

74If the check succeeds and v is not redundant for E ′ , sequence v.ê is added to the don't-do set dnd(E ′ ) (line 32).Note that, unlike in the original DPOR cs , v contains the processes of events executed after e ′ in E, that do not happen-after e and, thus, neither happen-after e ′ .This issue is further discussed in Section 3.3.

75As in the original DPOR cs , if a sequence w is added to the don't-do set of state s, w can be inherited down once we backtrack to s, possibly being reduced until it eventually becomes a unitary sequence and the exploration stops (referred to as a don't-do set blocked exploration).In that case, race detection must be forced explicitly.This is the task of the new if statement in lines 15 and 16.Similarly, if every process enabled in s [E] is also in dnd(E) for sequence E, then the exploration of E stops and race detection is forced explicitly, in this case for every unitary sequence in dnd(E) (lines 7, 8 and 9).The support to inherit down don't-do sequences is the same as in the original DPOR cs , corresponding to lines 19 and 20.Essentially, E.p inherits each sequence v where p.v ∈ dnd(E) (line 20), and where every process in v (line 19) is independent of p in E (denoted as E | = p ⋄ v), i.e, where the event in dom [E] (p) does not happen-before any event in dom [E.p] (v).

St. Cause

76Effects 5 p 2 ≾ E r 1 and s [q.p.p.r] = s [q.p.r.p] r.p added to dnd(q.p) 5 q 1 ≾ E p 2 and s [q.p.p] s [p.p.q] -6 p ∈ dnd(q.p.r) ⇐ r.p ∈ dnd(q.p)Pruning P1 10 q 1 ≾ E r 1 and s [q.p.r] = s [p.r.q] p.r.q added to dnd(ϵ) 15 q 1 ≾ E r 1 and s [p.p.q.r] = s [p.p.r.q] r.q added to dnd(p.p)16 q ∈ dnd(p.p.r) ⇐ r.q ∈ dnd(p.p)Pruning P2 20 p 2 ≾ E r 1 and s [p.p.r] = s [p.r.p] r.p added to dnd(p)

77Pruning P3 21 q ∈ dnd(p.r)⇐ r.q ∈ dnd(p)

78Pruning P4 nodes that are not explored and hence are pruned by ODPOR cs .

79Sequences starting with ¬ in parenthesis should be ignored by now.In the following we explain the most relevant additional actions that ODPOR cs performs w.r.t ODPOR, some of which lead to the above-mentioned prunings.Figure 4 lists such actions, showing, for each of them, the state, the cause (i.e. the result of the context-sensitive check or the inherited sequence in the don't-do set, where ⇐ should be read as "inherited from") and the effects of the action (i.e. the updates on don't-do sets or the pruning carried out).

80In the invocation to RaceDetection at state 5, i.e., after exploring sequence q.p.p.r.r, for the race between p 2 and r 1 , the new context-sensitive check at line 28 checks if s [q.p.p.r] = s [q.p.r.p] .Since the check succeeds r.p is added to dnd(q.p)(lines 29 and 32).Also at state 5, for the race between p 2 and q 1 , ODPOR cs checks whether s [q.p.p] = s [p.p.q] , but this time the check fails and, hence, nothing is added to dnd(ϵ).

81When backtracking to state 2 with r, sequence r.p in dnd(q.p) is inherited down as p in dnd(q.p.r) (line 20).This causes the pruning of box P1.At state 6, r is chosen to be explored, because p is in dnd(q.p.r).p is then removed from dnd(q.p.r.r) in line 19 since p 2 and r 1 are dependent (i.e., we do not have q.p.r | = p ⋄ r).The algorithm fully explores sequence q.p.r.r.p and then invokes again RaceDetection at state 10.For the reversible race between q 1 and r 1 , the check s [q.p.r] = s [p.r.q] succeeds and, hence, p.r.q is added to dnd(ϵ).

82The race between r 2 and p 2 causes the addition of p to wut(q.p.r).Hence, when the algorithm backtracks to state 6, and since p is both in wut(q.p.r) and dnd(q.p.r), RaceDetection is explicitly invoked (lines 15 and 16), though this time nothing new is added to any wakeup-tree nor any don't-do set.

83ODPOR cs then fully explores sequence p.p.q.r.r and invokes RaceDetection at state 15.For the race between r 1 and q 1 the algorithm checks whether s [p.p.q.r] = s [p.p.r.q] , and since the check succeeds r.q is added to dnd(p.p).This causes the pruning of box P2.The algorithm then backtracks to state 12 with r, explores sequence p.p.r.r.q and invokes RaceDetection at state 20.For the race between r 1 and p 2 the algorithm now checks whether s [p.p.r] = s [p.r.p] , and since the check succeeds r.p is added to dnd(p) (which already had r.q in it).

84The algorithm then backtracks to state 11 with r.It inherits down r.p and r.q to state 21 as p and q respectively, hence forcing it to select process r at state 21, causing the prunings of P3 and P4.Finally, sequences p.r.r.p.q and p.r.r.q.p are explored as in ODPOR.

85Overall, ODPOR cs has explored 6 executions (instead of the 12 explored by ODPOR), plus the additional explorations that need to be computed by the new context-sensitive checks.

Challenge II

86To illustrate this challenge, let us consider the processes p and q from our running example, and the initial exploration E 1 = t.t′ .p.p.q, where t is a process defined as t : z = 1; and t ′ is another instance of the same process t.Let us assume, for now, that ODPOR cs uses the original definition of sequence v (line 27), that is, v = notdep * (e, e ′ , E). ê′ .For the reversible race between p 2 and q 1 , ODPOR cs adds q to wut(t.t′ .p).Hence, upon backtracking to t.t ′ .p, it will explore E 2 = t.t′ .p.q.p.For the reversible race between t 1 and t ′ 1 , ODPOR cs sets v to p.p.q.t ′ (since all p 1 , p 2 and q are independent of t 1 , and also of t ′ 1 ) and adds it to wut(ϵ).Also, since s [t.t ′ ] = s [t ′ .t], it adds p.p.q.t ′ .t to dnd(ϵ).Later, when backtracking to ϵ and exploring p.p.q.t ′ , sequence t ′ .t is inherited down to dnd(p.p.q), which in turn causes t to be inherited down to dnd(p.p.q.t ′ ), causing the exploration to stop and the race-detection phase to start (line 16) for p.p.q.t ′ .t.This detects a race between p 2 and q 1 , causing the exploration of t ′ .t.p.q.p, which is redundant to E 2 (as

87Such a redundant trace would not have been explored by DPOR cs .This is because DPOR cs (as well as Source-DPOR and the original DPOR) does not record the sequence to be explored upon backtracking but, rather, an initial event to explore plus the sequences that should not be selected (by means of the so called backtrack-set and sleep-set).This allows using don't-do sequences to guide DPOR cs decisions regarding what to explore, achieving earlier and more effective contextsensitive prunings.However, wakeup trees are essential for ODPOR to achieve optimality.Therefore, the challenge is to determine whether it is possible to keep optimality, while at the same time being able to exploit don't-do sequences at least as effectively as DPOR cs .

88In order to reverse race e ≾ E e ′ , it suffices to have all ancestors of e ′ before it.Let us then re-define notdep * (e, e ′ , E) as ance(e, e ′ , E), the subsequence of E containing the processes whose events occur after e and happen-before ê′ (and thus, are independent with e, since otherwise e and e ′ would not be in race).This solves the problem in the above example: for the race between t and t ′ in E 1 , the sequences added to wut(ϵ) and dnd(ϵ) would be t ′ and t ′ .t,respectively.However, it is not enough since, in order to achieve optimality, v needs to include part of the processes of E whose corresponding events are independent with the ones in v, thus being detected as redundant in line 28.Let us define the set of future initials, written I fut (E ′ , v, E), that contains any process with no "happensbefore" predecessors in dom

89such that e ′ → E e).Indeed, the future initials are also required in sequence v, so that when an exploration is stopped by a don't-do sequence (line 16), the corresponding race detection phase has enough information to build the appropriate sequences for each detected new race.As a result, we redefine v as notdep * (e ′ , e ′ , E). ê′ .I fut (E ′ , v, E) (line 27) with notdep * (e, e ′ , E) = ance(e, e ′ , E).In the example above, for the race between t and t ′ in E 1 , the new sequences added to wut(ϵ) and dnd(ϵ) are t ′ .pand t ′ .p.t, respectively.

A More Efficient Context-Sensitive Check

90As explained above, for any given race, the state equivalence check of ODPOR cs (and DPOR cs ) compares the state of the current execution sequence right after the race (pre + (E, e ′ )) against that of an alternative sequence that executes the same events but with the race reversed.To ensure this, such an alternative sequence includes, after the reversed race, events that are not related to the race, namely suc(e, E) ≤ e ′ E .The computation of these alternative sequences may produce an overhead on the ODPOR cs (and DPOR cs ) algorithm.Therefore, we would like to make them as efficient as possible without compromising the effectiveness of the prunings performed due to the contextsensitive checks.

91To illustrate this, let us consider the process p from our running example, a new process t defined as t : y = 1 and an initial exploration E 1 = p.p.t.For the race between p 1 and t 1 the state equivalence check compares the states for E 1 and E 2 = t.p.p and succeeds.We can observe that in E 2 the second step of p

92) is completely unrelated to the race between p 1 and t 1 but it has been added to ensure both E 1 and E 2 have the same events.Indeed, if we take it out from E 2 the check would fail, i.e. s [p.p.t] s [t.p] .However, if the check would focus only on the variables (memory addresses) which are involved in the race, in this case variable x, then the check will succeed even with the shortened sequence t.p.

93To illustrate the potential impact this improvement may have in the algorithm, let us consider a generalization of the above pattern with a process p ′ : f or(i = 0; i < n; i++) a[i] = 0; that initializes the first n elements of an array a, a process t ′ : a[0] = 0; that simply writes on the first position of the array, and the initial exploration E ′ 1 = p ′ .p′ . . . .p ′ .t′ (where all steps of process p ′ are executed before process t ′ ).For the race between p ′ 1 and t ′ 1 the state equivalence check would compare the states of E ′ 1 and E ′ 2 = t ′ .p′ .p′ . . . .p ′ and succeed.Here we can observe the potential overhead that we may have in the computation of E ′ 2 .The proposal is to take out from E ′ 2 the events that are not related to the race, hence considering instead E ′ 2 = t ′ .p′ , and make the state equivalence check focus only on variable a[0], otherwise the check would fail.

94To accomplish this, we rewrite line 27 of Algorithm 1 as:

95where suc(e, E) ≤ e ′ E has been taken out from the sequence of the right-hand side, and V e,e ′ E added on top of the equality, indicating the equality is checked on the subset of variables V e,e ′ E , which is defined as follows.Let W E (e) and W E ({e 1 , . . .e n }) denote the set of variables (memory addresses) written in execu-tion E by event e and by the set of events {e 1 , . . .e n }, respectively.Let I e E (x) be the set of variables written by event e in execution E whose written value has been affected by variable x.We use Ē to denote the alternative sequence including event e, that is, E ′ .(v)≤ e ′ E .ê,where E ′ and v are as defined in lines 26 and 27 of Algorithm 1.We define the set of variables involved in a race between e and e ′ in execution E, written V e,e ′ E , as:

96( x∈W E (e) I e ′ E (x)) ∪

97(2)

98(W E ({e, e ′ }) \ W Ē ({e, e ′ })) ∪

99(W Ē ({e, e ′ }) \ W E ({e, e ′ }))

100The first term, labeled (1), includes the variables that are written in both events.The second and third terms include, for the original and the alternative executions E and Ē respectively, the variables written by the second event in the race whose written value has been affected by a variable written in the first event of the race in the corresponding execution.Finally, the fourth and fifth terms include the variables that are written by either e or e ′ in one of the executions that are not written by e nor e ′ in the other execution.• Consider e : x = 1; and e ′ : x = 2;.Since variable x is involved in a race between e and e ′ , it should be included in V e,e ′ E .This is captured by term (1).• Consider e : x = 1; and e ′ : y = x;.In this case term

101(2) produces {y} since the value written to y depends on whether e is executed before or not.The other terms produce the empty set.We hence get V e,e ′ E = {y}.

102• Consider e : i = 1; and e ′ : v[i] = 1; with an initial state where i = 0. Term (4) produces {v[1]} whereas term (5) produces {v[0]}.The other terms produce the empty set.We hence get V e,e ′ E = {v[0], v [1]}.If we instead consider an initial state with i = 1, we would get V e,e ′ E = {} since in this case both executions write v [1] with a value that does not depend on event e.If we consider e ′ : v[i] = i; (with initial state i = 1) then term (2) would produce {v [1]} since the written value now depends on event e.

103Note that in the case of assertion statements, the result of an assertion is assumed to be written to a memory address and thus it is included in the W and I sets.For instance, consider events e : x = 1; and e ′ : assert x > 0; with execution sequence E = e.e ′ .The result of the assertion is obviously involved in the race between e and e ′ and should be included in V e,e ′ E .This is captured by term (2) since the memory address where the result of the assertion is written to is assumed to belong to I e ′ E (x).The rest of the terms produce the empty set in this case.

Correctness and Optimality

104The following theorem ensures the soundness of our ODPOR cs extension.

105Theorem 1 (Soundness of ODPOR cs ).For each Mazurkiewicz trace T defined by the happens-before relation, Explore(ϵ, ⟨{ϵ}, ∅⟩, ∅) of Algorithm 1 explores a complete execution sequence that either implements T , or reaches an identical state to one that implements T.

106The optimality of ODPOR cs with respect to the Mazurkiewicz traces based on the context-sensitive notion of independence is in general not guaranteed, since it only detects certain cases of context-sensitive independence.However, it has analogous optimality results as the ODPOR algorithm (i.e., for the Mazurkiewicz traces based on the notion of independence of [1]): if ODPOR cs explores a don't-do set blocked execution E, then ODPOR explores completely an execution with the same happens-before relation than E.

107Theorem 2 (Optimality of ODPOR cs ).Algorithm 1 never explores two complete execution sequences that are equivalent, and never initiates redundant executions.

108The proofs of the above theorems can be found in Appendix A.

Optimal Context-Sensitive DPOR with Observers

109This section presents Optimal Context-Sensitive DPOR with Observers (ODPOR ob cs ), our new DPOR algorithm that not only combines and exploits the notions of context-sensitive independence and observability, but also takes advantage of their synergy to gain further pruning.First, Section 4.1 recalls the formal notion of observability and the Optimal DPOR with Observers (ODPOR ob ) algorithm of [9].Then, Section 4.2 presents the basic ODPOR ob cs algorithm that simply joins the ODPOR ob and ODPOR cs algorithms.Sections 4.3 and 4.4 present two enhancements that exploit the combination and the synergy between the notions of context-sensitive independence and observability.Finally, Section 4.5 studies the soundness of the enhanced ODPOR ob cs algorithm.

Optimal DPOR with Observers

110The notion of observability [9] allows dependencies between execution events to be conditional to the existence of later events called observers.The typical example in the context of programs with shared variables occurs when there are two events e and e ′ that write over the same variable, but the written value is not later read or observed.In such a case the idea is not to consider the two events as interfering and, hence, e does not happen-before e ′ .The intuition behind this approach is that only operations that observe a value (e.g.assertions or receives) can influence the control flow and lead to erroneous or unexpected behaviors, whereas other operations (e.g., writes or sends) cannot affect program behaviour if no future operation observes their effects.

111Again, as in [1], in order not to restrict to any specific computation model, Aronis et.al. [9] assume the existence of a happens-before assignment function that assigns a happensbefore relation to any execution sequence.The precision of such function can vary as long as it satisfies a set of properties, which relax those of [1] in order to consider the notion of observability.Let us recall the new properties related to the notion of observability.

112Definition 1 (observers(e, e ′ , E) [9]).Given an execution sequence E, and any two events e, e ′ ∈ dom(E) where e ⋖ E e ′ , there exists a set O = observers(e, e ′ , E) ⊆ dom(E) such that: 4. For every prefix E ′ of E such that e, e ′ ∈ dom(E ′ ):

5.

113If e≾ E e ′ , for all sequences w s.t.E.w is a sequence, and all events e ′′ ∈dom(E):

114• If e ↛ E e ′′ , then e ⋖ E.w e ′′ .

115• If e ′′ ↛ E e ′ , then e ′′ ⋖ E.w e ′ .6.For all e ′′ ∈dom(E) such that e ′ → E e ′′ , it holds that O ∩ observers(e ′ , e ′′ , E)=∅. 7. If O = {o} and E = E ′ .ô for some o and E ′ , then for any

116Intuitively, in the usual particular case of variable reads and writes, observers(e, e ′ , E) is the set of other events in E, independent of each other (by Property 2), that read the value written by e (e ′ ) for any variable also written by e ′ (e) (by Property 4).By an abuse of notation, we will sometimes treat this set as a sequence.

117From this point on, the presented algorithms will rely on such a generic happens-before assignment, i.e., one that considers observability and satisfies the above properties.In the examples we will continue to assume a concrete happens-before assignment based on the traditional approximation of dependency for programs with shared variables, extended to consider observability as follows.Two events p and q are considered dependent modulo observability if: (i) one enables the other, or (ii) one writes over a variable that the other reads, or (iii) both write over a variable that is later read by an observer.

118Example 8. Let us consider sequence E 1 = q.p.p.r.r.We have q 1 → E 1 p 2 since event r 1 is an observer of the race.However, event r 2 is not an observer in spite of reading variable x.This is because of Condition 2 of Definition 1 (r 1 is already an observer).On the other hand, r 2 is an observer of the race between q 1 and p 2 in sequence E 2 = p.r.q.p.r and hence we have q 1 → E 2 p 2 .Finally, in sequence E 3 = p.r.r.p.q we have p 2 ↛ E 3 q 1 since there is not an observer after them that reads the written value on variable x.

119The ODPOR ob algorithm of [9] corresponds to the code in black of procedure Explore of Algorithm 1 (excluding underlined blue parts) and the new RaceDetection procedure of Figure 5 with the original definition of notdep * of Section 2.2.Apart from the new happens-before assignment, the new support for handling observers corresponds to lines 4-6 of Figure 5. wut(E ′ ) := insert [E ′ ] (v, wut(E ′ )); Specifically, if the race between e and e ′ is observed (line 4), the race must be reversed and observed by the same observers.Thus, the last (max E ) observer o executed in E is selected (line 5) and used to compute v (line 6), where notobs * (e, e ′ , E)2 denotes the subsequence of E containing any process ê′′ such that e → E e ′′ , but e ′′ does not observe the race e ≾ E e ′ , and o ′ ↛ E e ′′ for any observer o ′ of the race.There is a small change in line 5 with respect to [9]: we select o as the last (rather than an arbitrary) observer from observers(e, e ′ , E).The reason for this will be clear in Section 4.3.

120Example 9.The exploration of ODPOR ob on our working example proceeds exactly the same as that of ODPOR (see Example 4) until state 34.This is because all write-write races until this point have a subsequent observer that reads the written value.As an example, see sequences E 2 and E 3 of Example 8.However, after exploring sequence p.r.r.p.q at state 34, ODPOR ob does not consider a race between p 2 and q 1 (since there is not a later observer) and hence it does not backtrack to state 32 to explore p.r.r.q.p (pruning P5 of Figure 1).Note that while the final value of variable x in these sequences is different (x = 1 vs. x = 2), ODPOR ob considers that this does not affect the program behavior, as the value is not read later.

The Basic "Union" Algorithm

121The ODPOR cs and ODPOR ob algorithms of Sections 3 and 4.1 can be combined simply by joining their codes together, that is, the code of procedure Explore of Algorithm 1 (including underlined blue parts) and the new RaceDetection procedure of Figure 5, adding the underlined blue code of the RaceDetection of Algorithm 1, including the enhancements of Sections 3.2, 3.3 and 3.4 and relying on the happens-before relation of Section 4.1.The exploration performed by such a "union" algorithm would be the intersection of the explorations of ODPOR cs and ODPOR ob , and its prunings the union of the ODPOR cs and ODPOR ob prunings.

122Example 10.In our working example such basic "union" algorithm proceeds as the ODPOR cs algorithm until state 34 and then, as ODPOR cs (see Example 9), it does not backtrack to state 32 to explore p.r.r.q.p.It is hence able to avoid the exploration of the states in boxes P1, P2, P3, P4 and P5 of Figure 1.

123This "union" algorithm can be seen in Algorithm 2, if we ignore the code underlined in red (which corresponds to the enhancements of Sections 4.3 and 4.4) and we take lines 76, 77 and 78 outside the scope of the else (as explained in Section 4.3).These modifications to the "union" algorithm are performed to exploit the synergy between the notions of contextsensitive independence and observability.The resulting algorithm is ODPOR ob cs .

124Algorithm let WuT ′ = subtree(wut(E), p);

125] then 78:

126dont := v.ê;

127add dont to dnd(E ′ );

1284.3.Refining the Context-Sensitive Check for Write-Write Races Consider again the race detection phase on our running example of Figure 1 after exploring sequence q.p.p.r.r.The "union" algorithm finds a reversible race q 1 ≾ E p 2 observed by r 1 .After setting v to p.p.q.r in line 71, the check s [q.p.p] = s [p.p.q] in line 77 fails (recall this line is temporarily assumed to be outside the else scope).Hence, nothing is added at this time to dnd(ϵ) and p.p.q.r is added to wut(ϵ).Interestingly, sequence p.p.q.r.r is equivalent to the already explored q.p.p.r.r from the point of view of the observer r 1 .I.e., although the value of variable x is different, the assert executed by r 1 holds in both cases.Note that this is not the case for the assert of r 2 (it holds in q.p.p.r.r but it does not in p.p.q.r.r), but since it is not an observer (due to Condition 2 of Definition 1) it does not need to be considered in this sequence (see Example 8).

129It thus seems natural in this case to perform an enhanced context-sensitive check that compares the states modulo observability, e.g., compares s [p.p.q.r] and s [q.p.p.r] only considering the effect of the observation performed by r 1 .Since in both cases it has the same effect (the assert holds), p.p.q.r could be added to dnd(ϵ), thus stopping the exploration of the fourth derivation at state 13.More precisely, given a race e ≾ E e ′ observed by o, we say that two states s and s ′ are equivalent modulo observability, written s W E (o) = s ′ (following the notation of Section 3.4), if the variables that are written by o have the same values in s and s ′ .Let us recall that in the case of observers with assertion statements, the result of the assertion is assumed to be written to a memory address and thus included in the W E (o) set.In the example above with E = q.p.p.r.r, the equality between s [p.p.q.r] and s [q.p.p.r] is performed only looking at the result of the assertion in r 1 .

130The implementation of the refined check corresponds to the underlined red code in lines 72, 73 and 74 of Algorithm 2. First, it sets o s to the subsequence of observer processes observers(e, e ′ , E).Then, after extending v with the required processes (see explanation below), it checks that for every observer process o ′ in o s (this time treated as a set), the state after executing o ′ is equivalent modulo observability to the state obtained by the alternative sequence E ′ .v≤ o E .(ôs \ ô), which contains the reversed race, followed by observer o and the remaining observers.

131As with the original context-sensitive check (see Section 3.3), in order to be effective, it is important not to include in v unnecessary processes before the reversed race, while at the same time including at the end those that are necessary to keep optimality.The solution is analogous to that of Section 3.3.First, unnecessary processes are taken away from sequence v (line 71).In particular, notdep * inherits the redefinition of Section 3.3, and notobs * (e, e ′ , E) is redefined as the subsequence of processes of E, excluding the occurrence e, whose events happen-before those in observers(e, e ′ , E).Finally, to ensure optimality, v is extended with I fut (E ′ , v, E) (line 71), to ensure it has enough information to detect redundancies.

132Note that all the predecessors of other observers are in v ≤ o E , thanks to the choice of o as max E (observers(e, e ′ , E)).Thus, we can execute ôs \ ô ( ô is already in v) without problem after E ′ .v≤ o E .Note also that we cannot use s [pre + (E,o)] to perform all the checks because, after every o ′ ∈ o s has been executed, there may be another event e ′′ < o ∈ E such that o ′ → E e ′′ , which would invalidate the check by modifying the value of the variables used in the check.That is why we use s [pre + (E,o ′ )] for each o ′ ∈ o s to perform each check in line 73.Another possibility, which could be more efficient in certain contexts (and does not require accessing these intermediate states), would be to perform all the checks with the state s [notdep * (e,e ′ ,E).ê.ê′ .(notobs* (e,e ′ ,E)\{ê}).ôs ] , where the race between e and e ′ has not been reversed.

133The following provides the intuition behind the need to consider every observer o ′ ∈ observers(e, e ′ , E) for the new check, rather than just the selected one o.Consider our running example with a simple modification: the instruction assert(x < 2); is executed by a different process r ′ , enabled from the initial state.Let the sequence E = q.p.p.r.r ′ be the initial exploration of the algorithm.For the race between q 1 and p 2 we have that observers(q 1 , p 2 , E) = {r 1 , r ′ 1 }.Let us assume the algorithm selects o := r.If the new check only considers event o 1 (instead of every o ′ ∈ o s ), the check succeeds (the assert holds in both cases) and, hence, p.p.q.r is added to dnd(ϵ).This would prevent the exploration of sequence p.p.q.r.r ′ (where the assert of r ′ 1 does not hold) which is not equivalent to any previously explored sequence.In this concrete example, this does not cause us to lose any different final result (the assert of r ′ 1 also fails in other combinations).However, this would not be the case in an example where the only possibility for the assert of r ′ 1 to fail would be to execute it after q.p.p.

134Note that the new enhanced check is only applied in the case of write-write races followed by an observer (i.e. when the algorithm enters the if of line 69) and that it can only be more precise than the original check.That is why in the final algorithm, the code of lines 76, 77 and 78 goes within the else scope, hence replacing the original check for the case of writewrite races.For races that are not observed, the original check is still applied in lines 77 and 78.

135Example 11.Let us consider the exploration performed by ODPOR ob cs on our running example of Figure 1 (recall that fragments in all boxes are pruned by ODPOR ob cs ).In the invocation to RaceDetection at state 5, i.e., after exploring sequence q.p.p.r.r, for the write-write race between q 1 and p 2 , the new enhanced context-sensitive check of line 73 only checks if the result of the assertion of r 1 is the same in both s [q.p.p.r] and s [p.p.q.r] (since we have observers(q 1 , p 2 , q.p.p.r.r) = {r 1 }), ignoring the value of variable x which is different.Since the check succeeds p.p.q.r is added to dnd(ϵ).This causes the pruning of box P6.The rest of the exploration proceeds as the "union" algorithm (see Example 10).Note that the enhanced check is also executed in the call to RaceDetection at state 24, i.e., after exploring sequence p.r.p.q.r, for the write-write race between p 2 and q 1 , but this time it fails since the assert of observer r 2 fails after p.r.p.q.r (where x = 2) but instead it succeeds in p.r.q.p.r (where x = 1).

Refining the Inheritance of Don't-Do Sequences

136One could expect that whenever a sequence w is added to a dnd(E ′ ) set of sequence E ′ due to the new refined check, a prefix of w be also added to wut(E ′ ).Indeed, if the refined check of line 73 succeeds, sequence v.( ôs \ ô) is added to dnd(E ′ ), and sequence v is inserted to wut(E ′ ).However, it is possible for the later sequence not to be added to wut(E ′ ) if it already contains an equivalent sequence (which had been added before).In such cases, the dnd sequence might not be propagated successfully during the exploration of the corresponding sequence in wut(E ′ ), resulting in unnecessary exploration.

137Example 12. Let us consider our running example but replacing process r by r : o = x; and exploring first sequence E 1 = p.q.q ′ .p.r, where q ′ is another instance of the same process q.For the race between q 1 and p 2 , the refined check builds the alternative sequence p.q ′ .p.q.r (note that q ′ happensbefore q in E 1 ).The obtained observation is o = 2, whereas in the original E 1 it was o = 1, hence q ′ .p.q.r is added to wut(p) but not to dnd(p).The algorithm explores four more sequences before backtracking to the root, including sequence E 2 = p.q.p.q ′ .r.In this case, for the race between q and q ′ , the refined check builds the alternative sequence p.p.q ′ .q.r (note that p happens-before q ′ in E 2 ).The obtained observation both in E 2 and p.p.q ′ .q.r is o = 2. Hence, p.q ′ .q.r is added to dnd(p) but not to wut(p), since it is equivalent to q ′ .p.q.r, which was added before.The propagation of dnd sequences in Algorithm 1 (underlined blue code of lines 19 and 20) is not able to propagate down p.q ′ .q.r when exploring q ′ .p.q.r, even though they are equivalent sequences.

138The refined propagation allows us to generalize the previous propagation of dnd sequences, which can be seen in the underlined red code of line 62 of Algorithm 2. Essentially, a sequence u.p.v will now be propagated as u.v, if p is independent of all processes in u.In addition, the new case can take advantage of observability using the information of the trace E ′ .u.p.v.We define E | = u.q.p.v q⋄ p if E.u | = q⋄ p, (i.e., they are unconditional independent), or ∃ ŵ ∈ v, such that the set of variables written both by p and q is overwritten by w and ∀r ∈ v that observes any of these variables, w < E.u.q.p.v r.Intuitively, this refined propagation allows transitively propagating equivalences between the dnd set and the WuT of a state.

139In the case of Example 12, when backtracking to p to explore q ′ .p.q.r, the sequence p.q ′ .q.r in dnd(p) is propagated down to dnd(p.q′ ) as p.q.r.This allows detecting p.q ′ .p.q.r as redundant.Indeed, p | = p.q ′ .q.r p 2 ⋄ q ′ 1 in p.q ′ .q.r since r 1 is not observing their effect (it observes the subsequent write q 1 ), whereas they would be dependent with the traditional notion of dependency.

140Let us finally point out that this refinement is also applicable to the ODPOR cs algorithm of Section 3.1, and also to the original DPOR cs algorithm of [4], although in these contexts it would be much less likely to be applied.

Correctness and Optimality

141The theorem for ODPOR ob cs is analogous to the one in Section Appendix A, but using the definition of equivalence modulo observability, introduced in Section 4.3.

142Theorem 3 (Soundness of ODPOR ob cs ).For each Mazurkiewicz trace T defined by the happens-before relation, Explore(ϵ, ⟨{ϵ}, ∅⟩,∅) of Algorithm 2 explores a complete execution sequence that either implements T , or reaches an equivalent state modulo observability as one that implements T.

143Theorem 4 (Optimality of ODPOR ob cs ).Algorithm 2 never explores two complete execution sequences that are equivalent.

144The proofs of the above theorems can be found in Appendix B.

Experiments

145This section reports on our experimental comparison of the performance of ODPOR [1], ODPOR ob [9], DPOR cs [4] and our proposed ODPOR cs and ODPOR ob cs .The major part of the experiments are performed using the Nidhugg tool [23], a stateless model checker for shared-memory pthreads programs written in C/C++ that operates by interpreting the LLVM intermediate representation.It is important to note that Nidhugg was developed and it is maintained by some of the authors of [1] and [9], and it is indeed used in the experimental evaluation of [9].It therefore includes implementations of the ODPOR and ODPOR ob algorithms.Our experimental evaluation has hence required the implementation and integration within the Nidhugg framework of the DPOR cs , ODPOR cs and ODPOR ob cs , as well as the implementation of the support to handle atomic blocks.

146We also use the SYCO tool [6], a systematic testing tool for message-passing concurrent programs written in the ABS modeling language [17], for the two largest benchmarks of [5] which were unsuitable to be translated into C/C++.

Goals of the Experimental Evaluation

147The goals of our experimental evaluation are the following:

148G1 Study the overall effectiveness in terms of scalability of ODPOR cs and ODPOR ob cs w.r.t ODPOR, DPOR cs and ODPOR ob .We expect cases where ODPOR ob cs produces exponential reductions over ODPOR ob and behaves similarly to DPOR cs and ODPOR cs (G1a), cases where it produces exponential reductions over DPOR cs and ODPOR cs , and behaves similarly to ODPOR ob (G1b), and, cases where it produces exponential reductions over all DPOR cs , ODPOR cs and ODPOR ob (G1c).We also expect cases where ODPOR ob cs may behave worse than either DPOR cs or ODPOR ob due to the overhead of either the observers or the context-sensitive part whenever it is not effective (G1d).Overall, we expect that ODPOR ob cs will often outperform or, at least, scale similarly than the best of the other algorithms.As regards ODPOR cs , we expect it to perform essentially equivalent to DPOR cs for most benchmarks (G1e).An explanation for this is found below in Section 5.3.G2 Observe the potential overheads that both the contextsensitive part (G2a) and the observers part (G2b) of the algorithm may produce.

149G3 Study the effectiveness of the context-sensitive check refinements of Sections 3.4 and 4.3.

Description of the Experiments

150We have used three sets of benchmarks: The first one is a subset of the classical concurrent programs used in [4] to compare Source-DPOR and DPOR cs .They feature typical distributed and concurrent algorithmic patterns, in which computations are split into smaller atomic subcomputations that concurrently interleave their executions, and work on shared data.Our set includes three concurrent sorting algorithms (pipesort, mergesort and quicksort), a distributed workers algorithm (pi), a concurrent fibonacci algorithm (fib), and a producer-consumer algorithm (boundedbuffer).

151Our second set of benchmarks contains the synthetic programs used in [9] to compare ODPOR and ODPOR ob and some variations of them.Benchmarks lastwrite, floatingread and lastzero correspond to benchmarks of the same name in [9], and abs corresponds to the running example of [9]'s figure 1 generalized for n processes.Benchmarks ending with -2phases and -dif are variations of the above for the corresponding prefix.Specifically, the -2phases variations perform 2 repetitions of the code pattern in each process so that potential exploration reductions can be better observed.The -dif variations write different values to all shared variables, hence context-sensitive checks cannot take advantage of context-sensitive dependencies.That allows us to reason about the worst-case scenario for the context-sensitive part of the algorithms.We also include in this second set arraywrite, a synthetic benchmark to illustrate the potential impact of the refined check of Section 3.4, which consists of 4 * N processes writing an N-array and two processes reading the first two positions.

152Each benchmark is executed for a series of increasing input parameters in order to observe the impact of the reductions and overheads on bigger explorations.Tables 1 and 2 show the results of the executions of ODPOR, ODPOR ob , DPOR cs and ODPOR ob cs for the first and second set of benchmarks respectively.The results for ODPOR cs are not shown in the tables since they are basically the same as those of DPOR cs .Column LE/LT shows the length of the longest execution sequence in terms of execution steps (LE) and the length of the longest trace in terms of LLVM instructions (LT ).Note that such a longest execution sequence and corresponding trace is the same on every algorithm.This gives an idea on the complexity and depth of the exploration which is carried out.Also, the difference between the LE and LT values on a given exploration provides an indication on the length of the atomic blocks of the benchmark (the bigger the difference the longer the atomic blocks).Columns labeled with E show the number of finished execution sequences whereas those with T show the time in seconds of the whole exploration.Times are obtained on an Intel(R) Core(TM) i7 CPU at 2.5Ghz with 8GB of RAM (Linux Kernel 5.4.0).Columns G cs−ob cs and G cs−ob ob show the time speedup of ODPOR ob cs over DPOR cs and ODPOR ob , respectively, computed by dividing their respective times by that of ODPOR ob cs .A timeout of 150 seconds is set.When reached, we write -, except for the speedups of the first input for which the timeout is reached, in such case we write >X to indicate that the speedup would be X if the process finishes right in the timeout, and hence it is guaranteed to be greater than X.Finally, our third set of benchmarks (Table 3) are run within the SYCO tool and include two larger programs implemented in the ABS modeling language using active objects and messagepassing: MapRed, an implementation of a map-reduce model developed by a company (440 lines of code); and SDN [8], a model of a software-defined network featuring a safety policy violation (490 lines).

Analysis of the Results

153We have confirmed that ODPOR cs performs basically equivalent to DPOR cs (goal G1e).The number of finished execution sequences is exactly the same for all benchmarks.The execution time is also basically the same with a very slight overhead (of at most 4%) due to the handling of the wakeup trees.An exception for this is the lastzero benchmark where ODPOR cs outperforms DPOR cs (e.g., for N = 6, ODPOR cs takes 0.24s vs. the 0.34 of DPOR cs ).It is already shown in [1] that even though optimality provides a very relevant and strong theoretical result, it is difficult to find examples where ODPOR produces significant improvements in practice over Source-DPOR.The lastzero benchmark is indeed the only case where this happens in [1].Note also that the primary goal of the development of ODPOR cs is to serve as an intermediate and necessary step towards the development of our finally proposed algorithm which is ODPOR ob cs .

154Looking at the results on our first set of benchmarks (see Table 1) we clearly observe that ODPOR ob cs always outperforms or behaves similarly to the best of the other algorithms (goal G1).For instance, in pipesort we observe that ODPOR ob and DPOR cs both feature exponential reductions over ODPOR and that ODPOR ob cs is able to produce exponential reductions over both of them (goal G1c).This is due to the benefits of combining the orthogonal reductions of ODPOR ob and DPOR cs and, also to the synergy of the combination (namely the refinement of Section 4.3) (goal G3).In quicksort, mergesort, fib and boundedbuffer we can observe that ODPOR ob performs almost identically to ODPOR since there are no observers to take advantage of.We also observe exponential reductions of both DPOR cs and ODPOR ob cs over both ODPOR and ODPOR ob due to context-sensitive dependencies (goal G1a).We can hence observe the overhead of the observers part of the algorithms in isolation (goal G2b) which is very low (see e.g. the times of ODPOR ob cs versus those of DPOR cs ).

155In pi we have a different situation.We observe exponential reductions of both ODPOR ob and DPOR cs w.r.t ODPOR indicating there are both observers-based independences and also context-sensitive independences.In this case, the combination of the reductions due to both kind of independences produced by ODPOR but, interestingly, not over DPOR cs , which behaves similarly to ODPOR ob cs (goal G1).This indicates that the prunings performed by ODPOR ob are in this case a subset of those produced by DPOR cs , hence joining them does not produce an improvement over the best of both algorithms (here DPOR cs ).

156In the second set of benchmarks (see Table 2) we can observe exponential reductions in the number of finished executions in ODPOR ob cs w.r.t all ODPOR, DPOR cs and ODPOR ob .Note that ODPOR ob cs is able to catch all redundant executions hence obtaining only 1 finished execution.Again, that is possible both due to the combination of ODPOR ob and DPOR cs and, also to the new refined check of Section 4.3 (goal G3).However, such a reduction over ODPOR ob does not have a direct correlation to a corresponding reduction in time in neither lastwrite nor floatingread nor abs.This indicates that the overhead of the context-sensitive part of the algorithm does not pay-off in these cases, mainly because the reductions are being done at the very end of the executions and hence few states are being pruned (goal G1d).This can indeed be observed looking at the results we get in the -dif variations of the benchmarks where the variable writes are all done with different values, hence making all context-sensitive checks to fail.We observe that in these cases ODPOR ob cs performs similar, and even better, as it does with the original benchmarks in terms of exploration time, clearly indicating that the prunings being made are not saving exploration effort.This is because of the overhead due to the handling and inheritance of the don't-do sets, which in the case of the -dif variations is not produced since there are no don't-do sets to be handled (goal G2a).

157Although it is not shown in the tables (in order not to overload them with more data) we are also measuring the number of executions which are cut due to don't-do sets (don't-do set blocked executions, DDSBs).Note that the number of DDSBs with ODPOR ob cs would be always bounded (above) by the difference between the number finished execution sequences of ODPOR ob and ODPOR ob cs (and the same with ODPOR cs and ODPOR, respectively).But it could be much less than that because by blocking a partial execution, we can be avoiding the exploration of several redundant complete executions that will be explored by ODPOR ob (or ODPOR).Indeed, the number of DDSBs would be a direct indication of the effectiveness of the context-sensitive checks.The more close to the above upper bound the less effective are the checks since that would mean that the total number of explored executions (including the DDSBs) would be close to the total number of executions explored by ODPOR ob .E.g., in the case of pi for N = 7, the number of DDSBs is 750 which means that ODPOR ob cs is exploring a total of 1022 executions (including the DDSBs) whereas ODPOR ob is exploring 5040.However, in the case of lastwrite we get 3, 7, 11 and 15 as the numbers of DDSBs for the four runs respectively, which means that ODPOR ob cs is exploring the same number of executions as ODPOR ob although most of them are cut at the end (since they are redundant).The results on the rest of the benchmarks confirm this claim: in the cases where G cs−ob ob ≤ 1, the total number of explored executions of ODPOR ob cs (including DDSBs) is close (or even equal, as in the case of lastwrite) to the number of explorations performed by ODPOR ob , whereas in the cases where G cs−ob ob grows, such number is much lower.

158The fact that ODPOR ob cs is able to catch many more redundant executions than ODPOR ob , as we have seen, does not necessarily indicate a reduction on the overall exploration time (due to the associated overheads).However, this indicates the potential of ODPOR ob cs to produce exponential reductions.That will hap-pen as soon as the pattern where the reduction takes place is followed by non-trivial explorations, in such case such upcoming explorations will be effectively pruned.This can be observed looking at the results obtained in the -2phases variations of the benchmarks where we can see such exponential reductions of ODPOR ob cs w.r.t both ODPOR ob and DPOR cs (goal G1).The results from the third set of benchmarks give evidence of the potential of our algorithm when applied over larger programs.For MapRed, both ODPOR ob cs and DPOR cs explore 9 executions in 185 ms. and 114 ms.respectively, while ODPOR ob explores 118 executions and takes almost 3 seconds, since there is no gain in using observers in this case.For In conclusion, our experimental results show that our algorithm ODPOR ob cs is able to effectively combine the benefits of both DPOR cs and ODPOR ob .On the other hand, we can observe that it also inherits their associated overheads.Whereas in the case of ODPOR ob the overhead is very low, our results show notable overheads in DPOR cs and hence ODPOR ob cs , which in some cases do not pay-off even though they do not seem to affect the overall scalability.In this sense, we believe that the integration of the optimizations proposed in [4] could help.Specifically, we have measured that nearly half of the exploration time in both DPOR cs and ODPOR ob cs is spent in the computation of the alternative execution sequences for the context-sensitive checks (that are later recomputed during the normal exploration), which we believe could be avoided (at least in part) by integrating the support to avoid recomputations described in [4].

159Finally, let us conclude this section by noting that DPOR cs , ODPOR cs , and, consequently, ODPOR ob cs are likely to be highly beneficial for programs with large atomic code sections (e.g., monitors, concurrent objects, and message-passing systems), where the usual approximation of dependency based on variable accesses, even if it is computed dynamically, can be rather imprecise.They are also likely to be beneficial for programs with assertions, as these only result in two possibly (local) states: either the assertion holds or it does not.Hence, the contextsensitive independence check is more likely to succeed.

Conclusions and Related Work

160DPOR is one of the most scalable techniques used in the verification of concurrent systems.Recent work has introduced orthogonal notions of conditional independence into DPOR: DPOR cs [4] proposes a context-sensitive check in the current state to detect more accurately independence among processes, ODPOR ob [9] proposes a finer notion of independence which is conditional to the existence of observers that read the values written by the processes.We propose a seamless integration of DPOR cs and ODPOR ob , via two major technical extensions to DPOR cs : (1) incorporating (and using effectively) the notion of wakeup tree used by ODPOR ob , and (2) refining the contextsensitive check (and the sequences computed with it) to take observers into account.As shown in our experimental evaluation, the resulting algorithm achieves prunings that go beyond the combination of the individual algorithms.

161Other recent approaches have considered alternative ways of refining the detection of independence.Data-Centric DPOR [11] was the first work to focus on the reads-from relation.It defines two traces to be observationally equivalent if every read event observes the same write event in both traces.In contrast, we use the notion of observability introduced by [9], which is based on observing interference of operations, not just individual writes.The equivalence relation used by Data-Centric is proven in [11] to see more traces as equivalent than the one based on Mazurkiewicz traces, which is the one used in our work and in all other variants of the DPOR algorithm of [13].Note that this is more unlikely to happen in programs with bigger atomic blocks like our first and third set of benchmarks (where we have indeed seen that the reads-from relation would not be exploited).A drawback of Data-Centric DPOR is that it is not always optimal.Recently, there have been other works proposing optimal DPOR algorithms based on the reads-from relation, either for sequential consistency [2], for the releaseacquire semantics [3] or for the C/C++ concurrency.Also, [22] proposes an optimal algorithm for the reads-from relation which is parametric in the choice of the memory model under a set of basic assumptions.This has been recently further extended to handle locks efficiently [21] and, for the first time, to ensure linear memory consumption per equivalence class while at the same time allowing parallelization [20].It remains to be studied whether our context-sensitive dependency can be successfully integrated within these approaches based on the readsfrom relation since their underlying algorithms are fundamentally different as the classical DPOR algorithm and its variants (including [9]).

162Another approach is to generate independence constraints (ICs), which ensure the independence of each pair of processes in the program.The work in [32,18] generated for the first time ICs for processes with a single instruction following some predefined patterns.Constrained DPOR [7] proposed to generate ICs in a pre-phase, using a SMT solver.The generated ICs are then used within DPOR in a similar way to our contextsensitive checks.In addition, it can perform another type of pruning using the notion of transitive uniform conditional independence -which ensures the ICs hold along the whole execu-tion trace (and ensures uniformity as defined in [19,16]).The extension of Constrained DPOR with observers, to the best of our knowledge, has not been studied yet.We believe the integration of wakeup trees could be done similarly to our proposal in Section 3.1, and the enhancements in Section 4 would be applicable also in the Constrained DPOR framework.Still, the combination of transitive uniformity and observability remains to be investigated.

163An orthogonal approach to increase scalability, introduced in Quasi-Optimal POR [26], is to approximate the optimal exploration using a provided constant k.In essence, by using approximation, alternatives are computed in polynomial time, rather than making an NP-complete exploration, as in ODPOR.Another orthogonal improvement is to inspect dependencies over event chains [29].This work has been recently extended to the context of symbolic execution [30], where cut-off events are used to detect program states already visited in order to handle non-terminating executions.

164Finally, there is a large body of related work in the context of dynamic runtime verification that include similar ideas for race and deadlock detection [28,10,27].For instance, [28] proposes a complete and sound algorithm that predicts all data races of a given trace but without considering observability, whereas [10] improves it by taking into account observability.

Appendix A. Proofs of Correctness and Optimality of ODPOR cs

165Let us claim some auxiliary lemmas and definitions before proving the main theorems of soundness and optimality.First, we claim a lemma needed to prove the correctness of the new context-sensitive check.

166Let the sequence E ′ = E 0 .ê.w.ê′ .w′ is explored by Algorithm 1 and the race e ≾ E ′ e ′ .According to the algorithm's definitions: E 0 = pre(E ′ , e) and v = notdep(e, e ′ , E ′ ).

167Lemma 1.If the following check of Algorithm 1 succeeds

168Proof.First, we know that E ′ = E 0 .ê.w.ê′ .w′ , then pre + (E ′ , e ′ ) = E 0 .ê.w.ê′ , and sequence ê.w, can be divided in two sets notdep(e, e ′ , E ′ ) and suc(e, E ′ ).

169Let us introduce a simple notation suc − (e, E ′ ) to denote the sequence suc(e, E ′ ) without the first process ê.Then, E 0 .ê.w.ê′ ≃ E 0 .ê.notdep(e, e ′ , E ′ ).suc − (e, E ′ ).ê′ ≃ E 0 .notdep(e,e ′ , E).ê.ê′ .suc(e,E ′ ) (taking into account that after E 0 .notdep(e,e ′ , E).ê, we have ê′ ⋄ suc − (e, E ′ )).Because of the hypothesis, we know that s , then the write instruction must depend on a value of another variable x in a condition.This variable must be different in both states after the execution of ê. ê′ and ê′ .ê,respectively.However, this is not possible since x must be modified by e or e ′ and then, x ∈ V e,e ′ E ′ , and, thus, by the initial hypothesis, x should have the same value, producing the same result in the condition of variable y.We get a contradiction.

• If y

170V e,e ′ E ′ we get a similar contradiction.Since they write different values over variable y, and both executions share the same prefix E 0 .notdep(e,e ′ , E), there must be a variable in V e,e ′ E ′ with a different value.Otherwise, the value of y must be the same in both executions.

171Consequently, we have that for every program variable y s

172] (y).

173The correctness of the ODPOR cs algorithm follows from the correctness of ODPOR, and the fact that context-sensitive checks only remove equivalent Mazurkiewicz traces.] , then for any complete sequence E of the form E = E 0 .v.ê.u ′ .w′ that contains a race e ′ ≾ E e, there is a complete sequence E ′′ = pre + (E ′ , e ′ ).w that defines a different Mazurkiewicz trace T ′ =→ E ′ and leads to an identical final state.

174Proof.Let E = E 0 .v.ê.u ′ .w′ be a complete execution sequence.Let us notice here that Proof of Theorem 1 (Soundness of ODPOR cs ).Consider an execution of Explore(ϵ, ⟨{ϵ}, ∅⟩, ∅) without the additions for context-sensitivity, and assuming we always choose an enabled process (if it is possible, from the wakeup tree) that would not be blocked by the don't-do set in the extended algorithm, wherever possible.This is exactly the ODPOR algorithm of [1] which is guaranteed to explore a complete execution sequence that implements each T [24].

175Suppose that some Mazurkiewicz trace T is omitted by ODPOR cs , C is the complete execution sequence that implements T (T =→ C ) and is explored by the original ODPOR algorithm.This sequence must be cut by our algorithm.Thus, it must be of the form C = E ′ .v′ .ê.y, where our algorithm added v.ê to dnd(E ′ ) after succeeding in the check exploring a sequence C ′′ , and v ′ .ê is v.ê possibly having added some events that do not depend on any event in dom [E ′ ] (v.ê), as otherwise the don't-do entry would have been removed.Hence, there exists a complete execution sequence E ′ .v.ê.w.y with the same happens-before relation as C, obtained by moving after v.ê events that are independent of v.ê (those with processes in w).By Lemma 1, we can apply Lemma 2 and we get that there is a different trace T ′ which leads to the same state as C. Since ODPOR explores a complete execution sequence for each Mazurkiewicz trace, it must include a complete execution sequence C ′ that implements T ′ .Note that C ′ has the same happens-before relation as C ′′ = pre + (C ′′ , e ′ ).w.y.

176We now show that C ′ must have been explored before C, i.e. it appears to the left of C in the ODPOR exploration tree.Sequence pre + (C ′′ , e ′ ) clearly appears to the left of C in the ODPOR tree, or it could not be used to add the don't-do entry that blocked C. Let us suppose instead that C ′ appears to the right of C in the exploration tree.Let E ′′ be the largest common prefix of C and C ′ .Now C = E ′′ .q.w ′ for some q.Since C ′ appears to the right of C, then q will be in the don't-do sets for (the remainder of) sequence C ′ unless it is removed by some dependent event.Let e ′ = next [E ′′ ] (q), that is, the next event that q executes after E ′′ .

177Suppose that E ′′ .q≤ E ′ , then the first change is above E ′ .The happens-before relation for C ′ must then have some event e ′′ (after E ′′ .q)such that e ′′ → C ′ e ′ , but this cannot be the case since → C ′ =→ pre + (C ′′ ,e ′ ).w.y where this does not occur.

178Suppose that E ′ ≤ E ′′ and, thus, the first change is at, or after, the point where pre + (C ′′ , e ′′ ) and E ′ .v.ê differ.Clearly C ′ must appear to the right of E ′ .(e) in the tree (otherwise it would be to the left of C).Hence, ê is in the don't-do set (for the remainder) of C ′ after E ′ until removed by dependent events.Suppose event e ′′ removes ê.Then, we have that e ′′ → C ′ e.This is a contradiction since this does not occur in pre + (C ′′ , e ′ ).w.y.

179Hence, C ′ must appear to the left of C in the ODPOR tree.If C ′ exists in the tree visited by ODPOR cs we are done, since we have found an equivalent complete sequence.Otherwise, we can apply the same construction to discover an equivalent complete sequence that occurs to the left in the original tree.The procedure must terminate since, eventually, we reach the leftmost branch, which cannot be removed by the context-sensitive additions to the algorithm.Now, let us claim a lemma needed for the optimality theorem.Lemma 3. Let E = E ′ .ê.w.ê′ .wbe an execution such that e ≾ E e ′ .Let v ′ and v be dep(e ′ , E). ê′ .I fut (E ′ , v, E) and notdep * (e, E). ê′ , respectively.v redundant(E ′ , done) ⇔ v ′ redundant(E ′ , done) Finally, let us sketch the proof of Theorem 2.

180Proof sketch of Theorem 2 (Optimality of ODPOR cs ).This theorem follows from: (1) the optimality of ODPOR, (2) the fact that the algorithm can cut executions that are not happensbefore equivalent but whose result is the same as that of other complete executions already explored (Lemma 2), and (3) the fact that races found in cut executions have enough information to detect redundancies correctly (Lemma 3).By Lemma 3, we detect the same redundancies than ODPOR, whenever ODPOR cs explores a don't-do set blocked execution E.Then, when detecting a race in E, the wakeup tree is updated if and only if it would also be updated in case E would have been completely explored.Consequently, if both algorithms detect the same redundancies, and ODPOR does not initiates any of them, ODPOR cs does not either.The happens-before relation used in ODPOR requires (by the soundness of ODPOR) to explore an equivalent execution to E. Let us notice that E does not have the same happens-before relation than any execution explored by ODPOR cs .Lemma 5 (soundness of new inheritance).Let E ′ be an execution such that p.q.u ∈ wut(E ′ ), q.p.u.v ∈ dnd(E ′ ), and E ′ | = q.p.u.v p ⋄ q.If E = E ′ .p.q.u.v and E ′′ = E ′ .q.p.u.v, then s [E] = s [E ′′ ] modulo observability.

181Proof.Let us distinguish two cases depending on E ′ | = q.p.u.v p ⋄ q:

182• If E ′ | = q.p.u.v p⋄q holds because E ′ | = p⋄q, then they are independent, hence E ′ .p.q ∼ E ′ .q.p ⇒ s [E ′ .p.q] = s [E ′ .q.p] ⇒ s

183• Otherwise, E ′ | = q.p.u.v p ⋄ q holds because it takes advantage of observability, (i.e., ∃ ŵ ∈ u.v such that the set of variables written by both p and q is overwritten by w and ∀r ∈ u.v that observes any of these variables, w < E ′ .q.p.u.v r).Then, u.v is of the form u 1 .ŵ.u 2 .r.v 3 for all r ∈ u.v, and, although s [E ′ .p.q] may be different to s [E ′ .q.p] , we know that s [E ′ .p.q.u 1 .ŵ] = s [E ′ .q.p.u 1 .ŵ] and hence

184The proofs of soundness and optimality of ODPOR ob cs are analogous to those of the soundness and optimality theorems of ODPOR cs relying on Lemmas 4 and 5.

Figure 1 :

185Figure 1: Execution tree computed by the ODPOR algorithms for our running example.Subtrees P1 to P4 (dashed boxes in blue) are pruned by ODPOR cs and DPOR cs ; P5 (dotted box) is pruned by ODPOR ob and P1-P6 are all pruned by ODPOR ob cs .Arrow labels indicate the scheduled process; upper node labels the wakeup trees (v + w is a tree with two traces); and lower node labels (in blue) the don't-do sets (dnd).

Figure 2 :

186Figure 2: Main actions performed by ODPOR on Example 4

Figure 3 :

187Figure 3: wut(ϵ) at state 10 in Example 4

Example 6 .

188Let us explain the exploration performed by ODPOR cs on our running example, which is shown in Figure 1.The lower node labels (in blue) that start with ¬ indicate sequences in the corresponding don't-do sets, and the nodes within dashed boxes (labeled P1, P2, P3 and P4) correspond to

Figure 4 :

189Figure 4: Main actions performed by ODPOR cs on Example 6

Example 7 .

190Let us illustrate the need for each of the terms above with the following examples of events e, e ′ and execution sequence E = e.e ′ :

1 . 2 .

191For all o ∈ O, it holds that e → E o, o e ′ , and o ↛ E e ′ .For all o, o ′ ∈ O, it holds that o ↛ E o ′ .3. If E ′ ≃ E, then observers(e, e ′ , E ′ ) = O.

1 : 4 : 6 :: else 8 :

192procedure RaceDetection(E) 2: for all e, e ′ ∈ dom(E) such that e ≾ E e ′ do 3: let E ′ = pre(E, e); if observers(e, e ′ , E) ∅ then 5: let o = max E (observers(e, e ′ , E)); let v = notdep * (e, e ′ ,E).ê′ .ê.(notobs * (e, e ′ ,E)\ ê′ ).ô; 7let v = notdep * (e, e ′ , E). ê′ ; 9: if v redundant(E ′ , done) then 10:

Figure 5 :

193Figure 5: RaceDetection of ODPOR ob [9]

Lemma 2 .

194If the following check of Algorithm 1 succeeds s[pre + (E ′ ,e ′ )] = s [E 0 .(v.suc(e,E ′ )) ≤ e ′ E ′

s

195[pre + (C ′′ ,e ′ )] V e,e ′ C ′′ = s [E ′ .(v.ê) ≤ e ′ C ′′ ]

Lemma 4 .

196Appendix B. Proofs of Correctness and Optimality of ODPOR ob csLet us prove two lemmas that are the key for the soundness and optimality of Algorithm 2. If Algorithm 2 checks that s[pre + (E ′ ,o ′ )] = e,e ′ o ′ s [E 0 .v≤ o E ′ .(ôs \ ô)]∀o ′ ∈ o s , then for any complete sequence E of the form E = E 0 .v.( ôs \ ô).w ′ that contains a race e ′ ≾ E e observed by o s = observers(e, e ′ , E) and o = max E (o s ), there is a complete sequence E ′ = pre + (E ′ , o).w that defines a different Mazurkiewicz trace T ′ =→ E ′ and leads to an identical final state modulo observability.Proof.Let E = E 0 .v.( ôs \ ô).w ′ be a complete execution sequence.Here, let us denote notobs(e, e

Table 1 :

197Experimental evaluation results.First set of benchmarks.

Table 2 :

198ob cs features exponential reductions over ODPOR ob Experimental evaluation results.Second set of benchmarks.

Table 3 :

199Experimental evaluation results.Third set of benchmarks.

200SDN, ODPOR ob cs explores 16 executions in 52 ms., whereas DPOR cs explores 22 executions in 83 ms. and ODPOR ob 58 in 229 ms.Finally, in order to illustrate the potential impact of the refined check of Section 3.4 in isolation, the following table shows the exploration times of ODPOR ob cs with and without the refined check (columns labeled respectively With 3.4 and Without 3.4) on the arraywrite benchmark for a series of increasing inputs (column N), and the corresponding speedups.

201e ′ ,E).ê′ .ê].Let us suppose there exists a variable y such thats [pre + (E ′ ,e ′ )] (y) s [E 0 .(v.suc(e,E ′ )) ≤ e ′ [E 0 .notdep(e,e′,E).ê′ .suc(e,E′)](y).Two cases can be distinguished:• If y ∈ V e,e ′ E ′ , then because of the hypothesis we know that the value of y is not modified by suc − (e, E ′ ) at state s [E 0 .notdep(e,e′ ,E).ê.ê′ ] .But it is modified by suc − (e, E ′ ) at state s [E 0 .notdep(e,e′ ,E).ê′ .ê]

202′ ,E).ê.ê′ .suc− (e,E ′ )] (y) s

2031. E 0 .v≃E0.v≤e′E ′ .v>e′E′ , 2. E 0 .v.ê.u ′ ≃E 0 .v.suc(e, E ′ ) < e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′,wherew ′′ are possibly some events added that do not depend on any event in dom [E 0 .v](suc(e,E′)) and 3.E 0 .v≤e′ E ′ | = v > e ′ E ′ ⋄ suc(e, E ′ ) < e ′ E ′ .Now, E ≃ 1,2 E 0 .v≤e′ E ′ .v>e′ E ′ .suc(e,E′ ) < e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′≃ 3 E 0 .v≤e′ E ′ .suc(e,E′ ) < e ′ E ′ .v>e′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′≃ E 0 .(v.suc(e, E ′ )) ≤ e ′ E ′ .v>e′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′Since s [pre + (E ′ ,e ′ )] = s [E 0 .(v.suc(e,E ′ )) ≤ e ′ E ′ ] , we have that s [E ′′ ] = s [E] where E ′′ = pre + (E ′ , e ′ ).w and w = v > e ′ E ′ .suc(e,E′ ) > e ′ E ′ .w′′.w′.Note that in execution sequence E we have e ′ → E e, whereas in E ′ , we have e → E ′ e ′ .After claiming the previous lemmas, let us prove now the soundness of ODPOR cs .

204′ , E) as notobs and notice that E = E 0 .v.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs.ô.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs < o E .notobs>oE .ô.( ôs \ ô).w ′ ∼ E 0 .ance(e,e′, E). ê′ .ê.notobs < o E. ô.notobs > o E .(ôs\ ô).w ′ ∼ E 0 .v≤o E .(ôs\ ô).v > o E .w′= E 0 .v≤o E .(ôs\ ô).wSince s [pre + (E ′ ,o ′ )] = e,e ′ o ′ s [E 0 .v≤o E .(ôs\ ô)] ∀o ′ ∈ o s , we have that s [E] is equivalent to s [E ′ ]modulo observability where E ′ = pre + (E ′ , o).w.Note that in E we have e ′ → E e, whereas in E ′ we instead have e → E ′ e ′ .

참고문헌 16건

  1. Partial-Order Methods for the Verification of Concurrent Systems: An Approach to the State-Explosion Problem 1996
  2. Peephole Partial Order Reduction Tools and Algorithms for Construction and Analysis of Systems · 2008 10.1007/978-3-540-78800-3_29
  3. State space reduction using partial order techniques International Journal on Software Tools for Technology Transfer · Springer Science+Business Media · 1999 10.1007/s100090050035
  4. Defining conditional independence using collapses Theoretical Computer Science · Elsevier BV · 1992 10.1016/0304-3975(92)90054-j
  5. Data-centric dynamic partial order reduction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2017 10.1145/3158119
  6. Optimal Dynamic Partial Order Reduction with Observers Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-319-89963-3_14
  7. SDN-Actors: Modeling and Verification of SDN Programs Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-319-95582-7_33
  8. Optimal stateless model checking under the release-acquire semantics Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2018 10.1145/3276505
  9. Optimal context-sensitive dynamic partial order reduction with observers 2019 10.1145/3293882.3330565
  10. Unfolding-based Partial Order Reduction International Conference on Concurrency Theory · 2015 10.4230/lipics.concur.2015.456
  11. Effective lock handling in stateless model checking Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3360599
  12. Optimal stateless model checking for reads-from equivalence under sequential consistency Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3360576
  13. Fast, sound, and effectively complete dynamic race prediction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2019 10.1145/3371085
  14. Dynamic Analysis Method for Concurrency Bugs in Multi-process/Multi-thread Environments International Journal of Parallel Programming · Springer Science+Business Media · 2020 10.1007/s10766-020-00661-3
  15. Truly stateless, optimal dynamic partial order reduction Proceedings of the ACM on Programming Languages · Association for Computing Machinery · 2022 10.1145/3498711
  16. Trace theory Lecture notes in computer science · Springer Science+Business Media · 1987 10.1007/3-540-17906-2_30