11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x.

Slides:



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

Program Verification Using Hoares Logic Book: Chapter 7.
Semantics Static semantics Dynamic semantics attribute grammars
PZ03D Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03D - Program verification Programming Language Design.
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.
Pre and Post Condition Rules Definition : If R and S are two assertions, then R is said to be stronger than S if R -> S (R implies S). –Example : the assertion.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Axiomatic Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 17.
Axiomatic Semantics The meaning of a program is defined by a formal system that allows one to deduce true properties of that program. No specific meaning.
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.
Dynamic semantics Precisely specify the meanings of programs. Why? –programmers need to understand the meanings of programs they read –programmers need.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Predicate Transformers
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.
CSE 331 Software Design & Implementation Dan Grossman Winter 2014 Lecture 2 – Reasoning About Code With Logic 1CSE 331 Winter 2014.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 5: Axiomatic Semantics II Roman Manevich Ben-Gurion University.
CS 355 – Programming Languages
CSE115/ENGR160 Discrete Mathematics 04/12/11 Ming-Hsuan Yang UC Merced 1.
Concepts of Programming Languages 1 Describing Syntax and Semantics Brahim Hnich Högskola I Gävle
Axiomatic Semantics Dr. M Al-Mulhem ICS
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.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Describing Syntax and Semantics
Proving Program Correctness The Axiomatic Approach.
Axiomatic semantics - II We reviewed the axiomatic semantic rules for: –assignment –sequence –conditional –while loop We also mentioned: –preconditions,
Proving Program Correctness The Axiomatic Approach.
CSE 755, part3 Axiomatic Semantics Will consider axiomatic semantics (A.S.) of IMP: ::=skip | | | | ; | | Only integer vars; no procedures/fns; vars declared.
Reading and Writing Mathematical Proofs
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Proofs of Correctness: An Introduction to Axiomatic Verification Prepared by Stephen M. Thebaut, Ph.D. University of Florida CEN 5035 Software Engineering.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
Languages and Compilers
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
CS6133 Software Specification and Verification
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
1 Section 8.2 Program Correctness (for imperative programs) A theory of program correctness needs wffs, axioms, and inference rules. Wffs (called Hoare.
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.
Hoare Logic LN chapter 5, 6 but without 6.8, 6.12, 6.13 (to be discussed later) Hoare Logic is used to reason about the correctness of programs. In the.
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Spring 2017 Program Analysis and Verification
Formal Methods in Software Engineering 1
Hoare Logic LN chapter 5, 6 but without 6. 8, 6. 12, 6
Lecture 2: Axiomatic semantics
Axiomatic semantics Points to discuss: The assignment statement
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
Semantics In Text: Chapter 3.
Predicate Transformers
Formal Methods in software development
Axiomatic Semantics Will consider axiomatic semantics (A.S.) of IMP:
Program correctness Axiomatic semantics
Lecture 2: Axiomatic semantics
CIS 720 Lecture 3.
Programming Languages and Compilers (CS 421)
CIS 720 Lecture 3.
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x program { m≥1, n ≥1 } { x = gcd(m,n) } assertion pre-condition post-condition specification Ch 23:Formal Semantics

11/22/2016IT 3272 A formal system:Axioms and Rules, { P } skip { P } { true } diverge { false } { [P] (i  E) } i := E { P } assignment { P } C {Q}  { P } ( C ) { Q } grouping { P } C 0 {Q} & { Q } C 1 { R }  { P } C 0 ; C 1 { R } sequencing { P, B } C 0 {Q} & { P, ¬B } C 1 { Q }  { P } if B then C 0 else C 1 { Q } if-statement { P, B } C { P }  { P } while B do C { P, ¬B } while-loop this P is called the loop invariant map

11/22/2016IT 3273 A formal system:Axioms and Rules, { P  R} & { R } C { Q }  { P } C { Q } pre-condition strengthening (II) implies { R  Q} & { P } C { R }  { P } C { Q } post-condition weakening { P 1 } C { Q } & { P 2 } C { Q }  { P 1  P 2 } C { Q } pre-condition disjunction { P} C { Q 1 } & { P} C { Q 2 }  { P } C { Q 1, Q 2 } post-condition conjunction or and

11/22/2016IT 3274 A correct program n := n+1; { ( n+1) ≥0 } { n ≥0 } This is a correct specification { [P] (i  E) } i := E { P } assignment It is correct because we can apply the following axiom to obtain the specification: This (piece of) program is correct.. Is what sense?

11/22/2016IT 3275 Another proof of the program correctness s := a; i := 0; while ¬(i=b) do ( s := s+1; i := i+1 ) program {b ≥0 } { s = a+b } assertion pre-condition post-condition specification The most difficult part is to figure out a useful loop invariant { s = a+i }

11/22/2016IT 3276 s := a; i := 0; {b ≥0 } {b ≥0, s = a+i } {b ≥0  (b ≥0, a = a+0) } {b ≥0, a = a+0 } s := a; {b ≥0, s = a+0 } {(b ≥0, s = a+0)  (b ≥0, s = a+0, 0=0) } {b ≥0, s = a+0, 0=0 } i := 0; {b ≥0, s = a+0, i = 0 } { (b ≥0, s = a+0, i=0)  ( b ≥0, s = a+i) }

11/22/2016IT 3277 s := s+1; i := i+1; {b ≥0, s = a+i, ¬(i=b) } {b ≥0, s = a+i } { P, B } C { P }  { P } while B do C { P, ¬B } {b ≥0, s = a+i, ¬¬(i=b) } {b ≥0, s = a+i } while ¬(i=b) do ( s := s+1; i := i+1 ) {(b ≥0, s = a+i, ¬¬(i=b))  (b ≥0, s = a+i, i=b) } {(b ≥0, s = a+i, i=b)  s = a+b}

11/22/2016IT 3278 Examples of correctness proofs Easy introduction to loop invariants