Download presentation
Presentation is loading. Please wait.
Published byAshley Andrews Modified over 9 years ago
1
CSE 20 DISCRETE MATH Prof. Shachar Lovett http://cseweb.ucsd.edu/classes/wi15/cse20-a/ Clicker frequency: CA
2
Todays topics Algorithms: number systems, binary representation Boolean logic Sections 1.3, 3.2-3.4 in Jenkyns, Stephenson
3
Operations on binary numbers Add, subtract, multiply,… … first, how do we add? A. 111 B. 100 C. 1011 D. 1111 E. None of the above
4
One bit addition 1 0 1 + 1 1 0 1
5
One bit addition 1 0 1 + 1 1 0 1
6
One bit addition 1 0 1 + 1 1 0 1 Carry: 0 1 1
7
One bit addition 1 0 1 + 1 1 0 1 Carry: 1 0 1 1
8
How to add binary numbers? 1 1 0 0 1 0 1 0 1 + 1 0 1 1 0 1 1 0 1 ? ? ? ? ?
9
How to add binary numbers? ? ? ? ? ? ? ? ? (carry) 1 1 0 0 1 0 1 0 1 + 1 0 1 1 0 1 1 0 1 ? ? ? ? ?
10
How to add binary numbers? Two basic operations: One-Bit-Addition(bit1, bit2, carry) Next-carry(bit1, bit2, carry) ? ? ? ? ? ? ? ? (carry) 1 1 0 0 1 0 1 0 1 + 1 0 1 1 0 1 1 0 1 ? ? ? ? ?
11
Numbers … logic … circuits
12
One bit addition One-Bit-Addition(bit1, bit2, carry) Bit1bit2carryOne-Bit-Addition FFFF FFTT FTFT FTTF TFFT TFTF TTFF TTTT T=1 F=0 Can we build this from “basic primitives”?
13
Logical operators JS pp. 82-84 Truth table is the definition of the operator! PQ P QP Q TTT TFF FTF FFF PQP v Q TTT TFT FTT FFF P~P TF FT
14
Logical operators JS pp. 82-84 PQ P QP Q TTT TFF FTF FFF PQP v Q TTT TFT FTT FFF P~P TF FT PQP XOR Q TT? TF? FT? FF? A.T, T, T, F B.T, F, F, T C.F, T, F, T D.F, F, F, T E.None of the above.
15
OR vs XOR A OR B: Either A, or B, or both A XOR B: Either A, or B, but not both In spoken language, we sometimes confuse them In mathematics, we needs to be precise
16
OR vs XOR A OR B: Either A, or B, or both A XOR B: Either A, or B, but not both In spoken language, we sometimes confuse them In mathematics, we needs to be precise You are at a restaurant. The menu says you can have either a salad or a soup. Mathematically, this is: A. OR B. XOR C. Both D. Neither
17
OR vs XOR A OR B: Either A, or B, or both A XOR B: Either A, or B, but not both In spoken language, we sometimes confuse them In mathematics, we needs to be precise You are at a birthday. The host asks: do you want ice-cream or cake (you can have both). Mathematically, this is: A. OR B. XOR C. Both D. Neither
18
Boolean expressions JS p. 83 How to translate to a truth table? Is there a unique way? A. Yes B. No (P Q) (~R)
19
Boolean expressions How to translate to a truth table? How many rows (not including header)? A. 2 B. 3 C. 4 D. 8 (P Q) (~R)
20
Boolean expressions PQR PQPQ ~R (P Q) (~R) FFF FFT FTF FTT TFF TFT TTF TTT
21
Boolean expressions PQR PQPQ ~R (P Q) (~R) FFFF FFTF FTFF FTTF TFFF TFTF TTFT TTTT
22
Boolean expressions PQR PQPQ ~R (P Q) (~R) FFFFT FFTFF FTFFT FTTFF TFFFT TFTFF TTFTT TTTTF
23
Boolean expressions PQR PQPQ ~R (P Q) (~R) FFFFTT FFTFFF FTFFTT FTTFFF TFFFTT TFTFFF TTFTTT TTTTFT
24
Truth table to expression PQR??? TTTT TTFT TFTT TFFF FTTF FTFF FFTT FFFF
25
DNFs DNF = Disjunctive Normal Form Literal: variable or its negation: P, ~P Term: AND of literals: P ~Q DNF: OR of terms: (P ~Q) (R P) ~P Theorem: any Boolean expression can be written as a DNF
26
Truth table to expression PQR??? TTTT TTFT TFTT TFFF FTTF FTFF FFTT FFFF
27
Truth table to expression PQR??? TTTT TTFT TFTT TFFF FTTF FTFF FFTT FFFF PQRPQR P Q ~R P ~Q R ~P ~Q R (P Q R) (P Q ~R) (P ~Q R) (~P ~Q R)
28
Truth tables and Circuits T“1”High voltage F“0”Low voltage
29
4 bit adder
30
Next class Quantifiers and paradoxes Read sections 3.2-3.4 in Jenkyns, Stephenson Google “liar’s paradox”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.