Safety and Liveness. Defining Programs Variables with respective domain –State space of the program Program actions –Guarded commands Program computation.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Program correctness The State-transition model A global state S  s 0 x s 1 x … x s m {s k = local state of process k} S0  S1  S2  … Each state transition.
Kripke: Outline …(1975) First improtant decision: the theory is about sentences, not about propositions. Like Tarski, not like Barwise & Etchemendy. ***
Determinization of Büchi Automata
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Section 7.4: Closures of Relations Let R be a relation on a set A. We have talked about 6 properties that a relation on a set may or may not possess: reflexive,
Lecture 2: Reasoning with Distributed Programs Anish Arora CSE 6333.
Finite state machines.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
INFINITE SEQUENCES AND SERIES
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
CS 536 Spring Global Optimizations Lecture 23.
Discrete Mathematics Lecture 4 Harper Langston New York University.
13. The Weak Law and the Strong Law of Large Numbers
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
Monadic Predicate Logic is Decidable Boolos et al, Computability and Logic (textbook, 4 th Ed.)
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
PROBABILITY AND STATISTICS FOR ENGINEERING Hossein Sameti Department of Computer Engineering Sharif University of Technology The Weak Law and the Strong.
1 2. Independence and Bernoulli Trials Independence: Events A and B are independent if It is easy to show that A, B independent implies are all independent.
CS 173, Lecture B August 27, 2015 Tandy Warnow. Proofs You want to prove that some statement A is true. You can try to prove it directly, or you can prove.
Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
1 Lecture 3 (part 3) Functions – Cardinality Reading: Epp Chp 7.6.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: Sequencing Properties Copyright , Matt Dwyer, John Hatcliff,
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Lecture #5 Properties of hybrid systems João P. Hespanha University of California at Santa Barbara Hybrid Control and Switched Systems.
Defining Programs, Specifications, fault-tolerance, etc.
Issues with Clocks. Context The tree correction protocol was based on the idea of local detection and correction. Protocols of this type are complex to.
Section 2.3 Properties of Solution Sets
CS201: Data Structures and Discrete Mathematics I
CS 395T Game-Based Verification of Contract Signing Protocols.
CS 267: Automated Verification Lecture 3: Fixpoints and Temporal Properties Instructor: Tevfik Bultan.
Program correctness The State-transition model The set of global states = so x s1 x … x sm {sk is the set of local states of process k} S0 ---> S1 --->
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Program correctness The State-transition model A global states S  s 0 x s 1 x … x s m {s k = set of local states of process k} S0  S1  S2  Each state.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
Recognizing safety and liveness Presented by Qian Huang.
Stabilization Presented by Xiaozhou David Zhu. Contents What-is Motivation 3 Definitions An Example Refinements Reference.
Defining Liveness by Bowen Alpern and Fred B. Schneider Presented by Joe Melnyk.
Distributed systems Consensus Prof R. Guerraoui Distributed Programming Laboratory.
Safety and Liveness. Recall Program –State space Program computation –Of the form Consider the set of all program computations.
Chapter 8 Asynchronous System Model by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
CS 542: Topics in Distributed Systems Self-Stabilization.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
1 Temporal logic. 2 Prop. logic: model and reason about static situations. Example: Are there truth values that can be assigned to x,y simultaneously.
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
INFINITE SEQUENCES AND SERIES The convergence tests that we have looked at so far apply only to series with positive terms.
Design of Tree Algorithm Objectives –Learning about satisfying safety and liveness of a distributed program –Apply the method of utilizing invariants and.
Summary of the Last Lecture This is our second lecture. In our first lecture, we discussed The vector spaces briefly and proved some basic inequalities.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
CS 173, Lecture B August 27, 2015 Tandy Warnow. Proofs You want to prove that some statement A is true. You can try to prove it directly, or you can prove.
1 Maximality Properties Dr. Mikhail Nesterenko Presented By Ibrahim Motiwala.
Chapter 2 Sets and Functions.
Fixpoints and Reachability
Overview Theory of Program Testing Goodenough and Gerhart’s Theory
Copyright © Cengage Learning. All rights reserved.
Set Topology MTH 251 Lecture # 8.
Instructor: Aaron Roth
Turing Machines Everything is an Integer
Presentation transcript:

Safety and Liveness

Defining Programs Variables with respective domain –State space of the program Program actions –Guarded commands Program computation – –(s j-1, s j ) is permitted by program actions Consider set of all program computations –Could depend upon the notion of fairness

Program Correctness How do we define that a program is correct with respect to its specification? –Intuition: A program is correct if all its computations are in the specification For above intuition to work, the specification should be the set of acceptable sequences of program states –Note that the program does not have to exhibit all behaviors in the specification –It just should not exhibit anything that it is not permitted by the specification

Hence, From now on, let specification be a set of infinite sequences of states

Example Coke and Pepsi vending machine –Specification: pressing a button results in dispensation of a Coke or Pepsi

Consider Programs Program 1 ButtonPressed  Dispense Coke Program 2 ButtonPressed  Dispense Pepsi Program 3 ButtonPressed  Dispense Coke ButtonPressed  Dispense Pepsi

Consider Programs Program 4 ButtonPressed  Dispense Sprite

Observations about Programs and Specifications Suppose that you do not have access to code of program P. You can only observe its behavior. –Observed behavior is one state at a time –Observed behavior is finite Looking at a finite prefix, we can never say that the specification is satisfied We may be able to say that the specification is NOT satisfied.

Specification 1 Vending machine only dispenses coke or pepsi Consider the behavior c,p,c,p,s,c,p, … Suppose a program behavior violates a specification, will you always be able to detect it at some finite point? –What do we mean that we detected safety violation at a finite point? It means that no matter what future states are the specification cannot be satisfied by that sequence. This is the intuition behind safety specification.

Specification 2 Vending machine is guaranteed to dispense pepsi Consider the finite behavior c,c,c,c,s,s,7 Given any finite behavior, can you say that the specification cannot be satisfied This is the intuition behind liveness specification

Specification 2 continued Suppose the infinite sequence were c,c,c,c,c, … Even though this sequence does not satisfy specification 2, we cannot conclude this at any finite point.

Specification 3 Dispense only coke or pepsi and that eventually dispense pepsi –Is this safety, liveness, both or neither This color is black This color is white This color is neither black nor white although it is a combination of the two

Safety and Liveness Safety –Intuition: Nothing bad happens Intuition: If something bad happens, it cannot be fixed Intuition: if a sequence violates specification then it does so at some finite point after which it cannot be fixed. –  :  SafetySpec : (  :  is a prefix of    ::   SafetySpec)

Safety and Liveness Liveness –Intuition: Something good happens eventually Intuition: No matter what has happened so far, the specification can be met  :  is finite sequence of states:  ::   LivenessSpec

Recalling weak fairness and strong fairness Are these safety properties? Are these liveness properties? What is a good fairness property?

Examples of Properties Invariant (S) : Predicate S is true in every state Closed (S) : If predicate S is true in some state, it will remain true in the next P Leads to Q : If P is ever true in some state then Q will be true in that or some future state P Converges to Q : Closed(P) and Closed(Q) and P leads to Q

–Consider sequenec P, p, p, … Violates specificatin Cannot say that at any finite point –Not a safety specification –Is there any finite prefix alpha such that alpha cannot be extended to satisfy the specification?

To show that P conv to Q is not a safety property Create a sequence that violates P converges to Q such that –At finite point, you cannot say that spec is violated –(P&NotQ), (P&NotQ) …

To show that P converges to Q is not a liveness property Find some alpha such that it cannot be extended to satisfy the specification P, NotP,

Specification 3 For vending machine: For every 10 consecutive button pressed, dispense at least 4 coke and at least 4 pepsi This is a safety specification

c Consider sequence –C, c, c, c, c, c, c

Specification 4 Pepsi must be dispensed at least once in 10 steps

Specification 4 After some point, the machine will only dispense pepsi This is a liveness specification

Sf1 & Sf2 Given Sf1, Sf2 is a safety specificaiton Show Sf1 & Sf2 is a safety specification For all sigma : sigma not in Sf1 & Sf2 : Take any sigma not in Sf1 and Sf2 –Case 1: sigma not in Sf1 –Case 2: sigma not in Sf2

Given –  :  Sf1 : (  :  is a prefix of    ::   Sf1) –  :  Sf2 : (  :  is a prefix of    ::   Sf2) To prove –  :  Sf1 & Sf2 : (  :  is a prefix of    ::   Sf1 & Sf2)

Case 1 Sigma not in Sf1 –There exists alpha : for all beta : Alpha beta is not in sf1 ==> there exists alpha : for all beta : alpha beta is not in sf1 & sf2 Same for Case 2 : Completes proof for showing that sf1 & sf2 is a safety property

Observation Some properties are neither safety properties nor liveness properties. They appear to be a combination of the two. Goal: prove that any property can be expressed as an intersection of a safety property and a liveness property

Spec1 = Always dispense coke or pepsi Spec2 = always dispense coke Spec3 = Always dispense coke and pepsi and eventually dispense pepsi Spec4 = dispense coke and pepsi in an alternating manner –Spec4 subset of spec1 –Spec2 is not a subset of spec4 and vice versa –Spec2 is a subset of spec1 but not of spec3 –Spec3 is a subset of spec1

Manipulation of Safety/Liveness Properties Intersection of safety and liveness properties –Step 1: Intersection of any number of safety properties is a safety property –Step 2: Given a specification, spec, find the smallest safety specification sf such that spec  sf –Step 3: spec = sf  (spec  (S w – sf)) –Step 4: (spec  (S w – sf)) is a liveness specification

Let sigma be some sequence Suppose spec = { sigma }, spec only contains one sequence

Towards Proving spec = safety  liveness S w denotes the set of all computations  S w denotes the set of all computations with prefix  (S w -  S w ) is a safety specification

Towards Proving spec = safety  liveness Consider (infinitely many) safety properties sf1, sf2, … –Is the union of them a safety specification? –Is the intersection of them a safety specification?

Towards Proving spec = safety  liveness Let spec be the given specification –Consider the set of safety properties sf 1, sf 2, … such that spec  sf i –Consider the intersection of these safety properties Let sf denote this intersection Observe: spec  sf sf is a safety specification

` P converges to Q is subset of closed(P) P converges to Q is a subset of closed(Q) P converges to Q is a subset of invariant(true) …

Properties of sf Consider a sequence   sf – spec –Let  be any prefix of  –There must exist  such that   spec –If not spec  (sf  (S w -  S w )), which is a safety specification This is a contradiction as sf is supposed to smallest safety specification containing spec

Towards Proving spec = safety  liveness spec = sf  (spec  (S w – sf)) Safety specification Liveness specification

To prove sf  (spec  (S w – sf)) = Sf  spec  ( sf  (S w – sf)) = spec

To show that (spec  (S w – sf)) is a liveness specification: For any , some extension of  is in (spec  (S w – sf)) Let  be any infinite extension of  Case 1:   spec : trivial Case 2:   (S w – sf) : trivial Case 3:   sf – spec: –Every prefix of  has an extension that satisfies spec –By construction  is a prefix of 

(x > 0) converges to (x > 5) –(x > 0) is closed, i.e., if x is 1 or higher, x can never become 0 or negative –(x > 5) is closed –If (x > 0) is reached then eventually (x > 5) would be reached Safety specification –x is always equal to 10 (not a superset of converges because –X is always greater than 0 (superset of converges) –Closed (x > 0) (superset of converges) –Closed (x > 5) (superset of converges) –Closed (x > 0) & Closed (x > 5) (superset of converges), … This is the smallest safety specification for converges

What happens if the sequence satisfies –Closed (x > 0) & Closed (x > 5) But violates (x > 0) congerges to (x > 5) –For any such sequence, at a finite point, there is a hope of satisfying the (x > 0) congerges to (x > 5)

Topology based explanation

Use of Safety and Liveness in Designing Programs Techniques for satisfying safety –Invariants –Closure We will discuss these next. Techniques for satisfying liveness –Variant functions We will discuss these briefly

Revisiting Fairness Properties What observation can you make about –Weak fairness –Strong fairness

Some Comments about this Framework Safety liveness framework discussed here relies on certain assumptions –A computation is correct if is included in the specification –More specifically, correctness of one computation does not depend on other computations –In other words, whether a computation satisfies the specification or not can be deduced solely from the computation and the specification

Comments (Continued) In some situations, this does not work –Example: Average response time for a request is 10 steps