Unit 3 Contents
Unit 3 Contents
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:
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
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
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
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.