SlideShare a Scribd company logo
1 of 140
2. KNOWLEDGE BASED AGENTS
Knowledge-based agents; The Wumpus world as an example world; Logic; propositional logic Reasoning patterns in
propositional logic; Effective propositional inference; Agents based on propositional logic. Representation revisited; Syntax
and semantics of first-order logic; Using first-order logic; Knowledge engineering in first-order logic. Propositional versus
first-order inference; Unification and lifting, Forward chaining; Backward chaining; Resolution, Truth maintenance systems.
Knowledge Based Agents in AI
• Knowledge is the basic element for a human brain to know and understand the things logically. When a person becomes
knowledgeable about something, he is able to do that thing in a better way. In AI, the agents which copy such an element of
human beings are known as knowledge-based agents.
• For efficient decision-making and reasoning, an intelligent agent need knowledge about the real world.
• Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system
A knowledge-based agent must able to do the following:
• An agent should be able to represent states, actions, etc.
• An agent Should be able to incorporate new percepts
• An agent can update the internal representation of the world
• An agent can deduce the internal representation of the world
• An agent can deduce appropriate actions.
The above diagram is representing a generalized architecture for a knowledge-based agent. The knowledge-
based agent (KBA) take input from the environment by perceiving the environment. The input is taken by the
inference engine of the agent and which also communicate with KB to decide as per the knowledge store in KB.
The learning element of KBA regularly updates the KB by learning new knowledge.
The architecture of knowledge-based agent:
Knowledge representation language : Knowledge-base is a central component of a knowledge-based agent, it is also known
as KB. It is a collection of sentences (here 'sentence' is a technical term and it is not identical to sentence in English). These
sentences are expressed in a language which is called a knowledge representation language. The Knowledge-base of KBA
stores fact about the world.
Why use a knowledge base?
Knowledge-base is required for updating knowledge for an agent to learn with experiences and take action as per the
knowledge.
Inference system
Inference means deriving new sentences from old.
Inference system allows us to add a new sentence to the knowledge base.
A sentence is a proposition about the world.
Inference system applies logical rules to the KB to deduce new information.
Inference system generates new facts so that an agent can update the KB.
An inference system works mainly in two rules which are given as:
Forward chaining : It start from the initial state of the problem till the solution.
Backward chaining : from the solution going back to the steps of what we take
Proof by resolution : it’s where we will use propositional logic
Forward Chaining:
Simple Example: Matches the set of conditions and infer results from these
conditions.
A(is true) and need to prove D is true
B C
AB
CD
Prove D is also true.
Solution: Starting from initial state A, Let assume
if A is true then B is true AB
Then B is true then C is true B C
finally C is true then D is true CD
Thus D is also true is proved.
• Backward Chaining:
It is backward search from goal to conditions used to get the goal.
Simple Example: A is true, we need to prove D is true
B C
AB
CD
Prove D is also true.
Solution: Starting from D, Let assume D is true then C is true CD
C is true then B is true B C
B is true then A is true AB
Thus A is proved true.
Proof by resolution:
Resolution is a theorem proving technique that proceeds by building refutation
proofs, i.e., proofs by contradictions (later we will see elaborately)
The resolution rule propositional logic is a single valid inference rule that produces a
new clause implied by two clause containing complementary literals.
A literal is propositional variable or the negation of a propositional variable.
Example: PVQ, ¬QVR, PVR (it take clauses P and Q and come up with new clause PVQ)
• Inference Rules:
A chain of conclusion that leads to the desired goal.
Logical function take premises for ex, PVQ i.e checks P and Q are true or false
and analysed the syntax (syntactically correct or not) and returned conclusion
(gives the final result)
Some of Inference rules:
Modus Ponen
AND introduction
AND elimination
Resolution etc which we will learn later elaborately
Logical
Function
Premises Analyse syntax Conclusion
Operations Performed by KBA
Following are three operations which are performed by KBA in order to show the intelligent behavior:
Actions of an agent
When there is a need to add/ update some new information or sentences in the knowledge-based system, we require an inference system.
Also, to know what information is already known to the agent, we require the inference system. The technical words used for describing the
mechanism of the inference system are: TELL and ASK. When the agent solves a problem, it calls the agent program each time. The agent
program performs three things:
It TELLS the knowledge base what it has perceived from the environment.
It ASKS the knowledge base about the actions it should take?
It TELLS the action which is chosen, and finally, the agent executes that action.
The details of the knowledge representation language are abstracted under these three functions. These functions create an interface
between the two main components of an intelligent agent, i.e., sensors and actuators.
The functions are discussed below:
•MAKE-PERCEPT-SENTENCE()
This function returns a sentence which tells the perceived information by the agent at a given time.
•MAKE-ACTION-QUERY()
This function returns a sentence which tells what action the agent must take at the current time.
•MAKE-ACTION-SENTENCE()
This function returns a sentence which tells an action is selected as well as executed.
Levels of a Knowledge-based agent
1. Knowledge Level: In this level, the behaviour of an agent is decided by specifying the following :
we need to specify what the agent knows, and
what the agent goals are.
example, suppose an automated taxi agent needs to go from a station A to station B, and he knows the way from A to B, so
this comes at the knowledge level.
2. Implementation Level: agent perform actions as per logical and knowledge level.
Ex At this level, an automated taxi agent actually implement his knowledge and logic so that he can reach to the destination.
For example, Consider an automated air conditioner. The inbuilt knowledge stored in its system is that “ It would adjust its
temperature according to the weather.” This represents the knowledge level of the agent. The actual working and its adjustment
define the implementation level of the knowledge-based agent.
3. Logical level:
At this level, we understand that how the knowledge representation of knowledge is stored. At this level, sentences are encoded
into different logics. At the logical level, an encoding of knowledge into logical sentences occurs.
ex At the logical level we can expect to the automated taxi agent to reach to the destination B.
What is Knowledge Representation?
Knowledge Representation in AI describes the representation of knowledge. Basically, it is a study of how the beliefs,
intentions, and judgments of an intelligent agent can be expressed suitably for automated reasoning. One of the primary
purposes of Knowledge Representation includes modeling intelligent behavior for an agent.
Cycle/componenet of Knowledge Representation in AI
Artificial Intelligent Systems usually consist of various components to display their intelligent behaviour. Some of these
components include:
•Perception
•Learning
•Knowledge Representation & Reasoning
•Planning
•Execution
Here is an example to show the different components of the system and how it works:
Example
The above diagram shows the interaction of an AI system with the real world and the components involved in showing
intelligence.
•The Perception component retrieves data or information from the environment, find out the source of noises and check if the
AI was damaged by anything. Also, it defines how to respond when any sense has been detected.
•Then, there is the Learning Component that learns from the captured data by the perception component. The goal is to build
computers that can be taught instead of programming them. Learning focuses on the process of self-improvement. In order to
learn new things, the system requires knowledge acquisition, inference, acquisition of heuristics, faster searches, etc.
•The main component in the cycle is Knowledge Representation and Reasoning which shows the human-like intelligence in
the machines. Knowledge representation is all about understanding intelligence. Instead of trying to understand or build brains
from the bottom up, its goal is to understand and build intelligent behavior from the top-down and focus on what an agent
needs to know in order to behave intelligently. Also, it defines how automated reasoning procedures can make this knowledge
available as needed.
•The Planning and Execution components depend on the analysis of knowledge representation and reasoning. Here, planning
includes giving an initial state, finding their preconditions and effects, and a sequence of actions to achieve a state in which a
particular goal holds. Now once the planning is completed, the final stage is the execution of the entire process.
So, these are the different components of the cycle of Knowledge Representation in AI.
The Basic Idea of Propositional Logic
Proposition means sentences.
Propositional logic is one of the simplest method of knowledge representation to a machine.
Propositional logic applies the Boolean logic (true /false) to convert our real-world data into a format that is
readable to the computer.
For instance, if we say ‘It is hot and humid today’, the machine won’t understand.
But if we can create propositional logic for this sentence, then, we can make the machine-read, and interpret our
message.
Derived from Boolean logic, the heart of propositional logic is the idea that the final output (meaning) of all
propositions are either true or false. It can’t be both.
For example,
‘Earth is round’, the output for this proposition is TRUE.
If we say, ‘Earth is square’, then the output is FALSE.
Propositional logic applies to those sentences where the output can only be either TRUE or FALSE.
But if we refer to the sentence like ‘Some children are lazy’ then here we have two possible outputs.
This preposition is TRUE for those children who are lazy, but it is FALSE for those children who are not lazy.
So, for such sentences/propositions where two or more outputs are possible, propositional logic doesn’t apply.
Sentences that are questions and commands in nature do not belong to proposition category.
Example what date today? It cannot have an answer true or false because it is a question, so question does not
belong to this category.
Other Features / types of propositions:
Atomic Proposition: Atomic propositions are the simple sentences/propositions. These are the sentences which
must be either true or false.
Example: 9+2 =11 is one such proposition, and it is true.
Sunrises in the west is another example, and it is false.
Compound / complex proposition: Compound propositions are which have been formed by connecting two, or
more sentences by using parenthesis and logical connectives.
A combination of simple sentences connected by logical connectors is called Compound.
Example: Today is Friday and people visit Temple today.
It’s raining, and the match is called off.
It is raining today, and street is wet.“
Sl. Type Symbol Description
1 Negation ¬ P
It represents a Negative condition. P is a positive statement, and ¬ P indicates NOT
condition.
Example: Today is Monday (P), Today is not a Monday (¬ P)
2 Conjunction P ^ Q
It joins two statements P, Q with AND clause.
Example: Ram is a cricket player (P). Ram is a Hockey player (Q). Ram plays both cricket
and Hockey is represented by (P ^ Q)
3 Disjunction P v Q
It joins two statements P, Q with OR Clause.
Example: Ram leaves for Mumbai (P) and Ram leaves for Chennai (Q). Ram leaves for
Chennai or Mumbai is represented by (P v Q). In this complex statement, at any given point
of time if P is True Q is not true and vice versa.
4
Implication/
conditional
P → Q
Sentence (Q) is dependent on sentence (P), and it is called implication. It follows the rule of If
then clause. If sentence P is true, then sentence Q is true. The condition is unidirectional.
Example: If it is Sunday (P) then I will go to Movie (Q), and it is represented as P → Q
5 Bi-conditional P ⇔ Q
Sentence (Q) is dependent on sentence (P), and vice versa and conditions are bi-directional in
this connective. If a conditional statement and its converse are true, then it is called as bi-
conditional connective (Implication condition in both the directions P → Q and Q → P). If
and only if all conditions are true, then the end statement is true.
Example: If I have 1000 Rupees then only I will go to Bar. The converse condition that I will
go to Bar if and only if I have Rs 1000. The first statement covers necessity and the second
one covers sufficiency.
Syntax of Propositional Logic:
P Q
Negation Conjunction Disjunction Implication Bi-conditional
¬ P ¬ Q P ^ Q P v Q P → Q P⇔Q
True True False False True True True True
True False False True False True False False
False True True False False True True False
False False True True False False True True
1.Propositional logic Practise exercise
2.If it rains, then I will stay at home.
3.If I will go to Australia, then I will earn more money.
4.He is poor but honest.
5.If a = b and b = c then a = c.
6.Neither it is hot nor cold today.
7.He goes to play a match if and only if it does not rain.
8.Birds fly if and only if sky is clear.
9.I will go only if he stays.
10.I will go if he stays.
11.It is false that he is poor but not honest.
12.It is false that he is poor or clever but not honest.
13.It is hot or else it is both cold and cloudy.
14.I will not go to class unless you come.
15.We will leave whenever he comes.
16.Either today is Sunday or Monday.
17.You will qualify GATE only if you work hard.
18.Presence of cycle in a single instance RAG is a necessary and sufficient condition for deadlock.
19.Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for deadlock.
20.I will dance only if you sing.
21.Neither the red nor the green is available in size 5.
Solution-
Part-01:
We have-
•The given sentence is- “If it rains, then I will stay at home.”
•This sentence is of the form- “If p then q”.
So, the symbolic form is p → q where-
p : It rains
q : I will stay at home
Part-02:
We have-
•The given sentence is- “If I will go to Australia, then I will earn more money.”
•This sentence is of the form- “If p then q”.
So, the symbolic form is p → q where-
p : I will go to Australia
q : I will earn more money
Part-03:
We have-
•The given sentence is- “He is poor but honest.”
•We can replace “but” with “and”.
•Then, the sentence is- “He is poor and honest.”
So, the symbolic form is p ∧ q where-
p : He is poor
q : He is honest
Part-04:
We have-
•The given sentence is- “If a = b and b = c then a = c.”
•This sentence is of the form- “If p then q”.
So, the symbolic form is (p ∧ q) → r where-
p : a = b
q : b = c
r : a = c
Part-05:
We have-
•The given sentence is- “Neither it is hot nor cold today.”
•This sentence is of the form- “Neither p nor q”.
•“Neither p nor q” can be re-written as “Not p and Not q”.
So, the symbolic form is ∼p ∧ ∼q where-
p : It is hot today
q : It is cold today
Part-06:
We have-
•The given sentence is- “He goes to play a match if and only if it does not rain.”
•This sentence is of the form- “p if and only if q”.
So, the symbolic form is p ↔ q where-
p : He goes to play a match
q : It does not rain
Part-07:
We have-
•The given sentence is- “Birds fly if and only if sky is clear.”
•This sentence is of the form- “p if and only if q”.
So, the symbolic form is p ↔ q where-
p : Birds fly
q : Sky is clear
Part-08:
We have-
•The given sentence is- “I will go only if he stays.”
•This sentence is of the form- “p only if q”.
So, the symbolic form is p → q where-
p : I will go
q : He stays
Part-09:
We have-
•The given sentence is- “I will go if he stays.”
•This sentence is of the form- “q if p”.
So, the symbolic form is p → q where-
p : He stays
q : I will go
Part-10:
We have-
•The given sentence is- “It is false that he is poor but not honest.”
•We can replace “but” with “and”.
•Then, the sentence is- “It is false that he is poor and not honest.”
So, the symbolic form is ∼(p ∧ ∼q) where-
p : He is poor
q : He is honest
Part-11:
We have-
•The given sentence is- “It is false that he is poor or clever but not honest.”
•We can replace “but” with “and”.
•Then, the sentence is- “It is false that he is poor or clever and not honest.”
So, the symbolic form is ∼((p ∨ q) ∧ ∼r) where-
p : He is poor
q : He is clever
r : He is honest
Part-12:
We have-
•The given sentence is- “It is hot or else it is both cold and cloudy.”
•It can be re-written as- “It is hot or it is both cold and cloudy.”
So, the symbolic form is p ∨ (q ∧ r) where-
p : It is hot
q : It is cold
r : It is cloudy
Part-13:
We have-
•The given sentence is- “I will not go to class unless you come.”
•This sentence is of the form- “p unless q”.
So, the symbolic form is ∼ q → p where-
p : I will go to class
q : You come
Part-14:
We have-
•The given sentence is- “We will leave whenever he comes.”
•We can replace “whenever” with “if”.
•Then, the sentence is- “We will leave if he comes.”
•This sentence is of the form- “q if p”.
So, the symbolic form is p → q where-
p : He comes
q : We will leave
Part-15:
We have-
•The given sentence is- “Either today is Sunday or Monday.”
•It can be re-written as- “Today is Sunday or Monday.”
So, the symbolic form is p ∨ q where-
p : Today is Sunday
q : Today is Monday
Part-16:
We have-
•The given sentence is- “You will qualify GATE only if you work hard.”
•This sentence is of the form- “p only if q”.
So, the symbolic form is p → q where-
p : You will qualify GATE
q : You work hard
Part-17:
We have-
•The given sentence is- “Presence of cycle in a single instance RAG is a necessary and sufficient condition for
deadlock.”
•This sentence is of the form- “p is necessary and sufficient for q”.
So, the symbolic form is p ↔ q where-
p : Presence of cycle in a single instance RAG
q : Presence of deadlock
Part-18:
We have-
•The given sentence is- “Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for
deadlock.”
•This sentence is of the form- “p is necessary but not sufficient for q”.
So, the symbolic form is (q → p) ∧ ∼(p → q) where-
p : Presence of cycle in a multi instance RAG
q : Presence of deadlock
Part-19:
We have-
•The given sentence is- “I will dance only if you sing.”
•This sentence is of the form- “p only if q”.
So, the symbolic form is p → q where-
p : I will dance
q : You sing
Part-20:
We have-
•The given sentence is- “Neither the red nor the green is available in size 5.”
•This sentence is of the form- “Neither p nor q”.
•“Neither p nor q” can be written as “Not p and Not q”.
So, the symbolic form is ∼p ∧ ∼q where-
p : Red is available in size 5
q : Green is available in size 5
Precedence of connectives / bracket simplification:
Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators. This
order should be followed while evaluating a propositional problem. Following is the list of the precedence order for
operators:
Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Sixth Precedence Biconditional
Note: For better understanding use parenthesis to make sure of the correct interpretations. Such as ¬R∨ Q, It
can be interpreted as (¬R) ∨ Q.
The formal syntax makes extensive use of brackets to make grouping unambiguous:
(((¬P)V(Q ∧R)) S)
If you don’t want to use bracket use precedence rules from highest to lowest : ¬ ∧ V  ↔
Many brackets can be dropped and formulas be simplified: ¬PVQ ∧R  S
Logic-Tautology, logical sequence, satisfiable and falsifiable
A proposition that is always true regardless of the truth values of the propositional variables it contains is called
a tautology.
A compound proposition that is always false is called a contradiction or absurdity.
And a compound proposition that is neither a tautology nor a contradiction is referred to as a contingency.
P Q P ⇔ Q
true true true
false false true
true false False
false true false
Logically Equivalent Statement
In the above example,
tautology is called as valid.
Contingency and contradiction is called as invalid.
The formula which made true is called satisfiable i.e, tautology and contingency are satisfiable because
contingency can be made true and tautology is always true so therefore it is satisfiable
Contradiction always be false and therefore it is unsatisfiable.
The formula which made false is called as falsifiable. Contradiction and contingency are falsifiable because
they made false
Tautology cant be made so it is unfalsifiable.
De Morgan law We have a number of rules for logical equivalence.
For example:
De Morgan Law:
¬(p ∧ q) ≡ ¬p ∨ ¬q (1)
¬(p ∨ q) ≡ ¬p ∧ ¬q (2)
The following TT for proof 1. Do for proof 2
P Q p ∧ Q ¬(p ∧ Q)
T T T F
T F F T
F T F T
F F F T
P Q ¬P ∨ ¬Q
T T F
T F T
F T T
F F T
Contrapositives
The proposition ¬q → ¬p is called the Contrapositive of the proposition p → q.
They are logically equivalent.
p → q ≡ ¬q → ¬p
P Q p → q
T T T
T F F
F T T
F F T
P Q ¬q → ¬p
T T T
T F F
F T T
F F T
Laws Of Propositional Logic
Laws Of Logic
Similarly, there are some very useful equivalences for compound propositions involving implications and biconditional statements, as seen
below.
Equivalence Laws Biconditional
Prove equivalence:
By using these laws, we can prove two propositions are logical equivalent.
Example 1: Prove ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬q.
LHS,
¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) DeMorgan
≡ ¬p ∧ (p ∨ ¬q) DeMorgan
≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) Distributivity
≡ F∨(¬p ∧ ¬q) Because ¬p ∧ p ≡ F
≡ ¬p ∧ ¬q Because F ∨r ≡ r for any r
Example 2: Prove (p ∧ q) → (p ∨ q) ≡ T.
(p ∧ q) → (p ∨ q) ≡ ¬(p ∧ q) ∨ (p ∨ q) Substitution for →
≡ (¬p ∨ ¬q) ∨ (p ∨ q) DeMorgan
≡ (¬p ∨ p) ∨ (¬q ∨ q) Commutativity and Associativity
≡ T∨T Because ¬p ∨ p ≡ T
≡ T
Rules of Inference for propositional logic
Inference means to find a conclusion based on the facts, information, and evidence. In simple
words, when we conclude the facts and figures to reach a particular decision, that is called inference.
In artificial intelligence, the expert system or any agent performs this task with the help of the inference
engine.
Reasoning patterns in propositional logic:
AND Elimination:
From a conjunction, any of the conjuncts can be inferred as
P∧Q == true , where P is true and Q is true, then we can set P ∧Q is true
P
Example:
(WumpusAhead ∧ WumpusAlive), WumpusAlive can be inferred
Types of Inference rules/ Reasoning patterns in propositional logic:
1. Modus Ponens:
The Modus Ponens rule is one of the most important rules of inference, when P → Q is true, so then P is true and therefore Q
must be true. It can be represented as:
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.
Proof by Truth table:
2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also true. It can be represented as:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P
Proof by Truth table:
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and Q→R is true. It can be represented as the
following notation:
Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
Proof by truth table:
4. Disjunctive Syllogism:
The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will 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
Proof by truth-table:
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.
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)
Proof by Truth-Table:
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:
Proof by Truth-Table:
Example:
Vivin plays football
Nikita plays tennis
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
Proof by Truth-Table:
• Conjunctive Normal Form
• It is formula which is equivalent to a given formula and which consists of a product of
elementary sums is called as conjunctive normal form.
• (PVQ) ∧(¬PV ¬Q) ∧(..V…V..) series of disjunction connected through conjunction.
Therefore in short it is conjunction of clauses ((PVQ) , (¬PV ¬Q))
• Example:
• ((P Q) R)
First step: Eliminate Implication -->
• ((P Q) R) (implication is replaced by negation and or operator)
• ((¬PV Q) R) (implication is replaced by negation and or operator)
• (¬(¬PV Q)V R)
Second Step: Move negation inward (OR becomes AND)
• (¬¬P ∧¬Q)V R) (double negation cancelled)
• (P ∧ ¬Q)V R
• Third Step: Now apply distributive law (because we need AND)
• (PVR) ∧( ¬QV R)
• Example:
• A ↔(BVC)
• First Step: Elimination of ↔ (means AB or C and B or C A)
• (A(BVC)) ∧((BVC)A)
• Second step: Elimination of  (means add negation & OR operator)
• (¬AV(BVC) ∧(¬(BVC)VA) (negation is present outside)
• Third Step: Move Negation inside (means OR will become AND operator)
• (¬AV(BVC) ∧((¬B ∧¬ C)VA) (here V is present but we need ∧)
• Fourth step: Apply distributive law
• (¬AVBVC) ∧(¬B VA) ∧( ¬ CVA)
• (¬AVBVC) ∧(¬B VA) ∧( ¬ CVA) (clause is conjunction of discjunction)
• So the statement is in conjunctive normal form
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e., proofs by contradictions.
It was invented by a Mathematician John Alan Robinson in the year 1965.
Resolution is used, if there are various statements are 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.
Proof by resolution
Resolution: An inference rule that yields a complete inference algorithm when coupled with any complete search
algorithm.
Clause: A disjunction of literals (an atomic sentence) is called as clause. (e.g. A∨B). A single literal can be viewed
as a unit clause (a disjunction of one literal ).
Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to be conjunctive normal
form or CNF.
Unit resolution inference rule: Takes a clause and a literal and produces a new clause.
Where li and mj are complementary literals .
This rule is also called the binary resolution rule because it only resolves exactly two
literals.
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.
Notice: The resulting clause should contain only one copy of each literal. The removal of multiple copies of literal is
called factoring.
e.g. resolve(A∨B) with (A∨¬B), obtain(A∨A) and reduce it to just A.
The resolution rule is sound and complete.
Resolution: Property
• Resolution is sound: Always produces sentences that are entailed by their premise
• Resolution is complete: It is guarantee to establish entailment of the query in finite time
• Completeness based on the key theorem:
If a set of clauses is unsatisfiable, then the set of all clauses that can be obtained by resolution contains the empty clause
• So, conversely, if we cannot find the empty clause, the query must be satisfiable
function PL-RESOLUTION(KB, α) returns true or false
inputs: KB, the knowledge base, a sentence in propositional logic
α, the query, a sentence in propositional logic
clauses ← the set of clauses in the CNF representation of KB ∧ ¬α
new ← { }
loop do
for each pair of clauses Ci, Cj in clauses do
resolvents ← PL-RESOLVE(Ci, Cj)
if resolvents contains the empty clause then return true
new ← new ∪ resolvents
if new ⊆ clauses then return false
clauses ← clauses ∪ new
A simple resolution algorithm for propositional logic above. The function PL-RESOLVE returns the set of all
possible clauses obtained by resolving its two inputs.
Inference in PL where the below 5 sentences are stored in KB
• R1:¬P1,1
// There is no pit in square[1,1]
•
• R2 : B1,1
↔(P1,2
v P2,1
) //square[1,1] will have breeze iff there is pit in [1,2]
or [2,1]
• R3 : B2,1
↔(P1,1
V P2,2
V P3,5
) square [2,1] have breeze iff there is pit in
[1,1], [2,2] or [3,1]
• R4: :¬B1,1
//There is no breeze in square [1,1]
• R5: B2,1
//There is no breeze in square [2,1]
• Rules of Wumpus game are R1,R2,R3
• Percept the agent perceive R4, R5
To perform Inference, our goal is to decide whether KB |= α for some sentence α
Example : :¬P1,2
// entails by our KB or not?
Model checking for inference by using algorithm:
In all the model if KB =True the α =True
Therefore KB |= α
From the previous slide,
The 7 relevant proposition symbol are : P1,1
B1,1
P1,2
P2,1
, B2,1
P2,2
P3,5
With the 7 symbol, there are total 27=128 possible models
Inference check using model checking algorithm:
e.g. 1. To perform inference let consider ¬P1,2
is true in all models where KB=True hence it is proved there is
no pit in square[1,2] KB |= P1,2
2. Let infer P2,2
is true . from the below fig, it is true for only two models therefore it is difficult to say there is pit
[2,2]
Thus P2,2
is false and KB =true. So we can say KB ⊭ P2,2
TT-ENTAILS?: A general algorithm for deciding entailment in propositional logic, performs a recursive enumeration
of a finite space of assignments to symbols.
Sound and complete.
Time complexity: O(2n)
Space complexity: O(n), if KB and α contain n symbols in all.
Monotonicity: A property of logical system, says that the set of entailed sentences can only increased as
information is added to the knowledge base.
For any sentences α and β,
If KB ⊨ α then KB ∧ β ⊨ α.
Monotonicity means that inference rules can be applied whenever suitable premises are found in the knowledge
base, what else in the knowledge base cannot invalidate any conclusion already inferred.
Proof by resolution
Resolution: An inference rule that yields a complete inference algorithm when coupled with any complete search
algorithm.
Clause: A disjunction of literals. (e.g. A∨B). A single literal can be viewed as a unit clause (a disjunction of one
literal ).
Unit resolution inference rule: Takes a clause and a literal and produces a new clause.
where each l is a literal, li and m are complementary literals (one is the negation of the other).
Full resolution rule: Takes 2 clauses and produces a new clause.
where li and mj are complementary literals.
• Resolution :
• This algorithm works using by proof by contradiction.
• To show KB |= α , we show that KB ∧ ¬ α is not satisfiable.
• So by applying resolution to KB ∧ ¬ α in CNF and resolve pairs with
complementary literal,
• For example if we keep li
= ¬ P and mj=P then as per resolution rules the
complimentary literal is removed so the remaining value will be li-1, mj-1
…
Conjunctive normal form
Conjunctive normal form (CNF): A sentence expressed as a conjunction of clauses is said to be in CNF.
Every sentence of propositional logic is logically equivalent to a conjunction of clauses, after converting a sentence
into CNF, it can be used as input to a resolution procedure.
A resolution algorithm
e.g. say agent is in square [1,1] where there is no breeze and no pit.
We need to prove no pits in α = ¬P1,2
KB = (B1,1⟺(P1,2∨P2,1))∧¬B1,1
KB=R2∧R4
By using biconditional elimination and CNF we get,
KB ∧ ¬ α=
Notice: Any clause in which two complementary literals appear can be discarded, because it is always
equivalent to True.
e.g. B1,1∨¬B1,1∨P1,2 = True∨P1,2 = True.
PL-RESOLUTION is complete.
Horn clauses and definite clauses
Definite clause:
A clause which is disjunction of literals with exactly one positive literals (a,P,…) is known as Definite Clause or Strict
Horn Clause.
Every definite clause can be written as an implication, whose premise is a conjunction of positive literals and whose
conclusion is a single positive literal.
Example : A B ≡ ¬A V B ( here one positive literal present i.e B)
Horn clause: A disjunction of literals of which at most one is positive. (All definite clauses are Horn clauses.)
In Horn form, the premise is called the body and the conclusion is called the head.. A sentence consisting of a single
positive literal is called a fact, it too can be written in implication form.
Horn clause are closed under resolution: if you resolve 2 horn clauses, you get back a horn clause.
Inference with horn clauses can be done through the forward-chaining and backward-chaining algorithms.
A Clause which is disjunction of literals with atmost one positive literals is known as Horn Clause.
Example : (¬P V ¬Q V K) (here it has only one positive literal ie. K)
Unification
It is a process of making 2 different logical atomic expressions identical by finding substitution. Unification depend on
substitution process.
Example
Know (x,ram) know(shyam, y)
Therefore unification become know (shyam, ram) (substitute x=shyam and y= ram)
Forward Chaining:
It is a join of reasoning which starts with atomic sentences in the knowledge base and applies
inference rules in the forward direction to extract more data until a goal is reached.
Properties:
It moves from bottom to top
It is a process of making a conclusion based on known facts or data by starting from the initial
state and reach goal state.
Forward chaining approach is also called as data driven as we reach to the goal using available
data.
To prove is P Q. A,B are given fact. Remaining 4 condition above are horn clause
• Backward Chaining:
It is a form of reasoning which starts with the goal and work backward chaininh
through rules to find known facts that support the goal.
Properties:
It is known as Top down approach.
BC is based on modus ponens inference rule.
In BC, the goal is broken into subgoals to prove the facts are true.
BC is also called as Goal driven approach as a list of goal decides which rules
are decided and used.
BC is used in gaming theory, automated theorem tools, inference engine and
various AI applications.
BC method mostly used DFS strategy for proof.
in the corresponding AND-OR graph: it works back down the graph until it reaches a set of known facts.
(Backward-chaining algorithm is essentially identical to the AND-OR-GRAPH-SEARCH algorithm.)
Effective propositional Inference model checking
The set of possible models, given a fixed propositional vocabulary, is finite, so entailment can be checked by
enumerating models. Efficient model-checking inference algorithms for propositional logic include backtracking
and local search methods and can often solve large problems quickly.
2 families of algorithms for the SAT (Boolean Satisfiability Problem) problem based on model checking
a. based on backtracking
b. based on local hill-climbing search
Boolean Satisfiability:
the problem of determining if there exists an interpretation that satisfies a given Boolean formula t/f.
Example:
DPLL embodies 3 improvements over the scheme of TT-ENTAILS?: Early termination, pure symbol heuristic, unit
clause heuristic.
Tricks that enable SAT solvers to scale up to large problems: Component analysis, variable and value
ordering, intelligent backtracking, random restarts, clever indexing.
Local search algorithms
Local search algorithms can be applied directly to the SAT problem, provided that choose the right evaluation
function. (We can choose an evaluation function that counts the number of unsatisfied clauses.)
These algorithms take steps in the space of complete assignments, flipping the truth value of one symbol at a time.
The space usually contains many local minima, to escape from which various forms of randomness are required.
Local search methods such as WALKSAT can be used to find solutions. Such algorithm are sound but not
complete.
WALKSAT: one of the simplest and most effective algorithms.
The landscape of random SAT problems
Underconstrained problem: When we look at satisfiability problems in CNF, an underconstrained problem is
one with relatively few clauses constraining the variables.
An overconstrained problem has many clauses relative to the number of variables and is likely to have no
solutions.
The notation CNFk(m, n) denotes a k-CNF sentence with m clauses and n symbols. (with n variables
and k literals per clause).
Given a source of random sentences, where the clauses are chosen uniformly, independently and without
replacement from among all clauses with k different literals, which are positive or negative at random.
Hardness: problems right at the threshold > overconstrained problems > underconstrained problems
Inference-based agents in the
wumpus world
A wumpus-world agent using
propositional logic:
P1,1
W1,1
Bx,y  (Px,y+1 
Px,y-1  Px+1,y
 Px-1,y) Sx,y 
(Wx,y+1  Wx,y-
1  Wx+1,y  Wx-
1,y) W1,1  W1,2
 …  W4,4
W1,1  W1,2
W1,1  W1,3
…
 64 distinct proposition symbols,
155 sentences
Expressiveness
limitation of
propositional logic
• KB contains "physics"
sentences for every single
square
• For every time t and every
location [x,y],
Ltx,y  FacingRightt  Forwardt 
Lx+1,yt
• Rapid proliferation of clauses
Artificial Intelligence Methods – WS 2005/2006 – Marc Erich Latoschik
Circuit-based agents
• Particular type of reflex agent with state
• Percepts are inputs to a sequential
circuit built of gates and registers (to
sore truth values for a single
proposition).
• Circuit will be evaluated according to
data-flow (compare to and-or graphs)
• Logical agents apply inference to a knowledge base
• to derive new information and make decisions
• Basic concepts of logic:
•syntax: formal structure of sentences
•semantics: truth of sentences wrt models
•entailment: necessary truth of one sentence given
another
•inference: deriving sentences from other sentences
•soundness: derivations produce only entailed
sentences
•completeness: derivations can produce all entailed
sentences
• Wumpus world requires the ability to represent partial
• and negated information, reason by cases, etc.
• Resolution is complete for propositional logic
Forward, backward chaining are linear-time, complete
for Horn clauses
• Propositional logic lacks expressive power
Circuit-based agents Summary
Wumpus is the name of a monster in the video game “Hunt The Wumpus”. It was developed by Gregory Yob in 1973.
Wumpus world problem to represent knowledge representation
The Wumpus world problem depicts the value of a knowledge-based agent and the interpretation of that
knowledge with the help of reasoning and planning. (or game playing which provides an environment to the knowledge-
based agent to showcase its stored knowledge)
Wumpus world problem in AI?
The Wumpus world is a 4x4 cave with 16 rooms connected to each other through passageways. The knowledge-based agent
goes forward in this world.
In Wumpus World:
It is a single-player game.
It is a cave consisting of rooms which are connected with one-another via passways.
There is a beast or monster in the game named Wumpus, lurking somewhere the cave.
Wumpus eats everyone who tries to enter the cave.
The player needs to kill the Wumpus.
The player has only one arrow to shoot out the monster.
There are some rooms containing bottomless pits which may trap anyone whoever wanders in the room.
The goal of the game is to search for a heap of gold.
How to “win” it
The agent has to find the gold and climb out of the cave without:
Falling into Pits
Getting eaten by Wumpus
There are also some components which can help the agent to navigate the cave. These components are
given as follows:
•The rooms adjacent to the Wumpus room are stinky, thus there is a stench there.
•The room next to PITs has a breeze, so if the agent gets close enough to PIT, he will feel it.
•If and only if the room contains gold, there will be glitter.
• Wumpus will scream*= when it is killed, which can be heard anywhere in the cave.
•The agent will feel a bump when they hit a wall
•Sensors help the agent move forward successfully.
PEAS Description of the Wumpus World
•Performance Measure: The player is awarded with the following utilities:
•(+1000): It is for coming out of the cave safely with the gold.
•(-1000): It is for falling into the pit or if eaten by the Wumpus.
•(-1): It is for each action taken by the player.
•(-10): It is for raising the arrow up.
The game ends if the player comes out of the cave safely or dies.
1) Environment: The environment provided in the Wumpus world is as follows:
•It is a 4X4 grid of 16 rooms.
•The player always starts in the square labeled [1,1] and facing towards the right.
•Location of the monster and the gold is choosen randomly in a uniform distribution.
•Remember, the location chosen will never be the starting point.
•Each square room other than the starting one can be a pit with 0.2 probability.
2) Actuators: The player performs the following actions:
•The agent can move forward or TurnLeft by 900 and TurnRight by 900.
•The player dies if he enters a room having a pit or alive monster. It is safe to enter the room if the Wumpus is
dead.
•If the player will try to move forward and bumps into the wall, then the player will not move.
•Using the action Grab, the player can pick up the gold in the same room.
•Using the action Shoot, the player can shoot the monster with the arrow. Either the arrow will shoot the monster
or will hit on the wall.
•The action Climb is used to come out of the cave but only from the square [1,1].
3) Sensors: The player is provided with five sensors, which gives a single bit of information:
•The player will perceive a Stench, if Wumpus is present in the room which is directly adjacent to the player.
•The player will perceive a Breeze, if in the square is directly adjacent to the pit.
•The player will perceive a Glitter, if in the square gold is present.
•The player will perceive a Bump, when the player walks into the wall.
When the player will shoot out the monster, it will emit a scary Scream which can be heard/perceived from
anywhere in the cave.
The Wumpus world Properties:
Partially observable: The Wumpus universe is only partially viewable because the agent can only observe the immediate
environment, such as a nearby room.
Deterministic: It's deterministic because the world's result and outcome are already known.
Sequential: It is sequential because the order is critical.
Static: Wumpus and Pits are not moving, thus it is static.
Discrete: There are no discrete elements in the environment.
One agent: We only have one agent, and Wumpus is not regarded an agent, hence the environment is single agent.
Now we will explore Wumpus world a bit and will explain how the agent will find its goal applying logical reasoning.
Agent's First step:
At first, the agent is in the first room, or square [1,1], and we all know that this room is safe for the agent, thus we will add
the sign OK to the below diagram (a) to represent that room is safe. The agent is represented by the letter A, the breeze by
the letter B, the glitter or gold by the letter G, the visited room by the letter V, the pits by the letter P, and the Wumpus by
the letter W.
Agent does not detect any wind or Stench in Room [1,1], indicating that the nearby squares are similarly in good condition.
Agent's second Step:
Now that the agent must go forward, it will either go to [1, 2] or [2, 1]. Let's say agent enters room [2, 1], where he
detects a breeze, indicating Pit is present. Because the pit might be in [3, 1] or [2, 2], we'll add the sign P? to
indicate that this is a Pit chamber.
Now the agent will pause and consider his options before doing any potentially destructive actions. The agent will
return to room [1, 1]. The agent visits the rooms [1,1] and [2,1], thus we'll use the symbol V to symbolize the
squares he's been to.
Agent's third step:
The agent will now proceed to the room [1,2], which is fine. Agent detects a stink in the room [1,2], indicating the
presence of a Wumpus nearby. However, according to the rules of the game, Wumpus cannot be in the room
[1,1], and he also cannot be in [2,2]. (Agent had not detected any stench when he was at [2,1]). As a result, the
agent infers that Wumpus is in the room [1,3], and there is no breeze at the moment, implying that there is no Pit
and no Wumpus in [2,2]. So that's safe, and we'll designate it as OK, and the agent will advance [2,2]
Agent's fourth step:
Because there is no odor and no breeze in room [2,2], let's assume the agent decides to move to room [2,3]. Agent
detects glitter in room [2,3], thus it should collect the gold and ascend out of the cave.
Differences Between Propositional and First-Order Logic
The first difference between the two relates to the fact that first-order logic includes propositional logic, but the opposite
isn’t true. This means that all problems expressed in propositional logic can be treated under first-order logic, but not all
problems in first-order logic can be treated in propositional logic.
The second difference relates to the nature of the elementary unit which constitutes the formulas of the two formal systems.
Propositional logic uses propositions and logical operators in order to constitute its Well-Formed Formulas. First-order logic,
in addition to those, also uses variables, quantifiers, and relationships. We’re going to see in the next sections what these
new concepts mean.
The third difference concerns the capacity for the abstraction of formulas expressed by the two systems. In propositional
logic, the system doesn’t allow to handle problems that involve mutating or undetermined parts. This means that the
validity of a solution to a formula found in propositional logic is restricted to that formula. In first-order logic, in contrast, it’s
possible to create formulas that possess a higher capacity for generalization.
Predicate Logic (calculus) / First order logic
What is first-order logic (FOL)?
1.FOL is a mode of representation in Artificial Intelligence. It is an extension of PL. FOL is also called predicate logic
2.FOL represents natural language statements in a concise way.
3.Predicate calculus deals with predicated which are propositions containing variables.
4. It is a powerful language that develops information about an object in a more easy way and can also express the
relationship between those objects.
1.FOL not only assumes that does the world contains facts (like PL does), but it also assumes the following:
1. Objects: A, B, people - ram, numbers, colours, wars, theories, squares, pit, etc.
2. Relations: It is unary relation such as colour like red, round, sister of, brother of, bigger than, comes between
etc.
3. Facts: one value for a given input like : is father of, best friend, can swim, third inning of, end of, etc.
Facts have truth value true or false
As a natural language, first-order logic has two main parts
Syntax
Semantics
Now there are three kinds of symbols:
Constants: objects
Predicate: relations
Functions: functions(i.e can return values other than truth and false)
Predicate logic statements can be divided into two parts:
Subject: Subject is the main part of the statement
Predicate: A predicate can be defined as relation, which binds two atoms together in a
statement.
Ex:
Sunil was intelligent –
Here Sunil is subject
intelligent is attribute
property characteristics also called as predicate (intelligent).
Note: predicate logic doesnot bother about the tense like present , past and future
tense i,.e sunil is intelligent, sunil will be intelliegent the predicate logic is same )
Intelligent(sunil)
Consider the statement :
“x is an integer”, it contains of two parts,
the first part x is the subject of the statement
and second part “is an integer” is known as predicate
(integer is attribute of subject x) can be written as integer(x)
•Syntax for first order logic:
In prepositional logic, every expression is a sentence that represents a fact.
•First order logic includes the sentences along with terms which can represent the objects.
•Constant symbols, variables and function symbols are used to build terms, while quantifiers and
predicate symbols are used to build the sentences.
•Syntax:
Constants A, B, C 1, 6, A,W,New York, Elie, Dog.....
Functions Size, Color, Sqrt, LessThan, Sin(θ), size...
Variable x, a
Terms Constant, variable or function(Term..)
Predicates True, False, <, >, brother, sister, father
Quantifiers ∀, ∃
Atomic sentences Predicate, Predicate(Term,…), Term=Term
Sentences ¬ Sentence, Sentence ∨ Sentence, Sentence ∧
Sentence, Sentence ⇒ Sentence, Sentence ⇔
Sentence, Quantifier Variable,… Sentence
Predicates vs Functions
• Predicates are relationships between things
– Objects in
– Truth out
• Functions are mappings between things
– Objects in
– Objects out
Predicates are essentially functions with Boolean output, but
• Predicates combine symbols to form atomic sentences
– True or false (under a given model)
• Functions combine symbols to form terms
– Expressions which refer to objects
Atomic and complex sentences in FOL
1. Atomic Sentence
•This is a basic sentence of FOL formed from a predicate symbol followed by a parenthesis with a sequence of
terms.
•We can represent atomic sentences as a predicate (value1, value2…., value n) or predicate(term1,…term n)
Example
1.John and Michael are colleagues → Colleagues (John,
Michael)
2.German Shepherd is a dog → Dog (German Shepherd)
2. Complex sentence
Complex sentences are made by combining atomic sentences using connectives. By negation, conjunction, disjunction,
bidirectional etc
FOL is further divided into two parts:
•Subject: the main part of the statement.
•Predicate: defined as a relation that binds two atoms together.
Example
1.Colleague (Oliver, Benjamin) ∧ Colleague (Benjamin, Oliver)
2.“x is an integer”
It has two parts;
Ram is a king or ram is not a king King is a predicate/class, ram is object/subject
King(ram)V¬king(ram)
•first, x is the subject.
•second, “is an integer” is called a predicate.
Quantifiers in First-order logic
•A quantifier is a language element which generates quantification, and quantification specifies the quantity of
specimen in the universe of discourse.
•The variable of predicates is quantified by qunatifiers.
•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 quantifier:
• Universal Quantifier, (for all, everyone, everything)
• Existential quantifier, (for some, at least one).
Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the statement within its range is true
for everything or every instance of a particular thing.
The Universal quantifier is represented by a symbol ∀, (for all) which resembles an inverted A.
∀<variable> <sentence>
Note: In universal quantifier we use implication "→"
If x is a variable, then ∀x is read as:
For all x
For each x
For every x.
Example:
All man drink coffee.
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who
drink coffee.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true for at
least one instance of something.
It is denoted by the logical operator ∃ (there exists), which resembles as inverted E. When it is used with a predicate
variable then it is called as an existential quantifier.
Note: In Existential quantifier we always use AND or Conjunction symbol (∧).
Let a variable x which refers to a cat so all x can be represented
in UOD as below:
If x is a variable, then existential quantifier will be ∃x or
∃(x). And it will be read as:
•There exists a 'x.'
•For some 'x.'
•For at least one 'x.'
Example:
Some boys are intelligent.
∃x: boys(x) ∧ intelligent(x)
It will be read as: There are some x where x is represent
as boy (predicate) who is intelligent (predicate)
X present in boys and intelligent are variable which
indicates subject or the objects.
Points to remember:
•The main connective for universal quantifier ∀ is implication →.
•The main connective for existential quantifier ∃ is and ∧ (disjunction).
Properties of Quantifiers:
•In universal quantifier, ∀x∀y is similar to ∀y∀x.
•In Existential quantifier, ∃x∃y is similar to ∃y∃x.
•∃x∀y is not similar to ∀y∃x.
Nested quantifiers & their uses
We can use both quantifiers together, but it’s not a type of quantifier; rather, it’s an outlier category.
•Nested quantifier refers to when one quantifier is within the scope of another quantifier.
•These quantifiers can be represented using the ∃x∀x signs.
•Here are some examples to understand this type of quantifier.
1.∃xy ∀x ∀y((x< 0) ∧ (y< 0) → (xy = 8))
This can be interpreted as: For every real number x and y ∈ ℝ, if x is negative and y is also negative,
implies for some values of xy must be equal to 8.
Example for not similar:
∃x∀y loves(x,y)
There is a person (single person is existential quantifier) who loves everyone in the world
∀y ∃x loves(y,x)
Everyone in the world is loved by at least one person
Equality
• term1 = term2 is true under a given interpretation if and only if term1 and term2 refer to the same object
– Father(John) = Henry
• Can also be used to state facts about functions
• 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)]
Domain is a section of the knowledge representation
1. Kindship domain
2. Mathematical sers
3. Assertion and queries in FOL
4. Wumpus world
Kinship Domain (Family relationship)
It consist of
Object=people
Unary predicates= male, female
Binary predicates=parent, brother, sister
Functions-father, mother
Relations-brotherhood, sisterhood
FOL inference rules for quantifier:
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, which is a valid inference rule in first-order logic.
•It can be applied only once to replace the existential sentence.
•The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was satisfiable.
•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:
Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge base.
•The above used K is a constant symbol, which is called Skolem constant.
•The Existential instantiation is a special case of Skolemization process.
4. Existential introduction
•An existential introduction is also known as an existential generalization, which is a valid inference rule in first-order
logic.
•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:
•Example: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Unification
• Unification is a kind of binding logic between two or more variables
• In propositional logic it is easy to determine that two literals can not both be true at same time
• Ex: Man(Sunil and ¬Man(Sunil) is a contradiction
While Man(Sunil) and ¬Man(Arun) is not contradiction
• In predicate logic, this matching process is more complicated since bindings of variables must be considered.
• In predicate logic in order to determine contradiction we need a matching procedure that compares two literals and
discovers whether there exists a set of substitutions that make them identical. This is where Unification algorithm is
used.
• The goal of unification is to make two expression look like identical by using substitution.
• It means the meaning if the sentence should not be changed, but it should be expressed in multiple ways
• The UNIFY algorithm in unification take two sentences as input and then return a unifer if one exists:
• - Substitution means replacing one variable with another term.
• - It takes two literals as input and makes them identical using substitution.
• - It returns fail if the expression d not match with each other.
• UNIFY(p,q)= θ where SUBST(θ,p)=SUBST(θ,q) (SUBST is substitution, p, q are atomic sentence where the SUBST
θ such that, by applying SUBST function θ on p,q, then p,q becomes equal , where p,q are the predicates with their
own arguments)
Example 1:
Lets say there are two different expressions/predicate/literal,
P(x,y) and P(a,f(z))
We need to make both above statements identical to each other.
Perform substitution,
P(x, y)…….(i)
P(a, f(z))…..(ii)
Substitute x with a and y with f(z) in the first expression, and it will be represented as z/x and f(z)/y
With both the substitutions, the first expression will be identical to the second expression and substitution set will be
[a/x, f(z)/y]
Note: why you need unification : because machine need to be intelligent like humans, and machine has its own KB,
so for given a statement, machine needs to search in KB what is similar and accordingly the result will be given.
Example 2:
Given: knows(Ram, x) is a predicate
My question is : Whom does Ram knows?
The UNIFY algorithm will search all the related sentences in the knowledge base which could unify with
Knows(Ram, x)
UNIFY (Knows(Ram,x), Knows(Ram, Shyam)) ≡ {x/Shyam} (both arguments are same and ram are same in both)
UNIFY(Knows{Ram,x}, Knows{y, Akash}) ≡ {x/Akash, y/Ram} (akash is replaced by variable by x……
UNIFY (Knows{Ram, x}, Knows{x, Raman}) ≡ fails //Unifier is empty (same variable x is used so fail)
The last one is failed because we have used the same variable for two persons or the two sentences happen to use
the same variable name, x
Unification are attempted only with sentences that have some chance of unifying.
For example, there is no point in trying to
Unify Knows(Ram, x) with Brother(Laxman, Ram) //predicates are different like “knows and brother” so unification not
possible and no logical binding of two statments because know and brother are logically incorrect.
Conditions for Unification
• Predicate symbol must be same, atoms or expression with different predicate symbol can never be
unified.
Tryassassinate (Marcus, Caesar)
Hate (Marcus, Caesar) //tryassassiate and hate are not identical
• Number of Arguments in both expression must be identical
Hate(Marcus)
Hate(Marcus, Caesar) // Marcus and (Marcus ,Caesar) are not identical
• Unification will fail if there are two similar variables present in the same expression.
UNIFY (Knows{Ram, x}, Knows{x, Raman}) ≡ fails
Inference Engine –Forward & Backward Chaining
The inference engine is the component of the expert system in AI which applies logical rules to the KB to infer new
information from known facts.
Forward and Backward chaining is the strategies used by the inference Engine in making the deductions.
Logical inference algorithm use forward and backward chaining approaches, which require KB in the form of first
order clause.
The inference engine compares each rule stored in the KB with facts contained in the DB.
When the IF(condition) part of the rules matches a fact, the rule is fired and its THEN(action) part is executed.
The matching of the rule IF parts to the facts produce inference chains.
The inference chain indicates how an expert system applies the rules to reach a conclusion.
Forward Chaining
It is form of reasoning which start with atomic sentences in the knowledge base and applies inference rules (Modus
Ponens) in the forward direction to extract more data until a goal is reached.
Here facts are held in a working memory and condition action rules represent actions to take when specified facts
occur in working memory it may add and delete facts from working memory.
Properties of FC:
• It is a bottom up approach as it moves from bottom to top.
• It is a process of making conclusion based on known facts or data, bys tarting from the initial state and reaches
the goal state.
• FC approach is also called as data driven as the date determines which rules are selected and used.
• Example:
• Given,
• A He exercises regularly
• A B If he is exercising, he is fit
• The new knowledge it could generate is,
• B He is fit.
Example:
Rule 1: IF student is excellent in academics
AND he is good in sports
THEN he is all rounder (// GOAL, ned to prove he is all rounder)
Rule 2: IF student gets marks>80
AND he is good in general knowledge
THEN he is excellent in academics
Rule 3: IF student is making centuries
THEN he is good in sports
Given following facts(Data):
1. Student get marks>80
2. Student is making centuries
3. He is good in general knowledge
From the given facts, We need to infer the “student is all rounder” which is our goal
From the fact 1 and 3, is present in rule 2 and prove he is excellent is academics (//sub goal)
Remaining fact 2, is present in rule 3 and prove he is good in sports (// next sub goal)
Now we need to check sub goals is present in rule 1 and prove he is all rounder (//goal obtained)
Example:
"As per the law, it is a crime for an American to sell weapons to hostile nations. Country A, an enemy of
America, has some missiles, and all the missiles were sold to it by Robert, who is an American citizen."
Prove that "Robert is criminal."
To solve the above problem, first, we will convert all the above facts into first-order definite clauses, and then we will
use a forward-chaining algorithm to reach the goal.
Facts Conversion into FOL:
•It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
•Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can be written in two definite clauses by using
Existential Instantiation, introducing new Constant T1.
Owns(A, T1) ......(2)
Missile(T1) .......(3)
•All of the missiles were sold to country A by Robert.
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
•Missiles are weapons.
Missile(p) → Weapons (p) .......(5)
•Enemy of America is known as hostile.
Enemy(p, America) →Hostile(p) ........(6)
•Country A is an enemy of America.
Enemy (A, America) .........(7)
•Robert is American
American(Robert). ..........(8)
Forward chaining proof:
Step-1:
In the first step we will start with the known facts and will choose the sentences which do not have implications,
such as: American(Robert), Enemy(A, America), Owns(A, T1), and Missile(T1). All these facts will be
represented as below.
Step-2:
At the second step, we will see those facts which infer from available facts and with satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Rule-(2) and (3) are already added.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which infers from the conjunction of
Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from Rule-(7).
Step-3:
At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1, r/A}, so we can add
Criminal(Robert) which infers all the available facts. And hence we reached our goal statement.
Hence it is proved that Robert is Criminal using forward chaining approach.
Backward Chaining
It is a goal driven method of deriving a particular goal from a given knowledge base and set of inference rules.
The inference system knows the final decision or goal this system starts from the goal and works backwards to
determine what facts must be asserted so that the goal can be achieved.
Example:
B He is fit
A If he is exercising, he is fit
A He exercises regularly.
Properties of BC:
It is known as a top down approach.
BC is based on Modus Ponens inference rule.
The goal is broken into sub goal or sub goals to prove the facts true.
It is called goal driven approach as a list of goals decides which rules are selected and used.
Example: This is opposite of FC. Here the interpreter tries to match the THEN condition instead of IF condition as
in FC
Rule 1: IF student is excellent in academics
AND he is good in sports
THEN he is all rounder (// GOAL, ned to prove he is all rounder)
Rule 2: IF student gets marks>80
AND he is good in general knowledge
THEN he is excellent in academics
Rule 3: IF student is making centuries
THEN he is good in sports
Given following facts(Data):
1. Student get marks>80
2. Student is making centuries
3. He is good in general knowledge
From the given facts, We need to infer the “student is all rounder” which is our goal
From the goal “ he is all rounder” we are going to check THEN, which is present in rule 1 and get the facts of 1 and
3 in IF- AND
The subpart is “He is good is sports” check in Rule 3 THEN and get the facts 2 “student is making centuries” Thus
from the goal we proved the facts
Example:
In backward-chaining, we will use the same above example, and will rewrite all the rules.
•American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
Owns(A, T1) ........(2)
•Missile(T1)
•?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
•Missile(p) → Weapons (p) .......(5)
•Enemy(p, America) →Hostile(p) ........(6)
•Enemy (A, America) .........(7)
•American(Robert). ..........(8)
Backward-Chaining proof:
In Backward chaining, we will start with our goal predicate, which is Criminal(Robert), and then infer further rules.
Step-1:
At the first step, we will take the goal fact. And from the goal fact, we will infer other facts, and at last, we will prove
those facts true. So our goal fact is "Robert is Criminal," so following is the predicate of it.
Step-2:
At the second step, we will infer other facts form goal fact which satisfies the rules. So as we can see in Rule-1,
the goal predicate Criminal (Robert) is present with substitution {Robert/P}. So we will add all the conjunctive facts
below the first level and will replace p with Robert.
Here we can see American (Robert) is a fact, so it is proved here.
Step-3:t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it satisfies Rule-(5). Weapon
(q) is also true with the substitution of a constant T1 at q.
Step-4:
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r) which satisfies the Rule- 4, with
the substitution of A in place of r. So these two statements are proved here.
Step-5:
At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which satisfies Rule- 6. And hence all the
statements are proved true using backward chaining.
What is Logic Programming?
A type of programming consisting of facts and relationships from which the programming language can draw a conclusion.
– In imperative programming languages, we tell the computer what to do by programming the procedure by which program
states and variables are modified.
– In contrast, in logical programming, we don’t tell the computer exactly what it should do (i.e., how to derive a conclusion).
User provided facts and relationships allow it to derive answers via logical inference.
Prolog is the most widely used logic programming language.
Prolog Features
Prolog uses logical variables:
These are not the same as variables in other languages.
Programmers can use them as ‘holes’ in data structures that are gradually filled in as computation proceeds.
Unification is a built-in term-manipulation method that passes parameters, returns results, selects and constructs data
structures.
Basic control flow model is backtracking.
Program clauses and data have the same form.
– A Prolog program can also be seen as a relational database containing rules as well as facts.
What is Knowledge Engineering?
it is a field that concentrates on creating a knowledge base for a specific domain. It includes an in-depth investigation
of a particular domain, learning all the important concepts about that domain, and then drafting out meaningful
output.
For example, we want to automate the teaching process for children in the subject of mathematics. It will require the
knowledge of teachers, subject matter experts, and data from previous batches and their performance in maths.
The general workflow to do this, we need to process the metadata (all about data, its quality, content, structure,
objects, and format) in order to have a basic idea of what it takes to make a decision.
In a general sense, it takes a problem to solve and then studies the factors which a human expert will consider while
making a decision. A human expert will consider a number of parameters and some will be more important than
others. After considering all the parameters human expert makes permutation and combinations using his prior
experience with domain and give weightage to all the parameters and makes a decision. This all just happens in some
fractions, but to investigate the whole process takes a good amount of time depending on the complexity of the
problem.
Knowledge engineering is the base that helped in the creation of expert systems where knowledge is transformed
into computer programs. Expert systems have a huge and flexible knowledge base which is integrated with
mechanisms that specify how to use the information of the knowledge base and apply it to a variety of situations.
These expert systems also use machine learning and deep learning algorithms in order to learn as humans do.
Nowadays these Expert systems are used in the education field, healthcare, financial services, manufacturing, etc.
Knowledge Engineering for different domains is different but it follows, the same set of procedures in
order to create expert systems.
1. Task Identification
This is the first step in the knowledge engineering process where the task to be performed is defined. In
a domain, a specific problem or a combination of several problems would be taken. This task must be
realistic and the subject matter expert needs to have a clear idea of what it is so that further process can
be carried out.
2. Acquisition of Knowledge
Once the problem is well defined then the next step is to gather relevant knowledge and information
about the problem. For some problems standard data is used that must be collected, for example, a
problem on heat exchanger requires the standard steam table data at x temperature and y pressure what
will be the value of enthalpy.
3. Prepare a road map
Once the goal and knowledge base are available the next step is to get the roadmap ready by breaking
the goal down into small steps by questionnaires and relevant knowledge base. Here the subject matter
expert puts his thoughts on how he would make decisions and what parameters would be considered at
all stages. There could be several ways to solve some problems, and all should be considered.
4. Encode
Now it’s time to convert this knowledge into computer language. Here the knowledge is encoded by
using different functions as well as in some cases, for a specific task, the algorithm is used to create a
model. These models are able to make decisions based on available parameters as an expert does, surely
the model must be trained and tested on a sufficient amount of data.
5. Evaluation and Debugging
In the process of creating an expert system, at each step, the model should be evaluated and debugged
then added to workflow. Once all small tasks are evaluated, they are assembled to create one whole expert
system. This system is again evaluated on similar problems and Debugged if any issue is there.
Benefits of Knowledge Engineering are as follows:
1.Knowledge engineering helps in creating better, smarter more effective expert system.
2.Models created with knowledge engineering are robust.
•It is possible to pull knowledge from various domains together to handle complicated issues.
•When built with Natural Language Programming (NLP) and knowledge engineering together, expert
have the ability to read the queries and provide answers and solutions, in a manner somewhat similar to
way a chatbot behaves.
Knowledge engineering process in an electronic circuit domain, which is already familiar. This approach is mainly
suitable for creating special-purpose knowledge base.
The knowledge-engineering process:
Following are some main steps of the knowledge-engineering process. Using these steps, we will develop a
knowledge base which will allow us to reason about digital circuit (One-bit full adder) which is given below
1. Identify the task:
The first step of the process is to identify the task, and for the digital circuit, there are various reasoning tasks.
At the first level or highest level, we will examine the functionality of the circuit:
•Does the circuit add properly?
•What will be the output of gate A2, if all the inputs are high?
At the second level, we will examine the circuit structure details such as:
•Which gate is connected to the first input terminal?
•Does the circuit have feedback loops?
2. Assemble the relevant knowledge:
In the second step, we will assemble the relevant knowledge which is required for digital circuits. So for digital
circuits, we have the following required knowledge:
•Logic circuits are made up of wires and gates.
•Signal flows through wires to the input terminal of the gate, and each gate produces the corresponding output
which flows further.
•In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.
•All these gates have one output terminal and two input terminals (except NOT gate, it has one input terminal).
3. Decide on vocabulary:
The next step of the process is to select functions, predicate, and constants to represent the circuits, terminals,
signals, and gates. Firstly we will distinguish the gates from each other and from other objects. Each gate is
represented as an object which is named by a constant, such as, Gate(X1). The functionality of each gate is
determined by its type, which is taken as constants such as AND, OR, XOR, or NOT. Circuits will be identified by a
predicate: Circuit (C1).
For the terminal, we will use predicate: Terminal(x).
For gate input, we will use the function In(1, X1) for denoting the first input terminal of the gate, and for output
terminal we will use Out (1, X1).
The function Arity(c, i, j) is used to denote that circuit c has i input, j output.
The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1))
We use a unary predicate On (t), which is true if the signal at a terminal is on.
4. Encode general knowledge about the domain:
To encode the general knowledge about the logic circuit, we need some following rules:
•If two terminals are connected then they have the same input signal, it can be represented as:
•∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (2).
•Signal at every terminal will have either value 0 or 1, it will be represented as:
•∀ t Terminal (t) →Signal (t) = 1 ∨Signal (t) = 0.
•Connect predicates are commutative:
•∀ t1, t2 Connect(t1, t2) → Connect (t2, t1).
•Representation of types of gates:
•∀ g Gate(g) ∧ r = Type(g) → r = OR ∨r = AND ∨r = XOR ∨r = NOT.
•Output of AND gate will be zero if and only if any of its input is zero.
•∀ g Gate(g) ∧ Type(g) = AND →Signal (Out(1, g))= 0 ⇔ ∃n Signal (In(n, g))= 0.
•Output of OR gate is 1 if and only if any of its input is 1:
•∀ g Gate(g) ∧ Type(g) = OR → Signal (Out(1, g))= 1 ⇔ ∃n Signal (In(n, g))= 1
•Output of XOR gate is 1 if and only if its inputs are different:
•∀ g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔ Signal (In(1, g)) ≠ Signal (In(2, g)).
•Output of NOT gate is invert of its input:
•∀ g Gate(g) ∧ Type(g) = NOT → Signal (In(1, g)) ≠ Signal (Out(1, g)).
•All the gates in the above circuit have two inputs and one output (except NOT gate).
1.∀ g Gate(g) ∧ Type(g) = NOT → Arity(g, 1, 1)
2.∀ g Gate(g) ∧ r =Type(g) ∧ (r= AND ∨r= OR ∨r= XOR) → Arity (g, 2, 1).
•All gates are logic circuits
•∀ g Gate(g) → Circuit (g).
5. Encode a description of the problem instance:
Now we encode problem of circuit C1, firstly we categorize the circuit and its gate components. This step is easy if
ontology about the problem is already thought. This step involves the writing simple atomics sentences of instances
of concepts, which is known as ontology.
For the given circuit C1, we can encode the problem instance in atomic sentences as below:
Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be:
1.For XOR gate: Type(x1)= XOR, Type(X2) = XOR
2.For AND gate: Type(A1) = AND, Type(A2)= AND
3.For OR gate: Type (O1) = OR.
And then represent the connections between all the gates.
6. Pose queries to the inference procedure and get answers:
In this step, we will find all the possible set of values of all the terminal for the adder circuit. The first query will be:
What should be the combination of input which would generate the first output of circuit C1, as 0 and a second output
to be 1?
1.∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C1))= i3
2. ∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1
7. Debug the knowledge base:
Now we will debug the knowledge base, and this is the last step of the complete process. In this step, we will try to
debug the issues of knowledge base.
In the knowledge base, we may have omitted assertions like 1 ≠ 0.
Truth maintenance systems (TMS) are also called reason maintenance systems.
TMS plays with uncertainty by permitting new knowledge to replace old knowledge which is believed to be outdated or erroneous.
TMS is a problem solver module responsible for,
Enforcing logical relations among beliefs
Generating explanation for conclusions
Finding solutions to search problems
Supporting default reasoning
Identifying causes for failure and recover from inconsistencies
Working Principle of TMS:
The Inference Engine (IE) solves domain problems based on its current belief set, while the TMS maintains
The updating process is incremental.
After each inference, information exchange between the two components.
The IE tells the TMS what deductions it has made.
The TMS, in turn, asks a question about current beliefs and reasons for failure. If maintains a consistent
even if now knowledge is added or removed.
Step1: Say, The KB contains the propositions P, P->Q and modus ponens.
Step2: From this, the IE would rightfully conclude Q and add this conclusion to the KB.
Step3: Later, if it was learned that P was appropriate, it would be added to the KB resulting in a
Step4: Consequently, it would be necessary to remove P to eliminate the inconsistency.
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.
Where li and mj are complementary literals.
This rule is also called the binary resolution rule because it only resolves exactly two literals.
Example:
We can resolve two clauses which are given below:
[Animal (g(x) V Loves (f(x), x)] and [¬ Loves(a, b) V ¬Kills(a, b)]
Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b)
These literals can be unified with unifier θ= [a/f(x), and b/x] , and it will generate a resolvent clause:
[Animal (g(x) V ¬ Kills(f(x), x)].
Steps for Resolution:
1.Conversion of facts into first-order logic.
2.Convert FOL statements into CNF
3.Negate the statement which needs to prove (proof by contradiction)
4.Draw resolution graph (unification).
Example:
1.John likes all kind of food.
2.Apple and vegetable are food
3.Anything anyone eats and not killed is food.
4.Anil eats peanuts and still alive
5.Harry eats everything that Anil eats.
Prove by resolution that:
6.John likes peanuts.
Step-1: Conversion of Facts into FOL
In the first step we will convert all the given statements into its first order logic.
Step-2: Conversion of FOL into CNF
In First order logic resolution, it is required to convert the FOL into CNF as CNF form makes easier for resolution
proofs.
1. Eliminate all implication (→ with ¬, V ) and rewrite
• ∀x ¬ food(x) V likes(John, x)
• food(Apple) Λ food(vegetables)
• ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
• eats (Anil, Peanuts) Λ alive(Anil)
• ∀x ¬ eats(Anil, x) V eats(Harry, x)
• ∀x¬ [¬ killed(x) ] V alive(x)
• ∀x ¬ alive(x) V ¬ killed(x)
• likes(John, Peanuts).
2. Move negation (¬)inwards and rewrite
• ∀x ¬ food(x) V likes(John, x)
• food(Apple) Λ food(vegetables)
• ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
• eats (Anil, Peanuts) Λ alive(Anil)
• ∀x ¬ eats(Anil, x) V eats(Harry, x)
• ∀x ¬killed(x) ] V alive(x)
• ∀x ¬ alive(x) V ¬ killed(x)
• likes(John, Peanuts).
3. Rename variables or standardize variables
• ∀x ¬ food(x) V likes(John, x)
• food(Apple) Λ food(vegetables)
• ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
• eats (Anil, Peanuts) Λ alive(Anil)
• ∀w¬ eats(Anil, w) V eats(Harry, w)
• ∀g ¬killed(g) ] V alive(g)
• ∀k ¬ alive(k) V ¬ killed(k)
• likes(John, Peanuts).
•Eliminate existential instantiation quantifier by elimination.
In this step, we will eliminate existential quantifier ∃, and this process is known as Skolemization. But in this example
problem since there is no existential quantifier so all the statements will remain same in this step.
•Drop Universal quantifiers.
In this step we will drop all universal quantifier since all the statements are not implicitly quantified so we don't need it.
1.¬ food(x) V likes(John, x)
2.food(Apple)
3.food(vegetables)
4.¬ eats(y, z) V killed(y) V food(z)
5.eats (Anil, Peanuts)
6.alive(Anil)
7.¬ eats(Anil, w) V eats(Harry, w)
8.killed(g) V alive(g)
9.¬ alive(k) V ¬ killed(k)
10.likes(John, Peanuts).
•Distribute conjunction ∧ over disjunction ¬.
This step will not make any change in this problem.
Step-3: Negate the statement to be proved (proof by refutation)
In this statement, we will apply negation to the conclusion last statements, which will be written as ¬likes(John,
Peanuts)
Step-4: Draw Resolution graph:
Now in this step, we will solve the problem by resolution tree using substitution. For the above problem, it will be
given as follows:
Hence the negation of the conclusion has been proved as a complete contradiction with the given set of
statements.
Examples of Predicate Logic practise it:
All students are smart.
∀ x ( Student(x) ⇒ Smart(x) )
There exists a student.
∃ x Student(x).
There exists a smart student.
∃ x ( Student(x) ∧ Smart(x) )
Every student loves some student.
∀ x ( Student(x) ⇒ ∃ y ( Student(y) ∧ Loves(x,y) ))
Every student loves some other student.
∀ x ( Student(x) ⇒ ∃ y ( Student(y) ∧ ¬ (x = y) ∧ Loves(x,y) ))
There is a student who is loved by every other student.
∃ x ( Student(x) ∧ ∀ y ( Student(y) ∧ ¬(x = y) ⇒ Loves(y,x) ))
Bill is a student.
Student(Bill)
Bill takes either Analysis or Geometry (but not both)
Takes(Bill, Analysis) ⇔ ¬ Takes(Bill, Geometry)
Bill takes Analysis or Geometry (or both).
Takes(Bill, Analysis) ∨ Takes(Bill, Geometry)
Bill takes Analysis and Geometry.
Takes(Bill, Analysis) ∧ Takes(Bill, Geometry)
Bill does not take Analysis.
¬ Takes(Bill, Analysis).
No student loves Bill.
¬ ∃ x ( Student(x) ∧ Loves(x, Bill) )
Bill has at least one sister.
∃ x SisterOf(x,Bill)
Bill has no sister.
¬ ∃ x SisterOf(x,Bill)
Bill has at most one sister.
∀ x, y ( SisterOf(x, Bill) ∧ SisterOf(y, Bill) ⇒ x = y )
Bill has exactly one sister.
∃ x ( SisterOf(x, Bill) ∧ ∀ y ( SisterOf(y, Bill) ⇒ x = y ))
Bill has at least two sisters.
∃ x, y ( SisterOf(x, Bill) ∧ SisterOf(y, Bill) ∧ ¬ (x = y) )
Every student takes at least one course.
∀ x ( Student(x) ⇒ ∃ y ( Course(y) ∧ Takes(x,y) ))
Only one student failed History.
∃ x ( Student(x) ∧ Failed(x, History) ∧ ∀ y ( Student(y) ∧ Failed(y, History) ⇒ x = y ))
No student failed Chemistry but at least one student failed History.
¬ ∃ x ( Student(x) ∧ Failed(x, Chemistry) ) ∧ ∃ x ( Student(x) ∧ Failed(x, History) )
Every student who takes Analysis also takes Geometry.
∀ x ( Student(x) ∧ Takes(x, Analysis) ⇒ Takes(x, Geometry) )
No student can fool all the other students.
¬ ∃ x ( Student(x) ∧ ∀ y ( Student(y) ∧ ¬ (x = y) ⇒ Fools(x,y) ))

More Related Content

Similar to pending-1664760315-2 knowledge based agent student.pptx

Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)vikas dhakane
 
Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)vikas dhakane
 
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERgerogepatton
 
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERijaia
 
Knowledge Base and AI Agents.pptx
Knowledge Base and AI Agents.pptxKnowledge Base and AI Agents.pptx
Knowledge Base and AI Agents.pptxWaqas Ahmad
 
LearningAG.ppt
LearningAG.pptLearningAG.ppt
LearningAG.pptbutest
 
Ai lecture 02(unit-02)
Ai lecture  02(unit-02) Ai lecture  02(unit-02)
Ai lecture 02(unit-02) vikas dhakane
 
Artificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge RepresentationArtificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge RepresentationThenmozhiK5
 
5.-Knowledge-Representation-in-AI_010824.pdf
5.-Knowledge-Representation-in-AI_010824.pdf5.-Knowledge-Representation-in-AI_010824.pdf
5.-Knowledge-Representation-in-AI_010824.pdfSakshiSingh770619
 
Architecture for Intelligent Agents Logic-Based Architecture Logic-based arc...
Architecture for Intelligent Agents Logic-Based Architecture  Logic-based arc...Architecture for Intelligent Agents Logic-Based Architecture  Logic-based arc...
Architecture for Intelligent Agents Logic-Based Architecture Logic-based arc...kathavera906
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AIVishal Singh
 
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriyaVijiPriya Jeyamani
 
Advanced user agent v clean
Advanced user agent v cleanAdvanced user agent v clean
Advanced user agent v cleanSTIinnsbruck
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligencesanjay_asati
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxRaviKiranVarma4
 

Similar to pending-1664760315-2 knowledge based agent student.pptx (20)

UNIT 2.pdf
UNIT 2.pdfUNIT 2.pdf
UNIT 2.pdf
 
Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)
 
Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)
 
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
 
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVERANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
 
Expert system
Expert systemExpert system
Expert system
 
Knowledge Base and AI Agents.pptx
Knowledge Base and AI Agents.pptxKnowledge Base and AI Agents.pptx
Knowledge Base and AI Agents.pptx
 
LearningAG.ppt
LearningAG.pptLearningAG.ppt
LearningAG.ppt
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
Ai lecture 02(unit-02)
Ai lecture  02(unit-02) Ai lecture  02(unit-02)
Ai lecture 02(unit-02)
 
Artificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge RepresentationArtificial Intelligence_ Knowledge Representation
Artificial Intelligence_ Knowledge Representation
 
5.-Knowledge-Representation-in-AI_010824.pdf
5.-Knowledge-Representation-in-AI_010824.pdf5.-Knowledge-Representation-in-AI_010824.pdf
5.-Knowledge-Representation-in-AI_010824.pdf
 
Architecture for Intelligent Agents Logic-Based Architecture Logic-based arc...
Architecture for Intelligent Agents Logic-Based Architecture  Logic-based arc...Architecture for Intelligent Agents Logic-Based Architecture  Logic-based arc...
Architecture for Intelligent Agents Logic-Based Architecture Logic-based arc...
 
Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
 
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
Expert System Lecture Notes Chapter 1,2,3,4,5 - Dr.J.VijiPriya
 
Advanced user agent v clean
Advanced user agent v cleanAdvanced user agent v clean
Advanced user agent v clean
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-3.pptx
 

More from kumarkaushal17

Open Source Cloud Computing (1).pptx
Open Source Cloud Computing (1).pptxOpen Source Cloud Computing (1).pptx
Open Source Cloud Computing (1).pptxkumarkaushal17
 
Chat application firebase.pptx1.pptx
Chat application firebase.pptx1.pptxChat application firebase.pptx1.pptx
Chat application firebase.pptx1.pptxkumarkaushal17
 
todd-ncts-2011-110828224616-phpapp02 (1).pptx
todd-ncts-2011-110828224616-phpapp02 (1).pptxtodd-ncts-2011-110828224616-phpapp02 (1).pptx
todd-ncts-2011-110828224616-phpapp02 (1).pptxkumarkaushal17
 
osi-security-architectureppt.pptx
osi-security-architectureppt.pptxosi-security-architectureppt.pptx
osi-security-architectureppt.pptxkumarkaushal17
 
DOC-20230427-WA0009..pptx
DOC-20230427-WA0009..pptxDOC-20230427-WA0009..pptx
DOC-20230427-WA0009..pptxkumarkaushal17
 
DOC-20230427-WA0010..pptx
DOC-20230427-WA0010..pptxDOC-20230427-WA0010..pptx
DOC-20230427-WA0010..pptxkumarkaushal17
 
DOC-20230427-WA0012..pptx
DOC-20230427-WA0012..pptxDOC-20230427-WA0012..pptx
DOC-20230427-WA0012..pptxkumarkaushal17
 
4. OPTIMIZATION NN AND FL.pptx
4. OPTIMIZATION NN AND FL.pptx4. OPTIMIZATION NN AND FL.pptx
4. OPTIMIZATION NN AND FL.pptxkumarkaushal17
 
Cloud_Deployment_Model (1).pptx
Cloud_Deployment_Model (1).pptxCloud_Deployment_Model (1).pptx
Cloud_Deployment_Model (1).pptxkumarkaushal17
 
pending-1664760315-2 knowledge based agent student.pptx
pending-1664760315-2 knowledge based agent student.pptxpending-1664760315-2 knowledge based agent student.pptx
pending-1664760315-2 knowledge based agent student.pptxkumarkaushal17
 
cs344-lect4-logic-14jan08.ppt
cs344-lect4-logic-14jan08.pptcs344-lect4-logic-14jan08.ppt
cs344-lect4-logic-14jan08.pptkumarkaushal17
 
dbmspresentation-161126155322.pptx
dbmspresentation-161126155322.pptxdbmspresentation-161126155322.pptx
dbmspresentation-161126155322.pptxkumarkaushal17
 
MYSQL GROUP FUNCTION.pptx
MYSQL GROUP FUNCTION.pptxMYSQL GROUP FUNCTION.pptx
MYSQL GROUP FUNCTION.pptxkumarkaushal17
 

More from kumarkaushal17 (20)

RM 4 UNIT.pptx
RM 4 UNIT.pptxRM 4 UNIT.pptx
RM 4 UNIT.pptx
 
Open Source Cloud Computing (1).pptx
Open Source Cloud Computing (1).pptxOpen Source Cloud Computing (1).pptx
Open Source Cloud Computing (1).pptx
 
Chat application firebase.pptx1.pptx
Chat application firebase.pptx1.pptxChat application firebase.pptx1.pptx
Chat application firebase.pptx1.pptx
 
5 UNIT RM.pptx
5 UNIT RM.pptx5 UNIT RM.pptx
5 UNIT RM.pptx
 
todd-ncts-2011-110828224616-phpapp02 (1).pptx
todd-ncts-2011-110828224616-phpapp02 (1).pptxtodd-ncts-2011-110828224616-phpapp02 (1).pptx
todd-ncts-2011-110828224616-phpapp02 (1).pptx
 
osi-security-architectureppt.pptx
osi-security-architectureppt.pptxosi-security-architectureppt.pptx
osi-security-architectureppt.pptx
 
Microservice.pptx
Microservice.pptxMicroservice.pptx
Microservice.pptx
 
DOC-20230427-WA0009..pptx
DOC-20230427-WA0009..pptxDOC-20230427-WA0009..pptx
DOC-20230427-WA0009..pptx
 
DOC-20230427-WA0010..pptx
DOC-20230427-WA0010..pptxDOC-20230427-WA0010..pptx
DOC-20230427-WA0010..pptx
 
DOC-20230427-WA0012..pptx
DOC-20230427-WA0012..pptxDOC-20230427-WA0012..pptx
DOC-20230427-WA0012..pptx
 
Semiservice.pptx
Semiservice.pptxSemiservice.pptx
Semiservice.pptx
 
4. OPTIMIZATION NN AND FL.pptx
4. OPTIMIZATION NN AND FL.pptx4. OPTIMIZATION NN AND FL.pptx
4. OPTIMIZATION NN AND FL.pptx
 
Cloud_Deployment_Model (1).pptx
Cloud_Deployment_Model (1).pptxCloud_Deployment_Model (1).pptx
Cloud_Deployment_Model (1).pptx
 
pending-1664760315-2 knowledge based agent student.pptx
pending-1664760315-2 knowledge based agent student.pptxpending-1664760315-2 knowledge based agent student.pptx
pending-1664760315-2 knowledge based agent student.pptx
 
cs344-lect4-logic-14jan08.ppt
cs344-lect4-logic-14jan08.pptcs344-lect4-logic-14jan08.ppt
cs344-lect4-logic-14jan08.ppt
 
dbmspresentation-161126155322.pptx
dbmspresentation-161126155322.pptxdbmspresentation-161126155322.pptx
dbmspresentation-161126155322.pptx
 
MYSQL GROUP FUNCTION.pptx
MYSQL GROUP FUNCTION.pptxMYSQL GROUP FUNCTION.pptx
MYSQL GROUP FUNCTION.pptx
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
 
IPv4-ppt.k.pptx
IPv4-ppt.k.pptxIPv4-ppt.k.pptx
IPv4-ppt.k.pptx
 
module 3-.pptx
module 3-.pptxmodule 3-.pptx
module 3-.pptx
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 

pending-1664760315-2 knowledge based agent student.pptx

  • 1. 2. KNOWLEDGE BASED AGENTS Knowledge-based agents; The Wumpus world as an example world; Logic; propositional logic Reasoning patterns in propositional logic; Effective propositional inference; Agents based on propositional logic. Representation revisited; Syntax and semantics of first-order logic; Using first-order logic; Knowledge engineering in first-order logic. Propositional versus first-order inference; Unification and lifting, Forward chaining; Backward chaining; Resolution, Truth maintenance systems.
  • 2. Knowledge Based Agents in AI • Knowledge is the basic element for a human brain to know and understand the things logically. When a person becomes knowledgeable about something, he is able to do that thing in a better way. In AI, the agents which copy such an element of human beings are known as knowledge-based agents. • For efficient decision-making and reasoning, an intelligent agent need knowledge about the real world. • Knowledge-based agents are composed of two main parts: • Knowledge-base and • Inference system A knowledge-based agent must able to do the following: • An agent should be able to represent states, actions, etc. • An agent Should be able to incorporate new percepts • An agent can update the internal representation of the world • An agent can deduce the internal representation of the world • An agent can deduce appropriate actions.
  • 3. The above diagram is representing a generalized architecture for a knowledge-based agent. The knowledge- based agent (KBA) take input from the environment by perceiving the environment. The input is taken by the inference engine of the agent and which also communicate with KB to decide as per the knowledge store in KB. The learning element of KBA regularly updates the KB by learning new knowledge. The architecture of knowledge-based agent:
  • 4. Knowledge representation language : Knowledge-base is a central component of a knowledge-based agent, it is also known as KB. It is a collection of sentences (here 'sentence' is a technical term and it is not identical to sentence in English). These sentences are expressed in a language which is called a knowledge representation language. The Knowledge-base of KBA stores fact about the world. Why use a knowledge base? Knowledge-base is required for updating knowledge for an agent to learn with experiences and take action as per the knowledge. Inference system Inference means deriving new sentences from old. Inference system allows us to add a new sentence to the knowledge base. A sentence is a proposition about the world. Inference system applies logical rules to the KB to deduce new information. Inference system generates new facts so that an agent can update the KB. An inference system works mainly in two rules which are given as: Forward chaining : It start from the initial state of the problem till the solution. Backward chaining : from the solution going back to the steps of what we take Proof by resolution : it’s where we will use propositional logic
  • 5. Forward Chaining: Simple Example: Matches the set of conditions and infer results from these conditions. A(is true) and need to prove D is true B C AB CD Prove D is also true. Solution: Starting from initial state A, Let assume if A is true then B is true AB Then B is true then C is true B C finally C is true then D is true CD Thus D is also true is proved.
  • 6. • Backward Chaining: It is backward search from goal to conditions used to get the goal. Simple Example: A is true, we need to prove D is true B C AB CD Prove D is also true. Solution: Starting from D, Let assume D is true then C is true CD C is true then B is true B C B is true then A is true AB Thus A is proved true.
  • 7. Proof by resolution: Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e., proofs by contradictions (later we will see elaborately) The resolution rule propositional logic is a single valid inference rule that produces a new clause implied by two clause containing complementary literals. A literal is propositional variable or the negation of a propositional variable. Example: PVQ, ¬QVR, PVR (it take clauses P and Q and come up with new clause PVQ)
  • 8. • Inference Rules: A chain of conclusion that leads to the desired goal. Logical function take premises for ex, PVQ i.e checks P and Q are true or false and analysed the syntax (syntactically correct or not) and returned conclusion (gives the final result) Some of Inference rules: Modus Ponen AND introduction AND elimination Resolution etc which we will learn later elaborately Logical Function Premises Analyse syntax Conclusion
  • 9. Operations Performed by KBA Following are three operations which are performed by KBA in order to show the intelligent behavior: Actions of an agent When there is a need to add/ update some new information or sentences in the knowledge-based system, we require an inference system. Also, to know what information is already known to the agent, we require the inference system. The technical words used for describing the mechanism of the inference system are: TELL and ASK. When the agent solves a problem, it calls the agent program each time. The agent program performs three things: It TELLS the knowledge base what it has perceived from the environment. It ASKS the knowledge base about the actions it should take? It TELLS the action which is chosen, and finally, the agent executes that action. The details of the knowledge representation language are abstracted under these three functions. These functions create an interface between the two main components of an intelligent agent, i.e., sensors and actuators.
  • 10. The functions are discussed below: •MAKE-PERCEPT-SENTENCE() This function returns a sentence which tells the perceived information by the agent at a given time. •MAKE-ACTION-QUERY() This function returns a sentence which tells what action the agent must take at the current time. •MAKE-ACTION-SENTENCE() This function returns a sentence which tells an action is selected as well as executed. Levels of a Knowledge-based agent 1. Knowledge Level: In this level, the behaviour of an agent is decided by specifying the following : we need to specify what the agent knows, and what the agent goals are. example, suppose an automated taxi agent needs to go from a station A to station B, and he knows the way from A to B, so this comes at the knowledge level. 2. Implementation Level: agent perform actions as per logical and knowledge level. Ex At this level, an automated taxi agent actually implement his knowledge and logic so that he can reach to the destination. For example, Consider an automated air conditioner. The inbuilt knowledge stored in its system is that “ It would adjust its temperature according to the weather.” This represents the knowledge level of the agent. The actual working and its adjustment define the implementation level of the knowledge-based agent.
  • 11. 3. Logical level: At this level, we understand that how the knowledge representation of knowledge is stored. At this level, sentences are encoded into different logics. At the logical level, an encoding of knowledge into logical sentences occurs. ex At the logical level we can expect to the automated taxi agent to reach to the destination B. What is Knowledge Representation? Knowledge Representation in AI describes the representation of knowledge. Basically, it is a study of how the beliefs, intentions, and judgments of an intelligent agent can be expressed suitably for automated reasoning. One of the primary purposes of Knowledge Representation includes modeling intelligent behavior for an agent.
  • 12. Cycle/componenet of Knowledge Representation in AI Artificial Intelligent Systems usually consist of various components to display their intelligent behaviour. Some of these components include: •Perception •Learning •Knowledge Representation & Reasoning •Planning •Execution Here is an example to show the different components of the system and how it works: Example
  • 13. The above diagram shows the interaction of an AI system with the real world and the components involved in showing intelligence. •The Perception component retrieves data or information from the environment, find out the source of noises and check if the AI was damaged by anything. Also, it defines how to respond when any sense has been detected. •Then, there is the Learning Component that learns from the captured data by the perception component. The goal is to build computers that can be taught instead of programming them. Learning focuses on the process of self-improvement. In order to learn new things, the system requires knowledge acquisition, inference, acquisition of heuristics, faster searches, etc. •The main component in the cycle is Knowledge Representation and Reasoning which shows the human-like intelligence in the machines. Knowledge representation is all about understanding intelligence. Instead of trying to understand or build brains from the bottom up, its goal is to understand and build intelligent behavior from the top-down and focus on what an agent needs to know in order to behave intelligently. Also, it defines how automated reasoning procedures can make this knowledge available as needed. •The Planning and Execution components depend on the analysis of knowledge representation and reasoning. Here, planning includes giving an initial state, finding their preconditions and effects, and a sequence of actions to achieve a state in which a particular goal holds. Now once the planning is completed, the final stage is the execution of the entire process. So, these are the different components of the cycle of Knowledge Representation in AI.
  • 14. The Basic Idea of Propositional Logic Proposition means sentences. Propositional logic is one of the simplest method of knowledge representation to a machine. Propositional logic applies the Boolean logic (true /false) to convert our real-world data into a format that is readable to the computer. For instance, if we say ‘It is hot and humid today’, the machine won’t understand. But if we can create propositional logic for this sentence, then, we can make the machine-read, and interpret our message. Derived from Boolean logic, the heart of propositional logic is the idea that the final output (meaning) of all propositions are either true or false. It can’t be both.
  • 15. For example, ‘Earth is round’, the output for this proposition is TRUE. If we say, ‘Earth is square’, then the output is FALSE. Propositional logic applies to those sentences where the output can only be either TRUE or FALSE. But if we refer to the sentence like ‘Some children are lazy’ then here we have two possible outputs. This preposition is TRUE for those children who are lazy, but it is FALSE for those children who are not lazy. So, for such sentences/propositions where two or more outputs are possible, propositional logic doesn’t apply. Sentences that are questions and commands in nature do not belong to proposition category. Example what date today? It cannot have an answer true or false because it is a question, so question does not belong to this category.
  • 16. Other Features / types of propositions: Atomic Proposition: Atomic propositions are the simple sentences/propositions. These are the sentences which must be either true or false. Example: 9+2 =11 is one such proposition, and it is true. Sunrises in the west is another example, and it is false. Compound / complex proposition: Compound propositions are which have been formed by connecting two, or more sentences by using parenthesis and logical connectives. A combination of simple sentences connected by logical connectors is called Compound. Example: Today is Friday and people visit Temple today. It’s raining, and the match is called off. It is raining today, and street is wet.“
  • 17. Sl. Type Symbol Description 1 Negation ¬ P It represents a Negative condition. P is a positive statement, and ¬ P indicates NOT condition. Example: Today is Monday (P), Today is not a Monday (¬ P) 2 Conjunction P ^ Q It joins two statements P, Q with AND clause. Example: Ram is a cricket player (P). Ram is a Hockey player (Q). Ram plays both cricket and Hockey is represented by (P ^ Q) 3 Disjunction P v Q It joins two statements P, Q with OR Clause. Example: Ram leaves for Mumbai (P) and Ram leaves for Chennai (Q). Ram leaves for Chennai or Mumbai is represented by (P v Q). In this complex statement, at any given point of time if P is True Q is not true and vice versa. 4 Implication/ conditional P → Q Sentence (Q) is dependent on sentence (P), and it is called implication. It follows the rule of If then clause. If sentence P is true, then sentence Q is true. The condition is unidirectional. Example: If it is Sunday (P) then I will go to Movie (Q), and it is represented as P → Q 5 Bi-conditional P ⇔ Q Sentence (Q) is dependent on sentence (P), and vice versa and conditions are bi-directional in this connective. If a conditional statement and its converse are true, then it is called as bi- conditional connective (Implication condition in both the directions P → Q and Q → P). If and only if all conditions are true, then the end statement is true. Example: If I have 1000 Rupees then only I will go to Bar. The converse condition that I will go to Bar if and only if I have Rs 1000. The first statement covers necessity and the second one covers sufficiency. Syntax of Propositional Logic:
  • 18. P Q Negation Conjunction Disjunction Implication Bi-conditional ¬ P ¬ Q P ^ Q P v Q P → Q P⇔Q True True False False True True True True True False False True False True False False False True True False False True True False False False True True False False True True
  • 19. 1.Propositional logic Practise exercise 2.If it rains, then I will stay at home. 3.If I will go to Australia, then I will earn more money. 4.He is poor but honest. 5.If a = b and b = c then a = c. 6.Neither it is hot nor cold today. 7.He goes to play a match if and only if it does not rain. 8.Birds fly if and only if sky is clear. 9.I will go only if he stays. 10.I will go if he stays. 11.It is false that he is poor but not honest. 12.It is false that he is poor or clever but not honest. 13.It is hot or else it is both cold and cloudy. 14.I will not go to class unless you come. 15.We will leave whenever he comes. 16.Either today is Sunday or Monday. 17.You will qualify GATE only if you work hard. 18.Presence of cycle in a single instance RAG is a necessary and sufficient condition for deadlock. 19.Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for deadlock. 20.I will dance only if you sing. 21.Neither the red nor the green is available in size 5.
  • 20. Solution- Part-01: We have- •The given sentence is- “If it rains, then I will stay at home.” •This sentence is of the form- “If p then q”. So, the symbolic form is p → q where- p : It rains q : I will stay at home Part-02: We have- •The given sentence is- “If I will go to Australia, then I will earn more money.” •This sentence is of the form- “If p then q”. So, the symbolic form is p → q where- p : I will go to Australia q : I will earn more money
  • 21. Part-03: We have- •The given sentence is- “He is poor but honest.” •We can replace “but” with “and”. •Then, the sentence is- “He is poor and honest.” So, the symbolic form is p ∧ q where- p : He is poor q : He is honest Part-04: We have- •The given sentence is- “If a = b and b = c then a = c.” •This sentence is of the form- “If p then q”. So, the symbolic form is (p ∧ q) → r where- p : a = b q : b = c r : a = c
  • 22. Part-05: We have- •The given sentence is- “Neither it is hot nor cold today.” •This sentence is of the form- “Neither p nor q”. •“Neither p nor q” can be re-written as “Not p and Not q”. So, the symbolic form is ∼p ∧ ∼q where- p : It is hot today q : It is cold today Part-06: We have- •The given sentence is- “He goes to play a match if and only if it does not rain.” •This sentence is of the form- “p if and only if q”. So, the symbolic form is p ↔ q where- p : He goes to play a match q : It does not rain
  • 23. Part-07: We have- •The given sentence is- “Birds fly if and only if sky is clear.” •This sentence is of the form- “p if and only if q”. So, the symbolic form is p ↔ q where- p : Birds fly q : Sky is clear Part-08: We have- •The given sentence is- “I will go only if he stays.” •This sentence is of the form- “p only if q”. So, the symbolic form is p → q where- p : I will go q : He stays
  • 24. Part-09: We have- •The given sentence is- “I will go if he stays.” •This sentence is of the form- “q if p”. So, the symbolic form is p → q where- p : He stays q : I will go Part-10: We have- •The given sentence is- “It is false that he is poor but not honest.” •We can replace “but” with “and”. •Then, the sentence is- “It is false that he is poor and not honest.” So, the symbolic form is ∼(p ∧ ∼q) where- p : He is poor q : He is honest
  • 25. Part-11: We have- •The given sentence is- “It is false that he is poor or clever but not honest.” •We can replace “but” with “and”. •Then, the sentence is- “It is false that he is poor or clever and not honest.” So, the symbolic form is ∼((p ∨ q) ∧ ∼r) where- p : He is poor q : He is clever r : He is honest Part-12: We have- •The given sentence is- “It is hot or else it is both cold and cloudy.” •It can be re-written as- “It is hot or it is both cold and cloudy.” So, the symbolic form is p ∨ (q ∧ r) where- p : It is hot q : It is cold r : It is cloudy
  • 26. Part-13: We have- •The given sentence is- “I will not go to class unless you come.” •This sentence is of the form- “p unless q”. So, the symbolic form is ∼ q → p where- p : I will go to class q : You come Part-14: We have- •The given sentence is- “We will leave whenever he comes.” •We can replace “whenever” with “if”. •Then, the sentence is- “We will leave if he comes.” •This sentence is of the form- “q if p”. So, the symbolic form is p → q where- p : He comes q : We will leave
  • 27. Part-15: We have- •The given sentence is- “Either today is Sunday or Monday.” •It can be re-written as- “Today is Sunday or Monday.” So, the symbolic form is p ∨ q where- p : Today is Sunday q : Today is Monday Part-16: We have- •The given sentence is- “You will qualify GATE only if you work hard.” •This sentence is of the form- “p only if q”. So, the symbolic form is p → q where- p : You will qualify GATE q : You work hard
  • 28. Part-17: We have- •The given sentence is- “Presence of cycle in a single instance RAG is a necessary and sufficient condition for deadlock.” •This sentence is of the form- “p is necessary and sufficient for q”. So, the symbolic form is p ↔ q where- p : Presence of cycle in a single instance RAG q : Presence of deadlock Part-18: We have- •The given sentence is- “Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for deadlock.” •This sentence is of the form- “p is necessary but not sufficient for q”. So, the symbolic form is (q → p) ∧ ∼(p → q) where- p : Presence of cycle in a multi instance RAG q : Presence of deadlock
  • 29. Part-19: We have- •The given sentence is- “I will dance only if you sing.” •This sentence is of the form- “p only if q”. So, the symbolic form is p → q where- p : I will dance q : You sing Part-20: We have- •The given sentence is- “Neither the red nor the green is available in size 5.” •This sentence is of the form- “Neither p nor q”. •“Neither p nor q” can be written as “Not p and Not q”. So, the symbolic form is ∼p ∧ ∼q where- p : Red is available in size 5 q : Green is available in size 5
  • 30. Precedence of connectives / bracket simplification: Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators. This order should be followed while evaluating a propositional problem. Following is the list of the precedence order for operators: Precedence Operators First Precedence Parenthesis Second Precedence Negation Third Precedence Conjunction(AND) Fourth Precedence Disjunction(OR) Fifth Precedence Implication Sixth Precedence Biconditional Note: For better understanding use parenthesis to make sure of the correct interpretations. Such as ¬R∨ Q, It can be interpreted as (¬R) ∨ Q. The formal syntax makes extensive use of brackets to make grouping unambiguous: (((¬P)V(Q ∧R)) S) If you don’t want to use bracket use precedence rules from highest to lowest : ¬ ∧ V  ↔ Many brackets can be dropped and formulas be simplified: ¬PVQ ∧R  S
  • 31. Logic-Tautology, logical sequence, satisfiable and falsifiable A proposition that is always true regardless of the truth values of the propositional variables it contains is called a tautology. A compound proposition that is always false is called a contradiction or absurdity. And a compound proposition that is neither a tautology nor a contradiction is referred to as a contingency.
  • 32. P Q P ⇔ Q true true true false false true true false False false true false Logically Equivalent Statement In the above example, tautology is called as valid. Contingency and contradiction is called as invalid. The formula which made true is called satisfiable i.e, tautology and contingency are satisfiable because contingency can be made true and tautology is always true so therefore it is satisfiable Contradiction always be false and therefore it is unsatisfiable. The formula which made false is called as falsifiable. Contradiction and contingency are falsifiable because they made false Tautology cant be made so it is unfalsifiable.
  • 33.
  • 34. De Morgan law We have a number of rules for logical equivalence. For example: De Morgan Law: ¬(p ∧ q) ≡ ¬p ∨ ¬q (1) ¬(p ∨ q) ≡ ¬p ∧ ¬q (2) The following TT for proof 1. Do for proof 2 P Q p ∧ Q ¬(p ∧ Q) T T T F T F F T F T F T F F F T P Q ¬P ∨ ¬Q T T F T F T F T T F F T
  • 35. Contrapositives The proposition ¬q → ¬p is called the Contrapositive of the proposition p → q. They are logically equivalent. p → q ≡ ¬q → ¬p P Q p → q T T T T F F F T T F F T P Q ¬q → ¬p T T T T F F F T T F F T
  • 38. Similarly, there are some very useful equivalences for compound propositions involving implications and biconditional statements, as seen below.
  • 40. Prove equivalence: By using these laws, we can prove two propositions are logical equivalent. Example 1: Prove ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬q. LHS, ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) DeMorgan ≡ ¬p ∧ (p ∨ ¬q) DeMorgan ≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) Distributivity ≡ F∨(¬p ∧ ¬q) Because ¬p ∧ p ≡ F ≡ ¬p ∧ ¬q Because F ∨r ≡ r for any r Example 2: Prove (p ∧ q) → (p ∨ q) ≡ T. (p ∧ q) → (p ∨ q) ≡ ¬(p ∧ q) ∨ (p ∨ q) Substitution for → ≡ (¬p ∨ ¬q) ∨ (p ∨ q) DeMorgan ≡ (¬p ∨ p) ∨ (¬q ∨ q) Commutativity and Associativity ≡ T∨T Because ¬p ∨ p ≡ T ≡ T
  • 41. Rules of Inference for propositional logic Inference means to find a conclusion based on the facts, information, and evidence. In simple words, when we conclude the facts and figures to reach a particular decision, that is called inference. In artificial intelligence, the expert system or any agent performs this task with the help of the inference engine. Reasoning patterns in propositional logic: AND Elimination: From a conjunction, any of the conjuncts can be inferred as P∧Q == true , where P is true and Q is true, then we can set P ∧Q is true P Example: (WumpusAhead ∧ WumpusAlive), WumpusAlive can be inferred
  • 42. Types of Inference rules/ Reasoning patterns in propositional logic: 1. Modus Ponens: The Modus Ponens rule is one of the most important rules of inference, when P → Q is true, so then P is true and therefore Q must be true. It can be represented as: 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. Proof by Truth table:
  • 43. 2. Modus Tollens: The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also true. It can be represented as: Statement-1: "If I am sleepy then I go to bed" ==> P→ Q Statement-2: "I do not go to the bed."==> ~Q Statement-3: Which infers that "I am not sleepy" => ~P Proof by Truth table:
  • 44. 3. Hypothetical Syllogism: The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and Q→R is true. It can be represented as the following notation: Example: Statement-1: If you have my home key then you can unlock my home. P→Q Statement-2: If you can unlock my home then you can take my money. Q→R Conclusion: If you have my home key then you can take my money. P→R Proof by truth table:
  • 45. 4. Disjunctive Syllogism: The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will 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 Proof by truth-table:
  • 46. 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. 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) Proof by Truth-Table:
  • 47. 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: Proof by Truth-Table: Example: Vivin plays football Nikita plays tennis
  • 48. 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 Proof by Truth-Table:
  • 49. • Conjunctive Normal Form • It is formula which is equivalent to a given formula and which consists of a product of elementary sums is called as conjunctive normal form. • (PVQ) ∧(¬PV ¬Q) ∧(..V…V..) series of disjunction connected through conjunction. Therefore in short it is conjunction of clauses ((PVQ) , (¬PV ¬Q)) • Example: • ((P Q) R) First step: Eliminate Implication --> • ((P Q) R) (implication is replaced by negation and or operator) • ((¬PV Q) R) (implication is replaced by negation and or operator) • (¬(¬PV Q)V R) Second Step: Move negation inward (OR becomes AND) • (¬¬P ∧¬Q)V R) (double negation cancelled) • (P ∧ ¬Q)V R • Third Step: Now apply distributive law (because we need AND) • (PVR) ∧( ¬QV R)
  • 50. • Example: • A ↔(BVC) • First Step: Elimination of ↔ (means AB or C and B or C A) • (A(BVC)) ∧((BVC)A) • Second step: Elimination of  (means add negation & OR operator) • (¬AV(BVC) ∧(¬(BVC)VA) (negation is present outside) • Third Step: Move Negation inside (means OR will become AND operator) • (¬AV(BVC) ∧((¬B ∧¬ C)VA) (here V is present but we need ∧) • Fourth step: Apply distributive law • (¬AVBVC) ∧(¬B VA) ∧( ¬ CVA) • (¬AVBVC) ∧(¬B VA) ∧( ¬ CVA) (clause is conjunction of discjunction) • So the statement is in conjunctive normal form
  • 51. Resolution Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e., proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the year 1965. Resolution is used, if there are various statements are 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. Proof by resolution Resolution: An inference rule that yields a complete inference algorithm when coupled with any complete search algorithm. Clause: A disjunction of literals (an atomic sentence) is called as clause. (e.g. A∨B). A single literal can be viewed as a unit clause (a disjunction of one literal ). Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to be conjunctive normal form or CNF. Unit resolution inference rule: Takes a clause and a literal and produces a new clause. Where li and mj are complementary literals . This rule is also called the binary resolution rule because it only resolves exactly two literals.
  • 52. 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. Notice: The resulting clause should contain only one copy of each literal. The removal of multiple copies of literal is called factoring. e.g. resolve(A∨B) with (A∨¬B), obtain(A∨A) and reduce it to just A. The resolution rule is sound and complete. Resolution: Property • Resolution is sound: Always produces sentences that are entailed by their premise • Resolution is complete: It is guarantee to establish entailment of the query in finite time • Completeness based on the key theorem: If a set of clauses is unsatisfiable, then the set of all clauses that can be obtained by resolution contains the empty clause • So, conversely, if we cannot find the empty clause, the query must be satisfiable
  • 53. function PL-RESOLUTION(KB, α) returns true or false inputs: KB, the knowledge base, a sentence in propositional logic α, the query, a sentence in propositional logic clauses ← the set of clauses in the CNF representation of KB ∧ ¬α new ← { } loop do for each pair of clauses Ci, Cj in clauses do resolvents ← PL-RESOLVE(Ci, Cj) if resolvents contains the empty clause then return true new ← new ∪ resolvents if new ⊆ clauses then return false clauses ← clauses ∪ new A simple resolution algorithm for propositional logic above. The function PL-RESOLVE returns the set of all possible clauses obtained by resolving its two inputs.
  • 54.
  • 55. Inference in PL where the below 5 sentences are stored in KB • R1:¬P1,1 // There is no pit in square[1,1] • • R2 : B1,1 ↔(P1,2 v P2,1 ) //square[1,1] will have breeze iff there is pit in [1,2] or [2,1] • R3 : B2,1 ↔(P1,1 V P2,2 V P3,5 ) square [2,1] have breeze iff there is pit in [1,1], [2,2] or [3,1] • R4: :¬B1,1 //There is no breeze in square [1,1] • R5: B2,1 //There is no breeze in square [2,1] • Rules of Wumpus game are R1,R2,R3 • Percept the agent perceive R4, R5
  • 56. To perform Inference, our goal is to decide whether KB |= α for some sentence α Example : :¬P1,2 // entails by our KB or not? Model checking for inference by using algorithm: In all the model if KB =True the α =True Therefore KB |= α From the previous slide, The 7 relevant proposition symbol are : P1,1 B1,1 P1,2 P2,1 , B2,1 P2,2 P3,5 With the 7 symbol, there are total 27=128 possible models
  • 57. Inference check using model checking algorithm: e.g. 1. To perform inference let consider ¬P1,2 is true in all models where KB=True hence it is proved there is no pit in square[1,2] KB |= P1,2 2. Let infer P2,2 is true . from the below fig, it is true for only two models therefore it is difficult to say there is pit [2,2] Thus P2,2 is false and KB =true. So we can say KB ⊭ P2,2
  • 58. TT-ENTAILS?: A general algorithm for deciding entailment in propositional logic, performs a recursive enumeration of a finite space of assignments to symbols. Sound and complete. Time complexity: O(2n) Space complexity: O(n), if KB and α contain n symbols in all.
  • 59. Monotonicity: A property of logical system, says that the set of entailed sentences can only increased as information is added to the knowledge base. For any sentences α and β, If KB ⊨ α then KB ∧ β ⊨ α. Monotonicity means that inference rules can be applied whenever suitable premises are found in the knowledge base, what else in the knowledge base cannot invalidate any conclusion already inferred. Proof by resolution Resolution: An inference rule that yields a complete inference algorithm when coupled with any complete search algorithm. Clause: A disjunction of literals. (e.g. A∨B). A single literal can be viewed as a unit clause (a disjunction of one literal ). Unit resolution inference rule: Takes a clause and a literal and produces a new clause. where each l is a literal, li and m are complementary literals (one is the negation of the other). Full resolution rule: Takes 2 clauses and produces a new clause. where li and mj are complementary literals.
  • 60. • Resolution : • This algorithm works using by proof by contradiction. • To show KB |= α , we show that KB ∧ ¬ α is not satisfiable. • So by applying resolution to KB ∧ ¬ α in CNF and resolve pairs with complementary literal, • For example if we keep li = ¬ P and mj=P then as per resolution rules the complimentary literal is removed so the remaining value will be li-1, mj-1 …
  • 61. Conjunctive normal form Conjunctive normal form (CNF): A sentence expressed as a conjunction of clauses is said to be in CNF. Every sentence of propositional logic is logically equivalent to a conjunction of clauses, after converting a sentence into CNF, it can be used as input to a resolution procedure. A resolution algorithm
  • 62. e.g. say agent is in square [1,1] where there is no breeze and no pit. We need to prove no pits in α = ¬P1,2 KB = (B1,1⟺(P1,2∨P2,1))∧¬B1,1 KB=R2∧R4 By using biconditional elimination and CNF we get, KB ∧ ¬ α=
  • 63. Notice: Any clause in which two complementary literals appear can be discarded, because it is always equivalent to True. e.g. B1,1∨¬B1,1∨P1,2 = True∨P1,2 = True. PL-RESOLUTION is complete. Horn clauses and definite clauses
  • 64. Definite clause: A clause which is disjunction of literals with exactly one positive literals (a,P,…) is known as Definite Clause or Strict Horn Clause. Every definite clause can be written as an implication, whose premise is a conjunction of positive literals and whose conclusion is a single positive literal. Example : A B ≡ ¬A V B ( here one positive literal present i.e B) Horn clause: A disjunction of literals of which at most one is positive. (All definite clauses are Horn clauses.) In Horn form, the premise is called the body and the conclusion is called the head.. A sentence consisting of a single positive literal is called a fact, it too can be written in implication form. Horn clause are closed under resolution: if you resolve 2 horn clauses, you get back a horn clause. Inference with horn clauses can be done through the forward-chaining and backward-chaining algorithms. A Clause which is disjunction of literals with atmost one positive literals is known as Horn Clause. Example : (¬P V ¬Q V K) (here it has only one positive literal ie. K) Unification It is a process of making 2 different logical atomic expressions identical by finding substitution. Unification depend on substitution process. Example Know (x,ram) know(shyam, y) Therefore unification become know (shyam, ram) (substitute x=shyam and y= ram)
  • 65.
  • 66. Forward Chaining: It is a join of reasoning which starts with atomic sentences in the knowledge base and applies inference rules in the forward direction to extract more data until a goal is reached. Properties: It moves from bottom to top It is a process of making a conclusion based on known facts or data by starting from the initial state and reach goal state. Forward chaining approach is also called as data driven as we reach to the goal using available data.
  • 67. To prove is P Q. A,B are given fact. Remaining 4 condition above are horn clause
  • 68. • Backward Chaining: It is a form of reasoning which starts with the goal and work backward chaininh through rules to find known facts that support the goal. Properties: It is known as Top down approach. BC is based on modus ponens inference rule. In BC, the goal is broken into subgoals to prove the facts are true. BC is also called as Goal driven approach as a list of goal decides which rules are decided and used. BC is used in gaming theory, automated theorem tools, inference engine and various AI applications. BC method mostly used DFS strategy for proof.
  • 69. in the corresponding AND-OR graph: it works back down the graph until it reaches a set of known facts. (Backward-chaining algorithm is essentially identical to the AND-OR-GRAPH-SEARCH algorithm.)
  • 70. Effective propositional Inference model checking The set of possible models, given a fixed propositional vocabulary, is finite, so entailment can be checked by enumerating models. Efficient model-checking inference algorithms for propositional logic include backtracking and local search methods and can often solve large problems quickly. 2 families of algorithms for the SAT (Boolean Satisfiability Problem) problem based on model checking a. based on backtracking b. based on local hill-climbing search Boolean Satisfiability: the problem of determining if there exists an interpretation that satisfies a given Boolean formula t/f. Example:
  • 71.
  • 72. DPLL embodies 3 improvements over the scheme of TT-ENTAILS?: Early termination, pure symbol heuristic, unit clause heuristic. Tricks that enable SAT solvers to scale up to large problems: Component analysis, variable and value ordering, intelligent backtracking, random restarts, clever indexing. Local search algorithms Local search algorithms can be applied directly to the SAT problem, provided that choose the right evaluation function. (We can choose an evaluation function that counts the number of unsatisfied clauses.) These algorithms take steps in the space of complete assignments, flipping the truth value of one symbol at a time. The space usually contains many local minima, to escape from which various forms of randomness are required. Local search methods such as WALKSAT can be used to find solutions. Such algorithm are sound but not complete. WALKSAT: one of the simplest and most effective algorithms.
  • 73.
  • 74. The landscape of random SAT problems Underconstrained problem: When we look at satisfiability problems in CNF, an underconstrained problem is one with relatively few clauses constraining the variables. An overconstrained problem has many clauses relative to the number of variables and is likely to have no solutions. The notation CNFk(m, n) denotes a k-CNF sentence with m clauses and n symbols. (with n variables and k literals per clause). Given a source of random sentences, where the clauses are chosen uniformly, independently and without replacement from among all clauses with k different literals, which are positive or negative at random. Hardness: problems right at the threshold > overconstrained problems > underconstrained problems
  • 75. Inference-based agents in the wumpus world A wumpus-world agent using propositional logic: P1,1 W1,1 Bx,y  (Px,y+1  Px,y-1  Px+1,y  Px-1,y) Sx,y  (Wx,y+1  Wx,y- 1  Wx+1,y  Wx- 1,y) W1,1  W1,2  …  W4,4 W1,1  W1,2 W1,1  W1,3 …  64 distinct proposition symbols, 155 sentences
  • 76. Expressiveness limitation of propositional logic • KB contains "physics" sentences for every single square • For every time t and every location [x,y], Ltx,y  FacingRightt  Forwardt  Lx+1,yt • Rapid proliferation of clauses Artificial Intelligence Methods – WS 2005/2006 – Marc Erich Latoschik Circuit-based agents • Particular type of reflex agent with state • Percepts are inputs to a sequential circuit built of gates and registers (to sore truth values for a single proposition). • Circuit will be evaluated according to data-flow (compare to and-or graphs)
  • 77. • Logical agents apply inference to a knowledge base • to derive new information and make decisions • Basic concepts of logic: •syntax: formal structure of sentences •semantics: truth of sentences wrt models •entailment: necessary truth of one sentence given another •inference: deriving sentences from other sentences •soundness: derivations produce only entailed sentences •completeness: derivations can produce all entailed sentences • Wumpus world requires the ability to represent partial • and negated information, reason by cases, etc. • Resolution is complete for propositional logic Forward, backward chaining are linear-time, complete for Horn clauses • Propositional logic lacks expressive power Circuit-based agents Summary
  • 78. Wumpus is the name of a monster in the video game “Hunt The Wumpus”. It was developed by Gregory Yob in 1973. Wumpus world problem to represent knowledge representation The Wumpus world problem depicts the value of a knowledge-based agent and the interpretation of that knowledge with the help of reasoning and planning. (or game playing which provides an environment to the knowledge- based agent to showcase its stored knowledge) Wumpus world problem in AI? The Wumpus world is a 4x4 cave with 16 rooms connected to each other through passageways. The knowledge-based agent goes forward in this world. In Wumpus World: It is a single-player game. It is a cave consisting of rooms which are connected with one-another via passways. There is a beast or monster in the game named Wumpus, lurking somewhere the cave. Wumpus eats everyone who tries to enter the cave. The player needs to kill the Wumpus. The player has only one arrow to shoot out the monster. There are some rooms containing bottomless pits which may trap anyone whoever wanders in the room. The goal of the game is to search for a heap of gold. How to “win” it The agent has to find the gold and climb out of the cave without: Falling into Pits Getting eaten by Wumpus
  • 79. There are also some components which can help the agent to navigate the cave. These components are given as follows: •The rooms adjacent to the Wumpus room are stinky, thus there is a stench there. •The room next to PITs has a breeze, so if the agent gets close enough to PIT, he will feel it. •If and only if the room contains gold, there will be glitter. • Wumpus will scream*= when it is killed, which can be heard anywhere in the cave. •The agent will feel a bump when they hit a wall •Sensors help the agent move forward successfully.
  • 80. PEAS Description of the Wumpus World •Performance Measure: The player is awarded with the following utilities: •(+1000): It is for coming out of the cave safely with the gold. •(-1000): It is for falling into the pit or if eaten by the Wumpus. •(-1): It is for each action taken by the player. •(-10): It is for raising the arrow up. The game ends if the player comes out of the cave safely or dies. 1) Environment: The environment provided in the Wumpus world is as follows: •It is a 4X4 grid of 16 rooms. •The player always starts in the square labeled [1,1] and facing towards the right. •Location of the monster and the gold is choosen randomly in a uniform distribution. •Remember, the location chosen will never be the starting point. •Each square room other than the starting one can be a pit with 0.2 probability. 2) Actuators: The player performs the following actions: •The agent can move forward or TurnLeft by 900 and TurnRight by 900. •The player dies if he enters a room having a pit or alive monster. It is safe to enter the room if the Wumpus is dead. •If the player will try to move forward and bumps into the wall, then the player will not move. •Using the action Grab, the player can pick up the gold in the same room. •Using the action Shoot, the player can shoot the monster with the arrow. Either the arrow will shoot the monster or will hit on the wall. •The action Climb is used to come out of the cave but only from the square [1,1].
  • 81. 3) Sensors: The player is provided with five sensors, which gives a single bit of information: •The player will perceive a Stench, if Wumpus is present in the room which is directly adjacent to the player. •The player will perceive a Breeze, if in the square is directly adjacent to the pit. •The player will perceive a Glitter, if in the square gold is present. •The player will perceive a Bump, when the player walks into the wall. When the player will shoot out the monster, it will emit a scary Scream which can be heard/perceived from anywhere in the cave. The Wumpus world Properties: Partially observable: The Wumpus universe is only partially viewable because the agent can only observe the immediate environment, such as a nearby room. Deterministic: It's deterministic because the world's result and outcome are already known. Sequential: It is sequential because the order is critical. Static: Wumpus and Pits are not moving, thus it is static. Discrete: There are no discrete elements in the environment. One agent: We only have one agent, and Wumpus is not regarded an agent, hence the environment is single agent. Now we will explore Wumpus world a bit and will explain how the agent will find its goal applying logical reasoning. Agent's First step: At first, the agent is in the first room, or square [1,1], and we all know that this room is safe for the agent, thus we will add the sign OK to the below diagram (a) to represent that room is safe. The agent is represented by the letter A, the breeze by the letter B, the glitter or gold by the letter G, the visited room by the letter V, the pits by the letter P, and the Wumpus by the letter W. Agent does not detect any wind or Stench in Room [1,1], indicating that the nearby squares are similarly in good condition.
  • 82. Agent's second Step: Now that the agent must go forward, it will either go to [1, 2] or [2, 1]. Let's say agent enters room [2, 1], where he detects a breeze, indicating Pit is present. Because the pit might be in [3, 1] or [2, 2], we'll add the sign P? to indicate that this is a Pit chamber. Now the agent will pause and consider his options before doing any potentially destructive actions. The agent will return to room [1, 1]. The agent visits the rooms [1,1] and [2,1], thus we'll use the symbol V to symbolize the squares he's been to.
  • 83. Agent's third step: The agent will now proceed to the room [1,2], which is fine. Agent detects a stink in the room [1,2], indicating the presence of a Wumpus nearby. However, according to the rules of the game, Wumpus cannot be in the room [1,1], and he also cannot be in [2,2]. (Agent had not detected any stench when he was at [2,1]). As a result, the agent infers that Wumpus is in the room [1,3], and there is no breeze at the moment, implying that there is no Pit and no Wumpus in [2,2]. So that's safe, and we'll designate it as OK, and the agent will advance [2,2] Agent's fourth step: Because there is no odor and no breeze in room [2,2], let's assume the agent decides to move to room [2,3]. Agent detects glitter in room [2,3], thus it should collect the gold and ascend out of the cave.
  • 84. Differences Between Propositional and First-Order Logic The first difference between the two relates to the fact that first-order logic includes propositional logic, but the opposite isn’t true. This means that all problems expressed in propositional logic can be treated under first-order logic, but not all problems in first-order logic can be treated in propositional logic. The second difference relates to the nature of the elementary unit which constitutes the formulas of the two formal systems. Propositional logic uses propositions and logical operators in order to constitute its Well-Formed Formulas. First-order logic, in addition to those, also uses variables, quantifiers, and relationships. We’re going to see in the next sections what these new concepts mean. The third difference concerns the capacity for the abstraction of formulas expressed by the two systems. In propositional logic, the system doesn’t allow to handle problems that involve mutating or undetermined parts. This means that the validity of a solution to a formula found in propositional logic is restricted to that formula. In first-order logic, in contrast, it’s possible to create formulas that possess a higher capacity for generalization.
  • 85. Predicate Logic (calculus) / First order logic What is first-order logic (FOL)? 1.FOL is a mode of representation in Artificial Intelligence. It is an extension of PL. FOL is also called predicate logic 2.FOL represents natural language statements in a concise way. 3.Predicate calculus deals with predicated which are propositions containing variables. 4. It is a powerful language that develops information about an object in a more easy way and can also express the relationship between those objects. 1.FOL not only assumes that does the world contains facts (like PL does), but it also assumes the following: 1. Objects: A, B, people - ram, numbers, colours, wars, theories, squares, pit, etc. 2. Relations: It is unary relation such as colour like red, round, sister of, brother of, bigger than, comes between etc. 3. Facts: one value for a given input like : is father of, best friend, can swim, third inning of, end of, etc. Facts have truth value true or false As a natural language, first-order logic has two main parts Syntax Semantics Now there are three kinds of symbols: Constants: objects Predicate: relations Functions: functions(i.e can return values other than truth and false)
  • 86. Predicate logic statements can be divided into two parts: Subject: Subject is the main part of the statement Predicate: A predicate can be defined as relation, which binds two atoms together in a statement. Ex: Sunil was intelligent – Here Sunil is subject intelligent is attribute property characteristics also called as predicate (intelligent). Note: predicate logic doesnot bother about the tense like present , past and future tense i,.e sunil is intelligent, sunil will be intelliegent the predicate logic is same ) Intelligent(sunil) Consider the statement : “x is an integer”, it contains of two parts, the first part x is the subject of the statement and second part “is an integer” is known as predicate (integer is attribute of subject x) can be written as integer(x)
  • 87. •Syntax for first order logic: In prepositional logic, every expression is a sentence that represents a fact. •First order logic includes the sentences along with terms which can represent the objects. •Constant symbols, variables and function symbols are used to build terms, while quantifiers and predicate symbols are used to build the sentences. •Syntax: Constants A, B, C 1, 6, A,W,New York, Elie, Dog..... Functions Size, Color, Sqrt, LessThan, Sin(θ), size... Variable x, a Terms Constant, variable or function(Term..) Predicates True, False, <, >, brother, sister, father Quantifiers ∀, ∃ Atomic sentences Predicate, Predicate(Term,…), Term=Term Sentences ¬ Sentence, Sentence ∨ Sentence, Sentence ∧ Sentence, Sentence ⇒ Sentence, Sentence ⇔ Sentence, Quantifier Variable,… Sentence
  • 88. Predicates vs Functions • Predicates are relationships between things – Objects in – Truth out • Functions are mappings between things – Objects in – Objects out Predicates are essentially functions with Boolean output, but • Predicates combine symbols to form atomic sentences – True or false (under a given model) • Functions combine symbols to form terms – Expressions which refer to objects Atomic and complex sentences in FOL 1. Atomic Sentence •This is a basic sentence of FOL formed from a predicate symbol followed by a parenthesis with a sequence of terms. •We can represent atomic sentences as a predicate (value1, value2…., value n) or predicate(term1,…term n) Example 1.John and Michael are colleagues → Colleagues (John, Michael) 2.German Shepherd is a dog → Dog (German Shepherd)
  • 89. 2. Complex sentence Complex sentences are made by combining atomic sentences using connectives. By negation, conjunction, disjunction, bidirectional etc FOL is further divided into two parts: •Subject: the main part of the statement. •Predicate: defined as a relation that binds two atoms together. Example 1.Colleague (Oliver, Benjamin) ∧ Colleague (Benjamin, Oliver) 2.“x is an integer” It has two parts; Ram is a king or ram is not a king King is a predicate/class, ram is object/subject King(ram)V¬king(ram) •first, x is the subject. •second, “is an integer” is called a predicate.
  • 90. Quantifiers in First-order logic •A quantifier is a language element which generates quantification, and quantification specifies the quantity of specimen in the universe of discourse. •The variable of predicates is quantified by qunatifiers. •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 quantifier: • Universal Quantifier, (for all, everyone, everything) • Existential quantifier, (for some, at least one). Universal Quantifier: Universal quantifier is a symbol of logical representation, which specifies that the statement within its range is true for everything or every instance of a particular thing. The Universal quantifier is represented by a symbol ∀, (for all) which resembles an inverted A. ∀<variable> <sentence> Note: In universal quantifier we use implication "→" If x is a variable, then ∀x is read as: For all x For each x For every x.
  • 91. Example: All man drink coffee. ∀x man(x) → drink (x, coffee). It will be read as: There are all x where x is a man who drink coffee. Existential Quantifier: Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true for at least one instance of something. It is denoted by the logical operator ∃ (there exists), which resembles as inverted E. When it is used with a predicate variable then it is called as an existential quantifier. Note: In Existential quantifier we always use AND or Conjunction symbol (∧). Let a variable x which refers to a cat so all x can be represented in UOD as below:
  • 92. If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as: •There exists a 'x.' •For some 'x.' •For at least one 'x.' Example: Some boys are intelligent. ∃x: boys(x) ∧ intelligent(x) It will be read as: There are some x where x is represent as boy (predicate) who is intelligent (predicate) X present in boys and intelligent are variable which indicates subject or the objects. Points to remember: •The main connective for universal quantifier ∀ is implication →. •The main connective for existential quantifier ∃ is and ∧ (disjunction). Properties of Quantifiers: •In universal quantifier, ∀x∀y is similar to ∀y∀x. •In Existential quantifier, ∃x∃y is similar to ∃y∃x. •∃x∀y is not similar to ∀y∃x.
  • 93. Nested quantifiers & their uses We can use both quantifiers together, but it’s not a type of quantifier; rather, it’s an outlier category. •Nested quantifier refers to when one quantifier is within the scope of another quantifier. •These quantifiers can be represented using the ∃x∀x signs. •Here are some examples to understand this type of quantifier. 1.∃xy ∀x ∀y((x< 0) ∧ (y< 0) → (xy = 8)) This can be interpreted as: For every real number x and y ∈ ℝ, if x is negative and y is also negative, implies for some values of xy must be equal to 8. Example for not similar: ∃x∀y loves(x,y) There is a person (single person is existential quantifier) who loves everyone in the world ∀y ∃x loves(y,x) Everyone in the world is loved by at least one person
  • 94. Equality • term1 = term2 is true under a given interpretation if and only if term1 and term2 refer to the same object – Father(John) = Henry • Can also be used to state facts about functions • 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)] Domain is a section of the knowledge representation 1. Kindship domain 2. Mathematical sers 3. Assertion and queries in FOL 4. Wumpus world Kinship Domain (Family relationship) It consist of Object=people Unary predicates= male, female Binary predicates=parent, brother, sister Functions-father, mother Relations-brotherhood, sisterhood
  • 95. FOL inference rules for quantifier: 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:
  • 96. •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:
  • 97. ∀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, which is a valid inference rule in first-order logic. •It can be applied only once to replace the existential sentence. •The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was satisfiable. •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: Example: From the given sentence: ∃x Crown(x) ∧ OnHead(x, John), So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge base. •The above used K is a constant symbol, which is called Skolem constant. •The Existential instantiation is a special case of Skolemization process.
  • 98. 4. Existential introduction •An existential introduction is also known as an existential generalization, which is a valid inference rule in first-order logic. •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: •Example: Let's say that, "Priyanka got good marks in English." "Therefore, someone got good marks in English."
  • 99.
  • 100.
  • 101. Unification • Unification is a kind of binding logic between two or more variables • In propositional logic it is easy to determine that two literals can not both be true at same time • Ex: Man(Sunil and ¬Man(Sunil) is a contradiction While Man(Sunil) and ¬Man(Arun) is not contradiction • In predicate logic, this matching process is more complicated since bindings of variables must be considered. • In predicate logic in order to determine contradiction we need a matching procedure that compares two literals and discovers whether there exists a set of substitutions that make them identical. This is where Unification algorithm is used. • The goal of unification is to make two expression look like identical by using substitution. • It means the meaning if the sentence should not be changed, but it should be expressed in multiple ways • The UNIFY algorithm in unification take two sentences as input and then return a unifer if one exists: • - Substitution means replacing one variable with another term. • - It takes two literals as input and makes them identical using substitution. • - It returns fail if the expression d not match with each other. • UNIFY(p,q)= θ where SUBST(θ,p)=SUBST(θ,q) (SUBST is substitution, p, q are atomic sentence where the SUBST θ such that, by applying SUBST function θ on p,q, then p,q becomes equal , where p,q are the predicates with their own arguments)
  • 102. Example 1: Lets say there are two different expressions/predicate/literal, P(x,y) and P(a,f(z)) We need to make both above statements identical to each other. Perform substitution, P(x, y)…….(i) P(a, f(z))…..(ii) Substitute x with a and y with f(z) in the first expression, and it will be represented as z/x and f(z)/y With both the substitutions, the first expression will be identical to the second expression and substitution set will be [a/x, f(z)/y] Note: why you need unification : because machine need to be intelligent like humans, and machine has its own KB, so for given a statement, machine needs to search in KB what is similar and accordingly the result will be given.
  • 103. Example 2: Given: knows(Ram, x) is a predicate My question is : Whom does Ram knows? The UNIFY algorithm will search all the related sentences in the knowledge base which could unify with Knows(Ram, x) UNIFY (Knows(Ram,x), Knows(Ram, Shyam)) ≡ {x/Shyam} (both arguments are same and ram are same in both) UNIFY(Knows{Ram,x}, Knows{y, Akash}) ≡ {x/Akash, y/Ram} (akash is replaced by variable by x…… UNIFY (Knows{Ram, x}, Knows{x, Raman}) ≡ fails //Unifier is empty (same variable x is used so fail) The last one is failed because we have used the same variable for two persons or the two sentences happen to use the same variable name, x Unification are attempted only with sentences that have some chance of unifying. For example, there is no point in trying to Unify Knows(Ram, x) with Brother(Laxman, Ram) //predicates are different like “knows and brother” so unification not possible and no logical binding of two statments because know and brother are logically incorrect.
  • 104. Conditions for Unification • Predicate symbol must be same, atoms or expression with different predicate symbol can never be unified. Tryassassinate (Marcus, Caesar) Hate (Marcus, Caesar) //tryassassiate and hate are not identical • Number of Arguments in both expression must be identical Hate(Marcus) Hate(Marcus, Caesar) // Marcus and (Marcus ,Caesar) are not identical • Unification will fail if there are two similar variables present in the same expression. UNIFY (Knows{Ram, x}, Knows{x, Raman}) ≡ fails
  • 105. Inference Engine –Forward & Backward Chaining The inference engine is the component of the expert system in AI which applies logical rules to the KB to infer new information from known facts. Forward and Backward chaining is the strategies used by the inference Engine in making the deductions. Logical inference algorithm use forward and backward chaining approaches, which require KB in the form of first order clause. The inference engine compares each rule stored in the KB with facts contained in the DB. When the IF(condition) part of the rules matches a fact, the rule is fired and its THEN(action) part is executed. The matching of the rule IF parts to the facts produce inference chains. The inference chain indicates how an expert system applies the rules to reach a conclusion.
  • 106. Forward Chaining It is form of reasoning which start with atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more data until a goal is reached. Here facts are held in a working memory and condition action rules represent actions to take when specified facts occur in working memory it may add and delete facts from working memory. Properties of FC: • It is a bottom up approach as it moves from bottom to top. • It is a process of making conclusion based on known facts or data, bys tarting from the initial state and reaches the goal state. • FC approach is also called as data driven as the date determines which rules are selected and used. • Example: • Given, • A He exercises regularly • A B If he is exercising, he is fit • The new knowledge it could generate is, • B He is fit.
  • 107. Example: Rule 1: IF student is excellent in academics AND he is good in sports THEN he is all rounder (// GOAL, ned to prove he is all rounder) Rule 2: IF student gets marks>80 AND he is good in general knowledge THEN he is excellent in academics Rule 3: IF student is making centuries THEN he is good in sports Given following facts(Data): 1. Student get marks>80 2. Student is making centuries 3. He is good in general knowledge From the given facts, We need to infer the “student is all rounder” which is our goal From the fact 1 and 3, is present in rule 2 and prove he is excellent is academics (//sub goal) Remaining fact 2, is present in rule 3 and prove he is good in sports (// next sub goal) Now we need to check sub goals is present in rule 1 and prove he is all rounder (//goal obtained)
  • 108.
  • 109. Example: "As per the law, it is a crime for an American to sell weapons to hostile nations. Country A, an enemy of America, has some missiles, and all the missiles were sold to it by Robert, who is an American citizen." Prove that "Robert is criminal." To solve the above problem, first, we will convert all the above facts into first-order definite clauses, and then we will use a forward-chaining algorithm to reach the goal. Facts Conversion into FOL: •It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are variables) American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1) •Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can be written in two definite clauses by using Existential Instantiation, introducing new Constant T1. Owns(A, T1) ......(2) Missile(T1) .......(3)
  • 110. •All of the missiles were sold to country A by Robert. ?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4) •Missiles are weapons. Missile(p) → Weapons (p) .......(5) •Enemy of America is known as hostile. Enemy(p, America) →Hostile(p) ........(6) •Country A is an enemy of America. Enemy (A, America) .........(7) •Robert is American American(Robert). ..........(8) Forward chaining proof: Step-1: In the first step we will start with the known facts and will choose the sentences which do not have implications, such as: American(Robert), Enemy(A, America), Owns(A, T1), and Missile(T1). All these facts will be represented as below.
  • 111.
  • 112. Step-2: At the second step, we will see those facts which infer from available facts and with satisfied premises. Rule-(1) does not satisfy premises, so it will not be added in the first iteration. Rule-(2) and (3) are already added. Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which infers from the conjunction of Rule (2) and (3). Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from Rule-(7).
  • 113. Step-3: At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1, r/A}, so we can add Criminal(Robert) which infers all the available facts. And hence we reached our goal statement. Hence it is proved that Robert is Criminal using forward chaining approach.
  • 114. Backward Chaining It is a goal driven method of deriving a particular goal from a given knowledge base and set of inference rules. The inference system knows the final decision or goal this system starts from the goal and works backwards to determine what facts must be asserted so that the goal can be achieved. Example: B He is fit A If he is exercising, he is fit A He exercises regularly. Properties of BC: It is known as a top down approach. BC is based on Modus Ponens inference rule. The goal is broken into sub goal or sub goals to prove the facts true. It is called goal driven approach as a list of goals decides which rules are selected and used.
  • 115. Example: This is opposite of FC. Here the interpreter tries to match the THEN condition instead of IF condition as in FC Rule 1: IF student is excellent in academics AND he is good in sports THEN he is all rounder (// GOAL, ned to prove he is all rounder) Rule 2: IF student gets marks>80 AND he is good in general knowledge THEN he is excellent in academics Rule 3: IF student is making centuries THEN he is good in sports Given following facts(Data): 1. Student get marks>80 2. Student is making centuries 3. He is good in general knowledge From the given facts, We need to infer the “student is all rounder” which is our goal From the goal “ he is all rounder” we are going to check THEN, which is present in rule 1 and get the facts of 1 and 3 in IF- AND The subpart is “He is good is sports” check in Rule 3 THEN and get the facts 2 “student is making centuries” Thus from the goal we proved the facts
  • 116.
  • 117. Example: In backward-chaining, we will use the same above example, and will rewrite all the rules. •American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1) Owns(A, T1) ........(2) •Missile(T1) •?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4) •Missile(p) → Weapons (p) .......(5) •Enemy(p, America) →Hostile(p) ........(6) •Enemy (A, America) .........(7) •American(Robert). ..........(8) Backward-Chaining proof: In Backward chaining, we will start with our goal predicate, which is Criminal(Robert), and then infer further rules. Step-1: At the first step, we will take the goal fact. And from the goal fact, we will infer other facts, and at last, we will prove those facts true. So our goal fact is "Robert is Criminal," so following is the predicate of it.
  • 118. Step-2: At the second step, we will infer other facts form goal fact which satisfies the rules. So as we can see in Rule-1, the goal predicate Criminal (Robert) is present with substitution {Robert/P}. So we will add all the conjunctive facts below the first level and will replace p with Robert. Here we can see American (Robert) is a fact, so it is proved here.
  • 119. Step-3:t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it satisfies Rule-(5). Weapon (q) is also true with the substitution of a constant T1 at q.
  • 120. Step-4: At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r) which satisfies the Rule- 4, with the substitution of A in place of r. So these two statements are proved here.
  • 121. Step-5: At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which satisfies Rule- 6. And hence all the statements are proved true using backward chaining.
  • 122. What is Logic Programming? A type of programming consisting of facts and relationships from which the programming language can draw a conclusion. – In imperative programming languages, we tell the computer what to do by programming the procedure by which program states and variables are modified. – In contrast, in logical programming, we don’t tell the computer exactly what it should do (i.e., how to derive a conclusion). User provided facts and relationships allow it to derive answers via logical inference. Prolog is the most widely used logic programming language. Prolog Features Prolog uses logical variables: These are not the same as variables in other languages. Programmers can use them as ‘holes’ in data structures that are gradually filled in as computation proceeds. Unification is a built-in term-manipulation method that passes parameters, returns results, selects and constructs data structures. Basic control flow model is backtracking. Program clauses and data have the same form. – A Prolog program can also be seen as a relational database containing rules as well as facts.
  • 123. What is Knowledge Engineering? it is a field that concentrates on creating a knowledge base for a specific domain. It includes an in-depth investigation of a particular domain, learning all the important concepts about that domain, and then drafting out meaningful output. For example, we want to automate the teaching process for children in the subject of mathematics. It will require the knowledge of teachers, subject matter experts, and data from previous batches and their performance in maths. The general workflow to do this, we need to process the metadata (all about data, its quality, content, structure, objects, and format) in order to have a basic idea of what it takes to make a decision. In a general sense, it takes a problem to solve and then studies the factors which a human expert will consider while making a decision. A human expert will consider a number of parameters and some will be more important than others. After considering all the parameters human expert makes permutation and combinations using his prior experience with domain and give weightage to all the parameters and makes a decision. This all just happens in some fractions, but to investigate the whole process takes a good amount of time depending on the complexity of the problem. Knowledge engineering is the base that helped in the creation of expert systems where knowledge is transformed into computer programs. Expert systems have a huge and flexible knowledge base which is integrated with mechanisms that specify how to use the information of the knowledge base and apply it to a variety of situations. These expert systems also use machine learning and deep learning algorithms in order to learn as humans do. Nowadays these Expert systems are used in the education field, healthcare, financial services, manufacturing, etc.
  • 124.
  • 125. Knowledge Engineering for different domains is different but it follows, the same set of procedures in order to create expert systems. 1. Task Identification This is the first step in the knowledge engineering process where the task to be performed is defined. In a domain, a specific problem or a combination of several problems would be taken. This task must be realistic and the subject matter expert needs to have a clear idea of what it is so that further process can be carried out. 2. Acquisition of Knowledge Once the problem is well defined then the next step is to gather relevant knowledge and information about the problem. For some problems standard data is used that must be collected, for example, a problem on heat exchanger requires the standard steam table data at x temperature and y pressure what will be the value of enthalpy. 3. Prepare a road map Once the goal and knowledge base are available the next step is to get the roadmap ready by breaking the goal down into small steps by questionnaires and relevant knowledge base. Here the subject matter expert puts his thoughts on how he would make decisions and what parameters would be considered at all stages. There could be several ways to solve some problems, and all should be considered. 4. Encode Now it’s time to convert this knowledge into computer language. Here the knowledge is encoded by using different functions as well as in some cases, for a specific task, the algorithm is used to create a model. These models are able to make decisions based on available parameters as an expert does, surely the model must be trained and tested on a sufficient amount of data.
  • 126. 5. Evaluation and Debugging In the process of creating an expert system, at each step, the model should be evaluated and debugged then added to workflow. Once all small tasks are evaluated, they are assembled to create one whole expert system. This system is again evaluated on similar problems and Debugged if any issue is there. Benefits of Knowledge Engineering are as follows: 1.Knowledge engineering helps in creating better, smarter more effective expert system. 2.Models created with knowledge engineering are robust. •It is possible to pull knowledge from various domains together to handle complicated issues. •When built with Natural Language Programming (NLP) and knowledge engineering together, expert have the ability to read the queries and provide answers and solutions, in a manner somewhat similar to way a chatbot behaves. Knowledge engineering process in an electronic circuit domain, which is already familiar. This approach is mainly suitable for creating special-purpose knowledge base. The knowledge-engineering process: Following are some main steps of the knowledge-engineering process. Using these steps, we will develop a knowledge base which will allow us to reason about digital circuit (One-bit full adder) which is given below
  • 127. 1. Identify the task: The first step of the process is to identify the task, and for the digital circuit, there are various reasoning tasks. At the first level or highest level, we will examine the functionality of the circuit: •Does the circuit add properly? •What will be the output of gate A2, if all the inputs are high? At the second level, we will examine the circuit structure details such as: •Which gate is connected to the first input terminal? •Does the circuit have feedback loops?
  • 128. 2. Assemble the relevant knowledge: In the second step, we will assemble the relevant knowledge which is required for digital circuits. So for digital circuits, we have the following required knowledge: •Logic circuits are made up of wires and gates. •Signal flows through wires to the input terminal of the gate, and each gate produces the corresponding output which flows further. •In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT. •All these gates have one output terminal and two input terminals (except NOT gate, it has one input terminal). 3. Decide on vocabulary: The next step of the process is to select functions, predicate, and constants to represent the circuits, terminals, signals, and gates. Firstly we will distinguish the gates from each other and from other objects. Each gate is represented as an object which is named by a constant, such as, Gate(X1). The functionality of each gate is determined by its type, which is taken as constants such as AND, OR, XOR, or NOT. Circuits will be identified by a predicate: Circuit (C1). For the terminal, we will use predicate: Terminal(x). For gate input, we will use the function In(1, X1) for denoting the first input terminal of the gate, and for output terminal we will use Out (1, X1). The function Arity(c, i, j) is used to denote that circuit c has i input, j output. The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1)) We use a unary predicate On (t), which is true if the signal at a terminal is on.
  • 129. 4. Encode general knowledge about the domain: To encode the general knowledge about the logic circuit, we need some following rules: •If two terminals are connected then they have the same input signal, it can be represented as: •∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (2). •Signal at every terminal will have either value 0 or 1, it will be represented as: •∀ t Terminal (t) →Signal (t) = 1 ∨Signal (t) = 0. •Connect predicates are commutative: •∀ t1, t2 Connect(t1, t2) → Connect (t2, t1). •Representation of types of gates: •∀ g Gate(g) ∧ r = Type(g) → r = OR ∨r = AND ∨r = XOR ∨r = NOT. •Output of AND gate will be zero if and only if any of its input is zero. •∀ g Gate(g) ∧ Type(g) = AND →Signal (Out(1, g))= 0 ⇔ ∃n Signal (In(n, g))= 0. •Output of OR gate is 1 if and only if any of its input is 1: •∀ g Gate(g) ∧ Type(g) = OR → Signal (Out(1, g))= 1 ⇔ ∃n Signal (In(n, g))= 1 •Output of XOR gate is 1 if and only if its inputs are different: •∀ g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔ Signal (In(1, g)) ≠ Signal (In(2, g)).
  • 130. •Output of NOT gate is invert of its input: •∀ g Gate(g) ∧ Type(g) = NOT → Signal (In(1, g)) ≠ Signal (Out(1, g)). •All the gates in the above circuit have two inputs and one output (except NOT gate). 1.∀ g Gate(g) ∧ Type(g) = NOT → Arity(g, 1, 1) 2.∀ g Gate(g) ∧ r =Type(g) ∧ (r= AND ∨r= OR ∨r= XOR) → Arity (g, 2, 1). •All gates are logic circuits •∀ g Gate(g) → Circuit (g). 5. Encode a description of the problem instance: Now we encode problem of circuit C1, firstly we categorize the circuit and its gate components. This step is easy if ontology about the problem is already thought. This step involves the writing simple atomics sentences of instances of concepts, which is known as ontology. For the given circuit C1, we can encode the problem instance in atomic sentences as below: Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be: 1.For XOR gate: Type(x1)= XOR, Type(X2) = XOR 2.For AND gate: Type(A1) = AND, Type(A2)= AND 3.For OR gate: Type (O1) = OR. And then represent the connections between all the gates.
  • 131. 6. Pose queries to the inference procedure and get answers: In this step, we will find all the possible set of values of all the terminal for the adder circuit. The first query will be: What should be the combination of input which would generate the first output of circuit C1, as 0 and a second output to be 1? 1.∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C1))= i3 2. ∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1 7. Debug the knowledge base: Now we will debug the knowledge base, and this is the last step of the complete process. In this step, we will try to debug the issues of knowledge base. In the knowledge base, we may have omitted assertions like 1 ≠ 0.
  • 132. Truth maintenance systems (TMS) are also called reason maintenance systems. TMS plays with uncertainty by permitting new knowledge to replace old knowledge which is believed to be outdated or erroneous. TMS is a problem solver module responsible for, Enforcing logical relations among beliefs Generating explanation for conclusions Finding solutions to search problems Supporting default reasoning Identifying causes for failure and recover from inconsistencies
  • 133. Working Principle of TMS: The Inference Engine (IE) solves domain problems based on its current belief set, while the TMS maintains The updating process is incremental. After each inference, information exchange between the two components. The IE tells the TMS what deductions it has made. The TMS, in turn, asks a question about current beliefs and reasons for failure. If maintains a consistent even if now knowledge is added or removed. Step1: Say, The KB contains the propositions P, P->Q and modus ponens. Step2: From this, the IE would rightfully conclude Q and add this conclusion to the KB. Step3: Later, if it was learned that P was appropriate, it would be added to the KB resulting in a Step4: Consequently, it would be necessary to remove P to eliminate the inconsistency.
  • 134. 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. Where li and mj are complementary literals. This rule is also called the binary resolution rule because it only resolves exactly two literals. Example: We can resolve two clauses which are given below: [Animal (g(x) V Loves (f(x), x)] and [¬ Loves(a, b) V ¬Kills(a, b)] Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b) These literals can be unified with unifier θ= [a/f(x), and b/x] , and it will generate a resolvent clause: [Animal (g(x) V ¬ Kills(f(x), x)]. Steps for Resolution: 1.Conversion of facts into first-order logic. 2.Convert FOL statements into CNF 3.Negate the statement which needs to prove (proof by contradiction) 4.Draw resolution graph (unification).
  • 135. Example: 1.John likes all kind of food. 2.Apple and vegetable are food 3.Anything anyone eats and not killed is food. 4.Anil eats peanuts and still alive 5.Harry eats everything that Anil eats. Prove by resolution that: 6.John likes peanuts. Step-1: Conversion of Facts into FOL In the first step we will convert all the given statements into its first order logic.
  • 136. Step-2: Conversion of FOL into CNF In First order logic resolution, it is required to convert the FOL into CNF as CNF form makes easier for resolution proofs. 1. Eliminate all implication (→ with ¬, V ) and rewrite • ∀x ¬ food(x) V likes(John, x) • food(Apple) Λ food(vegetables) • ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y) • eats (Anil, Peanuts) Λ alive(Anil) • ∀x ¬ eats(Anil, x) V eats(Harry, x) • ∀x¬ [¬ killed(x) ] V alive(x) • ∀x ¬ alive(x) V ¬ killed(x) • likes(John, Peanuts). 2. Move negation (¬)inwards and rewrite • ∀x ¬ food(x) V likes(John, x) • food(Apple) Λ food(vegetables) • ∀x ∀y ¬ eats(x, y) V killed(x) V food(y) • eats (Anil, Peanuts) Λ alive(Anil) • ∀x ¬ eats(Anil, x) V eats(Harry, x) • ∀x ¬killed(x) ] V alive(x) • ∀x ¬ alive(x) V ¬ killed(x) • likes(John, Peanuts). 3. Rename variables or standardize variables • ∀x ¬ food(x) V likes(John, x) • food(Apple) Λ food(vegetables) • ∀y ∀z ¬ eats(y, z) V killed(y) V food(z) • eats (Anil, Peanuts) Λ alive(Anil) • ∀w¬ eats(Anil, w) V eats(Harry, w) • ∀g ¬killed(g) ] V alive(g) • ∀k ¬ alive(k) V ¬ killed(k) • likes(John, Peanuts).
  • 137. •Eliminate existential instantiation quantifier by elimination. In this step, we will eliminate existential quantifier ∃, and this process is known as Skolemization. But in this example problem since there is no existential quantifier so all the statements will remain same in this step. •Drop Universal quantifiers. In this step we will drop all universal quantifier since all the statements are not implicitly quantified so we don't need it. 1.¬ food(x) V likes(John, x) 2.food(Apple) 3.food(vegetables) 4.¬ eats(y, z) V killed(y) V food(z) 5.eats (Anil, Peanuts) 6.alive(Anil) 7.¬ eats(Anil, w) V eats(Harry, w) 8.killed(g) V alive(g) 9.¬ alive(k) V ¬ killed(k) 10.likes(John, Peanuts). •Distribute conjunction ∧ over disjunction ¬. This step will not make any change in this problem. Step-3: Negate the statement to be proved (proof by refutation) In this statement, we will apply negation to the conclusion last statements, which will be written as ¬likes(John, Peanuts)
  • 138. Step-4: Draw Resolution graph: Now in this step, we will solve the problem by resolution tree using substitution. For the above problem, it will be given as follows: Hence the negation of the conclusion has been proved as a complete contradiction with the given set of statements.
  • 139. Examples of Predicate Logic practise it: All students are smart. ∀ x ( Student(x) ⇒ Smart(x) ) There exists a student. ∃ x Student(x). There exists a smart student. ∃ x ( Student(x) ∧ Smart(x) ) Every student loves some student. ∀ x ( Student(x) ⇒ ∃ y ( Student(y) ∧ Loves(x,y) )) Every student loves some other student. ∀ x ( Student(x) ⇒ ∃ y ( Student(y) ∧ ¬ (x = y) ∧ Loves(x,y) )) There is a student who is loved by every other student. ∃ x ( Student(x) ∧ ∀ y ( Student(y) ∧ ¬(x = y) ⇒ Loves(y,x) )) Bill is a student. Student(Bill) Bill takes either Analysis or Geometry (but not both) Takes(Bill, Analysis) ⇔ ¬ Takes(Bill, Geometry) Bill takes Analysis or Geometry (or both). Takes(Bill, Analysis) ∨ Takes(Bill, Geometry) Bill takes Analysis and Geometry. Takes(Bill, Analysis) ∧ Takes(Bill, Geometry) Bill does not take Analysis. ¬ Takes(Bill, Analysis). No student loves Bill. ¬ ∃ x ( Student(x) ∧ Loves(x, Bill) ) Bill has at least one sister. ∃ x SisterOf(x,Bill) Bill has no sister. ¬ ∃ x SisterOf(x,Bill) Bill has at most one sister. ∀ x, y ( SisterOf(x, Bill) ∧ SisterOf(y, Bill) ⇒ x = y )
  • 140. Bill has exactly one sister. ∃ x ( SisterOf(x, Bill) ∧ ∀ y ( SisterOf(y, Bill) ⇒ x = y )) Bill has at least two sisters. ∃ x, y ( SisterOf(x, Bill) ∧ SisterOf(y, Bill) ∧ ¬ (x = y) ) Every student takes at least one course. ∀ x ( Student(x) ⇒ ∃ y ( Course(y) ∧ Takes(x,y) )) Only one student failed History. ∃ x ( Student(x) ∧ Failed(x, History) ∧ ∀ y ( Student(y) ∧ Failed(y, History) ⇒ x = y )) No student failed Chemistry but at least one student failed History. ¬ ∃ x ( Student(x) ∧ Failed(x, Chemistry) ) ∧ ∃ x ( Student(x) ∧ Failed(x, History) ) Every student who takes Analysis also takes Geometry. ∀ x ( Student(x) ∧ Takes(x, Analysis) ⇒ Takes(x, Geometry) ) No student can fool all the other students. ¬ ∃ x ( Student(x) ∧ ∀ y ( Student(y) ∧ ¬ (x = y) ⇒ Fools(x,y) ))