More Mathematical Reasoning (Conditional Statements)

Slides:



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

This research is funded in part the U. S. National Science Foundation grant CCR DEET for Component-Based Software Murali Sitaraman, Durga P. Gandi.
Lesson 10.4: Mathematical Induction
PROOF BY CONTRADICTION
Computer Science School of Computing Clemson University Introduction to Mathematical Reasoning Jason Hallstrom and Murali Sitaraman Clemson University.
School of Computing Clemson University Mathematical Reasoning  Goal: To prove correctness  Method: Use a reasoning table  Prove correctness on all valid.
Addressing the Challenges of Current Software. Questions to Address Why? What? Where? How?
Reasoning About Code; Hoare Logic, continued
11111 Functional Program Verification CS 4311 A. M. Stavely, Toward Zero Defect Programming, Addison-Wesley, Y. Cheon and M. Vela, A Tutorial on.
Mixed Recursion: Sec. 8.4 Exercise 3. The closed-form formula for the Towers of Hanoi problem, M n = 2 n – 1, can be proved by mathematical induction.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
– Alfred North Whitehead,
Weakest pre-conditions and towards machine consistency Saima Zareen.
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Chapter 10 Sequences, Induction, and Probability Copyright © 2014, 2010, 2007 Pearson Education, Inc Mathematical Induction.
Proving correctness. Proof based on loop invariants  an assertion which is satisfied before each iteration of a loop  At termination the loop invariant.
Computer Science School of Computing Clemson University Mathematical Modeling Murali Sitaraman Clemson University.
Mathematics throughout the CS Curriculum Support by NSF #
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
Computer Science School of Computing Clemson University Specification and Reasoning in SE Projects Using a Web IDE Charles T. Cook (Clemson) Svetlana V.
Computer Science School of Computing Clemson University Mathematical Reasoning across the Curriculum Software Development Foundations and Software Engineering.
Lecture 16 March 22, 2011 Formal Methods CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Lecture 17 March 24, 2011 Formal Methods 2 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
9.4 Mathematical Induction
Recursive Algorithms &
Reasoning about programs March CSE 403, Winter 2011, Brun.
P. 270 #47-49.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Computer Science School of Computing Clemson University Mathematical Reasoning with Objects.
Loop Invariants and Binary Search Chapter 4.4, 5.1.
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
1 Computer Algorithms Tutorial 2 Mathematical Induction Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
Functional Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 21.
5-5 Indirect Proof. Indirect Reasoning: all possibilities are considered and then all but one are proved false. The remaining possibility must be true.
Section 2.3 Mathematical Induction. First Example Investigate the sum of the first n positive odd integers. 1= ____ 1 + 3= ____ = ____
Lecture 18 March 29, 2011 Formal Methods 3 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Computer Science School of Computing Clemson University Reasoning with Queues and Web Interface Demo.
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.
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Methods of Proof.
Modular Alternatives to Testing
Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2012
Component Implementations Using RESOLVE
Formal Specification of Java Interfaces
Reasoning about code CSE 331 University of Washington.
Use mathematical induction to prove that the formula is true for all natural numbers m. {image} Choose the first step of the proof from the following:
Proofs, Recursion and Analysis of Algorithms
Introduction to Components and Specifications Using RESOLVE
Functional Verification I
Notes 9.5 – Mathematical Induction
PROOF BY CONTRADICTION
Exercise Use mathematical induction to prove the following formula.
Formal Specification of Interfaces
Functional Verification I
Introduction to Components and Specifications Using RESOLVE
Mathematical Reasoning
Mathematical Induction
Mathematical Reasoning with Data Abstractions
1.1 Introduction to Inductive and Deductive Reasoning
Mathematical Induction
Tutorial Number 8 - Daniel Razavi
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Introduction to Proofs
Mathematical Induction
11.4 Mathematical Induction
Program Correctness an introduction.
Presentation transcript:

More Mathematical Reasoning (Conditional Statements) Murali Sitaraman Clemson University

Is the code correct for the given spec? Operation Do_Nothing (updates I: Integer); ensures I = #I; Code: If (I < Max_Int()) then Increment(I); Decrement(I); end;

These specs are the same… Operation Do_Nothing (updates I: Integer); ensures I = #I; Operation Do_Nothing (restores I: Integer);

Establish the goals in state-oriented terms using a table Cond Assume Confirm If (I < Max_Int()) 1 Increment(I); 2 Decrement(I) 3 end; 4 I4 = I0

Establish the conditions Cond Assume Confirm If (I < Max_Int()) 1 I0 < max_int Increment(I); 2 I0 < max_int Decrement(I) 3 I0 < max_int end; 4 I4 = I0

Establish sub-goals for different conditions Cond Assume Confirm If (I < Max_Int) 1 I0 < max_int Increment(I); 2 I0 < max_int Decrement(I) 3 I0 < max_int end; 4.1 not (I0 < max_int) I4 = I0 I4 = I0 4.2 I0 < max_int I4 = I3 I4 = I0

Fill in other assumptions and obligations as before… Cond Assume Confirm If (I < Max_Int) 1 I0 < max_int Increment(I); 2 I0 < max_int Decrement(I) 3 I0 < max_int end; 4.1 not (I0 < max_int) I4 = I0 I4 = I0 4.2 I0 < max_int I4 = I3 I4 = I0

Prove the subgoal(s) 4.1 Case: not (I0 < max_int) Prove I4 = I0 True from the assumption 4.2 Case: (I0 < max_int) Prove: I3 = I0 (assumption in state 4) Prove: (I2 - 1) = I0 (assumption in st 3) …

Prove remaining assertions to be confirmed For the condition (I0 < max_int), additional proofs are needed. These proofs of assertions to be confirmed in states 1 and 2 left as exercises

More Mathematical Reasoning Create this example using the web interface, generate VCs, and prove them For recursive implementations Recursive calls are handled just as any other call Need to show termination using a programmer-supplied decreasing “metric” For iterative implementations, invariants and decreasing metrics are used