Ai Unit 4aad
Ai Unit 4aad
Knowledge
-A.A.Deshpande
Knowledge Based Reasoning: Agents
• An intelligent agent needs knowledge about the real world for taking
decisions and reasoning to act efficiently.
• Knowledge-based agents are those agents who have the capability
of maintaining an internal state of knowledge, reason over that
knowledge, update their knowledge after observations and take
actions.
• These agents can represent the world with some formal representation
and act intelligently.
• Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system.
• Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system.
Knowledge-based Agent
• E.g., the KB containing “the Giants won” and “the Reds won”
entails “Either the Giants won or the Reds won”
• E.g., x+y = 4 entails 4 = x+y
Entailment
Inference(Guess,idea,conclusion)
Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true. Slide 99
2. Modus Tollens:
• The Modus Tollens rule states that if P→ Q is true and ¬ Q is true,
then ¬ P will also be true. It can be represented as:
Example:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
5. Addition:
The Addition rule is one the common inference rule, and it states that If
P is true, then P∨Q will be true.
• Example:
• Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will also be
true. It can be represented as:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will
also be true. It can be represented as
Resolution in FOL
• Resolution is a theorem proving technique that proceeds by building
refutation proofs, i.e., proofs by contradictions.
• Resolution is used, if there are various statements given, and we need to
prove a conclusion of those statements.
• Unification is a key concept in proofs by resolutions.
• Resolution is a single inference rule which can efficiently operate on
the conjunctive normal form or clausal form.
• Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known as a
unit clause.
• Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to
be conjunctive normal form or CNF.
• The resolution inference rule:
• The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are
assumed to be standardized apart so that they share no variables.
Variables x, y, z, a, b,....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Term
• A term is a logical expression that refers to an object.
• Constant symbols are therefore terms.
• Expression "King John's left leg“ is converted into Left Leg(John).
• Consider a term = f (d1 ,. . . , dn).
• The function symbol f refers to some function in the model (call it f);
the argument terms refer to objects in the domain (call them d1, . . . ,
dn); and the term as a whole refers to the object that is the value of
the function f applied to d1, . . . , dn.
Atomic Sentences
• These are the symbols that permit to determine or identify the range
and scope of the variable in the logical expression. There are two
types of quantifiers:
• Universal Quantifier, (for all, everyone, everything)
• Existential quantifier, (for some, at least one).
Universal Quantifier:
• ∀ 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”
Examples
1. All birds fly.
In this question the predicate is "fly(bird)."
since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).
2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).
3. Some boys play cricket.
In this question, the predicate is "play(x, y)," Since there are some boys so we will
use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).
(a) Not all cars have carburetors
(b) Some people are either religious or pious
(c) No dogs are intelligent
(d) All babies are illogical
(e) Every number is either negative or has a square root
(f) Some numbers are not real
(g) Every connected and circuit-free graph is a tree
(h) Not every graph is connected
(i) All that glitters is not gold
(j) Not all that glitters is gold
Inference rules in FOL
As propositional logic we also have inference rules in first-order logic, so following
are some basic inference rules in FOL:
• Universal Generalization
• Universal Instantiation
• Existential Instantiation
• Existential introduction
1.Universal Generalization
Universal generalization is a valid inference rule which states that
if premise P(c) is true for any arbitrary element c in the universe of
discourse, then we can have a conclusion as ∀ x P(x).
• It can be represented as:
• This rule can be used if we want to show that every element has
a similar property.
• In this rule, x must not appear as a free variable.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x
P(x) "All bytes contain 8 bits.", it will also be true.
2. Universal Instantiation:
• Universal instantiation is also called as universal elimination or UI is a
valid inference rule. It can be applied multiple times to add new
sentences.
• The new KB is logically equivalent to the previous KB.
• As per UI, we can infer any sentence obtained by substituting a
ground term for the variable.
• The UI rule state that we can infer any sentence P(c) by substituting a
ground term c (a constant within domain x) from ∀ x P(x) for any
object in the universe of discourse.
• It can be represented as:
Example:1.
• IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
Example: 2.
• Let's take a famous example,
• "All kings who are greedy are Evil." So let our knowledge base contains this detail as
in the form of FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
• So from this information, we can infer any of the following statements using
Universal Instantiation:
• King(John) ∧ Greedy (John) → Evil (John),
• King(Richard) ∧ Greedy (Richard) → Evil (Richard),
• King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),
3.Existential Instantiation:
• Existential instantiation is also called as Existential Elimination.
• This rule states that one can infer P(c) from the formula given in the
form of ∃x P(x) for a new constant symbol c.
• The restriction with this rule is that c used in the rule must be a new
term for which P(c ) is true.
• It can be represented as:
4.Existential introduction
Existential introduction
• An existential introduction is also known as an existential
generalization.
• This rule states that if there is some element c in the universe of
discourse which has a property P, then we can infer that there exists
something in the universe which has the property P.
• It can be represented as: