Docsity

Discrete Structure, Discrete Mathematics, Lecture notes of Engineering

Toggle sidebar
bg1
Chapter 3
Predicate Logic
“Logic will get you from A to B. Imagination will take you every-
where.” A. Einstein
In the previous chapter, we studied propositional logic. This chapter is
dedicated to another type of logic, called predicate logic.
Let us start with a motivating example.
Example 21. Consider the following two statements:
•Every SCE student must study discrete mathematics.
•Jackson is an SCE student.
It looks “logical” to deduce that therefore, Jackson must study discrete math-
ematics. However, this cannot be expressed by propositional logic...you may
try it, but you can already notice that none of the logical operators we have
learnt are applicable here.
We need new tools!
Definition 20. A predicate is a statement that contains variables (predicate
variables), and they may be true or false depending on the values of these
variables.
Example 22. P(x)=“x2is greater than x” is a predicate. It contains one
predicate variable x. If we choose x= 1, P(1) is “1 is greater than 1”, which
is a proposition (always false).
77
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Discrete Structure, Discrete Mathematics and more Lecture notes Engineering in PDF only on Docsity!

Chapter 3

Predicate Logic

“Logic will get you from A to B. Imagination will take you every- where.” A. Einstein

In the previous chapter, we studied propositional logic. This chapter is dedicated to another type of logic, called predicate logic. Let us start with a motivating example.

Example 21. Consider the following two statements:

  • Every SCE student must study discrete mathematics.
  • Jackson is an SCE student.

It looks “logical” to deduce that therefore, Jackson must study discrete math- ematics. However, this cannot be expressed by propositional logic...you may try it, but you can already notice that none of the logical operators we have learnt are applicable here.

We need new tools!

Definition 20. A predicate is a statement that contains variables (predicate variables), and they may be true or false depending on the values of these variables.

Example 22. P (x) = “x^2 is greater than x” is a predicate. It contains one predicate variable x. If we choose x = 1, P (1) is “1 is greater than 1”, which is a proposition (always false).

78 CHAPTER 3. PREDICATE LOGIC

Limitation Of Propositional Logic

  • Every SCE student must study discrete mathematics
  • Jackson is a SCE student
    • So Jackson must study discrete mathematics
      • This idea can’t be expressed with propositional logic
  • What propositional logic allows to express:
    • If Jackson is a SCE student he must study discrete mathematics
    • Jackson is a SCE student
      • So Jackson must study discrete mathematics

Predicates

  • Is the statement “x^2 is greater than x” a proposition?
  • Define P(x) = ‘ x^2 is greater than x ’.
  • Is P(1) a proposition? P(1)=“1^2 is greater than 1” (F)
  • P(x) is a predicate.

A predicate is a statement that contains variables

(predicate variables) and that may be true or false

depending on the values of these variables.

80 CHAPTER 3. PREDICATE LOGIC

Predicate Instantiated/Domain

  • A predicate instantiated (where variables are

evaluated in specific values) is a proposition.

The domain of a predicate variable is the collection of all

possible values that the variable may take.

A predicate is a statement that contains variables

(predicate variables) and that may be true or false

depending on the values of these variables.

  • Predicate logic extends (is more powerful than)

propositional logic.

o e.g. the domain of x in P(x): integer o Different variables may have different domains.

4/

Example

  • Let P(x, y) = “x > y”.

Domain: integers, i.e. both x and y are integers.

  • P(4, 3) means “4 >3”, so P(4, 3) is TRUE;
  • P(1, 2) means “1>2” , so P(1, 2) is FALSE;
  • P(3,4) is false (in general, P(x,y) and P(y,x) not

equal).

Quantification

  • Statements like
    • Some birds are angry.
    • On the internet, no one knows who you are.
    • The square of any real number is nonnegative.

© Rovio

Universal Quantification

  • E.g. “xD P(x) is true” iff “ P ( x ) is true for every x in D”.
    •  universal quantifiers, “for all”, “for every”
    •  - “is a member (or) element of”, “belonging to”
    • D – domain of predicate variable
  • The square of any real number is nonnegative.

A universal quantification is a quantifier (something that tells

the amount or quantity) meaning "given any" or "for all".

Symbol:

xR, x^2 ≥ 0.

Definition 23. An existential quantification is a quantifier meaning “there exists”, “there is at least one” or “for some”. We use the following symbol:

∃ (existential quantification)

Example 26. Here is a formal way to say that for some values that a pred- icate variable x can take in a domain D, the predicate is true:

︸︷︷︸^ ∃x for some x

∈︸︷︷︸ D

belonging to D

, P (x) (is true)

For example, for D = { birds }, P (x) = “x is angry”,

︸︷︷︸^ ∃x Some

∈︸︷︷︸ D

birds

, P (x) (is true) ︸ ︷︷ ︸ are angry

The term nested quantification refers to statements involving several quantifiers. Here is a series of examples.

Example 27. All statements involve two predicate variables x and y, where x has for domain R = { rabbits }, while y has for domain T = { tortoises }. The predicate used is C(x, y) =“Rabbit x is faster than tortoise y”.

  • In logic symbolism, we write “All rabbits are faster than all tortoises”:

︸︷︷︸^ ∀x For any

∈︸︷︷︸ R

rabbit x

, ∀y ︸︷︷︸ for any

︸︷︷︸^ ∈^ T

tortoise y

C(x, y) (is true) ︸ ︷︷ ︸ x is faster than y

  • In logic symbolism, we write “Every rabbit is faster than some tortoise”:

︸︷︷︸^ ∀x For any

︸︷︷︸^ ∈^ R

rabbit x

, ∃y ︸︷︷︸ there is

︸︷︷︸^ ∈^ T

a tortoise y

C(x, y) (is true) ︸ ︷︷ ︸ such that x is faster than y

  • In logic formalism, we write “There is a rabbit which is faster than all tortoises”:

︸︷︷︸^ ∃x There exists

︸︷︷︸^ ∈^ R

a rabbit x such that

, ∀y ︸︷︷︸ for any

︸︷︷︸^ ∈^ T

tortoise y

C(x, y) (is true) ︸ ︷︷ ︸ x is faster than y

84 CHAPTER 3. PREDICATE LOGIC

Nested Quantification (II)

  • Another example
    • “Every rabbit is faster than some tortoise.”
    • Domains: R={rabbits}, T={tortoises}.
    • Predicate C(x, y): Rabbit x is faster than tortoise y
  • In symbols
    • xR (yT, C(x, y)) orxR,yT, C(x, y)
  • In words:
    • For any rabbit x, there exists a (some) tortoise y, such that x is faster than y.

Nested Quantification (III)

  • Another example
    • “There is a rabbit which is faster than all tortoises.”
    • Domains: R={rabbits}, T={ tortoises}.
    • Predicate C(x, y): Rabbit x is faster than tortoise y.
  • In symbols (note the ordering in nesting)
    • xR (yT, C(x, y))
  • In words:
    • There exists a rabbit x, such that for any tortoise y, this rabbit x is faster than y.
86 CHAPTER 3. PREDICATE LOGIC

Truth Value of Quantified Statements

Statement When true When false

xD,P(x) P(x) is true for

every x.

There is one x for

which P(x) is false.

xD,P(x) There is one x

for which P(x)

is true.

P(x) is false for

every x.

Assume that D consists of x 1 , x 2 , … , xn

 xD, P(x)  P ( x 1 ) P ( x 2 ) …  P ( xn )

  xD, P(x)  P ( x 1 ) P ( x 2 ) …  P ( xn )

Negation of Quantification

  • ‘Not all SCE students study hard’ = ‘There is at

least one SCE student who does not study hard’

  • Negation of a universal quantification becomes

an existential quantification.

¬ (  x  D, P(x))   x  D, ¬P(x)

  • ‘It is not the case that some students in this class are

from NUS.’= ‘All students in this class are not from NUS’

  • Negation of an existential quantification becomes an

universal quantification.

¬ (  x  D, P(x))   x  D, ¬P(x)

¬ (xD, P(x)Q(x))

 xD ¬ (P(x)Q(x)) (negation of quantification)

 xD (¬ P(x) ¬ Q(x)) (DeMorgan)

Negation of Quantification

  • Example: Not all students in this class are

using Facebook and (also) Google+

 There is some (at least one) student in this class who is not using Facebook or not using Google+ (or may be using neither)

How To Determine Truth Value

  • Systematic approaches:
    • Method of exhaustion
    • Method of case
    • Method of logic derivation

Statement When true When false xD,P(x) P(x) is true for every x.

There is one x for which P(x) is false. xD,P(x) There is one x for which P(x) is true.

P(x) is false for every x.

Method of Case. Suppose you want to show that the truth value of (∃ x, P (x)) is true. For this, you just need to find one case, one instantiation of x, for which P (x) is true.

Example 28. P (x) = “∃ x ∈ Z, x^2 = x is true, take x = 1 for example. Thus such an x exists.

Similarly, if you want to show that the truth value of (∀ x, P (x)) is false, it is enough to find one counterexmaple.

Example 29. P (x) = “∀ x ∈ R, x^2 > x is false, take x = 0.3 for example. Thus P (x) cannot be true for all x.

However, you cannot show that (∃ x, P (x)) is false using some examples, you need to prove that you cannot find a single x in your domain for which P (x) is true! Vice-versa, you cannot show that (∀ x, P (x)) is true by giving some examples, you need to show that this is always true, for every x in the domain considered. To do this, again, if the domain is small, one may use the exhaustion method of trying all options, but if the domain is big (or infinite), like Z, we need another method. Method of Logic Derivation. This method consists of using logical steps to transform one logical expression into another.

Example 30. Suppose you want to know the truth value of ∃ x, (P (x) ∨ Q(x)), x has for domain D = {x 1 ,... , xn}. Then ∃ x, (P (x) ∨ Q(x)) is true if there is an xi ∈ D for which P (xi) ∨ Q(xi) is true that is

(∃ x, (P (x) ∨ Q(x))) ≡ (P (x 1 ) ∨ Q(x 1 )) ∨... ∨ (P (xn) ∨ Q(xn))

but now this new expression becomes true exactly when at least one P (xi) or Q(xj ) is true, that is

(∃ x, (P (x) ∨ Q(x))) ≡ (∃ x, P (x)) ∨ (∃ x, Q(x)). When trying to derive logic steps involving quantifiers, one should be very careful with the ordering of the quantifiers...A typical example is that

∀ x, ∃ y, P (x, y) ≡ ∃ y, ∀ x, P (x, y)

does not hold in general!

Example 31. Consider the predicate P (x, y) = “x admires y”. Then ∀ x, ∃ y, P (x, y) means that everyone admires someone, while ∃ y, ∀ x, P (x, y) means that there exists one person who is admired by everyone!

90 CHAPTER 3. PREDICATE LOGIC

 [ P ( x 1 ) …  P ( xn )]  [Q( x 1 )  …  Q( xn )]

Method Of Logic Derivation

Consider an (arbitrary) domain with n members. Is

 x(P(x)  Q(x)) logically equivalent to  xP(x)   xQ(x)?

 [ P ( x 1 )  Q ( x 1 )]  …  [ P ( xn ) Q( xn )]

  xP ( x )   x Q( x )

 x ( P ( x )  Q( x ))

Order Of Nesting Matters

  • Is  xy P(x,y)   yx P(x,y) in general?
    • LHS: y can vary with respect to x, y is fixed with respect to x
    • Let P(x, y) =“x admires y”. LHS = “Every person admires some people”, RHS= “Some people are admired by everyone”
  • Consider x,yR +, and let P ( x , y ) be xy =1.
  • Is  xy P(x,y)   yx P(x,y)?
  • Consider X={9, 10, 15}, Y={2,3}. Let Q(x,y): y divides x
  • Then, is  x X  y Y Q(x,y)   y Y  x X Q(x,y)?
92 CHAPTER 3. PREDICATE LOGIC

Conditional Quantification (I)

  • For all real number x, if x>1 then x^2 >
    • i.e., any real number greater than 1 has a square larger than 1
  • In symbolic form
    • Let P(x) denote “x>1”
    • Let Q(x) denote “x^2 >1”
    • Let R denote the domain, the collection of all real numbers -  x (P(x)Q(x))

Conditional Quantification (III)

  • Given a conditional quantification
    • Such as  xA (P(x)Q(x))
  • Then we define
    • contrapositive x  A , ¬Q(x) ¬P(x)
    • converse x  A , Q(x)  P(x)
    • inverse x  A , ¬P(x) ¬Q(x)
  • Note: A conditional proposition is logically

equivalent to its contrapositive

Our motivating Example 21 to start predicate logic was:

Example 33. Consider the following two statements: (1) Every SCE student must study discrete mathematics. (2) Jackson is an SCE student. It looks “logical” to deduce that therefore, Jackson must study discrete mathematics.

We will now develop inference rules, that will allow us to express this example (see Exercise 28). Consider a predicate variable x taking value in the domain D. Then ∀x ∈ D, P (x); ∴ P (c) for any c ∈ D.

As we did for propositional logic, we look at when the premises are true. When ∀x, P (x) is true, P (x) is true for any choice of x in the domain D, in particular it is true for any choice of c, therefore P (c) is true for any c ∈ D. This rule says that if P (x) is true for any x in a domain, one is allowed to instantiate P (x) in x = c for any choice of c ∈ D.

Example 34. Suppose we have the following premises: (1) No cat can catch Jerry; (2) Tom is a cat. We want to deduce that therefore Tom cannot catch Jerry. We define two predicates: Cat(x)=“x is a cat”, Catch(x)=“x can catch Jerry”. The second premise, Tom is a cat, is the easiest to write, it becomes: Cat(Tom)=“Tom is a cat”. Now for the first premise, suppose we want to say “cats are catching Jerry”, this would be if x is a cat, then x catches Jerry, that is Cat(x) → Catch(x),

keeping in mind that we have not yet assigned a quantifier to this statement. To say that “cats are not catching Jerry”, then this would be if x is cat, then x cannot catch Jerry, that is

Cat(x) → ¬Catch(x),

and finally, to say that “no cat can catch Jerry”, we add a universal quantifier:

∀x(Cat(x) → ¬Catch(x)).

We then have the following premises in predicate logic:

  1. ∀x(Cat(x) → ¬Catch(x));
  2. Cat(Tom);

We can then instantiate the first premise with x =Tom, to get

(Cat(Tom) → ¬Catch(Tom)).

But since the second premise says that Cat(Tom); modus ponens (p → q; p; ∴ q) tells us that therefore ¬Catch(Tom).

Consider a predicate variable x taking value in the domain D. Then

P (c) for an arbitrary c ∈ D; ∴ ∀x P (x) ∈ D.

This just means that if a predicate is true for an arbitrary element c ∈ D, then it is true for all x ∈ D. Indeed, if whichever premise you look at is true, then the conclusion is true. This rule allows us to infer P (x) for all x ∈ D based on P (c) being true for an arbitrary instance c ∈ D.

Example 35. Consider the premise for an arbitrary real number x, x^2 ≥ 0. Therefore the square of any real number is non-negative. Set P (x) = “x^2 ≥ 0”. In predicate logic, we have for any arbitrary c ∈ R, P (c). Therefore ∀x P (x).

In fact, we have already used this rule implicitly...In Exercise 2, we showed that if n^2 is even, then n is even, for n an integer. The way we did it, is that we showed the result for one arbitrary n, and concluded this is true for all of them! See Exercise 29 for a more complicated example. Consider a predicate variable x taking value in the domain D. Then

∃x ∈ D, P (x); ∴ P (c) for some c ∈ D.

We look at when the premises are true. When ∃x, P (x) is true, P (c) is true for at least one choice of c in the domain D. This rule allows to instantiate P (x) in some values of c for which P (c) is true.

Example 36. The premises are: (1) if any student gets > 80 in the exam, then (s)he gets an A, (2) there are students who get > 80 in the exam, (3) Sam is such a student. We want to conclude that therefore Sam gets an A. Set the predicates A(x) = “x gets an A”, M (x) = “x gets > 80 in the exam”, the domain D is D = { students }. In predicate logic, (1) and (2) are respectively given by

  1. ∀x, M (x) → A(x).
  2. ∃x, M (x).

Now that Sam is such a student can be expressed using the above rule, to obtain M(Sam). Then we can instantiate 1. with Sam, to get M(Sam) → A(Sam), which combined with M(Sam) leads to therefore A(Sam).

96 CHAPTER 3. PREDICATE LOGIC

Existential Instantiation

Example

  • If any student gets >80 in the final exam, then (s)he gets an A.
  • There are students who get >80 in the final exam, Sam is such a student.
  • Therefore, Sam gets an A.

x P(x)

 P(c) for some c in the domain.

Domain={all students}; A(x)=“x gets an A” M(x) = “x gets 80 in the final exam”

  1. x [M(x)  A(x)] Hypothesis
    1. x M(x) Hypothesis
    2. M(Sam) Hypothesis +Existential instantiation
    3. M(Sam)  A(Sam) Universal instantiation on 1
    4. A(Sam) Modus ponens on 4 and 3

Existential Generalization

P(c)

 x P(x)

for c some specific

element of domain.

Example

  • If everyone is selling stocks, then someone is selling stocks. © belongs to the cartoonist

Domain={all people} , Sell(x) =“x is selling stocks”. x Sell(x)  x Sell(x)

  1. x Sell(x) Hypothesis
  2. Sell(c) Universal instantiation
  3. x Sell(x) Existential generalization