Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 5

Mohammad Mahmoody
September 08, 2017

Class 5

Review

Mohammad Mahmoody

September 08, 2017
Tweet

More Decks by Mohammad Mahmoody

Other Decks in Education

Transcript

  1. Plan Finish Well-Ordering with Quantifiers Program Correctness (PS1) Validity, Satisfiability,

    Equivalence Negating Quantifiers Converting Formulas to DNF/CNF/3CNF SAT Solving: why satisfiability matters
  2. Disambiguating the English “Proofs also play a growing role in

    computer science; they are used to certify that software and hardware will always behave correctly, something that no amount of testing can do.” “Proofs can certify that a computing system will always behave correctly, something that no amount of testing can do.”
  3. Certifying Computing Systems “Proofs can certify that a computing system

    will always behave correctly, something that no amount of testing can do.”
  4. Certifying Computing Systems “Proofs can certify that a computing system

    will always behave correctly, something that no amount of testing can do.” ∀ ∈ . ¬(Test ⟹ Correct()) What does it mean to test a computing system?
  5. Certifying Computing Systems “Proofs can certify that a computing system

    will always behave correctly, something that no amount of testing can do.” ∀ ∈ . ¬(Test ⟹ Correct()) Test s = ∀ ∈ (). ℎ , ∈ ℎ(, ) Correct s = ∀ ∈ (). ℎ , ∈ ℎ(, )
  6. ∀ ∈ . ¬(Test ⟹ Correct()) Test s = ∀

    ∈ (). ℎ , ∈ ℎ(, ) Correct s = ∀ ∈ (). ℎ , ∈ ℎ(, ) When can testing certify a computing system is correct?
  7. TicTacToe(boardstate) – Acceptable behavior is to always pick a move

    that is legal (when one exists) and leads to best possible outcome.
  8. Proofs about Computing Systems “Proofs can certify that a computing

    system will always behave correctly, something that no amount of testing can do.” ∀ ∈ . ∃ ∈ . ⟹ Correct() ∃ ∈ . ∃ ∈ . ⟹ Correct()
  9. Proving Programs Correct def max(a, b): “Returns maximum of a

    and b” How should we define AcceptableBehaviors(max, x)?
  10. Proving Programs Correct def max(a, b): “Returns maximum of a

    and b” AcceptableBehaviors(max, x = (a, b)): result = max , no other state modified result ∈ , ∧ result ≥ ∧ result ≥ .
  11. Proving Programs Correct AcceptableBehaviors(max, x = (a, b)): result =

    max , no other state modified result ∈ , ∧ result ≥ ∧ result ≥ . def max(a, b): if a > b: result = a else: result = b return result Coq
  12. Real Computing Systems def max(a, b): if a > b:

    result = a … Idealized Computing Model ∀, ∈ ℕ . result = max a, b , result ∈ , ∧ result ≥ ∧ result ≥ .
  13. Real Computing Systems def max(a, b): if a > b:

    result = a … Idealized Computing Systems ∀, ∈ ℕ . result = max a, b , result ∈ , ∧ result ≥ ∧ result ≥ .
  14. Valid Formulas A formula is valid if there is no

    way to make it false. → ∧ → ⇒ ( → )
  15. Satisfiable Formulas A formula is satisfiable if there is some

    way to make it true. How to say something *is* valid using quantifiers? → ∧ → ⇒ ( → )
  16. ∀ , , ∈ , , → ∧ → ↔

    ( → )= Two Equivalent Formulas Two formulas are equivalent, if for all true/false assignment to the variables they evaluate to equal values. How to say it using quantifiers? → ∧ → ≡ ( → )
  17. Proof by Contradiction vs. Counter Example • Suppose we want

    to prove ∀ ∈ , () is True. How prove it by contradiction? • Suppose we want to show that ∀ ∈ , () is False. What should we do?
  18. DNF: Disjunctive Normal Form • Disjunction (OR) of some number

    of conjunctive clauses. • Conjunctive clause: AND of distinct literals • Literal: a variable or its negation • Disjunction of 0 number of clauses is also a DNF, but what is it? 1 ∧ 2 ∧ ¬3 ∨ 1 ∧ ¬2 ∧ 3 ∨ ¬1 ∧ 2 ∧ ¬3 F F
  19. T T T T F T F T T F

    F T T T F T F F F T F F F F ( ∧ ) ∨ ( ∧ ¬) ∨ (¬ ∧ ) ∨ (¬ ∧ ¬)
  20. CNF: Conjunctive Normal Form • Conjunction (AND) of some number

    of (disjunctive) clauses. • Clause: OR of distinct literals • Literal: a variable or its negation • Disjunction of 0 number of clauses is also a CNF, but what is it?
  21. T T T T F T F T T F

    F T T T F T F F F T F F F F (¬ ∨ ¬) ∧ (¬ ∨ ) ∧ ( ∨ ¬) ∧ ( ∨ )
  22. Converting to 3CNF Suppose we convert CNF = ( ∨

    ∨ ∨ ) Into 3CNF = ∨ ∨ ∧ (¬ ∨ ∨ ) In this case, it is easy to see that is satisfiable if and only if is satisfiable. Using quantifiers: ∃ , , , . ↔ ∃ , , , .
  23. Charge • PS2 Due Friday (6:29pm) • Next week: (Mathematical)

    Data Types – Sets, Functions – Read MCS Chapter 4