Lec07_Pf_Rules_and_Pfs

# Lec07_Pf_Rules_and_Pfs - Illinois Institute of Technology...

This preview shows pages 1–3. Sign up to view the full content.

CS 536 Notes: Proof Rules and Proofs Lecture 7, Mon Oct 18, 2010 A. Why To reason about programs, we need axioms or inference rules for each statement. B. Outcomes After this lecture, you should Know the rules of inference for sequencing, conditional, and iterative statements. C. Midterm Exam (60 minutes) D. Last Time Reviewed axiom for skip : { P } skip { P } Reviewed forward axiom for assignment: { P v = c } v := e { P [ c / v ] v = e [ c / v ]}. The constant c is a logical constant (appears only in the conditions). Special case: { P } v := e { P v = e } if v is fresh (appears in neither P or e ). Looked at backward axiom for assignment: { P [ e / v ]} v := e { P }. Looked at syntactic substitution. For e [ e / v ], ±nd all occurrences of v within e and replace them by e . Case 1: For quanti±er-free P , ±nd all occurrences of v and replace them by e . Case 2: The quanti±ed variable is v , the one we’re substituting for. ( Q v . P )[ e / v ] is Q v . P . Cases 3 and 4: The quanti±ed variable isn’t v and doesn’t appear in e . ( Q w . P )[ e / v ] is Q w .( P [ e / v ]). [In case 3, v doesn’t have a free occurrence in P , in which case P [ e / v ] is just P .] Case 5: Capture would occur. (I.e., v has a free occurrence in the body and the quanti±ed variable appears in e .) Need to rename the quanti±ed variable using a fresh variable (one used neither in P nor e ): ( Q w . P )[ e / v ] is ( Q z . ( P [ z / w ][ e / v ])). Saw proof rule for composition statements: Composition Rule : { P } S { R } { R } S { Q } ———————————————— { P } S ; S { Q } Saw proof rules that allow for precondition strengthening and postcondition weakening Recall P is stronger than Q Q is weaker than P i² ( P Q ). Illinois Institute of Technology Notes for Lecture 7 CS 536: Science of Programming - 1 of 6 - © James Sasaki, 2010

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Consequence Rule: P P { P } S { Q } Q Q ——————————————————— { P } S { Q } Weaken Postcondition { P } S { Q } Q Q —————————————— { P } S { Q } Strengthen Precondition P P { P } S { Q } —————————————— { P } S { Q } Each of these two rules introduces one predicate logic obligation. E. Proof Rule for Conditional Statements
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/17/2011 for the course CS 536 taught by Professor Cs536 during the Fall '08 term at Illinois Tech.

### Page1 / 6

Lec07_Pf_Rules_and_Pfs - Illinois Institute of Technology...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online