1
play

1 Logic for Reasoning about Truth: Outline Where Should We Start? - PDF document

snick Introductions, again snack Steven Wolfman <wolf@cs.ubc.ca> CPSC 121: Models of Computation ICICS 239; office hours listed on the website 2016W2 I also have an open door policy: If my door is open, come in and talk!


  1. snick  Introductions, again snack Steven Wolfman <wolf@cs.ubc.ca> CPSC 121: Models of Computation ICICS 239; office hours listed on the website 2016W2 I also have an open door policy: If my door is open, come in and talk! Propositional Logic: A First Model of Computation Also, I will usually be available after class. And, you can make appointments with me Steve Wolfman, based on notes by Patrice Belleville and others Additionally, you can use TA office hours 1 2 This work is licensed under a Creative Commons Attribution 3.0 Unported License. Outline Learning Goals: Pre-Class • Prereqs, Learning Goals, and Quiz Notes By the start of class, you should be able to: • True, False, and Gates. Why Start Here? – Translate back and forth between simple natural language statements and • Problems and Discussion propositional logic. • Next Lecture Notes: Unit Continues... – Evaluate the truth of propositional logic statements using truth tables. – Translate back and forth between propositional logic statements and circuits that assess the truth of those statements. How should you achieve pre-class goals? 3 4 Use the quiz to guide your readings! Where We Are in Learning Goals: In-Class The Big Stories By the end of this unit, you should be able Theory Hardware to: How do we model How do we build devices to computational systems? compute? – Build combinational computational systems using propositional logic expressions and Now : learning the Now : establishing equivalent digital logic circuits that solve real underpinning of all our our baseline tool problems, e.g., our 7- or 4-segment LED models (formal logical (gates), briefly displays (using a “DNF” or any other reasoning with Boolean justifying these as successful approach). values). baselines, and designing complex functions from gates. 7 11 1

  2. Logic for Reasoning about Truth: Outline Where Should We Start? • Prereqs, Learning Goals, and Quiz Notes I will suppose that ... some malicious demon of the utmost power and cunning has employed all his • True, False, and Gates. Why Start Here? energies in order to deceive me. I shall think that the sky, the air, the earth, colours, shapes, sounds • Problems and Discussion and all external things are merely the delusions of • Next Lecture Notes: Unit Continues... dreams which he has devised to ensnare my judgement. I shall consider myself as not having hands or eyes, or flesh, or blood or senses, but as falsely believing that I have all these things. - René Descartes 12 13 Logic as Model for Physical “OR” operator and gate Computations http://alumni.media.mit.edu/~paulo/courses Propositional logic model: Physical System Input a Input b /howmake/mlfabfinalproject.htm a  b means “ a OR b ” a b Circuit diagram model: the “OR” gate a  b output “Truth Table” model 5V We think of “flowing water” a  b a b as true and “no water” as T T T a ~a false, and the physical world T F T becomes an effective F T T representation for our ideas ! 14 0V F F F Problem : Outline Light Switch • Prereqs, Learning Goals, and Quiz Notes Problem : Design a circuit to control a light so that the light changes state any time its switch is flipped. • True, False, and Gates. Why Start Here? • Problems and Discussion • Next Lecture Notes: Unit Continues... ? The problem gives the story we have to implement. 16 17 Be sure you understand the story and always keep it in mind! 2

  3. Problem : Problem : ? ? Light Switch Light Switch Problem : Design a circuit to control a light so that the Problem : Design a circuit to control a light so that the light changes state any time its switch is flipped. light changes state any time its switch is flipped. Identifying inputs/outputs: consider Consider these possible Which are most useful for Which of these solves the these possible inputs and outputs: solutions: this problem? problem? Input : the switch flipped or a. flipped and shining a. Only #1 the switch is up b. flipped and changed b. Only #2 c. up and shining c. Only #3 Output : the light is shining or d. up and changed d. #1 and #2 the light changed states e. None of these e. Some other combination 18 19 Problem : Problem : ? Two-Switch Two-Switch Problem : Design a circuit to control a light so that Problem : Design a circuit to control a light so that the light changes state any time either of the two the light changes state any time either of the two switches that control it is flipped. switches that control it is flipped. Getting the Story Right: Is the light on or off when both switches are up? a. On, in every correct solution. b. Off, in every correct solution. c. It depends, but a correct solution should always do the same thing given the same settings for the switches. ? d. It depends, and a correct solution might do different things at different times with the same switch settings. 20 21 e. Neither on nor off. Problem : Problem : ? Two-Switch Three-Switch Problem : Design a circuit to control a light so that Problem : Design a circuit to control a light so that the light changes state any time either of the two the light changes state any time any of the three switches that control it is flipped. switches that control it is flipped. Which of these circuits solves the problem? a. Only #1 b. Only #2 c. #1 and #2 ? d. #1 and #3 e. All three 22 23 3

  4. Problem : Problem : ? ? Three-Switch Three-Switch Problem : Design a circuit to control a light so that Problem : Design a circuit to control a light so that the light changes state any time any of the three the light changes state any time any of the three switches that control it is flipped. switches that control it is flipped. Fill in the circuit’s truth table: a. b. c. d. e. Getting the Story Right: s 1 s 2 s 3 out out out out None Which of these indicates whether the light is on or off in a T T T T F F T of particular correct solution? T T F F T T F these T F T F T F T a. Whether an odd number of switches is on. T F F T F T F b. Whether the majority (two or more) of switches are on. F T T F T F T c. Whether all the switches are on. F T F T F T F d. Whether a switch has been flipped recently. F F T T F F T e. None of these. 24 25 F F F F T T F Problem : Problem : ? Three-Switch n -Switch Problem : Design a circuit to control a light so that Problem : Describe an algorithm for the light changes state any time any of the three designing a circuit to control a light so that switches that control it is flipped. the light changes state any time any of its Modelling the Circuit: n switches is flipped. Which of these describes an incorrect solution? (s 1  s 2  s 3 )  (s 1  ~s 2  ~s 3 )  a. (~s 1  s 2  ~s 3 )  (~s 1  ~s 2  s 3 ) ... s 1  s 2  s 3  (s 1  s 2  s 3 ) b. s 1  (s 2  s 3 ) c. ? (s 1  ~(s 2  s 3 ))  (~s 1  (s 2  s 3 )) d. 26 27 e. None of these is incorrect. Outline Learning Goals: In-Class • Prereqs, Learning Goals, and Quiz Notes By the end of this unit, you should be able • True, False, and Gates. Why Start Here? to: – Build combinational computational systems • Problems and Discussion using propositional logic expressions and • Next Lecture Notes: Unit Continues... equivalent digital logic circuits that solve real problems, e.g., our 7- or 4-segment LED displays. 28 29 4

  5. snick  Some Practice Problems snack Here are some assignment/exam-like practice problems related to this lecture’s in -class learning goals. Give them a shot! Some Things to Try... Design a representation (for a digital logic circuit) for the state of a stop light. Design a circuit that takes the current states of a stop light and produces (on your own if you have time and the next state. interest, not required) Design a circuit that takes the current states of two stop lights and produces true if they are “safe in combination” and false otherwise. (By “in combination” we mean that one of the states is the state of the lights along one road at an intersection and the other is the state of the lights along the perpendicular road. 30 31 Problem: Logicians and Hats Problem: Criminals and Hats Problem: A warden plans to line up 100 prisoners in Problem: Three logicians are each wearing order tomorrow. The warden will place a white or a black hat or a white hat, but not all white. black hat on each prisoner’s head so that no Nobody can see their own hat. However, A prisoner can see the hat on his or her own head, but they can see the hats of the prisoners in front can see the hats of B and C, and B can of them. From the back of the line, the warden will see the hats of A and C. C is blind. You go ask each prisoner “Is your hat black?” If the and ask them one by one in the order A, prisoner answers correctly, he or she is set free. Incorrect answers lead to immediate and noisy B, C, whether they know the color of their beheading. If they answer anything other than own hat. A answers “No”. B answers “No”. “yes” or “no”, all prisoners are beheaded. They Then C answers “Yes”. Explain how this is get one hour as a group to plan their strategy. possible. How many prisoners can be saved? The switch problems might give you a hint. 32 33 5

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