0% found this document useful (0 votes)
6 views105 pages

Unit 3 Contents

The document discusses First-Order Logic (FOL) in artificial intelligence, highlighting its ability to express complex statements beyond the limitations of propositional logic. It covers the syntax, semantics, and components of FOL, including quantifiers, free and bound variables, and applications of Prolog, a programming language based on logic. Additionally, it explains forward and backward chaining as inference techniques used in AI systems for reasoning and knowledge representation.

Uploaded by

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

Unit 3 Contents

The document discusses First-Order Logic (FOL) in artificial intelligence, highlighting its ability to express complex statements beyond the limitations of propositional logic. It covers the syntax, semantics, and components of FOL, including quantifiers, free and bound variables, and applications of Prolog, a programming language based on logic. Additionally, it explains forward and backward chaining as inference techniques used in AI systems for reasoning and knowledge representation.

Uploaded by

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

First-Order Logic in Artificial

intelligence
 We have learned how to represent statements using
propositional logic in the subject of propositional logic.
Unfortunately, we are limited to representing the facts in
propositional reasoning, which can either be true or false. To
express complex sentences or statements in natural English,
PL is insufficient. The expressive ability of propositional logic
is extremely constrained. Take the following sentence as an
example, which we are unable to express using PL logic.
 "Some humans are intelligent", or
 "Sachin likes cricket."
 To represent the above statements, PL logic is not sufficient,
so we required some more powerful logic, such as first-order
logic.
First-Order logic:
 Another method of information representation in artificial
intelligence is first-order logic. A development of propositional
logic, it.
 FOL is expressive enough to effectively describe the natural
language statements.
 Predicate logic or First-order predicate logic are other names for
first-order logic. First-order logic is a potent language that
expresses the relationship between the objects as well as how
knowledge about the objects can be developed more easily.
 First-order logic (like natural language) does not only assume that
the world contains facts like propositional logic but also assumes
the following things in the world:
◦ Objects: A, B, people, numbers, colors, wars, theories, squares, pits,
wumpus, ......
◦ Relations: It can be unary relation such as: red, round, is adjacent, or
n-any relation such as: the sister of, brother of, has color, comes
between
◦ Function: Father of, best friend, third inning of, end of, ......
 As a natural language, first-order logic also has two main
parts:
◦ Syntax
◦ Semantics
Syntax of First-Order logic:
 Which group of symbols constitutes a logical statement in
first-order logic depends on the FOL syntax. Symbols are the
fundamental syntactic building blocks of first-order
reasoning. In FOL, we express ideas using short-hand
notation.
 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 sentences of first-order
logic. These sentences are formed from a predicate symbol
followed by a parenthesis with a sequence 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:
 Complex sentences are made by combining atomic sentences
using connectives.
First-order logic statements can be divided into two parts:
 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 statement: "x is an integer.", it consists of two
parts, the first part x is the subject of the statement and
second part "is an integer," is known as 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.
 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 ∀, which
resembles an inverted A.
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.
 Let a variable x which refers to a cat so all x can be
represented in UOD as below:
∀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 ∃, 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 (∧).
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 a boy who is
intelligent.
Points to remember:
 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.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be
represented as follows.
∀x bird(x) →fly(x).
 2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where
x=man, and y= parent.
Since there is every man so will use ∀, and it will be
represented as follows:
∀x man(x) → respects (x, parent).
 3. Some boys play cricket.
In this question, the predicate is "play(x, y)," where x= boys,
and y= game. Since there are some boys so we will use ∃,
and it will be represented as:
∃x boys(x) → play(x, cricket).
 4. Not all students like both Mathematics and Science.
In this question, the predicate is "like(x, y)," where x=
student, and y= subject.
Since there are not all students, so we will use ∀ with
negation, so following representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x,
Science)].
 5. Only one student failed in Mathematics.
In this question, the predicate is "failed(x, y)," where x=
student, and y= subject.
Since there is only one student who failed in
Mathematics, so we will use following representation
for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀
(y) [¬(x==y) ∧ student(y) → ¬failed (x, Mathematics)].
Free and Bound Variables:
The quantifiers interact with variables which appear in a
suitable way. There are two types of variables in First-order
logic which are given below:

Free Variable: A variable is said to be a free variable in a


formula if it occurs outside the scope of the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.

Bound Variable: A variable is said to be a bound variable in a


formula if it occurs within the scope of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound variables.
What is Prolog

 Prolog stands for programming in logic. Prolog is the most commonly used
programming language in the logic programming paradigm.
 Because Prolog is a declarative language, programmes written in it don't
compute how to solve problems; instead, they are composed of data
founded on facts and rules (logical relationships). The relationships that
apply to the particular application are described by a logical relationship.
 Instead of using a program, the user poses a question to get the answer.
The run-time system searches through the database of facts and rules to
find the answer when a user poses a question.
 Marseille Prolog, which is built on Colmerauer's work, was the original
Prolog. Prolog was a prominent example of a fourth-generation computer
language. The declarative computing paradigm is supported by it.
 An announcement of a fifth-generation Japanese computer project was
made in 1981. Following that, Prolog was accepted as a development
language. The programme for this lesson was created using Edinburgh
Prolog's "Standard" syntax. The other category of prologues that are
decedents of Marseille Prolog is PrologII family prologues.
 Prolog features include a pattern-matching facility, a mathematical
variable, and interchangeable input and output. They also operate like
uniform data structures and have a backtracking strategy for searching for
proofs.
 There will be several ways to determine the solution. The run-time system
will be asked to discover an alternative remedy in such a situation. Use the
backtracking strategy to come up with an alternative answer. A weakly
typed language with dynamic type checking and static scope constraints is
Prolog.
 Because Prolog is a declarative language, we can define the issue we want
to solve rather than the method for doing so.
 Prolog is used in some fields, such as databases, NLP, and AI, but it is largely
worthless in others, such as numerical algorithms and instance graphics.
 Prolog is employed in projects involving artificial intelligence. Automated
reasoning systems, user interfaces that use natural language, and expert
systems are some examples of artificial intelligence uses. A database of
information and an interface engine make up the expert system. An interface
mechanism is offered by the prologue run time system.
 There are no literal numbers in an environment for fundamental logic
programming. Variables are denoted by an identifier with capital characters
and other identifiers. Data values are indicated by identifiers that begin with
lowercase characters. Typeless components make up the core of Prolog. The
majority of prologue versions now support integer values, characters, and
operations. The tuples and collections are described in the Prolog Mechanism.
 Prolog and functional computer languages share some characteristics with
Hugs. Relation term is used in a logic programme. A series of function
definitions are used to create a functional computer language. Recursive
definitions are crucial to logical computing and functional programming.
Applications of Prolog
 The applications of prolog are as follows:
 Specification Language
 Robot Planning
 Natural language understanding
 Machine Learning
 Problem Solving
 Intelligent Database retrieval
 Expert System
 Automated Reasoning
Starting Prolog
 Prolog system is straightforward. From one person to other person, the
precise details of Prolog will vary. Prolog will produce a number of lines of
headings in the starting, which is followed by a line. It contains just
 ?-
 The above symbol shows the system prompt. The prompt is used to show
that the Prolog system is ready to specify one or more goals of sequence
to the user. Using a full stop, we can terminate the sequence of goals.
For example:
?- write('Welcome to VIT'),nl,write('First class of Prolog'),nl.
nl indicates 'start a new line'. When we press 'return' key, the above
line will show the effect like this:
Welcome to VIT
First class of Prolog
yes
?- prompt shows the sequence of goal which is entered by the user.
The user will not type the prompt. Prolog system will automatically
generate this prompt. It means that it is ready to receive a
sequence of goals.
The above example shows a sequence of goals entered by the user
like this:
write('Welcome to VIT'), write('First class of Prolog'), nl(twice).
Consider the following sequence of goals:
write('Welcome to VIT'),nl,write('First class of Prolog'),nl.
The above sequence of goals has to succeed in order to be
succeeded.
 write('Welcome to VIT')
On the screen of the user, Welcome to Javatpoint has to be
displayed
 nl
On the screen of the user, a new line has to be output
 write('First class of Prolog')
On the screen of the user, Example of Prolog has to be displayed
 nl
On the screen of the user, a new line has to be output
 All these goals will simply achieve by the Prolog system by
outputting the line of text to the screen of the user. To show that
the goals have succeeded, we will output yes.
 The Prolog system predefined the meanings of nl and write. Write
and nl are called as built-in predicates.
 Halt and statistics are the two other built-in predicates. In almost
all Prolog versions, these predicates are provided as standard.
 ?- halt.
The above command is used to terminate the Prolog system.
 ?- statistics.
This command will cause the Prolog system statistics. This statistics
feature is mainly used to experienced user. In statistics, the
following things will generate:
The above output ends with Yes. Yes, specify that the goal has
succeeded, as halt, statistics, and many other built-in predicates
always do. When they evaluate, their values produce, which lies in the
side-effects.
'Query' is a sequence of one or more goals. These goals are entered
by the user at the prompt.
Forward Chaining and backward
chaining in AI
 One of the key topics in artificial intelligence is forward and
backward chaining, but before we can comprehend it, it's
important to know where the terms came from.
 Inference engine:
 The artificial intelligence system's reasoning engine is the part that
applies logical principles to the knowledge base to draw
conclusions about new information from established facts. The
expert system included the first reasoning engine. There are two
typical ways that an inference engine operates:
 Forward chaining
 Backward chaining
Horn Clause and Definite clause:
 Horn clause and definite clause are the forms of sentences, which enables
knowledge base to use a more restricted and efficient inference algorithm.
Logical inference algorithms use forward and backward chaining
approaches, which require KB in the form of the first-order definite
clause.
 Definite clause: A clause which is a disjunction of literals with exactly one
positive literal is known as a definite clause or strict horn clause.
 Horn clause: A clause which is a disjunction of literals with at most one
positive literal is known as horn clause. Hence all the definite clauses are
horn clauses.
Example: (¬ p V ¬ q V k). It has only one positive literal k.
 It is equivalent to p ∧ q → k.
A. Forward Chaining

 When using an inference engine, forward chaining is also


referred to as a forward argument or forward reasoning
technique.
 Using inference rules (Modus Ponens) in the forward path,
forward chaining is a type of reasoning that starts with
atomic sentences in the knowledge base and continues until
the desired outcome is attained.
 Starting with known facts, the Forward-chaining algorithm
invokes all rules whose premises are fulfilled and adds their
conclusion to the known facts. Up until the issue is resolved,
this procedure is repeated.
Properties of Forward-Chaining:
 As it advances from bottom to top, it is a down-up strategy.
 By starting from the initial state and working towards the
goal state, it is a method for drawing a conclusion based on
information that is already known.
 The forward-chaining strategy is also referred to as data-
driven because we use the data at our disposal to get there.
 The forward-chaining method is frequently employed in
expert systems like CLIPS, business rule systems, and
production rule systems.
 Think about the following well-known illustration, which we
will employ in both strategies:
 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.
B. Backward Chaining:
 When using an inference engine, backward-chaining is also referred to as a
backward argument or backward reasoning technique. An algorithm
known as a "backward chaining" algorithm works backward from the goal,
chaining through rules to discover known facts that support the goal.
 Properties of backward chaining:
 It is known as a top-down approach.
 Backward-chaining is based on modus ponens inference rule.
 In backward chaining, the goal is broken into sub-goal or sub-goals to
prove the facts true.
 It is called a goal-driven approach, as a list of goals decides which rules are
selected and used.
 Backward -chaining algorithm is used in game theory, automated theorem
proving tools, inference engines, proof assistants, and various AI
applications.
 The backward-chaining method mostly used a depth-first search strategy
for proof.
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:
 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

S.No. Forward Chaining Backward Chaining


1. Forward chaining starts from Backward chaining starts from
known facts and applies inference the goal and works backward
rule to extract more data unit it through inference rules to find
reaches to the goal. the required facts that support
the goal.
2. It is a bottom-up approach It is a top-down approach

3. Forward chaining is known as data- Backward chaining is known as


driven inference technique as we goal-driven technique as we
reach to the goal using the start from the goal and divide
available data. into sub-goal to extract the facts.
4. Forward chaining reasoning applies Backward chaining reasoning
a breadth-first search strategy. applies a depth-first search
strategy.
S.No. Forward Chaining Backward Chaining
5. Forward chaining tests for all the Backward chaining only tests for few
available rules required rules.
6. Forward chaining is suitable for Backward chaining is suitable for
the planning, monitoring, diagnostic, prescription, and
control, and interpretation debugging application.
application.
7. Forward chaining can generate Backward chaining generates a finite
an infinite number of possible number of possible conclusions.
conclusions.
8. It operates in the forward It operates in the backward direction.
direction.
9. Forward chaining is aimed for Backward chaining is only aimed for
any conclusion. the required data.
Resolution in FOL
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.
 Clause: Disjunction of literals (an atomic sentence) is called
a clause. It is also known as a unit clause.
 Conjunctive Normal Form: A sentence represented as a
conjunction of clauses is said to be conjunctive normal
form or CNF.
 The resolution inference rule:
 The resolution rule for first-order logic is simply a lifted version of the
propositional rule. Resolution can resolve two clauses if they contain
complementary literals, which are assumed to be standardized apart so
that they share no variables.

 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
◦ ∀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).
 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).
 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.
◦ ¬ food(x) V likes(John, x)
◦ food(Apple)
◦ food(vegetables)
◦ ¬ eats(y, z) V killed(y) V food(z)
◦ eats (Anil, Peanuts)
◦ alive(Anil)
◦ ¬ eats(Anil, w) V eats(Harry, w)
◦ killed(g) V alive(g)
◦ ¬ alive(k) V ¬ killed(k)
◦ likes(John, Peanuts).
 Note: Statements "food(Apple) Λ food(vegetables)" and "eats (Anil,
Peanuts) Λ alive(Anil)" can be written in two separate statements.
 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.
What is knowledge representation?
 Humans are best at understanding, reasoning, and interpreting
knowledge. Human knows things, which is knowledge and as per their
knowledge they perform various actions in the real world. But how
machines do all these things comes under knowledge representation and
reasoning. Hence we can describe Knowledge representation as following:
 Knowledge representation and reasoning (KR, KRR) is the part of Artificial
intelligence which concerned with AI agents thinking and how thinking
contributes to intelligent behavior of agents.
 It is responsible for representing information about the real world so that
a computer can understand and can utilize this knowledge to solve the
complex real world problems such as diagnosis a medical condition or
communicating with humans in natural language.
 It is also a way which describes how we can represent knowledge in
artificial intelligence. Knowledge representation is not just storing data
into some database, but it also enables an intelligent machine to learn
from that knowledge and experiences so that it can behave intelligently
like a human.
What to Represent:
 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 central component of the knowledge-based agents
is the knowledge base. It is represented as KB. The Knowledgebase is a
group of the Sentences (Here, sentences are used as a technical term and
not identical with the English language).
 Knowledge: Knowledge is awareness or familiarity gained by experiences
of facts, data, and situations. Following are the types of knowledge in
artificial intelligence:
Types of knowledge
 1. Declarative Knowledge:
 Declarative knowledge is to know about something.
 It includes concepts, facts, and objects.
 It is also called descriptive knowledge and expressed in
declarativesentences.
 It is simpler than procedural language.
 2. Procedural Knowledge
 It is also known as imperative knowledge.
 Procedural knowledge is a type of knowledge which is responsible for
knowing how to do something.
 It can be directly applied to any task.
 It includes rules, strategies, procedures, agendas, etc.
 Procedural knowledge depends on the task on which it can be applied.

 3. Meta-knowledge:
 Knowledge about the other types of knowledge is called Meta-knowledge.
 4. Heuristic knowledge:
 Heuristic knowledge is representing knowledge of some experts in a filed
or subject.
 Heuristic knowledge is rules of thumb based on previous experiences,
awareness of approaches, and which are good to work but not
guaranteed.
 5. Structural knowledge:
 Structural knowledge is basic knowledge to problem-solving.
 It describes relationships between various concepts such as kind of, part
of, and grouping of something.
 It describes the relationship that exists between concepts or objects.
The relation between knowledge
and intelligence:
 Knowledge of real-worlds plays a vital role in intelligence and
same for creating artificial intelligence. Knowledge plays an
important role in demonstrating intelligent behavior in AI
agents. An agent is only able to accurately act on some input
when he has some knowledge or experience about that
input.
 Let's suppose if you met some person who is speaking in a
language which you don't know, then how you will able to
act on that. The same thing applies to the intelligent
behavior of the agents.
 As we can see in below diagram, there is one decision maker
which act by sensing the environment and using knowledge.
But if the knowledge part will not present then, it cannot
display intelligent behavior.
AI knowledge cycle:

 An Artificial intelligence system has the following components for


displaying intelligent behavior:
 Perception
 Learning
 Knowledge Representation and Reasoning
 Planning
 Execution
 The above diagram is showing how an AI system can interact with
the real world and what components help it to show intelligence.
AI system has Perception component by which it retrieves
information from its environment. It can be visual, audio or
another form of sensory input. The learning component is
responsible for learning from data captured by Perception
comportment. In the complete cycle, the main components are
knowledge representation and Reasoning. These two components
are involved in showing the intelligence in machine-like humans.
These two components are independent with each other but also
coupled together. The planning and execution depend on analysis
of Knowledge representation and reasoning.
Approaches to knowledge
representation:
 There are mainly four approaches to knowledge representation, which are
givenbelow:
 1. Simple relational knowledge:
 It is the simplest way of storing facts which uses the relational method,
and each fact about a set of the object is set out systematically in columns.
 This approach of knowledge representation is famous in database systems
where the relationship between different entities is represented.
 This approach has little opportunity 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:
 In the inheritable knowledge approach, all data must be stored into a
hierarchy of classes.
 All classes should be arranged in a generalized form or a hierarchal
manner.
 In this approach, we apply inheritance property.
 Elements inherit values from other members of a class.
 This approach contains inheritable knowledge which shows a relation
between instance and class, and it is called instance relation.
 Every individual frame can represent the collection of attributes and its
value.
 In this approach, objects and values are represented in Boxed nodes.
 We use Arrows which point from objects to their values.
 Example:
3. Inferential knowledge:
 Inferential knowledge approach represents knowledge in the form
of formal logics.
 This approach can be used to derive more facts.
 It guaranteed correctness.
 Example: Let's suppose there are two statements:
◦ Marcus is a man
◦ All men are mortal
Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s
 4. Procedural knowledge:
 Procedural knowledge approach uses small programs and codes which
describes how to do specific things, and how to proceed.
 In this approach, one important rule is used which is If-Then rule.
 In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
 We can easily represent heuristic or domain-specific knowledge using this
approach.
 But it is not necessary that we can represent all cases in this approach.
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.
Techniques of knowledge
representation
 There are mainly four ways of knowledge representation which are
given as follows:
 1. Logical Representation
 Logical representation is a language with some concrete rules which deals
with propositions and has no ambiguity in representation. Logical
representation means drawing a conclusion based on various conditions.
This representation lays down some important communication rules. It
consists of precisely defined syntax and semantics which supports the
sound inference. Each sentence can be translated into logics using syntax
and semantics.
 Syntax:
 Syntaxes are the rules which decide how we can construct legal sentences
in the logic.
 It determines which symbol we can use in knowledge representation.
 How to write those symbols.
 Semantics:
 Semantics are the rules by which we can interpret the sentence in
the logic.
 Semantic also involves assigning a meaning to each sentence.
 Logical representation can be categorised into mainly two logics:
 Propositional Logics
 Predicate logics
 Advantages of logical representation:
 Logical representation enables us to do logical reasoning.
 Logical representation is the basis for the programming languages.
 Disadvantages of logical Representation:
 Logical representations have some restrictions and are challenging to work
with.
 Logical representation technique may not be very natural, and inference
may not be so efficient.
 Note: Do not be confused with logical representation and logical reasoning
as logical representation is a representation language and reasoning is a
process of thinking logically.
 2. Semantic Network Representation
 Semantic networks are alternative of predicate logic for knowledge
representation. In Semantic networks, we can represent our knowledge in
the form of graphical networks. This network consists of nodes
representing objects and arcs which describe the relationship between
those objects. Semantic networks can categorize the object in different
forms and can also link those objects. Semantic networks are easy to
understand and can be easily extended.
 This representation consist of mainly two types of relations:
 IS-A relation (Inheritance)
 Kind-of-relation
 Example: Following are some statements which we need to represent in
the form of nodes and arcs.
 Statements:
 Jerry is a cat.
 Jerry is a mammal
 Jerry is owned by Priya.
 Jerry is brown colored.
 All Mammals are animal.
 Drawbacks in Semantic representation:
 Semantic networks take more computational time at runtime as we need
to traverse the complete network tree to answer some questions. It might
be possible in the worst case scenario that after traversing the entire tree,
we find that the solution does not exist in this network.
 Semantic networks try to model human-like memory (Which has 1015
neurons and links) to store the information, but in practice, it is not
possible to build such a vast semantic network.
 These types of representations are inadequate as they do not have any
equivalent quantifier, e.g., for all, for some, none, etc.
 Semantic networks do not have any standard definition for the link names.
 These networks are not intelligent and depend on the creator of the
system.
 Advantages of Semantic network:
 Semantic networks are a natural representation of knowledge.
 Semantic networks convey meaning in a transparent manner.
 These networks are simple and easily understandable.
 3. Frame Representation
 A frame is a record like structure which consists of a collection of
attributes and its values to describe an entity in the world. Frames are the
AI data structure which divides knowledge into substructures by
representing stereotypes situations. It consists of a collection of slots and
slot values. These slots may be of any type and sizes. Slots have names and
values which are called facets.
 Facets: The various aspects of a slot is known as Facets. Facets are features
of frames which enable us to put constraints on the frames. Example: IF-
NEEDED facts are called when data of any particular slot is needed. A
frame may consist of any number of slots, and a slot may include any
number of facets and facets may have any number of values. A frame is
also known as slot-filter knowledge representation in artificial
intelligence.
 Frames are derived from semantic networks and later evolved into our
modern-day classes and objects. A single frame is not much useful. Frames
system consist of a collection of frames which are connected. In the frame,
knowledge about an object or event can be stored together in the
knowledge base. The frame is a type of technology which is widely used in
various applications including Natural language processing and machine
visions.
 Example: 1
 Let's take an example of a frame for a book
Slots Filters
Title Artificial Intelligence
Genre Computer Science
Author Peter Norvig
Edition Third Edition
Year 1996
Page 1152
Advantages of frame representation:
 The frame knowledge representation makes the programming easier by
grouping the related data.
 The frame representation is comparably flexible and used by many
applications in AI.
 It is very easy to add slots for new attribute and relations.
 It is easy to include default data and to search for missing values.
 Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
 In frame system inference mechanism is not be easily processed.
 Inference mechanism cannot be smoothly proceeded by frame
representation.
 Frame representation has a much generalized approach.
 4. Production Rules
 Production rules system consist of (condition, action) pairs which mean,
"If condition then action". It has mainly three parts:
 The set of production rules
 Working Memory
 The recognize-act-cycle
 In production rules agent checks for the condition and if the condition
exists then production rule fires and corresponding action is carried out.
The condition part of the rule determines which rule may be applied to a
problem. And the action part carries out the associated problem-solving
steps. This complete process is called a recognize-act cycle.
 The working memory contains the description of the current state of
problems-solving and rule can write knowledge to the working memory.
This knowledge match and may fire other rules.
 If there is a new situation (state) generates, then multiple production rules
will be fired together, this is called conflict set. In this situation, the agent
needs to select a rule from these sets, and it is called a conflict resolution.
 Example:
 IF (at bus stop AND bus arrives) THEN action (get into the bus)
 IF (on the bus AND paid AND empty seat) THEN action (sit down).
 IF (on bus AND unpaid) THEN action (pay charges).
 IF (bus arrives at destination) THEN action (get down from the bus).
Advantages of Production rule:
 The production rules are expressed in natural language.
 The production rules are highly modular, so we can easily remove, add or
modify an individual rule.
Disadvantages of Production rule:
 Production rule system does not exhibit any learning capabilities, as it
does not store the result of the problem for the future uses.
 During the execution of the program, many rules may be active hence
rule-based production systems are inefficient.
Ontological Engineering

 A machine sounds like an empty box unless it is encoded


with some features or information. Therefore, to make it a
valuable machine, it is required to put the necessary
knowledge in it. So that it could understand it and is able to
take the right decisions.
 Ontologies are formal definitions of vocabularies that allow
us to define difficult or complex structures and new
relationships between vocabulary terms and members of
classes that we define. Ontologies generally describe specific
domains such as scientific research areas.
Example:
Ontology depicting Movie:-
Components:
 Individuals –
Individuals are also known as instances of objects or concepts.It may or
may not be present in an ontology.It represents the atomic level of an
ontology.For example, in the above ontology of movie, individuals can be a
film (Titanic), a director (James Cameron), an actor (Leonardo DiCaprio).
 Classes –
Sets of collections of various objects are termed as classes.For example, in
the above ontology representing movie, movie genre (e.g. Thriller, Drama),
types of person (Actor or Director) are classes.
 Attributes –
Properties that objects may possess.For example, a movie is described by
the set of ‘parts’ it contains like Script, Director, Actors.
 Relations –
Ways in which concepts are related to one another.For example, as shown
above in the diagram a movie has to have a script and actors in it.
Reasoning in Artificial intelligence

 Reasoning:
 The reasoning is the mental process of deriving logical conclusion and
making predictions from available knowledge, facts, and beliefs. Or we can
say, "Reasoning is a way to infer facts from existing data." It is a general
process of thinking rationally, to find valid conclusions.
 In artificial intelligence, the reasoning is essential so that the machine can
also think rationally as a human brain, and can perform like a human.
 Types of Reasoning
 In artificial intelligence, reasoning can be divided into the following
categories:
 Play Video
 Deductive reasoning
 Inductive reasoning
 Abductive reasoning
 Common Sense Reasoning
 Monotonic Reasoning
 Non-monotonic Reasoning
 Note: Inductive and deductive reasoning are the forms of
propositional logic.
 1. Deductive reasoning:
 Deductive reasoning is deducing new information from logically
related known information. It is the form of valid reasoning, which
means the argument's conclusion must be true when the premises
are true.
 Deductive reasoning is a type of propositional logic in AI, and it
requires various rules and facts. It is sometimes referred to as top-
down reasoning, and contradictory to inductive reasoning.
 In deductive reasoning, the truth of the premises guarantees the
truth of the conclusion.
 Deductive reasoning mostly starts from the general premises to the
specific conclusion, which can be explained as below example.
 Example:
 Premise-1: All the human eats veggies
 Premise-2: Suresh is human.
 Conclusion: Suresh eats veggies.
 The general process of deductive reasoning is given below:
 2. Inductive Reasoning:
 Inductive reasoning is a form of reasoning to arrive at a conclusion
using limited sets of facts by the process of generalization. It starts
with the series of specific facts or data and reaches to a general
statement or conclusion.
 Inductive reasoning is a type of propositional logic, which is also
known as cause-effect reasoning or bottom-up reasoning.
 In inductive reasoning, we use historical data or various premises
to generate a generic rule, for which premises support the
conclusion.
 In inductive reasoning, premises provide probable supports to the
conclusion, so the truth of premises does not guarantee the truth
of the conclusion.
 Example:
 Premise: All of the pigeons we have seen in the zoo are white.
 Conclusion: Therefore, we can expect all the pigeons to be white.
 3. Abductive reasoning:
 Abductive reasoning is a form of logical reasoning which starts with
single or multiple observations then seeks to find the most likely
explanation or conclusion for the observation.
 Abductive reasoning is an extension of deductive reasoning, but in
abductive reasoning, the premises do not guarantee the
conclusion.
 Example:
 Implication: Cricket ground is wet if it is raining
 Axiom: Cricket ground is wet.
 Conclusion It is raining.
 4. Common Sense Reasoning
 Common sense reasoning is an informal form of reasoning, which
can be gained through experiences.
 Common Sense reasoning simulates the human ability to make
presumptions about events which occurs on every day.
 It relies on good judgment rather than exact logic and operates
on heuristic knowledge and heuristic rules.
 Example:
 One person can be at one place at a time.
 If I put my hand in a fire, then it will burn.
 The above two statements are the examples of common sense
reasoning which a human mind can easily understand and assume.
 5. Monotonic Reasoning:
 In monotonic reasoning, once the conclusion is taken, then it will remain the
same even if we add some other information to existing information in our
knowledge base. In monotonic reasoning, adding knowledge does not
decrease the set of prepositions that can be derived.
 To solve monotonic problems, we can derive the valid conclusion from the
available facts only, and it will not be affected by new facts.
 Monotonic reasoning is not useful for the real-time systems, as in real time,
facts get changed, so we cannot use monotonic reasoning.
 Monotonic reasoning is used in conventional reasoning systems, and a logic-
based system is monotonic.
 Any theorem proving is an example of monotonic reasoning.
 Example:
 Earth revolves around the Sun.
 It is a true fact, and it cannot be changed even if we add another sentence in
knowledge base like, "The moon revolves around the earth" Or "Earth is not
round," etc.
 Advantages of Monotonic Reasoning:
 In monotonic reasoning, each old proof will always remain valid.
 If we deduce some facts from available facts, then it will remain valid for
always.
 Disadvantages of Monotonic Reasoning:
 We cannot represent the real world scenarios using Monotonic reasoning.
 Hypothesis knowledge cannot be expressed with monotonic reasoning,
which means facts should be true.
 Since we can only derive conclusions from the old proofs, so new
knowledge from the real world cannot be added.
 6. Non-monotonic Reasoning
 In Non-monotonic reasoning, some conclusions may be invalidated
if we add some more information to our knowledge base.
 Logic will be said as non-monotonic if some conclusions can be
invalidated by adding more knowledge into our knowledge base.
 Non-monotonic reasoning deals with incomplete and uncertain
models.
 "Human perceptions for various things in daily life, "is a general
example of non-monotonic reasoning.
 Example: Let suppose the knowledge base contains the following
knowledge:
 Birds can fly
 Penguins cannot fly
 Pitty is a bird
 So from the above sentences, we can conclude that Pitty can fly.
 However, if we add one another sentence into knowledge base
"Pitty is a penguin", which concludes "Pitty cannot fly", so it
invalidates the above conclusion.
 Advantages of Non-monotonic reasoning:
 For real-world systems such as Robot navigation, we can use non-
monotonic reasoning.
 In Non-monotonic reasoning, we can choose probabilistic facts or
can make assumptions.
 Disadvantages of Non-monotonic Reasoning:
 In non-monotonic reasoning, the old facts may be invalidated by
adding new sentences.
 It cannot be used for theorem proving.
Difference between Inductive and
Deductive reasoning
Basis for Deductive Reasoning Inductive Reasoning
comparison
Definition Deductive reasoning is the form Inductive reasoning arrives at a
of valid reasoning, to deduce conclusion by the process of
new information or conclusion generalization using specific
from known related facts and facts or data.
information.
Approach Deductive reasoning follows a Inductive reasoning follows a
top-down approach. bottom-up approach.
Starts from Deductive reasoning starts from Inductive reasoning starts from
Premises. the Conclusion.
Usage Use of deductive reasoning is Use of inductive reasoning is
difficult, as we need facts which fast and easy, as we need
must be true. evidence instead of true facts.
We often use it in our daily life.
Basis for Deductive Reasoning Inductive Reasoning
comparison
Process Theory→ hypothesis→ Observations-
patterns→confirmation. →patterns→hypothesis→
Theory.
Argument In deductive reasoning, arguments In inductive reasoning,
may be valid or invalid. arguments may be weak
or strong.
Structure Deductive reasoning reaches from Inductive reasoning
general facts to specific facts. reaches from specific
facts to general facts.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy