Logical Operators Conjunction Disjunction Negation Exclusive Or Implication Biconditional 1
Statement meaning p q p implies q if p, then q if p, q when p, q whenever p, q q if p q when p q whenever p p only if q p is sufficient for q q is necessary for p q follows from p q is implied by p 2
Translate English into logical Expressions You access the ACM library only if you are a CS major and you do not have account holds. a: you access the ACM library c: you are a CS major f: you have account holds a (c f ) 3
Converse, Inverse, Contrapositive For the implication p q The converse is q p The inverse is p q The contrapositive is q p 4
Examples p: you get an A q: you get an xbox q q If you get an A, you will get an xbox The converse q p If you get an xbox, you will get an A The inverse p q If you do not get an A, you do not get an xbox The contrapositive q p If you do not get an xbox, you do not get an A 5
Boolean Operations Summary 6
Logical Equivalence (Textbook 1.3) A tautology is a compound proposition that is true regardless of the truth values of its constituent propositions p V p (what is the truth table?) A contradiction is a compound proposition that is false regardless of the truth values of its constituent propositions p p (what is the truth table?) A contingency is a compound proposition that is neither a tautology nor a contradiction. (p q) r 7
Logical Equivalence When two different compound propositions have the same truth value no matter what truth values their constituent propositions have, they are logically equivalent. p q When the truth table for p and q is the same Or, when p q is a tautology 8
Logical Equivalence Example: Show that the negation of p q is logically equivalent to p q i.e., (p q) (p q ) pt q p q (p q) p q ( (p q)) (p q) T T T F F T T F F T T T F T T F F T F F T F F T 9
Examples De Morgan s Law for Logic 1. (p q) is logically equivalent to p q Proof: p q p q (p q) p q T T T F F T F T F F F T T F F F F F T T 10
Examples De Morgan s Law for Logic 2. (p q) is logically equivalent to p q Proof: p q p q (p q) p q T T T F F T F F T T F T F T T F F F T T 11
More Examples Show that following compound propositions are logically equivalent Check the answer from the textbook 12
Logical equivalence by symbolic derivations Given the known logical equivalences, can we prove new logical equivalences? Without using truth tables Expand implication De Morgan s law Double negation 14
Satisfiability A compound proposition is satisfiable if there exists an assignment of truth values to its variables that makes it true. When no such assignment exists, the proposition in unsatisfiable. The satisfying set of values is called a solution. 15
Example Determine if the following compound proposition is satisfiable or not: You can show this using a truth table Or using logical arguments This proposition is true when at least one is true and at leas one is false This proposition is satisfiable 16
Predicates and Quantifiers Is the following statement a proposition? p: n is an odd integer Predicate p is not a proposition as the truth value of p depends on the value of variable n Statements involving variables are common in computer programs and mathematical proofs. We need to extend the logic to include such statements. 17
Propositional function Let p(x) be a statement involving the variable x. We call p a propositional function; once x is assigned a value, p(x) becomes a proposition. Example assume p(x) denotes the statement x is an odd integer p(3) is a proposition 18
Examples: Propositional functions P:= x is divisible by 8 P(2016) is true P(1876) is false 19
Generalization: functions with more than one variable Q(x,y):= x is divisible by y Q(21,7) is True Why? (because 21 is divisible by 7) Q(49,8) is False Why? (because 49 is not divisible by 8) 20
The Universe of Discourse The collection of values that a variable x can take is called x s universe of discourse or the domain of discourse (often just referred to as the domain) Example P(x) = 10. x > x We need to specify what is the domain of x 21
Quantifiers Many statements in mathematics and computer science use terms like for every and for some. For every triangle T, the sum of the angles of T is equal to 180 o. For some student P, the GPA of P is 4.0 We need to extend the logic system to include such statements. 22
Universal Quantifier The statement for every x, p(x) is said to be a universally quantified statement. Let P(x) := x 2 +2 3x x P(x) Ex: P(x):= x 2 +2 3x x P(x)is true in the universe of integers. x P(x)is false in the universe of rational numbers. 23
Existential Quantifier The statement for some x, p(x) is said to be a existentially quantified statement. The statement is symbolically written as x p(x). The symbol means for some., or there exists a value 24
Example Verify that the universally quantified statement for every real x, x 2 1 > 0 is false. We need to show that for some value of x x 2 1 0 Choose x=1; we get x 2 1 = 0. The statement is false. 25
Existential Quantifier The statement x p(x) is true if the statement p(x) is true for at least one x (in domain D). The statement x p(x) is false if the statement p(x) is false for every x (in D). Example: for some positive integer n, if n is prime, then n+1, n+2, n+3, n+4 are not prime. is an existentially quantified statement (domain is the set of positive integers). The statement is true since there exists an n (e.g., n=23), for which the statement is true. 26
Free and Bound Variables An expression like P(x) is said to have a free variable x (meaning, x is undefined) A quantifier (either or ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more bound variables 27
Example P(x,y) has 2 free variables, x and y xp(x,y) has 1 free variable Which one is bound and which is free xp(x,y) is not a proposition 28
Example Let P(x):= x is a perfect square a perfect square is a number that can be expressed as the product of two numbers x P(x) is true for the natural numbers x P(x) is false for the negative numbers x P(x) is false for the natural numbers 29
Translating English sentences (1) Some student in this class visited Mexico in the summer. (2) Every student in this class visited either Canada or Mexico in the summer. M(x) x visited Mexico in the summer C(x) x visited Canada in the summer (1) x M(x) (2) x (C(x) M(x)) 30
Translating statements into English C(x) x has a computer F(x,y) x and y are friends universe for x and y are all students in a school x (C(x) y (C(y) F(x,y)) For every student x in the school x has a computer or there is a student y such that y has a computer and x and y are friends. More natural: Every student has a computer or has a friend who has a computer. 31
Negating Quantified Expressions Generalized De Morgan s Laws x P(x) x P(x) x P(x) x P(x) Let P(x):= x puts Baby in a corner x P(x) means somebody puts baby in a corner x P(x) means x P(x) 32 everyone does not put baby in a corner nobody puts baby in a corner. Remember: (p q) is equiv. to p q and (p q) is equiv. to p q
Negating Quantified Expressions Generalized De Morgan s Laws Remember that Using De Morgan s Laws 33
Example 34
Nested Quantifiers Textbook 1.5 Nested quantifiers are quantifiers that occur within the scope of other quantifiers The order of the quantifiers is important, Except for the following all the quantifiers are universal or the quantifiers are existential 35
Nested Quantifiers 36
Example Expressing Uniqueness Each person s program is unique. Let the universe of discourse be people Let E(x,y) := the program of person x is the same as that of person y x y (x y) E(x,y) x y E(x,y) (x=y) 37
Order of Quantifiers Let C(x,y):= program x crashes on input y Let L(x,y):= program x loops forever on input y Universe for x is programs Universe for y is inputs There is an input that causes every program to crash or loop forever Every program has some input on which it either crashes or loops forever Some programs loop forever or crash on every input 38
Order of Quantifiers There is an input that causes every program to crash or loop forever Since it s not possible to both crash and loop forever, the OR is really XOR y x C(x,y) L(x,y) Every program has some input on which it either crashes or loops forever x y C(x,y) L(x,y) 39
Order of Quantifiers Some programs loop forever or crash on every input This is not the same as the previous example. x y C(x,y) L(x,y) 40
Negating Nested Quantifiers Successively apply the rules for negating statements involving a single quantifier Example someone has taken a flight on every airline in the world Represent it Negate it Back to English 41
Negating Nested Quantifiers someone has taken a flight on every airline in the world Represent it P(x,f):= person x has taken flight f Q(f,a):= f is a flight on airline a p a f P(p,f) Q(f,a)
Negating Nested Quantifiers someone has taken a flight on every airline in the world negate it p a f P(p,f) Q(f,a) p a f P(p,f) Q(f,a) p a f P(p,f) Q(f,a) p a f (P(p,f) Q(f,a)) p a f P(p,f) Q(f,a) p a f P(p,f) Q(f,a)
Negating Nested Quantifiers someone has taken a flight on every airline in the world Back to English For every person, there exists an airline such that for every flight either that person has not taken the flight or the flight is not on the airline. For every person, there exists an airline such that for every flight, if the person has taken the flight, then the flight is not on that airline For every person there exists an airline on which they ve never taken any flight