modular termination verification for non blocking
play

Modular Termination Verification for Non-blocking Concurrency Julian - PowerPoint PPT Presentation

Modular Termination Verification for Non-blocking Concurrency Julian Sutherland Joint work with: Pedro da Rocha Pinto, Thomas Dinsdale-Young, Philippa Gardner July, 2015 1 / 15 Module Abstractions Given the following modules. Queue Counter


  1. Modular Termination Verification for Non-blocking Concurrency Julian Sutherland Joint work with: Pedro da Rocha Pinto, Thomas Dinsdale-Young, Philippa Gardner July, 2015 1 / 15

  2. Module Abstractions Given the following modules. Queue Counter Stack ◮ What is the right specification? ◮ Sufficiently strong for clients to be able to use it constructively. ◮ Sufficiently weak for any “reasonable” implementations of the module to satisfy it. ◮ How much can we abstract? ◮ Can we prove termination? 2 / 15

  3. Example of a Client of a Counter Module x := makeCounter (); n := random (); m := random (); i := 0; j := 0; while ( i < n ) { while ( j < m ) { incr ( x ); incr ( x ); i := i + 1; j := j + 1; } } 3 / 15

  4. Counter Module Operations: Partial Correctness � � � � ⊢ emp makeCounter () C ( ret , 0) � � � � ⊢ n ∈ N . C ( x , n ) read ( x ) C ( x , n ) ∧ ret = n A � � � � ⊢ n ∈ N . C ( x , n ) incr ( x ) C ( x , n + 1) A 4 / 15

  5. Spin Counter: Increment � � � � ⊢ A n ∈ N . C ( x , n ) incr ( x ) C ( x , n + 1) function incr ( x ) { b := 0; while ( b = 0) { v := [ x ]; b := CAS ( x , v , v + 1); } } 5 / 15

  6. Counter Module Operations : Total Correctness � � � � ∀ α. ⊢ τ emp makeCounter () C ( ret , 0 , α ) � � � � ⊢ τ A n ∈ N , α. C ( x , n, α ) read ( x ) C ( x , n, α ) ∧ ret = n � � � � ∀ β. ⊢ τ A n ∈ N , α. C ( x , n, α ) ∧ α > β ( α ) incr ( x ) C ( x , n + 1 , β ( α )) 6 / 15

  7. Counter Module Operations : Total Correctness � � � � ∀ α. ⊢ τ emp makeCounter () C ( ret , 0 , α ) � � � � ⊢ τ A n ∈ N , α. C ( x , n, α ) read ( x ) C ( x , n, α ) ∧ ret = n � � � � ∀ β. ⊢ τ A n ∈ N , α. C ( x , n, α ) ∧ α > β ( α ) incr ( x ) C ( x , n + 1 , β ( α )) ∀ α > β. C ( x, n, α ) = ⇒ C ( x, n, β ) 6 / 15

  8. Counter Module Operations : Total Correctness � � � � ∀ α. ⊢ τ emp makeCounter () C ( ret , 0 , α ) � � � � ⊢ τ A n ∈ N , α. C ( x , n, α ) read ( x ) C ( x , n, α ) ∧ ret = n � � � � ∀ β. ⊢ τ A n ∈ N , α. C ( x , n, α ) ∧ α > β ( α ) incr ( x ) C ( x , n + 1 , β ( α )) ∀ α > β. C ( x, n, α ) = ⇒ C ( x, n, β ) Non-impedance relationship in the counter module: incr read

  9. Counter Module Operations : Total Correctness � � � � ∀ α. ⊢ τ emp makeCounter () C ( ret , 0 , α ) � � � � ⊢ τ A n ∈ N , α. C ( x , n, α ) read ( x ) C ( x , n, α ) ∧ ret = n � � � � ∀ β. ⊢ τ A n ∈ N , α. C ( x , n, α ) ∧ α > β ( α ) incr ( x ) C ( x , n + 1 , β ( α )) ∀ α > β. C ( x, n, α ) = ⇒ C ( x, n, β ) Non-impedance relationship in the counter module: incr read 6 / 15

  10. Total Correctness for Loops � � � � ∀ γ ≤ α. ⊢ τ p ( γ ) ∧ B ∃ β. p ( β ) ∧ β < γ C � � � � ⊢ τ p ( α ) while ( B ) C ∃ β. p ( β ) ∧ ¬ B ∧ β ≤ α 7 / 15

  11. Example of a Client of a Counter Module x := makeCounter (); n := random (); m := random (); i := 0; j := 0; while ( i < n ) { while ( j < m ) { incr ( x ); incr ( x ); i := i + 1; j := j + 1; } } 8 / 15

  12. Example of a Client of a Counter Module � � emp x := makeCounter (); n := random (); m := random (); i := 0; j := 0; while ( i < n ) { while ( j < m ) { incr ( x ); incr ( x ); i := i + 1; j := j + 1; } } � � C ( x , n + m , 0) 8 / 15

  13. Building abstraction I ( CClient r ( x, n )) � ∃ α. C ( x, n, α ) ∗ [ Total ( n, α )] r I ( CClient r ( x, ◦ )) � True 9 / 15

  14. Building abstraction I ( CClient r ( x, n )) � ∃ α. C ( x, n, α ) ∗ [ Total ( n, α )] r I ( CClient r ( x, ◦ )) � True Inc ( x, n + m, α ⊕ β, π 1 + π 2 ) = Inc ( x, n, α, π 1 ) • Inc ( x, m, β, π 2 ) Total ( n, α ) • Inc ( m, β, 1) defined = ⇒ n = m ∧ α = β 9 / 15

  15. Building abstraction I ( CClient r ( x, n )) � ∃ α. C ( x, n, α ) ∗ [ Total ( n, α )] r I ( CClient r ( x, ◦ )) � True Inc ( x, n + m, α ⊕ β, π 1 + π 2 ) = Inc ( x, n, α, π 1 ) • Inc ( x, m, β, π 2 ) Total ( n, α ) • Inc ( m, β, 1) defined = ⇒ n = m ∧ α = β Inc ( m, γ, π ) : n � n + 1 Inc ( m, γ, 1) : n � ◦ 9 / 15

  16. Building abstraction I ( CClient r ( x, n )) � ∃ α. C ( x, n, α ) ∗ [ Total ( n, α )] r I ( CClient r ( x, ◦ )) � True Inc ( x, n + m, α ⊕ β, π 1 + π 2 ) = Inc ( x, n, α, π 1 ) • Inc ( x, m, β, π 2 ) Total ( n, α ) • Inc ( m, β, 1) defined = ⇒ n = m ∧ α = β Inc ( m, γ, π ) : n � n + 1 Inc ( m, γ, 1) : n � ◦ 9 / 15

  17. Proving the Client � � emp x := makeCounter (); � � C ( x , 0 , ω ⊕ ω ) . . . 10 / 15

  18. Proving the Client � � emp x := makeCounter (); � � C ( x , 0 , ω ⊕ ω ) � � CClient ( x , 0) ∗ [ Inc (0 , ω ⊕ ω, 1)] � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v . . . . . . 10 / 15

  19. Proving the client � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v n := random (); i := 0; while ( i < n ) { . . . incr ( x ); i := i + 1; } 11 / 15

  20. Proving the client � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v n := random (); i := 0; while ( i < n ) { . . . incr ( x ); i := i + 1; } � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] 11 / 15

  21. Proving the client � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v n := random (); i := 0; ∃ v. CClient ( x , v ) ∗ [ Inc ( i , n , 1 � � 2 )] ∧ 0 ≤ v ∧ i = 0 while ( i < n ) { . . . incr ( x ); i := i + 1; } � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] 11 / 15

  22. Proving the client � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v n := random (); i := 0; ∃ v. CClient ( x , v ) ∗ [ Inc ( i , n , 1 � � 2 )] ∧ 0 ≤ v ∧ i = 0 while ( i < n ) { ∀ β. � ∃ v. CClient ( x , v ) ∗ [ Inc ( i , β, 1 � 2 )] ∧ i ≤ v ∧ i ≤ n . . . ∧ β = n − i incr ( x ); i := i + 1; } � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] 11 / 15

  23. Proving the client � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v n := random (); i := 0; ∃ v. CClient ( x , v ) ∗ [ Inc ( i , n , 1 � � 2 )] ∧ 0 ≤ v ∧ i = 0 while ( i < n ) { ∀ β. � ∃ v. CClient ( x , v ) ∗ [ Inc ( i , β, 1 � 2 )] ∧ i ≤ v ∧ i ≤ n . . . ∧ β = n − i incr ( x ); i := i + 1; � ∃ δ, v. CClient ( x , v ) ∗ [ Inc ( i , δ, 1 � 2 )] ∧ i ≤ v ∧ i ≤ n ∧ δ = n − i ∧ δ < β } � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] 11 / 15

  24. Proving the client � � emp x := makeCounter (); � � C ( x , 0 , ω ⊕ ω ) � � CClient ( x , 0) ∗ [ Inc (0 , ω ⊕ ω, 1)] � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v . . . . . . � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] 12 / 15

  25. Proving the client � � emp x := makeCounter (); � � C ( x , 0 , ω ⊕ ω ) � � CClient ( x , 0) ∗ [ Inc (0 , ω ⊕ ω, 1)] � ∃ v. CClient ( x , v ) ∗ [ Inc (0 , ω, 1 � 2 )] ∧ 0 ≤ v . . . . . . � ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 � 2 )] ∃ v. CClient ( x , v ) ∗ [ Inc ( n , 0 , 1 2 )] ∗ [ Inc ( m , 0 , 1 � � 2 )] � � ∃ v. CClient ( x , v ) ∗ [ Inc ( n + m , 0 , 1)] � � C ( x , n + m , 0) 12 / 15

  26. What to take home ◮ Ordinals can be used to bound interference in a module. ◮ Generally, termination is not guaranteed unless we restrict the environment. ◮ Atomic triples allow us to restrict the environment. ◮ The client can choose how to decrease the ordinals. ◮ Non-impedance seems to be a useful way of specifying blocking within a module. 13 / 15

  27. Conclusions ◮ Introduced atomic triples with total correctness interpretation. ◮ Introduced Total-TaDA, that extends TaDA for total correctness. ◮ Modular approach: clients and implementations are verified independently. ◮ Examples: Counters, Stacks, Queues, Sets, Graphs 14 / 15

  28. Current/Future work ◮ Extend logic (and specifications?) to blocking algorithms ◮ Non-terminating behaviour 15 / 15

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend