Refinement Proofs and Techniques
Suha Orhun Mutluergil Koc University, Istanbul, Turkey
Refinement Proofs and Techniques Suha Orhun Mutluergil Koc - - PowerPoint PPT Presentation
Refinement Proofs and Techniques Suha Orhun Mutluergil Koc University, Istanbul, Turkey Refinement In general: A concrete and complex system 1 refines the abstract system 2 iff 2 completely captures the behaviors of 1 .
Suha Orhun Mutluergil Koc University, Istanbul, Turkey
ο΄ In general: A concrete and complex system π1 refines the abstract system π2 iff π2 completely captures the behaviors of π1. ο΄ For automata/state machines/transition systems
ο΄ Refinement is based on observable actions alphabet Ξ£. ο΄ Formally: A Labeled Transition System (LTS) π1 Ξ£ βrefines the LTS π2 iff for every trace π of π1, there exists a trace πβ² of π2 such that π Ξ£ = πβ² Ξ£.
ο΄ Example: L1 = β©π1 = π‘0, π‘1, β¦ , Ξ£1 = π½, πΎ, πΏ , π1βͺ s.t. π1 β π1 Γ Ξ£1 Γ S1 π2 = β©π2 = π0, π1, β¦ , Ξ£2 = π½, πΎ, π , π2βͺ s.t. π2 β π2 Γ Ξ£2 Γ π2 Ξ£ = {π½, πΎ}
π‘0 π½ π‘1 πΏ π‘2 πΎ π‘3 πΎ π‘4 π0 π½ π1 πΎ π2 π π3 πΎ π4
ο΄ In general: A concrete and complex system π1 refines the abstract system π2 iff π2 completely captures the behaviors of π1. ο΄ For automata/state machines/transition systems
ο΄ Refinement is based on observable actions alphabet Ξ£. ο΄ Formally: A Labeled Transition System (LTS) π1 Ξ£ βrefines the LTS π2 iff for every trace π of π1, there exists a trace πβ² of π2 such that π Ξ£ = πβ² Ξ£.
ο΄ Example: L1 = β©π1 = π‘0, π‘1, β¦ , Ξ£1 = π½, πΎ, πΏ , π1βͺ s.t. π1 β π1 Γ Ξ£1 Γ S1 π2 = β©π2 = π0, π1, β¦ , Ξ£2 = π½, πΎ, π , π2βͺ s.t. π2 β π2 Γ Ξ£2 Γ π2 Ξ£ = {π½, πΎ}
π‘0 π· π‘1 πΏ π‘2 πΈ π‘3 πΈ π‘4 π0 π· π1 πΈ π2 π π3 πΈ π4
ο΄ In general, proofs depend on finding a particular kind of relations/functions that relates states of π1 to states of π2.
ο΄ Refinement mappings, forward simulation relations, backward simulation relations
ο΄ Completeness issues: None of these relations/functions are complete. ο΄ Refinement Mappings
ο΄ Complete if π1 is a forest and π2 is deterministic.2 ο΄ Otherwise, history and/or prophecy variables may need to be added.1
ο΄ Forward Simulations
ο΄ Complete if π2 is deterministic.2 ο΄ Otherwise, prophecy variables may need to be added.2
ο΄ Backward Simulations
ο΄ Complete if π1 is a forest.2 ο΄ Otherwise, history variables may need to be added.2
1. Abadi, M., & Lamport, L. (1991). The existence of refinement mappings. Theoretical Computer Science, 82(2), 253-284. 2. Lynch, N. A., & Vaandrager, F. W. (1995). Forward and backward simulations. Part I: Untimed systems. Information and Computation, 121(2), 214-233.
Joint work with Ahmed Bouajjani1, Constantin Enea1 and Michael Emmi2
1:IRIF, University of Paris Diderot 2:Nokia Bell Labs
Η: To Appear in CAV'17
ο΄ Scope: Proving correctness of concurrent stack and queue implementations (which eventually boils down to a refinement proof). ο΄ Contributions: A new stack and queue LTS specifications that are more useful than the standard specifications for the proofs
ο΄ Shown the equivalence to the standard specifications ο΄ Existence of forward simulations is guaranteed if some properties are known for the dequeue/pop methods of the implementations.
ο΄ Experiments/Applications
ο΄ Shown the correctness of Herlihy-Wing Queue1 by finding a forward simulation relation to the new queue implementation. ο΄ Shown correctness of Time-Stamped Stack2 finding a forward simulation relation to the new stack implementation.
1. Herlihy, Maurice P., and Jeannette M. Wing. "Linearizability: A correctness condition for concurrent objects." ACM Transactions on Programming Languages and Systems (TOPLAS) 12.3 (1990): 463-492. 2. Dodds, Mike, Andreas Haas, and Christoph M. Kirsch. "A scalable, correct time-stamped stack." ACM SIGPLAN Notices. Vol. 50. No.
ο΄ The standard correctness condition for concurrent data structures/libraries. ο΄ Call and return actions mark the beginning and end of methods. ο΄ History: Projection of a trace over call and return actions (π· βͺ π). ο΄ π1 is linearizable with respect to the specification π2 iff there exists a linearization point of every operation in the history β1 btw its call and return points such that the same operation of π2 takes place atomically at that point.
inv(deq) ret(deq,3) inv(enq,5) ret(enq) inv(enq,3) ret(enq) enq(5) deq(3) enq(3)
ο΄ Standard abstract specification π΅ππ‘π 0:
ο΄ State: π: βπ ο΄ Actions: πππ€(πππ, π), πππ πππ, π , π ππ’(πππ), πππ€(πππ), πππ(πππ, π), π ππ’(πππ, π) ο΄ πππ πππ, π β πβ² = π β β©πβͺ ο΄ πππ πππ, EMPTY β π = β qβ² = q ο΄ πππ πππ, π β π = π β π‘ β§ π β EMPTY β πβ² = π‘
ο΄ Showing that the implementation π1 π· βͺ π βrefines π΅ππ‘π 0 is sufficient. ο΄ If we know the linearization points of enqueue or dequeue methods, finding π· βͺ π βͺ πππ βrefinements are easier.
ο΄ Linearization points of enqueues are usually not fixed (depends on the execution). ο΄ Linearization points of dequeues are usually fixed and easy to determine. ο΄ π΅ππ‘π 0 is not deterministic in terms of π· βͺ π and π· βͺ π βͺ πππ πππ .
inv(enq,3) lin(enq,3) ret(enq) inv(enq,5) lin(enq,5) ret(enq)
π = β©3,5 βͺ
ο΄ Linearization points of enqueues are usually not fixed (depends on the execution). ο΄ Linearization points of dequeues are usually fixed and easy to determine. ο΄ π΅ππ‘π 0 is not deterministic in terms of π· βͺ π and π· βͺ π βͺ πππ πππ .
inv(enq,3) lin(enq,3) ret(enq) inv(enq,5) lin(enq,5) ret(enq)
π = β©5,3 βͺ
ο΄ States: Strict partial order of enqueue
They can be pending or completed ο΄ Actions: π· βͺ π βͺ πππ(πππ) ο΄ π΅ππ‘π is deterministic in terms of π· βͺ π βͺ πππ(πππ) ο΄ π΅ππ‘π produces same histories with π΅ππ‘π 0. ο΄ Example Application: Showing linearizability of Herlihy & Wing Queue1 by finding a forward simulation to π΅ππ‘π . π1 π2 π3 π5 π4 π6 :COMPLETED :PENDING
dequable minimal nodes
Programming Languages and Systems (TOPLAS) 12.3 (1990): 463-492.
ο΄ A natural conversion of π΅ππ‘π to π΅ππ‘π exists. Pops remove maximal elements instead of minimal elements. ο΄ Similar observations on implementations: linearization points of pushes are not fixed. For complicated examples, linearization points of pops are not fixed neither. But, we can determine commit points (that fixes the return value) of pops. ο΄ π΅ππ‘π0 is not deterministic in terms of π· βͺ π or π· βͺ π βͺ πππ(πππ). ο΄ We introduce a new π΅ππ‘π that produces different from the dual of π΅ππ‘π , equivalent executions with π΅ππ‘π0 and deterministic in terms of π· βͺ π βͺ πππ πππ . ο΄ We have shown its applicability by finding a forward simulation from the complicated Time-Stamped Stack1 implementation to π΅ππ‘π.
ο΄ Future work: Extending the idea to other data structures like sets. ο΄ Future work: Mechanizing the proofs on Boogie/CIVL proof system developed by Microsoft Research and Koc University. ο΄ Other interests:
ο΄ Refinement proofs for weak memory models. ο΄ Particularly, extending the CIVL proof system for TSO memory model. ο΄ New proof rules for TSO. ο΄ Extending the concept of linearizability for WMM.
ο΄ Any Questions?
inv(deq) ret(deq,3) inv(enq,5) ret(enq) inv(enq,3) ret(enq) inv(enq,3) ret(enq) inv(enq,5) ret inv(deq) ret(deq,3) lin(enq,3) lin lin inv lin ret inv lin ret inv lin ret
ο΄ Refinement Mappings: π: π π· β π π΅ ο΄ Initial: π‘ β π½πππ’ ππ· β π π‘ β π½πππ’(ππ΅) ο΄ Step: ο΄ Complete if ππ is a forest and ππ΅ is deterministic.2 ο΄ History and/or Prophecy variables may be needed to be added to find a
Abstract Concrete
π‘1 π‘2 π π’1 π’2 π+ f f
1. Abadi, M., & Lamport, L. (1991). The existence of refinement mappings. Theoretical Computer Science, 82(2), 253-284. 2. Lynch, N. A., & Vaandrager, F. W. (1995). Forward and backward simulations. Part I: Untimed systems. Information and Computation, 121(2), 214-233.
Let Ξ£ β Ξ£π·, Ξ£π΅ be the refinement alphabet. If π β Ξ£, then, π+ β Ξ£π΅ β Ξ£ βπ Ξ£π΅ β Ξ£ β. If π β Ξ£, then π+ β Ξ£π΅ β Ξ£ β.
ο΄ Forward Simulation Relations: fs β π π· Γ π π΅ ο΄ Initial: π‘ β π½πππ’ ππ· β ππ‘ π‘ β© π½πππ’ ππ΅ β β ο΄ Step: ο΄ Complete if ππ΅ is deterministic.1 ο΄ Prophecy variables may be needed to be added to find a frw. sim. rln.1
Abstract Concrete
π‘1 π‘2 π π’1
1
π’2
1
π+ fs fs π’1
2
π’2
2
π+
Computation, 121(2), 214-233.
ο΄ Backward Simulation Relations: bs β π π· Γ π π΅ ο΄ Initial: π‘ β π½πππ’ ππ· β ππ‘ π‘ β π½πππ’(ππ΅) ο΄ Step: ο΄ Complete if ππ is a forest.1 ο΄ History variables may be needed to be added to find a bck. sim. rln.1
Abstract Concrete
π‘1 π‘2 π π’1
1
π’2
1
π+ bs bs π’1
2
π’2
2
π+
Computation, 121(2), 214-233.
ο΄ π΅ππ‘π is a π· βͺ π βͺ πππ πππ -refinement of π΅ππ‘π 0. ο΄ π΅ππ‘π 0 is a π· βͺ π βͺ πππ πππ -refinement of π΅ππ‘π . ο΄ π΅ππ‘π is deterministic in terms of π· βͺ π βͺ πππ(πππ). ο΄ If ππ· is a queue implementation for which linearization or commit points of dequeue is known and fixed, we can find a forward simulation relation from ππ· to π΅ππ‘π .
ο΄ Example: Herlihy-Wing Queue1
Programming Languages and Systems (TOPLAS) 12.3 (1990): 463-492.
ο΄ Keep track of pushes that can be removed by a pop:
ο΄ Nodes that are pending or maximally closed when the pop started (initialize ππ and ππ€ sets) ο΄ Pushes that overlap with the pop (extend ππ€ set) ο΄ Nodes that become maximal while the pop was executing (update ππ set)
ο΄ NOTE: New π΅ππ‘π keeps working for implementations with fixed pop linearization points. ο΄ How it actually works:
ο΄ π΅ππ‘π is a π· βͺ π-refinement of π΅ππ‘π0. ο΄ π΅ππ‘π0 is a π· βͺ π-refinement of π΅ππ‘π. ο΄ π΅ππ‘π is deterministic in terms of π· βͺ π βͺ πππ(πππ). ο΄ If ππ· is a stack implementation for which linearization or commit points of pop is known and fixed, we can find a forward simulation relation from ππ· to π΅ππ‘π.
ο΄ Example: Time-Stamped Stack1