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

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

Consider the following propositions: p: lecture has started q: If I have a banana, then I have a pear r: I finished this problem

CSE 311: Foundations of Computing I. Lecture 1: Propositional Logic

CSE 311: Foundations of Computing. Lecture 3: Digital Circuits & Equivalence

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

CSC Discrete Math I, Spring Propositional Logic

Chapter 1, Section 1.1 Propositional Logic

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

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

CSE 20: Discrete Mathematics

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

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

Compound Propositions

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Definition 2. Conjunction of p and q

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

2.2: Logical Equivalence: The Laws of Logic

CSE 311 Lecture 02: Logic, Equivalence, and Circuits. Emina Torlak and Kevin Zatloukal

Tautologies, Contradictions, and Contingencies

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

PROPOSITIONAL CALCULUS

EECS 1028 M: Discrete Mathematics for Engineers

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

Propositional Logic. Spring Propositional Logic Spring / 32

THE LOGIC OF COMPOUND STATEMENTS

AMTH140 Lecture 8. Symbolic Logic

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

Overview. 1. Introduction to Propositional Logic. 2. Operations on Propositions. 3. Truth Tables. 4. Translating Sentences into Logical Expressions

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

Propositional Logic: Equivalence

n logical not (negation) n logical or (disjunction) n logical and (conjunction) n logical exclusive or n logical implication (conditional)

Proofs. Joe Patten August 10, 2018

Example. Logic. Logical Statements. Outline of logic topics. Logical Connectives. Logical Connectives

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Numbers that are divisible by 2 are even. The above statement could also be written in other logically equivalent ways, such as:

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

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Introduction to Decision Sciences Lecture 2

Propositional Logic Logical Implication (4A) Young W. Lim 4/11/17

Propositional Logic 1

1.1 Language and Logic

Boolean Logic. CS 231 Dianna Xu

Examples. Example (1) Example (2) Let x, y be two variables, and denote statements p : x = 0 and q : y = 1. Solve. x 2 + (y 1) 2 = 0.

Propositional logic ( ): Review from Mat 1348

1.1 Language and Logic

Discrete Mathematics and Applications COT3100

Topic 1: Propositional logic

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

1.3 Propositional Equivalences

Section 1.1: Logical Form and Logical Equivalence

Packet #1: Logic & Proofs. Applied Discrete Mathematics

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

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

Introduction to Sets and Logic (MATH 1190)

MAT2345 Discrete Math

Propositional natural deduction

LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, Propositional logic

Propositional Logic Logical Implication (4A) Young W. Lim 4/21/17

Logic and Proofs. (A brief summary)

CSE 20 DISCRETE MATH. Fall

The Foundations: Logic and Proofs. Part I

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

Propositional Equivalence

The Logic of Compound Statements cont.

FUNDAMENTALS OF MATHEMATICS HANDOUT 1.3 DR. MCLOUGHLIN

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

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

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

CHAPTER 1 - LOGIC OF COMPOUND STATEMENTS

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

Logic Overview, I. and T T T T F F F T F F F F

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

Section 1.2: Propositional Logic

Propositional Logic: Semantics

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

Unit 1. Propositional Logic Reading do all quick-checks Propositional Logic: Ch. 2.intro, 2.2, 2.3, 2.4. Review 2.9

Mathematical Reasoning (Part I) 1

Discrete Mathematics and Its Applications

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

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Department of Computer Science & Software Engineering Comp232 Mathematics for Computer Science

Propositional Logic. Propositional Equivalences. Agenda. Yutaka HATA, IEEE Fellow. Ch1.1 Propositional Logic. Ch1.2 Propositional Equivalences

CISC-102 Winter 2016 Lecture 17

Steinhardt School of Culture, Education, and Human Development Department of Teaching and Learning. Mathematical Proof and Proving (MPP)

1 Propositional Logic

Learning Goals of CS245 Logic and Computation

Today s Topic: Propositional Logic

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

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

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

Truth-Functional Logic

About the course. CSE 321 Discrete Structures. Why this material is important. Topic List. Propositional Logic. Administration. From the CSE catalog:

Section 1.1 Propositional Logic. proposition : true = T (or 1) or false = F (or 0) (binary logic) the moon is made of green cheese

CSC165 Mathematical Expression and Reasoning for Computer Science

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

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

Part I: Propositional Calculus

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

software design & management Gachon University Chulyun Kim

Solutions to Homework I (1.1)

Transcription:

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

Last class: Some Connectives & Truth Tables Negation (not) p p T F F T Disjunction (or) p q p q T T T T F T F T T F F F Conjunction (and) p q p q T T T T F F F T F F F F Exclusive Or p q p q T T F T F T F T T F F F

Last class: Implication If it s raining, then I have my umbrella p q p q T T T T F F F T T F F T

(1) I have collected all 151 Pokémon if I am a Pokémon master (2) I have collected all 151 Pokémon only if I am a Pokémon master These sentences are implications in opposite directions:

(1) I have collected all 151 Pokémon if I am a Pokémon master (2) I have collected all 151 Pokémon only if I am a Pokémon master These sentences are implications in opposite directions: (1) Pokémon masters have all 151 Pokémon (2) People who have 151 Pokémon are Pokémon masters So, the implications are: (1) IfI am a Pokémon master, theni have collected all 151 Pokémon. (2) IfI have collected all 151 Pokémon, theni am a Pokémon master.

Implication: pimplies q whenever pis true qmust be true if pthen q qif p pis sufficient for q ponly if q q is necessary for p p q p q T T T T F F F T T F F T

Biconditional: piffq pis equivalent to q pimplies qand qimplies p p is necessary and sufficient for q p q p q

Biconditional: piffq pis equivalent to q pimplies qand qimplies p p is necessary and sufficient for q p q p q T T T T F F F T F F F T

Last class: Using Logical Connectives Measles: You can get measles Mumps: You can get mumps MMR: You had the MMR vaccine You can get measles and mumps if you didn t have the MMR vaccine, but if you had the MMR vaccine then you can t get either. ((Measlesand Mumps) if not MMR) and (if MMRthen not (Measlesor Mumps)) ((Measles Mumps) if MMR) (if MMRthen (Measles Mumps))

Understanding the Vaccine Sentence You can get measles and mumps if you didn t have the MMR vaccine, but if you had the MMR vaccine you can t get either. ((Measles Mumps) if MMR) (if MMRthen (Measles Mumps)) ( MMR (Measles Mumps)) (MMR (Measles Mumps))

Understanding the Vaccine Sentence You can get measles and mumps if you didn t have the MMR vaccine, but if you had the MMR vaccine you can t get either. ((Measles Mumps) if MMR) (if MMRthen (Measles Mumps)) ( MMR (Measles Mumps)) (MMR (Measles Mumps)) Define shorthand : MMR : Measles : Mumps ( ) ( )

Analyzing the Vaccine Sentence with a Truth Table ( ) ( ) ( ) ( ( )) T T T T T F T F T T F F F T T F T F F F T F F F

Analyzing the Vaccine Sentence with a Truth Table ( ) ( ) ( ) ( ( )) T T T F T T T F F F T T F F F T T F F F T F T F F T T F F F T F F F F T F T T T F T T T T T T F T T F T F T F F T F T F F F T T F F T F T F F F F T F F F T T F

Converse, Contrapositive Implication: p q Converse: q p Contrapositive: q p Inverse: p q Consider p:xis divisible by 2 q: xis divisible by 4 p q q p q p p q

Converse, Contrapositive Implication: p q Converse: q p Contrapositive: q p Inverse: p q Consider p:xis divisible by 2 q: xis divisible by 4 p q q p q p p q Divisible By 4 Not Divisible By 4 Divisible By 2 Not Divisible By 2

Converse, Contrapositive Implication: p q Converse: q p Contrapositive: q p Inverse: p q Consider p:xis divisible by 2 q: x is divisible by 4 Divisible By 2 Not Divisible By 2 p q q p q p p q Divisible By 4 4,8,12,... Impossible Not Divisible By 4 2,6,10,... 1,3,5,...

Converse, Contrapositive Implication: p q Converse: q p Contrapositive: q p Inverse: p q How do these relate to each other? p q p q q p p q p q q p T T T F F T F F

Converse, Contrapositive Implication: p q Converse: q p Contrapositive: q p Inverse: p q An implication and it s contrapositive have the same truth value! p q p q q p p q p q q p T T T T F F T T T F F T F T T F F T T F T F F T F F T T T T T T

Tautologies! Terminology: A compound proposition is a Tautology if it is always true Contradiction if it is always false Contingencyif it can be either true or false p p p p (p q) p

Tautologies! Terminology: A compound proposition is a Tautology if it is always true Contradiction if it is always false Contingencyif it can be either true or false p p This is a tautology. It s called the law of the excluded middle. Ifpis true, thenp pis true. If p is false, then p pis true. p p This is a contradiction. It s always false no matter what truth valuep takes on. (p q) p This is a contingency. Whenp=T, q=t, (T T) Tis true. Whenp=T, q=f, (T F) Tisfalse.

Logical Equivalence A= Bmeans Aand B are identical strings : p q=p q p q q p

Logical Equivalence A= Bmeans Aand B are identical strings : p q=p q These are equal, because they are character-for-character identical. p q q p These are NOT equal, because they are different sequences of characters. They mean the same thing though. A Bmeans Aand B have identical truth values: p q p q p q q p p q q p

Logical Equivalence A= Bmeans Aand B are identical strings : p q=p q These are equal, because they are character-for-character identical. p q q p These are NOT equal, because they are different sequences of characters. They mean the same thing though. A Bmeans Aand B have identical truth values: p q p q Two formulas that are equal also are equivalent. p q q p These two formulas have the same truth table! p q q p When p=t andq=f, p qis false, butp q is true!

A B vs. A B A B is an assertion over all possible truth values that Aand Balways have the same truth values. A Bis a propositionthat may be true or false depending on the truth values of the variables in A and B. A B and (A B) T have the same meaning.

De Morgan s Laws (p q) p q (p q) p q Negate the statement: My code compiles or there is a bug. To negate the statement, ask when is the original statement false.

De Morgan s Laws (p q) p q (p q) p q Negate the statement: My code compiles or there is a bug. To negate the statement, ask when is the original statement false. It s false when not(my code compiles) AND not(there is a bug). Translating back into English, we get: My code doesn t compile and there is not a bug.

De Morgan s Laws Example: (p q) ( p q) p q p q p q p q (p q) (p q) ( p q) T T T F F T F F

De Morgan s Laws Example: (p q) ( p q) p q p q p q p q (p q) (p q) ( p q) T T F F F T F T T F F T T F T T F T T F T F T T F F T T T F T T

De Morgan s Laws (p q) p q (p q) p q if (!(front!= null && value > front.data)) front = new ListNode(value, front); else { ListNode current = front; while (current.next!= null && current.next.data < value)) current = current.next; current.next = new ListNode(value, current.next); }

De Morgan s Laws (p q) p q (p q) p q!(front!= null && value > front.data) front == null value <= front.data You ve been using these for a while!

Law of Implication p q p q p q p q p p q T T T F F T F F p q p q

Law of Implication p q p q p q p q p p q p q p q T T T F T T T F F F F T F T T T T T F F T T T T

Some Equivalences Related to Implication p q p q p q q p p q (p q) (q p) p q p q

Properties of Logical Connectives We will always give you this list!

Digital Circuits Computing With Logic T corresponds to 1 or high voltage F corresponds to 0 or low voltage Gates Take inputs and produce outputs (functions) Several kinds of gates Correspond to propositional connectives (most of them)

And Gate AND Connective p q p q p q T T T T F F F T F F F F vs. AND Gate p q AND OUT p q OUT 1 1 1 1 0 0 0 1 0 0 0 0 p q AND OUT block looks like D of AND

Or Gate OR Connective p q p q p q T T T T F T F T T F F F vs. OR Gate p q OR OUT p q OUT 1 1 1 1 0 1 0 1 1 0 0 0 p q OR OUT arrowhead block looks like V

Not Gates NOT Connective vs. NOT Gate p p p p p NOT OUT OUT Also called inverter T F 1 0 F T 0 1 p NOT OUT

Blobs are Okay! You may write gates using blobs instead of shapes! p q AND OUT p q OR OUT p NOT OUT

Combinational Logic Circuits p NOT AND OUT q NOT AND r s OR Values get sent along wires connecting gates

Combinational Logic Circuits p NOT AND OUT q NOT AND r s OR Values get sent along wires connecting gates

Combinational Logic Circuits p AND q NOT OR OUT r AND Wires can send one value to multiple gates!

Combinational Logic Circuits p AND q NOT OR OUT r AND Wires can send one value to multiple gates! ( )

Computing Equivalence Describe an algorithm for computing if two logical expressions/circuits are equivalent. What is the run time of the algorithm? Compute the entire truth table for both of them! There are 2 n entries in the column for nvariables.

Some Familiar Properties of Arithmetic +=+ (Commutativity) + = + (Distributivity) ( ) ( ) + +=+(+) (Associativity) ( )

Understanding Connectives Reflect basic rules of reasoning and logic Allow manipulation of logical formulas Simplification Testing for equivalence Applications Query optimization Search optimization and caching Artificial Intelligence Program verification