Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]

Similar presentations


Presentation on theme: "Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]"— Presentation transcript:

1 Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]

2 Logic (Chapter 1) (chapters 1.1, 1.2) Propositional Logic
Basic Definitions Logical operators Predicate Logic Predicates Quantified expressions

3 A Puzzle In the middle of the journey to a village, you need to select whether to go East or West at a branch. One is the path to hell and the other is to heaven, but you cannot tell which is which. Each villager always tells the truth or always lies and will only give a “Yes” or a “No” response to a question. You are only allowed to ask a villager one question to determine the way to heaven. What to ask? If you can ask two questions, the problem is trivial. Question 1: 4 > 5? Question 2: Is East the way to heaven? Yet you are allowed to ask only one question!

4 Propositions – Definition [O1]
Def: A proposition is a statement that is either true (T) or false (F), but not both. Which of the followings are propositions? 1 + 1 = 7. Do you feel hungry? Hong Kong is the largest city of China. 1 + 3. x + 2. Come here quickly!

5 Compound Proposition A proposition (compound proposition) can be formed by combining several propositions using logical operators. Logical operators:  (negation),  (and),  (or),  (exclusive or),  (implication),  (biconditional) Example: Mr. Wong is stupid and his wife is lazy. p: Mr. Wong is stupid q: his wife is lazy. p  q: where  stands for connective “and” A compound proposition also has a truth value (T or F) depending on the truth values of its constituting propositions and the operator(s).

6 Logical operators And (Conjunction) - Let p and q be two propositions, (p  q) is defined to be true if both p and q are true, and false otherwise. Example: (Today is Friday)  (2 is a factor of 15) ---- False Or (Disjunction) - Let p and q be two propositions, (p  q) is defined to be true if either p or q or both are true, and false otherwise. Exclusive-or - Let p and q be two propositions, then (p  q) is defined to be true if either p or q, but not both, is true, and false otherwise. Not (Negation) - Let p be a proposition, p is defined to be true if p is false. Otherwise p is false.

7 Truth Table p q p  q p  q p  q T F p p T F
Truth table can be used to display the truth values of propositions and is useful in determining the truth values of complicated proposition. Truth Tables for  (negation),  (and),  (or),  (exclusive-or) p q p  q p  q p  q T F All possible cases. How many? p p T F p and q are two propositions

8 Logical operators:  (negation),  (and),  (or),  (exclusive or),  (implication),  (biconditional) The implication pq is the proposition that is false when p is true and q is false, and true otherwise. pq is often read as “p implies q” or “if p, then q” p q pq T F Intuitively, the statement has no problem if the hypothesis p is not true. Example: Let p denote “You get grade A”, q denote “You will receive an iPad”. r denote pq What’s the truth value of r if You do not get grade A, and you receive an iPad You do not get grade A, an you do not receive an iPad You get grade A, and you do not receive an iPad T F

9 “If today is Sunday, then 2+3 = 5” daily usage
Remarks: 1 The mathematical concept of an implication vs daily usage of English “If today is Sunday, then 2+3 = 5” daily usage Assumes a relationship between the hypothesis & conclusion But the implication is true according to the definition. 2 Also, the meaning of the if-then statement is different when used in a program if (x > 3) then y = x; If the value of x is greater than 3, then execute the statement “y = x”

10 The bicondition pq is the proposition that is true both p and q have the same truth values and is false otherwise. pq is often read as “p if and only if q” or “p is necessary and sufficient for q” p q pq T F Remark: pq is true when both pq and qp are true. Example: (X is an even number)  (X+1 is an odd number)

11 p  q (p  q)  (p  q) p  q Exercise:
Let p and q be the propositions. p: It is below freezing q: It is snowing Write the following propositions using p and q and logical connectives (operators). (a) It is below freezing but not snowing. p  q (b) It is either below freezing or it is snowing, but it is not snowing if it is below freezing. (p  q)  (p  q) (c) It is either below freezing or snowing, but not both. p  q

12 Logically equivalence
We say that the two propositions p and q are logically equivalent if pq is always true. We denote this relationship by pq (or p ≡ q). That is, either both are true or both are false. Claim: (p  q)  (p  q) Again, we can prove it using truth table!

13 Some important equivalences
Obvious Rules p  T  p p  F  p p  T  T p  F  F p  p  p p  p  p (p)  p p  q  q  p p  q  q  p Commutative Q: Is addition commutative? (p + q = q + p ?) Q: Is subtraction commutative? (p – q = q – p?) (p  q)  r  p  (q  r) (p  q)  r  p  (q  r) Associative Q: Is multiplication associative? Q: Is division associative? Q: (p  q)  r  p  (q  r) ?? To show that it is not correct: Let p = F, q = F, r = T

14 More…. p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r)
(Distributive Law) (p  q)  p  q (p  q)  p  q (De Morgan’s Law) p  p  T p  p  F (Negation Law) (p  q)  (p  q) (Implication Law)

15 Implication Law & Unless
Let p, q be the propositions: p: You do not finish your homework. q: You get punished. The meaning of pq: If you do not finish your homework, you get punished. The meaning of :pÇq: You finish your homework or you will get punished.

16 Implication Law & Unless
Another way of saying ‘You finish your homework or you get punished.’: You get punished, unless you finish you homework. What do we mean by saying ‘p unless q’: It means p or q.

17 If the correct answer is East: The honest answer is “Yes”.
Question to be asked: If I were to ask you whether East is the way to heaven, would you answer “yes”? [O2] If the correct answer is East: The honest answer is “Yes”. For the dishonest villager, If he is asked “whether East is the way to heaven?” (Q1) What would be his answer? “No” So, if we ask him “If I were to ask you whether East is the way to heaven, would you answer “yes”? Since his own answer to Q1 is “No”, so he lies, and would answer “Yes” to this question. Similarly for the incorrect answer, both will answer “No”.

18 Predicates and Quantifiers
(chapters 1.3, 1.4) [O1 Abstract Concepts]

19 Predicates [O1] Is “x > 3” a proposition?
No, unless the value of x is fixed. Let P(x) denote the statement “x > 3” where P(x) is called a propositional function. P(x) has a truth value once the value of x is fixed. E.g. P(5) is true; P(1) is false. P actually refers to the property “is greater than 3” and is called the predicate. Note that x is a variable (the subject). A propositional function can have more than one variable (multi-value predicates). E.g. Let Q(x, y) denote “x + y > 10”. Then, Q(4, 5) is false; Q(5, 6) is true.

20 Universe of Discourse The collection of values that a variable x may take is called the universe of discourse or domain. Example: “x is rich”, x can refer to people in HK, the world, movies stars, IT people, … For the statement “x is prime”, the universe of discourse of x is the set of all positive integers.

21 Quantification (Quantifiers)
Two ways to convert a propositional function, say P(x), into a proposition. Assign value(s) to variable(s). Quantify variable(s): P(x) is true for all possible values of x (Universal Quantification) These exists at least one value of x such that P(x) is true (Existential Quantification) Example: Let P(x) denote the statement “x has a million dollars”. P(x) has no truth value and is not a proposition. P(John) is a proposition. x P(x) is a proposition. “for all possible values of x (universe of discourse), P(x) is true” e.g. “x P(x)” is false where domain is people in this room.

22 Universal and Existential Quantification
Suppose the universe of discourse (domain) of P(x) is {x1, x2, x3 …} The universal quantification x P(x)  P(x1)  P(x2)  P(x3)  … P(x) is true for all possible values of x The existential quantification x P(x)  P(x1)  P(x2)  P(x3)  … P(x) is true for at least one value of x

23 Example: Let P(x) denote the statement “x is married”. P(x) has no truth value and is not a proposition. P(Peter) is a proposition. x P(x) is a proposition. “there exist an x from the possible values, P(x) is true” e.g. “x P(x)” is true where u.o.d. is the postgrad students in our dept. Examples (the universe of discourse is the set of integers): What is the truth value of the following? x (x2 = x) x (x2 = x) x [y (x+y = x-y)] x [y (x+y = x-y)]

24 Example To express: “Every student in this class is smart.”
“All students in this class are smart.” etc. Let’s make the universe of discourse be the set of all students (including those not in this class). Let P(x) be the statement “x is smart.” Let Q(x) be the statement “x is in the class.” Can you write down the expression? x (Q(x) ∧ P(x)) which means all students are in this class and smart Answer: x (Q(x) P(x))

25 Example To express: “Some students in the this class are smart.”
“At least one student in this class is smart.” “Not all students in this class are stupid” Let P(x) be the statement “x is smart.” Let Q(x) be the statement “x is in the FCS class.” Let’s make the universe of discourse be the set of all students. Can you write down the expression?  x (Q(x)  P(x)) which cannot guarantee at least one student in this class is smart (e.g. there can be no students in this class and there is one student, say Peter, who is not in this class, the statement is still true!). Answer:  x (Q(x) ∧ P(x))

26 Quantifier Equivalences
Suppose the universe of discourse is {x1, x2, x3,…}. x P(x)  P(x1)  P(x2)  P(x3)  … x P(x)  P(x1)  P(x2)  P(x3)  … By the De Morgan’s Law, (p  q)  p  q (p  q)  p  q we can prove that x P(x)  x P(x) x P(x)  x P(x)

27 Compared the previous example with this one.
Let P(x) denote “x is at least 165 cm tall” A(x) denote “x is less than 165 cm tall” Are “x (P(x)  A(x))” and “(x P(x))  (x A(x))” equivalent? No, here is the counterexample. Let the universe of discourse has only “Peter” and “May”. Peter is 170 cm tall, and May is 160 cm tall. P(Peter) is true, but A(Peter) is false; P(May) is false, but A(May) is true; So, “x (P(x)  A(x))” is true but “(x P(x))  (x A(x))” is false

28 Ordering of quantifiers
If x y M(x, y) is true, can we say that y x M(x, y) is also true? If y x M(x, y) is true, can we say that x y M(x, y) is also true? Hint: Suppose x is a key and y is a lock. Let M(x, y) denote the statement “x can open y” Note: Transposing different kinds of quantifiers may have different meanings However, two quantifiers of the same kind can be transposed without changing the meaning of the expression. x y Q(x, y)  y x Q(x, y) x y Q(x, y)  y x Q(x, y) Note that the main differences in the example is that S1=“there exists x, for all y M(x,y)” refers to the same x that can make M(x,y) true for all y. But S2=“for all y, there exists x, M(x, y)” can have different x for different y. is correct: If “there exist x, for all y M(x, y)” is true, then let c in U (universe of discourse) such that M(c, y) is true for all y. Then, for any y, set x = c, M(x, y) must be true, then “for all y, there exists x, M(x,y)” is true. is not correct: The counterexample can be M(x, y) = x likes y U = {A, B, C} and A likes B; B likes C; C likes A, the other M(x, y) are all false. So, S1 is not true, but S2 is true.

29 Some Conventions The universe of discourse may be restricted within the quantification. x > 0 P(x)  x (x > 0  P(x)) [ For all x that are greater than zero, P(x) holds ] x > 0 P(x) x (x > 0  P(x)) [ There is an x greater than zero such that P(x) holds. ] The universe of discourse is restricted from “a set of integers” to “a set of positive integers” Try some exercises on Sec. 1.3, 1.4


Download ppt "Logic Hubert Chan [O1 Abstract Concepts] [O2 Proof Techniques]"

Similar presentations


Ads by Google