Program correctness SAT and its correctness

Slides:



Advertisements
Similar presentations
Algorithmic Software Verification VII. Computation tree logic and bisimulations.
Advertisements

Functional Verification III Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 23.
1 Computation Tree Logic (CTL). 2 CTL Syntax P - a set of atomic propositions, every p  P is a CTL formula. f, g, CTL formulae, then so are  f, f 
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Programming Language Semantics Denotational Semantics Chapter 5 Based on a lecture by Martin Abadi.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
Programming Language Semantics Denotational Semantics Chapter 5 Part II.
Temporal Logic and Model Checking. Reactive Systems We often classify systems into two types: Transformational: functions from inputs available at the.
¹ -Calculus Based on: “Model Checking”, E. Clarke and O. Grumberg (ch. 6, 7) “Symbolic Model Checking: 10^20 States and Beyond”, Burch, Clark, et al “Introduction.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Induction and recursion
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
A Simple Model Checker for CTL. The problem n We need efficient algorithms to solve the problems [1]M,s  [2]M,s  where M should have finitely many states,
Rev.S08 MAC 1140 Module 12 Introduction to Sequences, Counting, The Binomial Theorem, and Mathematical Induction.
The ACL2 Proof Assistant Formal Methods Jeremy Johnson.
Solving fixpoint equations
Reading and Writing Mathematical Proofs
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
10/19/2015COSC , Lecture 171 Real-Time Systems, COSC , Lecture 17 Stefan Andrei.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
CS 267: Automated Verification Lecture 3: Fixpoints and Temporal Properties Instructor: Tevfik Bultan.
More on Correctness. Prime Factorization Problem: Write a program that computes all the prime factors of a given number Solution (Idea): Factors are less.
1 Symmetry Symmetry Chapter 14 from “Model Checking” by Edmund M. Clarke Jr., Orna Grumberg, and Doron A. Peled presented by Anastasia Braginsky March.
September 29, 2009Theory of Computation Lecture 7: Primitive Recursive Functions III 1 Some Primitive Recursive Functions Example 3: h(x) = x! Here are.
1 CSEP590 – Model Checking and Automated Verification Lecture outline for July 9, 2003.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
29/06/2016Verification Synchronous Languages Verification.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
ALGORITHMS PROVING ALGORITHMS (PROGRAMS) CORRECT WITH AND WITHOUT INDUCTION.
How CTL model checking works
Equivalence Relations
All-pairs Shortest paths Transitive Closure
Fixpoints and Reachability
Functional Verification III
Week 3 2. Review of inner product spaces
CSEP590 – Model Checking and Automated Verification
Symbolic Model Checking Revision Slides
CTL model checking algorithms
Advanced Algorithms Analysis and Design
Theory Of Computer Science
Disjunctive Normal Form
Mathematical Induction Recursion
Functional Verification III
Proving Properties of Recursive List Functions
Copyright © Cengage Learning. All rights reserved.
Programming Languages and Compilers (CS 421)
1st-order Predicate Logic (FOL)
CSCI1600: Embedded and Real Time Software
Computer Security: Art and Science, 2nd Edition
Formal methods in software development
MA/CSSE 474 Theory of Computation
Functional Verification III
Application: Algorithms
Formal methods in software development
Functional Verification III
Advanced Analysis of Algorithms
Primitive Recursive Predicates
Program correctness Axiomatic semantics
Program Verification with Hoare Logic
Program correctness Branching-time temporal logics
Model Checking CS 680 Formal Methods Jeremy Johnson.
Equivalence Relations
Program correctness Model-checking CTL
Instructor: Aaron Roth
Theory of Computation Lecture 6: Primitive Recursive Functions I
Theory of Computation Lecture 17: Calculations on Strings II
1st-order Predicate Logic (FOL)
Presentation transcript:

Program correctness SAT and its correctness Spring 2007 Program correctness SAT and its correctness  Marcello Bonsangue

Next we present an algorithm for it and proves its correctness Context We have defined the semantics of CTL formulas M,s   We have given an efficient method for model checking a CTL formula returning all states s such that M,s   Next we present an algorithm for it and proves its correctness Slide 2

The algorithm SAT SAT stands for ‘satisfies’ Written in Pascal-like Input: a well-formed CTL formula Output: a subset of the states of a transition system M = <S, ,l> Written in Pascal-like function return local_var while do od case is end_case Slide 3

The main function (I) function SAT() begin case  is T : return S atomic : return {s  S |  l(s) } 1 : return S - SAT(1) 1  2 : return SAT(1)  SAT(2) 1  2 : return SAT(1)  SAT(2) 1  2 : return SAT(1  2) : Slide 4

The main function (II) : AX1 : return SAT(EX1) EX1 : return SAT_EX(1) A[1 U 2] : return SAT(E[2U(1 2)]EG2) E[1 U 2] : return SAT_EU(1, 2) EF1 : return SAT(E[T U 1]) AF1 : return SAT_AF(1) EG1 : return SAT(AF1) /*SAT_EG(1)*/ AG1 : return SAT(EF1) end_case end Slide 5

The function SAT_EX function SAT_EX() local_var X,Y begin X := SAT() Y := { s  S | s  s’ : s’  X} return Y end Slide 6

The function SAT_AF function SAT_AF() local_var X,Y begin X := S Y := SAT() while X  Y do X := Y Y := Y  { s  S | s  s’ : s’  Y } od return Y end Slide 7

The function SAT_EU function SAT_EU(,) local_var W,X,Y begin W := SAT() X := S Y := SAT() /* Calculated only once */ while X  Y do X := Y Y := Y  (W  { s  S | s  s’ : s’  Y }) od return Y end Slide 8

The function SAT_EG function SAT_EG() local_var X,Y begin X :=  Y := SAT() while X  Y do X := Y Y := Y  { s  S | s  s’ : s’  Y } od return Y end Slide 9

SAT() = { s  S | M,s  } = [[]] Does it work? Claim: For a given model M=<S, , l> and well-formed CTL formula , SAT() = { s  S | M,s  } = [[]] def Is this true? Slide 10

The proof (I) The claim is proved by induction on the structure of the formula. For  = T, , or atomic the set [[]] is computed directly For , 1  2, 1  2 or 1  2 we apply induction and predicate logic equivalences Example: SAT(1  2) = SAT(1)  SAT(2) = [[1]]  [[2]] (induction) = [[1  2]] Slide 11

The proof (II) For EX we apply induction SAT(EX) = SAT_EX( ) = { s  S |  s  s’ : s’  SAT()} = { s  S | s  s’ : s’ [[]]} (induction) = { s  S | s  s’ : M,s’  } (definition [[-]]) = { s  S | M,s  EX} (definition  ) = [[EX]] (definition [[-]]) Slide 12

The proof (III) For AX, A[1 U 2], EF, or AG we can rely on logical equivalences and on the correctness of SAT_EX, SAT_AF, SAT_EU, and SAT_EG Example: SAT(AX) = SAT(EX) = S - SAT_EX() (def. SAT()) = S - [[EX]] (correctness SAT_EX) = [[AX]] (logical equivalence) But we still have to prove the correctness of SAT_AF, SAT_EU, and SAT_EG Slide 13

? EG as fixed point Recall that EG    EX EG. Since EX = { s  S |  s  s’ : s’  [[]]} we have the following fixed-point definition of EG [[EG]] = [[]]  { s  S | s  s’ : s’  [[EG]]} ? Slide 14

Fixed points Let S be a set and F:Pow(S)  Pow(S) be a a function F is monotone if X  Y implies F(X)  F(Y) for all subsets X and Y of S A subset X of S is a fixed point of F if F(X) =X A subset X of S is a least fixed point of F if F(X) = X and X  Y for all fixed point Y of F Slide 15

Examples S = {s,t} and F:X  X  {s} F is monotone {s} and {s,t} are all fixed points of F {s} is the least fixed point of F S = {s,t} and G:Xif X={s} then {t} else {s} G is not monotone {s}  {s,t} but G({s}) = {t}  {s} = G({s,t}) G does not have any fixed point Slide 16

Fixed points (II) Let Fi(X) = F(F(…F(X)…)) for i > 0 (thus F1(X) = F(X))  i-times Theorem: Let S be a set with n+1 elements. If F:Pow(S)  Pow(S) is a monotone function then 1) Fn+1() is the least fixed point of F 2) Fn+1(S) is the greatest fixed point of F Least and greatest fixed points can be computed and the computation is guaranteed to terminate ! Slide 17

Computing EG we look if it is a fixed point of the function To find a set [[EG]] such that [[EG]] = [[]]  { s  S | s  s’ : s’  [[EG]]} we look if it is a fixed point of the function F(X) = [[]]  { s  S | s  s’ : s’  X} Theorem: Let n = |S| be the size of S and F defined as above. We have F is monotone [[EG]] is the greatest fixed point of F [[EG]] = Fn+1(S) Slide 18

F(X) = [[]]  { s  S | s  s’ : s’  X} Correctness of SAT_EG Inside the loop it always holds Y  SAT() Because Y  SAT(), substitute in SAT_EG Y := Y  { s  S | s  s’ : s’  Y } with Y := SAT()  { s  S | s  s’ : s’  Y } Note that SAT_EG() is calculating the greatest fixed point (use induction!) F(X) = [[]]  { s  S | s  s’ : s’  X} It follows from the previous theorem that SAT_EG() terminates and computes [[EG]]. Slide 19

Example: EG s2 s0 s1 q Let us compute [[EGq]]. s3 p s4 q It is the greatest fixed point of F(X) = [[q]]  { s  S | s  s’ : s’  X } = {s0,s4}  { s  S | s  s’ : s’  X } Slide 20

Example: EG Iterating F on S until it stabilizes F1(S) ={s0,s4}  { s  S | s  s’ : s’  S } = {s0,s4}  S = {s0,s4} F2(S) =F(F1(S)) = F({s0,s4}) = {s0,s4}  { s  S | s  s’ : s’  {s0,s4} } Thus {s0,s4} is the greatest fixed point of F and equals [[EGq]] Slide 21

? EU as fixed point Recall that E[ U ]    (  EX E[ U ]). Since EX = { s  S |  s  s’ : s’  [[]]} we obtain [[E[U]]] = [[]]([[]]{sS | s  s’: s’[[E[U]]]}) ? Slide 22

G(X) = [[]]  ([[]]  { s  S | s  s’ : s’  X}) Computing E[ U ] As before, we show that [[E[ U ]]] is a fixed point of the function G(X) = [[]]  ([[]]  { s  S | s  s’ : s’  X}) Theorem: Let n = |S| be the size of S and G defined as above. We have G is monotone [[E[ U ]]] is the least fixed point of G [[E[ U ]]] = Gn+1() Slide 23

Correctness of SAT_EU Inside the loop it always holds W=SAT() and Y  SAT(). Substitute in SAT_EU Y:=Y  (W  { s  S | s  s’ : s’  Y }) with Y:=SAT()  (SAT()  { s  S | s  s’ : s’  Y }) Note that SAT_EU() is calculating the least fixed point of G(X) = [[]]  ([[]]  { s  S | s  s’ : s’  X}) It follows from the previous theorem that SAT_EU(,) terminates and computes [[E[U]]] Slide 24

Example: EU s2 s0 s1 q s3 p s4 q Let us compute [[EFp]] = [[E[TUp]]]. It is the least fixed point of G(X) = [[p]]  ([[T]]  { s  S | s  s’ : s’  X}) = {s3}  (S  { s  S | s  s’ : s’  X }) = {s3}  { s  S | s  s’ : s’  X } Slide 25

Example: EU Iterating G on  until it stabilizes we have G1() = {s3}  { s  S | s  s’ : s’   } = {s3}   = {s3} G2() = G(G1()) = G({s3}) = {s3}  { s  S | s  s’ : s’  {s3} } = {s1,s3} G3() = G(G2()) = G({s1,s3}) = {s3}  { s  S | s  s’ : s’  {s1,s3} } = {s0,s1, s2,s3} G4() =G(G3()) = G({s0,s1, s2,s3}) = {s3}  { s  S | s  s’ : s’  {s0,s1, s2,s3} } Thus [[EFp]] = [[E[TUp]]] = {s0,s1,s2,s3}. Slide 26

AX = { s  S | s  s’ : s’  [[]]} AF as fixed point Since AF    AX AF and AX = { s  S | s  s’ : s’  [[]]} we obtain [[AF]] = [[]]  { s  S | s  s’ : s’  [[AF]]} ? Slide 27

H(X) = [[]]  { s  S | s  s’ : s’  X} Computing AF Again, consider [[AF]] as a fixed point of the function H(X) = [[]]  { s  S | s  s’ : s’  X} Theorem: Let n = |S| be the size of S and G defined as above. We have H is monotone [[AF]] is the least fixed point of H [[AF]] = Hn+1() Slide 28

Correctness of SAT_AF Inside the loop it always holds Y  SAT(). Substitute in SAT_AF Y:=Y  { s  S | s  s’ : s’  Y }) with Y:=SAT()  { s  S | s  s’ : s’  Y } Note that SAT_AF() is calculating the least fixed point of H(X) = [[]]  { s  S | s  s’ : s’  X} It follows from the previous theorem that AT_AF() terminates and computes [[AF]] Slide 29