CPSC 121: Models of Computation

Slides:



Advertisements
Similar presentations
Digital Circuits. Review – Getting the truth table The first step in designing a digital circuit usually is to get the truth table. That is, for every.
Advertisements

Digital Circuits.
CPSC 121: Models of Computation Unit 6 Rewriting Predicate Logic Statements Based on slides by Patrice Belleville and Steve Wolfman.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Propositional Logic, Continued Steve Wolfman, based on notes by Patrice Belleville and.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic, Continued Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Propositional Calculus Math Foundations of Computer Science.
Copyright © Cengage Learning. All rights reserved.
Building Adders & Sub tractors Dr Ahmed Telba. Introducing adder circuits Adder circuits are essential inside microprocessors as part of the ALU, or arithmetic.
3. DIGITAL ELECTRONICS..
Lecture 3. Boolean Algebra, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
Chapter 2 Combinational Systems And / Or / Not. TRIAD PRINCIPLE: Combinational is about And / Or / Not combinations As well as equivalent functions. It.
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Lecture 7 Topics –Boolean Algebra 1. Logic and Bits Operation Computers represent information by bit A bit has two possible values, namely zero and one.
1 The Chinese University of Hong Kong Faculty of Education Diploma in Education (Part-Time) Winter 1997 Educational Communications and Technology Assignment.
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
CPSC 121: Models of Computation Unit 2 Conditionals and Logical Equivalences Unit 2 - Conditionals 1 Based on slides by Patrice Belleville and Steve Wolfman.
CPSC 121: Models of Computation Unit 0 Introduction George Tsiknis Based on slides by Patrice Belleville and Steve Wolfman.
CS1Q Computer Systems Lecture 7
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean Logic.
EET 1131 Unit 5 Boolean Algebra and Reduction Techniques
CPSC 121: Models of Computation 2016W2
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
Logic.
Activity 1 5 minutes Grab a whiteboard and pen, come to the front and work out the Truth Table for the following circuit: R A B C Q.
CSIS-110 Introduction to Computer Science
Morgan Kaufmann Publishers
Computer Science 210 Computer Organization
Combinational Logic Design&Analysis.
Module 2: Conditionals and Logical Equivalences
Digital Fundamentals Floyd Chapter 5 Tenth Edition
Lecture 1 – Formal Logic.
Truth Tables and Equivalent Statements
Chapter 2.3 Binary Logic.
CPSC 121: Models of Computation
Fundamentals & Ethics of Information Systems IS 201
Digital Fundamentals Floyd Chapter 5 Tenth Edition
Computer Science 210 Computer Organization
Some basic electronics and truth tables
The Bridge Between Symbolic Logic And Electronic Digital Computing
BASIC & COMBINATIONAL LOGIC CIRCUIT
This Lecture Substitution model
Digital Fundamentals Floyd Chapter 5 Tenth Edition
Chapter 5: Control Structure
Chapter 3 Introduction to Logic 2012 Pearson Education, Inc.
From now on: Combinatorial Circuits:
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
CMSC250 Fall 2018 Circuits 1 1.
Copyright © Cengage Learning. All rights reserved.
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Digital Fundamentals Floyd Chapter 5 Tenth Edition
Digital Fundamentals Floyd Chapter 5 Tenth Edition
This Lecture Substitution model
CPSC 121: Models of Computation
Chapter 5 Combinational Logic Analysis
CPSC 121: Models of Computation
Basic circuit analysis and design
This Lecture Substitution model
Digital Fundamentals Floyd Chapter 5 Tenth Edition
Digital Circuits.
Discrete Structures Prepositional Logic 2
Chapter 3 – Describing Logic Circuits
Combination Logic & FPGAs.
Presentation transcript:

CPSC 121: Models of Computation Unit 1: Propositional Logic George Tsiknis Based on slides by Patrice Belleville and Steve Wolfman

Pre–Lecture Learning Goals By the start of the class, you should be able to: Translate back and forth between simple natural language statements and propositional logic. 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. Unit 1 - Propositional Logic

Quiz 1 Feedback We will discuss the open-ended question a bit later. ~a v ~b : I am not hungry, or I am not cold. ~(a v b): It is not true that I am either hungry or cold. If I am cold, but not hungry: is ~a v ~b true? --> Yes is ~(a v b) true? --> No Recall by the De Morgan's law that ~(a v b) is the same thing as ~a ^ ~b (not ~a v ~b). Rosen uses \neg instead of \sim Unit 1 - Propositional Logic

In-Class Learning Goals By the end of this unit, you should be able to: Build computational systems to solve real problems, using both propositional logic expressions and equivalent digital logic circuits. The light switches problem from the 1st online quiz. The 7- or 4-segment LED displays we will discuss in class. Building ground work for the Course Big Goals: How do we model computational systems? How do we build devices to compute? Unit 1 - Propositional Logic

Making a Truth Table Note: when you write a truth table, always list the combinations in the same order. For instance, with 3 variables the first column contains 4 false followed by 4 true. the second column contains 2 false, 2 true, 2 false, 2 true. and the third column alternates false with true. With k variables, the first column has 2k-1 false and then 2k-1 true, the second column has 2k-2 false and then 2k-2 true (twice), etc. Another way is to start with the last column and one variable which will be assigned F and T add one variable at a time duplicating what you have so far and setting the new variable to F for the first copy and T for the second Rosen uses  instead of ~. Unit 1 - Propositional Logic

Circuits to Logic Expressions How do we find the logical expression that corresponds to a circuit's output? First we write the operator for the gate that produces the circuit's output. The operator's left argument is the expression that corresponds to the circuit for the first input of that gate. The operator's right argument is the expression that corresponds to the circuit for the second input of that gate. Build the logical expression for the left and right argument the same way. This is our First algorithm! Unit 1 - Propositional Logic

Example 1 What does this circuit compute? ( ) ^ ~( ) ( ) v ( ) a ⊕ c ( ) ^ ~( ) ( ) v ( ) a ⊕ c a ⊕ b ( ) ⊕ ( ) a ⊕ b c ⊕ d Unit 1 - Propositional Logic

Example 2 What logical expression corresponds to the following circuit? ~(avb) ^ (ac) ^ ((b^d) v ~(c^d)) Unit 1 - Propositional Logic

Problem: Three-Switch Design a circuit that changes the state of the light whenever any of the switches that control it is flipped. Ideally your solution would work with any number! ? Unit 1 - Propositional Logic

? How do we approach this? Try to understand the “story”: what are the inputs and outputs? Formalize the problem: “Let a,b,c represent 3 switches from left to right” Solve in propositional logic: may create a truth table with the inputs and outputs Try a simpler problem: start with 1 switch; then try 2; then try 3 switches. see if we can generalize to n switches. Test your answer: try some cases, or check some properties Using simpler examples to understand a problem is a common technique used in CPSC (and in MATH). Unit 1 - Propositional Logic

? One Switch Identifying inputs/outputs: consider these: Input1: the switch flipped Input2: the switch is on Output1: the light is on Output2: the light changed state Which are most useful for this problem? Input1 and Output1 Input1 and Output2 Input2 and Output1 Input2 and Output2 None of these C Unit 1 - Propositional Logic

? One Switch Let’s use: S = switch is on out = light is on Truth table: Which of the following circuits solves the problem? Unit 1 - Propositional Logic

? Two Switches Make sure we understand the problem first. Is the light on or off when both switches are “on”? On in every correct solution. Off in every correct solution. Depends, but a correct solution should always do the same thing with the same settings for the switches.. Depends, and a correct solution might do different things at different times with the same settings for the switches. Neither on nor off. C Unit 1 - Propositional Logic

? Two Switches Circuit design tip: if you are not sure where to start while designing a circuit, First build the truth table. Then turn it into a circuit. For the two switches problem: We can decide arbitrarily what the output is when all switches are OFF. This determines the output for all other cases! Let's see how... Truth table (suppose light OFF when all switches are OFF): Draw atable s1 | s2 | out | F | F | F | . . . Unit 1 - Propositional Logic

? Two Switches Two switches: which circuit(s) work(s) ? B & D Unit 1 - Propositional Logic

? Three Switches Fill in the circuit’s truth table: Which output column(s) is(are) correct ? A B C D E s1 s2 s3 T F out T F out F T out F T out T F None of them A or B Unit 1 - Propositional Logic

? Three Switches Suppose we decided to have the light OFF when all switches are OFF. What pattern do we observe? The light is ON if What is the formula for it? Now to generalize to n switches... What do you think the answer is? How can we convince ourselves that it is correct? Mathematical induction One or three switches are on. s1 XOR ( s2 XOR s3) The light is on if an odd number of switches are on. Unit 1 - Propositional Logic

7-Segment LED Display Problem: design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated below. Rosen uses \neg instead of \sim. Unit 1 - Propositional Logic

7-Segment LED Display Understanding the story: How many inputs to our circuit are there? One Seven Ten Four None of these This is VERY tricky for students. What is an “input”? (I use it in TWO ways myself. In one sense to mean an “input wire” and in another to mean an “input value”. Possible answers: 4, 7, 10 Unit 1 - Propositional Logic

7-LED Display First: what’s the circuit’s job? Problem: Design a circuit that displays the numbers 0 through 9 using seven LEDs (lights) in the shape illustrated above. First: what’s the circuit’s job? Story! The circuit’s job isn’t just to connect a switch to each light. That would just mean seven plain wires. The circuit’s job is to INTERPRET a numerical input and turn it into an output.

7-LED Display–Input Values How many different values (messages) must the circuit understand? (This is different than “how many inputs are there”.) One Seven Ten Four None of these This is VERY tricky for students. What is an “input”? (I use it in TWO ways myself. In one sense to mean an “input wire” and in another to mean an “input value”. Answer: 10 Zero and seven are definitely misconceptions, however.

7-LED Display-Input Lines How many different “parameters” (wires) carry those messages? (Not quite parameter like in CPSC 110… more like an input wire). One Seven Ten Four None of these 4 and 10 are ok answers. [2011W1] CPSC 110 HAD talked about parameters by this time. This is VERY tricky for students. What is an “input”? (I use it in TWO ways myself. In one sense to mean an “input wire” and in another to mean an “input value”. Zero and seven are definitely misconceptions, however.

7-LED Display-Inputs How do we represent the inputs? Use ? logical (true/false) values. Each integer represented by 1 specific combination. Could we do this randomly? Yes! But we won't How many of you know about binary representation? How many values we can represent with 1 propositional variable : 2 propositional variables : 3 " " : n " " : 2 4 2^n Unit 1 - Propositional Logic

7-LED Display-Representing Inputs Here's how we will represent the inputs: # a b c d F 1 T 2 3 4 5 6 7 8 9 ... Notice the order: F's first. Unit 1 - Propositional Logic

7-LED Display-Outputs Understanding Outputs: How many outputs are there? 1 4 7 10 None of the above c Unit 1 - Propositional Logic

Simulate 7-LED Display Let's simulate it with people (raising their hands) ... Which other person's algorithm do you need to know about? No one else's Your neighbours The person opposite to you Everybody else's None of the above. 26 Ask 7 students to simulate it. a Unit 1 - Propositional Logic

Analyzing One Segment What’s the truth table for the lower-left segment? a. b. c. d. e. None of these. # a b c d F 1 T 2 3 4 5 6 7 8 9 out F T out F T out T F out 2 6 8 4 7 9 3 1 5 This is a good point to note that the negation of an output is NOT always a viable solution. The answer is c. b is its negation and is INCORRECT.

Analyzing One Segment From the truth table, we can make an expression for each true row and OR them together. # a b c d out F T 1 2 3 4 5 6 7 8 9 Which logical statement is true only in this row? ~a  ~b  c  ~d a  b  c  d ~a  ~b  c  ~d a  b  ~c  d None of these c

Analyzing One Segment ( )  ( )  ( ) Let' s complete the expression for the lower-left segment # a b c d out F T 1 2 3 4 5 6 7 8 9 ( )  ( )  ( ) EMPHASIZE that they MUST MUST MUST MUST MUST read through and understand 2.4.5!

Alternative to Table with Many Ts We can use the F rows and negate the statement! # a b c d out F T 1 2 3 4 5 6 7 8 9 Which of these correctly models this LED? ~(~a  b  ~c  d)  ~(~a  b  c  ~d) ~(a  ~b  c  ~d)  ~(a  ~b  ~c  d) ~[(~a  b  ~c  d)  (~a  b  c  ~d)] ~[(a  ~b  c  ~d)  (a  ~b  ~c  d)] None of these A bit hard to read  The answer is c. Based on De Morgan’s, some of the others come CLOSE to being right.

Another Way Looking back at the bottom-left segment: There may be a simpler proposition, which will translate into a smaller circuit. Can you find a pattern in the rows for which the segment should be “on”? # a b c d out F T 1 2 3 4 5 6 7 8 9 ~d ^ (~b v c) Unit 1 - Propositional Logic

What is coming up? Second online quiz is due on WEDNESDAY, SEPT 10, 7:00pm. Assigned reading for the quiz: Epp, 4th edition: 2.2 Epp, 3rd edition: 1.2 Rosen, 6th edition: 1.1 from page 6 onwards. Rosen uses \neg instead of \sim. Unit 1 - Propositional Logic

Exercises: Prove that our two solutions for the lower-left segment are not logically equivalent. You should do this by providing values for the variables, so the two propositions have different truth values. Why are they both correct solutions, despite that? Finish the problem by building circuits for the other 5 segments. Design a circuit that takes three bits as input, and outputs the binary representation for their sum. Unit 1 - Propositional Logic