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

AI Lecture 3

Predicate calculus allows for quantification of variables and functions. It represents relationships between objects using predicates and functions. Key concepts include: 1) Predicates take a fixed number of terms as arguments and can be combined with logical operators. 2) Functions map terms to terms and have an associated arity. 3) Quantifiers like ∀ and ∃ allow for statements about all or some objects. 4) Unification matches variables between expressions to determine substitutions that make them equal. 5) Inference rules like modus ponens and modus tollens allow deducing new conclusions.

Uploaded by

Mstafa Mhamad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

AI Lecture 3

Predicate calculus allows for quantification of variables and functions. It represents relationships between objects using predicates and functions. Key concepts include: 1) Predicates take a fixed number of terms as arguments and can be combined with logical operators. 2) Functions map terms to terms and have an associated arity. 3) Quantifiers like ∀ and ∃ allow for statements about all or some objects. 4) Unification matches variables between expressions to determine substitutions that make them equal. 5) Inference rules like modus ponens and modus tollens allow deducing new conclusions.

Uploaded by

Mstafa Mhamad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

• Every function symbol has an associated arity

indicating the number of elements or terms in


the domain mapped onto each element of the
range.
f(x,y) arity 2
father (david) arity 1(unary).
• The term may be constant , variable or
function expression.
Symbols and Terms
• 1- True and False ( Truth symbols)
• 2- Constant symbols
• 3- Variable symbols
• 4- function symbols

• An atomic sentences in predicate calculus is a predicate of arity n


followed by n terms enclosed in parenthesis and separated by
commas. Predicate calculus sentences are delimited by a period.
• E.g.
– like (ahmed , ali). //ahamd like ali
– likes(ali , kamil). //ali like kamil
– .
– .
– friend(bill, goerge). //bill friend goerge
• Atomic sentences are also called atomic
expressions or propositions. We may combine
atomic sentences using logical operator to form
sentences.
• V , ^ , ‫ﬢ‬, ==> and =
• Predicate calculus includes two symbols, the
variable quantifier Ɐ and Ǝ.
• ƎY friends (Y, peter) . (existential quantifier)
• ⱯX Likes (X,ice_cream). (Universal quantifier).
Predicate calculus sentences
• Every atomic sentence is a sentence

1- if S is a sentence then ‫ﬢ‬S

2- if S1 and S2 are sentences then S1^S2

3- if S1 and S2 are sentences then S1 V S2

4- if S1 and S2 are sentences then S1==>S2

5- if S1 and S2 are sentences then S1=S2

6-if X is a variable and S a sentence then ⱯX S is a sentence.

7-if X is a variable and S a sentence then ƎX S is a sentence.


• mother (fatema,ali). //fatema mother ali
• mother (fatema,moh). //fatema mother moh
• father (ahmed, ali). //ahmed father ali
• father (ahmed ,moh). //ahmed father moh
• ⱯX ⱯY father(X,Y) V mother (X,Y) ==> parent(X,Y).
• //if all X is father of Y or all x mother of y
Then all x is parent Y (then used for ==>)
• ⱯX ⱯY ⱯZ parent(X,Y) ^ parent (X,Z) ==> sibling(Y,Z).
• //if all X is parent of Y and all X parent of all Z
Then all Y is sibling Z (Y and Z is sister or brother each other)
Semantics for the predicate calculus
• Predicate calculus semantics provide a formal basis for determining the
truth value of well-formed expressions.

• Examples of English sentences represented in predicate calculus are :

- If it doesn’t rain tomorrow, tom will go to the mountains.


‫ﬢ‬weather (rain , tomorrow) ==> go (tom , mountain).
- All basketball players are tall
ⱯX basketball-player(X) ===> tall(X).
- Some people like fish
Ǝ X person(X) ^likes (X,fish).
- Nobody like Somali
‫ﬢ‬ƎX likes (X, somali).
• on(c,a). //c on a
• on(b,d). //b on d
• ontable(a). //a on table C B
• ontable(d).//d on table
• clear(b). A D
• clear(c).
• hand-empty.

• ⱯX(‫ﬢ‬ƎY on(Y,X) ====> clear(X)).


• //ⱯX=all x ,‫ ﬢ‬ƎY =no Y ,on(Y,X)==no Y on X then clear x
• ⱯXⱯY (hand-empty^ clear(X) ^clear(Y)^ pickup(X) ^
putdown(X,Y))==>stack(X,Y).
• // hand-empty and clear(X) and clear(Y)and pickup(X) and putdown(X,Y))
// putdown(X,Y))==X putdown Y
• //stack(X,Y) ==X stack Y
Unification
• Is an algorithm for determining the
substitutions needed to make two predicate
calculus expressions match.
• Suppose sentences p and q if pɕ=qɕ

p q
ɕ
knows(john , x) knows(john , Jane) { x| Jane}
knows(John , x) knows(y , Oj) {x|Oj, y|John}
knows(John , x) knows(y , mother(y)) {y|John, x|mother(y)}
• Ex. foo(X, a, g(Y))

foo(fred, a, g(z)) { fred|X, z|Y}


foo(w , a, g(jack)) {w|X , jack|Y}
foo(z, a, g(moo(z))) {z|X , moo(z)|Y}

P=q
P=foo(X, a, g(Y))
Q1=foo(fred,a,g(z))  p=q1  foo(X, a, g(Y)) = foo(fred,a,g(z))
Q2=foo(w,a,g(jack))  p=q1  foo(X, a, g(Y)) = foo(w,a,g(jack))
Q3=foo(z,a,g(moo(z))  p=q1  foo(X, a, g(Y)) = foo(z,a,g(moo(z))
Unification algorithm
• Basic idea: can replace variables by:
• other variables
• constants
• function expressions
• High level algorithm:
• Represent the expression as a list
• Process the list one by one
– Determine a substitution (if necessary)
– Apply to the rest of the list before proceeding
Examples with the algorithm
• Unify p(a,X) and p(a,b)
• (p a X) (p a b)
• Unify p(a,X) and p(Y, f(Y))
• (p a X) (p Y (f Y))
• Unify parents(X, father(X), mother(bill)) and
• parents(bill, father(bill), Y)
• (parents X (father X) (mother bill))
• (parents bill (father bill) Y)
function unify code
Processed example
• (parents X (father X) (mother bill)), (parents bill (father bill) Y)
• parents =? Parents yes
• return nil
• (X (father X) (mother bill)), (bill (father bill) Y)
• X =? bill no, substitute
• return {bill/X}
• (bill (father bill) (mother bill)), (bill (father bill) Y)
• bill =? bill yes
• return nil
Processed example (cont’d)
• ( (father bill) (mother bill)), ( (father bill) Y)
• bill =? bill yes
• return nil
• (father bill), (father bill)
• father =? father yes
• return nil
• (bill) (bill)
• bill =? bill yes
• return nil
Processed example (cont’d)
• (mother bill), Y
• (mother bill) =? Y no, substitute
• return {(mother bill) / Y}
• The set of unifying substitutions for
• (parents X (father X) (mother bill)), (parents bill (father bill) Y)
• The result is
• {bill / X, (mother bill) / Y}.
• The result is
• (parents bill (father bill) (mother bill))
Inference rules

• An interpretation that makes a sentence true is said to satisfy


that sentence.The ability to infer new correct expressions
from a set of true assertions.

• An expression X logically follows from a set of predicate


calculus expressions (S) if every interpretation that satisfies S
also satisfies X This notion gives us a basis for verifying the
correctness of rules of inference.

• If the inference rule is able to produce every expression that


logically follows from S, then it is said to be complete , modus
ponens.
• Ex p1=faster (bob , pat)
P2=faster (pat, steve)
p1^ p2 ===>q
= faster(X, Y) ^ faster (Y,Z) ==> faster(X,Z).
{bob|X, pat|Y, steve |Z}
q=faster(bob,steve)
Satisfy, model, valid, inconsistent
• For a predicate calculus expression X and an
interpretation I:
• If X has a value of T under I and a particular
variable assignment, then I is said to satisfy X.
• If I satisfies X for all variable assignments, then
I is a model of X.
• X is satisfiable iff there is an interpretation
and variable assignment that satisfy it;
otherwise it is unsatisfiable.
Satisfy, model, valid, inconsistent
(cont’d)
• A set of expressions is satisfiable iff there is an
interpretation and variable assignment that
satisfy every element.
• If a set of expressions is not satisfiable, it is
said to be inconsistent.
• If X has a value T for all possible
interpretations, X is said to be valid.
Logically follows, sound, and complete
• A predicate calculus expression X logically follows
from a set S of predicate calculus expressions if
every interpretation and variable assignment that
satisfies S also satisfies X.
• An inference rule is sound if every predicate
calculus expression produced by the rule from a
set S of predicate calculus expressions also
logically follows from S.
• An inference rule is complete if, given a set S of
predicate calculus expressions, the rule can infer
every expression that logically follows from S.
Modus ponens and modus tollens
• If the sentences P and P  Q are known to be
true, then modus ponens lets us infer Q.

• If the sentence P  Q is known to be true,


and the sentence Q is known to be false,
modus tollens lets us infer P.
Example
•(S1) If John paid the electricity bill today, then
he would have looked miserable when you
saw him.
•(S2) John did not look miserable when you
saw him.
•(S3) So John did not pay the electricity bill
today.
(2) Validity & Soundness

Modus Tollens
The form of that argument...
If X, then Y
not-Y
So not-X
(2) Validity & Soundness

Example
•(S1) If John paid the electricity bill today, then
we do not have enough money to pay the gas
bill.
•(S2) If we do not have enough money to pay
the gas bill, Lisa will be angry.
•(S3) So if John paid the electricity bill today,
then Lisa will be angry.
Summary
• Propositional calculus: no variables or
functions
• Predicate calculus: allows quantified variables
as parameters of predicates or functions
• Higher order logics: allows predicates to be
variables (might be needed to describe
mathematical properties such as “every
proposition implies itself” or “there are
decidable propositions.)

You might also like