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

Similar documents
CSE 20 Discrete Math. Winter, January 24 (Day 5) Number Theory. Instructor: Neil Rhodes. Proving Quantified Statements

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

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Binary addition example worked out

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

CSE 20 DISCRETE MATH. Fall

UNIVERSITI TENAGA NASIONAL. College of Information Technology

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

EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits)

Outline. EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits) Combinational Logic (CL) Defined

Math 13, Spring 2013, Lecture B: Midterm

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

Lecture 2 Review on Digital Logic (Part 1)

Fundamentals of Digital Design

Cs302 Quiz for MID TERM Exam Solved

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

2 Application of Boolean Algebra Theorems (15 Points - graded for completion only)

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

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

Switches: basic element of physical implementations

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

1 Predicates and Quantifiers

Logic and Proofs. (A brief summary)

Chapter 2: Switching Algebra and Logic Circuits

CS61c: Representations of Combinational Logic Circuits

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

Combinational Logic. By : Ali Mustafa

UC Berkeley College of Engineering, EECS Department CS61C: Representations of Combinational Logic Circuits

Notation Index. gcd(a, b) (greatest common divisor) NT-16

Computer Organization: Boolean Logic

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

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

Exercise Set 1 Solutions Math 2020 Due: January 30, Find the truth tables of each of the following compound statements.

Numbers and Arithmetic

Chapter 4, Logic using Propositional Calculus Handout

EECS150 - Digital Design Lecture 19 - Combinational Logic Circuits : A Deep Dive

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A

CS1800 Discrete Structures Fall 2017 October, CS1800 Discrete Structures Midterm Version A

Introduction to Sets and Logic (MATH 1190)

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

THE LOGIC OF QUANTIFIED STATEMENTS. Predicates and Quantified Statements I. Predicates and Quantified Statements I CHAPTER 3 SECTION 3.

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

Number System conversions

Definition 2. Conjunction of p and q

Conversions between Decimal and Binary

Systems I: Computer Organization and Architecture

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

ICS141: Discrete Mathematics for Computer Science I

Problem 1: Suppose A, B, C and D are finite sets such that A B = C D and C = D. Prove or disprove: A = B.

Numbers and Arithmetic

CHAPTER1: Digital Logic Circuits Combination Circuits

Combinational Logic Design Principles

Lecture 3. Logic Predicates and Quantified Statements Statements with Multiple Quantifiers. Introduction to Proofs. Reading (Epp s textbook)

For all For every For each For any There exists at least one There exists There is Some

Binary Multipliers. Reading: Study Chapter 3. The key trick of multiplication is memorizing a digit-to-digit table Everything else was just adding

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

1 Boolean Algebra Simplification

Basic Logic and Proof Techniques

Chapter 2: The Logic of Quantified Statements. January 22, 2010

CHAPTER 2 NUMBER SYSTEMS

Chapter 1 CSCI

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

Logic. Logic is a discipline that studies the principles and methods used in correct reasoning. It includes:

Digital Logic (2) Boolean Algebra

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

THE LOGIC OF COMPOUND STATEMENTS

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

CSC 125 :: Final Exam December 14, 2011

BOOLEAN ALGEBRA INTRODUCTION SUBSETS

MAT2345 Discrete Math

Unit 8A Computer Organization. Boolean Logic and Gates

10/14/2009. Reading: Hambley Chapters

MATH 271 Summer 2016 Practice problem solutions Week 1

COS 140: Foundations of Computer Science

Logic and Proofs. (A brief summary)

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Boolean Algebra & Logic Gates. By : Ali Mustafa

What is the decimal (base 10) representation of the binary number ? Show your work and place your final answer in the box.

BOOLEAN ALGEBRA. Introduction. 1854: Logical algebra was published by George Boole known today as Boolean Algebra

CS 220: Discrete Structures and their Applications. Predicate Logic Section in zybooks

CS1800: Hex & Logic. Professor Kevin Gold

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

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

CSE 20: Discrete Mathematics

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

COMBINATIONAL LOGIC FUNCTIONS

UNIT 8A Computer Circuitry: Layers of Abstraction. Boolean Logic & Truth Tables

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

Section Summary. Proof by Cases Existence Proofs

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Part I: Propositional Calculus

WEEK 2.1 BOOLEAN ALGEBRA

ECE380 Digital Logic. Positional representation

Propositional Logic, Predicates, and Equivalence

STRATEGIES OF PROBLEM SOLVING

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Menu. Review of Number Systems EEL3701 EEL3701. Math. Review of number systems >Binary math >Signed number systems

Transcription:

CSE 20 Discrete Math Algebraic Rules for Propositional Formulas Equivalences between propositional formulas (similar to algebraic equivalences): Associative Summer, 2006 July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic Instructor: Neil Rhodes Distributive Double Negation DeMorgan s Commutative Absorption Bound Idempotent Negation 2 Boolean Functions Functions that take n inputs (all 0 or 1) and returns a value of 0 or 1 Truth TableBoolean Function Disjunctive Normal Form a b c z 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 3 4

Gates Numbers in Different Bases And Or Not Xor (exclusive or) Nand Given a number dn-1dn-2dn-3...d1d0 in a base b, then: Each di is in the range 0 b-1 The value of the number is dn-1b n-1 +dn-2b n-2 +dn-3b n-3 + +d1b 1 +d0b 0 b is an integer > 1 The largest such number with n digits is b n -1 The smallest such number with n digits is b n-1 Common bases in CS: 2 (binary) binary digit = bit Inconvenient to read/write 8 (octal) No 8, 9, 10 16 (hexadecimal) How to represent di in range 10..15? Very common Nor 5 6 Converting between Bases Converting a number n in base b to base c Divide n by c. The remainder is the rightmost digit Continue until n is 0 Shortcut for converting between common bases 2->8 Group in triples from RHS 2->16 Group in group of four from RHS 16->2 Convert each hex digit into 4 binary digits 8->2 Convert each octal digit into 3 binary digits Binary Numbers Using k bits to represent a non-negative number k is often a power of 2 (8, 16, 32, 64) Total unique numbers is 2 k Biggest number is 2 k -1 Most-significant-bit Least-significant-bit Adding numbers Add each pair of bits (including carry) from right to left, carrying as needed Overflow: If we end up with a carry, we ve overflowed the result and can no longer represent it k=8: A8 + 86 = 7 8

How Computers Add We want to add two binary numbers: 13 +22 ----- 35 Truth Table: Half Adder (Single-bit Adder) p q S C 0 0 0 1 1 0 1 1 Rules: 0 + 0 = 0 + 1 = 1 + 0 = Black box: 1 + 1 = 9 10 Calculating the carry bit Half Adder p q S C 0 0 0 1 1 0 1 1 Calculating the sum bit Half Adder A B S C 0 0 0 1 1 0 1 1 Circuit: Circuit: 11 12

Half Adder A B S C 0 0 0 1 1 0 1 1 Combinatorial (Combinational) Circuit An input wire can split to be used as input to two gates An output wire can be used as input The outputs depend only on the present inputs Don t depend on history One way to achieve this: no cycles Sequential circuits: output depends on the history Overall circuit: Direct correspondence between combinatorial circuits and boolean functions Master s thesis by Claude Shannon: 1937 13 14 Full Adder Half-adder only works for rightmost bits of two numbers. Full adder can also handle the incoming carry bit Circuit? Negative Numbers Sign-bit only MSB is now a sign bit Remaining bits represent the positive number Problems: 2 representations of 0 Difficult to add/subtract Ones-complement To obtain a negative number, complement (flip) each bit in the positive number Problems: 2 representations of 0 Twos-complement To obtain the negative number, complement (flip) each bit in the positive number and add 1 neg(n) = 2 k -n neg(n) + n = 2 k -n+n = 2 k = 0 Negative of 0 Problems: More negative numbers than positive (not symmetric) 15 16

Adding Twos-Complement Numbers Add the two (whether positive or negative) If carry bit from MSB is set: If both were negative If result looks negative, it is correct - Example: -3 + -2 If result looks positive, overflow occurred If both were positive Not possible If signs were different, overflow can be ignored Example: 5 + -3 If carry bit from MSB is not set: If both were positive and result looks negative: overflow occurred Other Operations with Twos-Complement Numbers Subtraction: convert subtraction problem to addition problem Convert a - b to a + (-b) Summary: Ignore the carry bit from the MSB. If two numbers of the same sign yield a result of a different sign, overflow occurred. 17 18 Other Operations with Twos-Complement Numbers Multiplication: Multiply by power of 2: arithmetic shift left Shift (all but sign bit) 1 to the left (new bit on right is a zero) Arbitrary result = 0 while b 0 if (b and 1) 0 result = result + a shift a left by one shift b right by one return result Other Operations with Twos-Complement Numbers Division Divide by power of 2: arithmetic shift right Shift all bits 1 to the right (what about new sign bit?) Example of arbitrary divisor and dividend using long division: 25/4 19 20

Predicates Important Sets Grammatical origin Z (Zahl = Number) Alternate definitions of a predicate: A sentence with a finite number of variables. Replacing variables with specific values yields a statement. The domain is the set of all possible values to substitute. A function whose codomain is (true/false) statements. Example: x 2 > 1 Domain? Example statements? Boy x likes girl y (alternate syntax: ) Domain? Example statements? Z + N (Natural) No general agreement on whether it includes 0 Q (Quotient) R (Real) P (Prime) 21 22 Truth Set of a Predicate, P(x) Quantifiers The set of all elements in the domain that make P(x) true Universal x D S(x) Denoted: {x D: P(x)} Example: What is the truth set of x is a factor of 8? Existential x D: S(x) If D is {0, 1, 2}? if D is in {0, 1, 2, 3, } (N)? If D is in {, -3, -2, -1, 0, 1, 2, 3, } (Z)? Common to drop D if it is clear from context 23 24

Examples Let L(x, y) be the predicate Boy x likes girl y ~( x: P(x)) x ~P(x) Negation and Quantifiers y: x: L(x, y) y: x L(x, y) ~( x P(x)) x: ~P(x) x y: L(x, y) y L( Jose, y) 25 26 Examples L(x, y) = x likes y Domain: all people in my son s 1 st grade class Everyone likes Jill Converting to Predicates If a number is a natural number, it is an integer Nobody likes Jill Not everybody likes Jill The square of any real number greater than 2 is greater than 4 There exists a person that nobody likes Nobody dislikes everybody Everybody likes him/herself x y z ( L(x, y) L(y, z) L(x, z)) x y (L(x, y) L(y, x)) 27 28

Quantifiers and Adversaries Statements involving quantifiers can be viewed as a game Two players You, trying to prove the statement is true An adversary, trying to prove the statement is false Work from left to right through the quantifiers y: the adversary selects an y (think of the adversary as choosing the worst possible y). That y remains bound the rest of the game x: you select an x that will satisfy the statement. That x remains bound the rest of the game Example: x Z, y Z: 2x = y Limit The limit of a sequence a is L means that a gets arbitrarily close to L lim a n = L n ε R +, n 0 N : n N,n n 0 L ε a n L + ε x Z: y Z, xy = 0 y Z, x Q: y0xy = 1 29 30 Order of Growth of a Function We say that T(n) has an asymptotic upper bound of f(n) if: Proving Quantified Statements Prove universal statement: x D, P(x) Exhaustive enumeration n 0 N : c R + : n Z,n n 0 0 T (n) c f (n) Generalizing from the generic particular Suppose x is in D Therefore P(x) Example: The difference of two odd numbers is even 31 32

Proving Quantified Statements Prove existential statement: x D: P(x) Constructive proof Display an x Give a set of directions for finding x Nonconstructive proof Proof by contradiction (assume non-existence and show a contradiction) Show x must exist Example: In a group of 367 people, at least two share a birthday Disproving Quantified Statements Disprove universal statement: x D, P(x) Counterexample Show an x in D where not P(x) Example: All primes are of the form 2 n - 1 Disprove existential statement: x D: P(x) Equivalent to: Prove Or, alternatively, Therefore, best bet is generalizing from the generic particular. Example: There exists a prime which can be written as the square of an integer > 1 33 34