Upload
others
View
12
Download
0
Embed Size (px)
Citation preview
ARTIFICIAL
INTELLIGENCE
LECTURE # 04
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 1
Review of Last Lecture
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 2
Review
• Reasoning
• Types of Reasoning
• Logic
• Propositional Logic
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 3
Today’s Lecture
• Review of previous lecture
• Limitations of Propositional Logic
• Predicate Calculus
• First Order Predicate Logic
• First Order Predicate Logic Constructs
• Inference Rules
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 4
Limitations of Propositional Logic
We Can’t describe things in terms of their properties or relationships (very limited expressive power)
Propositional logic is declarative Propositional logic is compositional.
We can’t express rules or generalizations
If the train is late and there are no taxis, john is late for the meeting If trains are late and there are no taxis, anyone traveling by trains is late
for the meeting…
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 5
Limitations…
• Propositions can only represent knowledge as complete sentences, e.g.
• a = the ball’s color is blue. • Cannot analyze the internal structure of the sentence.
• No quantifiers are available, e.g. for-all, there-exists • Propositional logic provides no framework for proving statements
such as: • All humans are mortal • All women are humans • Therefore, all women are mortals
• This is a limitation in its representational power.
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal 6
Predicate Calculus
• Provides a richer modeling language
• We have objects and properties
• We have relationships between objects
• We have quantification – an ability to refer to all or some objects
Retain connectives such as ~ =
Instead of looking at sentences that are of interest merely for their
truth values, predicate calculus is used to represent statements
about specific objects or individuals .
Examples of individuals:
you, this page of lecture, the number 1, Socrates
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 7
Predicate Calculus (cont.)
A predicate is that which says something about the subject.
e. g., The book is red.
subject color of the book
represented as:
is-red(book) or simply red(book)
is-red: predicate
book: argument
· A predicate statement takes the value true or false .
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 8
Predicate Calculus (cont.)
• red(book) is true if the book is red, false if it is not, then ~red( book) becomes false.
• Predicate with one argument is called a 1- place predicate.
• A predicate can have more than 1 argument: e. g., color( book, red)
mother( john, mary)
greater- than( 7, 4)
• The number of arguments of a predicate is called its arity.
• book, red, john, mary, 7, 4 … are constants.
• We need variables and quantifiers to express sentences such as
“Everyone likes ice cream”
“Ali has some friends”
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 9
Predicate Calculus (cont.)
• " for all, for every (universal quantifier) • $ there exists (some) (existential quantifier )
Examples:
"X likes(X, ice_ cream)
$Y friends(Y, Ali)
• The quantifier specifies the extension of the variable (the total number of objects it applies, or the range of values it can take).
• . Universal and existential quantifiers allow expressing general rules with variables
• Universal quantification
• All cats are mammal • It is equivalent to the conjunction of all the sentences obtained by
substitution the name of an object for the variable x.
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 10
Predicate Calculus (cont.)
• Functions -- have a fixed number of arguments (arity)
-- return (or evaluate to) objects instead of truth values.
e. g., uncle- of( mary) = john
plus( 4, 3) = 7
• Arguments can be constants, variables, or functions.
e. g., father- of( father- of( john))
• Sometime we use something called a term , which is either a constant, variable, or function expression
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 11
Quantification: Existential
• Existential quantification : • an existentially quantified sentence is true in case one of the
disjunct is true
$ x Sister(x, Ibrahem) // $ : There exists
• Equivalent to disjunction: Sister(fatima, ibrahem) V
Sister(zainab, ibrahem) V
Sister(kalsoom, ibrahem)
…
• We can mix existential and universal
quantification.
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 12
Predicate Calculus Syntax
• Every atomic sentence is a sentence.
• If s is a sentence, so is ~s.
• If s1 and s2 are sentences, so is s1 s2 ;
.… so is s1 s2 ;
.… so is s1 s2 ;
.… so is s1 = s2 ;
• If X is a variable and s a sentence, then "X s is a sentence.
• .… then $X s is a sentence.
• For example:
"X "Y father( X, Y) mother( X, Y) parent( X, Y)
is a well- formed predicate calculus sentence.
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 13
First-order logic
• Simplest form of predicate logic,
• Propositional logic assumes the world contains facts
• First-order logic (like natural language) assumes the world contains • Objects: people, houses, numbers, colors, baseball games, wars,
centuries…
• properties: blue, small, tall, ugly, ...
• Relations: prime, brother of, bigger than, part of, comes between, bogus …
• Functions: father of, best friend, third inning of, one more than, plus, …
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 14
FOPC
• The main types of symbols used are • Constant: name specific object
• Predicates: a fact or predicate is divided into 2 parts. • Predicate: the assertion of the proposition
• Argument: the object of the proposition.
• E.g. “Ali likes bananas” in predicate logic will b,
• Likes( Ali, bananas),
• Variables: use for general representation of objects • Likes ( X, Y),
• Formula: combine predicate and quantifiers to represent information.
• Connectives: ^, v, ~,
• Quantifiers: $, "
• Function: father(x) = y: A function that specifies the unique element, that is the father of Ali
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 15
Predicates, variables, functions, constants, connectives, quantifiers
Constants: (first letter small)
bLUE a color
sanTRO a car
crow a bird
Variables: (first letter capital)
Represent general class of objects/properties
Dog: an element that is a dog, but unspecified
Color: an unspecified color
FOL: Basic Elements
Function (evaluates to a constant / variable)Maps Sentences to Objects
• Denote a mapping 4m the domain of function to range of function.
Ali is father of Babar father(babar) = ali
Babar is son of Ali son(ali) = babar
• If you write father(baber), the answer should be ali
• For the above functions the arity is 1 (number of arguments to the function)
• We can have functions with arity > 1, e.g. student(amar, mcs)
FOL: Basic Elements
Functions:
1) ali likes akram likes(ali) = akram
2) atif likes abid likes(atif) = abid
3) Constants to Variables likes(X) = Y
{X,Y} have two possible BINDINGS
{X, Y} could be {ali, akram}
Or
{X,Y} could be {atif, abid}
FOL: Basic Elements
Predicate
Maps Sentences to Truth Values (True/False)
Predicate name a relationship b/w zero or more
objects in the world. (arity)
1) Shahid is student student(shahid)
2) Sana is a girl girl(sana)
3) Father of baber is elder than Hamza elder(father(babar),
hamza)
For 1 and 2 arity is 1 and for 3 the arity is 2
FOL: Basic Elements
Predicate
1) Shahid is a good student
student(shahid,good) or good_student(shahid) or
is_good(shahid,student)
2) Sana is a friend of Saima, Sana and Saima both are
girls
friend_of(sana,saima)^girl(sana)^girl(saima)
3) Bill helps Fred
helps(bill,fred)
FOL: Basic Elements
Connectives:
^ and
v or
~ not
Implication
Quantification
To express sentences like:
All persons can see
There is a person who cannot see
Use:
Universal quantifiers " (ALL)
Existential quantifiers $ (There exists)
FOL: Basic Elements
Complex sentences
• Complex sentences are made from atomic sentences using
connectives
S, S1 S2, S1 S2, S1 S2, S1 S2,
sibling(ali,hamza) sibling(hamza,ali)
>(1,2) ≤ (1,2) (1 is greater than 2 or less than equal
to 2)
>(1,2) >(1,2) (1 is greater than 2 and is not
greater than equal to 2)
Universal quantification • "<variables> <sentence>
Every girl at UOG is smart:
"X at(X, uog) smart(X)
• Roughly speaking, equivalent to the conjunction of instantiations of P
at(rabia,uog) smart(rabia)
at(safia,uog) smart(safia)
at(amna,uog) smart(amna)
…
• Typically, is the main connective with ".
• Common MISTAKE: ^ is main connective with ".
• "X at(X, uog) smart(X)
• Every girl is at UOG and every girl is smart.
Existential quantification
• $<variables> <sentence>
• Some boys at UOG are smart:
$X at(X,UOG) smart(X)
• Roughly speaking, equivalent to the disjunction of instantiations of P
• at(amir,UOG) smart(amir)
at(bashir,UOG) smart(bashir)
at(asim,UOG) smart(asim)
...
• Typically, is the main connective with $ .
Properties of quantifiers
• Quantifiers can be nested E.g. "X $Y or $X "Y
• "X "Y is the same as "Y "X
• $X $Y is the same as $Y $X
• $X "Y is not 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”
Properties of quantifiers (Contd.)
• Quantifier duality: each can be expressed using the other
• "X likes(X,car) $X likes(X,car)
• $X likes(X,bread) "X likes(X,bread)
• "X likes(X,car) $X likes(X,car)
• $X likes(X,bread) "X likes(X,bread)
FOPC Inference Rules
• The ability .to infer new correct expressions from a set of true assertion is an important feature of the predicate calculus
• Allow the deduction of new sentences from previously given sentences.
If we know that [all humans are mortal] is true, and that [Socrates is a human] is true than we can conclude that, [Socrates is mortal] In FOPC. e. g., "X human( X) mortal( X) human( Socrates) It should logically follow that: mortal( Socrates)
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 27
Some rules of inference
• Here are some examples of sound rules of inference • A rule is sound if its conclusion is true whenever the premise is true
• Each can be shown to be sound using a truth table RULE PREMISE CONCLUSION Modus Ponens A, A B B And Introduction A, B A B And Elimination A B A Double Negation A A Unit Resolution A B, B A Resolution A B, B C A C
Some Useful Inference Rules
29
modus ponens (MP)
If P is true and P Q is true
then Q is true
e. g., If we know that “John is an uncle” is true and that “If John is an uncle then John is male ” is true. Then we can conclude that “John is male” is true.
Let P = John is an uncle
Q = John is male
Hence if P is true and P Q is true
then Q is true.
• This is known as the modus ponens rule, or the implication elimination rule.
inference rules
• Modus Ponens (MP)
• Modus pones can also be applied to expression containing variables.??????????????????
"X (man(X) mortal( X)
man(waleed)
It should logically follow that:
mortal(waleed)
P, PQ
____________
Q
inference rules
Modus Tolens
• If X is true then Y is true. ( X Y)
Y is false. ~Y
Therefore X is false. ~A
• Example
• If there is smoke, there is fire. There is not fire, so there is no smoke.
• If I am happy, then I smile. I am not smiling, therefore I am not happy.
if P Q is true and Q is false or ~Q is true
then ~P is true
e. g., sick( student) not_ attend_ lecture( student)
~not_ attend_ lecture( student)
produces: ~sick( student)
31
Inference Rules
Intelligent( Saira) CSMajor (Saira)
___________________________
Intelligent(Saira) ^ CSMajor( Saira)
P Q
__________
P ^ Q
And-Introduction (AI)
Inference Rules
• And-Elimination (AE)
P ^Q
_______
P
Intelligent(Saira) ^ CSMajor( Saira)
___________________________
Intelligent( Saira)
Inference Rules
• Universal Elimination (UE)
• Any universal quantified variable in a true sentence is replaced
by any appropriate term form the domain, the result is a true
sentence.
"x Takes( x , AI) & Intelligent(x)
_______________________
Takes( Pat , AI ) & Intelligent (Pat)
The substitution has to be done by a Ground Term.
Methods of Inference
• Forward Chaining: Starts with the available data and
uses inference rules to extract more data until a goal is
reached.
• Backward Chaining: Starts with a goal and works
backwards from the goal to the facts to see if there is data
available that will support the goal
Forward Chaining
• From "x[man(x) → mortal(x)], we infer that man(Talha) →
mortal(Talha) using UE.
• From man(Talha) and man(Talha) → mortal(Talha), we
infer mortal(Talha) using Modus Ponens.
• We started with the available data and used inference
rules to extract more data until a goal is reached.
Backward Chaining
• We start with goal.
• man(Talha) → mortal(Talha) using UE.
• To show that mortal(Talha), we have to show man(Talha).
• Man(Talha) is given in KB.
• Therefore, mortal(Talha).
• We Started with a goal and worked backwards from the goal to the facts to see if there is data available that will support the goal
Resolution Rule
• Deduction mechanism we discussed above, using the
four rules of inference may be used in practical systems,
but is not feasible. It uses a lot of inference rules that
introduce a large branch factor in the search for a proof.
• An alternative is approach is called resolution, a strategy
used to determine the truth of an assertion, using only
one resolution rule:
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 38
A B
~B C
__________
A C
Resolution-Truth Table
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 39
Conjunctive Normal Form (CNF)
• Resolution requires all sentences to be converted into a
special form called conjunctive normal form (CNF). A
statement in conjunctive normal form (CNF) consists of
ANDs of ORs.
• The outermost structure is made up of conjunctions. Inner
units called clauses are made up of disjunctions. The
components of a statement in CNF are clauses and
literals. A clause is the disjunction of many units. The units
that make up a clause are called literals. And a literal is
either a variable or the negation of a variable.
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 40
Conversion to CNF
• Eliminate arrows (implications)
A B = ~A B
• 2. Drive in negations using De Morgan’s Laws, which are
given below
~(A B) = ~A ~B
• 3. Distribute OR over AND
A (B C) = (A B) (A C)
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 41
Example: CNF
(A B) (C D)
1. ~(A B) (~C D)
2. (~A ~B) (~C D)
3. (~A ~C D) (~b ~C D)
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 42
Resolution by Refutation
• Now, we will look at a proof strategy called resolution
refutation. The steps for proving a statement using
resolution refutation are:
1. Write all sentences in CNF
2. Negate the desired conclusion
3. Apply the resolution rule until you derive a contradiction
or cannot apply the rule anymore.
4. If we derive a contradiction, then the conclusion follows
from the given axioms
5. If we cannot apply anymore, then the conclusion cannot
be proved from the given axioms
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 43
Resolution-Refutation Example 1
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 44
Resolution-Refutation Example 2
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 45
Resolution-Refutation Example 2
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 46
Resolution-Refutation Example 2
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 47
References
• Artificial Intelligence, A modern approach by Russell:
(Chapter # 8,9)
• Artificial Intelligence: Structures and Strategies for
Complex Problem Solving (Chapter # 2)
• Internet
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 48
End of Lecture
Artificial Intelligence 2012 Lecture 04 Delivered By Zahid Iqbal 49