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

Chapter 3

The document discusses ontology as a data model representing knowledge through concepts and relationships, emphasizing its components such as individuals, classes, attributes, and relations. It outlines the significance of ontology in computer science for knowledge representation and reasoning, contrasting it with knowledge bases, and detailing various types of ontologies. Additionally, it covers knowledge representation methods, including logical representation, production rules, semantic networks, frames, and scripts, along with their advantages and disadvantages.

Uploaded by

Udayan Tathe
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 views41 pages

Chapter 3

The document discusses ontology as a data model representing knowledge through concepts and relationships, emphasizing its components such as individuals, classes, attributes, and relations. It outlines the significance of ontology in computer science for knowledge representation and reasoning, contrasting it with knowledge bases, and detailing various types of ontologies. Additionally, it covers knowledge representation methods, including logical representation, production rules, semantic networks, frames, and scripts, along with their advantages and disadvantages.

Uploaded by

Udayan Tathe
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/ 41

Unit – 3 : Knowledge representation and reasoning

Ontology :-
It is a data model that represents knowledge as a set of concepts within a domain and
the relationships between these concepts.
It comes from two Greek Words.
• Onto: Existence or Being Real
• Logia: Science or Study
The word is used in two settings:
• Philosophical
• Non Philosophical

Components:
1. 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).
2. 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.
3.Attributes –
Properties that objects may possess.
For example, a movie is described by the set of ‘parts’ it contains like Script,
Director, Actors.
4.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.

What is Ontology in Computer Science?


• Definition: Ontology in Computer Science and Information Science encompass
a representation or formal naming and definition of categories, properties and
relationship between the Concepts.
• It is a branch of Computer Science where we deal with representation of
Knowledge or Information in a machine.
• It refers to a shared vocabulary for researchers. It includes machine-interpretable
definitions of basic concepts and the relationships between them.
• Ontology-based AI allows the system to use contents and the relationships
between them to make inferences that emulate human behaviour.
• It can produce targeted results and does not require training sets to become
functional.
• Knowledge represented in a formal way.
• A hierarchy of concepts within the domain
• A shared vocabulary to denote the types
• Properties and interrelationship between those concepts
• Def: “An ontology is a specification of conceptualization that is designed for
reuse across multiple applications and implementations. A specification of
conceptualization written, formal description of a set of concepts and
relationships in a domain of interest”.(Peter Karp, 2000)
• Def: “The arrangement of kinds of things into types and categories with a well-
defined structure”. (Passin, 2004)
Ontology Vs Knowledge Base:
• An ontology is a formal representation of a domain of knowledge. It is an
Abstract Entity, it defines the vocabulary for the domains and the relationship
between the concepts. But, an ontology says nothing about how the knowledge
is being stored(as physical file, in a database or in other some form) or how it
can be accessed.
• A Knowledge Base(KB) is a physical artifact, it is a database, a repository of
information that can be accessed and manipulated in some predefined fashion.
The knowledge in the knowledge base can be said to be modelled according to
an ontology.

Types of Ontology :-
• Upper Level Ontologies: An Upper Level Ontologies also called as top level
Ontologies describe the most general concepts that are the same across all the
knowledge domains (Eg.: Entities)
• General Ontologies: Represent the knowledge at an intermediate level of details
independently of a specific task. (Eg.: Theories of Time and Space)
• Domain Level Ontologies: Designed for a specific tasks and is also called as
application ontologies.

Knowledge Representation and Reasoning :-


● Knowledge representation means represent knowledge about the world in a
manner that facilitates inferencing(drawing conclusions) from the knowledge.
● Knowledge representation and reasoning (KR², KR&R) is the field of AI
dedicated to representing information about the world in a form that a computer
system can utilize to solve complex tasks such as diagnosing a medical condition
or having a dialog in a natural language.
● It incorporates findings from psychology about how humans solve problems and
represent knowledge in order to design formalisms that will make complex
systems easier to design and build.
● KR&R also incorporates findings from logic to automate various kinds of
reasoning, such as the application of rules or the relations of sets and subsets.
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 Knowledge-base is a group of the
Sentences (Here, sentences are used as a technical term and not identical with
the English language).

Types of Knowledge representation


● Logic / Logical representation
● Rules / Production Rules
● Semantic Net
● Frames
● Script

1. Logic:
● 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.
1. 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.
2. 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:


1. Propositional Logics (either true or false but not both)
2. Predicate logics (quantifiers like for all, there exist etc)

Advantages of logical representation:


1. Logical representation enables us to do logical reasoning.
2. Logical representation is the basis for the programming languages.

Disadvantages of logical Representation:


1. Logical representations have some restrictions and are challenging to work
with.
2. Logical representation technique may not be very natural, and inference may
not be so efficient.

2.Rules / Production Rules:


Rules / Production Rules it 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.
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:


1. The production rules are expressed in natural language.
2. The production rules are highly modular, so we can easily remove, add or modify
an individual rule.

Disadvantages of Production rule:


1. Production rule system does not exhibit any learning capabilities, as it does not
store the result of the problem for the future uses.
2. During the execution of the program, many rules may be active hence rule-based
production systems are inefficient.

3. Semantic Network Representation:


● In Semantic networks, we 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:
a. IS-A relation (Inheritance)
b. Kind-of-relation
Example: Following are some statements which we need to represent in the form of
nodes and arcs.
Statements:
a. Jerry is a cat.
b. Jerry is a mammal
c. Jerry is owned by Priya.
d. Jerry is white colored.
e. All Mammals are animal.

Advantages of Semantic network:


1. Semantic networks are a natural representation of knowledge.
2. Semantic networks convey meaning in a transparent manner.
3. These networks are simple and easily understandable.

Drawbacks in Semantic representation:


1. 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.
2. Semantic networks try to model human-like memory to store the information,
but in practice, it is not possible to build such a vast semantic network.
3. These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
4. Semantic networks do not have any standard definition for the link names.
5. These networks are not intelligent and depend on the creator of the system.

4. Frames / 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.
● Frame 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.
● A frame is also known as slot-filter knowledge representation in artificial
intelligence.
Example: 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:
1. The frame knowledge representation makes the programming easier by grouping
the related data.
2. The frame representation is comparably flexible and used by many applications
in AI.
3. It is very easy to add slots for new attribute and relations.
4. It is easy to include default data and to search for missing values.
5. Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
1. In frame system inference mechanism is not be easily processed.
2. Inference mechanism cannot be smoothly proceeded by frame representation.
3. Frame representation has a much generalized approach.

5.Script:
● A script is a structured representation describing a stereotyped sequence of
events in a particular context.
● Scripts are used in natural language understanding systems to organize a
knowledge base in terms of the situations that the system should understand.
● Scripts use a frame-like structure to represent the commonly occurring
experience like going to the movies eating in a restaurant, shopping in a
supermarket, or visiting an ophthalmologist.
● Thus, a script is a structure that prescribes a set of circumstances that could be
expected to follow on from one another.
● Scripts are beneficial because:
1. Events tend to occur in known runs or patterns.
2. A casual relationship between events exist.
3. An entry condition exists which allows an event to take place.
4. Prerequisites exist upon events taking place.
Components of a script
1. Entry condition: These are basic condition which must be fulfilled before events
in the script can occur.
2. Results: Condition that will be true after events in script occurred.
3. Props: Slots representing objects involved in events
4. Roles: These are the actions that the individual participants perform.
5. Track: Variations on the script. Different tracks may share components of the
same scripts.
6. Scenes: The sequence of events that occur.

Propositional logic in Artificial intelligence


Propositional logic (PL) is the simplest form of logic where all the statements are made
by propositions. A proposition is a declarative statement which is either true or false. It
is a technique of knowledge representation in logical and mathematical form.

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.

Following are some basic facts about propositional logic:

o Propositional logic is also called Boolean logic as it works on 0 and 1.


o In propositional logic, we use symbolic variables to represent the logic, and we
can use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
o Propositions can be either true or false, but it cannot be both.
o Propositional logic consists of an object, relations or function, and logical
connectives.
o These connectives are also called logical operators.
o The propositions and connectives are the basic elements of the propositional
logic.
o Connectives can be said as a logical operator which connects two sentences.
o A proposition formula which is always true is called tautology, and it is also
called a valid sentence.
o A proposition formula which is always false is called Contradiction.
o A proposition formula which has both true and false values is called
o Statements which are questions, commands, or opinions are not propositions
such as "Where is Rohini", "How are you", "What is your name", are not
propositions.

Syntax of propositional logic:

The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:

1.Atomic Propositions

2.Compound propositions

Atomic Proposition: Atomic propositions are the simple propositions. It consists of a


single proposition symbol. These are the sentences which must be either true or false.

Example:

52.8M
963
Java Try Catch

a) 2+2 is 4, it is an atomic proposition as it is a true fact.


b) "The Sun is cold" is also a proposition as it is a false fact.

Compound proposition: Compound propositions are constructed by combining


simpler or atomic propositions, using parenthesis and logical connectives.

Example:

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 connect two simpler propositions or representing a


sentence logically. We can create compound propositions with the help of logical
connectives. There are mainly five connectives, which are given as follows:

1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either


Positive literal or negative literal.
2. 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.
3. 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.
4. 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
5. 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:

In propositional logic, we need to know the truth values of propositions in all possible
scenarios. We can combine all the possible combination with logical connectives, and
the representation of these combinations in a tabular format is called Truth table.
Following are the truth table for all logical connectives:
Truth table with three propositions:

We can build a proposition composing three propositions P, Q, and R. This truth table
is made-up of 8n Tuples as we have taken three proposition symbols.
Precedence of connectives:

Just like arithmetic operators, there is a precedence order for propositional connectors
or logical operators. This order should be followed while evaluating a propositional
problem. Following is the list of the precedence order for operators:

Precedence Operators

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Fifth Precedence Implication

Six Precedence Biconditional

Note: For better understanding use parenthesis to make sure of the correct
interpretations. Such as ¬R∨ Q, It can be interpreted as (¬R) ∨ Q.

Logical equivalence:

Logical equivalence is one of the features of propositional logic. Two propositions are
said to be logically equivalent if and only if the columns in the truth table are identical
to each other.

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:

o Commutativity:
o P∧ Q= Q ∧ P, or
o P ∨ Q = Q ∨ P.
o Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
o Identity element:
o P ∧ True = P,
o P ∨ True= True.
o Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
o DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
o Double-negation elimination:
o ¬ (¬P) = P.

Limitations of Propositional logic:

o We cannot represent relations like ALL, some, or none with propositional logic.
Example:
a. All the girls are intelligent.
b. Some apples are sweet.
o Propositional logic has limited expressive power.
o In propositional logic, we cannot describe statements in terms of their properties
or logical relationships.
Rules of Inference in Artificial intelligence
Inference:

In artificial intelligence, we need intelligent computers which can create new logic from
old logic or by evidence, so generating the conclusions from evidence and facts is
termed as Inference.

Inference rules:

Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.

In inference rules, the implication among all the connectives plays an important role.
Following are some terminologies related to inference rules:

o Implication: It is one of the logical connectives which can be represented as P


→ Q. It is a Boolean expression.
o 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.
o Contrapositive: The negation of converse is termed as contrapositive, and it can
be represented as ¬ Q → ¬ P.
o Inverse: The negation of implication is called inverse. It can be represented as
¬ P → ¬ Q.

From the above term some of the compound statements are equivalent to each other,
which we can prove using 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:

The Modus Ponens rule is one of the most important rules of inference, and it states that
if P and P → Q is true, then we can infer that Q will be true. It can be represented as:

Example:

Statement-1: "If I am sleepy then I go to bed" ==> P→ Q


Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.

Proof by Truth table:

2. Modus Tollens:

The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also
true. It can be represented as:

Statement-1: "If I am sleepy then I go to bed" ==> P→ Q


Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P

Proof by Truth table:


3. Hypothetical Syllogism:

The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and
Q→R is true. It can be represented as the following notation:

Example:

Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R

Proof by truth table:

4. Disjunctive Syllogism:

The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will be
true. It can be represented as:

Example:

Statement-1: Today is Sunday or Monday. ==>P∨Q


Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q

Proof by truth-table:
5. Addition:

The Addition rule is one the common inference rule, and it states that If P is true, then
P∨Q will be true.

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:

The Wumpus World in Artificial intelligence


Wumpus world:

The Wumpus world is a simple world example to illustrate the worth of a knowledge-
based agent and to represent knowledge representation. It was inspired by a video
game Hunt the Wumpus by Gregory Yob in 1973.

The Wumpus world is a cave which has 4/4 rooms connected with passageways. So
there are total 16 rooms which are connected with each other. We have a knowledge-
based agent who will go forward in this world. The cave has a room with a beast which
is called Wumpus, who eats anyone who enters the room. The Wumpus can be shot by
the agent, but the agent has a single arrow. In the Wumpus world, there are some Pits
rooms which are bottomless, and if agent falls in Pits, then he will be stuck there forever.
The exciting thing with this cave is that in one room there is a possibility of finding a
heap of gold. So the agent goal is to find the gold and climb out the cave without fallen
into Pits or eaten by Wumpus. The agent will get a reward if he comes out with gold,
and he will get a penalty if eaten by Wumpus or falls in the pit.

Note: Here Wumpus is static and cannot move.

Following is a sample diagram for representing the Wumpus world. It is showing some
rooms with Pits, one room with Wumpus and one agent at (1, 1) square location of the
world.

There are also some components which can help the agent to navigate the cave.
These components are given as follows:

a. The rooms adjacent to the Wumpus room are smelly, so that it would have some
stench.
b. The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then
he will perceive the breeze.
c. There will be glitter in the room if and only if the room has gold.
d. The Wumpus can be killed by the agent if the agent is facing to it, and Wumpus
will emit a horrible scream which can be heard anywhere in the cave.

PEAS description of Wumpus world:

To explain the Wumpus world we have given PEAS description as below:


Performance measure:

o +1000 reward points if the agent comes out of the cave with the gold.
o -1000 points penalty for being eaten by the Wumpus or falling into the pit.
o -1 for each action, and -10 for using an arrow.
o The game ends if either agent dies or came out of the cave.

Environment:

o A 4*4 grid of rooms.


o The agent initially in room square [1, 1], facing toward the right.
o Location of Wumpus and gold are chosen randomly except the first square [1,1].
o Each square of the cave can be a pit with probability 0.2 except the first square.

Actuators:

o Left turn,
o Right turn
o Move forward
o Grab
o Release
o Shoot.

Sensors:

o The agent will perceive the stench if he is in the room adjacent to the Wumpus.
(Not diagonally).
o The agent will perceive breeze if he is in the room directly adjacent to the Pit.
o The agent will perceive the glitter in the room where the gold is present.
o The agent will perceive the bump if he walks into a wall.
o When the Wumpus is shot, it emits a horrible scream which can be perceived
anywhere in the cave.
o These percepts can be represented as five element list, in which we will have
different indicators for each sensor.
o Example if agent perceives stench, breeze, but no glitter, no bump, and no scream
then it can be represented as:
[Stench, Breeze, None, None, None].

The Wumpus world Properties:

o Partially observable: The Wumpus world is partially observable because the


agent can only perceive the close environment such as an adjacent room.
o Deterministic: It is deterministic, as the result and outcome of the world are
already known.
o Sequential: The order is important, so it is sequential.
o Static: It is static as Wumpus and Pits are not moving.
o Discrete: The environment is discrete.
o 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 will explore the Wumpus world and will determine how the agent will find its
goal by applying logical reasoning.

Agent's First step:

Initially, the agent is in the first room or on the square [1,1], and we already know that
this room is safe for the agent, so to represent on the below diagram (a) that room is
safe we will add symbol OK. Symbol A is used to represent agent, symbol B for the
breeze, G for Glitter or gold, V for the visited room, P for pits, W for Wumpus.

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 agent needs to move forward, so it will either move to [1, 2], or [2,1]. Let's suppose
agent moves to the room [2, 1], at this room agent perceives some breeze which means
Pit is around this room. The pit can be in [3, 1], or [2,2], so we will add symbol P? to
say that, is this Pit room?

Now agent will stop and think and will not make any harmful move. The agent will go
back to the [1, 1] room. The room [1,1], and [2,1] are visited by the agent, so we will
use symbol V to represent the visited squares.

Agent's third step:

At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2]
agent perceives a stench which means there must be a Wumpus nearby. But Wumpus
cannot be in the room [1,1] as by rules of the game, and also not in [2,2] (Agent had not
detected any stench when he was at [2,1]). Therefore agent infers that Wumpus is in the
room [1,3], and in current state, there is no breeze which means in [2,2] there is no Pit
and no Wumpus. So it is safe, and we will mark it OK, and the agent moves further in
[2,2].
Agent's fourth step:

At room [2,2], here no stench and no breezes present so let's suppose agent decides to
move to [2,3]. At room [2,3] agent perceives glitter, so it should grab the gold and climb
out of the cave.

First-Order Logic in Artificial intelligence :


In the topic of Propositional logic, we have seen that how to represent statements using
propositional logic. But unfortunately, in propositional logic, we can only represent the
facts, which are either true or false. PL is not sufficient to represent the complex
sentences or natural language statements. The propositional logic has very limited
expressive power. Consider the following sentence, which we cannot represent using
PL logic.

o "Some humans are intelligent", or


o "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:

o First-order logic is another way of knowledge representation in artificial


intelligence. It is an extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language statements in a
concise way.
o First-order logic is also known as Predicate logic or First-order predicate
logic. First-order logic is a powerful language that develops information about
the objects in a more easy way and can also express the relationship between
those objects.
o 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:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pits,
wumpus, ......
o 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
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
a. Syntax
b. Semantics

Syntax of First-Order logic:

The syntax of FOL determines which collection of symbols is a logical expression in


first-order logic. The basic syntactic elements of first-order logic are symbols. We write
statements in short-hand notation in FOL.

Basic Elements of First-order logic:

Following are the basic elements of FOL syntax:

66.2M
1.3K
Exception Handling in Java - Javatpoint
Constant 1, 2, A, John, Mumbai, cat,....

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

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃

Atomic sentences:

o 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.
o 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:

o Complex sentences are made by combining atomic sentences using connectives.

First-order logic statements can be divided into two parts:

o Subject: Subject is the main part of the statement.


o 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:

o A quantifier is a language element which generates quantification, and


quantification specifies the quantity of specimen in the universe of discourse.
o 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:
a. Universal Quantifier, (for all, everyone, everything)
b. 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:

o For all x
o For each x
o 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:

o There exists a 'x.'


o For some 'x.'
o 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:

o The main connective for universal quantifier ∀ is implication →.


o The main connective for existential quantifier ∃ is and ∧.

Properties of Quantifiers:

o In universal quantifier, ∀x∀y is similar to ∀y∀x.


o In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o ∃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.

Situation Calculus:
• Situation calculus is used for planning by asking for a situation in which a goal
is true. Answer extraction is used to find a situation in which the goal is true.

• This situation can be interpreted as a sequence of actions for the agent to perform.

• The situation calculus is a logic formalism designed for representing and


reasoning about dynamical domains. It was first introduced by John McCarthy
in 1963. The main version of the situational calculus that is presented in this
article is based on that introduced by Ray Reiter in 1991.

• The main elements of the situation calculus are the actions, fluents and the
situations.

• A number of objects are also typically involved in the description of the world.

• The situation calculus is based functions on a sorted domain with three sorts:
actions, situations, and objects, where the objects include everything that is not
an action or a situation.

• Variables of each sort can be used. While actions, situations, and objects are
elements of the domain, the fluents are modeled as either predicates.

Actions: The actions form a sort of the domain. Variables of sort action can be used.
Actions can be quantified.
Situations: In the situation calculus, a dynamic world is modeled as progressing
through a series of situations as a result of various actions being performed within the
world. A situation represents a history of action occurrences.
Fluents: Statements whose truth value may change are modeled by relational fluents,
predicates which take a situation as their final argument. Functional fluents are
functions which take a situation as their final argument and return a situation-dependent
value.
• In the modern version of the situational calculus, a situation is a sequence of
actions.

• Originally, situations were defined as “the complete state of the universe at an


instant of time”.

• It was clear from the beginning that such situations could not be completely
described; the idea was simply to give some statements about situations, and
derive consequences from them.

• This is also different from the approach that is taken by the fluent calculus, where
a state can be a collection of known facts, that is, a possibly incomplete
description of the universe.

Problems with First Order Logic :


• The syntax of FOL is designed to make it easy to say things about objects but
finding problem solution using FOL is computationally expensive
• FOL is Undecidable(Semi-decidable)

• We can use frames where we keep all related data together

• But frame lack in logic basis

• So we can think of Description Logics(DL) which is subset of FOL and


decidable and computationally inexpensive

• DLs are family of languages used in artificial intelligence to describe and


reason about the relevant concepts of an application domain (known as
terminological knowledge).

Description Logic :
• Description logics (DL) are a family of formal knowledge representation
languages. Many DLs are more expressive than propositional logic but less
expressive than first-order logic.

• In contrast to first order logic, the core reasoning problems for DLs are (usually)
decidable, and efficient decision procedures have been designed and
implemented for these problems.

• There are general, spatial, temporal, spatiotemporal, and fuzzy description


logics, and each description logic features a different balance between expressive
power and reasoning complexity by supporting different sets of mathematical
constructors.

• DLs are used to describe the set of concepts.

• The fundamental modeling concept of a DL is the axiom - a logical statement


relating roles and/or concepts.

• Def: DL are notations that are designed to make it easier to describe


definitions and properties of categories.
Description Logics
Concepts / categories

. .
Doman D contains
mortal
man individuals

91

In FOL we say ∀ x man(x) ⇒ mortal(x)


In DL we say man ⊆ mortal (No quantifiers and variables used)
A description logic (DL) models concepts, roles and individuals, and their
relationships.
concepts: {c,d,....}
roles:{binary relations such as father, mother and so on represented with r, s……}
individuals: {a,b,....}
The Principal Inference tasks:
Subsumption - checking if one category is a subset of another by comparing
their definitions
Classification - checking whether an object belongs to a category

The syntax of descriptions in a subset of the CLASSIC language


Concept → Thing | ConceptName
| And (Concept,…)
| All (RoleName, Concept)
| AtLeast (Integer, RoleName)
| AtMost (Integer, RoleName)
| Fills (RoleName, IndividualName, …)
| SameAs (Path, Path)
| OneOf (IndividualName, …)
Path → [RoleName, …]

For example, to say that bachelors are unmarried adult males we would write
Bachelor = And(Unmarried, Adult, Male) .
The equivalent in first-order logic would be
Bachelor (x) ⇔ Unmarried(x) ∧ Adult(x) ∧ Male(x) .
Any description in CLASSIC can be translated into an equivalent first-order sentence,
but some descriptions are more straightforward in CLASSIC.
For example, to describe the set of men with at least three sons who are all
unemployed and married to doctors, and at most two daughters who are all
professors in physics or math departments, we would use
And(Man, AtLeast(3, Son), AtMost(2, Daughter ), All(Son, And(Unemployed,
Married, All(Spouse, Doctor ))), All(Daughter , And(Professor
,Fills(Department,Physics, Math))))

The most important aspect of description logics is their emphasis on tractability of


inference.
A problem instance is solved by describing it and then asking if it is subsumed by one
of several possible solution categories.
DLs ensure that subsumption-testing can be solved in time polynomial in the size of
the descriptions.
It can only have one of two consequences:
- either hard problems cannot be stated at all, or
- they require exponentially large descriptions

Reasoning with default information :


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 :

o Deductive reasoning
o Inductive reasoning
o Abductive reasoning
o Common Sense Reasoning

o Monotonic Reasoning
o Non-monotonic Reasoning

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.

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:

1. One person can be at one place at a time.


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

o 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:

o In monotonic reasoning, each old proof will always remain valid.


o If we deduce some facts from available facts, then it will remain valid for always.

Disadvantages of Monotonic Reasoning:

o We cannot represent the real world scenarios using Monotonic reasoning.


o Hypothesis knowledge cannot be expressed with monotonic reasoning, which
means facts should be true.
o 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:

o Birds can fly


o Penguins cannot fly
o 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:

o For real-world systems such as Robot navigation, we can use non-monotonic


reasoning.
o In Non-monotonic reasoning, we can choose probabilistic facts or can make
assumptions.

Disadvantages of Non-monotonic Reasoning:

o In non-monotonic reasoning, the old facts may be invalidated by adding new


sentences.
o It cannot be used for theorem proving.

You might also like