Download presentation
Presentation is loading. Please wait.
1
CSI 2101 / Predicate logic (§1.3-1.4):
Motivation Predicates Quantifiers universal quantifier, existential quantifier, other quantifiers domain of a quantifier binding variable by a quantifier Quantified expressions equivalence of quantified expressions negating quantified expressions translating into/from English nested quantifiers order of quantifiers Dr. Nejib Zaguia - Winter 2008
2
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Motivation Predicate logic is an extension of propositional logic that permits concisely reasoning about whole classes of entities. Propositional logic (recall) treats simple propositions (sentences) as atomic entities. In contrast, predicate logic distinguishes the subject of a sentence from its predicate. Dr. Nejib Zaguia - Winter 2008
3
Applications of Predicate Logic
Topic #3 – Predicate Logic Applications of Predicate Logic It is the formal notation for writing perfectly clear, concise, and unambiguous mathematical definitions, axioms, and theorems (more on subsequent lectures) for any branch of mathematics. Predicate logic with function symbols, the “=” operator, and a few proof-building rules is sufficient for defining any conceivable mathematical system, and for proving anything that can be proved within that system! Dr. Nejib Zaguia - Winter 2008
4
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Other Applications Predicate logic is the foundation of the field of mathematical logic, which culminated in Gödel’s incompleteness theorem, which revealed the ultimate limits of mathematical thought: Given any finitely describable, consistent proof procedure, there will always remain some true statements that will never be proven by that procedure. I.e., we can’t discover all mathematical truths, unless we sometimes resort to making guesses. Kurt Gödel A note on pronunciation: The guy’s name is Austrian. The o with the double dot over it is called an “o umlaut.” It is also sometimes written “oe” in languages without umlauts, thus, “Goedel” is also a correct way to write his name in English. An o umlaut is pronounced something between “uh” and “ur”. So, “Goedel” is pronounced something like “girdle.” One way of saying Godel’s theorem is that there are infinitely many finite mathematical statements that are true, but that are not provable from earlier statements by any finite argument following a fixed set of logical inference rules. Thus, the only way to really expand the scope of mathematics is to make guesses (through intuition or inspiration) about additional statements being true (or equivalently, additional inference rules being valid). When one makes such guesses, since they have not been proven, one should always keep in mind the possibility that they may be false (inconsistent with earlier statements), and thus may eventually be disproven. Thus, in general, we can never really know whether a given mathematical system we are using is really logically self-consistent. (Except for some very simple systems of limited power can be proven to be consistent.) Later, we will see that the mathematical world was badly shaken up when it was discovered that the simple form of set theory that everyone had been using was actually logically inconsistent! To restore consistency, the theory had to be modified, and the new set theory is self-consistent, as far as anyone knows. Goedel was also a close colleague and friend of Albert Einstein, and he discovered (among other things) that Einstein’s theory of General Relativity (the modern theory of gravity) had some theoretical solutions in which time travel into the past was possible! Dr. Nejib Zaguia - Winter 2008
5
Practical Applications of Predicate Logic
Topic #3 – Predicate Logic Practical Applications of Predicate Logic It is the basis for clearly expressed formal specifications for any complex system. It is basis for automatic theorem provers and many other Artificial Intelligence systems. E.g. automatic program verification systems. Predicate-logic like statements are supported by some of the more sophisticated database query engines and container class libraries these are types of programming tools. Dr. Nejib Zaguia - Winter 2008
6
Subjects and Predicates
Topic #3 – Predicate Logic Subjects and Predicates In the sentence “The dog is sleeping”: The phrase “the dog” denotes the subject - the object or entity that the sentence is about. The phrase “is sleeping” denotes the predicate- a property that is true of the subject. In predicate logic, a predicate is modeled as a function P(·) from objects to propositions. P(x) = “x is sleeping” (where x is any object). Dr. Nejib Zaguia - Winter 2008
7
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic More About Predicates Convention: Lowercase variables x, y, z... denote objects/entities; uppercase variables P, Q, R… denote propositional functions (predicates). Keep in mind that the result of applying a predicate P to an object x is the proposition P(x). But the predicate P itself (e.g. P=“is sleeping”) is not a proposition (not a complete sentence). E.g. if P(x) = “x is a prime number”, P(3) is the proposition “3 is a prime number.” Dr. Nejib Zaguia - Winter 2008
8
Propositional Functions
Topic #3 – Predicate Logic Propositional Functions Predicate logic generalizes the grammatical notion of a predicate to also include propositional functions of any number of arguments, each of which may take any grammatical role that a noun can take. E.g. 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.” Dr. Nejib Zaguia - Winter 2008
9
Predicates The predicate can have several variables:
Friends(X,Y): X and Y are friends Parents(X,Y,Z): X is a child of Y and Z SumsTo7(x, y): x+y=7 P(x,y,z): x > y2+z3-5 So, what are the truth values of: SumsTo7(4,5) P(27, 2, 3) WillPassCSI2101(Daniel Sousa)
10
Predicates in computing
The predicates are very useful in capturing the properties the variable values must satisfy before/during/after executing a code segment Consider the code segment temp = x; x = y; y = temp; Precondition – what holds before the code segment: Q(x, y): x = a, y = b for some values a and b Postcondition – what holds after the code segment: R(x,y): x = b, y = a also can be expressed as Q(y, x) To verify that the postcondition holds, we must start from the assumption that the precondition holds and go over every stop of the code ad examine what it does to see whether the postcondition is really true.
11
Predicates in computing
Consider the code segment if P(x, y) { temp = x; x = y; y = temp; } where P(x, y) is “x>y” Precondition – what holds before the code segment: Q(x, y): x = a, y = b for some values a and b Postcondition – what holds after the code segment: ???!
12
Universes of Discourse (U.D.s)
Topic #3 – Predicate Logic Universes of Discourse (U.D.s) The power of distinguishing objects from predicates is that it lets you state things 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) ... The collection of values that a variable x can take is called x’s universe of discourse. Dr. Nejib Zaguia - Winter 2008
13
Quantifier Expressions
Topic #3 – Predicate Logic Quantifier Expressions Quantifiers provide a notation that allows us to quantify (count) how many objects in the univ. of disc. satisfy a given predicate. “” is the FORLL or universal quantifier. x P(x) means for all x in the u.d., P holds. “” is the XISTS or existential quantifier. x P(x) means there exists an x in the u.d. (that is, 1 or more) such that P(x) is true. Dr. Nejib Zaguia - Winter 2008
14
The Universal Quantifier
Topic #3 – Predicate Logic The Universal Quantifier Example: Let the u.d. of x be parking spaces at UO. Let P(x) be the predicate “x is full.” Then the universal quantification of P(x), x P(x), is the proposition: “All parking spaces at UO are full.” i.e., “Every parking space at UO is full.” i.e., “For each parking space at UF, that space is full.” Instructors: You can substitute your favorite overly-crowded destination in place of the University of Florida in this example. Dr. Nejib Zaguia - Winter 2008
15
The Existential Quantifier
Topic #3 – Predicate Logic The Existential Quantifier Example: Let the u.d. of x be parking spaces at UO. Let P(x) be the predicate “x is full.” Then the existential quantification of P(x), x P(x), is the proposition: “Some parking space at UO is full.” “There is a parking space at UO that is full.” “At least one parking space at UO is full.” Dr. Nejib Zaguia - Winter 2008
16
Free and Bound Variables
Topic #3 – Predicate Logic 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. Dr. Nejib Zaguia - Winter 2008
17
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic 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?] “P(x), where x=3” is another way to bind x. 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: e.g. let Q(y) = x P(x,y) y x Dr. Nejib Zaguia - Winter 2008
18
Nesting of Quantifiers
Topic #3 – Predicate Logic Nesting of Quantifiers Example: Let the u.d. of x & y be people. Let L(x,y)=“x likes y” (a predicate w. 2 f.v.’s) Then y L(x,y) = “There is someone whom x likes.” (A predicate w. 1 free variable, x) Then x (y L(x,y)) = “Everyone has someone whom they like.” (A __________ with ___ free variables.) Proposition Dr. Nejib Zaguia - Winter 2008
19
Review: Predicate Logic (§1.3)
Objects x, y, z, … Predicates P, Q, R, … are functions mapping objects x to propositions P(x). Multi-argument predicates P(x, y). Quantifiers: [x P(x)] :≡ “For all x’s, P(x).” [x P(x)] :≡ “There is an x such that P(x).” Universes of discourse, bound & free vars. Dr. Nejib Zaguia - Winter 2008
20
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Quantifier Exercise If R(x,y)=“x relies upon y,” express the following in unambiguous English: x(y R(x,y))= y(x R(x,y))= x(y R(x,y))= y(x R(x,y))= x(y R(x,y))= Everyone has someone to rely on. There’s a poor overburdened soul whom everyone relies upon (including himself)! There’s some needy person who relies upon everybody (including himself). Everyone has someone who relies upon them. Everyone relies upon everybody, (including themselves)! Dr. Nejib Zaguia - Winter 2008
21
Natural language is ambiguous!
Topic #3 – Predicate Logic Natural language is ambiguous! “Everybody likes somebody.” For everybody, there is somebody they like, x y Likes(x,y) or, there is somebody (a popular person) whom everyone likes? y x Likes(x,y) “Somebody likes everybody.” Same problem: Depends on context, emphasis. [Probably more likely.] Dr. Nejib Zaguia - Winter 2008
22
Still More Conventions
Topic #3 – Predicate Logic Still More Conventions Sometimes the universe of discourse is restricted within the quantification, e.g., x>0 P(x) is shorthand for “For all x that are greater than zero, P(x).” =x (x>0 P(x)) x>0 P(x) is shorthand for “There is an x greater than zero such that P(x).” =x (x>0 P(x)) Dr. Nejib Zaguia - Winter 2008
23
More to Know About Binding
Topic #3 – Predicate Logic More to Know About Binding x x P(x) - x is not a free variable in x P(x), therefore the x binding isn’t used. (x P(x)) Q(x) - The variable x is outside of the scope of the x quantifier, and is therefore free. Not a complete proposition! (x P(x)) (x Q(x)) – This is legal, because there are 2 different x’s! Dr. Nejib Zaguia - Winter 2008
24
Quantifier Equivalence Laws
Topic #3 – Predicate Logic Quantifier Equivalence Laws Definitions of quantifiers: If u.d.=a,b,c,… x P(x) P(a) P(b) P(c) … x P(x) P(a) P(b) P(c) … From those, we can prove the laws: x P(x) x P(x) x P(x) x P(x) Which propositional equivalence laws can be used to prove this? (Chalkboard.) Another way to see why the order of quantifiers matters is to expand out the definitions of FORALL and EXISTS in terms of AND and OR. For example, suppose the universe of discourse just consists of two objects a and b. Now, consider some predicate P(x,y). Then, FORALL x EXISTS y P(x,y) (EXISTS y P(a,y)) /\ (EXISTS y P(b,y)) (P(a,a) \/ P(a,b)) /\ (P(b,a) \/ P(b,b)). In contrast, EXISTS y FORALL x P(x,y) (FORALL x P(x,a)) \/ (FORALL x P(x,b)) (P(a,a) /\ P(b,a)) \/ (P(a,b) /\ P(b,b)). To see that these two are inequivalent, suppose only P(a,a) and P(b,b) are true. Then, the first proposition (with the FORALL first) is true, but, the second proposition (with the EXISTS first) is true. Students can come up with this counterexample in-class as an exercise. DeMorgan's Dr. Nejib Zaguia - Winter 2008
25
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic More Equivalence Laws x y P(x,y) y x P(x,y) x y P(x,y) y x P(x,y) x (P(x) Q(x)) (x P(x)) (x Q(x)) x (P(x) Q(x)) (x P(x)) (x Q(x)) Exercise: See if you can prove these yourself. What propositional equivalences did you use? Dr. Nejib Zaguia - Winter 2008
26
Review: Predicate Logic (§1.3)
Topic #3 – Predicate Logic Review: Predicate Logic (§1.3) Objects x, y, z, … Predicates P, Q, R, … are functions mapping objects x to propositions P(x). Multi-argument predicates P(x, y). Quantifiers: (x P(x)) =“For all x’s, P(x).” (x P(x))=“There is an x such that P(x).” These “Review” slides I insert at the point where I am at the beginning of a lecture, just to quickly review what we’ve been covering recently. Instructors should feel free to move these slides around to wherever they are convenient. Dr. Nejib Zaguia - Winter 2008
27
More Notational Conventions
Topic #3 – Predicate Logic More Notational Conventions Quantifiers bind as loosely as needed: parenthesize x P(x) Q(x) Consecutive quantifiers of the same type can be combined: x y z P(x,y,z) x,y,z P(x,y,z) or even xyz P(x,y,z) All quantified expressions can be reduced to the canonical alternating form x1x2x3x4… P(x1, x2, x3, x4, …) ( ) Dr. Nejib Zaguia - Winter 2008
28
Defining New Quantifiers
Topic #3 – Predicate Logic Defining New Quantifiers As per their name, quantifiers can be used to express that a predicate is true of any given quantity (number) of objects. Define !x P(x) to mean “P(x) is true of exactly one x in the universe of discourse.” !x P(x) x (P(x) y (P(y) y x)) “There is an x such that P(x), where there is no y such that P(y) and y is other than x.” Dr. Nejib Zaguia - Winter 2008
29
Some Number Theory Examples
Topic #3 – Predicate Logic Some Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, … “A number x is even, E(x), if and only if it is equal to 2 times some other number.” x (E(x) (y x=2y)) “A number is prime, P(x), iff it’s greater than 1 and it isn’t the product of any two non-unity numbers.” x (P(x) (x>1 yz x=yz y1 z1)) Note we can even use quantifier expressions to define concepts like even-ness and prime-ness. Dr. Nejib Zaguia - Winter 2008
30
Goldbach’s Conjecture (unproven)
Topic #3 – Predicate Logic Goldbach’s Conjecture (unproven) Using E(x) and P(x) from previous slide, E(x>2): P(p),P(q): p+q = x or, with more explicit notation: x [x>2 E(x)] → p q P(p) P(q) p+q = x. “Every even number greater than 2 is the sum of two primes.” The notation in the top part may look confusing at first but it is actually unambiguous. After FORALL we must have the name of a variable. The following term has 1 free variable x, so we assume that variable comes after the FORALL. Then, the expression E(x>2) becomes a predicate that restricts the universe of discourse. E() is only a predicate if it contains a free variable; the only free variable within it is x so we translate E(x>2) as E(x) /\ x>2. This then is the predicate that must be true of an item in the universe of discourse in order for the rest of the expression to apply to it. Similarly, P(p) and P(q) translate to both free variables p and q after the EXISTS and to conjoined propositions about p and q. Alternatively, the whole expression could also be written FORALL E(x)>2 EXISTS p+q=x, P(p), P(q). Or of course in many other equivalent forms. Due to Goedel’s theorem, as far as we know right now, it is entirely possible that Goldbach’s conjecture could be perfectly true for the universe of all natural numbers from 0 to infinity, yet, there might be absolutely NO finite-length proof of this conjecture from the basic axioms of number theory. On the other hand, it might have a proof that is finite but extremely long, or even possibly a relatively short one that we just haven’t been lucky enough to discover yet. Dr. Nejib Zaguia - Winter 2008
31
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Calculus Example One way of precisely defining the calculus concept of a limit, using quantifiers: Dr. Nejib Zaguia - Winter 2008
32
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Deduction Example Definitions: s :≡ Socrates (ancient Greek philosopher); H(x) :≡ “x is human”; M(x) :≡ “x is mortal”. Premises: H(s) Socrates is human. x H(x)M(x) All humans are mortal. Dr. Nejib Zaguia - Winter 2008
33
Deduction Example Continued
Topic #3 – Predicate Logic Deduction Example Continued Some valid conclusions you can draw: H(s)M(s) [Instantiate universal.] If Socrates is human then he is mortal. H(s) M(s) Socrates is inhuman or mortal. H(s) (H(s) M(s)) Socrates is human, and also either inhuman or mortal. (H(s) H(s)) (H(s) M(s)) [Apply distributive Law.] F (H(s) M(s)) [Trivial contradiction.] H(s) M(s) [Use identity law.] M(s) Socrates is mortal. Dr. Nejib Zaguia - Winter 2008
34
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic Another Example Definitions: H(x) :≡ “x is human”; M(x) :≡ “x is mortal”; G(x) :≡ “x is a god” Premises: x H(x) M(x) (“Humans are mortal”) and x G(x) M(x) (“Gods are immortal”). Show that x (H(x) G(x)) (“No human is a god.”) Dr. Nejib Zaguia - Winter 2008
35
Dr. Nejib Zaguia - Winter 2008
Topic #3 – Predicate Logic The Derivation x H(x)M(x) and x G(x)M(x). x M(x)H(x) [Contrapositive.] x [G(x)M(x)] [M(x)H(x)] x G(x)H(x) [Transitivity of .] x G(x) H(x) [Definition of .] x (G(x) H(x)) [DeMorgan’s law.] x G(x) H(x) [An equivalence law.] Dr. Nejib Zaguia - Winter 2008
36
End of §1.3-1.4, Predicate Logic
Topic #3 – Predicate Logic End of § , Predicate Logic From these sections you should have learned: Predicate logic notation & conventions Conversions: predicate logic clear English Meaning of quantifiers, equivalences Simple reasoning with quantifiers Dr. Nejib Zaguia - Winter 2008
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.