Weakest pre-conditions and towards machine consistency Saima Zareen.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Formal Methods in Software Engineering
Semantics Static semantics Dynamic semantics attribute grammars
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
Program Proving Notes Ellen L. Walker.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Discrete Mathematics Lecture 4: Sequences and Mathematical Induction
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Axiomatic Semantics Dr. M Al-Mulhem ICS
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
UNIT II Decision Making And Branching Decision Making And Looping
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
CSE 755, part3 Axiomatic Semantics Will consider axiomatic semantics (A.S.) of IMP: ::=skip | | | | ; | | Only integer vars; no procedures/fns; vars declared.
Fundamentals of C and C++ Programming Control Structures and Functions.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
CSI 3125, Axiomatic Semantics, page 1 Axiomatic semantics The assignment statement Statement composition The "if-then-else" statement The "while" statement.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.5 Application: Correctness of Algorithms 1 [P]rogramming reliability – must be an activity.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
1 “B is a method for specifying, designing, and coding software systems.” J.R. Abrial, The B-Book, Cambridge University Press.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Imperative Programming Statements and invariants.
Windows Programming Lecture 03. Pointers and Arrays.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Axiomatic Verification II Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 18.
Describing Syntax and Semantics
Chapter 3 of Programming Languages by Ravi Sethi
Formal Methods in Software Engineering
Topics The if Statement The if-else Statement Comparing Strings
B (The language of B-Method )
Topics The if Statement The if-else Statement Comparing Strings
Formal Program Specification
Axiomatic semantics Points to discuss: The assignment statement
Programming Languages 2nd edition Tucker and Noonan
Axiomatic Verification II
Predicate Transformers
Output Variables {true} S {i = j} i := j; or j := i;
Binary Search and Loop invariants
Formal Program Specification
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

Weakest pre-conditions and towards machine consistency Saima Zareen

Outline State Space Multiple assignment statements Post Condition Skip statement Conditional statement CASE statement Proof Obligations

State Space

Multiple Assignment statements

Post Condition A particular statement which is required to be true after executing S. Notation S [P] Exercise

skip The empty statement which has no effect at all on any part of the state. It is always guaranteed to terminate successfully and the state on termination will be the same as the state before it was executed. Predicate will remain same before and after skip executes [skip]P=P

Conditional Statement Programming languages provide conditional statements which allow branching depending on a particular value on the state. The most common of this is If then else IF E THEN S ELSE T END It is used in two circumstances When the post condition is of P can be guaranteed. Either E is true in which S will be executed Otherwise then T will execute

Conditional Statement contd..

Conditional Statement alternative interpretation

Case Statement Allows the flow of control of the assignment to depend on the value of a particular expression. It lists a number of alternative values. A case statement is written as follows

Case Statement contd.. E describes expression which is to be evaluated. If it evaluates to e1,then T1 is executed If it evaluates to e2 then T2 is executed. If does not evaluate to any of the list of alternatives then ELSE clause is executed. It is an optional clause. For example The set DIRECTION={north, south, east, west} Variable dir must evaluate to some element of DIRECTION, then the following CASE statement finds the opposite direction for dir

Case Statement contd..

Only finite cases are included. If there are infinitely many possibilities then the remaining ones will have to be covered by the ELSE clause or left with no associate statement. For example The following CASE statement assigns a percentage discount rate depending on the size of the order

Case Statement contd.. For a CASE statement to guarantee to establish a post condition P, we require that any branch OR e THEN T must have that T establishes P whenever the expression E evaluates to the value e on that branch. If E =e then [T]P must hold. If none f the values is matched, then the ELSE clause must establish P. This leads to the following rule

CASE statement Exercise

Begin and End

Consistency of INVARIANT

Proof Obligations A proof obligation is a mathematical formula to be proven, in order to ensure that a B component is correct.

Proof Obligation for Initialization

[T]I

Proof Obligation for Operations

B is a method for specifying, designing, and coding software systems. — Jean-Raymond Abrial

Inconsistency An operation whose proof obligation is not true, highlights a confusion between the machine invariant and the operation. It needs to be resolved. Number of ways to resolve a machine inconsistency. By Strengthening the precondition. May be Body of the operation might not be correct. May be Invariant may be too loose that allowed some states that should not be permitted. Invariant may be wrong.

Summary We have studied the concept of state space and weakest pre- conditions that result in valid final states. Multiple assignment statements can also be used to show parallel execution of statements. Evaluation of pre conditions using conditional and case statements. Proof obligations of initialization and Operations