cpsc 121 models of computation
play

CPSC 121: Models of Computation Instructor: Bob Woodham - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation Menu January 9, 2009 Topics:


  1. CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation

  2. Menu January 9, 2009 Topics: Conditional Statement — Implication — Biconditional Logical Equivalence Reading: Today: Epp 1.2 January 12: Epp 1.5 Next: Epp 1.3 Reminders: Labs and tutorials begin week of January 12 On-line Quiz 3 deadline 9:00pm January 13 On-line Quiz 2 deadline was 9:00pm January 8 On-line/static Quiz 1 (mark has been waived) WebCT Vista: http://www.vista.ubc.ca www: http://www.ugrad.cs.ubc.ca/~cs121/ CPSC 121: Models of Computation

  3. Why Truth Tables? We use truth tables to: Define the meaning of logical connectives 1 Construct (simple) proofs in propositional logic 2 Design (simple) combinational circuits 3 CPSC 121: Models of Computation

  4. All 16 Logical Operators (with “Gate” Names) B B X N N N ∗ U U N A A X O O N ∗ O F F O N N O T T O ∗ p q R p q R D D R q p R ∗ T T T T T T T T T T F F F F F F F F T F T T T T F F F F T T T T F F F F F T T T F F T T F F T T F F T T F F F F T F T F T F T F T F T F T F T F CPSC 121: Models of Computation

  5. All 16 Logical Operators (with “Gate” Names) B B X N N N ∗ U U N A A X O O N ∗ O F F O N N O T T O ∗ p q R p q R D D R q p R ∗ T T T T T T T T T T F F F F F F F F T F T T T T F F F F T T T T F F F F F T T T F F T T F F T T F F T T F F F F T F T F T F T F T F T F T F T F ∗ The operator whose truth values are given in this column is called implication. Implication is very important in formal logic (and we’ll return to it shortly). Note, however, that implication is not a named gate (in hardware) CPSC 121: Models of Computation

  6. All 16 Logical Operators (with “Gate” Names) B B X N N N ∗ U U N A A X O O N ∗ O F F O N N O T T O ∗ p q R p q R D D R q p R ∗ T T T T T T T T T T F F F F F F F F T F T T T T F F F F T T T T F F F F F T T T F F T T F F T T F F T T F F F F T F T F T F T F T F T F T F T F ∗ The operator whose truth values are given in this column is called implication. Implication is very important in formal logic (and we’ll return to it shortly). Note, however, that implication is not a named gate (in hardware) CPSC 121: Models of Computation

  7. (Harder) Question How many distinct Boolean operators are there of n Boolean variables? Answer: There are 2 ( 2 n ) The truth table has 2 n rows since there are that number of distinct combinations of truth values for the n variables. For each row, we have an entry that can be either true or false. Thus, there are 2 ( 2 n ) distinct truth tables for n Boolean variables We use truth tables as a proof method for propositional logic. But, this is feasible only when the number of variables is small. There are other proof methods for propositional logic that we will need to consider CPSC 121: Models of Computation

  8. Recall from Last Lecture Proposition: a statement that is true or false (but not both) Compound Proposition: formed by combining existing propositions with logical connectives ( ∧ ∨ ¬ ⊕ ) defined, via a truth table, as follows: p q p ∧ q p ∨ q ¬ p p ⊕ q T T T T F F T F F T F T F T F T T T F F F F T F Digital circuit design uses logic gates (NOT AND OR XOR NAND NOR XNOR) to describe a circuit Digital circuits produce the correct binary output for each combination of binary inputs CPSC 121: Models of Computation

  9. Question Follow Up There is no required “correct” ordering to rows in a truth table. For example, the two truth tables p q p ∧ q p ∨ q ¬ p p ⊕ q T T T T F F T F F T F T F T F T T T F F F F T F p q AND OR NOT p XOR 0 0 0 0 1 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 are equivalent (when we associate T with 1 and F with 0) CPSC 121: Models of Computation

  10. (In-Class) Example 1: Construct the truth table for: 1 ( ¬ p ∨ q ) ∧ ¬ ( ¬ q ∨ p ) Draw the corresponding circuit diagram 2 Find a simpler circuit that is logically equivalent to the 3 circuit in step 2 CPSC 121: Models of Computation

  11. Implication Suppose we have 2 propositions: p : You fail the final exam for CPSC 121 q : You fail the course Now, the CPSC 121 course outline tells you that if you fail the final exam then you fail the course Question: How do we write this in propositional logic? Answer: We write p → q (and say “p implies q”) This is called a conditional proposition (or an implication ) with p the hypothesis (or antecedent or premise ) and q the conclusion (or consequent) Informally, implication corresponds to the English “if p then q ” CPSC 121: Models of Computation

  12. Implication Informally, implication also corresponds to the English “ p implies q ” “ q if p ” “ q whenever p ” and to the slightly more mathematical “ p is a sufficient condition for q ” “ q is a necessary condition for p ” “ p only if q ” . . . and even more CPSC 121: Models of Computation

  13. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T CPSC 121: Models of Computation

  14. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T CPSC 121: Models of Computation

  15. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T But, isn’t something strange here? If the hypothesis is false CPSC 121: Models of Computation

  16. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T But, isn’t something strange here? If the hypothesis is false then the implication is true CPSC 121: Models of Computation

  17. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T But, isn’t something strange here? If the hypothesis is false then the implication is true even though the conclusion may be true or false CPSC 121: Models of Computation

  18. Implication Formally, we define implication via a truth table: p → q p q p → q T T T T F F F T T F F T But, isn’t something strange here? If the hypothesis is false then the implication is true even though the conclusion may be true or false CPSC 121: Models of Computation

  19. Implication Let’s return to our example p : You fail the final exam for CPSC 121 q : You fail the course If p is false then p → q is true. But, this doesn’t say whether or not you pass CPSC 121. Proposition q could still be true or false IMPORTANT POINT: Don’t confuse the truth value of the conclusion with the truth value of the implication! CPSC 121: Models of Computation

  20. Another Implication Example Suppose we have 2 propositions: p : You are > 200 years old q : You are female Question: Is p → q true or false? Answer: The implication p → q is (vacuously) true The implication p → q asserts that q is a necessary condition for p . That is, being female is a necessary condition for being > 200 years old The implication p → q does not assert that p is a necessary condition for q . There are lots of females in the world. It is not necessary to be > 200 years old in order to be female CPSC 121: Models of Computation

  21. Yet Another Implication Example Suppose we have 2 propositions: p : You rob a bank q : You are arrested Consider the implication p → q p is a sufficient condition for q p is not a necessary condition for q . (There are many other ways to get yourself arrested) CPSC 121: Models of Computation

  22. Our CPSC 121 Example One More Time Suppose we take our original 3 propositions: p : You fail the final exam for CPSC 121 q : You fail the course P 1 : p → q and add 3 more: r : You pass the course s : You pass the final exam for CPSC 121 P 2 : r only if s P 2 says that s is a necessary condition for r P 2 also says that r is a sufficient condition for s Finally, s → r is false while P 1 : p → q is true Question: What is the relationship between P 1 and P 2 ? HINT: You can assume that p is the negation of s and that q is the negation of r CPSC 121: Models of Computation

  23. A Final Implication Example Suppose we have 2 propositions: p : The rooster crows at dawn q : The sun rises Implication in propositional logic is independent of any cause–and–effect relationship between hypothesis and conclusion In this example, there may be circumstances in which we conclude that p → q is true. But, that does not mean that we are concluding that it is the rooster’s crowing that causes the sun to rise CPSC 121: Models of Computation

  24. Biconditional Let p and q be propositions. In mathematics, we often write “ p if and only if q ” Question: How do we write this in propositional logic? Answer: We write p ↔ q This is called a biconditional proposition Informally, the biconditional also corresponds to the English “ p is necessary and sufficient for q ” “ p iff q ” CPSC 121: Models of Computation

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend