• No results found

Predicate logic.pptx

N/A
N/A
Protected

Academic year: 2020

Share "Predicate logic.pptx"

Copied!
51
0
0

Loading.... (view fulltext now)

Full text

(1)

Predicate logic

Also known as predicate calculus or Order-Logic(FOL) or First-Order-Predicate-Calculus (FOPC).

(2)

Propositional Logic can’t say

If X is married to Y, then Y is married to X.

If X is west of Y, and Y is west of Z, then X is west of Z.And a million other simple things.

Fix:

extend representation: add predicates

(3)

3

Propositional logic is a weak language

Hard to identify “individuals” (e.g., Mary, 3)

Can’t directly talk about properties of individuals or relations between individuals (e.g., “Bill is tall”)

Generalizations, patterns, regularities can’t easily be represented (e.g., “all triangles have 3 sides”) • First-Order Logic (abbreviated FOL or FOPC) is

expressive enough to concisely represent this kind of information

FOL adds relations, variables, and quantifiers, e.g.,

“Every elephant is gray”:  x (elephant(x) → gray(x))

(4)

4

First-order logic

First-order logic (FOL) models the world in terms of Objects, which are things with individual identities

Properties of objects that distinguish them from other objectsRelations that hold among sets of objects

Functions, which are a subset of relations where there is only one “value” for any given “input”

Examples:

Objects: Students, lectures, companies, cars ...

Relations: Brother-of, bigger-than, outside, part-of, has-color,

occurs-after, owns, visits, precedes, ...

Properties: blue, oval, even, large, ...

(5)

Propositional Functions

Propositional functions (or predicates) are propositions that contain variables.

Ex: Let P(x) denote x > 3

where P denotes the predicate “is greater than 3” and x is the variable. The statement P(x) is also said to be the value of the propositional

function P at x. Once a value has been assigned to the variable x, the statement P(x) becomes a proposition and has a truth value.

P(x) has no truth value until the variable x is bound by either

(6)

Quantifiers

Quantifiers

Universal x

Existential x

xP(x)

True

when P(x) is true for every x.

False

if there is an x for which P(x) is false.

xP(x)

(7)

When the variables in a propositional function are assigned values, the resulting

statement becomes a proposition with a certain truth value. However, there is another important way, called quantification, to create a proposition from a

propositional function. Quantification expresses the extent to which a predicate is true over a range of elements. In English, the words all, some, many, none, and

(8)

Negation

(it is not the case)



xP(x)

equivalent to

x

P(x)

True

when P(x) is false for every x

False

if there is an x for which P(x) is true.

xP(x)

is equivalent to

x

P(x)

(9)

Universal Quantification of P(x)

xP(x)

“for all x P(x)”

“for every x P(x)”

Defined as:

P(x

0

)

P(x

1

)

P(x

2

)

P(x

3

)

. . . for all x

i

in U

Example:

Let P(x) denote x

2

x

(10)

Examples using universal quantifier

EXAMPLE 1: Let P(x) be the statement “x + 1 > x.” What is the truth

value of the quantification ∀xP(x), where the domain consists of all real numbers?

Solution: Because P(x) is true for all real numbers x, the quantification

(11)

Besides “for all” and “for every,” universal quantification can be

expressed in many other ways, including “all of,” “for each,” “given any,” “for arbitrary,” “for each,” and “for any.”

Remark: It is best to avoid using “for any x” because it is often

(12)

A statement xP(x) is false, where P(x) is a propositional function, if and only if P(x) is not always true when x is in the domain. One way to show that P(x) is not always true when x is in the domain is to find a

(13)

EXAMPLE 2: Let Q(x) be the statement “x < 2.” What is the truth value

of the quantification ∀xQ(x), where the domain consists of all real numbers?

Solution: Q(x) is not true for every real number x, because, for

(14)

EXAMPLE 3: Suppose that P(x) is “x2 > 0.” To show that the statement

xP(x) is false where the universe of discourse consists of all integers, we give a counterexample. We see that x = 0 is a counterexample

(15)

EXAMPLE 4: What is the truth value of xP(x), where P(x) is the

statement “x2 < 10” and the domain consists of the positive integers

not exceeding 4?

Solution: The statement xP(x) is the same as the conjunction

P(1) P(2) P(3) P(4),

because the domain consists of the integers 1, 2, 3, and 4. Because

P(4), which is the statement

(16)

EXAMPLE 5: What does the statement xN(x) mean if N(x) is

“Computer x is connected to the network” and the domain consists of all computers on campus?

Solution: The statement xN(x) means that for every computer x on

(17)

EXAMPLE 6: What is the truth value of x(x2x) if the domain consists

of all real numbers? What is the truth value of this statement if the domain consists of all integers?

Solution: The universal quantification ∀x(x2x), where the domain

consists of all real numbers, is false. For example, ( 1/2 )2 1/2. Note

that x2x if and only if x2x = x(x − 1) ≥ 0. Consequently, x2x if and

only if x ≤ 0 or x ≥ 1. It follows that ∀x(x2x) is false if the domain

consists of all real numbers (because the inequality is false for all real numbers x with 0 < x < 1). However, if the domain consists of the

integers, ∀x(x2x) is true, because there are no integers x with 0 < x <

(18)

A domain must always be specified when the statement xP(x) is

(19)

Existential Quantification

of P(x)

xP(x)

“there is an x such that P(x)”

“there is at least one x such that P(x)”

“there exists at least one x such that P(x)”

Defined as:

P(x

0

)

P(x

1

)

P(x

2

)

P(x

3

)

. . . for all x

i

in U

Example:

Let P(x) denote x

2

x

(20)

EXAMPLE1: Let P(x) denote the statement “x > 3.” What is the truth

value of the quantification ∃xP(x), where the domain consists of all real numbers?

Solution: Because “x > 3” is sometimes true—for instance, when x = 4

—the existential quantification of P(x), which is ∃xP(x), is true.

Observe that the statement xP(x) is false if and only if there is no

(21)

EXAMPLE 2: Let Q(x) denote the statement “x = x + 1.”What is the

truth value of the quantification ∃xQ(x), where the domain consists of all real numbers?

Solution: Because Q(x) is false for every real number x, the existential

(22)

When all elements in the domain can be listed—say, x1, x2, . . . , xn

the existential quantification ∃xP(x) is the same as the disjunction

P(x1) P(x2) ∨ · · · ∨ P(xn),

(23)

EXAMPLE 3: What is the truth value of xP(x), where P(x) is the statement “x2 > 10” and the universe of discourse consists of the

positive integers not exceeding 4?

Solution: Because the domain is {1, 2, 3, 4}, the proposition xP(x) is

the same as the disjunction

P(1) P(2) P(3) P(4).

Because P(4), which is the statement “42 > 10,” is true, it follows that

(24)

Negating Quantified

Expressions

• We will often want to consider the negation of a quantified expression. For instance, consider the negation of the statement

• “Every student in your class has taken a course in calculus.”

• This statement is a universal quantification, namely,

• ∀xP(x),

• where P(x) is the statement “x has taken a course in calculus” and the domain consists of the students in your class. The negation of this statement is “It is not the case that every student in your class has taken a course in calculus.” This is equivalent to “There is a student in your class who has not taken a course in calculus.” And this is simply the existential quantification of the negation of the original propositional function, namely,

• ∃x P(x).

• This example illustrates the following logical equivalence:

(25)

• Suppose we wish to negate an existential quantification. For instance, consider the proposition

• “There is a student in this class who has taken a course in calculus.” This is the existential quantification

• ∃xQ(x),

• where Q(x) is the statement “x has taken a course in calculus.” The negation of this statement is the proposition “It is not the case that there is a student in this class who has taken a course in calculus.” This is equivalent to “Every student in this class has not taken calculus,” which is just the universal quantification of the negation of the original propositional function, or, phrased in the language of quantifiers,

• ∀x Q(x).

• This example illustrates the equivalence

(26)

EXAMPLE : What are the negations of the statements x(x2 > x) and

x(x2 = 2)?

Solution: The negation of x(x2 > x) is the statement ¬∀ x(x2 > x),

which is equivalent to ∃x(x2 > x). This can be rewritten as x(x2

x). The negation of ∃x(x2 = 2) is the statement ¬∃ x(x2 = 2), which is

equivalent to ∀x(x2 = 2). This can be rewritten as x(x2 2). The

(27)

Example

Let

T(a,b)

denote the propositional function “a

trusts b.” Let

U

be the set of all people in the

world.

Everybody trusts Bob.

xT(x,Bob)

Bob trusts somebody.

(28)

Example

Alice trusts herself. T(Alice, Alice)

Alice trusts nobody. (everybody is not trusted by Alice) x T(Alice,x)

Carol trusts everyone trusted by David. x(T(David,x)  T(Carol,x))

(29)

Examples

x

y T(x,y)

Someone trusts everybody.

y

x T(x,y)

Somebody is trusted by everybody.

Bob trusts only Alice.

(30)

Quantification of Two

Variables

xyP(x,y)

True when for every x there is a y for which P(x,y) is true.

(in this case y can depend on x)

False if there is an x such that P(x,y) is false for every y.

yxP(x,y)

True if there is a y for which P(x,y) is true for every x.

(i.e., true for a particular y regardless (or independent) of x)

False if for every y there is an x for which P(x,y) is false.

Note that order matters here

In particular, if yxP(x,y) is true, then xyP(x,y) is true.

(31)

Examples

Let L(x,y) be the statement “x loves y” where U for both x and y is the set of all people in the world.

Everybody loves Jerry. xL(x,Jerry)

Everybody loves somebody. x yL(x,y)

(32)

Examples

There is somebody whom Lydia does not love. xL(Lydia,x)

Nobody loves everybody. (For each person there is at least one person they do not love.)

xyL(x,y)

(33)

33

Sentences are built from terms and

atoms

• A term (denoting a real-world individual) is a constant symbol, a variable symbol, or an n-place function of n terms.

x and f(x1, ..., xn) are terms, where each xi is a term. A term with no variables is a ground term

An atomic sentence (which has value true or false) is an n-place

predicate of n terms

• A complex sentence is formed from atomic sentences connected by the logical connectives:

P, PQ, PQ, PQ, PQ where P and Q are sentences

• A quantified sentence adds quantifiers  and 

• A well-formed formula (wff) is a sentence containing no “free”

variables. That is, all variables are “bound” by universal or existential quantifiers.

(34)

34

Quantifiers

Universal quantifiers are often used with “implies” to form “rules”:

(x) student(x)  smart(x) means “All students are smart”

Universal quantification is rarely used to make blanket statements about

every individual in the world:

(x)student(x)smart(x) means “Everyone in the world is a student and is smart”

Existential quantifiers are usually used with “and” to specify a list of

properties about an individual:

(x) student(x)  smart(x) means “There is a student who is smart”

A common mistake is to represent this English sentence as the FOL

sentence:

(x) student(x)  smart(x)

(35)

35

Quantifier Scope

Switching the order of universal quantifiers does not change the

meaning:

• (x)(y)P(x,y) ↔ (y)(x) P(x,y)

Similarly, you can switch the order of existential quantifiers:

(x)(y)P(x,y) ↔ (y)(x) P(x,y)

Switching the order of universals and existentials does change

meaning:

Everyone likes someone: (x)(y) likes(x,y)

(36)

36

Connections between All and Exists

We can relate sentences involving  and  using De Morgan’s laws:

(x) P(x) ↔ (x) P(x)

(x) P ↔ (x) P(x)

(37)

37

Universal instantiation

(a.k.a. universal elimination)

If (x) P(x) is true, then P(C) is true, where C is any constant in the

domain of x

Example:

(x) eats(Ziggy, x)  eats(Ziggy, IceCream)

The variable symbol can be replaced by any ground term, i.e., any

(38)

38

Existential instantiation

(a.k.a. existential elimination)

• From (x) P(x) infer P(c) • Example:

• (x) eats(Ziggy, x)  eats(Ziggy, Stuff)

• Note that the variable is replaced by a brand-new constant

not occurring in this or any other sentence in the KB

• Also known as skolemization; constant is a skolem constant

• In other words, we don’t want to accidentally draw other inferences about it by introducing the constant

• Convenient to use this to reason about the unknown

(39)

39

Existential generalization

(a.k.a. existential introduction)

If P(c) is true, then (x) P(x) is inferred.

Example

eats(Ziggy, IceCream)  (x) eats(Ziggy, x)

All instances of the given constant symbol are replaced by the new

variable symbol

Note that the variable symbol cannot already exist anywhere in the

(40)

Thinking of Quantification as

Loops

Quantifications of more than one variable can be thought of as nested loops.

For example, xyP(x,y) can be thought

of as a loop over x, inside of which we loop over y (i.e., for each value of x).

Likewise, xyP(x,y) can be thought of

as a loop over x with a loop over y nested inside. This can be extended to any

(41)

Quantification as Loops

Using this procedure

•xyP(x,y) is true if P(x,y) is true for all values of x,y

as we loop through y for each value of x.

•xyP(x,y) is true if P(x,y) is true for at least one set of

values x,y as we loop through y for each value of x.

(42)

Quantification of 3 Variables

Let Q(x,y,z) be the statement “x + y = z”, where x,y,z are real numbers. What is the truth values of

•xyzQ(x,y,z)?

(43)

Quantification of 3 Variables

Let Q(x,y,z) be the statement “x + y = z”, where x,y,z are real numbers.

•xyzQ(x,y,z)

is the statement, “For all real numbers x and for all real numbers y, there is a real number z such that

x + y = z.”

(44)

Quantification of 3 Variables

Let Q(x,y,z) be the statement “x + y = z”, where x,y,z are real numbers. zxyQ(x,y,z)

is the statement, “There is a real number z such that for all real numbers x and for all real numbers y,

x + y = z.”

(45)

Examples

Let

P(x) be the statement: “x is a Georgia Tech student” Q(x) be the statement: “ x is ignorant”

R(x) be the statement: “x wears red” and U is the set of all people.

No Georgia Tech students are ignorant.

x(P(x) Q(x))

x(P(x) Q(x))

OK by Implication equivalence.

x(P(x)  Q(x))

(46)

Examples

x(P(x)  Q(x))

Ûx (P(x)  Q(x)) Negation equivalence Ûx ( P(x)  Q(x)) Implication equivalence Ûx (  P(x)   Q(x)) DeMorgan’s Ûx ( P(x)   Q(x)) Double negation

Only true if everyone is a GT student and is not ignorant. No Georgia Tech students are ignorant.

(47)

Examples

P(x) be the statement: “x is a Georgia Tech student” Q(x) be the statement: “ x is ignorant”

R(x) be the statement: “x wears red” and U is the set of all people.

No Georgia Tech students are ignorant.

x(P(x)  Q(x))

(48)

Examples

x(P(x)  Q(x))

Û x (P(x)  Q(x)) Negation equivalence Ûx (P(x)  Q(x)) DeMorgan

Ûx (P(x) Q(x)) Implication equivalence No Georgia Tech students are ignorant.

(49)

Examples

Let

P(x) be the statement: “x is a Georgia Tech student” Q(x) be the statement: “ x is ignorant”

R(x) be the statement: “x wears red” and U is the set of all people.

(50)

Examples

Let

P(x) be the statement: “x is a Georgia Tech student” Q(x) be the statement: “ x is ignorant”

R(x) be the statement: “x wears red” and U is the set of all people.

No Georgia Tech student wears red. x(P(x) R(x))

(51)

Examples

If “no Georgia Tech students are ignorant” and “all ignorant people wear red”, does it follow that “no Georgia Tech student wears red?”

x((P(x) Q(x))  (Q(x) R(x)))

NO

Some misguided GT student might wear red!!

References

Related documents