Knowledge Representation and Search:: Artificial Intelligence

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Artificial Intelligence

Knowledge Representation and Search:


PREDICATE LOGIC
Course Contents
Again..Selected topics for our course. Covering all of AI is impossible!

Key topics include:


Introduction to Artificial Intelligence (AI)
Knowledge Representation and Search
Introduction to AI Programming
Problem Solving Using Search
Exhaustive Search Algorithm
Heuristic Search
Techniques and Mechanisms of Search Algorithm
Knowledge Representation Issues and Concepts
Strong Method Problem Solving
Reasoning in Uncertain Situations
Soft Computing and Machine Learning
Basic concepts of logic
• syntax: formal structure of sentences
• semantics: truth of sentences wrt models
• entailment: necessary truth of one sentence
given another
• inference: deriving sentences from other
sentences
• soundness: derivations produce only entailed
sentences
• completeness: derivations can produce all
entailed sentences
Recall: Propositional Logic
First-Order Logic (FOL)
First-Order Logic (FOL)
First Order Predicate Logic
 Includes 2 symbols:
 Variable quantifiers
  (existential) and
  (universal)
 A quantifier followed by a variable and a
sentence:
  X likes(X,pizza) ; true for all X
  Y friends(Y,amir) ; true if there is atleast one
Universal Quantification
Properties of Quantifiers

????
Properties of Quantifiers
Quantifier Duality
Fun with Sentences
Try this…represent in Predicate
Logic
• If it doesn’t rain on Monday, Naim will go to the mountain

• All children are cute

• Nobody likes mouse


Exercise: Translate into Predicate
Logic:

1. If it doesn’t rain today, I will go to


the class.
2. Putih is a siamese and a good cat.
3. All basketball players are tall.
4. Some people like reading.
5. I have a brother who is a teacher.
Applications of First-Order Logic

• Prolog: a logic programming languages


• Production systems
• Semantic nets
• Automated theorem proving
• Planning
Proof methods
Inference rules in propositional
logic
• Here are just a few of the rules you can apply
when reasoning in propositional logic:

From aima.eecs.berkeley.edu/slides-ppt, chs 7-9 17


Proofs
Example Proof

cat cat

cat cat
cat

cat
Example: Translate the KB into
Propositional Logic
 If it is hot and humid, then it is raining. If it is
humid, then it is hot. It is humid.
H It is hot.
D It is humid.
R It is raining.

1. If it is hot and humid, then it is raining


2. If it is humid, then it is hot
3. It is humid
Example: PROOF-Logical Inference
Rules
GOAL-Is it Raining?
1. (H ^ D)  R
2. D  H
3. D

From 2 and 3: by Modus Ponens, we infer:


4. H
From 4: by ^-introduction, we infer:
5. H ^ D
From 1 and 5: by Modus Ponens, we infer:
6. R (Goal -- It is raining)
Search with Primitive Inference
Rules
Search with Primitive Inference
Rules
Unification
Resolution
The magic of resolution
• Here’s how resolution works:
– You transform each of your facts into a particular form, called a clause
(this is the tricky part)
– You apply a single rule, the resolution principle, to a pair of clauses
• Clauses are closed with respect to resolution--that is, when you
resolve two clauses, you get a new clause
– You add the new clause to your fact base
• So the number of facts you have grows linearly
– You still have to choose a pair of facts to resolve
– You never have to choose a rule, because there’s only one

26
The resolution principle
• Here it is:
– From X  someLiterals
and X  someOtherLiterals
----------------------------------------------
conclude: someLiterals 
someOtherLiterals
• That’s all there is to it!
• Example:
– broke(Bob)  well-fed(Bob)
¬broke(Bob)  ¬hungry(Bob)
--------------------------------------
well-fed(Bob)  ¬hungry(Bob)

27
Resolution Proof Tree
Resolution Proof Tree
Clause form
• A clause is a disjunction ("or") of zero or more literals, some or all of which
may be negated.
• Example:

Predicate Form Clause Form


1. ∀ (X) (dog) (X) → animal (X)) ¬ dog (X) ∨ animal (X)
2. dog (fido) dog (fido)
3. ∀ (Y) (animal (Y) → die (Y)) ¬ animal (Y) ∨ die (Y)

• Notice that clauses use only “or” and “not”—they do not use “and,” “implies,”
or either of the quantifiers “for all” or “there exists”
• The impressive part is that any predicate calculus expression can be put into
clause form
– Existential quantifiers, , are the trickiest ones.
Ref: Example of Conversion to Clause Form
30
A first example

• “Everywhere that John goes, Rover goes. John is at


school.”
– at(John, X)  at(Rover, X) (not yet in clause form)
– at(John, school) (already in clause form)
• We use implication elimination to change the first of these
into clause form:
– at(John, X)  at(Rover, X)
– at(John, school)
• We can resolve these on at(-, -), but to do so we have to
unify X with school; this gives:
– at(Rover, school)

31
Refutation resolution

• The previous example was easy because it had very few


clauses
• When we have a lot of clauses, we want to focus our
search on the thing we would like to prove
• We can do this as follows:
– Assume that our fact base is consistent (we can’t
derive NIL)
– Add the negation of the thing we want to prove to the
fact base
– Show that the fact base is now inconsistent
– Conclude the thing we want to prove

32
Example of refutation resolution
• “Everywhere that John goes, Rover goes. John
is at school. Prove that Rover is at school.”
1. at(John, X)  at(Rover, X)
2. at(John, school)
3. at(Rover, school) (this is the added clause)
• Resolve #1 and #3:
4. at(John, X)
• Resolve #2 and #4:
5. NIL
• Conclude the negation of the added clause:
at(Rover, school)

33

You might also like