Sec 1 Group 4

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

GROUP ASSIGNMENT OF AI ITec 4151

School of Computing and Informatics

Department of Information Technology

Group Assignment of Artificial Intelligent

Section one Group 4 Course Code: ITec 4151

Title: Predicate (First-order) and Inference in first order logic

Group member

Submission Date: 23/04/2010 Submitted to: Mr.Tefera

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 1


GROUP ASSIGNMENT OF AI ITec 4151

Q1. Predicate (First-order) and inference in first order logic.

First-order logic (like natural language) assumes the world contains


 Objects: people, houses, numbers, colors, baseball games, wars,
 Relations: red, round, prime, brother of, bigger than, part of, comes between
some else
 Functions: father of, best friend, one more than, plus …

In FOL, Sentences are built or made up of terms and atoms:


 A term (denoting a real-world object) is a constant symbol, a variable
Symbol or function. For example, x and f(x1... xn) are terms, where each x is
a term.
 An atom(which has value true or false) is either an n-place predicate
Of n terms, or, if P and Q are atoms, then ~P, P V Q, P ^ Q, P => Q,
P <=> Q are atoms.
 A sentence is an atom, or, if P is a sentence and x is a variable, then
(Ax)P and (Ex) P are sentences.
 A well-formed formula (WFF) is a sentence containing no "free" Variables.
I.e., all variables are "bound" by universal or existential Quantifiers.
E.g., (Ax) P(X,Y)has x bound as a universally quantified variable, but y is
Free.

Syntax of FOL: Basic elements:-


 Constants King John, 2, NUS and others (In this, the constant could be
names ,numbers)
 Predicates Brother, >. (Where as in this predicate the relation between
the constant can enlists).
 Functions Sqrt (the function which could perform by the combination of
both the predicates or relations and constants).
 Variables x, y, a, b,...(those variables play a crucial role to make the
function) to handle some values.
 Connectives (not or negation of (x)), (implies or if then
condition),(this even indicates and ), (or), (by implies or if and only if)
Even those lists connectives and equality are types of relation between the
variables and the constants.
 Equality = (This indicates that the two or more objects are same).
 Quantifiers , 

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 2


GROUP ASSIGNMENT OF AI ITec 4151

Atomic sentences

Atomic sentence = predicate (term1,...,termn) or term1 = term2

Term =function (term1,...,termn) or constant or variable

Example: - Brother (King John, Richard)

Complex sentences

Complex sentences are made from atomic sentences using connectives.

S, S1  S2, S1  S2, S1  S2, S1  S2,

E.g. Sibling (King _John, Richard)  Sibling (Richard, King _John).


 Truth in first-order logic

• Model contains objects (domain elements) and relations among them


• Interpretation specifies referents for
 constant symbols → objects
 predicate symbols → relations
 function symbols → functional relations

• An atomic sentence predicate (term1,...,termn) is true iff the objects referred to by it.
• term1,...,termn are in the relation referred to by predicate.

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 3


GROUP ASSIGNMENT OF AI ITec 4151

Models for FOL: Example

 Universal quantification

• <variables> <sentence>

Everyone at NUS is smart:

X At(x,NUS)  Smart(x)

• X P is true in a model m if P is true with x being each possible object in the


model .
• Roughly speaking, equivalent to the conjunction of instantiations of P.

At (Kingohn,NUS)  Smart(KingJohn)

At(Richard,NUS)  Smart(Richard)

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 4


GROUP ASSIGNMENT OF AI ITec 4151

 Existential quantification

• <variables> <sentence>
• Someone at NUS is smart:
• x At(x,NUS)  Smart(x)
• x P is true in a model m if P is true with x being some possible object in the
model.
• Roughly speaking, equivalent to the disjunction of instantiations of P.

At(KingJohn, NUS)  Smart(KingJohn)

At (Richard,NUS)  Smart(Richard)

At (NUS, NUS)  Smart (NUS)

Properties of quantifiers
 x y is the same as y x
 x y is the same as y x
 x y Loves(x,y)
 “There is a person who loves everyone in the world”.
 y x Loves(x,y)
 “Everyone in the world is loved by at least one person” .
 Quantifier duality: each can be expressed using the other
 x Likes(x, Ice Cream) x Likes(x, Ice Cream)
 x Likes(x, Ice Cream) x Likes(x, Ice Cream)

Equality
 term1 = term2 is true under a given interpretation if and only if term1 and
term2 refer to the same object.
 E.g. definition of Sibling in terms of Parent:
x,y Sibling(x,y)  [(x = y)  m,f  (m = f)  Parent(m,x) 
Parent(f,x)  Parent(x,y)  Parent(f,y)].

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 5


GROUP ASSIGNMENT OF AI ITec 4151

Inference in first order logic


 Inference is the process of deriving a specific sentence from a KB (where the
sentence must be entailed by the KB)
 Universal Substitution
Every Substitution of a universally quantified sentence is entailed by it:
∀ V α/SUBST ({v /g}, α)
For any variable v and ground term g
E.g., ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x)
King (John) ∧ Greedy (John) ⇒ Evil (John)
King (Richard) ∧ Greedy (Richard) ⇒ Evil (Richard)
King (Father (John)) ∧ Greedy (Father (John)) ⇒ Evil (Father (John))

 Existential Substitution
For any sentence α, variable v and constant symbol k that does not appear
elsewhere in the knowledge base:
∃ V α/SUBST ({v /k}, α)
E.g., ∃ x Crown(x) ∧ On Head(x, John) yields
Crown (C1) ∧ On Head (C1, John) provided C1is a new constant symbol, called a
Skolem constant.
Substitution

A substitution in a sentence binds variables to particular values

Example when we say p=teacher(X)

Z={X/Sara}

Pz=teacher (Sara)

 Unification

We can get the inference immediately if we can find a substitution θ such that King(x)
and Greedy(x) match King (John) and Greedy(y)

θ = {x/John,y/John} works
o Unification finds substitutions that make different logical expressions look
identical.
o Standardizing apart eliminates overlap of variables.
o To unify Knows(John,x) and Knows(y,z)

θ = {y/John, x/z } or θ = {y/John, x/John, z/John}


SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 6
GROUP ASSIGNMENT OF AI ITec 4151

• The first unifier is more general than the second.


• There is a single most general unifier (MGU) that is unique up to
renaming of variables.

MGU = (y/John, x/z)

A substitution s unifies sentences p and q if ps = qs.


P Q A
Knows(john, X) Knows(john, Jane) {X/Jane}
Knows(john, X) Knows(Y, yared) {X/ yared,Y/john}
Knows(john, X) Knows(Mother(Y)) {Y/john,X/mother(john)}

Examples

UNIFY(Knows(John,x), Knows(John, Jane)) = {x/Jane}

UNIFY(Knows(John,x), Knows(y,yared)) = {x/yared, y/John}

UNIFY(Knows(John,x), Knows(y,Mother(y))= {y/John, x/Mother(John)


 Use unification in drawing inferences: unify premises of rule with known
facts, and then apply to conclusion.
 If we know q, and Knows (John,x)  Likes(John,x)

Conclude
 Likes(John, Jane)
 Likes(John, yared)
 Likes(John, Mother(John))
 Generalized Modus Ponens(GMP)
p1', p2’, pn’, ( p1 p2 … pnq)/qθwhere pi'θ = piθ for all i
p1' is King (John) p1 is King(x)
p2' is Greedy(y) p2 is Greedy(x)
θ is {x/John,y/John} q is Evil(x)
q θ is Evil (John)
Example
p1’=Faster (Bob, pat)
P2’=Faster (pat, Steve)
P1’n p2=>q=Faster(X, Y) n faster(Y, Z)=>Faster(X, Z)
A={X/Bob, Y/pat/Steve}
Pa=Faster (Bob, Steve)

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 7


GROUP ASSIGNMENT OF AI ITec 4151

Example knowledge base


It is a crime for an American to sell weapons to hostile nations:
American(x)  Weapon(y)  Sells(x, y, z)  Hostile (z)  Criminal(x)
Nono … has some missiles, i.e., x Owns (Nono, x)  Missile(x):
Owns (Nono, M1) and Missile (M1)
… All of its missiles were sold to it by Colonel West
Missile(x)  Owns (Nono, x)  Sells (West, x, Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x, America)  Hostile(x)
West, who is American …
American (West)
The country Nono, an enemy of America …
Enemy (Nono, America)
 Two mechanisms for applying binding to Generalized Modus Ponens
 Forward chaining
 Backward chaining

Forward chaining
o Start with the data (facts) and draw conclusions
o If the other premises are known, then add the conclusion to the KB
and continue chaining.

 Forward chaining is widely used in deductive databases

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 8


GROUP ASSIGNMENT OF AI ITec 4151

Backward chaining
 Start with the query, and try to find facts to support it
 Attempt to prove each premise of the rule by backward chaining

 Widely used for logic programming


 Incomplete due to infinite loops

Resolution
 Resolution allows a complete inference mechanism (search-based) using only one
rule of inference.
 There is a resolution here below
 There is a pit at 2,1 or 2,3 or 1,2 or 3,2
o P21 P23 P12 P32
 There is no pit at 2,1
o P21
 Therefore (by resolution) the pit must be at 2,3 or 1,2 or 3,2
o P23 P12 P32
Proof using Resolution

 To prove a fact P, repeatedly apply resolution until either:


o No new clauses can be added, (KB does not entail P)
o The empty clause is derived (KB does entail P)

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 9


GROUP ASSIGNMENT OF AI ITec 4151

 This is proof by contradiction: if we prove that KB P derives a contradiction


(empty clause) and we know KB is true, then P must be false, so P must be true!
 To apply resolution mechanically, facts need to be in Conjunctive Normal Form
(CNF)
 To carry out the proof, need a search mechanism that will enumerate all possible
resolutions.

CNF Example

1. B22  ( P21 P23 P12 P32 )


2. Eliminate, replacing with two implications

(B22 ( P21P23 P12 P32 ))  ((P21 P23 P12 P32 )B22)


3 Replace implication (A B) by AB

(B22 ( P21P23 P12 P32 ))  ((P21 P23 P12 P32 )B22)


4 Move  “inwards” (unnecessary parents removed)

(B22 P21 P23 P12 P32 )((P21 P23 P12 P32 ) B22)

5 Distributive Law

(B22 P21 P23 P12 P32 ) (P21 B22)  (P23 B22) (P12 B22) (P32 B22)

(Final result has 5 clauses)

Resolution Example

 Given B22 and P21 and P23 and P32 , prove P12
 (B22 P21 P23 P12 P32 ) ; P12
 (B22 P21 P23 P32 ) ; P21
 (B22 P23 P32 ) ; P23
 (B22 P32 ) ; P32
 (B22) ; B22

[Empty clause]

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 10


GROUP ASSIGNMENT OF AI ITec 4151

 This is proof by contradiction: if we prove that KB P derives a contradiction


(empty clause) and we know KB is true, then P must be false, so P must be true!

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 11


GROUP ASSIGNMENT OF AI ITec 4151

Conclusion
First-order logic:
– Objects and relations are semantic primitives.
– Syntax: constants, functions, predicates, equality, quantifiers.

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 12


GROUP ASSIGNMENT OF AI ITec 4151

Reference:
We have referred some webs and others to make or do this assignment from those we refer are:
 some web site like www.tutorialpoint.com
 www.scholar.google.com
 Google like Wikipedia
 Some peoples who are member of our class

SCHOOL OF COMPUTING AND INFORMATICS DEP’T OF INFORMATION TECHNOLOGY Page 13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy