Boolean Logic. CS 231 Dianna Xu

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

CSC Discrete Math I, Spring Propositional Logic

UNIT-I: Propositional Logic

Compound Propositions

Definition 2. Conjunction of p and q

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

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

EECS 1028 M: Discrete Mathematics for Engineers

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

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

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

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

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

2.2: Logical Equivalence: The Laws of Logic

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

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

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

LOGIC & PROPOSITIONAL EQUIVALENCE

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Chapter 1, Section 1.1 Propositional Logic

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

Propositional logic ( ): Review from Mat 1348

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

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

Propositional Equivalence

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

Propositional Logic 1

Discrete Structures for Computer Science

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

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

Mathematical Logic Part One

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

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

We last time we began introducing equivalency laws.

AMTH140 Lecture 8. Symbolic Logic

Propositional Logic. Spring Propositional Logic Spring / 32

Sec$on Summary. Propositions Connectives. Truth Tables. Negation Conjunction Disjunction Implication; contrapositive, inverse, converse Biconditional

Discrete Mathematics and Applications COT3100

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

CSE 20 DISCRETE MATH. Fall

1 Propositional Logic

CSE 240 Logic and Discrete Mathematics

PROPOSITIONAL CALCULUS

Math.3336: Discrete Mathematics. Applications of Propositional Logic

Mathematical Logic Part One

Introduction to Decision Sciences Lecture 2

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

Section 1.1: Logical Form and Logical Equivalence

Today s Topic: Propositional Logic

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

It is not the case that ϕ. p = It is not the case that it is snowing = It is not. r = It is not the case that Mary will go to the party =

Logic and Truth Tables

TRUTH TABLES LOGIC (CONTINUED) Philosophical Methods

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

Equivalence and Implication

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

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Mathematical Logic Part One

CS 220: Discrete Structures and their Applications. Propositional Logic Sections in zybooks

KP/Worksheets: Propositional Logic, Boolean Algebra and Computer Hardware Page 1 of 8

Chapter 4, Logic using Propositional Calculus Handout

CISC-102 Winter 2016 Lecture 17

Propositional Languages

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

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.

Packet #1: Logic & Proofs. Applied Discrete Mathematics

1.3 Propositional Equivalences

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

Discrete Mathematics

1.1 Language and Logic

The Foundations: Logic and Proofs. Part I

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

2/18/14. What is logic? Proposi0onal Logic. Logic? Propositional Logic, Truth Tables, and Predicate Logic (Rosen, Sections 1.1, 1.2, 1.

ARTIFICIAL INTELLIGENCE

Math.3336: Discrete Mathematics. Propositional Equivalences

Introduction to Sets and Logic (MATH 1190)

Tools for reasoning: Logic. Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic: Implications:

Logic and Propositional Calculus

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

Discrete Mathematics and Its Applications

Learning Goals of CS245 Logic and Computation

LOGIC CONNECTIVES. Students who have an ACT score of at least 30 OR a GPA of at least 3.5 can receive a college scholarship.

Truth-Functional Logic

1.1 Statements and Compound Statements

Propositions. Frequently, we will use the word statement instead of proposition.

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

Logic and Proofs. (A brief summary)

Solutions to Homework I (1.1)

CSC165 Mathematical Expression and Reasoning for Computer Science

THE LOGIC OF COMPOUND STATEMENTS

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.

Propositional natural deduction

DERIVATIONS AND TRUTH TABLES

Propositional logic (revision) & semantic entailment. p. 1/34

The Logic of Compound Statements cont.

Mat 243 Exam 1 Review

1.1 Language and Logic

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

ICS141: Discrete Mathematics for Computer Science I

1 The Foundation: Logic and Proofs

Transcription:

Boolean Logic CS 231 Dianna Xu 1

Proposition/Statement A proposition is either true or false but not both The sky is blue Lisa is a Math major x == y Not propositions: Are you Bob? x := 7 2

Boolean variables We use Boolean variables to refer to propositions Usually denoted with lower case letters starting with p (i.e. p, q, r, s, etc.) A Boolean variable can have one of two values true (T) or false (F) A proposition can be A single variable: p A compound statement: pù(qú~r) 3

Introduction to Logical Operators About a dozen logical operators Similar to algebraic operators + * - / In the following examples, p = It is Tuesday q = It is 9/3 4

Logical operators: Not Negation Not switches (negates) the truth value Symbol: ~ or In C/C++ and Java, the operand is! p ~p T F F T ~p = It is not Tuesday 5

Logical operators: And Conjunction And is true if both operands are true Symbol: Ù In C/C++ and Java, the operand is && pùq = It is Tuesday and it is 9/3 p q pùq T T T T F F F T F F F F 6

Logical operators: Or Disjunction Or is true if either operands is true Symbol: Ú In C/C++ and Java, the operand is púq = It is Tuesday or it is 9/3 (or both) p q púq T T T T F T F T T F F F 7

Logical operators: Exclusive Or Exclusive Or is true if one of the operands are true, but false if both are true Symbol: Å Often called XOR påq º (p Ú q) Ù ~(p Ù q) In Java, the operand is ^ (but not in C/C++) påq = It is Tuesday or it is 9/3, but not both p q påq T T F T F T F T T F F F 8

Inclusive Or versus Exclusive Or Do these sentences mean inclusive or exclusive or? Experience with C++ or Java is required Lunch includes soup or salad To enter the country, you need a passport or a driver s license Publish or perish 9

Logical Equivalence Two statements are logically equivalent if and only if they have identical truth values for all possible substitutions of statement variables p q 10

Conditional A conditional means if p then q or p implies q Symbol: p q = If it is Tuesday, then it is 9/3 p q º ~p v q p q p q ~p v q T T T T T F F F F T T T F F T T the antecedent the consequent 11

Conditional 2 Let p = I am elected and q = I will lower taxes p q = If I am elected, then I will lower taxes The statement doesn t say anything about ~p If ~p, then the conditional is true regardless of whether q is true or false p q p q T T T T F F F T T F F T 12

Conditional 3 Conditional Inverse Converse Contrapositive p q ~p ~q p q ~p ~q q p ~q ~p T T F F T T 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 The conditional and its contra-positive are equivalent So are the inverse and converse 13

Logical operators: Conditional 4 Alternate ways of stating a conditional: p implies q If p, q p is sufficient for q q if p q whenever p q is necessary for p (if ~q then ~p) p only if q 14

Bi-conditional A bi-conditional means p if and only if q Symbol: «Alternatively, it means (if p then q) and (if q then p) p«q º p q Ù q p Note that a bi-conditional has the opposite truth values of the exclusive or p q p«q T T T T F F F T F F F T 15

Bi-conditional Let p = You get a grade and q = You take this class Then p«q means p q p«q You get a grade if and T T T only if you take this class T F F F T F Alternatively, it means If you get a grade, then F F T you took (take) this class and if you take (took) this class then you get a grade 16

Boolean operators summary not not and or xor conditional biconditional p q ~p ~q pùq púq påq p q p«q T T F F T T F T T T F F T F T T F F F T T F F T T T F F F T T F F F T T Learn what they mean, don t just memorize the table! 17

Precedence of operators Precedence order (from highest to lowest): ~ Ù Ú The first three are the most important Not is always performed before any other operation 18

Translating English Sentences Problem: p = It is below freezing q = It is snowing It is below freezing and it is snowing pùq It is below freezing but not snowing pù~q It is not below freezing and it is not snowing ~pù~q It is snowing or below freezing (or both) púq If it is below freezing, it is also snowing p q It is either below freezing or it is snowing, (púq)ù(p ~q) but it is not snowing if it is below freezing That it is below freezing is necessary and p q sufficient for it to be snowing 19

Tautology and Contradiction A tautology t is a statement that is always true p Ú ~p will always be true (Negation Law) A contradiction c is a statement that is always false p Ù ~p will always be false (Negation Law) p p Ú ~p p Ù ~p T T F F T F 20

DeMorgan s Law Probably the most important logical equivalence To negate pùq (or púq), you flip the sign, and negate BOTH p and q Thus, ~(p Ù q) ~p Ú ~q Thus, ~(p Ú q) ~p Ù ~q p q ~p ~q pùq ~(pùq) ~pú~q púq ~(púq) ~pù~q T T F F T F F T F F T F F T F T T T F F F T T F F T T T F F F F T T F T T F T T 21

Logical Equivalences Communicative p Ù q q Ù p p Ú q q Ú p Associative (pùq)ùr pù(qùr) (púq)úr pú(qúr) Distributive pù(qúr) (pùq)ú(pùr) pú(qùr) (púq)ù(púr) Identity p Ù t p p Ú c p Negation p Ú ~p t p Ù ~p c Double Negative ~(~p) p Idempotent p Ù p p p Ú p p Universal bound p Ù c c p Ú t t De Morgan s ~(p Ù q) ~p Ú ~q ~(p Ú q) ~p Ù ~q Absorption p Ú (p Ù q) p p Ù (p Ú q) p Negation of t and c ~t c ~c t

How to prove two propositions Two methods: Using truth tables are equivalent? Not good for long formulae Should not be your first method to prove logical equivalence! Using the logical equivalences and laws The preferred method Example: show that: ( p r) Ú ( q r) º ( p Ù q) r 23

Using Truth Tables ( p r) Ú ( q r) º ( p Ù q) r p q r p r q r (p r)ú(q r) pùq (pùq) r T T T T T T T T T T F F F F T F T F T T T T F T T F F F T T F T F T T T T T F T F T F T F T F T F F T T T T F T F F F T T T F T 24

Using Logical Equivalences ( p r) Ú ( q r) º ( p Ù q) r Original statement (~ p r) (~ q r) ~ (p q) r Definition of implication (~ p r) (~ q r) (~ p ~ q) r ~ p r ~ q r ~ p ~ q r ~ p ~ q r r ~ p ~ q r ~ p ~ q r ~ p ~ q r DeMorgan s Law Associativity of Or Re-arranging Idempotent Law 25