Proof Spaces for Unbounded Parallelism
Zachary Kincaid University of Toronto January 16, 2015
Joint work with: Azadeh Farzan, University of Toronto Andreas Podelski, University of Freiburg
Proof Spaces for Unbounded Parallelism Zachary Kincaid University - - PowerPoint PPT Presentation
Proof Spaces for Unbounded Parallelism Zachary Kincaid University of Toronto January 16, 2015 Joint work with: Azadeh Farzan, University of Toronto Andreas Podelski, University of Freiburg Single template T executed by every thread
Zachary Kincaid University of Toronto January 16, 2015
Joint work with: Azadeh Farzan, University of Toronto Andreas Podelski, University of Freiburg
TN T T T
N times
Program Verifier
No Yes Property T Diverge
TN = T ∥ T ∥· · · ∥ T
Program Verifier
No Yes Property T Diverge
TN = T ∥ T ∥· · · ∥ T
Program Verifier
No Yes Property T Diverge
TN = T ∥ T ∥· · · ∥ T
Program Verifier
No Yes Property T Diverge
global t : int // ticket counter global s : int // service counter local m : int // my ticket init s ≤ t m := t++ // acquire ticket do { // busy wait } until (m <= s) // critical section s++ // bump service counter
Proving correctness of a multi-threaded program is hard. ∀i, j ∈ Thread.pc(i) ̸= init ∧ pc(j) ̸= init ∧ m(i) = m(j) ⇒ i = j Proving correctness of a trace of a multi-threaded program is easy.
Program is correct each of its traces are correct.
Proving correctness of a multi-threaded program is hard. ∀i, j ∈ Thread.pc(i) ̸= init ∧ pc(j) ̸= init ∧ m(i) = m(j) ⇒ i = j Proving correctness of a trace of a multi-threaded program is easy.
Program is correct each of its traces are correct.
Proving correctness of a multi-threaded program is hard. ∀i, j ∈ Thread.pc(i) ̸= init ∧ pc(j) ̸= init ∧ m(i) = m(j) ⇒ i = j Proving correctness of a trace of a multi-threaded program is easy.
Program is correct ⇐ ⇒ each of its traces are correct.
init wait crit exit m := t++ [m <= s] [m > s] s++ global t : int // ticket counter global s : int // service counter local m : int // my ticket init s ≤ t m := t++ // acquire ticket do { // busy wait } until (m <= s) // critical section s++ // bump service counter
T A. Henzinger, R. Jhala, R. Majumdar, K. L. McMillan. Abstractions from proofs. POPL’04
by construction or approximation of fixpoints. POPL’77.
init wait crit exit m := t++ [m <= s] [m > s] s++ global t : int // ticket counter global s : int // service counter local m : int // my ticket init s ≤ t m := t++ // acquire ticket do { // busy wait } until (m <= s) // critical section s++ // bump service counter
T A. Henzinger, R. Jhala, R. Majumdar, K. L. McMillan. Abstractions from proofs. POPL’04
by construction or approximation of fixpoints. POPL’77.
init wait crit exit m := t++ [m <= s] [m > s] s++ m := t++ : 1 m := t++ : 2 [m <= s] : 1 [m <= s] : 2 Error trace ∈ (Σ×N)∗ Commands Thread IDs
T A. Henzinger, R. Jhala, R. Majumdar, K. L. McMillan. Abstractions from proofs. POPL’04
by construction or approximation of fixpoints. POPL’77.
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
init wait crit exit m := t++ [m <= s] [m > s] s++ {s ≤ t} m := t++ : 1 s m m t m := t++ : 2 s m m m [m <= s] : 1 s m m m [m <= s] : 2 {false}
Intermediate assertions
Craig interpolation, Abstract post, Dual narrowing, ...
T A. Henzinger, R. Jhala, R. Majumdar, K. L. McMillan. Abstractions from proofs. POPL’04
by construction or approximation of fixpoints. POPL’77.
init wait crit exit m := t++ [m <= s] [m > s] s++ {s ≤ t} m := t++ : 1 {s ≤ m(1) ∧ m(1) < t} m := t++ : 2 {s ≤ m(1)∧m(1) < m(2)} [m <= s] : 1 {s ≤ m(1)∧m(1) < m(2)} [m <= s] : 2 {false}
Intermediate assertions
Craig interpolation,1 Abstract post,2 Dual narrowing,3 ...
1 T A. Henzinger, R. Jhala, R. Majumdar, K. L. McMillan. Abstractions from proofs. POPL’04 2 P. Cousot & R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs
by construction or approximation of fixpoints. POPL’77.
3 P. Cousot. Abstracting Induction by Extrapolation and Interpolation. VMCAI’15.
{s ≤ t} m := t++ : 1 {s ≤ m(1)} {true} m := t++ : 1 {m(1) < t} {m(1) < t} m := t++ : 2 {m(1) < m(2)} {s ≤ m(1) ∧ m(1) < m(2)} [m <= s] : 2 {false} {s ≤ m(1) ∧ m(1) < m(2)} s++ : 1 {s ≤ m(2)}
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
{s ≤ t} m := t++ : 1 {m(1) < t} {m(1) < t} m := t++ : 2 {m(1) < m(2)} s t m := t++ : 1; m := t++ : 2 m m
{s ≤ t} m := t++ : 1 {m(1) < t} {m(1) < t} m := t++ : 2 {m(1) < m(2)} {s ≤ t} m := t++ : 1; m := t++ : 2 {m(1) < m(2)}
TN = T ∥ T ∥· · · ∥ T
{s ≤ m(1)∧m(1) < m(2)} [m <= s] : 2 {false}
TN = T ∥ T ∥· · · ∥ T
{s ≤ m(1)∧m(1) < m(2)} [m <= s] : 2 {false} {s ≤ m(2)∧m(2) < m(1)} [m <= s] : 1 {false} [1 → 2] [2 → 1]
TN = T ∥ T ∥· · · ∥ T
{s ≤ m(1)∧m(1) < m(2)} [m <= s] : 2 {false} {s ≤ m(2)∧m(2) < m(3)} [m <= s] : 3 {false} [1 → 2] [2 → 3]
{m(1) < t} m := t++ : 3 {m(1) < m(3)} {m(2) < t} m := t++ : 3 {m(2) < m(3)} m t m t m := t++ : 3 m m m m
{m(1) < t} m := t++ : 3 {m(1) < m(3)} {m(2) < t} m := t++ : 3 {m(2) < m(3)} {m(1) < t ∧ m(2) < t} m := t++ : 3 {m(1) < m(3) ∧ m(2) < m(3)}
A Proof space is a set of valid Hoare triples which is closed under sequencing, symmetry, and conjunction.
Proof rule: if there exists a proof space H such that for all error traces pre false H then the program is correct.
A Proof space is a set of valid Hoare triples which is closed under sequencing, symmetry, and conjunction.
Proof rule: if there exists a proof space H such that for all error traces pre false H then the program is correct.
A Proof space is a set of valid Hoare triples which is closed under sequencing, symmetry, and conjunction.
Proof rule: if there exists a proof space H such that for all error traces τ {pre}τ{false} ∈ H, then the program is correct.
Theorem Every inductive invariant (with control variables & universal thread quantification) corresponds to a proof space.
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Infeasible traces Feasible traces No corresponding executions At least one corresponding execution Error traces Error is reachable! Proof Space
Vocabulary (Q, ar) is a finite relational first-order vocabulary Q = {p, q}, ar(p) = 2, ar(q) = 1 p p p q true Configurations
Vocabulary (Q, ar) is a finite relational first-order vocabulary Q = {p, q}, ar(p) = 2, ar(q) = 1 p(1, 2) p(1, 2) ∧ p(2, 3) ∧ q(1) true Configurations
q(i) q(i) p(i, j) ∧ q(j) a : j [ i = j ] a : j [ t r u e ] q q p q a a q p q a q q p q p p q a a
q(i) q(i) p(i, j) ∧ q(j) a : j [ i = j ] a : j [ t r u e ] q(1) q(1) p(1, 1) ∧ q(1) a : 1 a : 1 q p q a q q p q p p q a a
q(i) q(i) p(i, j) ∧ q(j) a : j [ i = j ] a : j [ t r u e ] q(1) q(1) p(1, 1) ∧ q(1) a : 1 a : 1 q(2) p(2, 1) ∧ q(1) a : 1 q q p q p p q a a
q(i) q(i) p(i, j) ∧ q(j) a : j [ i = j ] a : j [ t r u e ] q(1) q(1) p(1, 1) ∧ q(1) a : 1 a : 1 q(2) p(2, 1) ∧ q(1) a : 1 q(1) ∧ q(2) p(2, 1) ∧ q(1) p(1, 1) ∧ p(2, 1) ∧ q(1) a : 1 a : 1
Proof space inclusion reduces to PA emptiness ∀τ ∈ Error trace.{pre}τ{false} ∈ H ⇐ ⇒ Err ∩ A(H) = ∅
Theorem The emptiness problem for predicate automata is undecidable. Theorem The emptiness problem for monadic predicate automata ( q Q ar q ) is decidable.
Theorem The emptiness problem for predicate automata is undecidable. Theorem The emptiness problem for monadic predicate automata (∀q ∈ Q, ar(q) ≤ 1) is decidable.
Proof spaces: a theoretical foundation for verifying multi-threaded programs
Proof spaces: a theoretical foundation for verifying multi-threaded programs
Proof spaces: a theoretical foundation for verifying multi-threaded programs