Symbolic Abstract Data Types (ADTs)
Constantin Enea
University Paris Diderot - Paris 7 joint work with Michael Emmi, IMDEA Madrid
Symbolic Abstract Data Types (ADTs) Constantin Enea University - - PowerPoint PPT Presentation
Symbolic Abstract Data Types (ADTs) Constantin Enea University Paris Diderot - Paris 7 joint work with Michael Emmi, IMDEA Madrid Modular Reasoning Abstract Data Types smaller & simpler program, easier to reason about
Symbolic Abstract Data Types (ADTs)
Constantin Enea
University Paris Diderot - Paris 7 joint work with Michael Emmi, IMDEA Madrid
smaller & simpler program, easier to reason about Abstract Data Types
Compositional Proof Rule
that could be checked once for all programs
your program complex objects
Modular Reasoning
Concurrent objects
happens-before partial order
push(1) pop ⇒ 1 push(2) push(3) pop ⇒ 2 pop ⇒ 3
O |= ADT iff ∀ h ∈ Histories(O) ∃ linearization ∈ ADT
∃ linearization ∈ SeqStack ?
push(1) pop⇒1 push(2) push(3) pop⇒2 pop⇒3 push(1) pop⇒3 pop⇒1 push(2) pop⇒2 push(3)∉
push(1) pop⇒1 pop⇒3 push(2) pop⇒2 push(3)∉
push(1) pop⇒1 push(2) pop⇒3 pop⇒2 push(3)∉ ∈
push(1) pop⇒1 push(2) pop⇒3 pop⇒2 push(3)ADTs, Linearizability
Challenges:
(checking linearizability is more complex than checking reachability)
Approach: symbolic representations of seq. hist. (linearizations) (first order logic)
Modular Reasoning
Describing ADTs
the most recent write
∀ o1, o2, o3. “o1 is a write(a)” ∧ “o2 is a write(b)” ∧ “o3 is a read=>a” ∧ o1 < o2 => o3 < o2
Inferring Symbolic ADTs
GOAL inferring FO descriptions of ADTs HYPOTHESIS
[Emmi, E, POPL’16]
Challenges
pop⇒1 push(1) pop⇒1
violation correct
values
set of patterns:
Abstracting Data: Matchings
push(1) push(2) pop⇒EMPTY pop⇒2 pop⇒1
dequeues cannot be in the reverse order
enq(1) deq⇒1 enq(2) deq⇒2
same instances of values)
Abstract Algorithm
Input: a reference implementation Impl Output: FO formula representing Histories(Impl) patterns = O ; for each seq. hist. h do if * then break; else if h is executable with Impl then continue; else if h is redundant with patterns then continue; else add h to patterns return exclusion of patterns
Example: atomic queue
deq⇒1 deq⇒1 enq(1) deq⇒1 enq(1) deq⇒1 enq(1) deq⇒EMPTY enq(1) deq⇒1 deq⇒EMPTY enq(2) enq(1) deq⇒2 enq(2) enq(1) deq⇒2 deq⇒1
One deq per enq dequeuing empty fifo order
Abstract Algorithm
Input: a reference implementation Impl Output: FO formula representing Histories(Impl) patterns = O ; for each seq. hist. h do if * then break; else if h is executable with Impl then continue; else if h is redundant with patterns then continue; else add h to patterns return exclusion of patterns
some pattern ⪯ h
History Weakening
LEMMA Libraries closed under weakening
weaker order
push(1) pop⇒1 push(2)
pop⇒EMPTY
pop⇒2
all concurrent
push(1) pop⇒1 push(2) pop⇒EMPTY pop⇒2
Closure properties
push(1) pop⇒1 pop⇒EMPTY push(2) pop⇒2
write(1) read⇒1 read⇒1 read⇒1
Weaker than ++
PROPOSITION Typical concurrent libraries are closed under ⪰
h ⪯ h’ iff h is weaker than h’ or h has more matches or duplicates THEOREM ⪯ is a well quasi-order on bounded-width histories
bounded number
Inference Algorithm
patterns are violations
specifications
Excluding Patterns
enq(1) deq⇒1
∃ o, o’: lab(o) = deq⇒1 ⋀ lab(o’) = enq(1) ⋀ o < o’ ⋀ match(o) = o’
existentially-quantified
the pattern
Runtime Monitoring
GOAL
HYPOTHESIS w/o sacrificing practical completeness
NP → PTIME
PTIME → linear time + constant space
[Emmi, E, Hamza, PLDI’15]
Symbolic checking
THEORY(AtomicStack) transitive ∀o1,o2,o3. o1 < o2 ⋀ o2 < o3 ⟹ o1 < o3 antisymmetric ∀o1,o2. o1 < o2 ⟹ o2 ≮ o1 empty ∀o1,o2. pop(o1,empty) ⋀ push(o2,_) ⋀ unmatched(o2) ⟹ o1 < o2 … FORMULA(h) … ⋀ push(o4,2) ⋀ … ⋀ pop(o6,empty) ⋀ … ⋀ o4 < o5 ⋀ o5 < o6
THEOREM h ∈ Hist(L) iff FORMULA(h) ⋀ THEORY(L) is SAT
transitive
empty
Saturation Algorithm
push(1) pop⇒1 push(2) push(3) pop⇒EMP pop⇒3 push(2) push(3) pop⇒EMP push(2) push(3) pop⇒EMPONLY PROPAGATION
transitive empty
push(2) pop⇒3 push(2) pop⇒3 push(1) pop⇒1 push(2) push(3) pop⇒EMP pop⇒3branch backtrack
NO DECISIONS
NP → PTIME
Operation Removal
THEOREM Always sound to remove matches IDEA identify obsolete matches
remove match PTIME → linear time + constant space
STILL A VIOLATION
push(2) push(3) pop⇒EMPTY pop⇒3 push(1) pop⇒1 push(2) push(3) pop⇒EMPTY pop⇒3m a t c h i n g
Empirically
Enumerate Symbolic Symbolic+R Saturate Saturate+R 10 100 1000 Steps 5 25 50 75 100 Seconds E 47 SYM 47 SAT 47 C(4) 44 C(2) 27 E 32 SYM 33 SAT 33 C(4) 25 C(2) 11 E 18 SYM 18 SAT 18 C(4) 15 C(2) 12 E 49 SYM 49 SAT 49 C(4) 49 C(2) 25 Bounded-Size k-FIFO Distributed Queue Random-Dequeue Queue Unbounded-Size k-FIFO 5 10 15 20 25 30 35 40 45 Violations discovered w/o removal w/ removalexponentially more efficient complete in practice
Conclusion
Future work:
atomicity?
Inference Algorithm
Input: a reference implementation Impl Output: FO formula representing Seq(Impl) patterns = O ; k = 1; repeat none-found = true; for each seq. hist. h of size k do if h is executable with Impl then continue; else if some pattern ⪯ h then continue; else add h to patterns; none-found = false; k++; return exclusion of patterns