Chapter 3
Chapter 3
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.
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.
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.
Slots Filters
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.
Example:
a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.
The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
1.Atomic Propositions
2.Compound propositions
Example:
52.8M
963
Java Try Catch
Example:
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
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.
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:
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.
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:
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:
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
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:
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:
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 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.
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.
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:
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].
Now we will explore the Wumpus world and will determine how the agent will find its
goal by applying logical reasoning.
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.
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.
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:
66.2M
1.3K
Exception Handling in Java - Javatpoint
Constant 1, 2, A, John, Mumbai, cat,....
Variables x, y, z, a, b,....
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).
Complex Sentences:
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:
Universal Quantifier:
o For all x
o For each x
o For every x.
Example:
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.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
Example:
It will be read as: There are some x where x is a boy who is intelligent.
Points to remember:
Properties of Quantifiers:
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:
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 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.
• 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.
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.
. .
Doman D contains
mortal
man individuals
91
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))))
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 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
2. Inductive Reasoning:
Example:
Premise: All of the pigeons we have seen in the zoo are 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.
Conclusion It is raining.
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:
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.
Example:
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.
6.Non-monotonic Reasoning :
"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:
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.