CIS 720 Lecture 4.

Slides:



Advertisements
Similar presentations
The "if structure" is used to execute statement(s) only if the given condition is satisfied.
Advertisements

50.530: Software Engineering Sun Jun SUTD. Week 13: Rely-Guarantee Reasoning.
CIS 720 Lecture 2. Concurrency …shared variable declaration…. …shared variable initialization… co P 1 // P 2 // P 3 // P 4 oc Execution of P 1 … P 4 starts.
Reduction, abstraction, and atomicity: How much can we prove about concurrent programs using them? Serdar Tasiran Koç University Istanbul, Turkey Tayfun.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Multiprocessor Synchronization Algorithms ( ) Lecturer: Danny Hendler The Mutual Exclusion problem.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 12 The Critical Section problem John Gurd, Graham Riley Centre for Novel.
CIS 720 Mutual Exclusion. Critical Section problem Process i do (true) entry protocol; critical section; exit protocol; non-critical section od.
VIDE Integrated Environment for Development and Verification of Programs.
1 Intro to Induction Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
TR1413: INTRO TO DISCRETE MATHEMATICS LECTURE 2: MATHEMATICAL INDUCTION.
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
DAST 2005 Tirgul 6 Heaps Induction. DAST 2005 Heaps A binary heap is a nearly complete binary tree stored in an array object In a max heap, the value.
Verifying a Wait Free Register Algorithm Using Assertional Reasoning Xu Qiwen Faculty of Science and Technology University of Macau.
Representing distributed algorithms Why do we need these? Don’t we already know a lot about programming? Well, you need to capture the notions of atomicity,
CSE 311 Foundations of Computing I Lecture 15 Recursive Definitions and Structural Induction Autumn 2011 CSE 3111.
Sept COMP60611 Fundamentals of Parallel and Distributed Systems Lecture 15 More Advanced Program Properties: Temporal logic and jSpin John Gurd,
Program Correctness. 2 Program Verification An object is a finite state machine: –Its attribute values are its state. –Its methods optionally: Transition.
9.4 Mathematical Induction
Logical Reasoning:Proof Prove the theorem using the basic axioms of algebra.
Mutual Exclusion Using Atomic Registers Lecturer: Netanel Dahan Instructor: Prof. Yehuda Afek B.Sc. Seminar on Distributed Computation Tel-Aviv University.
Hwajung Lee. The State-transition model The set of global states = s 0 x s 1 x … x s m {s k is the set of local states of process k} S0  S1  S2  Each.
CIS 720 Correctness of Concurrent Programs. i := 1 max := A[1] do i < n  i = i + 1 if (max < A[i]) max = A[i] od.
From … to Induction CS 270 Math Foundations of CS Jeremy Johnson.
CSE373: Data Structures and Algorithms Lecture 2: Proof by Induction Linda Shapiro Winter 2015.
CIS 720 Lecture 5. Techniques to avoid interference Disjoint variables –If the write set of each process is disjoint from the read and write set of other.
Introduction to Proofs
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
A Calculus of Atomic Actions Tayfun Elmas, Shaz Qadeer and Serdar Tasiran POPL ‘ – Seminar in Distributed Algorithms Cynthia Disenfeld 27/05/2013.
Other Forms of Induction CS 270 Math Foundations of CS Jeremy Johnson.
Program Analysis and Verification
1 Computer Algorithms Tutorial 2 Mathematical Induction Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
5-5 Indirect Proof. Indirect Reasoning: all possibilities are considered and then all but one are proved false. The remaining possibility must be true.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Mathematical Induction. The Principle of Mathematical Induction Let S n be a statement involving the positive integer n. If 1.S 1 is true, and 2.the truth.
11.7 – Proof by Mathematical Induction
Chapter 3 The Real Numbers.
CSE 311: Foundations of Computing
What I Teach (Do what I say, not what I do)
Self-stabilization.
Mathematical Structures for Computer Science Chapter 1
Atomicity, Non-determinism, Fairness
ITEC452 Distributed Computing Lecture 5 Program Correctness
Notes 9.5 – Mathematical Induction
Axiomatic Verification II
PROOF BY CONTRADICTION
CIS 720 Mutual Exclusion 2.
IS 2150 / TEL 2810 Introduction to Security
Invariant Based Methodology
Axiomatic Verification II
Chapter 11: Further Topics in Algebra
CIS 720 Lecture 5.
Program correctness Axiomatic semantics
CIS 720 Lecture 6.
COMP60621 Designing for Parallelism
CIS 720 Lecture 4.
CIS 720 Lecture 3.
CIS 720 Lecture 3.
CIS 720 Lecture 5.
CIS 720 Lecture 2.
CIS 720 Lecture 4.
IS 2150 / TEL 2810 Introduction to Security
CIS 720 Lecture 4.
CIS 720 Lecture 2.
CIS 720 Mutual Exclusion 2.
IS 2150 / TEL 2810 Information Security & Privacy
CIS 720 Lecture 4.
Program Analysis and Verification
11.4 Mathematical Induction
Program Correctness an introduction.
Presentation transcript:

CIS 720 Lecture 4

Concurrency rule for all i, { Pi } Si { Qi } { P1 /\ …. /\ Pn } co S1 // …. // Sn oc { Q1 /\ …. /\ Qn}

{true} {true} x = 0; y = 1; x = 0; co co x = 1 x = x + 1 // // y = y + 1 x = x + 2 oc oc { x = 0 /\ y = 1} { x = 0} {x = 0} {x = 0} {x = 1} {x = 1} {y = 1} {x = 0} {y = 2} {x = 2} { x = 1 /\ y = 2} { x = 0 /\ x = 2}

Interference freedom Let a be a statement and C be an assertion. NI(a, C) iff { pre(a) /\ C } a { C } Execution of a does not invalidates (or interferes) with C. {pre(a) /\ C a C

{ Pi } Si { Qi }, for all i, are interference free if for all assertions C in proof outline of Si, for all actions a in Sj, i != j NI(a, C) holds

Concurrency rule { Pi } Si { Qi } are interference free { P1 /\ …. /\ Pn } co S1 // …. // Sn { Q1 /\ …. /\ Qn}

x= 0; co x = x + 1 // x = x + 2 od

NI (x = 0 \/ x = 2, x = x + 2) To prove { (x = 0 \/ x = 2) /\ (x = 0 \/ x = 1}) x := x + 2 { x = 0 \/ x = 2)} { (x = 0) x := x + 2 { x = 0 \/ x = 2)} x (x = 0 \/ x = 2 )x+ 2 (x + 2 = 0 \/ x + 2 = 2) (x = -2 \/ x = 0) x = 0  (x = -2 \/ x = 0) { (x = 0) x := x + 2 { x = 0 \/ x = 2)}

Techniques to avoid interference Disjoint variables If the write set of each process is disjoint from the read and write set of other processes, then the proof outlines will be interference free.

Avoiding interference Global Invariants: Assume that every assertion in the proof outline of Pi is of the form I /\ L, where L refers to local variables of Pi or to variables that only Pi writes. - Then the proof outlines will be interference free.

Concurrency rule for all i, { I} Si { I } { I } co S1 // …. // Sn { I}

x = 0 ; y = 0; z = 0 co x = 1 y := 1 // if y = 1  z = 1 oc

x = 0 ; y = 0; z = 0 co x = 1 y := 1 // if y = 1  z = 1 oc

Avoiding interference Weakened assertions x= 0; co x = x + 1 // x = x + 2 od {x = 0} {x = 0 \/ x = 2}

Avoiding interference Synchronization

Bank transactions co // Transfer(x,y,am): Auditor: ac[x] = ac[x] – am; total = 0; i = 0; ac[y] = ac[y] + am do i < n total = total + ac[i] i = i + 1 od oc

Avoiding interference Synchronization Await Statement rule {P /\ B } S {Q} {P} < await(B)  S > {Q} { y > 0 } y := x { x > 0 } { true } await(y > 0)  y := x { x > 0 }

b = false x = 0 ; y = 0; z = 0 co x = x + 1 b := true z = x + 3 // < await b  y = x > oc

b = false x = 0 ; y = 0; z = 0 co x = x + 1 b := true z = x + 3 // < await b  y = x > oc (I /\ x = 1 /\ not b) /\ (I /\ b) false

Bank transactions total = 0; i = 0; co // Transfer(x,y,am): Auditor: < await( (i < x /\ i < y) \/ {A1: Total = ac[1]+….+ac[i] } (i > x /\ i > y)) do i < n  ac[x] = ac[x] – am; i = i + 1 ac[y] = ac[y] + am > total = total + ac[i] od oc

Bank transactions co // Transfer(x,y,am): Auditor: if < await(!auditon)  ac[x] = ac[x] – am; auditon = 1; total = 0; i = 0; ac[y] = ac[y] + am > [] do i < n <await (auditon && ( (x < i && y < i) ||(x > i && y > i))) total = total + ac[i]  ac[x] = ac[x] – am; ac[y] = ac[y] + am> i = i + 1 fi od auditon = 0 oc