SlideShare une entreprise Scribd logo
1  sur  87
Rushdi Shams, Dept of CSE, KUET, Bangladesh 1
Knowledge Representation IIKnowledge Representation II
LogicsLogics
Artificial IntelligenceArtificial Intelligence
Version 1.0Version 1.0
There are 10 types of people in this world- who understand binaryThere are 10 types of people in this world- who understand binary
and who do not understand binaryand who do not understand binary
Rushdi Shams, Dept of CSE, KUET, Bangladesh 2
Propositional LogicPropositional Logic
Rushdi Shams, Dept of CSE, KUET, Bangladesh 3
Introduction
Need formal notation to represent knowledge,
allowing automated inference and problem solving.
One popular choice is use of logic.
Propositional logic is the simplest.
Symbols represent facts: P, Q, etc..
These are joined by logical connectives (and, or,
implication) e.g., P Λ Q; Q ⇒ R
Given some statements in the logic we can deduce new
facts (e.g., from above deduce R)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 4
Syntactic Properties of
Propositional Logic
If S is a sentence, ¬S is a sentence (negation)
If S1 and S2 are sentences, S1 ∧ S2 is a sentence
(conjunction)
If S1 and S2 are sentences, S1 ∨ S2 is a sentence
(disjunction)
If S1 and S2 are sentences, S1 ⇒ S2 is a sentence
(implication)
If S1 and S2 are sentences, S1 ⇔ S2 is a sentence
(bi-conditional)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 5
Semantic Properties of
Propositional Logic
¬S is true iff S is false
S1 ∧ S2 is true iff S1 is true and S2 is true
S1 ∨ S2 is true iff S1is true or S2 is true
S1 ⇒ S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2is false
S1 ⇔ S2is true iff S1⇒S2 is true and
S2⇒S1 is true
Rushdi Shams, Dept of CSE, KUET, Bangladesh 6
Truth Table for Connectives
Rushdi Shams, Dept of CSE, KUET, Bangladesh 7
Model of a Formula
If the value of the formula X holds 1 for the
assignment A, then the assignment A is called model
for formula X.
That means, all assignments for which the formula X
is true are models of it.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 8
Model of a Formula
Rushdi Shams, Dept of CSE, KUET, Bangladesh 9
Model of a Formula:
Can you do it?
Rushdi Shams, Dept of CSE, KUET, Bangladesh 10
Satisfiable Formulas
If there exist at least one model of a formula then the
formula is called satisfiable.
The value of the formula is true for at least one
assignment. It plays no rule how many models the
formula has.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 11
Satisfiable Formulas
Rushdi Shams, Dept of CSE, KUET, Bangladesh 12
Valid Formulas
A formula is called valid (or tautology) if all
assignments are models of this formula.
The value of the formula is true for all assignments. If
a tautology is part of a more complex formula then
you could replace it by the value 1.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 13
Valid Formulas
Rushdi Shams, Dept of CSE, KUET, Bangladesh 14
Unsatisfiable Formulas
A formula is unsatisfiable if none of its
assignment is true in no models
Rushdi Shams, Dept of CSE, KUET, Bangladesh 15
Logical equivalence
Two sentences are logically equivalent iff true in same models: α ≡ ß
iff α╞ β and β α╞
Rushdi Shams, Dept of CSE, KUET, Bangladesh 16
Deduction: Rule of Inference
1. Either cat fur was found at the scene of the crime, or dog fur was
found at the scene of the crime. (Premise)
C v D
Rushdi Shams, Dept of CSE, KUET, Bangladesh 17
Deduction: Rule of Inference
2. If dog fur was found at the scene of the crime, then officer
Thompson had an allergy attack. (Premise)
D A→
Rushdi Shams, Dept of CSE, KUET, Bangladesh 18
Deduction: Rule of Inference
3. If cat fur was found at the scene of the crime, then Macavity is
responsible for the crime. (Premise)
C M→
Rushdi Shams, Dept of CSE, KUET, Bangladesh 19
Deduction: Rule of Inference
4. Officer Thompson did not have an allergy attack. (Premise)
¬ A
Rushdi Shams, Dept of CSE, KUET, Bangladesh 20
Deduction: Rule of Inference
5. Dog fur was not found at the scene of the crime. (Follows from 2
D A→ and 4. ¬ A). When is ¬ A true? When A is false- right?
Now, take a look at the implication truth table. Find what is the
value of D when A is false and D A→ is true
¬ D
Rushdi Shams, Dept of CSE, KUET, Bangladesh 21
Rules for Inference:
Modus Tollens
If given α β→
and we know ¬β
Then ¬α
Rushdi Shams, Dept of CSE, KUET, Bangladesh 22
Deduction: Rule of Inference
6. Cat fur was found at the scene of the crime. (Follows from 1
C v D and 5 ¬ D). When is ¬ D true? When D is false- right?
Now, take a look at the OR truth table. Find what is the value of
C when D is false and C V D is true
C
Rushdi Shams, Dept of CSE, KUET, Bangladesh 23
Rules for Inference:
Disjunctive Syllogism
If given α v β
and we know ¬α
then β
If given α v β
and we know ¬β
then α
Rushdi Shams, Dept of CSE, KUET, Bangladesh 24
Deduction: Rule of Inference
7. Macavity is responsible for the crime. (Conclusion. Follows from
3 C M→ and 6 C). When is C M→ true given that C is true?
Take a look at the Implication truth table.
M
Rushdi Shams, Dept of CSE, KUET, Bangladesh 25
Rules for Inference:
Modus Ponens
If given α β→
and we know α
Then β
Rushdi Shams, Dept of CSE, KUET, Bangladesh 26
Conjunctive Normal Form (CNF)
A formula is in conjunctive normal form (CNF) if it is
a conjunction (AND) of clauses, where a clause is a
disjunction (OR) of literals or a single literal.
It is similar to the canonical product of sums form
used in circuit theory
All of the following formulas are in CNF:
Rushdi Shams, Dept of CSE, KUET, Bangladesh 27
Conjunctive Normal Form (CNF)
The following formulae are not in CNF:
The above three formulas are respectively equivalent
to the following three formulas that are in conjunctive
normal form:
Rushdi Shams, Dept of CSE, KUET, Bangladesh 28
Conjunctive Normal Form (CNF)
Eliminate implication with its equivalence. This will
turn P Q into ¬ P V Q→
Use de Morgan's law to move the ¬ symbol onto
atoms (not sentences), replace:
Perform the following operation:
Rushdi Shams, Dept of CSE, KUET, Bangladesh 29
CNF
(p ^ ~q) V (r V s) ^ (r V t)
(p V r V s ) ^ (p V r V t) ^ (~q V r V s)^(~q V r V t)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 30
Horn Clause
 A Horn clause is a clause with at most one positive
literal.
 Any Horn clause therefore belongs to one of four
categories:
1. A rule: 1 positive literal, at least 1 negative literal. A
rule has the form "~P1 V ~P2 V ... V ~Pk V Q".
2. A fact or unit: 1 positive literal, 0 negative literals.
3. A negated goal : 0 positive literals, at least 1 negative
literal.
4. The null clause: 0 positive and 0 negative literals.
Appears only as the end of a resolution proof.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 31
First Order Logic orFirst Order Logic or
First Order Predicate Logic orFirst Order Predicate Logic or
Predicate LogicPredicate Logic
Rushdi Shams, Dept of CSE, KUET, Bangladesh 32
Introduction
Propositional logic is declarative
Propositional logic allows partial/disjunctive/negated
information
(unlike most data structures and databases)
Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
Propositional logic has very limited expressive power
(unlike natural language)
E.g., cannot say “if any student sits an exam they either pass or
fail”.
Propositional logic is compositional
(meaning of B ^ P is derived from meaning of B and of P)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 33
Introduction
You see that we can convert the sentences into
propositional logic but it is difficult
Thus, we will use the foundation of propositional
logic and build a more expressive logic
Rushdi Shams, Dept of CSE, KUET, Bangladesh 34
Introduction
Whereas 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, …
Relations: red, round, prime, brother of, bigger than,
part of, comes between, …
Functions: father of, best friend, one more than, plus, …
Rushdi Shams, Dept of CSE, KUET, Bangladesh 35
Syntax of FOL: Basic Elements
Constants KingJohn, 2, NUS,...
Predicates Brother, >,...
Functions Sqrt, LeftLegOf,...
Variables x, y, a, b,...
Connectives ¬, ⇒, ∧, ∨, ⇔
Equality =
Quantifiers ∀, ∃
Rushdi Shams, Dept of CSE, KUET, Bangladesh 36
Examples
King John and Richard the Lion heart are
brothers
Brother(KingJohn,RichardTheLionheart)
The length of left leg of Richard is greater than
the length of left leg of King John
> (Length(LeftLegOf(Richard)),
Length(LeftLegOf(KingJohn)))
Rushdi Shams, Dept of CSE, KUET, Bangladesh 37
Atomic Sentences
Rushdi Shams, Dept of CSE, KUET, Bangladesh 38
Atomic Sentences
Rushdi Shams, Dept of CSE, KUET, Bangladesh 39
Complex Sentences
Complex sentences are made from atomic sentences using
connectives:
¬S, S1∧ S2, S1∨ S2, S1⇒ S2, S1⇔S2,
Example
Sibling(KingJohn,Richard) ⇒ Sibling(Richard,KingJohn)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 40
Complex Sentences
Rushdi Shams, Dept of CSE, KUET, Bangladesh 41
FOL illustrated
 Five objects-
1. Richard the Lionheart
2. Evil King John
3. Left leg of Richard
4. Left leg of John
5. The crown
Rushdi Shams, Dept of CSE, KUET, Bangladesh 42
FOL illustrated
 Objects are related with
Relations
 For example, King John and
Richard are related with
Brother relationship
 This relationship can be
denoted by
(Richard,John),(John,Richard)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 43
FOL illustrated
 Again, the crown and King
John are related with
OnHead Relationship-
OnHead (Crown,John)
 Brother and OnHead are
binary relations as they
relate couple of objects.
Rushdi Shams, Dept of CSE, KUET, Bangladesh 44
FOL illustrated
 Properties are relations that
are unary.
 In this case, Person can be
such property acting upon
both Richard and John
Person (Richard)
Person (John)
 Again, king can be acted
only upon John
King (John)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 45
FOL illustrated
 Certain relationships are
best performed when
expressed as functions.
 Means one object is related
with exactly one object.
Richard -> Richard’s left leg
John -> John’s left leg
Rushdi Shams, Dept of CSE, KUET, Bangladesh 46
Universal quantification
∀<variables> <sentence>
Everyone studies at KUET is smart:
∀x Studies (x,KUET) ⇒ Smart (x)
∀x P is true in a model m iff P is true with x being each possible
object in the model
Roughly speaking, equivalent to the conjunction of
instantiations of P
Rushdi Shams, Dept of CSE, KUET, Bangladesh 47
Universal quantification
 Remember, we had five
objects, let us replace them
with a variable x-
1. x ―›Richard the Lionheart
2. x ―› Evil King John
3. x ―› Left leg of Richard
4. x ―› Left leg of John
5. x ―› The crown
Rushdi Shams, Dept of CSE, KUET, Bangladesh 48
Universal quantification
 Now, for the quantified
sentence
∀x King (x) ⇒ Person (x)
Richard is king ⇒ Richard is Person
John is king ⇒ John is person
Richard’s left leg is king ⇒ Richard’s
left leg is person
John’s left leg is king ⇒ John’s left leg
is person
The crown is king ⇒ the crown is
person
Rushdi Shams, Dept of CSE, KUET, Bangladesh 49
Universal quantification
Richard is king ⇒ Richard is
Person
John is king ⇒ John is person
Richard’s left leg is king ⇒
Richard’s left leg is person
John’s left leg is king ⇒ John’s left
leg is person
The crown is king ⇒ the crown is
person
Only the second
sentence is correct,
the rest is incorrect
Rushdi Shams, Dept of CSE, KUET, Bangladesh 50
A common mistake to avoid
Typically, ⇒ is the main connective with ∀
Common mistake: using ∧ as the main connective
with ∀:
∀x Studies (x,KUET) ∧ Smart (x)
means “Everyone Studies at KUET and everyone is smart”
Rushdi Shams, Dept of CSE, KUET, Bangladesh 51
Existential Quantification
∃<variables> <sentence>
Someone studies at KUET is smart:
∃x Studies (x,KUET) ∧ Smart (x)
∃x P is true in a model m iff P is true with x being
some possible object in the model
Roughly speaking, equivalent to the disjunction
of instantiations of P
Rushdi Shams, Dept of CSE, KUET, Bangladesh 52
Another common mistake to
avoid
Typically, ∧ is the main connective with ∃
Common mistake: using ⇒ as the main connective with ∃:
∃x Studies (x,KUET) ⇒ Smart (x)
means some guys, if they study in KUET, then they are smart
Rushdi Shams, Dept of CSE, KUET, Bangladesh 53
Properties of quantifiers
∀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
Rushdi Shams, Dept of CSE, KUET, Bangladesh 54
Properties of quantifiers
∃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”
Rushdi Shams, Dept of CSE, KUET, Bangladesh 55
Properties of quantifiers
Quantifier duality: each can be expressed using the other
∀x Likes(x,IceCream) is equivalent to
¬∃x ¬Likes(x,IceCream)
∃x Likes(x,Broccoli) is equivalent to
¬∀x ¬Likes(x,Broccoli)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 56
Properties of quantifiers
 Equivalences-
1. ∃x P is equivalent to ¬∀x ¬P
2. ¬∃x ¬P is equivalent to ∀x P
3. ∃x ¬P is equivalent to ¬∀x P
4. ¬∃x P is equivalent to ∀x ¬P
Rushdi Shams, Dept of CSE, KUET, Bangladesh 57
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(m,y) ∧ Parent(f,y)]
Rushdi Shams, Dept of CSE, KUET, Bangladesh 58
Example knowledge base
The law says that it is a crime for an
American to sell weapons to hostile
nations. The country Nono, an enemy of
America, has some missiles, and all of its
missiles were sold to it by Colonel West,
who is American.
Prove that Col. West is a criminal
Rushdi Shams, Dept of CSE, KUET, Bangladesh 59
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,
Owns(Nono,x)
Missile(x)
… 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)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 60
Forward Chaining
American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒
Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(x,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 61
Forward Chaining
American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒
Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(x,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 62
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z)
⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(x,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 63
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(z) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(x,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 64
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(z) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(x,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 65
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(z) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(x)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 66
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(z) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 67
Forward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 68
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 69
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 70
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 71
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 72
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 73
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 74
Backward Chaining
American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧
Hostile(Nono) ⇒ Criminal(x)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 75
…& the Inference
American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧
Hostile(Nono) ⇒ Criminal(West)
Owns(Nono,x)
Missile(x)
Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono)
Missile(x) ⇒ Weapon(x)
Enemy(Nono,America) ⇒ Hostile(Nono)
American(West)
Enemy(Nono,America)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 76
Probability: Logic forProbability: Logic for
UncertaintyUncertainty
Rushdi Shams, Dept of CSE, KUET, Bangladesh 77
Conditional Probability
Definition of conditional probability:
P(a | b) = P(a ∧ b) / P(b) if P(b) > 0
Product rule gives an alternative formulation:
P(a ∧ b) = P(a | b) P(b) = P(b | a) P(a)

Rushdi Shams, Dept of CSE, KUET, Bangladesh 78
Inference with Probability
Rushdi Shams, Dept of CSE, KUET, Bangladesh 79
Inference in Probability
P(toothache) =
0.108 + 0.012 + 0.016 + 0.064
= 0.2
Rushdi Shams, Dept of CSE, KUET, Bangladesh 80
Inference in Probability
P(cavity V toothache) =
0.108 + 0.012 + 0.072 + .008 +
0.016 + 0.064 = 0.28
Rushdi Shams, Dept of CSE, KUET, Bangladesh 81
Inference in Probability
Can also compute conditional probabilities:
Rushdi Shams, Dept of CSE, KUET, Bangladesh 82
Inference in Probability
Can also compute conditional probabilities:
Rushdi Shams, Dept of CSE, KUET, Bangladesh 83
Baye’s Rule
Product rule gives an alternative formulation:
P(a ∧ b) = P(a | b) P(b)
= P(b | a) P(a)
Joining them together, we can find-
P(a | b) = P(b | a) P(a)
P(b)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 84
Application of Bayes’ Rule
A doctor knows that the disease meningitis causes the patient to
have a stiff neck is 50%
Means probability of stiff neck given the probability of having
meningitis
P(s | m) = 0.5
He also knows that in every 50000 patients, 1 may have meningitis
Means probability that a patient has meningitis
P (m) = 1/50000
He also knows that in every 20 patients, 1 may have stiff neck
Means probability that a patient has meningitis
P (m) = 1/20
Then, from Bayes’ rule
P(m | s) = P(s | m) P(m)
P(s)
Rushdi Shams, Dept of CSE, KUET, Bangladesh 85
Application of Bayes’ Rule
P(m | s) = P(s | m) P(m)
P(s)
= 0.5 X (1/50000)
1/20
= 0.0002
Means he can expect only 1 in 5000 patients with a stiff neck
to have meningitis
Rushdi Shams, Dept of CSE, KUET, Bangladesh 86
References
Artificial Intelligence: A Modern Approach (2nd
Edition)
by Russell and Norvig
Chapter 7, 8, 9, 13
http://www.iep.utm.edu/p/prop-log.htm#H5
http://www.cs.yale.edu/homes/cc392/node5.html
http://www.cs.nyu.edu/courses/spring03/G22.2560-001/ho
Rushdi Shams, Dept of CSE, KUET, Bangladesh 87
Acknowledgement
Dr. Adel Elsayed
Research Leader, M3C Lab, University of Bolton, UK
Weiqiang Wei
PhD Student, University of Bolton, UK

Contenu connexe

Tendances

Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge RepresentationTekendra Nath Yogi
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logicAmey Kerkar
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and LiftingMegha Sharma
 
Artificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real WorldArtificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real Worldahmad bassiouny
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representationSajan Sahu
 
Artificial intelligence and first order logic
Artificial intelligence and first order logicArtificial intelligence and first order logic
Artificial intelligence and first order logicparsa rafiq
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logicgiki67
 
Grover's algorithm simplified.pptx
Grover's algorithm simplified.pptxGrover's algorithm simplified.pptx
Grover's algorithm simplified.pptxSundarappanKathiresa
 
Mrbml004 : Introduction to Information Theory for Machine Learning
Mrbml004 : Introduction to Information Theory for Machine LearningMrbml004 : Introduction to Information Theory for Machine Learning
Mrbml004 : Introduction to Information Theory for Machine LearningJaouad Dabounou
 
Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).munawerzareef
 
Fractional knapsack class 13
Fractional knapsack class 13Fractional knapsack class 13
Fractional knapsack class 13Kumar
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)SHUBHAM KUMAR GUPTA
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Yasir Khan
 
Artificial Intelligence Unit 2
Artificial Intelligence Unit 2Artificial Intelligence Unit 2
Artificial Intelligence Unit 2SURBHI SAROHA
 

Tendances (20)

Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and Lifting
 
Applications of hybrid systems
Applications of hybrid systemsApplications of hybrid systems
Applications of hybrid systems
 
Artificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real WorldArtificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real World
 
Fuzzy inference
Fuzzy inferenceFuzzy inference
Fuzzy inference
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representation
 
First order logic
First order logicFirst order logic
First order logic
 
Artificial intelligence and first order logic
Artificial intelligence and first order logicArtificial intelligence and first order logic
Artificial intelligence and first order logic
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logic
 
Grover's algorithm simplified.pptx
Grover's algorithm simplified.pptxGrover's algorithm simplified.pptx
Grover's algorithm simplified.pptx
 
Mrbml004 : Introduction to Information Theory for Machine Learning
Mrbml004 : Introduction to Information Theory for Machine LearningMrbml004 : Introduction to Information Theory for Machine Learning
Mrbml004 : Introduction to Information Theory for Machine Learning
 
Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).Longest common subsequence(dynamic programming).
Longest common subsequence(dynamic programming).
 
AI 6 | Adversarial Search
AI 6 | Adversarial SearchAI 6 | Adversarial Search
AI 6 | Adversarial Search
 
Fractional knapsack class 13
Fractional knapsack class 13Fractional knapsack class 13
Fractional knapsack class 13
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
 
AI_Session 25 classical planning.pptx
AI_Session 25 classical planning.pptxAI_Session 25 classical planning.pptx
AI_Session 25 classical planning.pptx
 
Artificial Intelligence Unit 2
Artificial Intelligence Unit 2Artificial Intelligence Unit 2
Artificial Intelligence Unit 2
 

En vedette

Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logicRushdi Shams
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translationRushdi Shams
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software failsRushdi Shams
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu schedulingRushdi Shams
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processingRushdi Shams
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating SystemsRushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structureRushdi Shams
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: ParsingRushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semanticsRushdi Shams
 
The uncertainty principle
The uncertainty principleThe uncertainty principle
The uncertainty principlefarman53
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translationRushdi Shams
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AIVishal Singh
 
Risk and Uncertainty
Risk and UncertaintyRisk and Uncertainty
Risk and UncertaintyBrad Stollery
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & ReasoningSajid Marwat
 

En vedette (17)

Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
 
Weka
WekaWeka
Weka
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Semantic networks
Semantic networksSemantic networks
Semantic networks
 
The uncertainty principle
The uncertainty principleThe uncertainty principle
The uncertainty principle
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
 
Risk and Uncertainty
Risk and UncertaintyRisk and Uncertainty
Risk and Uncertainty
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
 

Similaire à Knowledge representation

Gödel’s incompleteness theorems
Gödel’s incompleteness theoremsGödel’s incompleteness theorems
Gödel’s incompleteness theoremsSérgio Souza Costa
 
Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3SURBHI SAROHA
 
Jarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicJarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicPalGov
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSCSSN
 
Predicate_Logic.pdf
Predicate_Logic.pdfPredicate_Logic.pdf
Predicate_Logic.pdfKiranNats
 
GUC_2744_59_29307_2023-02-22T14_07_02.pdf
GUC_2744_59_29307_2023-02-22T14_07_02.pdfGUC_2744_59_29307_2023-02-22T14_07_02.pdf
GUC_2744_59_29307_2023-02-22T14_07_02.pdfChrisRomany1
 
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...Madhav Mishra
 

Similaire à Knowledge representation (15)

Logic 2
Logic 2Logic 2
Logic 2
 
Gödel’s incompleteness theorems
Gödel’s incompleteness theoremsGödel’s incompleteness theorems
Gödel’s incompleteness theorems
 
AI Lesson 17
AI Lesson 17AI Lesson 17
AI Lesson 17
 
L2.pdf
L2.pdfL2.pdf
L2.pdf
 
Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3
 
AppTheories_L3
AppTheories_L3AppTheories_L3
AppTheories_L3
 
Jarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logicJarrar.lecture notes.aai.2011s.ch7.p logic
Jarrar.lecture notes.aai.2011s.ch7.p logic
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Dscrete structure
Dscrete  structureDscrete  structure
Dscrete structure
 
AI Lesson 34
AI Lesson 34AI Lesson 34
AI Lesson 34
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision Making
 
Predicate_Logic.pdf
Predicate_Logic.pdfPredicate_Logic.pdf
Predicate_Logic.pdf
 
GUC_2744_59_29307_2023-02-22T14_07_02.pdf
GUC_2744_59_29307_2023-02-22T14_07_02.pdfGUC_2744_59_29307_2023-02-22T14_07_02.pdf
GUC_2744_59_29307_2023-02-22T14_07_02.pdf
 
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
Applied Artificial Intelligence Unit 2 Semester 3 MSc IT Part 2 Mumbai Univer...
 
Semantics
SemanticsSemantics
Semantics
 

Plus de Rushdi Shams

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchRushdi Shams
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IRRushdi Shams
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101Rushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hackingRushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)Rushdi Shams
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process modelsRushdi Shams
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineeringRushdi Shams
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systemsRushdi Shams
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocksRushdi Shams
 
Lecture 1 and 2 processes
Lecture 1 and 2  processesLecture 1 and 2  processes
Lecture 1 and 2 processesRushdi Shams
 
Lecture 3 and 4 threads
Lecture 3 and 4  threadsLecture 3 and 4  threads
Lecture 3 and 4 threadsRushdi Shams
 
Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Rushdi Shams
 
My slide relational algebra
My slide  relational algebraMy slide  relational algebra
My slide relational algebraRushdi Shams
 

Plus de Rushdi Shams (17)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L3 defense
L3  defenseL3  defense
L3 defense
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
 
Lecture 1 and 2 processes
Lecture 1 and 2  processesLecture 1 and 2  processes
Lecture 1 and 2 processes
 
Lecture 3 and 4 threads
Lecture 3 and 4  threadsLecture 3 and 4  threads
Lecture 3 and 4 threads
 
Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)
 
My slide relational algebra
My slide  relational algebraMy slide  relational algebra
My slide relational algebra
 

Dernier

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Dernier (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Knowledge representation

  • 1. Rushdi Shams, Dept of CSE, KUET, Bangladesh 1 Knowledge Representation IIKnowledge Representation II LogicsLogics Artificial IntelligenceArtificial Intelligence Version 1.0Version 1.0 There are 10 types of people in this world- who understand binaryThere are 10 types of people in this world- who understand binary and who do not understand binaryand who do not understand binary
  • 2. Rushdi Shams, Dept of CSE, KUET, Bangladesh 2 Propositional LogicPropositional Logic
  • 3. Rushdi Shams, Dept of CSE, KUET, Bangladesh 3 Introduction Need formal notation to represent knowledge, allowing automated inference and problem solving. One popular choice is use of logic. Propositional logic is the simplest. Symbols represent facts: P, Q, etc.. These are joined by logical connectives (and, or, implication) e.g., P Λ Q; Q ⇒ R Given some statements in the logic we can deduce new facts (e.g., from above deduce R)
  • 4. Rushdi Shams, Dept of CSE, KUET, Bangladesh 4 Syntactic Properties of Propositional Logic If S is a sentence, ¬S is a sentence (negation) If S1 and S2 are sentences, S1 ∧ S2 is a sentence (conjunction) If S1 and S2 are sentences, S1 ∨ S2 is a sentence (disjunction) If S1 and S2 are sentences, S1 ⇒ S2 is a sentence (implication) If S1 and S2 are sentences, S1 ⇔ S2 is a sentence (bi-conditional)
  • 5. Rushdi Shams, Dept of CSE, KUET, Bangladesh 5 Semantic Properties of Propositional Logic ¬S is true iff S is false S1 ∧ S2 is true iff S1 is true and S2 is true S1 ∨ S2 is true iff S1is true or S2 is true S1 ⇒ S2 is true iff S1 is false or S2 is true i.e., is false iff S1 is true and S2is false S1 ⇔ S2is true iff S1⇒S2 is true and S2⇒S1 is true
  • 6. Rushdi Shams, Dept of CSE, KUET, Bangladesh 6 Truth Table for Connectives
  • 7. Rushdi Shams, Dept of CSE, KUET, Bangladesh 7 Model of a Formula If the value of the formula X holds 1 for the assignment A, then the assignment A is called model for formula X. That means, all assignments for which the formula X is true are models of it.
  • 8. Rushdi Shams, Dept of CSE, KUET, Bangladesh 8 Model of a Formula
  • 9. Rushdi Shams, Dept of CSE, KUET, Bangladesh 9 Model of a Formula: Can you do it?
  • 10. Rushdi Shams, Dept of CSE, KUET, Bangladesh 10 Satisfiable Formulas If there exist at least one model of a formula then the formula is called satisfiable. The value of the formula is true for at least one assignment. It plays no rule how many models the formula has.
  • 11. Rushdi Shams, Dept of CSE, KUET, Bangladesh 11 Satisfiable Formulas
  • 12. Rushdi Shams, Dept of CSE, KUET, Bangladesh 12 Valid Formulas A formula is called valid (or tautology) if all assignments are models of this formula. The value of the formula is true for all assignments. If a tautology is part of a more complex formula then you could replace it by the value 1.
  • 13. Rushdi Shams, Dept of CSE, KUET, Bangladesh 13 Valid Formulas
  • 14. Rushdi Shams, Dept of CSE, KUET, Bangladesh 14 Unsatisfiable Formulas A formula is unsatisfiable if none of its assignment is true in no models
  • 15. Rushdi Shams, Dept of CSE, KUET, Bangladesh 15 Logical equivalence Two sentences are logically equivalent iff true in same models: α ≡ ß iff α╞ β and β α╞
  • 16. Rushdi Shams, Dept of CSE, KUET, Bangladesh 16 Deduction: Rule of Inference 1. Either cat fur was found at the scene of the crime, or dog fur was found at the scene of the crime. (Premise) C v D
  • 17. Rushdi Shams, Dept of CSE, KUET, Bangladesh 17 Deduction: Rule of Inference 2. If dog fur was found at the scene of the crime, then officer Thompson had an allergy attack. (Premise) D A→
  • 18. Rushdi Shams, Dept of CSE, KUET, Bangladesh 18 Deduction: Rule of Inference 3. If cat fur was found at the scene of the crime, then Macavity is responsible for the crime. (Premise) C M→
  • 19. Rushdi Shams, Dept of CSE, KUET, Bangladesh 19 Deduction: Rule of Inference 4. Officer Thompson did not have an allergy attack. (Premise) ¬ A
  • 20. Rushdi Shams, Dept of CSE, KUET, Bangladesh 20 Deduction: Rule of Inference 5. Dog fur was not found at the scene of the crime. (Follows from 2 D A→ and 4. ¬ A). When is ¬ A true? When A is false- right? Now, take a look at the implication truth table. Find what is the value of D when A is false and D A→ is true ¬ D
  • 21. Rushdi Shams, Dept of CSE, KUET, Bangladesh 21 Rules for Inference: Modus Tollens If given α β→ and we know ¬β Then ¬α
  • 22. Rushdi Shams, Dept of CSE, KUET, Bangladesh 22 Deduction: Rule of Inference 6. Cat fur was found at the scene of the crime. (Follows from 1 C v D and 5 ¬ D). When is ¬ D true? When D is false- right? Now, take a look at the OR truth table. Find what is the value of C when D is false and C V D is true C
  • 23. Rushdi Shams, Dept of CSE, KUET, Bangladesh 23 Rules for Inference: Disjunctive Syllogism If given α v β and we know ¬α then β If given α v β and we know ¬β then α
  • 24. Rushdi Shams, Dept of CSE, KUET, Bangladesh 24 Deduction: Rule of Inference 7. Macavity is responsible for the crime. (Conclusion. Follows from 3 C M→ and 6 C). When is C M→ true given that C is true? Take a look at the Implication truth table. M
  • 25. Rushdi Shams, Dept of CSE, KUET, Bangladesh 25 Rules for Inference: Modus Ponens If given α β→ and we know α Then β
  • 26. Rushdi Shams, Dept of CSE, KUET, Bangladesh 26 Conjunctive Normal Form (CNF) A formula is in conjunctive normal form (CNF) if it is a conjunction (AND) of clauses, where a clause is a disjunction (OR) of literals or a single literal. It is similar to the canonical product of sums form used in circuit theory All of the following formulas are in CNF:
  • 27. Rushdi Shams, Dept of CSE, KUET, Bangladesh 27 Conjunctive Normal Form (CNF) The following formulae are not in CNF: The above three formulas are respectively equivalent to the following three formulas that are in conjunctive normal form:
  • 28. Rushdi Shams, Dept of CSE, KUET, Bangladesh 28 Conjunctive Normal Form (CNF) Eliminate implication with its equivalence. This will turn P Q into ¬ P V Q→ Use de Morgan's law to move the ¬ symbol onto atoms (not sentences), replace: Perform the following operation:
  • 29. Rushdi Shams, Dept of CSE, KUET, Bangladesh 29 CNF (p ^ ~q) V (r V s) ^ (r V t) (p V r V s ) ^ (p V r V t) ^ (~q V r V s)^(~q V r V t)
  • 30. Rushdi Shams, Dept of CSE, KUET, Bangladesh 30 Horn Clause  A Horn clause is a clause with at most one positive literal.  Any Horn clause therefore belongs to one of four categories: 1. A rule: 1 positive literal, at least 1 negative literal. A rule has the form "~P1 V ~P2 V ... V ~Pk V Q". 2. A fact or unit: 1 positive literal, 0 negative literals. 3. A negated goal : 0 positive literals, at least 1 negative literal. 4. The null clause: 0 positive and 0 negative literals. Appears only as the end of a resolution proof.
  • 31. Rushdi Shams, Dept of CSE, KUET, Bangladesh 31 First Order Logic orFirst Order Logic or First Order Predicate Logic orFirst Order Predicate Logic or Predicate LogicPredicate Logic
  • 32. Rushdi Shams, Dept of CSE, KUET, Bangladesh 32 Introduction Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information (unlike most data structures and databases) Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power (unlike natural language) E.g., cannot say “if any student sits an exam they either pass or fail”. Propositional logic is compositional (meaning of B ^ P is derived from meaning of B and of P)
  • 33. Rushdi Shams, Dept of CSE, KUET, Bangladesh 33 Introduction You see that we can convert the sentences into propositional logic but it is difficult Thus, we will use the foundation of propositional logic and build a more expressive logic
  • 34. Rushdi Shams, Dept of CSE, KUET, Bangladesh 34 Introduction Whereas 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, … Relations: red, round, prime, brother of, bigger than, part of, comes between, … Functions: father of, best friend, one more than, plus, …
  • 35. Rushdi Shams, Dept of CSE, KUET, Bangladesh 35 Syntax of FOL: Basic Elements Constants KingJohn, 2, NUS,... Predicates Brother, >,... Functions Sqrt, LeftLegOf,... Variables x, y, a, b,... Connectives ¬, ⇒, ∧, ∨, ⇔ Equality = Quantifiers ∀, ∃
  • 36. Rushdi Shams, Dept of CSE, KUET, Bangladesh 36 Examples King John and Richard the Lion heart are brothers Brother(KingJohn,RichardTheLionheart) The length of left leg of Richard is greater than the length of left leg of King John > (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn)))
  • 37. Rushdi Shams, Dept of CSE, KUET, Bangladesh 37 Atomic Sentences
  • 38. Rushdi Shams, Dept of CSE, KUET, Bangladesh 38 Atomic Sentences
  • 39. Rushdi Shams, Dept of CSE, KUET, Bangladesh 39 Complex Sentences Complex sentences are made from atomic sentences using connectives: ¬S, S1∧ S2, S1∨ S2, S1⇒ S2, S1⇔S2, Example Sibling(KingJohn,Richard) ⇒ Sibling(Richard,KingJohn)
  • 40. Rushdi Shams, Dept of CSE, KUET, Bangladesh 40 Complex Sentences
  • 41. Rushdi Shams, Dept of CSE, KUET, Bangladesh 41 FOL illustrated  Five objects- 1. Richard the Lionheart 2. Evil King John 3. Left leg of Richard 4. Left leg of John 5. The crown
  • 42. Rushdi Shams, Dept of CSE, KUET, Bangladesh 42 FOL illustrated  Objects are related with Relations  For example, King John and Richard are related with Brother relationship  This relationship can be denoted by (Richard,John),(John,Richard)
  • 43. Rushdi Shams, Dept of CSE, KUET, Bangladesh 43 FOL illustrated  Again, the crown and King John are related with OnHead Relationship- OnHead (Crown,John)  Brother and OnHead are binary relations as they relate couple of objects.
  • 44. Rushdi Shams, Dept of CSE, KUET, Bangladesh 44 FOL illustrated  Properties are relations that are unary.  In this case, Person can be such property acting upon both Richard and John Person (Richard) Person (John)  Again, king can be acted only upon John King (John)
  • 45. Rushdi Shams, Dept of CSE, KUET, Bangladesh 45 FOL illustrated  Certain relationships are best performed when expressed as functions.  Means one object is related with exactly one object. Richard -> Richard’s left leg John -> John’s left leg
  • 46. Rushdi Shams, Dept of CSE, KUET, Bangladesh 46 Universal quantification ∀<variables> <sentence> Everyone studies at KUET is smart: ∀x Studies (x,KUET) ⇒ Smart (x) ∀x P is true in a model m iff P is true with x being each possible object in the model Roughly speaking, equivalent to the conjunction of instantiations of P
  • 47. Rushdi Shams, Dept of CSE, KUET, Bangladesh 47 Universal quantification  Remember, we had five objects, let us replace them with a variable x- 1. x ―›Richard the Lionheart 2. x ―› Evil King John 3. x ―› Left leg of Richard 4. x ―› Left leg of John 5. x ―› The crown
  • 48. Rushdi Shams, Dept of CSE, KUET, Bangladesh 48 Universal quantification  Now, for the quantified sentence ∀x King (x) ⇒ Person (x) Richard is king ⇒ Richard is Person John is king ⇒ John is person Richard’s left leg is king ⇒ Richard’s left leg is person John’s left leg is king ⇒ John’s left leg is person The crown is king ⇒ the crown is person
  • 49. Rushdi Shams, Dept of CSE, KUET, Bangladesh 49 Universal quantification Richard is king ⇒ Richard is Person John is king ⇒ John is person Richard’s left leg is king ⇒ Richard’s left leg is person John’s left leg is king ⇒ John’s left leg is person The crown is king ⇒ the crown is person Only the second sentence is correct, the rest is incorrect
  • 50. Rushdi Shams, Dept of CSE, KUET, Bangladesh 50 A common mistake to avoid Typically, ⇒ is the main connective with ∀ Common mistake: using ∧ as the main connective with ∀: ∀x Studies (x,KUET) ∧ Smart (x) means “Everyone Studies at KUET and everyone is smart”
  • 51. Rushdi Shams, Dept of CSE, KUET, Bangladesh 51 Existential Quantification ∃<variables> <sentence> Someone studies at KUET is smart: ∃x Studies (x,KUET) ∧ Smart (x) ∃x P is true in a model m iff P is true with x being some possible object in the model Roughly speaking, equivalent to the disjunction of instantiations of P
  • 52. Rushdi Shams, Dept of CSE, KUET, Bangladesh 52 Another common mistake to avoid Typically, ∧ is the main connective with ∃ Common mistake: using ⇒ as the main connective with ∃: ∃x Studies (x,KUET) ⇒ Smart (x) means some guys, if they study in KUET, then they are smart
  • 53. Rushdi Shams, Dept of CSE, KUET, Bangladesh 53 Properties of quantifiers ∀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
  • 54. Rushdi Shams, Dept of CSE, KUET, Bangladesh 54 Properties of quantifiers ∃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”
  • 55. Rushdi Shams, Dept of CSE, KUET, Bangladesh 55 Properties of quantifiers Quantifier duality: each can be expressed using the other ∀x Likes(x,IceCream) is equivalent to ¬∃x ¬Likes(x,IceCream) ∃x Likes(x,Broccoli) is equivalent to ¬∀x ¬Likes(x,Broccoli)
  • 56. Rushdi Shams, Dept of CSE, KUET, Bangladesh 56 Properties of quantifiers  Equivalences- 1. ∃x P is equivalent to ¬∀x ¬P 2. ¬∃x ¬P is equivalent to ∀x P 3. ∃x ¬P is equivalent to ¬∀x P 4. ¬∃x P is equivalent to ∀x ¬P
  • 57. Rushdi Shams, Dept of CSE, KUET, Bangladesh 57 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(m,y) ∧ Parent(f,y)]
  • 58. Rushdi Shams, Dept of CSE, KUET, Bangladesh 58 Example knowledge base The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American. Prove that Col. West is a criminal
  • 59. Rushdi Shams, Dept of CSE, KUET, Bangladesh 59 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, Owns(Nono,x) Missile(x) … 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)
  • 60. Rushdi Shams, Dept of CSE, KUET, Bangladesh 60 Forward Chaining American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(x,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 61. Rushdi Shams, Dept of CSE, KUET, Bangladesh 61 Forward Chaining American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(x,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 62. Rushdi Shams, Dept of CSE, KUET, Bangladesh 62 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(x,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 63. Rushdi Shams, Dept of CSE, KUET, Bangladesh 63 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(x,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 64. Rushdi Shams, Dept of CSE, KUET, Bangladesh 64 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(x,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 65. Rushdi Shams, Dept of CSE, KUET, Bangladesh 65 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(x) American(West) Enemy(Nono,America)
  • 66. Rushdi Shams, Dept of CSE, KUET, Bangladesh 66 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(z) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 67. Rushdi Shams, Dept of CSE, KUET, Bangladesh 67 Forward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 68. Rushdi Shams, Dept of CSE, KUET, Bangladesh 68 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 69. Rushdi Shams, Dept of CSE, KUET, Bangladesh 69 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 70. Rushdi Shams, Dept of CSE, KUET, Bangladesh 70 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 71. Rushdi Shams, Dept of CSE, KUET, Bangladesh 71 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 72. Rushdi Shams, Dept of CSE, KUET, Bangladesh 72 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,z) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 73. Rushdi Shams, Dept of CSE, KUET, Bangladesh 73 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 74. Rushdi Shams, Dept of CSE, KUET, Bangladesh 74 Backward Chaining American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧ Hostile(Nono) ⇒ Criminal(x) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 75. Rushdi Shams, Dept of CSE, KUET, Bangladesh 75 …& the Inference American(West) ∧ Weapon(y) ∧ Sells(West,y,Nono) ∧ Hostile(Nono) ⇒ Criminal(West) Owns(Nono,x) Missile(x) Missile(x) ∧ Owns(Nono,x) ⇒Sells(West,x,Nono) Missile(x) ⇒ Weapon(x) Enemy(Nono,America) ⇒ Hostile(Nono) American(West) Enemy(Nono,America)
  • 76. Rushdi Shams, Dept of CSE, KUET, Bangladesh 76 Probability: Logic forProbability: Logic for UncertaintyUncertainty
  • 77. Rushdi Shams, Dept of CSE, KUET, Bangladesh 77 Conditional Probability Definition of conditional probability: P(a | b) = P(a ∧ b) / P(b) if P(b) > 0 Product rule gives an alternative formulation: P(a ∧ b) = P(a | b) P(b) = P(b | a) P(a) 
  • 78. Rushdi Shams, Dept of CSE, KUET, Bangladesh 78 Inference with Probability
  • 79. Rushdi Shams, Dept of CSE, KUET, Bangladesh 79 Inference in Probability P(toothache) = 0.108 + 0.012 + 0.016 + 0.064 = 0.2
  • 80. Rushdi Shams, Dept of CSE, KUET, Bangladesh 80 Inference in Probability P(cavity V toothache) = 0.108 + 0.012 + 0.072 + .008 + 0.016 + 0.064 = 0.28
  • 81. Rushdi Shams, Dept of CSE, KUET, Bangladesh 81 Inference in Probability Can also compute conditional probabilities:
  • 82. Rushdi Shams, Dept of CSE, KUET, Bangladesh 82 Inference in Probability Can also compute conditional probabilities:
  • 83. Rushdi Shams, Dept of CSE, KUET, Bangladesh 83 Baye’s Rule Product rule gives an alternative formulation: P(a ∧ b) = P(a | b) P(b) = P(b | a) P(a) Joining them together, we can find- P(a | b) = P(b | a) P(a) P(b)
  • 84. Rushdi Shams, Dept of CSE, KUET, Bangladesh 84 Application of Bayes’ Rule A doctor knows that the disease meningitis causes the patient to have a stiff neck is 50% Means probability of stiff neck given the probability of having meningitis P(s | m) = 0.5 He also knows that in every 50000 patients, 1 may have meningitis Means probability that a patient has meningitis P (m) = 1/50000 He also knows that in every 20 patients, 1 may have stiff neck Means probability that a patient has meningitis P (m) = 1/20 Then, from Bayes’ rule P(m | s) = P(s | m) P(m) P(s)
  • 85. Rushdi Shams, Dept of CSE, KUET, Bangladesh 85 Application of Bayes’ Rule P(m | s) = P(s | m) P(m) P(s) = 0.5 X (1/50000) 1/20 = 0.0002 Means he can expect only 1 in 5000 patients with a stiff neck to have meningitis
  • 86. Rushdi Shams, Dept of CSE, KUET, Bangladesh 86 References Artificial Intelligence: A Modern Approach (2nd Edition) by Russell and Norvig Chapter 7, 8, 9, 13 http://www.iep.utm.edu/p/prop-log.htm#H5 http://www.cs.yale.edu/homes/cc392/node5.html http://www.cs.nyu.edu/courses/spring03/G22.2560-001/ho
  • 87. Rushdi Shams, Dept of CSE, KUET, Bangladesh 87 Acknowledgement Dr. Adel Elsayed Research Leader, M3C Lab, University of Bolton, UK Weiqiang Wei PhD Student, University of Bolton, UK