Anda di halaman 1dari 41

ARTIFICIAL

INTELLIGENCE
LECTURE # 03

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Review of Last Lecture

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Todays Lecture
Review of last lecture

Reasoning
Types of Reasoning
Logic

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Reasoning
Reasoning is the process of deriving logical conclusions

from given facts.


Durkin defines reasoning as the process of working with

knowledge, facts and problem solving strategies to draw


conclusions.

Throughout this section, you will notice how representing

knowledge in a particular way is useful for a particular


kind of reasoning.
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Deductive reasoning
As the name implies, is based on deducing new

information from logically related known information.


A deductive argument offers assertions that lead

automatically to a conclusion, e.g.


If there is dry wood, oxygen and a spark, there will be a

fire
Given: There is dry wood, oxygen and a spark
We can deduce: There will be a fire.
All men are mortal. Socrates is a man.
We can deduce: Socrates is mortal
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Inductive Reasoning
Inductive reasoning is based on forming, or inducing a

generalization from a limited set of observations, e.g.


Observation: All the crows that I have seen in my life are
black.
Conclusion: All crows are black

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Comparison of deductive and inductive


reasoning
The inductive reasoning is as follows: By experience,

every time I have let a ball go, it falls downwards.


Therefore, I conclude that the next time I let a ball go, it
will also come down.
The deductive reasoning is as follows: I know Newton's

Laws. So I conclude that if I let a ball go, it will certainly


fall downwards.
Thus the essential difference is that inductive reasoning is

based on experience,
while deductive reasoning is based on rules, hence the

latter will always be correct.


Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Analogical Reasoning
Analogical reasoning works by drawing analogies

between two situations, looking for similarities and


differences, e.g.

when you say driving a truck is just like driving a car, by

analogy you know that there are some similarities in the


driving mechanism,

But you also know that there are certain other distinct

characteristics of each.
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Common-sense Reasoning
Common-sense reasoning is an informal form of

reasoning that uses rules gained through experience or


what we call rules-of-thumb.

It operates on heuristic knowledge and heuristic rules.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

Non-Monotonic Reasoning
Non-Monotonic reasoning is used when the facts of the

case are likely to change after some time, e.g.


Rule:
IF the wind blows

THEN the curtains sway


When the wind stops blowing, the curtains should sway

no longer.
However, if we use monotonic reasoning, this would not

happen. The fact that the curtains are swaying would be


retained even after the wind stopped blowing.
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

10

Logic
Algebra is a type of formal logic deals with number

PROPOSITIONAL LOGIC
PREDICATE CALCULUS/LOGIC

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

11

Proposition
A proposition (p, q, r, ) is simply a statement (i.e., a

declarative sentence) with a definite meaning, having a truth


value thats either true (T) or false (F)

Normally, a proposition is named e.g. P, Q, R etc.


Propositional Logic is the logic of compound statements built

from simpler statements using Boolean connectives.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

12

Proposition
A proposition is a statement about the world that may be either true

or false.

Examples of propositions (properly formed statements):

Alis car is blue.


Seven plus six equals twelve. (7 + 6 = 12)
Amjad is Alis uncle.

Each of the sentences is a proposition - not to be broken

down into its constituent parts. i. e., we simply assign true,


say, to Amjad is Alis uncle.
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

13

Examples of non- propositions


Alis uncle

Seven plus four

Whos there? (interrogative, question)


Just do it! (imperative, command)

1 + 2 (expression with a non-true/false value)

Because we cannot assign truth value to them.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

14

Propositional Symbols
Propositions are denoted by propositional symbols such

as: P, Q, R, S,.
Truth symbols are: true (or T), false (or F).

Single propositions by themselves are not very

interesting.
We need to express complex propositions/compound

propositions:
The book is on the table or it is on the chair.
If Socrates is a man then he is mortal.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

15

Propositional Symbols
We can use logical connecters such as:

...and
...or
...implies
..is equivalent
...not

[conjunction]
[disjunction]
[implication / conditional]
[biconditional]
[negation]

Sentences in the propositional calculus are formed from these atomic

symbols according to the syntax rules.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

16

Operators / Connectives
An operator or connective combines one or more operand

expressions into a larger expression. (E.g., + in numeric


exprs.)

Unary operators take 1 operand (e.g., -3);


Binary operators take 2 operands (eg 3 4).

Propositional or Boolean operators operate on propositions or

truth values instead of on numbers.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

17

The Negation Operator


The unary negation operator (NOT) transforms a prop. into

its logical negation.

E.g. If p = I have brown hair.

then p = I do not have brown hair.

Truth table for NOT:

p p
T F
F T

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

18

The Conjunction Operator


The binary conjunction operator (AND) combines two

propositions to form their logical conjunction.

E.g. If p=I will have salad for lunch. and q=I will have steak

for dinner., then pq=I will have salad for lunch and I will
have steak for dinner.

Conjunction Truth Table

p
F
F
T
T

q
F
T
F
T

pq
F
F
F
T

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

19

The Disjunction Operator


The binary disjunction operator (OR) combines two

propositions to form their logical disjunction.

Example:
p=That car has a bad engine.

q=That car has a bad carburetor.

pq=Either that car has a bad engine, or

that car has a bad carburetor.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

20

The Disjunction Operator


Note that pq means that p is true, or q is true, or both are

true!

So this operation is also called inclusive or, because it includes

the possibility that both p and q are true.

Disjunction Truth Table

p
F
F
T
T

q
F
T
F
T

pq
F
T
T
T

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

21

Examples
Example: BCS AI Class
P = Ali is the teacher

Q = Saira is the student

R= AI is a course teaching in BS

P ^ Q = Ali is the teacher and Saira is the student.


Q ^ R= Saira is the student and tought AI in BS

The book is on the table or it is on the chair.


If Socrates is a man then he is mortal.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

22

A Simple Exercise
Let p=It rained last night,
q=The sprinklers came on last night,
r=The lawn was wet this morning.
Translate each of the following into English:
p

q ^ r

r p
rpq

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

23

The Exclusive Or Operator


The binary exclusive-or operator (XOR) combines two

propositions to form their logical exclusive or.

p = I will earn an A in this course,


q = I will drop this course,

p q = I will either earn an A for this course, or I will drop it

(but not both!)

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

24

Exclusive-Or Truth Table


Note that pq means that p is true, or q is true, but not both!
This operation is called exclusive or, because it excludes the

possibility that both p and q are true.

p
F
F
T
T

q pq
F F
T T
F T
T F

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

25

The Implication Operator


The implication p q states that p implies q.

It is FALSE only in the case that p is TRUE but q is FALSE.


E.g., p=I am elected.

q=I will lower taxes.


p q = If I am elected, then I will lower taxes
Its premise or antecedent is p and its conclusion or consequent

is q

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

26

Implication Truth Table


p q is false only when

p is true but q is not true.

Examples:

p
F
F
T
T

q pq
F
T
T T
F
F
T T

If 1+1=2, then I am richer than Bill Gates. True or False?

If the moon is made of green cheese, then I am richer than Bill

Gates. True or False?

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

27

The Biconditional Operator


The biconditional p q states that p is true if and only if (IFF)

q is true.
It is TRUE when both p q and q p are TRUE.
p = It is raining.
q = The home team wins.

p q = If and only if it is raining, the home team wins.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

28

Biconditional Truth Table

p q means that p and q

have the same truth value.

Note this truth table is the

exact opposite of s!
p q means (p q)

p q does not imply


p and q are true, or cause each other.

p
F
F
T
T

q pq
F T
T F
F F
T T

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

29

Truth Table

p q p q p

p q p q p q

30

Precedence of Logical Operators

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

31

Precedence of Logical Operators


Operator

Precedence

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

32

Some Alternative Notations


Name:
Propositional logic:
Boolean algebra:
C/C++/Java (wordwise):
C/C++/Java (bitwise):

not and or

p pq +
! && ||
~ & |

xor implies

!=
^

iff

==

Logic gates:

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

33

Propositional Calculus Sentences (Syntax)


Every propositional symbol and truth symbol is a sentence.
e. g., true, P, R.
The negation of a sentence is a sentence.
e. g., ~P, ~false
The conjunction of two sentences is a sentence.
e. g., P Q, P Q
The disjunction of two sentences is a sentence.
e. g., Q R
The implication of one sentence for another is a sentence.
e. g., P Q
The equivalence of two sentences is a sentence
e. g., P Q = R

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

34

Exercise
Fact 1: Saira likes cakes. = P

Fact 2: Saira eats cakes. = Q


P Q, PQ, Q, P Q, P Q ????????

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

35

Exercise
Fact 1: Saira likes cakes. = P

Fact 2: Saira eats cakes. = Q


P Q, PQ, Q, P Q, P Q ????????
PQ : Saira Likes cakes or eats cakes.
PQ : Saira likes cakes and eats cakes.
Q : Saira does not eat cakes.
PQ: If Saira likes cakes then he eats cakes.
PQ:Saira eats cakes if and only if he likes cakes.

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

36

Limitations of Propositional logic


We Cant describe things in terms of their properties or

relationships (very limited expressive power)


Propositional logic is declarative
Propositional logic is compositional:

meaning of B1,1 P1,2 is derived from meaning of B1,1 and of

P1,2

We cant 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 03 Delivered By Zahid Iqbal

37

Limitations
Propositions can only represent knowledge as complete sentences,

e.g.
a = the balls 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

38

References
Artificial Intelligence: Structures and Strategies for

Complex Problem Solving


Internet

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

39

End of Lecture

Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

40

Puzzle Game
A farmer went to market and purchased a fox, a goose,

and a bag of beans. On his way home, the farmer came to


the bank of a river and hired a boat. But in crossing the
river by boat, the farmer could carry only himself and a
single one of his purchases - the fox, the goose, or the
bag of the beans.
If left alone, the fox would eat the goose, and the goose

would eat the beans.


The farmer's challenge was to carry himself and his

purchases to the far bank of the river, leaving each


purchase intact. How did he do it?
Artificial Intelligence 2012 Lecture 03 Delivered By Zahid Iqbal

41

Anda mungkin juga menyukai