CSE 20 DISCRETE MATH. Fall

Similar documents
CSE 20 DISCRETE MATH. Fall

HW1 graded review form? HW2 released CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH. Winter

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

CSE 20 DISCRETE MATH. Winter

CSE 20 DISCRETE MATH. Fall

Note: The area of logic that deals with propositions is called the propositional calculus or propositional logic.

Definition 2. Conjunction of p and q

CSC Discrete Math I, Spring Propositional Logic

CSE 20 DISCRETE MATH WINTER

CSE 240 Logic and Discrete Mathematics

Compound Propositions

Combinational Logic. By : Ali Mustafa

Section 1.1: Logical Form and Logical Equivalence

Boolean algebra. Examples of these individual laws of Boolean, rules and theorems for Boolean algebra are given in the following table.

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

THE LOGIC OF COMPOUND STATEMENTS

DISCRETE STRUCTURES WEEK5 LECTURE1

Chapter 1, Section 1.1 Propositional Logic

Sample Problems for all sections of CMSC250, Midterm 1 Fall 2014

CSE 20 DISCRETE MATH. Winter

Statements and Quantifiers

Boolean Logic. CS 231 Dianna Xu

Logic. Def. A Proposition is a statement that is either true or false.

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

CSE 20: Discrete Mathematics

Proposition/Statement. Boolean Logic. Boolean variables. Logical operators: And. Logical operators: Not 9/3/13. Introduction to Logical Operators

Cs302 Quiz for MID TERM Exam Solved

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

CSE20: Discrete Mathematics for Computer Science. Lecture Unit 2: Boolan Functions, Logic Circuits, and Implication

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

COSC 243. Introduction to Logic And Combinatorial Logic. Lecture 4 - Introduction to Logic and Combinatorial Logic. COSC 243 (Computer Architecture)

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

2/13/2012. Logic: Truth Tables. CS160 Rosen Chapter 1. Logic?

A statement is a sentence that is definitely either true or false but not both.

Discrete Structures & Algorithms. Propositional Logic EECE 320 // UBC

CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH SPRING

Discrete Mathematics

Menu. Let s logically analyze a simple paragraph:

Boolean Algebra & Digital Logic

ICS141: Discrete Mathematics for Computer Science I

Logic and Proof. Aiichiro Nakano

software design & management Gachon University Chulyun Kim

Chapter 1, Part I: Propositional Logic. With Question/Answer Animations

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

CSE 20: Discrete Mathematics

Chapter 4, Logic using Propositional Calculus Handout

What is Logic? Introduction to Logic. Simple Statements. Which one is statement?

Mat 243 Exam 1 Review

CS100: DISCRETE STRUCTURES. Lecture 5: Logic (Ch1)

MTH202 Discrete Mathematics

Binary addition example worked out

Floating Point Representation and Digital Logic. Lecture 11 CS301

Numbers and Arithmetic

S C F F F T T F T T S C B F F F F F T F T F F T T T F F T F T T T F T T T

Digital Logic (2) Boolean Algebra

Building a Computer Adder

MAT2345 Discrete Math

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Propositional logic ( ): Review from Mat 1348

An Introduction to Logic 1.1 ~ 1.4 6/21/04 ~ 6/23/04

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

Packet #1: Logic & Proofs. Applied Discrete Mathematics

PROPOSITIONAL CALCULUS

Discrete Mathematics and Its Applications

10/14/2009. Reading: Hambley Chapters

CS Module 1. Ben Harsha Apr 12, 2017

Your quiz in recitation on Tuesday will cover 3.1: Arguments and inference. Your also have an online quiz, covering 3.1, due by 11:59 p.m., Tuesday.

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1

CSE 311: Foundations of Computing. Lecture 2: More Logic, Equivalence & Digital Circuits

CprE 281: Digital Logic

Today s Topic: Propositional Logic

Chapter Summary. Propositional Logic. Predicate Logic. Proofs. The Language of Propositions (1.1) Applications (1.2) Logical Equivalences (1.

Discrete Mathematics and Applications COT3100

Discrete Structures for Computer Science

~ p is always false. Based on the basic truth table for disjunction, if q is true then p ~

cse 311: foundations of computing Spring 2015 Lecture 3: Logic and Boolean algebra

1.1 Language and Logic

10/5/2012. Logic? What is logic? Propositional Logic. Propositional Logic (Rosen, Chapter ) Logic is a truth-preserving system of inference

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics. Introductory Notes in Discrete Mathematics Solution Guide

Introduction to Z3. Bow-Yaw Wang. December 19, Institute of Information Science Academia Sinica, Taiwan

Introduction Propositional Logic

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

TRUTH TABLES LOGIC (CONTINUED) Philosophical Methods

Section L.1- Introduction to Logic

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

Propositional Logic. Spring Propositional Logic Spring / 32

Chapter 7 Logic Circuits

4 Switching Algebra 4.1 Axioms; Signals and Switching Algebra

Looking at a two binary digit sum shows what we need to extend addition to multiple binary digits.

Chapter 1: The Logic of Compound Statements. January 7, 2008

Chapter 2: Switching Algebra and Logic Circuits

Propositional Logic 1

1.10 (a) Function of AND, OR, NOT, NAND & NOR Logic gates and their input/output.

Systems I: Computer Organization and Architecture

Transcription:

CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/

Today's learning goals Describe and use algorithms for integer operations based on their expansions Relate algorithms for integer operations to bitwise boolean operations Correctly use XOR and bit shifts List the truth tables and meanings for negation, conjunction, disjunction, exclusive or. Evaluate the truth value of a compound proposition given truth values of its constituent variables. Relate boolean operations to applications in combinatorial circuits

Algorithms For base 2 representations: If n = (a k-1 a 1 a 0 ) 2 then 4n =

CENTR 105: AB CENTR 115: BA Algorithms For base 2 representations: If n = (a k-1 a 1 a 0 ) 2 then 4n = To change your remote frequency 1. Press and hold power button until flashing 2. Enter two-letter code 3. Checkmark / green light indicates success If n = (a k-1 a 1 a 0 ) 2 then n is divisible by 4 exactly when A. k=2 B. a 0 = 1 C. a 1 = 0 D. a 1 = a 0 E. None of the above

Base expansion Rosen p. 246 Notation: for positive integer n Write when (a k-1 a 1 a 0 ) b n = a k-1 b k-1 + + a 1 b + a 0 Base b expansion of n

Terminology Base b expansion aka positional representation base b: Coefficients between 0 and b-1 (inclusive) Leading coefficient nonzero Fixed-width base b expansion: Coefficients between 0 and b-1 (inclusive) Pad leading coefficients as 0 to match desired width

Representing more? Base b expansions can express any positive integers Fixed width base b expansions can express nonnegative integers [0, b k -1] What about negative integers? rational numbers? other real numbers? stay tuned for CSE 30, CSE 140

Fixed width representation, circuits Rosen p. 20 Combinatorial (Logic) Circuit Inputs e.g. coefficients in fixed-width binary representation Outputs e.g. flag OR coefficients in fixed-width binary representation

Circuits for arithmetic Input: fixed-width 3-bit representation of n Output: 4n When might output not be correct? Overflow?

Circuits for arithmetic Input: fixed-width 3-bit representation of n Output: n mod 4

More complicated arithmetic Rosen p. 251, 826 In base b, s k-1 s 1 s 0 + t k-1 t 1 t 0 Algorithm relies on: one symbol sum, carry

Arithmetic + Representations For decimal: one digit sum table 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 0 2 2 3 4 5 6 7 8 9 0 1 3 3 4 5 6 7 8 9 0 1 2 4 4 5 6 7 8 9 0 1 2 3 5 5 6 7 8 9 0 1 2 3 4 6 6 7 8 9 0 1 2 3 4 5 7 7 8 9 0 1 2 3 4 5 6 8 8 9 0 1 2 3 4 5 6 7 9 9 0 1 2 3 4 5 6 7 8

Arithmetic + Representations For binary: one bit sum table 0 1 0 0 1 1 1 0

Arithmetic + Representations Alternatively, Input Output x y Sum Carry 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1

Arithmetic + Representations Rosen p. 251,826 Alternatively, XOR AND x y Input Output x y Sum Carry 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 Half adder logic circuit

Computer bit operations Rosen p. 11 x y x v y x OR y x ^ y x AND y x y x XOR y 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 1 1 0 "x OR y is 1 if at least one of x or y is 1" "x AND y is 1 if both x and y are 1" "x XOR y is 1 if exactly one of x and y is 1"

Ground? For n à 4n circuit, needed to pad with zeros. How? - Ground: constant 0 - Contradiction: a circuit (function) that always outputs 0 Which of the following is a contradiction? A. x OR x B. x AND x C. x XOR x D. All of the above E. None of the above

Logic gates Rosen p. 21 p p p q p q p q p q Inverter OR gate AND gate p T F p F T XOR gate New contradiction possible:

Logic Rosen Section 1.1 Use gates and circuits to express arithmetic. Precisely express theorems and invariant statements. Make valid arguments to prove theorems.

Circuits Propositions 0 (off) False 1 (on) (Order switched!) True p q p v q p ^ q p q T T T T F T F T F T F T T F T F F F F F

Definitions Rosen p. 2-4 Proposition: declarative sentence that is T or F (not both) Propositional variable: variables that represent propositions. Compound proposition: new propositions formed from existing propositions using logical operators. Truth table: table with 1 row for each of the possible combinations of truth values of the input and an additional column that shows the truth value of the result of the operation corresponding to a particular row.

Truth table: (p v q) v (p v r) How many rows are in the truth table for (p v q) v (p v r)? A. 1 B. 2 C. 3 D. 4 E. None of the above How do we fill in these rows? - Inputs - Output Precedence order of operations on p. 11

Truth tables Can use truth table to compute truth value of compound proposition. Also, can specify logical operator by truth table. Next time: how to prove two tables are equivalent? and how to reverse engineer compound proposition from a truth table?

Reminders Homework 1 due Friday at 11pm Algorithms, number representations Office hours