Discrete structures - CS Fall 2017 Questions for chapter 2.1 and 2.2

Similar documents
To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2008

1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4]

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

L05 - Negating Statements

CS1800 Discrete Structures Final Version A

Combinational Circuits Digital Logic (Materials taken primarily from:

CSE 20 DISCRETE MATH. Fall

QUESTION BANK FOR TEST

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Grade 7/8 Math Circles Fall November 6/7/8 Boolean Logic

Chapter 3. Gate-Level Minimization. Outlines

01 Introduction to Digital Logic. ENGR 3410 Computer Architecture Mark L. Chang Fall 2006

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1

Gate Level Minimization Map Method

Grade 7/8 Math Circles Fall November 6/7/8 Boolean Logic

Standard Forms of Expression. Minterms and Maxterms

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Propositional Calculus. Math Foundations of Computer Science

EE292: Fundamentals of ECE

Circuit analysis summary

Definition MATH Benjamin V.C. Collins, James A. Swenson MATH 2730

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Computer Organization and Levels of Abstraction

Chapter 2: Universal Building Blocks. CS105: Great Insights in Computer Science

Computer Organization and Levels of Abstraction

CSE 20 DISCRETE MATH. Winter

CS February 17

Introduction to Computer Architecture

Introduction to Boolean logic and Logical Gates

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Designing Information Devices and Systems II Fall 2017 Miki Lustig and Michel Maharbiz Discussion 1B

Midterm Exam 2B Answer key

Binary Values. CSE 410 Lecture 02

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Lecture (04) Boolean Algebra and Logic Gates

Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Simplification of Boolean Functions

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Strategies for Proofs

COMP combinational logic 1 Jan. 18, 2016

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)

LECTURE 2 An Introduction to Boolean Algebra

Boolean algebra. June 17, Howard Huang 1

Objectives: 1- Bolean Algebra. Eng. Ayman Metwali

Designing Information Devices and Systems II Spring 2018 J. Roychowdhury and M. Maharbiz Discussion 1A

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Midterm 1

Gate-Level Minimization

Module -7. Karnaugh Maps

Logic Gates and Boolean Algebra ENT263

Midterm #1a Fall minutes

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

(l) Represent each of the sets A, B and C using bit strings. Then, use bit string representation and bitwise logical operations to find

Gate-Level Minimization

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

SAT Solver. CS 680 Formal Methods Jeremy Johnson

Combinational Devices and Boolean Algebra

HW1. Due: September 13, 2018

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

Back to the knights and knaves island

CPSC 121 Midterm 1 Friday October 14th, Signature: Section (circle one): 11:00 15:30 17:00

1. Boolean algebra. [6] 2. Constructing a circuit. [4] 3. Number representation [4] 4. Adders [4] 5. ALU [2] 6. Software [4]


(Refer Slide Time 6:48)

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 09 MULTIPLEXERS

Combinational Circuits

ENGIN 112 Intro to Electrical and Computer Engineering

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

Lecture 3: Recursion; Structural Induction

Section 1.1 Logic LOGIC

Standard Boolean Forms

Combinational Logic & Circuits

2.1 Binary Logic and Gates

Control and Environments Fall 2017 Discussion 1: August 30, Control. If statements. Boolean Operators

CS40-S13: Functional Completeness

CARLETON UNIVERSITY. Laboratory 2.0

Summary of Course Coverage

Gate-Level Minimization. BME208 Logic Circuits Yalçın İŞLER

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Assignment (3-6) Boolean Algebra and Logic Simplification - General Questions

LAB #3: ADDERS and COMPARATORS using 3 types of Verilog Modeling

Arithmetic-logic units

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)

Experiment 4 Boolean Functions Implementation

BOOLEAN ALGEBRA. 1. State & Verify Laws by using :

Did you ever think that a four hundred year-old spider may be why we study linear relationships today?

C ONTROL AND H IGHER O RDER F UNCTIONS

Chapter 2. Boolean Expressions:

Lecture 5: More Examples/Applications of Quasirandom Graphs

Binary Adders: Half Adders and Full Adders

STUDENT LESSON A14 Boolean Algebra and Loop Boundaries

JMC 2015 Teacher s notes Recap table

Gate-Level Minimization. section instructor: Ufuk Çelikcan

Transcription:

Discrete structures - CS1802 - Fall 2017 Questions for chapter 2.1 and 2.2 1. (a) For the following switch diagrams, write the corresponding truth table and decide whether they correspond to one of the logic gates AND or OR. i. ii. (b) Draw switch diagrams for the following truth tables: i. ii. A B Output 0 0 1 0 1 1 1 0 1 1 1 0 A B Output 0 0 0 0 1 1 1 0 0 1 1 0 (c) For the following logic circuit: i. Compute the output for: I 0 =0,I 1 =0,I 2 =0,I 3 =0 1

ii. Compute the output for: I 0 =1,I 1 =1,I 2 =0,I 3 =0 iii. Compute the output for: I 0 =1,I 1 =1,I 2 =1,I 3 =1 Answer: (a) i. ii. (b) i. A B Output 0 0 0 0 1 1 1 0 1 1 1 1 This is an OR gate. A B Output 0 0 1 0 1 1 1 0 0 1 1 1 This is not an OR gate and not an AND gate. ii. (c) i. The output is 1. ii. The output is 0. iii. The output is 1. 2. In this question we will consider the parity of 3 bits. You may think of these 3 bits as if they represent an integer between 0 to 7. 2

The possible bit-representations are: Bit 1 Bit 2 Bit 3 Integer 0 0 0 0 0 0 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 5 1 1 0 6 1 1 1 7 We say that the parity of the bits is odd if exactly 1 or exactly 3 of the bits equal 1, and we say that the parity is even if exactly 0 or exactly 2 of the bits equal 1. (In the above table, for the integers 1, 2, 4, 7theparityisodd,andfor0, 3, 5, 6 the parity is even.) Throughout the question you may use AND gates, OR gates, and NOT gates. (a) Given the value of 3 bits as input, design a logic circuit that determines whether the 3 bits are all 1. (The output should be 1 if all the bits equal 1 and 0 otherwise.) Your logic circuit should look like: Answer: One possible straightforward solution is: (b) Given the value of 3 bits as input, design a logic circuit that determines whether exactly 1 out of the 3 bits equals 1. (The output should be 1 if exactly one bit equals 1 and 0 otherwise.) Your logic circuit should look like: 3

Answer: One possible straightforward solution is: (c) Use the logic circuits that you designed in the previous sections to design alogiccircuitthatdetermineswhethertheparityof3bitsisevenorodd. (The output should be 1 if the parity is odd and 0 otherwise.) Answer: One possible straightforward solution is: 4

Lecture 5 Recitation (W. Schnyder) I Logical Equivalence 1. (A ^ B) _ (A ^ ( B)) is logically equivalent to which of the following: A, B, 0, 1, A _ ( B) Solution: A due to distribution and complement rules NOTE: for the rest of the assignment, I will write AND, NOT, OR, etc rather than using the Boolean logic symbols. Students: make sure to use the Boolean symbols in all assignments. 2. (A _ B) islogicallyequivalenttowhichofthefollowing: A, B, 0, 1, (NOT A) AND (NOT B) Solution: (NOT A) AND (NOT B) due to DeMorgan s Rule 3. Use laws of logic to show that (A ^ (B _ A)) and A _ B are logically equivalent. Solution: (A ^ (B _ A)) ((A ^ B) _ (A ^ A)) ((A ^ B) _ F alse) (A ^ B) A _ B 4. Evaluate (A B) ^ (B _ ( A)) (i) when A is T (true) and B is F (false); (ii) when A is F and B is T? and (iii) when A and B are both F? Solution: (i) T and F thus F; (ii) T and T thus T (iii) F and T thus F 5. How many total rows will there be in the truth table representation of 1

(A XOR B) OR ((NOT C) AND A) Solution: Three variables. Therefore 2 3 or 8 6. What value of A will cause (A XNOR B) XOR (A OR B) to be T when B is T? Solution: The second clause is true, so the first needs to be false. XNOR is true when the values match. So the values need to not match. So A is F. II DNF and CNF Given the truth table: A B C Out 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1. Write an expression in DNF that has this truth table. Solution: ( A ^ B ^ C) _ ( A ^ B ^ C) _ (A ^ B ^ C) _ (A ^ B ^ C) (which could be simplified) 2. Write an expression in CNF for this truth table. Solution: (A _ B _ C) ^ (A _ B _ C) ^ ( A _ B _ C) ^ ( A _ B _ C) (which could be simplified) III For Fun 1. You are on Smullyan island where each inhabitant belongs to one of two clans: the TRUTH TELLERS who always tell the truth and the LIARS who always lie. You meet a couple. The husband says Exactly one of us is lying. The 2

wife says At least one of us is telling the truth. Who, if anyone, is telling the truth? Construct a truth table with two variables, H (meaning that the husband is a truth teller) and W (the wife is a truth teller) and two statement columns, one for the statement Exactly one is lying, the other for the statement At least one is truthful. Explain how your truth table can be used to discover who (if anyone) is telling the truth. (Note: you might also solve the problem by going through cases in your head. The truth table is used to organize this process.) Solution: H W Exactly one lying At least one truthful T T F T T F T T F T T T F F F F ArowisonlyconsistentifthevaluesofHandTareidenticaltothevaluesof their statements (a liar says something false, and a truth teller says something true). The only row with this property is the last one: both are liars. 2. You are still on Smullyan island walking back to your hotel when the road forks into two branches. You don t know which branch to take but there is an inhabitant sitting on a bench nearby and you are allowed to ask him a single question. What question could you ask to discover the way back? (Note: though all this happens on Smullyan island, this problem isn t of the same kind as the one above). Solution: Possible question: Which branch would someone from the other clan suggest? Then take the other branch. 3

CS1802 Discrete Structures Recitation Fall 2017 September 12, 2017 CS1802 Week 3: Logic and Proofs More Logic i. Let P mean it is raining, Q mean the sprinklers are on, and R mean the lawn is wet. Phrase each English statement as propositional logic using _, ^,, =), and (). 1. If it is raining, the lawn is wet. 2. If it is raining or the sprinklers are on, the lawn is wet. 3. If the lawn is not wet, it is not raining. 4. The lawn is wet if and only if it is either raining or the sprinklers are on. 5. If the lawn is not wet, it is not raining is actually just another way of saying If it is raining, the lawn is wet. The two statements are equivalent; they are both only false if it is raining and the lawn is not wet. Come up with an equivalent statement to If it is raining or the sprinklers are on, the lawn is wet that begins with If the lawn is not wet... and give the propositional logic form of this statement. Solution: 1. P =) R 2. (P _ Q) =) R 3. R =) P 4. R () (P _ Q) 5. If the lawn is not wet, it is not raining and the sprinklers are not on : R =) ( P ^ Q) (note De Morgan s Law makes this equivalent to R =) (P _ Q) ) ii. Interpret the following statements as English sentences, then decide whether those statements are true if x and y can be any integers. 1

1. 8x9y : x + y =0 2. 9y8x : x + y = x 3. 9x8y : x + y = x Solution: 1. For all x, thereexistsy such that x + y = 0 : true (negative numbers) 2. There exists y such that for all x, x + y = 0 : true (0) 3. There exists x such that for all y, x + y = 0 : false 2

Proofs Solution: Interpret the following statements as English sentences, then decide whether those statements are true. 1. 8x 2 Z, 9y 2 Z : x + y = prime TRUE : for any given x 2 Z, choose y =2 x, sox + y =2prime 2. 8x 2 Z, 9y 2 Z : x + y = prime and y = prime FALSE for y = 7: there is no y 2 Z such that both y and y + 7 are prime 3. 8x 2 Z,x even, 9y 2 Z : x + y = prime and y = prime This is a hard question, not clear the answer is known yet. There has been recently significant progress on Golbach Conjecture and related problems https://math.stackexchange.com/questions/28247/can-every-even-integer-be-expressed -as-the-difference-of-two-primes 4. 8x 2 R, 8y 2 R : x>y, x 2 >y 2 FALSE for x = 1; y = 3 5. 8x 2 R,x>0, 8y 2 R,y >0:x>y, x 2 >y 2 TRUE for x, y > 0. Proof: x>y, x 2 >xy; xy > y 2, x 2 >xy>y 2 6. 8x 2 R,x6= 0, 8y 2 R : x + y<0, x y<0 FALSE for x = 1,y = 2 3

Solution: Bitwise Interpret the following statements as English sentences, then decide whether those statements are true. Variables a, b,c are boolean and variabels A, B, C are boolean sequences (or sequences of bits), for example A = a 1 a 2...a k = a 1,a 2,...,a k is a sequence of k bits or k boolean variables. k is fixed (for example k=32). A, B, C allow boolean operations bitwise : A = a 1 a 2...a k and B = b 1 b 2...b k then A ^ B = a 1 ^ b 1,a 2 ^ b 2,...,a k ^ b k Similarly A _ B = a 1 _ b 1,a 2 _ b 2,...,a k _ b k,etc 1. 8a, b, c 2{T,F} : a ^ b = a ^ c ) b = c FALSE for a =0,b=1,c=0 2. 8A, B, C 2{T,F} k : A ^ B = A ^ C ) B = C FALSE for A = 010,B = 101,C = 001 3. 9A, 8B,C 2{T,F} k : A ^ B = A ^ C ) B = C TRUE for A = 111 : 111 ^ B = 111 ^ C ) B = C 4. 8a, b, c 2{T,F} : a _ b = a _ c ) b = c FALSE for a =1,b=1,c=0 5. 8A, B, C 2{T,F} k : A _ B = A _ C ) B = C FALSE for A = 010,B = 101,C = 111 6. 9A, 8B,C 2{T,F} k : A _ B = A _ C ) B = C TRUE 4

7. 8a, b, c 2{T,F} : a XOR b = a XOR c ) b = c TRUE: if bits b and c have the same XOR with bit fixed bit a (either 0 or 1) then they must be equal 8. 8A, B, C 2{T,F} k : A XOR B = A XOR C ) B = C TRUE 9. This last XOR equation should allow you to prove the strategy for the XOR-square-game: the player wants to leave the table such that when the counts are written in binary, their XOR across all rows is 0. Prove that if player A leaves a board with XOR(binary rows)=0, then player B cannot do the same Prove that if player B leaves a board with XOR(binary rows)6= 0, then player A has a move to make the board as desired XOR(binary rows)= 0 5