0% found this document useful (0 votes)
6 views

CH 2

Uploaded by

ioio.ns327
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

CH 2

Uploaded by

ioio.ns327
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

THE PREDICATE

CALCULUS
Knowledge

 Knowledge is a theoretical or practical understanding of a


subject or a domain. Knowledge is also the sum of what is
currently known, and apparently knowledge is power. Those
who possess knowledge are called experts.

 Knowledge representation is a science of translating actual


knowledge into a format that can be used by the computer.
THE PROPOSITIONAL
CALCULUS

 The propositional calculus and the predicate calculus are


representation languages for artificial intelligence.

 Using their words, phrases, and sentences, we can represent and


reason about properties and relationships in the world.

 The first step in describing a language is to introduce the pieces


that make it up: its set of symbols.
Syntax vs. Semantic

 Syntax: is the study of the principles and rules for constructing


phrases and sentences in natural languages

 The syntax of the logic system defined by a set of rules for


producing legal sentences.

 Semantics: is the study of meaning of legal sentences.


PROPOSITIONAL CALCULUS SYMBOLS

 The symbols of propositional calculus are:


 The propositional symbols (that denote propositions): P, Q, R, S, …
 The truth symbols: True and False
 The connectives:
 ∧ : the conjunction (and)
 ∨ : the disjunction (or)
 ¬ : the negation
 → : the implication (conditional statement)
 ≡ : the equivalence
Propositional Calculus sentences (i)

 Sentences in the propositional calculus are formed from these atomic symbols according to the following
rules:

 Every propositional symbol and truth symbol is a sentence.


For example: true, P, Q, and R are sentences.

 The negation of a sentence is a sentence:


For example: ¬ P and ¬ false are sentences.

 The conjunction (and) of two sentences is a sentence.


For example: P ∧ Q is a sentence (P and Q are called the conjuncts).

 The disjunction (or) of two sentences is a sentence.


For example: P ∨ Q is a sentence (P OR Q are referred to as disjuncts).

 The implication of one sentence from another is a sentence.


For example: P → Q is a sentence (P is called the premise or antecedent and Q is called the conclusion or
consequent.)

 The equivalence of two sentences is a sentence.


For example: P ∨ Q ≡ R is a sentence.
Propositional Calculus sentences (ii)

 Legal sentences are also called well-formed formulas or WFFs.


 In the sentences of propositional calculus, the symbols ( ) and [ ]
are used to group symbols into sub expressions and so to
control their order of evaluation and meaning.
For example, (P ∨ Q) ≡ R is quite different from P ∨ (Q ≡R)

 An expression is considered a sentence (or well-formed formula)


if and only if it can be formed of legal symbols through some
sequence of the above rules.
Example

Is the following expression a well-formed sentence in the propositional calculus?


((P ∧ Q) → R) ≡ ¬ P ∨ ¬ Q ∨ R

Answer
Yes, it is a well-formed sentence in the propositional calculus because it has been
constructed (through a series of applications of legal rules and is therefore “well
formed) as follows:
 P, Q, and R are propositions and thus sentences.
 P ∧ Q, the conjunction of two sentences, is a sentence.
 (P ∧ Q) → R, the implication of a sentence for another, is a sentence.
 ¬ P and ¬ Q, the negations of sentences, are sentences.
 ¬ P ∨ ¬ Q, the disjunction of two sentences, is a sentence.
 ¬ P ∨ ¬ Q ∨ R, the disjunction of two sentences, is a sentence.
 ((P ∧ Q) → R) ≡ ¬ P ∨ ¬ Q ∨ R, the equivalence of two sentences, is a
sentence.
The Semantics of the Propositional Calculus

 Interpretation is the truth value assignment to propositional sentences.


 Formally, an interpretation is a mapping from the propositional symbols
into the set {T, F}.

 Because AI programs must reason with their representational structures, it


is important to demonstrate that the truth of their conclusions depends
only on the truth of their initial knowledge or premises.

 As mentioned earlier, the symbols true and false are part of the set of
well-formed sentences of the propositional calculus; i.e., they are distinct
from the truth value assigned to a sentence.

 To enforce this distinction, the symbols T and F are used for truth value
assignment.
The interpretation for sentences in the
Propositional Calculus

 The truth assignment of negation ( ¬ P), where P is any propositional symbol,


is F if the assignment to P is T, and T if the assignment to P is F.

 The truth assignment of conjunction (∧) is T only when both conjuncts have
truth value T; otherwise it is F.

 The truth assignment of disjunction (∨) is F only when both disjuncts have
truth value F; otherwise it is T.

 The truth assignment of implication (→) is F only when the premise (symbol
before the implication) is T and the truth value of the consequent (symbol
after the implication) is F; otherwise it is T.

 The truth assignment of equivalence (≡) is T only when both expressions have
the same truth assignment for all possible interpretations; otherwise it is F.
Propositional Calculus Laws

P, Q, and R are propositional expressions

The double negation law ¬ ( ¬ P) ≡ P


The definition of implication (P → Q) ≡ ( ¬ P ∨ Q)
The contrapositive law (P → Q) ≡ ( ¬ Q → ¬ P)
De Morgan’s laws ¬ (P ∨ Q) ≡ ( ¬ P ∧ ¬ Q)
¬ (P ∧ Q) ≡ ( ¬ P ∨ ¬ Q)
The commutative laws (P ∧ Q) ≡ (Q ∧ P)
(P ∨ Q) ≡ (Q ∨ P)
The associative laws ((P ∧ Q) ∧ R) ≡ (P ∧ (Q ∧ R))
((P ∨ Q) ∨ R) ≡ (P ∨ (Q ∨ R))
The distributive laws P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Truth Tables

 Two expressions in the propositional calculus are equivalent if


they have the same value under all truth value assignments.

 This equivalence may be demonstrated using truth tables.


Example

 Using a truth table, show that the expressions


(P → Q) and ( ¬ P ∨ Q) are equivalent (P → Q ≡ ¬ P ∨ Q)
The Predicate Calculus: introduction (i)

 In propositional calculus, each atomic symbol (P, Q, etc.) denotes a single


proposition. Therefore, there is no way to access the components of an
individual assertion. For instance, P is a proposition such that

P: “it rained on Tuesday”

 On the contrary, predicate calculus provides this ability. For instance, we


can create a predicate weather that describes a relationship between a
day and the weather:

weather (Tuesday, rain)

 Through inference rules we can manipulate predicate calculus expressions,


accessing their individual components and inferring new sentences.
The Predicate Calculus: introduction (ii)

 Predicate calculus also allows expressions to contain variables.


 Variables let us create general assertions about classes of
entities. For example, we could state that:
for all values of X, where X is a day of the week,
the statement weather(X, rain) is true;
i.e., it rains every day.
Predicate Calculus Symbols (i)

 The alphabet that makes up the symbols of the predicate


calculus consists of:

 The set of both upper and lowercase letters of the English


alphabet

 The set of decimal digits (0, 1, 2, … , 9)


 The underscore ( _ )
 Symbols in the predicate calculus begin with a letter and are
followed by any sequence of the above legal characters.
Example

Is the following a legitimate character in the alphabet of predicate calculus symbols?


A
Yes
d
Yes
#
No
/
No
6
Yes
_
Yes
&
 No
Example

 Is the following a legitimate predicate calculus symbol?

 George
YES
 Fire3
YES
 science!!!
No
 ahmd_and_salem
YES
 3jack
No
 bill
YES
 XXXX
YES
 Cheating not allowed
No
 friends_of
YES
 ab%cd
No
Predicate Calculus Symbols (ii)

 Parentheses “( )”, commas “,”, and periods “.” are used solely to
construct well-formed expressions and do not denote objects or
relations in the world. These are called improper symbols.

 Predicate calculus symbols may represent either variables,


constants, functions, or predicates.
Predicate Calculus Symbols
(iii)
 Predicate calculus symbols include:
 Truth symbols: true and false (these are reserved symbols).
 Constant symbols: symbol expressions having the first character lowercase.
 Variable symbols: symbol expressions beginning with an uppercase character.
 Function symbols: symbol expressions having the first character lowercase.

 Every function symbol has an associated arity, indicating the number of


elements in the domain mapped onto each element of the range.

 A function expression is a function symbol followed by its arguments.


i.e., it consists of a function constant of arity n, followed by n terms (t 1, t2
,…, tn) enclosed in parentheses and separated by commas.
Predicate Calculus Terms

 A predicate calculus term is either a constant, variable, or


function expression. It may be used to denote objects and
properties in a problem domain.

 Examples of terms are:


 cat
 times(2,3)
X
 Blue
 mother(sarah)
 kate
Predicates

 Symbols in predicate calculus may also represent predicates.


 Predicate symbols, like constants and function names, begin with a lowercase letter.
 A predicate names a relationship between zero or more objects in the world.
 The number of objects so related is the arity of the predicate.
 Predicates with the same name but different arities are considered distinct.
 Examples of predicates are:
 likes
 equals
 on
 near
 part_of
Atomic Sentences

 Atomic sentence
 Is the most primitive unit of the predicate calculus language.
 It is a predicate of arity n followed by n terms enclosed in parentheses and
separated by commas.
 The truth values, true and false, are also atomic sentences
 Atomic sentences are also called atomic expressions, atoms, or
propositions

 We may combine atomic sentences using logical operators to


form sentences in the predicate calculus. These are the same
logical connectives used in propositional calculus
(∧, ∨, ¬ , →, and ≡)
Examples of Atomic Sentences

 Examples of atomic sentences are:


 likes(george,kate)
 likes(george,susie)
 likes(X,george)
 likes(X,X)
 likes(george,sarah,tuesday)
 friends(bill,richard)
 friends(bill,george)
 friends(father_of(david),father_of(andrew))
 helps(bill,george)
 helps(richard,bill)
Universal and Existential Quantifiers

 The universal quantifier,∀, indicates that the sentence is true for


all values of the variable.
 In the example, ∀X likes(X, ice_cream) is true for all values in the
domain of the definition of X.

 The existential quantifier,∃, indicates that the sentence is true


for at least one value in the domain.
 For examle ∃ Y friends(Y, peter) is true if there is at least one object,
indicated by Y that is a friend of peter.
Syntax of First Order Logic: Quantifiers

For the universal quantifier For the existential quantifier


 ⇒ is the main connective with  ∧ is the main connective with
(∀). (∃)

 E.g.: ∀x At(x,Egypt) ⇒ Smart(x)  E.g. ∃xAt(x, Egypt) ∧ Smart(x)


means: means “there are students at
“everyone that is at Egypt is smart” Egypt that are smart”
PREDICATE CALCULUS SENTENCES

 Every atomic sentence is a sentence.

 If s is a sentence, then so is its negation, ¬ s.

 If s1 and s2 are sentences, then so is their conjunction, s1 ∧ s2.


 If s1 and s2 are sentences, then so is their disjunction, s1 ∨ s2.
 If s1 and s2 are sentences, then so is their implication, s1 → s2.
 If s1 and s2 are sentences, then so is their equivalence, s1 ≡ s2.
 If X is a variable and s a sentence, then ∀ X s is a sentence.
 If X is a variable and s a sentence, then ∃ X s is a sentence.
Verify _ Sentence Algorithm
A Family Relationships

 An Example of the use of predicate calculus to describe a simple


world. The domain of discourse is a set of family relationships in
a biblical genealogy:

 mother(eve, abel)
 mother(eve , cain)
 father(adam , abel)
 father(adam , cain)
 ∀ X ∀ Y father(X, Y) ∨ mother(X, Y) → parent(X, Y)
 ∀ X ∀ Y ∀ Z parent(X, Y) ∧ parent(X, Z) → sibling (Y, Z)
A Semantics for the Predicate Calculus

 Given an interpretation, the meaning of an expression is a truth


value assignment over the interpretation.

 The value of an atomic sentence is either T or F as determined


by the interpretation I
FIRST-ORDER PREDICATE CALCULUS (i)

 First-order predicate calculus allows quantified variables to


refer to objects in the domain of discourse and not to predicates
or functions.

 For example,∀(Likes) Likes(george,kate)


is not a well-formed expression in the first-order predicate
calculus.

 There are higher-order predicate calculi where such expressions


are meaningful.
FIRST-ORDER PREDICATE CALCULUS (ii)

 Examples of English sentences represented in predicate calculus are:

 If it doesn’t rain on Monday, Tom will go to the mountains.


¬ weather(rain, monday)→go(tom, mountains)

 Emma is a Doberman pinscher and a good dog.


gooddog(emma) ∧ isa(emma, doberman)

 All basketball players are tall.


∀ X (basketball_player(X)→tall(X))

 Some people like anchovies.


∃ X (person(X) ∧ likes(X, anchovies))

 If wishes were horses, beggars would ride.


equal(wishes, horses)→ride(beggars)

 Nobody likes taxes.


¬ ∃ X likes(X, taxes)
Example (i)

 Everybody likes some food.


X F food(F)  likes (X,F)

 There is a food that everyone likes.


F X food(F)  likes (X,F)

 Whenever someone eats a spicy dish, they’re happy.


X F food(F)  spicy(F)  eats (X,F)  happy(X)

 John’s meals are spicy.


X meal_of(John,X)  spicy(X)

 Every city has a dogcatcher who has been bitten by every dog in town.
∀x City(x) ⇒ [∃y DogCatcher(y)∧[∀z Dog(z)∧LivesIn(z, x) ⇒ BittenBy(y, z)]]
Example (iii)

Consider the following axioms:


1. All hounds howl at night.
2. Anyone who has any cats will not have any mice.
3. Light sleepers do not have anything which howls at night.
4. Ali has either a cat or a hound.

Translate each of the above axioms into a well formed formula


(WFF).

Given the fact that Ali is a light sleeper, Does Ali have mice?
Explain.
Answer

1. ∀x(Hound(x) → Howl(x))

2. ∀x∀y(Have(x, y) ∧ Cat(y) → ¬∃z(Have(x, z) ∧ Mouse(z)))

3. ∀x(LS(x) → ¬∃y(Have(x, y) ∧ Howl(y)))

4. ∃x(Have(Ali , x) ∧ (Cat(x) ∨ Hound(x)))

5. LS(Ali ) → ¬∃z(Have(Ali , z) ∧ Mouse(z))


Unification

 Unification is an algorithm for determining the substitutions needed to make two


predicate calculus expressions match.

 Unification specifies conditions under which two (or more) predicate calculus
expressions may be said to be equivalent.

 Because p(X) and p(Y) are equivalent, Y may be substituted for X to make the
sentences match.

 Unification is complicated by the fact that a variable may be replaced by any term,
including other variables and function expressions of arbitrary complexity. These
expressions may themselves contain variables.
Examples

 Unify p(a,X) and p(a,b)


answer: b/X p(a,b)

 Unify p(a,X) and p(Y,b)


answer: a/Y, b/X p(a,b)

 Unify p(a,X) and p(Y, f(Y))


answer: a/Y, f(a)/X p(a,f(a))

 Unify p(a,X) and p(X,b)


Failure

 Unify p(a,X) and p(Y,b)


answer: a/Y, b/X p(a,b)

 Unify p(a,b) and p(X,X)


Failure

 Unify p(X, f(Y), b) and P(X, f(b), b)


answer: b/Y

You might also like