Predicates (CSCI 2824 Spring 2015)

In this lecture, we will cover the following topics:

  • Propositional Logic: Truth tables, logical equivalence, tautologies and fallacies.

  • Predicates and Quantifiers (Section 1.4 of the book).

Predicates

In the previous lecture, we looked at propositions. Propositions are statements for which we can give “true” or “false” valuation. We will now generalize propositions to predicates.

Predicates should be familiar from english grammar.

 underset{mathit{Subject}}{underbrace{mbox{Tom}}};; underset{mathit{Predicate}}{underbrace{mbox{is going to school}}} ,.

Thus, the predicate can be informally expressed as: X is going to school, where X is a variable that can stand for a person.

If we fill in values for X, such as Tom, Susan, My Fish and so on, we obtain propositions that can be given true or false valuations.

A predicate P(x) is a statement with a variable x such that whenever x is substituted by a value, then it results in a proposition that can be given true or false valuation.

Example-1(a):

Let M(x) stand for the statement: __<x>__ is mortal.

Q: What is M(mbox{+Socrates+})?

A: The proposition Socrates is mortal.

Example-1(b):

We can use predicates in propositional formulas.

Socrates is mortal AND he NOT is the son of Zeus.

This can expressed as

 mbox{Mortal}(mbox{Socrates}) land neg mbox{Son}(mbox{Socrates}, mbox{Zeus}) ,

where the predicate mbox{Mortal}(x) stand for the statement: __<x>__ is mortal, and the predicate mbox{Son}(x,y) stand for the statement: __<x>__ is the son of __<y>__.

Example-2:

Predicates can be arithmetic in nature. Here are some predicates over numbers:

  • n < 10: Number n is less than 10.

  • mbox{Prime}(x): Number x is prime.

  •  (n < 10) Rightarrow  (n < 20): If number n is less than 10 then it is less than 20.

Note that we can plug in various numbers and find out if the resulting statement is true of false.

  • Try all statements above with n=100. Which ones are true?

  • What about with n= -5?

Example-3:

Predicates can involve multiple variables.

Let Father(x,y) stand for the statement: __<x>__ is the father of __<y>__ .

Q: Using the predicate above, how do we express Darth is the father of Luke?

A: Father(Darth, Anakin).

And the same applies to predicates over numbers:

  •  x < 10  lor y - x > 10 .

  •  x^2 - sin y = 2.4

  •  neg(y = x + 100) lor  neg( y < x - 3).

Example-4:

We can now bring in all the propositional connectives and combine them with predicates.

Q: How do we say that

( Darth is the father of Luke OR Anakin is the father of Luke) AND (Luke is NOT the father of Darth)

using the Father predicate from the previous example?

A:  (Father(Darth, Luke)  lor Father(Anakin,Luke)) land neg Father(Luke,Darth).

Example-5:

Let P(n) be a predicate over numbers n that stands for n is prime.

Which of the following formulae are true over numbers?

  • P(100)

  • P(17)

  • neg P(13)  lor P(18).

  • P(14) Rightarrow P(15).

Answers:

  • P(100) is false.

  • P(17) is true.

  • neg P(13)  lor P(18) is false.

  • P(14) Rightarrow P(15) is true.

Redo the example with the following interpretation of P: P(x):  x  mbox{is even}.

An application: Predicate logic forms the root of Prolog, which is used in artificial intelligence.

Predicates and Sets

We can use predicates to select elements from a set. Let us fix a set U={1,2,3,ldots,100}.

  • Select elements from U that are even:

  • Define E(x) to be the predicate: x is even. We can instead write E(x) out as x  mbox{mod} 2 = 0.

  • We then write the set as: { x in U | E(x) }.

  • Alternative notation: { x in U | x mbox{mod} 2 = 0 }.

  • Select elements from U that are greater than 4 and are divisible by 13:

    • { x in U | (x geq 4)  land (x mbox{mod} 13 = 0 ) }.

  • Select the empty set.

    • { x in U | (x not= x) }.

  • Select the entire set U:

    • { x in U | x = x }.

Application: SQL for database management

Structured Query Language (SQL) is a data definition and manipulation language, based on relational calculus. In plain terms, SQL allows us to query (i.e., retrieve) data that satisfies certain criteria, which would be specified using predicates.

Here is what a query looks like (syntax may be a little off), given e.g. a database db that stores a list of people and their ages.

SQL Query
SELECT (name, age)
   FROM db
   WHERE ( name[1]=="z" && age < 20)

This syntax uses the predicate name1==“z” && age < 20 (where name and age are the variables) and returns from the database db a list of people whose names start with “z” and who are less than 20 years old.

Negation of Predicates and Formulas

The negation of predicate P(x) is written as neg P(x). However, this can be simplified further by applying DeMorgan's Laws.

Eg., Consider the predicate x < y. It is cumbersome to write neg (x < y) everywhere. Instead, we write x geq y.

In other words, we say that the predicate geq represents the negation of <.

Starting from predicates, we can extend negations to formulae.

What is the negation of:

 (x < y)  lor (x > y^2 + 3) ,?

Answer:

 ( x geq y) land (x leq y^2 + 3)

Note how the lor changes to a land while negation.

Rules for negation:

Formula Type Negation
neg P P
P lor Q neg P land neg Q
P land Q  neg P lor neg Q

Example

Write down the negation of the following formulae:

Q1: x^2 geq y land ( x < 5  lor x > 8).

A:  x^2 < y lor ( x geq 5 land x  leq 8 ).

Q2: Father(A,B) lor (Father(A,C) land Father(C,D)).

A:  neg Father(A,B) land (neg Father(A,C) lor neg Father(C,D)).

Quantifiers

The power of predicates arise from our ability to quantify. Let us illustrate quantification with an example.

How do we express the statement: For all natural numbers x, x is divisible by 2 OR x-1 is divisible by 2 ?

If we forget the for all in the first place, we can write

 x mbox{mod} 2 = 0  lor (x-1) mbox{mod}  = 0

This is a formula involving a predicate that allows us to plug-in values for x. But the original statement was meant to hold for all possible values of x.

We use the universal or forall quantifier to say:

 (forall x in mathbb{N}) x mbox{mod} 2 = 0  lor (x-1) mbox{mod}  = 0  ,.

  • The forall symbol is an inverted A and stands for for all or for each.

  • The notation in mathbb{N} stands for belongs to the set mathbb{N}.

  • The set mathbb{N} is commonly used to denote the set of natural numbers. Other commonly used notations include mathbb{R} for reals, mathbb{Z} for integers and mathbb{Q} for rational numbers.

The other quantifier used is the existential or the exists quantifier. As an example, we wish to say: There is a number n that is even and prime.

 (exists n in mathbb{N}) mbox{Prime}(n) land (n mbox{mod} 2 = 0)

The symbol exists stands for exists. Notice that it is an inverted E.

Quantified Formula

Whenever there is a quantifier in front of a formula, it is called a quantified formula.

As an example consider the formula:

 psi[y]:  (forall x in mathbb{R}) x leq 5  Rightarrow  x - y leq 5

In this formula the variable x is called a bound or a quantified variable. The variable y is called a free variable.

We usually write formulas as psi[y] to denote that y is a free variable in the formula.

For example, which of the following are true for the formula above:

  • psi(20)?

  • psi(-1)?

Formulas can have multiple quantifiers in front of them:

 (forall x in mathbb{N}) (exists y in  mathbb{N}) (y > x land mbox{Prime}(y)

Q Paraphrase this formula in plain english.

A For every number x there exists a number y such that y > x and y is prime.

Q Express this sentence in Logic: “ Forall persons x,y,z, If (x is the parent of y) and ( y is the parent of z) then (x is the grandparent of z) ”. Use predicates “P(x,y)” for parent and “GP(x,y)”, grand parent.

 (forall x,y,z in mathsf{Persons}) (P(x,y) land P(y,z)) Rightarrow GP(x,z) ,.

Q Define the formula Sib(x,y) to express that x is a sibling of y using the parent relation, where two persons are siblings if they have a parent in common.

A:  (exists z in mathsf{Persons}) P(z,x) land P(z,y)