logic for computer science
play

Logic for Computer Science 06 Proof strategies Wouter Swierstra - PowerPoint PPT Presentation

Logic for Computer Science 06 Proof strategies Wouter Swierstra University of Utrecht 1 Last time Proof strategies 2 This lecture Wrap-up Review 3 Proofs There is no single defjnition of what is a proof it depends on


  1. Logic for Computer Science 06 – Proof strategies Wouter Swierstra University of Utrecht 1

  2. Last time Proof strategies 2

  3. This lecture Wrap-up Review 3

  4. Proofs There is no single defjnition of ‘what is a proof’ – it depends on context. • Who are you trying to convince? Fellow experts? A machine? • How much detail can you omit? • Are you working in a very formal setting? And many other factors contribute to what might be considered a valid proof. 4

  5. Proof strategies One way to teach formal thinking in an intuitive way is by giving proof strategies . These proof strategies correspond to ‘templates’ that can be used to break a large proof into smaller pieces. They may not cover every step in every proof (oftentimes there is some creativity, specifjc defjnitions or properties involved) – but they give you somewhere to start. For each logical operator there are two proof strategies: • one stating how to use an assumption of a certain form (elimination strategy); • one stating how to prove a goal of a certain form (introduction strategy). 5

  6. Proof strategies for quantifjers 6

  7. Proof strategies – universal quantifjcation introduction Let a be arbitrary. Proof of P ( a ) Therefore, ∀ x P ( x ) holds. 7

  8. Proof strategies – universal quantifjcation elimination Proof of ∀ x P ( x ) Therefore, P ( a ) holds. Both strategies seem reasonable. The book argues that they generalise the strategies for conjunction. We have already used them implicitly in previous proofs… Subsets Theorem Let A , B , and C be sets. Then A ⊆ C ∧ B ⊆ C ⇒ A ∪ B ⊆ C 8

  9. Exercise Question Prove that for all sets A and B , if A ∩ B = A then A ⊆ B . Where did you need to apply the strategies for the universal quantifjer? 9

  10. Proof strategies – universal quantifjcation introduction Let a be arbitrary. Proof of P ( a ) Therefore, ∀ x P ( x ) holds. 10

  11. Proof strategies – universal quantifjcation elimination Proof of ∀ x P ( x ) Therefore, P ( a ) holds. Both strategies seem reasonable. The book argues that they generalise the strategies for conjunction. We have already used them implicitly in previous proofs… Subsets Theorem Let A , B , and C be sets. Then A ⊆ C ∧ B ⊆ C ⇒ A ∪ B ⊆ C 11

  12. Proof strategies – existential quantifjcation introduction We choose a to be some value. Proof of P ( a ) Therefore, ∃ x P ( x ) holds. 12

  13. Proof We need to show that a f a 0 If we choose a 1, we have f 1 1 2 1 0 as required. Example: existential quantifjcation introduction Lemma The function f ( x ) = x 2 − 2 x + 1 intersects the x-axis. 13

  14. Example: existential quantifjcation introduction Lemma The function f ( x ) = x 2 − 2 x + 1 intersects the x-axis. Proof We need to show that ∃ a f ( a ) = 0 If we choose a = 1, we have f ( 1 ) = 1 − 2 + 1 = 0 as required. 13

  15. Proof strategies – universal quantifjcation elimination Proof of ∃ x P ( x ) Let a be some arbitrary value and assume P ( a ) holds. Proof of R Hence R holds. Like we saw for the universal quantifjer, these strategies generalise the strategy for disjunction. 14

  16. A wrong proof Proof of ∃ x P ( x ) Let a be some arbitrary value and assume P ( a ) holds. Proof of R Hence R holds. Question Use the proof strategies to try to give a proof that ( ∃ x P(x)) ⇒ ( ∀ x P(x)) What is wrong with the proof? 15

  17. Derived proof strategies 16

  18. Derived proof strategies: contraposition We have already seen a few examples of derived proof strategies, that capture some recurring pattern of usage of the more primitive strategies. For example, there is the special case of the disjunction elimination rule where the disjunction being eliminated was of the form P ∨ ¬ P . Another example is a so-called proof by contraposition that relies on ( P ⇒ Q ) ⇔ ( ¬ Q ⇒ ¬ P ) . Instead of assuming P and deriving Q , we can also assume ¬ Q and derive ¬ P to conclude that P ⇒ Q . 17

  19. Contraposition Assume ¬ Q . . . . Proof of ¬ P . . . Hence P ⇒ Q holds. A similar proof strategy exists for implication elimination that is sometimes called modus tollens . 18

  20. Modus tollens . . . Proof of P ⇒ Q . . . . . . . Proof of ¬ Q . . . . Therefore, we can conclude ¬ P □ . 19

  21. A wrong proof Theorem: All numbers are equal to 0. Proof: Let n be a natural number. If n = 0, then are goal holds. If n ̸ = 0 – this contradicts our assumption that n = 0. Hence, n = 0. Question What is wrong with this proof? 20

  22. Other proof steps These proof strategies give you the basic steps to help you break down a problem into smaller parts. But there are many other steps in a proof that are not covered by these strategies: • Unfolding defjnitions, for example replacing A ⊆ B with ∀ x x ∈ A ⇒ x ∈ B • Folding back defjnitions, for example replacing ∀ x x ∈ A ⇒ x ∈ B with A ⊆ B . • Arithmetic calculations. • Algebraic properties, such as a + b = b + a . • Choosing the right witness when trying to prove a property starting with an existential quantifjer. • Choosing the right property R when eliminating a disjunction; • Any creative steps that require insight somehow. • … 21

  23. But that’s a story for another lecture… Proof strategies: semi-formal These proof strategies are means to teach proofs. They give you enough of a formal framework to understand how to write proofs, identify which steps are allowed and which are not. But they do not nail down exactly what constitutes a proof and what doesn’t. And they are not formal enough that they can be automatically checked by a computer, for instance. 22

  24. Proof strategies: semi-formal These proof strategies are means to teach proofs. They give you enough of a formal framework to understand how to write proofs, identify which steps are allowed and which are not. But they do not nail down exactly what constitutes a proof and what doesn’t. And they are not formal enough that they can be automatically checked by a computer, for instance. But that’s a story for another lecture… 22

  25. What is a proof? • We can prove a given propositional logic formula is always true using a truth table ; • We can establish an equality between two terms in a Boolean algebra using an equational proof , showing how the two terms are equal using the laws and theorems of Boolean algebras. • We can prove more general statements using proof strategies . • … but there are many more logics or domains where we study proofs! 23

  26. Lets look at several difgerent proofs… Are proofs unique? Exercise: Prove that n 2 − n is even for all natural numbers. (This example is taken from Joel David Hamkins’s book on Proof and the art of mathematics ) 24

  27. Are proofs unique? Exercise: Prove that n 2 − n is even for all natural numbers. (This example is taken from Joel David Hamkins’s book on Proof and the art of mathematics ) Lets look at several difgerent proofs… 24

  28. The proof by cases • If n is even, then n 2 is even (why?). But then n 2 − n is the difgerence of two even numbers, which is always even (why?). • If n is odd, then n 2 is odd (why?). But then n 2 − n is the difgerence of two odd numbers, which is always even (why?). Regardless of whether n is even or odd, n 2 − n is always even. 25

  29. The proof by high-school algebra We can write n 2 − n as n × ( n − 1 ) , that is, n 2 − n is always the product of two consecutive numbers, one of which must be even. But any product of an even number is also even (why?). Hence n 2 − n must be even. 26

  30. The proof by diagram 27

  31. A machine checked proof 28

  32. And more And then there are several other possible proofs: • using induction ; • combinatorial proofs; • using the fact that the sum of the fjrst n − 1 natural numbers is equal to n ( n − 1 ) / 2; • and many others… Each of these proofs highlights some particular aspect or property. Each proof provides a difgerent insight! 29

  33. Review 30

  34. Review • Introduction • Propositions • Sets • Boolean algebra • Predicate logic • Proof strategies 31

  35. Exam practical matters Come on time I will provide you with scrap paper. Be sure to bring a photo ID, Solis login credentials, and pen or pencil. The exam lasts for 2 hours, which should be plenty of time. 32

  36. Extra time Students entitled to extra time should come to the exam 15 minutes in advance. They can start the exam earlier and continue working for an additional 10 minutes, if necessary. 33

  37. Introduction • What is logic? • Why study logic? • What is an invariant? 34

  38. Propositions – material • Propositional logic formulas • Truth tables • Proofs and properties (commutativity, associativity, de Morgan’s laws, etc.) 35

  39. Propositions – questions Possible questions may include: • Complete this truth table… • Draw a syntax tree/understand the precedence of operators…. • Prove these two formulas are equivalent…. • Give the defjnition of commutativity… But a solid understanding of propositional logic is necessary to understand the more complicated proofs in later chapters. 36

Recommend


More recommend