Lecture 2: Distributed Programs and their Correctness Anish Arora CSE 6333 1
Table of Precedence + ─ = < > Highest [x := E] substitution . function application + ─ unary prefix operators x / mod gcd binary arith. operators + ─ = < > Lowest 2
Equivalence Associativity : (P Q) R P (Q R) Symmetry : P Q Q P Identity : true Q Q Note: is not ‘conjunctional’ P Q R ? P Q Q R Example: Tom has 2 eyes Tom has 1 eye Tom has no eyes ? (Tom has 2 eyes Tom has 1 eye) (Tom has 1 eye Tom has no eyes)
Negation false true (P Q) P Q P Q (P Q) Theorem : (P Q) (Q P) Proof: (P Q) (Q P) = { axiom : definition of } (P Q) (Q P) = { axiom : (P Q) P Q } P Q Q P = { is symmetric, associative } P P Q Q = (P P) (Q Q) { definition of false : false true} = false false = true
Disjunction , Conjunction Symmetry : P Q Q P Associativity : (P Q) R P (Q R) Idempotence : P P P Distributivity of over : P (Q R) P Q P R Excluded miracle : P P The Golden Rule: P Q P Q P Q P Q P Q P Q P Q P Q P Q Note : P Q P Q P P Q Q P Q
Quantification : Universal , Existential (x : R : P) (x : true : R P) (x : R : true) true (x : R : P) (x : R : P) (x : R : P) (x : true : R P) (x : R : false) false Q: (x : false : R) ?
Reasoning with Hoare Triples {P} g skip {P} is true {P[x := E]} true x := E {P} rule of textual substitution {P} g st {Q} equivales {P g} true st {Q} and (P g) Q {P} g st {P} equivales {P g} true st {P}
Reasoning with Hoare Triples (contd.) P Q and {Q} g st {R} implies {P} g st {R} {P} g st {Q} and Q R implies {P} g st {R} {P} g st {R} and {Q} g st {R} implies {P Q} g st {R} {P} g st {Q} and {P} g st {R} implies {P} g st {Q R}