Lec05_Sample_triples_and_proof_rules

# Lec05_Sample_triples_and_proof_rules - Illinois Institute...

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

CS 536 Notes: Examples of Correctness Triples; Proof Rules for Correctness Triples Lecture 5, Mon Sep 27, 2010 A. Why Correctness triples are how we write a program with its speci ± cation. Proof rules for correctness triples will show us how to reason about programs and their speci ± cations. B. Outcomes After this lecture, you should Know that a program can have di ² erent speci ± cations, some more useful than others. Know why we need proof rules for correctness triples and how they connect/are di ² erent from validity for correctness triples. Know some of the di ² erent cases for reasoning about an assignment statement’s properties. Know what syntactic substitution is and how to do it. C. Quiz 1 Results Scores are shown to the right. The mean was 79.4 and the mode was 82 so we were slightly clumped toward high grades. Questions 1, 2, and 11 had the lowest average score (67%, 73%, and 13% respectively). D. Last Time: Meaning of Programs, Syntax of Correctness Triples, Partial Correctness Semantics for Correctness Triples Program are state transformers: M ( S , ! ) = { " } if running program S starting in state ! halts in state " . M ( S , ! ) = # if running program S starting in state ! leads to an in ± nite loop. •A Correctness Triple (a.k.a. Hoare Triple ) has a precondition predicate, a program, and a postcondition predicate 98 96 96 96 95 95 95 93 93 92 92 92 91 91 91 90 90 90 89 89 88 88 88 88 87 86 86 85 84 82 82 82 81 80 79 79 77 77 76 75 73 71 71 71 70 70 68 68 68 67 66 64 63 63 59 59 55 51 47 36 Count: 60 Mean: 79.4 Std dev: 13.9 Illinois Institute of Technology Notes for Lecture 5 CS 536: Science of Programming - 1 of 7 - © James Sasaki, 2010

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

View Full Document
Syntax : { P } S { Q } where P and Q are the pre- and post-conditions and S is the program. Note the curly braces are not part of P or Q , they’re like comment symbols or keywords. Intuitive “Partial Correctness” Semantics : { P } S { Q } holds/is satis ± ed/is true in state ! if (a) if P is true in ! , then (b) if running S in ! halts in some state, then (c) Q is true in that state. Equivalently, { P } S { Q } holds in state ! if P is false in ! , if S doesn’t halt in ! , or if S halts in a state in which Q is true. Notation : ! ! { P } S { Q } i ² (( ! ! P ) implies ( M ( S , ! ) " # implies M ( S , ! ) ! Q )). Equivalently, ! ! { P } S { Q } i ² ( ! " P or M ( S , ! ) = # or M ( S , ! ) ! Q ). If { P } S { Q } does not hold in a state ! that ! P then our program has a bug: P is true in ! but running S in ! halts in some state that doesn’t satisfy Q . •We want our programs to be valid (to hold in all states). Notation : ! { P } S { Q } i ² for all ! , ! ! { P } S { Q }. E. Some Simple Examples of Partial Correctness Triples
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 / 7

Lec05_Sample_triples_and_proof_rules - Illinois Institute...

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

View Full Document
Ask a homework question - tutors are online