Upcoming SlideShare
×

# Lecture 2 predicates quantifiers and rules of inference

5,490 views
5,198 views

Published on

2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Please include option to view this offline also.

Are you sure you want to  Yes  No
• can you share all the lectures of this course?

Are you sure you want to  Yes  No
Views
Total views
5,490
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
147
2
Likes
2
Embeds 0
No embeds

No notes for slide

### Lecture 2 predicates quantifiers and rules of inference

1. 1. Lecture by Prof. Dr. Nasir TauheedDepartment of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 2Predicates & QuantifiersStatements involving variables, such as“x > 3,” “x = y + 3,” and “x + y = z,” are often found in mathematicalassertions and in computer programs. These statements are neither true notfalse when the values of the variables are not specified. In this section we willdiscuss the ways that propositions can be produced from such statements.The statement “x is greater than 3” has two parts: • The first part, the variable “x” is the subject of the statement. • The second part the – predicate, “is greater than 3” – refers to a property that the subject of the statement can have.We can denote the statement “x is greater than 3” by P(x), where P denotesthe predicate “is greater than 3” and x is the variable. The statement P(x) isalso said to be the value of the proposition function P at x. Once a value hasbeen assigned to the variable x, the statement P(x) becomes a proposition andhas a truth value.Example 1: Let P(x) denote the statement “x > 3”. ThenP(4) : 4 > 3 is true, but P(2) : 2 > 3 is false.Replacing x by the value of 4 (or by 2) is a way to quantify the propositional functionP(x). Quantify means to make it true or false.Predicates become propositions once every variable is bound- by assigning ita value from the Universe of Discourse U or quantifying it. (The collection ofvalues that a variable x can take is called x’s Universe of Discourse.)Example 2:Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, 3, . . .}P(x): x > 0 is the predicate. It has no truth value until the variable x is bound. Examples of propositions where x is assigned a value: P(-3) is false, P(0) is false, P(3) is true.The collection of integers for which P(x) is true are the positive integers.P(y) ∨ ¬P(0) is not a proposition. The variable y has not been bound.However, P(3) ∨ ¬P(0) is a proposition which is true.Week 2 Page 1
2. 2. Predicate logic generalizes the grammatical notion of a predicate to alsoinclude propositional functions of any number of arguments, each of whichmay take any grammatical role that a noun can take.Example 3:Let P(x,y,z) = “x gave y the grade z”, then if x=“Mike”, y=“Mary”, z=“A”, then P(x,y,z) = “Mike gave Mary the grade A.”Exercise 4:Let R be the three-variable predicate R(x, y z): x + y = zFind the truth values of R(2, -1, 5), R(3, 4, 7), R(x, 3, z).Quantifiers Let’s say you have a predicate like P(x) and you want to apply a statement for all possible values of x. You can use quantifiers to do this. The notation ∀ x P(x) shows the universal quantification of P(x), with the upside-down A as the universal qualifier. – It says, FOR ALL x P(x) or FOR EVERY x P(x)Example 5:Let the u.d. of x be parking spaces at DCS. Let P(x) be the predicate “x isfull.”Then the universal quantification of P(x), ∀x P(x), is the proposition: – “All parking spaces at DCS are full.” – i.e., “Every parking space at DCS is full.” – i.e., “For each parking space at DCS, that space is full.”The power of distinguishing objects from predicates is that it lets you statethings about many objects at once. • E.g., let P(x) = “x+1>x”. We can then say, “For any number x, P(x) is true” instead of (0+1>0) ∧ (1+1>1) ∧ (2+1>2) ∧ ...Existential Quantifier of a proposition: there exists an element x in theuniverse of discourse such that P(x) is true – That is, there is AN x, or at least ONE x, such that P(x) is true – In this case, one would use the backwards E to denote this type quantifier rather than the all inclusive upside down A:Week 2 Page 2
3. 3. ∃ x P(x) For example, if P(x) was the statement x > 89, and your data set included test scores of 65, 72, 85, 88, and 95 what would be the existential quantification of P(x)? – TRUE!Example 6: Let the u.d. of x be parking spaces at DCS. Let P(x) be thepredicate “x is full.”Then the existential quantification of P(x), ∃x P(x), is the proposition: – “Some parking space at DCS is full.” – “There is a parking space at DCS that is full.” – “At least one parking space at DCS is full.” QuantifiersStatement When is it True? When is it False? P(x) is true for every x. There is an x for which P(x) is false. There is an x for which P(x) is P(x) is false for every x. true.Practical use of Quantifiers: – In programming, at times you will create looping mechanisms to test every instance of your data (the scores for every student taking an exam, for instance) – You would inadvertently be using some aspect of universal or even existential quantification to test your data – Hence, this aspect of discrete math is a way of thinking about, or mapping out, what a programmer would have to construct to meet the needs of a customer.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.Example of Binding • P(x,y) has 2 free variables, x and y. • ∃x P(x,y) has 1 free variable, and one bound variable. [Which is which? y is a free variable and x is bound (by the existential quantification ∃x).] • “P(x), where x=3” is another way to bind x.Week 2 Page 3
4. 4. • An expression with zero free variables is a bona-fide (actual) proposition. • An expression with one or more free variables is still only a predicate: ∀x P(x,y).REMEMBER! A predicate is not a proposition until all variables have beenbound either by quantification or assignment of a value!Equivalences involving the negation operator ¬∀x P(x) ⇔ ∃x ¬P(x) ¬∃x P(x) ⇔ ∀x ¬P(x)Distributing a negation operator across a quantifier changes a universal to anexistential and vice versa. ¬∀x P(x) ⇔ ¬(P(x1) ∧ P(x2) ∧ … ∧ P(xn)) ⇔ ¬P(x1) ∨ ¬P(x2) ∨ ¬ … ∨ ¬ P(xn) ⇔ ∃x ¬P(x)Multiple Quantifiers: read left to right . . .Nesting of QuantifiersExample: Let the u.d. of x & y be people.Let L(x,y) = “x likes y” (a predicate with 2 f.v.’s).Then ∃y L(x,y) = “There is someone whom x likes.” (A predicate with 1 freevariable, x.)Then ∀x (∃y L(x,y)) = “Everyone has someone whom they like.”(A proposition with 0 free variables.)Quantifier ExerciseIf R(x,y)=“x relies upon y,” express the following in unambiguous English: ∀x(∃y R(x,y)) = Everyone has someone to rely on. ∃y(∀x R(x,y)) = There’s a poor overburdened soul whom everyone relies upon (including himself)! ∃x(∀y R(x,y)) = There’s some needy person who relies upon everybody (including himself). ∀y(∃x R(x,y)) = Everyone has someone who relies upon them. ∀x(∀y R(x,y)) = Everyone relies upon everybody, (including themselves)!Example: Let U = R, the real numbers,Week 2 Page 4
5. 5. P(x,y): xy= 0 ∀x ∀y P(x, y) ∀x ∃y P(x, y) ∃x ∀y P(x, y) ∃x ∃y P(x, y) The only one that is false is the first one.What’s about the case when P(x,y) is the predicate x/y=1?Example: Let U = {1, 2, 3}. Find an expression equivalent to ∀x ∃y P(x, y)where the variables are bound by substitution instead:Expand from inside out or outside in. Outside in: ∃y P(1, y) ∧ ∃y P(2, y) ∧ ∃y P(3, y) ⇔ [P(1,1) ∨ P(1,2) ∨ P(1,3)] ∧ [P(2,1) ∨ P(2,2) ∨ P(2,3)] ∧ [P(3,1) ∨ P(3,2) ∨ P(3,3)]As you can see, with just these two quantifiers we can put together even morecomplex statements. Many theorems, results, etc. in mathematics are typicallyrepresented using quantifiers. For example, we know that all positive integershave at least one prime factor that is less than or equal to the number itself.Mathematically speaking, we can use our statement q(x,y) from before toexpress this result.q(x,y): x is a prime number that divides into y evenly AND is less than orequal to y. ∀y∃x [q(x,y)]Literally, this reads: “For all values y, there exists a value for x for which x isa prime number that divides into y evenly AND is less than or equal to y.”A very important distinction to make here is the order of the quantifiers. Thestatement ∃x∀y [q(x,y)] for example is NOT true.This literally reads: “There exists a value of x for which for all values of y, xis a prime number that divides into y evenly AND is less than or equal to y.”The reason this is not true is because no matter what value you try to pick forx, you can ALWAYS find a value for y such that x DOES NOT divide y.Perhaps, some practice evaluating these statements might help. Consider thesesimple open statements:Week 2 Page 5
6. 6. p(x): x > 0 q(x): x2 – 2x – 3 = 0 r(x): x < 0 s(x): x2 > 0Decide whether each of these assertions is true or not: 1) ∃x [p(x) ∧ q(x)] 2) ∀x [p(x) ∧ r(x) → s(x)] 3) ∀x [r(x) → ¬q(x)]Now, take these assertions and put them into symbolic form:1) For all values of x less than 0, x2 is greater than 0.2) There exists a value of x for which if x2 – 2x – 3 = 0 then x is greater than 0.3) For all values of x such that x2 – 2x – 3 = 0, x < 0. A little chart to keep all of this straight Statement When True When False∃x p(x) For at least one value a in the For all values a in the universe for x, p(a) is true. universe for x, p(a) is false.∀x p(x) For all values a in the For at least one value a in the universe for x, p(a) is true. universe for x, p(a) is false.∃x [¬p(x)] For at least one value a in the For all values a in the universe for x, p(a) is false. universe for x, p(a) is true.∀x [¬p(x)] For all values a in the For at least one value a in the universe for x, p(a) is false. universe for x, p(a) is true.Given a statement ∀x [p(x) → q(x)], here are other related statements: 1) Contrapositive: ∀x [¬q(x) → ¬p(x)] 2) Converse: ∀x [q(x) → p(x)] 3) Inverse: ∀x [¬p(x) → ¬q(x)]As we have mentioned before, if the given statement is true, then thecontrapositive MUST BE true. However, neither the converse nor the inverseare necessarily true.However, if both the given statement AND the converse are true, we have andif and only if relationship. Similarly, if both the given statement and theinverse are true, we also have and if and only if (i.e. equivalence) relationship.A couple more rules that follow...So now, consider each of these implications:Week 2 Page 6
7. 7. 1) ∃x [p(x) ∧ q(x)] [∃x p(x) ∧ ∃x q(x)] 2) ∃x [p(x) ∨ q(x)] ⇔ [∃x p(x) ∨ ∃x q(x)] 3) ∀x [p(x) ∧ q(x)] ⇔ [∀x p(x) ∧ ∀x q(x)] 4) [∀x p(x) ∨ ∀x q(x)] ∀x [p(x) ∨ q(x)]An important observation is that the first and fourth rules only go one way.Can you think of some counter examples to these rules?Here are a couple of mine:For number 1, let statement p(x) = “x is greater than 100.” q(x) = “x is less than 0.”Certainly, ∃x p(x), also we have ∃x q(x). This is because there exists an xgreater than 100, namely 101. But there also exists an x less than 0, namely –1.BUT, it is NOT true that ∃x [p(x) ∧ q(x)]. If this were the case, then we couldfind a single value of x for which BOTH p(x) AND q(x) hold. But, clearlythey are contradictory statements and this can not happen.A counter example to the converse of rule number 4 is the following:Let p(x) = “x is an even integer.” q(x) = “x is an odd integer.”Clearly, for all integers x, we have either p(x) or q(x). BUT, it is not true that∀x p(x) and it is also not true that ∀x q(x). The reason neither of these is trueis because all integers are not odd, and all integers are not even either.Other practice problemsFirst translate these assertions into English. Then deduce, with proof, whetherthey are valid or not. To show an assertion to be invalid, merely present acounter example. To prove it, you must show that the statement holds for allthe values it says it will hold. 1. ∀y∃x [y = 2x ∧ x∈Z ∧ y∈Z] 2. ∃x∀y [y/x < |y| ∧ x∈Z ∧ y∈Z] 3. ∃x∃y [x/y = y/x ∧ x∈Z ∧ y∈Z]Week 2 Page 7
8. 8. Practical Applications • Basis for clearly expressed formal specifications for any complex system. • Basis for automatic theorem provers and many other Artificial Intelligence systems. • Supported by some of the more sophisticated database query engines and container class libraries (these are types of programming tools).Methods of ProofIntroductionIn mathematics we make assertions about a system whether it be a numbersystem or something more abstract such as a group or linear space. Anassertion not known to be true or false is called a hypothesis or conjecture.Prior to 1995, a famous conjecture was Fermat Last Theorem. It stated that sfor an integer n ≥ 3 there are no positive integer solutions to the equation xn +yn = zn . The process of establishing the truth of an assertion is called a proof.Once a conjecture has been shown to be a true statement we label it as alemma, theorem or corollary. We think of a lemma as a result which is usedprimarily to prove a more important result (i.e. a theorem), and a corollary asa special case or consequence of a theorem. For example in calculus, we couldthink of Maclaurin Theorem as a corollary to Taylor Theorem. s sIn these notes we are concerned with techniques that may be used to prove aresult and provide a tonic to the student malady on proofs namely ``I don s tknow where to start It is probably impossible to teach how to prove .something and the best one can offer is a catalog of types of proof along withexamples. By reading proofs, the student can often gain insight as to how toprove their own particular result. Once they have gained some experience,they might then be ready for more complicated proofs. What is certain is thatthere is no cook book solution to obtaining a proof. We recommend that youread the notes on logic before proceeding.Rules of inference • Patterns of logically valid deductions from hypotheses to conclusionsFor this part of the Logic we will follow the notes written by StefanWaner and Steven R. Costenoble.Week 2 Page 8
9. 9. Inference Rules - General Form • Inference Rule – – Pattern establishing that if we know that a set of antecedent statements of certain forms are all true, then a certain related consequent statement is true.antecedent 1antecedent 2 …∴ consequent “∴” means “therefore”Inference Rules & Implications • Each logical inference rule corresponds to an implication that is a tautology. • antecedent 1 Inference rule antecedent 2 … ∴ consequent • Corresponding tautology:((antecedent 1) ∧ (antecedent 2) ∧ …) → consequentSome Inference Rules p Rule of Addition ________ ∴ p∨q p∧q Rule of Simplification ________ ∴p p Rule of Conjunction q ________ ∴ p∧qModus Ponens & TollensWeek 2 Page 9
10. 10. p Rule of modus ponens p→q (a.k.a. law of detachment) ∴q (“the mode of affirming”) ¬q p→q Rule of modus tollens ∴¬p (“the mode of denying”)Syllogism Inference Rules p→q Rule of hypothetical q→r syllogism ________ ∴p→r p∨q Rule of disjunctive ¬p syllogism ________ ∴qFormal Proofs • A formal proof of a conclusion C, given premises p1, p2,…,pn consists of a sequence of steps, each of which applies some inference rule to premises or to previously-proven statements (as antecedents) to yield a new true statement (the consequent). • A proof demonstrates that if the premises are true, then the conclusion is true.Formal Proof Example • Suppose we have the following premises: “It is not sunny and it is cold.” “We will swim only if it is sunny.” “If we do not swim, then we will canoe.” “If we canoe, then we will be home early.” • Given these premises, prove the theorem “We will be home early” using inference rules. • Let us adopt the following abbreviations:Week 2 Page 10
11. 11. • sunny = “It is sunny”; cold = “It is cold”; swim = “We will swim”; canoe = “We will canoe”; early = “We will be home early”. • Then, the premises can be written as: (1) ¬sunny ∧ cold (2) swim → sunny (3) ¬swim → canoe (4) canoe → earlyStep Proved by1. ¬sunny ∧ cold Premise #1.2. ¬sunny Simplification of 1.3. swim→sunny Premise #2.4. ¬swim Modus tollens on 2, 3.5. ¬swim→canoe Premise #3.6. canoe Modus ponens on 4, 5.7. canoe→early Premise #4.8. early Modus ponens on 6, 7.Definitions and TheoremsIn many math text books you will see definitions and theorems. The definitions are defining technicalwords and give a name to a special subclass of objects. For example, when we study the integers wehave a special subset of positive integers greater than 1 which are called primes. In calculus we dealmainly with continuous functions or differentiable functions which are special subsets of functions.Quite often it is these definitions that lead to proofs of elementary results. In understandingmathematics, it is important to have a solid grasp of these definitions. Without that, comprehending atheorem is limited and attempting to prove a theorem is useless. Definitions have the form ``X is a blobif and only if condition This biconditional form is used in two ways. First, suppose we have an object .Y and want to know if it is a blob. We see if Y satisfies the condition. If it does then Y is a blob,otherwise it is not. Secondly, suppose we have an object Y that is a blob. Then we know that Y doessatisfy the condition and may make use of this fact, in a proof say.The majority of theorem statements have two forms. The first is a conditional statement ``If conditionthen conclusion This form is an implication and it means that the conclusion is true whenever the .condition is true. If the condition is denoted by p and the conclusion by q then the statement of thetheorem is written as . Consequently, if and only if the logical statement is atautology. Often you will see the phrase ``For allin statements of theorems. A statement such as ``For all x in X, conclusionis really a conditional form ``If x is an element of X then conclusion It happens .to be true no matter which element x we consider.The second common form of a theorem statement is the biconditional. This has the form ``p if and onlyif qor symbollically . It is equivalent to the two implications and . Indeed, this ishow many of these theorems are proved (by proving the two implications). Logically, if and onlyif is a tautology.Week 2 Page 11
12. 12. One important aspect of statements is that they do have equivalent forms. Often, it might be difficult toprove a result as it is stated but it could be easier to prove an equivalent statement. The following tablegives a list of common equivalent forms.We also list some of the English equivalents of the conditional.Other phrases that appear in theorems are ``There existsand ``unique A theorem statement such as .``There exists an x in X such that conclusion is know as an existence theorem. It says that the conclusion statement is satsfied by something (or the truth set is non empty). However, the conclusionmay be satisfied by many elements of the set. If there is precisely one element of the set that satisfies theconclusion then the theorem statement would state ``There exists a unique x in X such that conclusion .Such theorems are referred to as uniqeness theorems. Our previous statement is an existence anduniqeness theorem. It is possible to have a theorem which asserts uniqeness but not existence.Disproving StatementsSome conjectures are false. Verifying that a conjecture is false is often easier than proving a conjectureis true. Despite that, showing a conjecture is false may have its own challenges and usually requires adeep knowledge of the subject.Some statements are often shown to be false by a counter examples. Such statements have the form``For all x in X conclusion This is shown to be false by finding one element of X which does not satisfy .the conclusion. As an example, consider the statement ``For all prime numbers p, 2p+1 is prime This .statement is true for the primes 2, 3 and 5. It is also true for the primes 11 and 23. However, thestatement is an assertion for all primes. Clearly the statement is not true for the prime 7 (since 15 = 3 5)and we have obtained a counter example to the statement.For finite sets, statements of the form such as ``There exists an x such that conclusioncan be refuted by example. By testing each element of the set and showing no element satisfies the conclusion we haveshown the statement is false through an exhaustive search. This would also refute the statement ``Thereexists a unique x such that conclusion However, a statement of this form might be false for another .Week 2 Page 12
13. 13. reason, namely that there are two or more elements of the set that satisfy the conclusion. Again, thisstatement could be refuted through a counter example. For example consider the statement ``Theequation has a unique solution This statement is false in the integers since both 1 and -1 satisfy .the equation and we have disproved it using a counter example. Note that the statement is true in thepositive integers.As we noted above, some statements remain conjectures for many years (or even centuries) due to thefact that a proof cannot be constructed (or discovered) or that a counter example cannot be found. Thereare many famous conjectures and famous theorems that were conjectures for many years (The 4 colortheorem and Fermat Last Theorem, for example). sTypes of ProofWe discuss some approaches to proofs in this section. We focus our attention on proof by mathematicalinduction, direct proofs, and indirect proofs (by contrapositive, equivalence and proofs usingcontradiction). We assume that the theorem statement is a conditional form ( ) since thebiconditional form is equivalent to two conditional implications. • Direct Proofs • Proof by Contradiction and Reductio ad Absurdum • The Contrapositive and Equivalent Forms • Existence Proofs • Uniqueness Proofs • Mathematical InductionDirect ProofsIn a direct proof of the statement we employ the transitive nature of implication. That is to saythat if and then it follows that . To start off the proof we assume that p is a truestatement. From this we deduce an implied statement . From we deduce an implied statement andso on until we obtain an implication . Using the transitive property of implication we thendeduce the validity of the theorem statement. The idea is very simple but the problem is what are theseimplied statements ? These are results in their own right and may be obtained from othertheorems, corollaries or lemmas. In other words, they are known true statements. Alternatively, theymay be obtained from definitions. Undoubtedly, then, we have to know some of the implications of thestatement . In other words, what does a given piece of information tell us. The bad news is that a givenstatement might make us think of several consequences and only a few of those facts might be used inthe proof. The worst case is that a given statement means absolutely nothing. So the difficulty in a directproof is finding these connections between certain facts. For example, suppose we know that x is aprime number. What does that tell us? Here are some possible connections. • Only positive divisors are 1 and itself • If x is not two then it is an odd integer • If x is odd then it is of the form 4k+1 or 4k-1 for some integer k.Essentially we need to build in our memory a list of facts and implications. This comes down to knowing as muchinformation as possible. One might compare a direct proof to crossing a river using stepping stones. Standing on the riverbank is knowing the statement p. Getting across the river is deducing the statement q. The stepping stones are theintermediate statements each of which is a consequence of the other. From each stone, you may have a choice of severalstones to reach next and you have to decide which one is best for you. The worst scenario is to have no stones on which tostep!Week 2 Page 13