0% found this document useful (0 votes)
183 views66 pages

Unit 3

- The document discusses knowledge representation in artificial intelligence, specifically first-order logic. - Propositional logic is insufficient to represent more complex statements, so first-order logic was developed. It allows representation of objects, relations between objects, and functions. - The syntax and semantics of first-order logic are explained, including basic elements like constants, variables, predicates, functions, and connectives. Quantifiers like universal and existential are also defined. - Knowledge engineering is the process of building a knowledge base in first-order logic to represent a domain. The steps of identifying tasks, assembling relevant knowledge, and deciding on vocabulary are outlined.

Uploaded by

jana k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views66 pages

Unit 3

- The document discusses knowledge representation in artificial intelligence, specifically first-order logic. - Propositional logic is insufficient to represent more complex statements, so first-order logic was developed. It allows representation of objects, relations between objects, and functions. - The syntax and semantics of first-order logic are explained, including basic elements like constants, variables, predicates, functions, and connectives. Quantifiers like universal and existential are also defined. - Knowledge engineering is the process of building a knowledge base in first-order logic to represent a domain. The steps of identifying tasks, assembling relevant knowledge, and deciding on vocabulary are outlined.

Uploaded by

jana k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 66

UNIT III

KNOWLEDGE REPRESENTATION

First-Order Logic in Artificial intelligence


We learned how to represent statements using propositional logic in
Propositional Logic. Unfortunately, we can only represent facts that are either
true or untrue in propositional logic. To represent complicated phrases or
natural language statements, PL is insufficient. The expressive power of
propositional logic is quite restricted. Consider the sentence below, which we
can't represent with PL logic.
"Some humans are intelligent", or
"Sachin likes cricket."
Because PL logic is insufficient to capture the above statements, we needed to
use more stronger logic, such as first-order logic.
First-Order logic
 In artificial intelligence, first-order logic is another method of
knowledge representation. It's a variant of propositional logic.
 FOL has enough expressiveness to convey natural language statements
succinctly.
 Predicate logic or First-order predicate logic are other names for first-
order logic. First-order logic is a sophisticated language that makes it
easier to build information about objects and to articulate relationships
between them.
 First-order logic (like natural language) assumes not just that the world
includes facts, as does propositional logic, but also that the world has
the following things:
Objects: A, B, people, numbers, colors, wars, theories, squares, pits,
wumpus, ......
Relations: It can be a unary relation like red, round, or nearby, or an n-any
relation like sister of, brother of, has colour, or comes between.
Function: Father of, best friend, third inning of, end of, ......
First-order logic contains two basic elements as a natural language:
 Syntax
 Semantics
Syntax of First-Order logic
In first-order logic, the syntax of FOL determines which set of symbols
represents a logical expression. Symbols are the core syntactic constituents of
first-order logic. In FOL, we use short-hand notation to write statements.
Basic Elements of First-order logic
Following are the basic elements of FOL syntax

Constant 1, 2, A, John, Mumbai, cat,....

Variables x, y, z, a, b,....

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃

Atomic sentences
Atomic sentences are the most basic first-order logic sentences. These
sentences are made up of a predicate symbol, a parenthesis, and a series of
terms.
We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
                Chinky is a cat: => cat (Chinky).
Complex Sentences
Connectives are used to join atomic sentences to form complex sentences.
The following are two types of first-order logic statements:
Subject: Subject is the main part of the statement.
Predicate: A predicate can be defined as a relation, which binds two atoms
together in a statement.
Consider the following statement: "x is an integer." It has two parts: the first
component, x, is the statement's subject, and the second part, "is an integer," is
the statement's predicate.

Quantifiers in First-order logic


Quantification describes the quantity of specimen in the universe of discourse,
and a quantifier is a linguistic element that generates quantification.
These are the symbols that allow you to determine or identify the variable's
range and scope in a logical expression. There are two different kinds of
quantifiers:
 Universal Quantifier, (for all, everyone, everything)
 Existential quantifier, (for some, at least one).
Universal Quantifier
A universal quantifier is a logical symbol that indicates that a statement inside
its range is true for everything or every instance of a specific thing.
A symbol ∀ that resembles an inverted A is used to represent the Universal
quantifier.
If x is a variable, then ∀x is read as:
 For all x
 For each x
 For every x.
Example
All man drink coffee.
Let x be a variable that corresponds to a cat, and all x in UOD can be
represented as follows.

∀x man(x) → drink (x, coffee).


It will be read as: Therᵗe are all x where x is a man who drink coffee.
Existential Quantifier
Existential quantifiers are a sort of quantifier that expresses that a statement is
true for at least one instance of something within its scope.
The logical operator ∃ resembles an inverted E and is used to represent it. It is
referred to be an existential quantifier when it is employed with a predicate
variable.
If x is a variable, the existential quantifier is either ∃x or ∃(x). It will also 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 a boy who is intelligent.
Features
The main connective for universal quantifier ∀ is implication →.
The main connective for existential quantifier ∃ is and ∧.
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.
Some Examples of FOL using quantifier:
1. All birds fly.
The predicate in this question is "fly(bird)."
Because all birds are able to fly, it will be portrayed as follows.
              ∀x bird(x) →fly(x).
2. Every man looks up to his father or mother.
The predicate in this question is "respect(x, y)," where x=man and y=parent.
Because every man exists, we shall use ∀, which will be represented as
follows:
              ∀x man(x) → respects (x, parent).
3. Some of the youngsters enjoy cricket.
The predicate in this question is "play(x, y)," where x=boys and y=game.
We'll use ∃ because there are some boys, and it'll be written as:
              ∃x boys(x) → play(x, cricket).
4. Not every student enjoys both math and science.
The predicate in this question is "like(x, y)," where x denotes student and y
denotes subject.
Because not all pupils are present, we shall utilise ∀ with negation, as shown
in the following representation:
              ¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].
5. Only one student received a failing grade in mathematics.
The predicate in this question is "failed(x, y)," where x represents a student
and y represents a topic.
We shall adopt the following representation because there is just one student
who failed Mathematics:
              ∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧
student(y) → ¬failed (x, Mathematics)].
Free and Bound Variables
The quantifiers interact with variables that exist in the right order. First-order
logic has two sorts of variables, which are listed below:
In a formula, a variable is said to be a free variable if it exists outside of the
quantifier's scope.
          Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: In a formula, a variable is said to be a bound variable if it
appears within the scope of the quantifier.
          Example: ∀x [A (x) B( y)], here x and y are the bound variables.
Knowledge Engineering
Knowledge engineering is the process of building a knowledge base in first-
order logic. In knowledge engineering, a knowledge engineer is someone who
researches a given domain, learns significant domain concepts, and develops a
formal representation of the objects.
In this topic, we'll look at the knowledge engineering process in the context of
an electronic circuit, which we're already familiar with. This method is best
suited for developing specialised knowledge bases.
The knowledge-engineering process:
The knowledge-engineering process is broken down into the following steps.
We will construct a knowledge foundation that will allow us to reason about
the digital circuit (One-bit full adder) that is shown below using these
techniques.

1. Identify the task:


The initial stage in the procedure is to determine the task, and there are several
reasoning tasks for the digital circuit.
We'll look at the circuit's functionality at the highest level, or first level:
 Does the circuit add properly?
 What will be the output of gate A2, if all the inputs are high?
At the second level, we'll look into the specifics of the circuit structure, 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 put together the necessary information for digital
circuits. So, in order to understand digital circuits, we must have the following
understanding.
 Wires and gates combine to form logic circuits.
 Signals flow through wires to the gate's input terminal, and each gate
produces an output that flows in the opposite direction.
 The gates AND, OR, XOR, and NOT are employed in this logic
circuit.
 One output terminal and two input terminals are shared by all of these
gates (except NOT gate, it has one input terminal).
3. Decide on vocabulary
Selecting functions, predicates, and constants to represent circuits, terminals,
signals, and gates is the next phase in the process. To begin, we'll separate the
gates from one another and from other items. Each gate is represented as an
object with a unique name, such as Gate (X1). Each gate's functionality is
determined by its type, which is represented by constants such as AND, OR,
XOR, and NOT. A predicate will be used to identify circuits: Circuit (C1).
For the terminal, we will use predicate: Terminal(x).
The function In(1, X1) will be used to denote the first input terminal of the
gate, and Out will be used to denote the output terminal (1, X1).
Circuit c has I input and j output, as indicated by the function Arity(c, I j).
Predicate Connect(Out(1, X1), In(1, X1)) can be used to express the
connections between gates.
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
We'll need the following principles to encode general information about logic
circuits:
When two terminals are connected, the input signal is the same, which may be
expressed as
∀  t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Sign
al (2).   
 Every terminal's signal will have a value of 0 or 1, and 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.   
 If and only if any of the AND gate's inputs are 0, the output will be
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).
∀  g Gate(g) ∧ Type(g) = NOT →   Arity(g, 1, 1)   
∀  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).
Encode a description of the problem instance
 Now, in order to decode the problem of circuit C1, we must first
classify the circuit and its gate components. This phase is simple if the
problem's ontology has already been considered. This step entails
writing simple atomic sentences of idea instances, which is referred to
as ontology.
 We may encode the issue instance in atomic phrases for the given
circuit C1 as follows:
 Because there are two XOR gates, two AND gates, and one OR gate in
the circuit, the atomic sentences for these gates will be:
 For XOR gate: Type(x1)= XOR, Type(X2) = XOR  
 For AND gate: Type(A1) = AND, Type(A2)= AND  
 For OR gate: Type (O1) = OR. 
 And then represent the connections between all the gates.
Pose queries to the inference procedure and get answers
We'll find all of the possible values for all of the terminals in the adder circuit
in this stage. The first question will be: What input combination should yield a
0 for the first output of circuit C1 and a 1 for the second output?
∃ i1, i2, i3 Signal (In(1, C1))=i1  ∧  Signal (In(2, C1))=i2  ∧ Signal (In(3, C1))
= i3  
∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1 
Debug the knowledge base
We'll now debug the knowledge base, which is the final step in the process. In
this stage, we'll try to figure out what's wrong with the knowledge base.
We may have missed statements like 1 ≠ 0 in the knowledge base.
Inference in First-Order Logic
In First-Order Logic, inference is used to derive new facts or sentences from
existing ones. Before we get into the FOL inference rule, it's important to
understand some basic FOL terminology.
Substitution:
Substitution is a basic procedure that is applied to terms and formulations. It
can be found in all first-order logic inference systems. When there are
quantifiers in FOL, the substitution becomes more complicated. If we
write F[a/x], so it refers to substitute a constant "a" in place of variable "x".
Equality
In First-Order Logic, atomic sentences are formed not only via the use of
predicate and words, but also through the application of equality. We can do
this by using equality symbols, which indicate that the two terms relate to the
same thing.
Brother (John) = Smith, for example.
The thing referred to by the Brother (John) is comparable to the object referred
to by Smith in the example above. The negation symbol can also be used
alongside the equality symbol to show that two terms are not the same.
Example: ¬(x=y) which is equivalent to x ≠y.
FOL inference rules for quantifier
First-order logic has inference rules similar to propositional logic, therefore
here are some basic inference rules in FOL:
 Universal Generalization
 Universal Instantiation
 Existential Instantiation
 Existential introduction
1. Universal Generalization:
Universal generalisation is a valid inference rule that asserts that if premise
P(c) is true for every arbitrary element c in the universe of discourse, we can
draw the following conclusion: ∀ x P(x).

It can be represented as:  .


If we want to prove that every element has a similar property, we can apply
this rule.
x must not be used as a free variable in this rule.
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:
A valid inference rule is universal instantiation, often known as universal
elimination or UI. It can be used to add additional sentences many times.
The new knowledge base is logically equal to the existing knowledge base.
We can infer any phrase by replacing a ground word for the variable,
according to UI.
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 known as Existential Elimination, and it is a
legitimate first-order logic inference rule.
It can only be used to replace the existential sentence once.
Although the new KB is not conceptually identical to the old KB, it will be
satisfiable if the old KB was.
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 denoted 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 sign K used above is a constant symbol known as the Skolem constant.
Skolemization process is a specific case of Existential instantiation.
4. Existential introduction
An existential generalisation is a valid inference rule in first-order logic that is
also known as an existential introduction.
This rule argues that if some element c in the universe of discourse has the
property P, we can infer that something in the universe has the attribute P.
It can be represented as: 
Example: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Generalized Modus Ponens Rule
In FOL, we use a single inference rule called Generalized Modus Ponens for
the inference process. It's a modified form of Modus ponens.
"P implies Q, and P is declared to be true, hence Q must be true," summarises
Generalized Modus Ponens.
According to Modus Ponens, for atomic sentences pi, pi', q. Where there is a
substitution θ such that SUBST (θ, pi',) = SUBST(θ, pi), it can be represented
as:

Example
We will use this rule for Kings are evil, so we will find some x such that x is
king, and x is greedy so we can infer that x is evil.
Here let say, p1' is king(John)        p1 is king(x)  
p2' is Greedy(y)                       p2 is Greedy(x)  
θ is {x/John, y/John}                  q is evil(x)  
SUBST(θ,q). 
Propositional logic in Artificial intelligence
The simplest kind of logic is propositional logic (PL), in which all statements
are made up of propositions. The term "proposition" refers to a declarative
statement that can be true or false. It's a method of expressing knowledge in
logical and mathematical terms.
Example
a) It is Sunday.  
b) The Sun rises from West (False proposition)  
c) 3+3= 7(False proposition)  
d) 5 is a prime number.
The following are some fundamental propositional logic facts:
 Because it operates with 0 and 1, propositional logic is also known as
Boolean logic.
 In propositional logic, symbolic variables are used to express the logic,
and any symbol can be used to represent a proposition, such as A, B,
C, P, Q, R, and so on.
 Propositions can be true or untrue, but not both at the same time.
 An object, relations or functions, and logical connectives make up
propositional logic.
 Logical operators are another name for these connectives.
 The basic elements of propositional logic are propositions and
connectives.
 Connectives are logical operators that link two sentences together.
 Tautology, commonly known as a legitimate sentence, is a proposition
formula that is always true.
 Contradiction is a proposition formula that is always false.
 Statements that are inquiries, demands, or opinions are not
propositions, such as "Where is Rohini," "How are you," and "What is
your name," are not propositions.
Syntax of propositional logic
The allowed sentences for knowledge representation are defined by the syntax
of propositional logic. Propositions are divided into two categories:
 Atomic Propositions
 Compound propositions
Atomic Proposition: Simple statements are atomic propositions. It is made up
of only one proposition sign. These are the sentences that must be true or
untrue in order to pass.
Example
a) 2+2 is 4, it is an atomic proposition as it is a true fact.  
b) "The Sun is cold," as well as being a false fact, is a proposition.
Compound propositions are made up of simpler or atomic propositions joined
together with parenthesis and logical connectives.
a) "It is raining today, and street is wet."  
b) "Ankit is a doctor, and his clinic is in Mumbai."
Logical Connectives
Logical connectives are used to link two simpler ideas or to logically represent
a statement. With the use of logical connectives, we can form compound
assertions. There are five primary connectives, which are listed below:
Negation: A sentence such as ¬ P is called negation of P. A literal can be
either Positive literal or negative literal.
Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a
conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called
disjunction, where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
Implication: A sentence such as P → Q, is called an implication. Implications
are also known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example
If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.Following is
the summarized table for Propositional Logic Connectives:
Truth Table
We need to know the truth values of propositions in all feasible contexts in
propositional logic. With logical connectives, we can combine all possible
combinations, and the representation of these combinations in a tabular
manner is known as a truth table. The truth table for all logical connectives is
as follows:
 
Truth table with three propositions
A proposition can be constructed by combining three propositions: P, Q, and
R. Because we used three proposition symbols, this truth table is made up of
8n Tuples.

Precedence of connectives
Propositional connectors or logical operators, like arithmetic operators, have a
precedence order. When evaluating a propositional problem, this order should
be followed. The following is a list of the operator precedence order:

Precedence Operators

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)


Fifth Precedence Implication

Six Precedence Biconditional

Logical equivalence
One of the characteristics of propositional logic is logical equivalence. If and
only if the truth table's columns are equal, two assertions are said to be
logically comparable.
Let's take two propositions A and B, so for logical equivalence, we can write it
as A⇔B. In below truth table we can see that column for ¬A∨ B and A→B,
are identical hence A is Equivalent to B

Properties of Operators
Commutativity:
P∧ Q= Q ∧ P, or
P ∨ Q = Q ∨ P.
Associativity:
(P ∧ Q) ∧ R= P ∧ (Q ∧ R),
(P ∨ Q) ∨ R= P ∨ (Q ∨ R)
Identity element:
P ∧ True = P,
P ∨ True= True.
Distributive:
P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
DE Morgan's Law:
¬ (P ∧ Q) = (¬P) ∨ (¬Q)
¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
Double-negation elimination:
¬ (¬P) = P.
Limitations of Propositional logic
With propositional logic, we can't represent relations like ALL, SOME, or
NONE. Example:
 All the girls are intelligent.
 Some apples are sweet.
The expressive power of propositional logic is restricted.
We can't explain propositions in propositional logic in terms of their qualities
or logical relationships.
Rules of Inference in Artificial intelligence
Inference
We need intelligent computers in artificial intelligence to construct new logic
from old logic or evidence, therefore inference is the process of drawing
conclusions from data and facts.
Inference rules
The templates for creating valid arguments are known as inference rules. In
artificial intelligence, inference rules are used to generate proofs, and a proof
is a series of conclusions that leads to the intended outcome.
The implication among all the connectives is vital in inference rules. Some
terms relating to inference rules are as follows:
Implication: It is one of the logical connectives which can be represented as P
→ Q. It is a Boolean expression.
Converse: The converse of implication, which means the right-hand side
proposition goes to the left-hand side and vice-versa. It can be written as Q →
P.
Contrapositive: The negation of converse is termed as contrapositive, and it
can be represented as ¬ Q → ¬ P.
Inverse: The negation of implication is called inverse. It can be represented as
¬ P → ¬ Q.
Some of the compound claims in the above term are equivalent to each other,
which we can establish using a truth table.

Hence from the above truth table, we can prove that P → Q is equivalent to ¬
Q → ¬ P, and Q→ P is equivalent to ¬ P → ¬ Q.
Types of Inference rules
1. Modus Ponens:
One of the most essential laws of inference is the Modus Ponens rule, which
asserts that if P and P →Q are both true, we can infer that Q will be true as
well. It's written like this:

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.
2.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.

Example:
Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
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:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be
true. It can be represented as

Proof by Truth-Table:

Wumpus world
The Wumpus world is a basic world example that demonstrates the value of a
knowledge-based agent and how knowledge representation is represented. It
was inspired by Gregory Yob's 1973 video game Hunt the Wumpus.
The Wumpus world is a cave with 4x4 rooms and pathways connecting them.
As a result, there are a total of 16 rooms that are interconnected. We now have
a knowledge-based AI capable of progressing in this world. There is an area in
the cave with a beast named Wumpus who eats everybody who enters. The
agent can shoot the Wumpus, but he only has a single arrow. There are some
Pits chambers in the Wumpus universe that are bottomless, and if an agent
falls into one, he will be stuck there indefinitely. The intriguing thing about
this cave is that there is a chance of finding a gold heap in one of the rooms.
So the agent's mission is to find the gold and get out of the cave without
getting eaten by Wumpus or falling into Pits. If the agent returns with gold, he
will be rewarded, but if he is devoured by Wumpus or falls into the pit, he will
be penalised.
A sample diagram for portraying the Wumpus planet is shown below. It
depicts some rooms with Pits, one room with Wumpus, and one agent in the
world's (1, 1) square position.

There are some elements that can assist the agent in navigating the cave. The
following are the components:
 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.
 If the agent is facing the Wumpus, the agent can kill it, and the
Wumpus will cry horribly, which can be heard throughout the cave.
PEAS description of Wumpus world
To explain the Wumpus world we have given PEAS description as below:
Performance measure:
 +1000 reward points if the agent comes out of the cave with the gold.
 -1000 points penalty for being eaten by the Wumpus or falling into the
pit.
 -1 for each action, and -10 for using an arrow.
 The game ends if either agent dies or came out of the cave.
Environment:
 A 4*4 grid of rooms.
 The agent initially in room square [1, 1], facing toward the right.
 Location of Wumpus and gold are chosen randomly except the first
square
 Each square of the cave can be a pit with probability 0.2 except the
first square.
Actuators
 Left turn,
 Right turn
 Move forward
 Grab
 Release
 Shoot.
Sensors:
 If the agent is in the same room as the Wumpus, he will smell the
stench. (Not on a diagonal.)
 If the agent is in the room directly adjacent to the Pit, he will feel a
breeze.
 The agent will notice the gleam in the room where the gold is located.
 If the agent walks into a wall, he will feel the bump.
 When the Wumpus is shot, it lets out a horrifying cry that can be heard
throughout the cave.
 These perceptions can be expressed as a five-element list in which
each sensor will have its own set of indicators.
 For instance, if an agent detects smell and breeze but no glitter, bump,
or shout, it might be represented as [Stench, Breeze, None, None,
None].
The Wumpus world Properties
 Partially observable: The Wumpus world is partially observable
because the agent can only perceive the close environment such as an
adjacent room.
 Deterministic: It is deterministic, as the result and outcome of the
world are already known.
 Sequential: The order is important, so it is sequential.
 Static: It is static as Wumpus and Pits are not moving.
 Discrete: The environment is discrete.
 One agent: The environment is a single agent as we have one agent
only and Wumpus is not considered as an agent.
Exploring the Wumpus world
Now we'll investigate the Wumpus universe and see how the agent will
achieve its goal through logical reasoning.
The first step for an agent is to:
Initially, the agent is in the first room, or square [1,1], and we already 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.
At Room [1,1] agent does not feel any breeze or any Stench which means the
adjacent squares are also OK.
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 symbolise 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 odour 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.
Unification
 Unification is the process of finding a substitute that makes two
separate logical atomic expressions identical. The substitution process
is necessary for unification.
 It accepts two literals as input and uses substitution to make them
identical.
 Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such
that, Ψ1𝜎 = Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
 Example: Find the MGU for Unify{King(x), King(John)}
 Let Ψ1 = King(x), Ψ2 = King(John),
 Substitution θ = {John/x} is a unifier for these atoms and applying this
substitution, and both expressions will be identical.
 For unification, the UNIFY algorithm is employed, which takes two
atomic statements and returns a unifier for each of them (If any exist).
 All first-order inference techniques rely heavily on unification.
 If the expressions do not match, the result is failure.
 The replacement variables are referred to as MGU (Most General
Unifier).
E.g. Let's assume P(x, y) and P(a, f(z)) are two different expressions.
In this case, we must make both of the preceding assertions identical. We'll
make the substitution in this case.
  P(x, y)......... (i)
  P(a, f(z))......... (ii)
 In the first statement, replace x with a and y with f(z), and the result
will be a/x and f(z)/y.
 The first expression will be equal to the second expression with both
replacements, and the substitution set will be [a/x, f(z)/y].
Conditions for Unification
Following are some basic conditions for unification:
 Atoms or expressions with various predicate symbols can never be
united.
 Both phrases must have the same number of arguments.
 If two comparable variables appear in the same expression, unification
will fail.
Unification Algorithm
Algorithm: Unify(Ψ1, Ψ2)
Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:
a) If Ψ1 or Ψ2 are identical, then return NIL.
b) Else if Ψ1is a variable,
a. then if Ψ1 occurs in Ψ2, then return FAILURE
b. Else return { (Ψ2/ Ψ1)}.
c) Else if Ψ2 is a variable,
a. If Ψ2 occurs in Ψ1 then return FAILURE,
b. Else return {( Ψ1/ Ψ2)}.
d) Else return FAILURE.
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then return
FAILURE.
Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return
FAILURE.
Step. 4: Set Substitution set(SUBST) to NIL.
Step. 5: For i=1 to the number of elements in Ψ1.
a) Call Unify function with the ith element of Ψ1 and ith element of
Ψ2, and put the result into S.
b) If S = failure then returns Failure
c) If S ≠ NIL then do,
a. Apply S to the remainder of both L1 and L2.
b. SUBST= APPEND(S, SUBST).
Step.6: Return SUBST.
Implementation of the Algorithm
Step.1: Initialize the substitution set to be empty.
Step.2: Recursively unify atomic sentences:
 Check for Identical expression match.
 If one expression is a variable vi, and the other is a term ti which does
not contain variable vi, then:
 Substitute ti / vi in the existing substitutions
 Add ti /vi to the substitution setlist.
 If both the expressions are functions, then function name must be
similar, and the number of arguments must be the same in both the
expression.
 For each pair of the following atomic sentences find the most general
unifier (If exist).
1. Find the MGU of {p(f(a), g(Y)) and p(X, X)}
            Sol: S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X, X)
                  SUBST θ= {f(a) / X}
                  S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a), f(a))
                  SUBST θ= {f(a) / g(y)}, Unification failed.
Unification is not possible for these expressions.
2. Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))}
Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))
S0 => { p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}
SUBST θ={b/Z}
S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))}
SUBST θ={f(Y) /X}
S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))}
SUBST θ= {g(b) /Y}
S2 => { p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))} Unified Successfully.
And Unifier = { b/Z, f(Y) /X , g(b) /Y}.
3. Find the MGU of {p (X, X), and p (Z, f(Z))}
Here, Ψ1 = {p (X, X), and Ψ2 = p (Z, f(Z))
S0 => {p (X, X), p (Z, f(Z))}
SUBST θ= {X/Z}
S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {f(Z) / Z}, Unification Failed.
Hence, unification is not possible for these expressions.
4. Find the MGU of UNIFY(prime (11), prime(y))
Here, Ψ1 = {prime(11) , and Ψ2 = prime(y)}
S0 => {prime(11) , prime(y)}
SUBST θ= {11/y}
S1 => {prime(11) , prime(11)} , Successfully unified.
 Unifier: {11/y}.
5. Find the MGU of Q(a, g(x, a), f(y)), Q(a, g(f(b), a), x)}
Here, Ψ1 = Q(a, g(x, a), f(y)), and Ψ2 = Q(a, g(f(b), a), x)
S0 => {Q(a, g(x, a), f(y)); Q(a, g(f(b), a), x)}
SUBST θ= {f(b)/x}
S1 => {Q(a, g(f(b), a), f(y)); Q(a, g(f(b), a), f(b))}
SUBST θ= {b/y}
S1 => {Q(a, g(f(b), a), f(b)); Q(a, g(f(b), a), f(b))}, Successfully Unified.
Unifier: [a/a, f(b)/x, b/y].
6. UNIFY(knows(Richard, x), knows(Richard, John))
Here, Ψ1 = knows(Richard, x), and Ψ2 = knows(Richard, John)
S0 => { knows(Richard, x); knows(Richard, John)}
SUBST θ= {John/x}
S1 => { knows(Richard, John); knows(Richard, John)}, Successfully Unified.
Unifier: {John/x}.
Forward Chaining and backward chaining in AI
Forward and backward chaining is an essential topic in artificial intelligence,
but before we go into forward and backward chaining, let's look at where these
two phrases come from.
Inference engine:
In artificial intelligence, the inference engine is a component of the intelligent
system that applies logical rules to the knowledge base to infer new
information from known facts. The expert system included the first inference
engine. Inference engines often operate in one of two modes:
 Forward chaining
 Backward chaining
Horn Clause and Definite clause
Horn clause and definite clause are sentence types that allow the knowledge
base to apply a more limited and efficient inference procedure. Forward and
backward chaining techniques are used in logical inference algorithms, and
they both need KB in the form of a first-order definite sentence.
A definite clause, sometimes known as a strict horn clause, is a clause that is a
disjunction of literals with exactly one affirmative literal.
Horn clause: A horn clause is a clause that is a disjunction of literals with at
most one positive literal. As a result, every definite clause is a horn clause.
Example: (¬ p V ¬ q V k). It has only one positive literal k.
It is equivalent to p ∧ q → k.
Forward Chaining
When employing an inference engine, forward chaining is also known as
forward deduction or forward reasoning. Forward chaining is a type of
reasoning that starts with atomic sentences in a knowledge base and uses
inference rules (Modus Ponens) to extract more material in the forward
direction until a goal is attained.
The Forward-chaining algorithm begins with known facts, then activates all
rules with satisfied premises and adds their conclusion to the known facts.
This process continues until the issue is resolved.
Properties of Forward-Chaining
 As it moves from bottom to top, it is a down-up method.
 It is a method of arriving at a conclusion based on known facts or data
by starting at the beginning and working one's way to the end.
 Forward-chaining is also known as data-driven since it allows us to
achieve our goal by utilising existing data.
 Expert systems, such as CLIPS, business, and production rule systems,
frequently employ the forward-chaining approach.
Consider the following well-known example, which we'll apply to both ways.
Example
"It is illegal for an American to sell weapons to unfriendly countries,
according to the law. Country A, an American foe, has a few missiles, all of
which were sold to it by Robert, an American citizen."
Demonstrate that "Robert is a thief."
To answer the problem, we'll turn all of the facts above into first-order definite
clauses, then utilise a forward-chaining procedure to get to 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
When employing an inference engine, backward-chaining is also known as
backward deduction or backward reasoning. A backward chaining algorithm is
a type of reasoning that begins with the objective and goes backward, chaining
via rules to discover known facts that support it.
Properties of backward chaining
 A top-down strategy is what it's called.
 The modus ponens inference rule is used in backward-chaining.
 The goal is divided down into sub-goals or sub-goals in backward
chaining to establish the facts are correct.
 It's known as a goal-driven strategy because a list of objectives
determines which rules are chosen and implemented.
 In game theory, automated theorem proving tools, inference engines,
proof helpers, and other AI applications, the backward-chaining
algorithm is used.
 For proof, the backward-chaining method primarily used a depth-first
search strategy.
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) ------(3)
?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.
Difference between backward chaining and forward chaining

 Ahead chaining begins with known facts and moves forward by


applying inference rules to extract more data until it reaches the goal,
whereas backward chaining begins with the goal and moves backward
by applying inference rules to determine the facts that satisfy the goal.
 A data-driven inference technique is forward chaining, and a goal-
driven inference strategy is backward chaining.
 The down-up strategy is known as forward chaining, and the top-down
approach is known as backward chaining.
 Forward chaining employs a breadth-first approach, whereas reverse
chaining employs a depth-first approach.
 The Modus ponens inference rule is used in both forward and
backward chaining.
 Forward chaining is useful for jobs like planning, design process
monitoring, diagnosis, and classification, whereas backward chaining
is useful for tasks like categorization and diagnosis.
 Backward chaining aims to avoid the needless path of reasoning,
whereas forward chaining can be like an exhaustive search.
 There may be a variety of ASK questions from the knowledge base in
forward-chaining, whereas there may be fewer ASK questions in
backward-chaining.
 Forward chaining is sluggish because it tests all of the rules, whereas
backward chaining is quick since it simply checks the rules that are
required.

S. Forward Chaining Backward Chaining


No.

1. Forward chaining starts from Backward chaining starts from


known facts and applies the goal and works backward
inference rule to extract through inference rules to find
more data unit it reaches to the required facts that support
the goal. the goal.

2. It is a bottom-up approach It is a top-down approach

3. Forward chaining is known Backward chaining is known as


as data-driven inference goal-driven technique as we
technique as we reach to the start from the goal and divide
goal using the available data. into sub-goal to extract the
facts.
4. Forward chaining reasoning Backward chaining reasoning
applies a breadth-first search applies a depth-first search
strategy. strategy.

5. Forward chaining tests for all Backward chaining only tests


the available rules for few required rules.

6. Forward chaining is suitable Backward chaining is suitable


for the planning, monitoring, for diagnostic, prescription, and
control, and interpretation debugging application.
application.

7. Forward chaining can Backward chaining generates a


generate an infinite number finite number of possible
of possible conclusions. conclusions.

8. It operates in the forward It operates in the backward


direction. direction.

9. Forward chaining is aimed Backward chaining is only


for any conclusion. aimed for the required data.

Resolution in FOL
Resolution is a method of theorem proof that involves constructing refutation
proofs, or proofs by contradictions. It was created in 1965 by a mathematician
named John Alan Robinson.
When several statements are supplied and we need to prove a conclusion from
those claims, we employ resolution. In proofs by resolutions, unification is a
crucial idea. Resolution is a single inference rule that can work on either the
conjunctive normal form or the clausal form efficiently.
Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also
known as a unit clause.
Conjunctive Normal Form: A sentence represented as a conjunction of clauses
is said to be conjunctive normal form or CNF.

The resolution inference rule


The propositional rule is just a lifted version of the resolution rule for first-
order logic. If two clauses include complementary literals that are expected to
be standardised apart so that they share no variables, resolution can resolve
them.

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:
 Conversion of facts into first-order logic.
 Convert FOL statements into CNF
 Negate the statement which needs to prove (proof by contradiction)
 Draw resolution graph (unification).
To better understand all the above steps, we will take an example in which we
will apply resolution.
Example:
 John likes all kind of food.
 Apple and vegetable are food
 Anything anyone eats and not killed is food.
 Anil eats peanuts and still alive
 Harry eats everything that Anil eats.
Prove by resolution that:
 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.
Eliminate all implication (→) and rewrite
a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x¬ [¬ killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts).
Move negation (¬)inwards and rewrite
a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x ¬killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts).
Rename variables or standardize variables
a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀w¬ eats(Anil, w) V eats(Harry, w)
f. ∀g ¬killed(g) ] V alive(g)
g. ∀k ¬ alive(k) V ¬ killed(k)
h. 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.
y.¬ food(x) V likes(John, x)
a. food(Apple)
b. food(vegetables)
c. ¬ eats(y, z) V killed(y) V food(z)
d. eats (Anil, Peanuts)
e. alive(Anil)
f. ¬ eats(Anil, w) V eats(Harry, w)
g. killed(g) V alive(g)
h. ¬ alive(k) V ¬ killed(k)
i. 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
In this statement, we will apply negation to the conclusion 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.

Explanation of Resolution graph


In the first step of resolution graph, ¬likes(John, Peanuts) , and likes(John,
x) get resolved(canceled) by substitution of {Peanuts/x}, and we are left
with ¬ food(Peanuts)
In the second step of the resolution graph, ¬ food(Peanuts) , and food(z) get
resolved (canceled) by substitution of { Peanuts/z}, and we are left with ¬
eats(y, Peanuts) V killed(y) .
In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil,
Peanuts) get resolved by substitution {Anil/y}, and we are left
with Killed(Anil) .
In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get
resolve by substitution {Anil/k}, and we are left with ¬ alive(Anil) .
In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get
resolved.
Knowledge representation
Humans excel in comprehending, reasoning, and interpreting information.
Humans have knowledge about things and use that knowledge to accomplish
various activities in the real world. However, knowledge representation and
reasoning deal with how robots achieve all of these things. As a result, the
following is a description of knowledge representation:
 Knowledge representation and reasoning (KR, KRR) is a branch of
artificial intelligence that studies how AI agents think and how their
thinking influences their behaviour.
 It is in charge of encoding information about the real world in such a
way that a computer can comprehend it and use it to solve complicated
real-world problems like diagnosing a medical condition or conversing
with humans in natural language.
 It's also a means of describing how artificial intelligence can represent
knowledge. Knowledge representation is more than just storing data in
a database; it also allows an intelligent machine to learn from its
knowledge and experiences in order to act intelligently like a person.

Representation
Following are the kind of knowledge which needs to be represented in AI
systems:
 Object: All the facts about objects in our world domain. E.g., Guitars
contains strings, trumpets are brass instruments.
 Events: Events are the actions which occur in our world.
 Performance: It describe behavior which involves knowledge about
how to do things.
 Meta-knowledge: It is knowledge about what we know.
 Facts: Facts are the truths about the real world and what we represent.
 Knowledge-Base: The knowledge base is the most important part of
the knowledge-based agents. It's abbreviated as KB. The Sentences are
grouped together in the Knowledgebase (Here, sentences are used as a
technical term and not identical with the English language).
 Knowledge: Knowledge is the awareness or familiarity of facts, data,
and circumstances gained through experiences. The types of
knowledge in artificial intelligence are listed below.
Types of knowledge
Following are the various types of knowledge
1. Declarative Knowledge:
Declarative knowledge is the ability to understand something.
It contains ideas, facts, and objects.
It's also known as descriptive knowledge, and it's communicated using
declarative statements.
It is less complicated than procedural programming.
2. Procedural Knowledge
It's sometimes referred to as "imperative knowledge."
Procedure knowledge is a form of knowledge that entails knowing how to do
something.
It can be used to complete any assignment.
It has rules, plans, procedures, and agendas, among other things.
The use of procedural knowledge is contingent on the job at hand.
3. Meta-knowledge:
Knowledge about the other types of knowledge is called Meta-knowledge.
4. Heuristic knowledge:
Heuristic knowledge is the sum of the knowledge of a group of specialists in a
certain field or subject.
Heuristic knowledge refers to rules of thumb that are based on prior
experiences, awareness of methodologies, and are likely to work but not
guaranteed.
5. Structural knowledge:
Basic problem-solving knowledge is structural knowledge.
It describes the connections between distinct concepts such as kind, part of,
and grouping.
It is a term that describes the relationship between two or more concepts or
objects.
The relation between knowledge and intelligence
Real-world knowledge is essential for intelligence, and artificial intelligence
is no exception. When it comes to exhibiting intelligent behaviour in AI
entities, knowledge is crucial. Only when an agent has some knowledge or
expertise with a given input can he act appropriately on it.
Consider what you would do if you encountered someone who spoke to you in
a language you did not understand. The same can be said for the agents'
intelligent behaviour.
One decision maker, as shown in the diagram below, acts by detecting the
environment and applying knowledge. However, if the knowledge component
is missing, it will be unable to demonstrate intelligent behaviour.
AI knowledge cycle
An Artificial intelligence system has the following components for displaying
intelligent behavior:
Perception
Learning
Knowledge Representation and Reasoning
Planning
Execution
The diagram above depicts how an AI system interacts with the real
environment and what components assist it in displaying intelligence.
Perception is a component of an AI system that allows it to gather information
from its surroundings. It can be in the form of visual, aural, or other sensory
input. The learning component is in charge of gaining knowledge from the
data collected by Perception comportment. The main components of the entire
cycle are knowledge representation and reasoning. These two elements have a
role in demonstrating intelligence in machine-like humans. These two
components are independent of one another, but they are also linked. Analysis
of knowledge representation and reasoning is required for planning and
implementation.
Approaches to knowledge representation:
There are mainly four approaches to knowledge representation, which are
givenbelow:
1. Simple relational knowledge:
It is the most basic technique of storing facts that use the relational method,
with each fact about a group of objects laid out in columns in a logical order.
This method of knowledge representation is often used in database systems to
express the relationships between various things.
This method leaves minimal room for inference.
Example: The following is the simple relational knowledge representation.

Player Weight Age

Player1 65 23

Player2 58 18

Player3 75 24
2. Inheritable knowledge:
All data must be kept in a hierarchy of classes in the inheritable knowledge
approach.
All classes should be organised in a hierarchical or generic fashion.
We use the inheritance property in this method.
Other members of a class pass on their values to elements.
The instance relation is a type of inheritable knowledge that illustrates a
relationship between an instance and a class.
Each individual frame might indicate a set of traits as well as their value.
Objects and values are represented in Boxed nodes in this technique.
Arrows are used to connect objects to their values.
Example:

3. Inferential knowledge:
Knowledge is represented in the form of formal logics in the inferential
knowledge approach.
More facts can be derived using this method.
It ensured that everything was in order.
Example: Let's suppose there are two statements:
a. Marcus is a man
b. All men are mortal
Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s
4. Procedural knowledge:
Small programmes and codes are used in the procedural knowledge approach
to specify how to do specific things and how to proceed.
One significant rule employed in this method is the If-Then rule.
We may employ several coding languages, such as LISP and Prolog, with this
information.
Using this method, we can readily represent heuristic or domain-specific
information.
However, this strategy does not require us to represent all scenarios.
Requirements for knowledge Representation system:
A good knowledge representation system must possess the following
properties.
1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.
2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to
produce new knowledge corresponding to existing structure.
3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most
productive directions by storing appropriate guides.
4. Acquisitional efficiency- The ability to acquire the new knowledge easily
using automatic methods.
ONTOLOGICAL ENGINEERING
Events, Time, Physical Objects, and Beliefs are examples of concepts that
appear in a variety of disciplines. Ontological engineering is a term used to
describe the process of representing abstract concepts.

Because of the habit of showing graphs with the general concepts at the top
and the more specialised concepts below them, the overall framework of
concepts is called an upper ontology, as seen in Figure.
Categories and Objects
The categorization of objects is an important aspect of knowledge
representation. Although much reasoning takes place at the level of categories,
much engagement with the environment takes place at the level of particular
things.
A shopper's goal, for example, would generally be to purchase a basketball
rather than a specific basketball, such as BB9. In first-order logic, there are
two ways to represent categories: predicates and objects. To put it another
way, we can use the predicate Basketball (b) or reify1 the category as an
object, Basketballs.
To state that b is a member of the category of basketballs, we may say
Member(b, Basketballs), which we would abbreviate as b Basketballs.
Basketballs is a subcategory of Balls, thus we say Subset(Basketballs, Balls),
abbreviated as Basketballs Balls. Through inheritance, categories help to
organise and simplify the information base. We can deduce that every apple is
edible if we state that all instances of the category Food are edible and that
Fruit is a subclass of Food and Apples is a subclass of Fruit. Individual apples
are said to inherit the quality of edibility from their membership in the Food
category. By connecting things to categories or quantifying over their
members, first-order logic makes it simple to state truths about categories.
Here are some instances of different types of facts:
• An object is a member of a category.
BB9 ∈ Basketballs
• A category is a subclass of another category. Basketballs ⊂ Balls
• All members of a category have some properties.
(x∈ Basketballs) ⇒ Spherical (x)
• Members of a category can be recognized by some properties. Orange(x) ∧
Round (x) ∧ Diameter(x)=9.5 ∧ x∈ Balls ⇒ x∈ Basketballs
• A category as a whole has some properties.
Dogs ∈ Domesticated Species
Because Dogs is both a category and a subcategory of Domesticated Species,
the latter must be a category of categories. Categories can also be formed by
establishing membership requirements that are both required and sufficient. A
bachelor, for example, is a single adult male:
x∈ Bachelors ⇔ Unmarried(x) ∧ x∈ Adults ∧ x∈ Males
Physical Composition
To declare that one thing is a part of another, we utilise the general PartOf
connection. Objects can be categorised into hierarchies, similar to the Subset
hierarchy:
PartOf (Bucharest, Romania)
PartOf (Romania, EasternEurope)
PartOf(EasternEurope, Europe)
PartOf (Europe, Earth)
The PartOf relation is transitive and reflexive; that is,
PartOf (x, y) ∧PartOf (y, z) ⇒PartOf (x, z)
PartOf (x, x)
Therefore, we can conclude PartOf (Bucharest, Earth).
For example, if the apples are Apple1, Apple2, and Apple3, then
BunchOf ({Apple1,Apple2,Apple3})
denotes the composite object with the three apples as parts (not elements). We
can define BunchOf in terms of the PartOf relation. Obviously, each element
of s is part of
BunchOf (s): ∀x x∈ s ⇒PartOf (x, BunchOf (s)) Furthermore, BunchOf (s) is
the smallest object satisfying this condition. In other words, BunchOf (s) must
be part of any object that has all the elements of s as parts:
∀y [∀x x∈ s ⇒PartOf (x, y)] ⇒PartOf (BunchOf (s), y)
Measurements
In both scientific and commonsense theories of the world, objects have height,
mass, cost, and so on. The values that we assign for these properties are called
measures. Length(L1)=Inches(1.5)=Centimeters(3.81)
Conversion between units is done by equating multiples of one unit to another:
Centimeters(2.54 ×d)=Inches(d)
Similar axioms can be written for pounds and kilograms, seconds and days,
and dollars and cents. Measures can be used to describe objects as follows:
Diameter (Basketball12)=Inches(9.5)
ListPrice(Basketball12)=$(19)
d∈ Days ⇒ Duration(d)=Hours(24)
Time Intervals
Event calculus opens us up to the possibility of talking about time, and time
intervals. We will consider two kinds of time intervals: moments and extended
intervals. The distinction is that only moments have zero duration:
Partition({Moments,ExtendedIntervals},Intervals)
i∈Moments⇔Duration(i)=Seconds(0)
The functions Begin and End pick out the earliest and latest moments in an
interval, and the function Time delivers the point on the time scale for a
moment.
The function Duration gives the difference between the end time and the start
time. Interval (i) ⇒Duration(i)=(Time(End(i)) − Time(Begin(i)))
Time(Begin(AD1900))=Seconds(0)
Time(Begin(AD2001))=Seconds(3187324800)
Time(End(AD2001))=Seconds(3218860800)
Duration(AD2001)=Seconds(31536000) Two intervals Meet if the end time of
the first equals the start time of the second. The complete set of interval
relations, as proposed by Allen (1983), is shown graphically in Figure 12.2
and logically below: Meet(i,j) ⇔ End(i)=Begin(j)
Before(i,j) ⇔ End(i) < Begin(j)
After (j,i) ⇔ Before(i, j)
During(i,j) ⇔ Begin(j) < Begin(i) < End(i) < End(j)
Overlap(i,j) ⇔ Begin(i) < Begin(j) < End(i) < End(j)
Begins(i,j) ⇔ Begin(i) = Begin(j)
Finishes(i,j) ⇔ End(i) = End(j)
Equals(i,j) ⇔ Begin(i) = Begin(j) ∧ End(i) = End(j)

EVENTS
Fluents and events are reified in event calculus. The ability to communicate
fluently At(Shankar, Berkeley) is an object that alludes to the fact that Shankar
is in Berkeley, but it doesn't say whether it's true or not. The predicate T, as in
T(At(Shankar, Berkeley), t), is used to affirm that a fluent is true at some point
in time. Instances of event categories are used to describe events. The event
E1 of Shankar flying from San Francisco to Washington, D.C. is described as
E1 ∈Flyings∧ Flyer (E1, Shankar ) ∧ Origin(E1, SF) ∧ Destination (E1,DC)
we can define an alternative three-argument version of the category of flying
events and say E1 ∈Flyings(Shankar, SF,DC) We then use Happens(E1, i) to
say that the event E1 took place over the time interval i, and we say the same
thing in functional form with Extent(E1)=i. We represent time intervals by a
(start, end) pair of times; that is, i = (t1, t2) is the time interval that starts at t1
and ends at t2. The complete set of predicates for one version of the event
calculus is T(f, t) Fluent f is true at time t Happens(e, i) Event e happens over
the time interval i Initiates(e, f, t) Event e causes fluent f to start to hold at
time t Terminates(e, f, t) Event e causes fluent f to cease to hold at time t
Clipped(f, i) Fluent f ceases to be true at some point during time interval i
Restored (f, i) Fluent f becomes true sometime during time interval i We
assume a distinguished event, Start, that describes the initial state by saying
which fluents are initiated or terminated at the start time. We define T by
saying that a fluent holds at a point in time if the fluent was initiated by an
event at some time in the past and was not made false (clipped) by an
intervening event. A fluent does not hold if it was terminated by an event and
not made true (restored) by another event. Formally, the axioms are:
Happens(e, (t1, t2)) ∧Initiates(e, f, t1) ∧¬Clipped(f, (t1, t)) ∧ t1 < t ⇒T(f,
t)Happens(e, (t1, t2)) ∧ Terminates(e, f, t1)∧¬Restored (f, (t1, t)) ∧ t1 < t ⇒
¬T(f, t)
where Clipped and Restored are defined by Clipped(f, (t1, t2)) ⇔∃ e, t, t3
Happens(e, (t, t3))∧ t1 ≤ t < t2 ∧ Terminates(e, f, t) Restored (f, (t1, t2)) ⇔∃ e,
t, t3 Happens(e, (t, t3)) ∧ t1 ≤ t < t2 ∧ Initiates(e, f, t)

MENTAL EVENTS AND MENTAL OBJECTS


We require a model of the mental objects (or knowledge base) in someone's
head, as well as the mental processes that change those mental things. It is not
necessary to have a detailed model. We don't need to know how many
milliseconds it will take for a specific agent to make a deduction. We'll be
content only to be able to deduce that mother is aware of whether she is sitting
or not. We begin with propositional attitudes toward mental objects, such as
Believes, Knows, Wants, Intends, and Informs, which an agent can possess.
The issue is that these attitudes behave differently than "ordinary" predicates.
For example, suppose we try to assert that Lois knows that Superman can fly:
Knows (Lois, CanFly(Superman)) One minor issue with this is that we
normally think of CanFly(Superman) as a sentence, but here it appears as a
term. That issue can be patched up just be reifying CanFly(Superman); making
it a fluent. A more serious problem isthat, if it is true that Superman is Clark
Kent, then we must conclude that Lois knows that Clark can fly: (Superman =
Clark) ∧Knows(Lois, CanFly(Superman)) |= Knows(Lois, CanFly (Clark))
Modal logic is designed to address this problem. Regular logic is concerned
with a single modality, the modality of truth, allowing us to express “P is
true.” Modal logic includes special modal operators that take sentences (rather
than terms) as arguments. For example, “KAP is the notation for "A knows P,"
where K is the modal operator for knowledge. It takes two arguments: a
statement and an agent (represented as the subscript). Modal logic has the
same syntax as first-order logic, with the exception that modal operators can
also be used to build sentences. A model in first-order logic has a set of
objects as well as an interpretation that translates each name to the correct
item, relation, or function. We want to be able to consider both the possibility
that Superman's secret identity is Clark and the chance that it isn't in modal
logic. As a result, we'll need a more complex model, one that includes a
collection of alternative worlds rather than a single real world. The worlds are
connected in a graph by accessibility relations, one relation for each modal
operator. We say that world w1 is accessible from world w0 with respect to
the modal operator KA if everything in w1 is consistent with what A knows in
w0, and we write this as Acc(KA,w0,w1). In diagrams below we show
accessibility as an arrow between possible worlds. In general, a knowledge
atom KAP is true in world w if and only if P is true in every world accessible
from w. The truth of more complex sentences is derived by recursive
application of this rule and the normal rules of first-order logic. That means
that modal logic can be used to reason about nested knowledge sentences:
what one agent knows about another agent’s knowledge. For example, we can
say that, even though Lois doesn’t know whether Superman’s secret identity is
Clark Kent, she does know that Clark knows: KLois [KClark
Identity(Superman, Clark )
∨KClark¬Identity(Superman, Clark )] Figure below shows some possible
worlds for this domain, with accessibility relations for Lois and Superman

In the TOP-LEFT diagram, it is common knowledge that Superman knows his


own identity, and neither he nor Lois has seen the weather report. So in w0 the
worlds w0 and w2 are accessible to Superman; maybe rain is predicted, maybe
not. For Lois all four worlds are accessible from each other; she doesn’t know
anything about the report or if Clark is Superman. But she does know that
Superman knows whether he is Clark, because in every world that is
accessible to Lois, either Superman knows I, or he knows ¬I. Lois does not
know which is the case, but either way she knows Superman knows. In the
TOP-RIGHT diagram it is common knowledge that Lois has seen the weather
report. So in w4 she knows rain is predicted and in w6 she knows rain is not
predicted. Superman does not know the report, but he knows that Lois knows,
because in every world that is accessible to him, either she knows R or she
knows ¬ R. In the BOTTOM diagram we represent the scenario where it is
common knowledge that Superman knows his identity, and Lois might or
might not have seen the weather report. We represent this by combining the
two top scenarios, and adding arrows to show that Superman does not know
which scenario actually holds. Lois does know, so we don’t need to add any
arrows for her. In w0 Superman still knows I but not R, and now he does not
know whether Lois knows R. From what Superman knows, he might be in w0
or w2, in which case Lois does not know whether R is true, or he could be in
w4, in which case she knows R, or w6, in which case she knows ¬R.
REASONING SYSTEMS FOR CATEGORIES
This section discusses systems that are specifically built for categorical
organisation and reasoning. There are two families of systems: semantic
networks and description logics. Semantic networks provide graphical aids for
visualising a knowledge base and efficient algorithms for inferring properties
of an object based on its category membership, while description logics
provide a formal language for constructing and combining category definitions
and efficient algorithms for deciding subset and superset relationships between
categories.
SEMANTIC NETWORKS
Semantic networks come in a variety of shapes and sizes, but they may all
represent individual objects, categories of objects, and relationships between
things. A typical graphical notation shows object or category names in ovals
or boxes, with labelled links connecting them.
For example, Figure below has a Member Of link between Mary and Female
Persons, corresponding to the logical assertion Mary ∈FemalePersons ;
similarly, the SisterOf link between Mary and John corresponds to the
assertion SisterOf (Mary, John). We can connect categories using SubsetOf
links, and so on. We know that persons have female persons as mothers, so
can we draw a HasMother link from Persons to FemalePersons? The answer is
no, because HasMother is a relation between a person and his or her mother,
and categories do not have mothers. For this reason, we have used a special
notation—the double-boxed link—in Figure 12.5. This link asserts that ∀x x∈
Persons ⇒ [∀ y HasMother (x, y) ⇒ y ∈FemalePersons ] We might also want
to assert that persons have two legs—that is, ∀x x∈ Persons ⇒ Legs(x, 2) The
semantic network notation makes it convenient to perform inheritance
reasoning. For example, by virtue of being a person, Mary inherits the
property of having two legs. Thus, to find out how many legs Mary has, the
inheritance algorithm followsthe MemberOf link from Mary to the category
she belongs to, and then follows SubsetOf links up the hierarchy until it finds
a category for which there is a boxed Legs link—in this case, the Persons
category.
Multiple inheritance complicates inheritance when an object can belong to
more than one category or when a category might be a subset of more than one
other category. The fact that links between bubbles indicate only binary
relations is a disadvantage of semantic network notation compared to first-
order logic. In a semantic network, for example, the sentence Fly(Shankar,
NewYork, NewDelhi, Yesterday) cannot be claimed explicitly. Nonetheless,
the impact of n-ary assertions can be obtained by reifying the proposition as an
event belonging to a suitable event category.
The semantic network structure for this event is depicted in the diagram
below. It's worth noting that the constraint on binary relations necessitates the
formation of a large ontology of reified concepts. The ability of semantic
networks to represent is one of its most essential features.

The capacity of semantic networks to represent default values for categories is


one of its most essential features. When looking closely at Figure 3.6, one can
see that John only has one leg, despite the fact that he is a human, and all
people have two legs.
In a strictly logical KB, this would be a contradiction, but in a semantic
network, the assertion that all persons have two legs has only
default status; that is, a person is assumed to have two legs unless this is
contradicted by more specific information
Criminal (West). The resolution proof is shown inWe also include the
negated goal below.

Take note of the structure: a single "spine" starts with the goal clause and
resolves against knowledge base clauses until the empty clause is formed. This
is typical of Horn clause knowledge bases' resolution. In the backward-
chaining algorithm of Figure, the clauses along the main spine correspond to
the sequential values of the objectives variable. This is because, in backward
chaining, we always opt to resolve with a clause whose positive literal unified
with the left most literal of the "current" clause on the spine. Backward
chaining is thus only a special example of resolution with a specific control
mechanism for determining which resolution should be performed next.

You might also like