School of Computing Clemson University Mathematical Reasoning  Goal: To prove correctness  Method: Use a reasoning table  Prove correctness on all valid.

Slides:



Advertisements
Similar presentations
Problem 1: Balls Problem 2: Josephine Problem 3: Alternating List.
Advertisements

For(int i = 1; i
Geometry Section 1.1 Patterns and Inductive Reasoning
CS201 – Introduction to Computing – Sabancı University 1 Conditional Execution – Sections 4.2, 4.3, 4.4 and 4.7 l Up to now, we have seen that instructions.
Computer Science School of Computing Clemson University Introduction to Mathematical Reasoning Jason Hallstrom and Murali Sitaraman Clemson University.
Addressing the Challenges of Current Software. Questions to Address Why? What? Where? How?
1 DATA ABSTRACTION: USER DEFINED TYPES AND THE CLASS.
BBS514 Structured Programming (Yapısal Programlama)1 Functions and Structured Programming.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
1 Discrete Structures CS Johnnie Baker Comments on Early Term Test.
Lecture 2: Fundamental Concepts
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
So far we have learned about:
CSE115/ENGR160 Discrete Mathematics 02/14/12 Ming-Hsuan Yang UC Merced 1.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 times table 2 times table 3 times table 4 times table 5 times table
Mathematics throughout the CS Curriculum Support by NSF #
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
Honors Geometry Section 1.0 Patterns and Inductive Reasoning
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)
CSE373: Data Structures and Algorithms Lecture 2b: Proof by Induction and Powers of Two Nicki Dell Spring 2014.
computer
Review the Mathematical Practices Describe how the Mathematical Practices impact instruction Create a plan to purposefully integrate the Mathematical.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
9.4 Mathematical Induction
Multiplication by 2 Mental Mathematics Starters Activity 7a.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 7 Clicker Questions September 22, 2009.
Data Verification and Validation
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.
Rounding up – and down! Mental Mathematics Starters Activity 3b.
Function prototype A function must be declared before it can be referenced. One way to declare a function is to insert a function prototype before the.
Rounding up – and down! Mental Mathematics Starters Activity 3a.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Computer Science School of Computing Clemson University Mathematical Reasoning with Objects.
Name ______ Lesson 2 – Patterns from Gr. 6_ Page 12 Tables
Tables Learning Support
5-5 Indirect Proof. Indirect Reasoning: all possibilities are considered and then all but one are proved false. The remaining possibility must be true.
Lecture 18 March 29, 2011 Formal Methods 3 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
HOW can properties be used to prove rules for multiplying integers?
Computer Science School of Computing Clemson University Reasoning with Queues and Web Interface Demo.
Lesson 1-7 Inductive Reasoning. Inductive Reasoning – making conclusions based on patterns you observe. Conjecture – conclusion you reach by inductive.
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.
CS 2130 Computational Structures (Discrete Mathematics for Computing)
Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2012
5.3- Inverse Functions If for all values of x in the domains of f and g, then f and g are inverse functions.
Unit 1. Sorting and Divide and Conquer
Use the Table of Integrals to evaluate the integral
Methods of Proof A mathematical theorem is usually of the form pq
321 Section, 2-7 Natalie Linnell.
Times Tables.
Mathematical Induction
X-STANDARD MATHEMATICS ONE MARK QUESTIONS
CSE 373 Data Structures and Algorithms
Mathematical Reasoning
MAT 3100 Introduction to Proof
Describe how they are made.
More Mathematical Reasoning (Conditional Statements)
Data entry and Data management
Mathematical Reasoning with Data Abstractions
Rational Numbers.
CSE 1020:Software Development
NOR ZALINA ISMAIL FACULTY OF COMPUTER AND MATHEMATICAL SCIENCES1
3 times tables.
6 times tables.
9 x 14 9 x 12 Calculate the value of the following: 1 9 × 5 =
Precedence tables and activity networks
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Chapter 5 Desk Checking/Dry Running.
Presentation transcript:

School of Computing Clemson University Mathematical Reasoning  Goal: To prove correctness  Method: Use a reasoning table  Prove correctness on all valid inputs

School of Computing Clemson University Example: Prove Correctness Spec: Operation Do_Nothing (i: Integer); requires min_int <= i and i + 1 <= max_int; ensures i = #i; Code: Increment(i); Decrement(i);

School of Computing Clemson University Design by Contract  Requirements and guarantees Requires clauses are preconditions Ensures clauses are postconditions  Caller is responsible for requirements  Postcondition holds only if caller meets operation’s requirements

School of Computing Clemson University Basics of Mathematical Reasoning  Suppose you are proving the correctness for some operation P Confirm P’s ensures clause at the last state Assume P’s requires clause in state 0

School of Computing Clemson University In State 2 – Establish Goal of Do_Nothing’s Ensures Clause AssumeConfirm 0 Increment(i); 1 Decrement(i) 2i2 = i0

School of Computing Clemson University In State 0 Assume Do_Nothing’s Requires Clause AssumeConfirm 0min_int <= i0 and i0 + 1 <= max_int Increment(i); 1 Decrement(i) 2i2 = i0

School of Computing Clemson University More Basics  Now, suppose that P calls Q Confirm Q’s requires clause in the state before Q is called Assume Q’s ensures clause in the state after Q is called

School of Computing Clemson University Specification of Integer Operations  Operation Increment (i: Integer); requires i + 1 <= max_int; ensures i = #i + 1;  Operation Decrement (i: Integer); requires min_int <= i - 1; ensures i = #i – 1;

School of Computing Clemson University Assume Calls Work as Advertised AssumeConfirm 0min_int <= i0 and i0 + 1 <= max_int Increment(i); 1i1 = i0 + 1 Decrement(i) 2i2 = i1 - 1i2 = i0

School of Computing Clemson University More Preconditions Must Be Confirmed AssumeConfirm 0min_int <= i0 and i0 + 1 <= max_int Increment(i); 1i1 = i0 + 1 min_int <= i1 - 1 Decrement(i) 2i2 = i1 - 1 i2 = i0

School of Computing Clemson University Write Down Verification Conditions(VCs)  Verification Condition for State 0 (min_int <= i0) ^ (i0 + 1 <= max_int)  i0 + 1 <= max_int

School of Computing Clemson University Write Down Verification Conditions(VCs)  VC for State 1 P1: min_int <= i0 (from State 0) P2: i0 + 1 <= max_int (from State 0) P3: i1 = i0 + 1 VC: P1 ^ P2 ^ P3  min_int <= i1 - 1  VC for State 2 P4: i2 = i1 - 1 VC: P1 ^ P2 ^ P3 ^ P4  i2 = i0

School of Computing Clemson University Use Direct Proof Method  For p  q  Assume premise ‘p’  Show conclusion ‘q’ is true  Prove VC for State 0 Assume P1: min_int <= i0 Assume P2: i0 + 1 <= max_int Show: i0 + 1 <= max_int

School of Computing Clemson University Prove VCs for State 1 & State 2  Prove VC for State 1 Assume P1: min_int <= i0 Assume P2: i0 + 1 <= max_int Assume P3: i1 = i0 + 1 Show: min_int <= i1 - 1  Prove VC for State 2 Assume P1 ^ P2 ^ P3 Assume P4: i2 = i1 – 1 Show: i2 = i0