You are on page 1of 30

DELHI TECHNOLOGICAL UNIVERSITY

(FORMERLY DELHI COLLEGE OF ENGINEERING)


BAWANA ROAD, DELHI - 110042
JANUARY, 2022

PROJECT

Knowledge Representation and


Reasoning in A.I.

FEC-32 LOGICAL REASONING (S3)

OBJECTIVES:

1. To study various kinds of reasoning such as propositional logic (Deductive


and Inductive Reasoning), Abductive Reasoning, Common-Sense
Reasoning, etc., and how they are used to make valid and specific
conclusions from available facts, beliefs, knowledge.
2. To study how knowledge representation in AI is done with help of logic and why
logic is the foundation of Artificial Intelligence.

SUBMITTED TO: Prof. Rinki Jadwani

SUBMITTED BY: Parv Mudgal (2K21/A10/03)

Vishal Shandilya(2K21/A13/17)

1|Page
FEC-32 LOGICAL REASONING
Contents

CANDIDATE’S DECLARATION ..................................................................................................................................................4

CERTIFICATE ..............................................................................................................................................................................5
ACKNOWLEDGEMENT...............................................................................................................................................................6

INTRODUCTION ..........................................................................................................................................................................7
Logical Reasoning and Its Role in Artificial Intelligence ..............................................................................................................8

Types of Reasoning .....................................................................................................................................................................8


1. Deductive reasoning ........................................................................................................................................................8
2. Inductive Reasoning ........................................................................................................................................................9

3. Abductive reasoning ........................................................................................................................................................9

4. Common Sense Reasoning .............................................................................................................................................9

5. Monotonic Reasoning ......................................................................................................................................................9


6. Non-monotonic Reasoning ........................................................................................................................................... 10

What is Knowledge Representation in AI?................................................................................................................................ 11

Let us first discuss A Knowledge-Based Agent ........................................................................................................................ 11


Kinds of Knowledge to Represent in AI systems .............................................................................................................. 11

Types of Knowledge in AI Systems .......................................................................................................................................... 11

1. Declarative knowledge .................................................................................................................................................. 12

2. Procedural knowledge .................................................................................................................................................. 12

3. Heuristic knowledge ...................................................................................................................................................... 12

4. Meta-knowledge ............................................................................................................................................................ 12

5. Structural knowledge .................................................................................................................................................... 12


Approach to Knowledge Representation .................................................................................................................................. 13
1. Simple relational knowledge ......................................................................................................................................... 13

2. Inheritable knowledge ................................................................................................................................................... 13

3. Inferential knowledge .................................................................................................................................................... 14

4. Procedural knowledge .................................................................................................................................................. 14

Requirements for Knowledge Representation system: ............................................................................................................. 14


A good knowledge representation system must possess the following properties........................................................... 14

Techniques of Knowledge Representation ............................................................................................................................... 15


1. Logical Representation ................................................................................................................................................. 15
► Syntax: .......................................................................................................................................................................... 15

► Semantics: .................................................................................................................................................................... 15
2. Semantic Network ......................................................................................................................................................... 16

Statements ........................................................................................................................................................................ 16
Advantages of Semantic Networks ................................................................................................................................... 16
2|Page
FEC-32 LOGICAL REASONING
3. Frame Representation .................................................................................................................................................. 16

4. Production Rules ........................................................................................................................................................... 17

Propositional Logic in Artificial Intelligence ....................................................................................................................... 17

Syntax of Propositional Logic ............................................................................................................................................ 18


1. Atomic Propositions ...................................................................................................................................................... 18

2. Compound Propositions: ............................................................................................................................................... 18


Logical Connectives .......................................................................................................................................................... 18
Truth Table ........................................................................................................................................................................ 19

Logical equivalence........................................................................................................................................................... 20

Rules of Inference in Artificial intelligence ........................................................................................................................ 21


Addition ............................................................................................................................................................................. 22

Modus Tollens ................................................................................................................................................................... 23

Disjunctive Syllogism ........................................................................................................................................................ 23


Hypothetical Syllogism ...................................................................................................................................................... 23

Constructive Dilemma ....................................................................................................................................................... 23

Destructive Dilemma ......................................................................................................................................................... 23


First-Order Logic (Predicate Logic) in Artificial Intelligence ...................................................................................................... 24

Atomic sentences .............................................................................................................................................................. 25

Complex Sentences .......................................................................................................................................................... 25

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


Quantifiers in First-order logic ........................................................................................................................................... 25

Universal Quantifier........................................................................................................................................................... 25

Existential Quantifier ......................................................................................................................................................... 26


Properties of Quantifiers ................................................................................................................................................... 26
Some Examples of FOL using quantifier: ......................................................................................................................... 26

Inference in First-Order Logic ................................................................................................................................................... 27

Substitution ....................................................................................................................................................................... 27

Equality.............................................................................................................................................................................. 27
FOL inference rules for quantifier: .................................................................................................................................... 27
1. Universal Generalization ............................................................................................................................................... 27

2. Universal Instantiation ................................................................................................................................................... 28


3. Existential Instantiation ................................................................................................................................................. 28

4. Existential introduction .................................................................................................................................................. 28


CONCLUSION .......................................................................................................................................................................... 29
Bibliography .............................................................................................................................................................................. 30

3|Page
FEC-32 LOGICAL REASONING
CANDIDATE’S DECLARATION

We, Parv Mudgal 2K21/A10/03 and Vishal Shandilya 2K21/A13/17),


hereby declare that the project titled “Knowledge Representation and Reasoning in Artificial Intelligence” which is submitted
by us to the Prof. Rinki Jadwani Delhi Technological University, Delhi in partial fulfillment of the requirement for the award
of the degree of Bachelor of Technology is original and not copied from any source without proper citation. This work has not
previously formed the basis for the award of any Degree, Diploma Associateship, Fellowship, or other similar title or
recognition.

Place: Delhi Parv Mudgal

Date: Vishal Shandilya

4|Page
FEC-32 LOGICAL REASONING
CERTIFICATE

I hereby certify that the Project Dissertation titled “Knowledge Representation and Reasoning in Artificial Intelligence” which
is submitted by [Parv Mudgal and Vishal Shandilya], 2K21/A10/03 and 2K21/A13/17, Delhi Technological University, Delhi
in partial fulfillment of the requirement for the award of the degree of Bachelor of Technology, is a record of the project work
carried out by the students under my supervision. To the best of my knowledge this work has not been submitted in part or
full for any Degree to this University or elsewhere.

Place: Delhi Rinki Jadwani

Delhi: Professor

5|Page
FEC-32 LOGICAL REASONING
ACKNOWLEDGEMENT

It is our privilege to express our sincerest regards to our project coordinator, Prof. Rinki Jadwani, for their valuable input,
able guidance, encouragement, whole-hearted cooperation, and constructive criticism throughout our project.

We deeply express our sincere thanks to our Head of Department for encouraging and allowing us to present the project on
the topic “Knowledge Representation and Reasoning in Artificial Intelligence “at our department premises for the partial
fulfillment of the requirements leading to the award of B-Tech degree.

We take this opportunity to thank all our lecturers who have directly or indirectly helped our project. We pay our respects
and love to our parents and all other family members and friends for their love and encouragement throughout our
careers.Last but not least we express our thanks to our friends for their cooperation and support.

6|Page
FEC-32 LOGICAL REASONING
INTRODUCTION

Knowledge Representation and Reasoning is concerned with encoding human knowledge in computer systems and AI AI-
based locations such that it can serve as a basis for drawing logical conclusions. Using logical reasoning, KRR systems
derive implicit knowledge from the given information to make more intelligent computers, reduce redundancy, and detect
errors.

The project deals with logical representation, semantics, syntax, knowledge representation using logic, propositional logic,
syntax, logical connectives, truth table, precedence of connectives, logical equivalence, limitations, Rules, and Types of
Inference in AI, first-order logic, etc, and how they act as the main foundation of AI and Intelligent Computers, how their
implementation will allow machines to think logically, and rationally like human brains.

7|Page
FEC-32 LOGICAL REASONING
Logical Reasoning and Its Role in Artificial Intelligence:

Logical reasoning is the science of valid reasoning. It is one of the fundamental skills of effective thinking. It works by
raisingquestions like:

▪ If this is true, what else must be true?


▪ If this is true, what else is probably true?
▪ If this isn’t true, what else can’t be true?
These are all inferences: they’re connections between a given sentence (the “premise”) and some other sentence (the
“conclusion”). Inferences are the basic building blocks of logical reasoning, and there are strict rules governing what
counts as a valid inference and what doesn’t — it’s a lot like math, but applied to sentences rather than numbers.
Example:
If there is someone at the door, the dog will bark.
Assuming this sentence holds, some other sentences must also be true.
▪ If the dog didn’t bark, there is no one at the door. Just because the dog barked doesn’t mean there’s someone
at the door.
There are also a few sentences that are probably true, such as:
▪ The dog can sense (hear or smell) when someone is at the door.

▪ The dog belongs to the people who live in the house where the door is located.

The reasoning is the mental process of deriving logical conclusions 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 like human brain, and can perform like a human.

Artificial intelligence (AI) is a wide-ranging branch of computer science concerned with building smart machines capable of
performing tasks that typically require human intelligence. AI is an interdisciplinary science with multiple approaches, but
advancements in machine learning and deep learning are creating a paradigm shift in virtually every sector of the tech
industry. In the field of Artificial Intelligence, it is common that logic to be used as a foundational concept to help the AI
entities learn novel things and drive analytics based on them. The logic here provides the techniques that are required for
analyzing many things such as inferential properties of a language or even the implementation of the languages as well.
Logic helps tobridge the gap between the high-level logical analysis of a problem and its corresponding implementation in
terms of accuracy of learning and ease of use.

Types of Reasoning

In artificial intelligence, reasoning can be divided into the following categories:

1. Deductive reasoning

Deductive reasoning is a basic form of valid reasoning. Deductive reasoning, or deduction, starts with a general statement,
or hypothesis, and examines the possibilities to reach a specific, logical conclusion. The scientific method uses deduction to
test hypotheses and theories. "In deductive inference, we hold a theory, and based on it we predictits consequences. That
is, we predict what the observations should be if the theory were correct. We go from the general — the theory — to the
specific — the observations.

Deductive reasoning usually follows steps. First, there is a premise, then a second premise, and finally an inference. A
common form of deductive reasoning is syllogism, in which two statements — a major premise and a minor premise —
reach a logical conclusion. For deductive reasoning to be sound, the hypothesis must be correct.

For example, "All men are mortal. Harold is a man. Therefore, Harold is mortal."

8|Page
FEC-32 LOGICAL 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 is contradictory to inductive reasoning.

2. Inductive Reasoning

Inductive reasoning is the opposite of deductive reasoning. Inductive reasoning makes broad generalizations from specific
observations. There is data, then conclusions are drawn from the data. In inductive inference, we go from the specific to the
general. We make many observations, discern a pattern, make a generalization, and infer an explanation or a theory. It is a
type of propositional logic, which is also known as cause-effect reasoning or bottom-up reasoning.

Example: "The coin I pulled from the bag is a penny. That coin is a penny. A third coin from the bag is a penny. Therefore,
all the coins in the bag are pennies." Even if all of the premises are true in a statement, inductive reasoning allows for the
conclusion to be false. Here's an example: "Harold is a grandfather. Harold is bald. Therefore, all grandfathers are bald." The
conclusion does not follow logically from the statements. Inductive reasoning has its place in the scientific method. Scientists
use it to form hypotheses and theories. Deductive reasoning allows them to apply the theories to specific situations.

3. Abductive reasoning:

Another form of scientific reasoning that doesn't fit in with inductive or deductive reasoning is abductive. Abductive reasoning
usually starts with an incomplete set of observations and proceeds to the likeliest possible explanation for the group of
observations. It is based on making and testing hypotheses using the best information available. It often entails making an
educated guess after observing a phenomenon for which there is no clear explanation.

For example, a person walks into their living room and finds torn-up papers all over the floor. The person's dog has been
alone in the room all day. The person concludes that the dog tore up the papers because it is the most likely scenario. Now,
the person's sister may have brought by his niece and she may have torn up the papers, or it may have been done by the
landlord, but the dog theory is the more likely conclusion. Daily decision-making is also an example of abductive reasoning.

4. Common Sense Reasoning

It is an informal type of reasoning gained from experiences rather than knowledge.

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. 3. If I jump from the
tower, then my bones will be broken.

The above three statements are examples of common-sense reasoning that the 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 a valid conclusion from the available facts
only, and it will not be affected by new facts. It is not useful for real-time systems, as in real time, facts get changed, so we
cannot use monotonic reasoning. It is used in conventional reasoning systems, and a logic-based system is monotonic.

Any theorem proving is an example of monotonic reasoning.

Examples: 1. Sun revolves around the sun.

It is a fact, and it cannot be changed even if we add another sentence into the edge 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 they will remain valid for always.

9|Page
FEC-32 LOGICAL REASONING
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 to our knowledge
base. It deals with incomplete and uncertain models. "Human perceptions for various things in daily life, "is a general
example of non-monotonic reasoning.

Example: Let’s suppose the knowledge base contains the following knowledge:

1. Birds can fly. 2. Penguins cannot fly. 3. Pitty is a bird.

So, from the above sentences, we can conclude that Pitty can fly. However, if we add one another sentence into the
knowledgebase "Pitty is a penguin", which concludes "Pitty cannot fly so it invalidates the above conclusion.

Advantages of Non-monotonic reasoning: It is used in real-world systems such as Robot navigation. We can choose
probabilistic facts or can make assumptions.

Disadvantages of Non-monotonic Reasoning: The old facts may be invalidated by adding new sentences. It cannot be
used for theorem proving.

10 | P a g e
FEC-32 LOGICAL REASONING
What is Knowledge Representation in AI?

Knowledge Representation is a radical and new approach to AI that is changing the world. The question of representing
knowledge is a key issue in artificial intelligence: how can human knowledge of all kinds be represented by a computer
language, and in such a way that computers can use this knowledge for purposes of reasoning? Modern computer
applications have led to the generalized use of knowledge representations in various contexts, including information
search,simulation, and web semantic ontology description.

An intelligent agent should be able to acquire information (or knowledge) from the environment to represent and understand
it, and to be able of reasoning, that is to infer the implications of what it knows and of the choices it has. Logic is widely used
in Artificial Intelligence as a representational method. The advantage of using formal logic as a language of AI is that it is
precise and definite and allows reason about negatives and disjunctions. This allows programs to be written which are
declarative - they describe what is true and not how to solve problems. This is of importance for automated reasoning
techniques for general-purpose inferencing. A large amount of the reasoning carried out by humans depends on handling
uncertain knowledge. Logic cannot represent this uncertainty well. Similarly, natural language reasoning requires inferring a
hidden state, namely, the intention of the speaker. Humans can cope with a virtually infinite variety of utterances using a finite
store of common-sense knowledge. Formal logic has difficulty with this kind of ambiguity.

Let us first discuss A Knowledge-Based Agent:

Knowledge-Based Agent: Knowledge-based agents are those agents who have the capability of maintaining an internal state
of knowledge, reason over that knowledge, update their knowledge after observations and take actions. These agents can
represent the world with some formal representation and act intelligently. It needs knowledge about the real-world for taking
decisions and reasoning to act efficiently. It must be able to do the following things:

1. It should represent states and actions. 2. It should incorporate new precepts.

3. It can update the internal representation of the world. 4. It can deduce the internal representation of the world.

5. It can deduce appropriate actions.

Kinds of Knowledge to Represent in AI systems:

1. Objects: The facts or features about the objects in our real-world like a bike has two wheels, handle, engine, tank, etc.

2. Events: The actions which occur in our world are called events.

3. Performance: It is an evaluation of how things are done. It is a parameter for judging the rate of doing work.

4. Meta-Knowledge: It is knowledge about a preselected knowledge i.e. things we already know. For example,
Bibliographic data is a meta-knowledge

5. Facts: Facts are statements that are true about the real world and what we represent.

6. Knowledge Base: It is a collection of sentences (not English sentences rather it is a technical term)

Types of Knowledge in AI Systems:

Depending on the type of functionality, Knowledge in AI can be categorized as:

11 | P a g e
FEC-32 LOGICAL REASONING

1. Declarative knowledge

The knowledge which is based on concepts, facts, and objects, is termed 'Declarative Knowledge’. It provides all the
necessary information about the problem in terms of simple statements, either true or false.

2. Procedural knowledge

Procedural knowledge derives the information based on rules, strategies, agendas, and procedures. It describes how a
problem can be solved. Procedural knowledge directs the steps on how to perform something.
For example Computer programs.

3. Heuristic knowledge

Heuristic knowledge is based on the thumb rule. It provides information based on a thumb rule, which is useful in guiding the
reasoning process. In this type, the knowledge representation is based on the strategies to solve the problems through the
experience of past problems, compiled by an expert. Hence, it is also known as Shallow knowledge.

4. Meta-knowledge

This type gives an idea about the other types of knowledge that are suitable for solving the problems. Meta-knowledge
helps enhance the efficiency of problem-solving proper reasoning process.

5. Structural knowledge

Structural knowledge is associated with information based on rules, sets, concepts, and relationships. It provides the
information necessary for developing the knowledge structures and overall mental model of the problem.

An AI system has the following components for displaying intelligent behavior:

12 | P a g e
FEC-32 LOGICAL REASONING

The above diagram is showing the interaction of the AI system the with real-world and its components.

Perception: It is a means by which it receives or retrieves information from the environment which can be any form either
audio, visual, or any other form.

Learning: It is the component responsible for learning the data retrieved by the perception component.

Knowledge Representation and Reasoning are two components responsible for intelligence like human beings in
machines and are the main components of the cycle. Though they are independent of each other they are coupled together.

Planning and Execution are dependent on KRR.

Approach to Knowledge Representation

There are mainly 4 approaches to representing knowledge.

1. Simple relational knowledge:

It is the simplest way of storing facts which uses the relational method, and each fact about a set of the object is set out
systematically in columns. This approach of knowledge representation is famous in database systems where the relationship
between different entities is represented. This approach has little opportunity for inference. Example: The following is the
simple relational knowledge representation.

2. Inheritable knowledge:

In the inheritable knowledge approach, all data must be stored in a hierarchy of classes. All classes should be arranged in a
generalized form or a hierarchal manner. In this approach, we apply inheritance property. Elements inherit values from
other members of a class. This approach contains inheritable knowledge which shows a relation between instance and
class, and it is called instance relation. Every individual frame can represent the collection of attributes and their value. In
this approach, objects and values are represented in Boxed nodes.

13 | P a g e
FEC-32 LOGICAL REASONING
► We use Arrows that point from objects to their values.

o Example:

3. Inferential knowledge:

The inferential knowledge approach represents knowledge in the form of formal logic. This approach can be used to
derivemore facts. It guaranteed correctness.

o Example: Let's suppose there are two statements:


1. Marcus is a man
2. All men are mortal
Then it can represent as;
man (Marcus)
∀x = man (x) ---------- > mortal (x)s

4. Procedural knowledge:

The procedural knowledge approach uses small programs and codes which describe how to do specific things, and
how toproceed. In this approach, one important rule is used which is the If-Then rule. We can use various coding
languages suchas 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 Adequacy – the ability to represent all the different kinds of knowledge that might be needed in that
domain.

2. Inferential Adequacy – the ability to manipulate the representational structures to derive new structures (corresponding
to new knowledge) from existing structures.

3. Inferential Efficiency – the ability to incorporate additional information into the knowledge structure which can be used to
focus the attention of the inference mechanisms in the most promising directions.

4. Acquisitional Efficiency – the ability to acquire new information easily. Ideally, the agent should be able to control its
knowledge acquisition, but the direct insertion of information by a ‘knowledge engineer’ would be acceptable. Finding a
system that optimizes these for all possible domains is not going to be feasible.

14 | P a g e
FEC-32 LOGICAL REASONING
Techniques of Knowledge Representation

There are four ways to represent knowledge:

1. Logical Representation

Knowledge and logical reasoning play a huge role in artificial intelligence. However, you often require more than just general
and powerful methods to ensure intelligent behavior. Formal logic is the most helpful tool in this area. It is a language with
unambiguous representation guided by certain concrete rules. Knowledge representation relies heavily not so much
on what logic is used but on the method of logic used to understand or decode knowledge. It allows designers to lay down
certain vital communication rules to give and acquire information from agents with minimum errors in communication.
Different rules of logic allow you to represent different things resulting in an efficient inference. Hence, the knowledge
acquired by logical agents will be definite which means it will either be true or false. Although working with logical
representation is challenging, it forms the basis for programming languages and enables you to construct logical reasoning.
Logical representation means drawing a conclusion based on various conditions. Each sentence can be translated into
logic using syntax and semantics.

► Syntax:

It is a set of rules, principles, and processes which decides the formation of legal sentences in the logic. It studies thestructure
of sentences. It determines the symbol used in knowledge representation. It shows how to write those symbols.

Example: 1. Because banana he is eating a hungry. 2. He ate a banana because he is hungry.

The first example doesn’t make any sense, but if you look carefully, it contains the same words as the second example. The
only difference exists in the word order. Therefore, word order is a key element in syntax. However, this does not mean that
syntax is about meaning. A sentence can be syntactically correct, yet have no meaning

► Semantics:

It studies the meaning of words and language. It studies ways in which the meanings of words can be related to each other
and ambiguity. Ambiguity is one way of studying the meaning of language. A sentence is said to be ambiguous when it has
more than one meaning. It is a set of rules by which the sentences in logic are interpreted. It involves assigning a meaning
to each sentence.

15 | P a g e
FEC-32 LOGICAL REASONING
For example, I saw the girl with binoculars.

This sentence has two meanings. One meaning is that I saw a girl while I was looking through the binoculars. The other is
that I saw a girl who was using binoculars.

There are two categories of logical representation. They are as follows.

1. Propositional Logic 2. Predicate logic or First-Order Logic

2. Semantic Network

A semantic network allows you to store knowledge in the form of a graphic network with nodes and arcs representing objects
and their relationships. It could represent physical objects or concepts or even situations. A semantic network is generally
used to represent data or reveal structure. It is also used to support conceptual editing and navigation. A semantic network
is simple and easy to implement and understand. It is more natural than logical representation. It allows you to categorize
objects in various forms and then link those objects. It also has greater expressiveness than logical representation.

Example: Following are some statements that we need to represent in the form of nodes and arcs.

Statements:

1. Jerry is a cat.
2. Jerry is a mammal
3. Jerry is owned by Priya.
4. Jerry is brown colored.
5. All Mammals are animals.

In the above diagram, we have represented the different types of knowledge in the form of nodes and arcs. Each object
isconnected with another object by some relation.

Advantages of Semantic Networks:

The network is graphical and therefore relatively easy to understand.

Disadvantages of Semantic Networks:

It can be difficult to show all the different inference situations using a network. They are less reliable than other knowledge
representation techniques because inferring becomes a process of searching across the diagram. Diagrams can become
very complex

3. Frame Representation

A frame is a collection of attributes and its associated values, which describes an entity in the real world. It is a record-like
structure consisting of slots and their values. Slots could be of varying sizes and types. These slots have names and values.
Or they could have subfields named as facets. They allow you to put constraints on the frames.
16 | P a g e
FEC-32 LOGICAL REASONING
A frame for a book is given below.

Slots Fillers Slot Fillers


publisher Thomson name computer
title Expert Systems specialization of
author Giarratano of kind of machine
edition Third types (desktop, laptop, mainframe, super)
if-added: Procedure ADD_COMPUTER
year 1998
speed default: faster
pages 600 if-needed: Procedure FIND_SPEED
location (home, office, mobile)
Under warranty (yes, no)

Advantages of frame representation

It is very easy to add slots for new attributes and relations and include default data to search for missing, understand
andvisualize.

Disadvantages of frame representation

In frame system inference mechanism is not be easily processed. It cannot be smoothly proceeded by frame representation.
It has a much-generalized approach.

4. Production Rules

Production rule-based representation has many properties essential for knowledge representation. It consists of production
rules, working memory, and the recognize-act-cycle. It is also called condition-action rules. In production rules agent
checks forthe condition and if the condition exists the hen production rule fires and corresponding action is carried out. The
working memory contains the description of the current state of problem-solving and rule that can write knowledge to the
working memory. 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. They are highly modular, so we can easily remove, add or modify
an individual rule.

Disadvantages of Production rule:

The production rule system does not exhibit any learning capabilities, as it does not store the result of the problem for the
future uses.

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 that is either true or false. It is a technique of knowledge representation in logical and mathematical
form.

Example:

1. a) It is November. 2. b) The Sun rises from the West (False proposition)

17 | P a g e
FEC-32 LOGICAL REASONING
3. c) 3+3= 7(False proposition) 4. d) 5 is a prime number.

5. It is also called Boolean logic as it works on 0 and 1.

6. We use symbols to represent the logic like A, B, C, and D.

7. Propositions can be either true or false but not both.

8. Propositional logic consists of an object, relations or function, and logical connectives.

9. These connectives are also called logical operators.

10. The propositions and connectives are the basic elements of propositional logic.

11. Connectives can be said to a logical operator which connects two propositional variables.

12. A proposition formula that is always true is called tautology, and it is also called a valid sentence.

13. A proposition formula that is always false is called Contradiction.

15. Questions, commands, opinions, exclamatory, Inconsistent sentences are not propositions. The following statements
are notpropositions-

► Close the door. (Command) ►Do you speak French? (Question)

► What a beautiful picture! (Exclamation) ► I always tell lies. (Inconsistent)

►P(x): x + 3 = 5 (Predicate)

Syntax of Propositional Logic

The syntax defines the allowable sentences for the knowledgeable representation.

There are two types of propositions used in AI:

1. Atomic Propositions

Atomic propositions are those propositions that cannot be divided further. Small letters like p, q, r, s, etc are used to
represent atomic propositions. It must be either true or false

The examples of atomic propositions are-

p: Sun rises in the east. q: Sunsets in the west. r: Apples are red. s: Grapes are green.

2. Compound Propositions:

Compound propositions are those propositions that are formed by combining one or more atomic propositions using
connectives. It contains some connective. Capital letters like P, Q, R, S, etc. are used to represent compound propositions.

Examples

P: Sun rises in the east and Sunsets in the west. Q: Apples are red and Grapes are green.

Logical Connectives

It connects two undividable simple sentences or expresses a sentence in a logical sense. Complex statements can be
created using logical connectives. There are 5 types of connectors namely

Sl. Type Symbol Description

18 | P a g e
FEC-32 LOGICAL REASONING

1 Negation ¬P It represents a Negative condition. P is a positive statement and ¬ P indicates

NOT condition. Example: Today is Monday (P), Today is not a Monday (¬ P)

2 Conjunction P^Q It joins two statements P, Q with AND clause. Example: Ram is a cricket player

(P). Ram is a Hockey player (Q). Ram plays both cricket and Hockey is

represented by (P ^ Q)

3 Disjunction PvQ It joins two statements P, Q with OR Clause. Example: Ram leaves for Mumbai

(P) and Ram leaves for Chennai (Q). Ram leaves for Chennai or Mumbai are

represented by (P v Q). In this complex statement, at any given point of time if P

is True Q is not true, and vice versa.

4 Implication P→Q Sentence (Q) is dependent on sentence (P) and it is called implication. It follows

the rule of the If then clause. If sentence P is true then sentence Q is true. The

condition is unidirectional. Example: If it is Sunday (P) then I will go to Movie (Q)

and it is represented as P → Q

5 Bi- P⇔Q Sentence (Q) is dependent on sentence (P) and vice versa and conditions are bi-

conditional directional in this connective. If a conditional statement and its converse are true

then it is called aabi-conditional connective (Implication condition in both the

directions P → Q and Q → P). If and only if all conditions are true then the end

statement is true. Example: If I have 1000 Rupees then only, I will go to Bar. The

converse condition that I will go to Bar if and only if I have Rs 1000. The first

statement covers necessity and the second one covers sufficiency.

Truth Table

It maps the truth values of propositions for all combinations that are possible with several logical connectives. It follows
Boolean logic and propositional calculus. All such scenarios with corresponding truth values are captured in a Table known
asTruth Table.

P Q Negation Conjunction Disjunction Implication Bi-

conditional

19 | P a g e
FEC-32 LOGICAL REASONING

¬P ¬Q P^Q PvQ P→Q P⇔Q

True True False False True True True True

True False False True False True False False

False True True False False True True False

False False True True False False True True

The order of precedence of logical connectors in evaluating propositional logic is, 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 (If…then)
Six Precedence Biconditional (If and only if)

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 the below truth table we can see
tcolumnslumn 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.

20 | P a g e
FEC-32 LOGICAL REASONING

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: We cannot represent relations like ALL, some, or none with propositional logic.
Example: ► All the girls are intelligent. ► Some apples are sweet.

It has limited expressive power and we cannot describe statements in terms of their properties or logical relationships.

Rules of Inference in Artificial intelligence

The inference is basically drawing a conclusion based on evidence and facts. The inference is also deducing new
statements from the statements whose truth is known to us with rules of inference. Mathematical logic is often used for
logical proofs. Proofsare valid arguments that determine the truth values of mathematical statements.

An argument is a sequence of statements. The last statement is the conclusion and all its preceding statements are called
premises (or hypothesis). The symbol “∴∴”, (read therefore) is placed before the conclusion. A valid argument is one where
the conclusion follows from the truth values of the premises.

Rules of Inference provide the templates or guidelines for constructing valid arguments from the statements that we already
have.

Some terms related to 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:

21 | P a g e
FEC-32 LOGICAL REASONING

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

Addition

If P is a premise, we can use Addition rule to derive P∨Q. For example

Let P be the proposition, “He studies very hard” is true

Therefore − "Either he studies very hard or he is a very bad student." Here Q is the proposition “he is a very bad student”.

Conjunction

If P and Q are two premises, we can use Conjunction rule to derive P∧Q. For example

Let P − “He studies very hard” Let Q − “He is the best boy in the class”

Therefore − "He studies very hard and he is the best boy in the class"

Simplification

If P∧Q is a premise, we can use Simplification rule to derive P. For example


22 | P a g e
FEC-32 LOGICAL REASONING
"He studies very hard and he is the best boy in the class", P∧Q

Therefore − "He studies very hard".

Modus Ponens

If P and P→Q are two premises, we can use Modus Ponens to derive Q. For example:

"If you have a password, then you can log on to Facebook", P→Q

"You have a password", P

Therefore − "You can log on to facebook"

Modus Tollens

If P→Q and ¬Q are two premises, we can use Modus Tollens to derive ¬P. For example:

"If you have a password, then you can log on to facebook", P→Q

"You cannot log on to Facebook", ¬Q

Therefore − "You do not have a password "

Disjunctive Syllogism

If ¬P and P∨Q are two premises, we can use Disjunctive Syllogism to derive Q. For example:

"The ice cream is not vanilla flavored", ¬P

"The ice cream is either vanilla flavored or chocolate flavored", P∨Q

Therefore − "The ice cream is chocolate flavored”

Hypothetical Syllogism

If P→Q and Q→R are two premises, we can use Hypothetical Syllogism to derive P→R. For example:

"If it rains, I shall not go to school”, P→Q

"If I don't go to school, I won't need to do homework", Q→R

Therefore − "If it rains, I won't need to do homework"

Constructive Dilemma

If (P→Q) ∧(R→S) and P∨R are two premises, we can use constructive dilemma to derive Q∨S. For example:

“If it rains, I will take a leave”, (P→Q)

“If it is hot outside, I will go for a shower”, (R→S)

“Either it will rain or it is hot outside”, P∨R

Therefore − "I will take a leave or I will go for a shower"

Destructive Dilemma

If (P→Q) ∧ (R→S) and ¬Q∨¬S are two premises, we can use destructive dilemma to derive ¬P∨¬R

Example

“If it rains, I will take a leave”, (P→Q)

23 | P a g e
FEC-32 LOGICAL REASONING
“If it is hot outside, I will go for a shower”, (R→S)

“Either I will not take a leave or I will not go for a shower”, ¬Q∨¬S

Therefore − "Either it does not rain or it is not hot outside"

First-Order Logic (Predicate Logic) in Artificial Intelligence

In propositional logic, we can only represent facts or statements which are either true or false. it had very limited
expressiveness. So, to overcome this difficulty, first order logic is used. It is sufficient to represent the natural language
statements in precise way. It assumes that the world contains objects, relations and functions. Objects: A, B, numbers, wars,
cricket, theories, squares…. Relations: It can be unary relation such as: red, round is adjacent, or n-any relation such
as: the sister of, brother of, has colour, comes between etc. Functions: Father of, best friend, third match of, end of, start of
etc. It includes the sentences along with terms which can represent the objects. Constant symbols, variables and function
symbols are used to build terms, while quantifiers and predicate symbols are used to build the sentences. FOL has two main
parts.

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

2. Semantics:

Whether a sentence is true or not depends on the underlying set and the interpretation of the function, constant, and relation
symbols. To this end, we have structures: a structure consists of an underlying set together with an interpretation of
functions, constants, and relations. Given a sentence ϕϕ and a structure MM, MM models ϕϕ means that the sentence ϕϕ is
true with respect to MM.

Let’s understand with an example,


Consider the sentence “Elephants are big”. There are many ways to represent this sentence.
HasSize (Elephant, Big)
SizeOF (Elephant)= Big

Lets introduce a new syntax,


Is Equal (SizeOf (Elephant, Big), this states that a object Elephant is big, which is a useless fact in any reasoning process
about the Elephants in general. So, let’s represent that all Elephants are big.
So, we can find FOL statement as,

► All things that are Elephants are big. ► For all things x, for which x is an Elephant, x is big.
24 | P a g e
FEC-32 LOGICAL REASONING
► For all things x, if x is an Elephant, then x is big. ► Finally, the FOL will be written as. ► ∀x Elephant (x) ⇒ Big(x)

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:

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

b. Predicate: A predicate can be defined as a relation, which binds two atoms together in a statement.

Consider the statement: "x is an integer", 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

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.is represented by a symbol ∀, which resembles an inverted A.
Note: In universal quantifier we use implication "→".

If x is a variable, then ∀x is read as:

► For all x ► For each x ► For every x for example: All man drink coffee.

Let a variable x which refers to a cat so all x can be represented in UOD as below:

25 | P a g e
FEC-32 LOGICAL REASONING

► ∀x man(x) → drink (x, coffee). It will be read as: There are all x where x is a man who drink coffee.

Existential Quantifier

Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true for at least one
instance of something. It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a
predicate variable then it is called as an existential quantifier.

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).


If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:

► There exists a 'x.' ► For some 'x.' ► For at least one 'x.' For 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.

Properties of Quantifiers

a. In universal quantifier, ∀x∀y is similar to ∀y∀x. b. In Existential quantifier, ∃x∃y is similar to ∃y∃x. c. ∃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).

26 | P a g e
FEC-32 LOGICAL REASONING
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)].

Inference in First-Order Logic

FOL Inference Rules for Quantifiers

Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences. Before understanding the
FOL inference rule, let's understand some basic terminologies used in FOL.

Substitution:

Substitution is a fundamental operation performed on terms and formulas. It occurs in all inference systems in first-order
logic. The substitution is complex in the presence of quantifiers in FOL. If we write F[a/x], so it refers to substitute a constant
"a" in place of variable "x".

Note: First-order logic is capable of expressing facts about some or all objects in the universe.
Equality:

First-Order logic does not only use predicate and terms for making atomic sentences but also uses another way, which is
equality in FOL. For this, we can use equality symbols which specify that the two terms refer to the same object.

Example: Brother (John) = Smith.

As in the above example, the object referred by the Brother (John) is similar to the object referred by Smith. The equality
symbol can also be used with negation to represent that two terms are not the same objects.

Example: ¬(x=y) which is equivalent to x ≠y.

FOL inference rules for quantifier:

As propositional logic we also have inference rules in first-order logic, so following are some basic inference rules in FOL:

1. Universal Generalization

It is a valid inference rule which states that if premise P(c) is true for any arbitrary element c in the universe of discourse,
then we can have a conclusion as ∀ x P(x). This rule can be used if we want to show that every element has a similar
property. In this rule, x must not appear as a free variable. It can be represented as:

.
27 | P a g e
FEC-32 LOGICAL REASONING
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8 bits.", it will also be true.

2. Universal Instantiation

It is also called as universal elimination or UI is a valid inference rule. It can be applied multiple times to add new sentences.
The new KB is logically equivalent to the previous KB. As per UI, we can infer any sentence obtained by substituting a
ground term for the variable. It states that we can infer any sentence P(c) by substituting a ground term c (a constant
within domain x) from ∀ x P(x) for any object in the universe of discourse. It can be represented as:

Example:1 IF "Every person like ice-cream"=> ∀x P(x) so we can infer that “John likes ice-cream" => P(c)

Example: 2. Let's take a famous example, “All kings who are greedy are Evil." So, let our knowledge base contains this
detail as in the form of FOL: ∀x king(x) ∧ greedy (x) → Evil (x),

So, from this information, we can infer any of the following statements using Universal Instantiation:

o King (John) ∧ Greedy (John) → Evil (John),


o King (Richard) ∧ Greedy (Richard) → Evil (Richard),
o King (Father (John)) ∧ Greedy (Father (John)) → Evil (Father (John)),

3. Existential Instantiation

It is also called as Existential Elimination, which is a valid inference rule in first-order logic. t can be applied only once to
replace the existential sentence. The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was
satisfiable. This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a new constant symbol.
The restriction with this rule is that c used in the rule must be a new term for which P (c ) is true.

Example: From the given sentence: ∃x Crown(x) ∧ OnHead (x, John),

So, we can infer: Crown(K) ∧ OnHead (K, John), as long as K does not appear in the knowledge base.

Where K is a constant symbol, called Skolem constant. It is a special case of Skolemization process.

4. Existential introduction

It known as an existential generalization, which is a valid inference rule in first-order logic. This rule states that if there is
some element c in the universe of discourse which has a property P, then we can infer that there exists something in the
universe which has the property P. It is represented as;

Example: Let's say that,


"Priyanka got good marks in English."
"Therefore, someone got good marks in English."

28 | P a g e
FEC-32 LOGICAL REASONING
CONCLUSION

Thus, Knowledge representation and reasoning is plays important part in Artificial Intelligence system.
The intelligent agent (machine) does not understand human knowledge directly. So, to make the
machines think like human, it should be able to acquire information form the environment, to process
and to be able of reasoning. So, to represent the knowledge of humans for machines to acquire and
react, knowledge representation is done. It is done with help of various kind of reasonings like inductive,
deductive, common sense, abductive and using logical representation (Propositional Logic, Predicate
Logic), Sematic Network, Frame Representation etc.

29 | P a g e
FEC-32 LOGICAL REASONING
Bibliography

https://www.ntirawen.com/2018/09/types-of-knowledge-in-artificial.html

http://intelligence.worldofcomputing.net/knowledge-representation/frames.html#.X6Pg7ogzaUk

https://www.tutorialandexample.com/inference-in-first-order-logic/

https://www.fingent.com/blog/classifying-knowledge-representation-in-artificial-intelligence/

Knowledge Representation and Reasoning by J. Ronald Brachman and J. Lévesque

https://www.smartzworld.com/downloads/download/ai-module-4-pdf-notes/

https://www.smartzworld.com/notes/artificial-intelligence-notes-pdf-ai/

Artificial Intelligence: Pearson New International Edition by Stuart Russell

Introduction to Logic by Irving M. Copi, Carl Cohen, Kenneth McMahon

https://pediaa.com/difference-between-syntax-and-semantics/

https://brainly.in/question/3396411

https://www.ismll.uni-hildesheim.de/lehre/ai-07s/skript/ai-4up-04-propositional-logic.pdf

https://www.javatpoint.com/reasoning-in-artificial-intelligence

https://www2.cs.duke.edu/courses/summer13/compsci230/restricted/lectures/L05.pdf

https://www.tutorialandexample.com/inference-in-first-order-logic/

30 | P a g e

You might also like