towards algorithmic synthesis of synchronization for shared … · 2016-07-16 ·...

44
Groundwork Algorithm Extensions Conclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory Concurrent Programs Roopsha Samanta The University of Texas at Austin July 6, 2012 Roopsha Samanta Algorithmic Synthesis of Synchronization 1 / 20

Upload: others

Post on 04-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Towards Algorithmic Synthesis ofSynchronization for Shared-Memory

Concurrent Programs

Roopsha Samanta

The University of Texas at Austin

July 6, 2012

Roopsha Samanta Algorithmic Synthesis of Synchronization 1 / 20

Page 2: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Problem Definition

Given a shared-memory concurrent program P, composed ofunsynchronized processes P1, . . . ,Pk , and a (branching-time)temporal logic specification φspec such that P 6|= φspec , automaticallygenerate synchronized processes Ps

1, . . . ,Psk such that Ps |= φspec .

Roopsha Samanta Algorithmic Synthesis of Synchronization 2 / 20

Page 3: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Example

P:x : {0,1,2} with x = 1P1 ‖ P2

P1:L1: while(x < 2)L2: x := x + 1;L3: while true;

P2:T1: while(x > 0)T2: x := x − 1;T3: while true;

φspec : AF(L3 ∧ T3 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 3 / 20

Page 4: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Example

P:x : {0,1,2} with x = 1P1 ‖ P2

6|=

φspec : AF(L3 ∧ T3 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 3 / 20

Page 5: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Q&A

Why shared-memory concurrent programs?

UbiquitousHard to writeHarder to verify

Why temporal logic specifications? Why branching-time?

Terminating, ongoing programsSafety, livenessExpressivity

Why synthesize only the synchronization?

Trickiest partSimple specifications, tractable

Roopsha Samanta Algorithmic Synthesis of Synchronization 4 / 20

Page 6: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Q&A

Why shared-memory concurrent programs?

UbiquitousHard to writeHarder to verify

Why temporal logic specifications? Why branching-time?

Terminating, ongoing programsSafety, livenessExpressivity

Why synthesize only the synchronization?

Trickiest partSimple specifications, tractable

Roopsha Samanta Algorithmic Synthesis of Synchronization 4 / 20

Page 7: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Q&A

Why shared-memory concurrent programs?

UbiquitousHard to writeHarder to verify

Why temporal logic specifications? Why branching-time?

Terminating, ongoing programsSafety, livenessExpressivity

Why synthesize only the synchronization?

Trickiest partSimple specifications, tractable

Roopsha Samanta Algorithmic Synthesis of Synchronization 4 / 20

Page 8: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Q&A

Why shared-memory concurrent programs?

UbiquitousHard to writeHarder to verify

Why temporal logic specifications? Why branching-time?

Terminating, ongoing programsSafety, livenessExpressivity

Why synthesize only the synchronization?

Trickiest partSimple specifications, tractable

Roopsha Samanta Algorithmic Synthesis of Synchronization 4 / 20

Page 9: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

A Vocabulary L

L-symbols

Variable symbols (x)Function, constant symbols (1, 2, +, −)Predicate, proposition symbols (L1, T3, >, <)Sort symbols (bool, int0to2)Distinguished equality predicate symbol =

(Sorted) L-terms and L-atoms:

L-term (t): v or f (t1, . . . , tm) (x , 1, x + 1)L-atom(G): B(t1, . . . , tm) or t1 = t2 (x > 1, L1, x = 1)Sorts mapped to nonempty domains (bool→ {T,F},int0to2→ {0,1,2})Symbols, terms, atoms mapped to values in appropriatedomains.

Roopsha Samanta Algorithmic Synthesis of Synchronization 5 / 20

Page 10: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

A Vocabulary L

L-symbols

Variable symbols (x)Function, constant symbols (1, 2, +, −)Predicate, proposition symbols (L1, T3, >, <)Sort symbols (bool, int0to2)Distinguished equality predicate symbol =

(Sorted) L-terms and L-atoms:

L-term (t): v or f (t1, . . . , tm) (x , 1, x + 1)L-atom(G): B(t1, . . . , tm) or t1 = t2 (x > 1, L1, x = 1)Sorts mapped to nonempty domains (bool→ {T,F},int0to2→ {0,1,2})Symbols, terms, atoms mapped to values in appropriatedomains.

Roopsha Samanta Algorithmic Synthesis of Synchronization 5 / 20

Page 11: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

(Finite-state) Concurrent Programs over L

Syntax:

P ::= vardeclaration process || processvardeclaration ::= v1 : domain1, . . . , vn : domainnprocess ::= localvardeclaration bodylocalvardeclaration ::= vardeclarationbody ::= labeledstmt ; body | labeledstmtlabeledstmt ::= LOC: atomicstmtatomicstmt ::= assignment | conditiontest | goto | CCRassignment ::= 〈 v :=t 〉conditiontest ::= 〈 if G LOCif else, LOCelse 〉goto ::= 〈 goto LOC 〉CCR ::= 〈 G→ body 〉v ,LOC ::= L-symbol, t ::= L-term, G ::= L-atom

Semantics: Finite-state transition system (S,S0,R)

Roopsha Samanta Algorithmic Synthesis of Synchronization 6 / 20

Page 12: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

(Finite-state) Concurrent Programs over L

Syntax:

P ::= vardeclaration process || processvardeclaration ::= v1 : domain1, . . . , vn : domainnprocess ::= localvardeclaration bodylocalvardeclaration ::= vardeclarationbody ::= labeledstmt ; body | labeledstmtlabeledstmt ::= LOC: atomicstmtatomicstmt ::= assignment | conditiontest | goto | CCRassignment ::= 〈 v :=t 〉conditiontest ::= 〈 if G LOCif else, LOCelse 〉goto ::= 〈 goto LOC 〉CCR ::= 〈 G→ body 〉v ,LOC ::= L-symbol, t ::= L-term, G ::= L-atom

Semantics: Finite-state transition system (S,S0,R)

Roopsha Samanta Algorithmic Synthesis of Synchronization 6 / 20

Page 13: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

(Finite-state) Concurrent Programs over L

Syntax:

P ::= vardeclaration process || processvardeclaration ::= v1 : domain1, . . . , vn : domainnprocess ::= localvardeclaration bodylocalvardeclaration ::= vardeclarationbody ::= labeledstmt ; body | labeledstmtlabeledstmt ::= LOC: atomicstmtatomicstmt ::= assignment | conditiontest | goto | CCRassignment ::= 〈 v :=t 〉conditiontest ::= 〈 if G LOCif else, LOCelse 〉goto ::= 〈 goto LOC 〉CCR ::= 〈 G→ body 〉v ,LOC ::= L-symbol, t ::= L-term, G ::= L-atom

Semantics: Finite-state transition system (S,S0,R)

Roopsha Samanta Algorithmic Synthesis of Synchronization 6 / 20

Page 14: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

(Finite-state) Concurrent Programs over L

Syntax:

P ::= vardeclaration process || processvardeclaration ::= v1 : domain1, . . . , vn : domainnprocess ::= localvardeclaration bodylocalvardeclaration ::= vardeclarationbody ::= labeledstmt ; body | labeledstmtlabeledstmt ::= LOC: atomicstmtatomicstmt ::= assignment | conditiontest | goto | CCRassignment ::= 〈 v :=t 〉conditiontest ::= 〈 if G LOCif else, LOCelse 〉goto ::= 〈 goto LOC 〉CCR ::= 〈 G→ body 〉v ,LOC ::= L-symbol, t ::= L-term, G ::= L-atom

Semantics: Finite-state transition system (S,S0,R)

Roopsha Samanta Algorithmic Synthesis of Synchronization 6 / 20

Page 15: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

(Finite-state) Concurrent Programs over L

Syntax:

P ::= vardeclaration process || processvardeclaration ::= v1 : domain1, . . . , vn : domainnprocess ::= localvardeclaration bodylocalvardeclaration ::= vardeclarationbody ::= labeledstmt ; body | labeledstmtlabeledstmt ::= LOC: atomicstmtatomicstmt ::= assignment | conditiontest | goto | CCRassignment ::= 〈 v :=t 〉conditiontest ::= 〈 if G LOCif else, LOCelse 〉goto ::= 〈 goto LOC 〉CCR ::= 〈 G→ body 〉v ,LOC ::= L-symbol, t ::= L-term, G ::= L-atom

Semantics: Finite-state transition system (S,S0,R)

Roopsha Samanta Algorithmic Synthesis of Synchronization 6 / 20

Page 16: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

CTL-like Specifications over L (LCTL)

Syntax: φ ::= L-atom | ¬φ |φ ∨ φ |EXφ |EXi φ |A[φUφ] |E[φUφ]

Semantics:Defined from semantics of L-atoms, propositional and temporaloperators

Roopsha Samanta Algorithmic Synthesis of Synchronization 7 / 20

Page 17: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Revisiting Example

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 8 / 20

Page 18: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Synthesis Algorithm Sketch

1 Formulate an LCTL formula φP for semantics of P.

2 Construct a tableau Tφ for φ : φP ∧ φspec .If Tφ is empty, declare specification as unsatisfiable.

3 If Tφ is non-empty, extract a model M for φ from it.

4 Decompose M to obtain CCRs to synchronize each process.

5 Compile CCRs into lower level synchronization primitives([EmeSam2011])

Roopsha Samanta Algorithmic Synthesis of Synchronization 9 / 20

Page 19: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Formulation of φP

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

At any step, only one process moves

AG(L1 ⇒ AX2(L1)) ∧ . . .

Roopsha Samanta Algorithmic Synthesis of Synchronization 10 / 20

Page 20: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Formulation of φP

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

A process is always in exactly one of its locations

AG(L1 ∨ L2 ∨ L3 ∨ L4)AG(L1 ⇒ ¬(L2 ∨ L3 ∨ L4)). . .

Roopsha Samanta Algorithmic Synthesis of Synchronization 10 / 20

Page 21: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Formulation of φP

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

Some process always moves.

AG(EX true)

Roopsha Samanta Algorithmic Synthesis of Synchronization 10 / 20

Page 22: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Formulation of φP

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

Initial condition

L1 ∧ T1 ∧ x = 1

Roopsha Samanta Algorithmic Synthesis of Synchronization 10 / 20

Page 23: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Formulation of φP

P:x : {0, 1, 2} with x = 1P1 ‖ P2

P1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

P2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

Local process execution

AG((L1 ∧ x < 2) ⇒ AX1(L2))AG((L1 ∧ x ≥ 2) ⇒ AX1(L4))AG(

∧c∈{0,1,2}(L2 ∧ x = c) ⇒ AX1(L3 ∧ x = c + 1))

AG(L3 ⇒ AX1(L1)). . .

Roopsha Samanta Algorithmic Synthesis of Synchronization 10 / 20

Page 24: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Construction of Tableau Tφ

Tableau basics:

Finite, rooted, directed AND/OR graphNodes labeled with formulasOR-node formulas valid iff formulas in some AND-node succ. validAND-node formulas valid iff formulas in all OR-node succ. validAssume ability to evaluate L-atoms and L-terms

Algorithm Sketch:

Let root node of Tφ be OR-node, labeled φRepeat until no new nodes can be added:Add appropriate AND-node succ. of OR-nodes and OR-nodesucc. of AND-nodes, merging equivalent nodesPrune inconsistent nodes to get final Tφ

Roopsha Samanta Algorithmic Synthesis of Synchronization 11 / 20

Page 25: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Construction of Tableau Tφ

Tableau basics:

Finite, rooted, directed AND/OR graphNodes labeled with formulasOR-node formulas valid iff formulas in some AND-node succ. validAND-node formulas valid iff formulas in all OR-node succ. validAssume ability to evaluate L-atoms and L-terms

Algorithm Sketch:

Let root node of Tφ be OR-node, labeled φRepeat until no new nodes can be added:Add appropriate AND-node succ. of OR-nodes and OR-nodesucc. of AND-nodes, merging equivalent nodesPrune inconsistent nodes to get final Tφ

Roopsha Samanta Algorithmic Synthesis of Synchronization 11 / 20

Page 26: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Construction of Tableau Tφ

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

Roopsha Samanta Algorithmic Synthesis of Synchronization 12 / 20

Page 27: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Construction of Tableau Tφ

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX2T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T EX2T φspec

Roopsha Samanta Algorithmic Synthesis of Synchronization 12 / 20

Page 28: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Construction of Tableau Tφ

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX2T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T EX2T φspec

L2 T1 x = 1φspec

L1 T2 x = 1φspec

1 21 2

Roopsha Samanta Algorithmic Synthesis of Synchronization 12 / 20

Page 29: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Extraction of Model M from Tφ

Model-fragment:

Rooted DAG of AND-nodes in TφAll eventualities in root node fulfilled

Identify model fragments rooted at each AND-node of Tφ

If multiple model fragments, pick one of minimal size

Join model fragments to get model

Roopsha Samanta Algorithmic Synthesis of Synchronization 13 / 20

Page 30: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Extraction of Model M from Tφ

L1 T1 x = 1

L2 T1 x = 1 L1 T2 x = 1

L3 T1 x = 2 L2 T2 x = 1 L1 T3 x = 0

L3 T2 x = 2 L2 T3 x = 0

L1 T1 x = 2

L4 T1 x = 2 L1 T2 x = 2

L4 T2 x = 2

L4 T3 x = 1

L4 T1 x = 1

L4 T2 x = 1

L4 T3 x = 0 L4 T1 x = 0

L4 T4 x = 0

L1 T1 x = 0

L2 T1 x = 0 L1 T4 x = 0

L2 T4 x = 0

L3 T4 x = 1

L1 T4 x = 1

L2 T4 x = 1

L3 T4 x = 2L1 T4 x = 2

L4 T4 x = 2

1 2

1 2 1 2

1

2 1 2 1

2

1 2

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

Roopsha Samanta Algorithmic Synthesis of Synchronization 14 / 20

Page 31: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Obtaining Ps1 , Ps

2 from M

L1 T1 x = 1

L2 T1 x = 1 L1 T2 x = 1

L3 T1 x = 2 L2 T2 x = 1 L1 T3 x = 0

L3 T2 x = 2 L2 T3 x = 0

L1 T1 x = 2

L4 T1 x = 2 L1 T2 x = 2

L4 T2 x = 2

L4 T3 x = 1

L4 T1 x = 1

L4 T2 x = 1

L4 T3 x = 0 L4 T1 x = 0

L4 T4 x = 0

L1 T1 x = 0

L2 T1 x = 0 L1 T4 x = 0

L2 T4 x = 0

L3 T4 x = 1

L1 T4 x = 1

L2 T4 x = 1

L3 T4 x = 2L1 T4 x = 2

L4 T4 x = 2

1 2

1 2 1 2

1

2 1 2 1

2

1 2

2 1

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

2

1 2

2 1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1

Roopsha Samanta Algorithmic Synthesis of Synchronization 15 / 20

Page 32: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Obtaining Ps1 , Ps

2 from M

P:x : {0, 1, 2} with x = 1P1 ‖ P2

Ps1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 ¬((x = 0) ∧ (T1 ∨ T3))

→ x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

Ps2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 ¬((x = 2) ∧ (L1 ∨ L3))

→ x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 15 / 20

Page 33: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Assumptions, Correctness, Complexity

[Assumptions]:

P1, P2 are finite-state programs over L

All program variables are shared variables, initialized to specific values

L-atoms and L-terms can be evaluated

[Soundness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , if thealgorithm generates Ps, then Ps |= φspec .

[Completeness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , thealgorithm generates Ps such that Ps |= φspec if φ = φspec ∧ φP is satisfiable.

[Complexity]: Exponential in the size of φspec and P variables.

Roopsha Samanta Algorithmic Synthesis of Synchronization 16 / 20

Page 34: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Assumptions, Correctness, Complexity

[Assumptions]:

P1, P2 are finite-state programs over L

All program variables are shared variables, initialized to specific values

L-atoms and L-terms can be evaluated

[Soundness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , if thealgorithm generates Ps, then Ps |= φspec .

[Completeness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , thealgorithm generates Ps such that Ps |= φspec if φ = φspec ∧ φP is satisfiable.

[Complexity]: Exponential in the size of φspec and P variables.

Roopsha Samanta Algorithmic Synthesis of Synchronization 16 / 20

Page 35: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Assumptions, Correctness, Complexity

[Assumptions]:

P1, P2 are finite-state programs over L

All program variables are shared variables, initialized to specific values

L-atoms and L-terms can be evaluated

[Soundness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , if thealgorithm generates Ps, then Ps |= φspec .

[Completeness]:Given unsynchronized processes P1, P2 and an LCTL formula φspec , thealgorithm generates Ps such that Ps |= φspec if φ = φspec ∧ φP is satisfiable.

[Complexity]: Exponential in the size of φspec and P variables.

Roopsha Samanta Algorithmic Synthesis of Synchronization 16 / 20

Page 36: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Uninitialized Variables

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

Roopsha Samanta Algorithmic Synthesis of Synchronization 17 / 20

Page 37: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Uninitialized Variables

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX2T φspec

L1 T1 x = 1AX1L2 AX1T1

AX2T2 AX2L1

EX1T EX2T φspec

L2 T1 x = 1φspec

L1 T2 x = 1φspec

1 21 2

Roopsha Samanta Algorithmic Synthesis of Synchronization 17 / 20

Page 38: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Uninitialized Variables

φspec = AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

EX(L1 ∧ T1 ∧ x = 0) ∧EX(L1 ∧ T1 ∧ x = 1) ∧EX(L1 ∧ T1 ∧ x = 2)

φspec

L1 T1 x = 2EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

L1 T1 x = 1EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

L1 T1 x = 0EX1T ∨ EX2T ∨(EX1T ∧ EX2T)

φspec

Roopsha Samanta Algorithmic Synthesis of Synchronization 17 / 20

Page 39: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Uninitialized Variables

L1 T1 x = 1

L2 T1 x = 1 L1 T2 x = 1

L3 T1 x = 2 L2 T2 x = 1 L1 T3 x = 0

L3 T2 x = 2 L2 T3 x = 0

L1 T1 x = 2

L4 T1 x = 2 L1 T2 x = 2

L4 T2 x = 2

L4 T3 x = 1

L4 T1 x = 1

L4 T2 x = 1

L4 T3 x = 0 L4 T1 x = 0

L4 T4 x = 0

L1 T1 x = 0

L2 T1 x = 0 L1 T4 x = 0

L2 T4 x = 0

L3 T4 x = 1

L1 T4 x = 1

L2 T4 x = 1

L3 T4 x = 2L1 T4 x = 2

L4 T4 x = 2

1 2

1 2 1 2

1

2 1 2 1

2

1 2

2 1

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

2

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1

Roopsha Samanta Algorithmic Synthesis of Synchronization 17 / 20

Page 40: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Observability

P:x : {0, 1, 2} with x = 1P1 ‖ P2

Ps1:L1: 〈 if (x < 2) L2, L4 〉;L2: 〈 ¬((x = 0) ∧ (T1 ∨ T3))

→ x := x + 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

Ps2:T1: 〈 if (x > 0) T2, T4 〉;T2: 〈 ¬((x = 2) ∧ (L1 ∨ L3))

→ x := x − 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 18 / 20

Page 41: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Observability

L1 T1 x = 1

L2 T1 x = 1 L1 T2 x = 1

L3 T1 x = 2 L2 T2 x = 1 L1 T3 x = 0

L3 T2 x = 2 L2 T3 x = 0

L1 T1 x = 2

L4 T1 x = 2 L1 T2 x = 2

L4 T2 x = 2

L4 T3 x = 1

L4 T1 x = 1

L4 T2 x = 1

L4 T3 x = 0 L4 T1 x = 0

L4 T4 x = 0

L1 T1 x = 0

L2 T1 x = 0 L1 T4 x = 0

L2 T4 x = 0

L3 T4 x = 1

L1 T4 x = 1

L2 T4 x = 1

L3 T4 x = 2L1 T4 x = 2

L4 T4 x = 2

1 2

1 2 1 2

1

2 1 2 1

2

1 2

2 1

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

2

1 2

2 1

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1, 2

1

Roopsha Samanta Algorithmic Synthesis of Synchronization 18 / 20

Page 42: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Observability

P:x : {0, 1, 2} with x = 1t : bool with t = 1l : bool with l = 1P1 ‖ P2

Ps1:L1: 〈 if (x < 2) L2, L4;

l := 0 〉;L2: 〈 ¬((x = 0) ∧ (t = 1))

→ x := x + 1; l := 1 〉;L3: 〈 goto L1 〉;L4: 〈 goto L4 〉;

Ps2:T1: 〈 if (x > 0) T2, T4;

t := 0 〉;T2: 〈 ¬((x = 2) ∧ (l = 1))

→ x := x − 1; t := 1 〉;T3: 〈 goto T1 〉;T4: 〈 goto T4 〉;

AF(L4 ∧ T4 ∧ (x = 0 ∨ x = 2))

Roopsha Samanta Algorithmic Synthesis of Synchronization 18 / 20

Page 43: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Related Work

Inference of high-level synchronization, guardedcommands: [EC82, VYY09]Synthesis of low-level synchronization for relaxed memorymodels: [KVV10]Sketching: [S-LRBE05]Open systems [PR89]

Roopsha Samanta Algorithmic Synthesis of Synchronization 19 / 20

Page 44: Towards Algorithmic Synthesis of Synchronization for Shared … · 2016-07-16 · GroundworkAlgorithmExtensionsConclusion Towards Algorithmic Synthesis of Synchronization for Shared-Memory

Groundwork Algorithm Extensions Conclusion

Ongoing Work

Efficient tableau construction?Infinite-state programs?Pleasant guards?Other synchronization primitives?

Roopsha Samanta Algorithmic Synthesis of Synchronization 20 / 20