3.Knowledge and Reasoning
3.Knowledge and Reasoning
By Namanjeet Singh
5 mins read
Last updated: 16 Jun 2023
307 views
Topics Covered
Overview
Introduction
Knowledge-Base
The KBA receives input from the environment through perception, which the
inference engine processes.
The inference engine communicates with the knowledge base (KB) to determine
the appropriate action based on the knowledge stored in the KB.
Inference System
Generating new facts by the inference system allows the agent to update its
knowledge base. The inference system operates primarily through two rules,
which are referred to as forward chaining and backward chaining.
There are three main operations that a knowledge-based agent (KBA) performs
to demonstrate intelligent behavior. The first operation is called TELL, where
the KBA informs the knowledge base about the information it has perceived
from the environment.
The second operation is called ASK, where the KBA requests the knowledge
base to suggest appropriate action.
The third operation is PERFORM, where the KBA executes the selected
action.
The Structure Outline of a Generic Knowledge-Based Agents Program
function KB-AGENT(percept):
persistent: KB, a knowledge base
t, a counter, initially 0, indicating the
time
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
Action = ASK(KB, MAKE-ACTION-QUERY(t))
TELL(KB, MAKE-ACTION-SENTENCE(action, t))
t = t + 1
return action
Each time the function is executed, the agent performs three operations:
Knowledge Level
Implementation Level
Declarative Approach
Procedural Approach
Conclusion
1. Rule-Based Systems
Description: Rule-based agents use a set of if-then rules to make decisions and
draw conclusions based on given inputs.
Components:
Strengths:
Weaknesses:
2. Frame-Based Systems
Components:
Strengths:
Weaknesses:
3. Semantic Networks
Strengths:
Weaknesses:
4. Logic-Based Systems
Description: These agents use formal logic (e.g., propositional logic, first-order
logic) to represent knowledge and draw conclusions.
Components:
Strengths:
Weaknesses:
Computationally expensive, particularly for large knowledge bases.
Requires expertise to formulate and manage logical statements.
5. Ontology-Based Approaches
Components:
Strengths:
Weaknesses:
Description: CBR relies on solving new problems based on solutions from past
cases stored in a case base.
Strengths:
Can be very effective for problems where prior cases provide valuable
insights.
Continuously improves as more cases are accumulated.
Weaknesses:
7. Hybrid Approaches
Weaknesses:
Conclusion
Logical Representation
FOL allows for more precise and flexible reasoning about the
relationships between objects and is widely used in mathematics,
computer science, and philosophy.
There are several advantages to using logical representation, such as its ability
to facilitate logical reasoning and serve as the foundation for programming
languages. However, there are also some limitations and challenges associated
with this method. One disadvantage is that logical representations can be
restrictive and difficult to work with. Additionally, this approach may not be
very intuitive, and the process of inference may not always be efficient.
Example:
It is Monday.
The Sun rises from the North (False proposition)
3+3= 8(False proposition)
7 is a prime number.
However, there are some drawbacks associated with this representation method.
For instance, semantic networks can be computationally expensive at runtime,
as traversing the entire network tree may be necessary to answer certain
questions. Furthermore, modeling the vastness of human-like memory is not
practical. Semantic networks also lack quantifier equivalents such as "for all" or
"for some", and do not have standard definitions for link names. Additionally,
they are not inherently intelligent and depend on the creator of the system.
Example: The following are a few statements that must be represented with
nodes and arcs:
Jerry is a cat.
Jerry is a mammal
Jerry is owned by Priya.
Jerry is brown-colored.
All Mammals are animals.
Frame Representation
The syntax of a frame consists of attributes and values, and the semantics
involve defining the meaning of each attribute and value. The frame
representation method offers several advantages in the field of artificial
intelligence. One of its key strengths is its ability to simplify programming by
grouping related data. It is also a highly flexible approach utilized in various AI
applications. Moreover, the visual nature of frame representation makes it easy
to comprehend.
However, there are also some limitations associated with frame representation.
For instance, the inference mechanism in frame systems can be challenging to
process, and the approach is not always the most efficient. Additionally, the
generalized nature of frame representation means that it may not always be the
best fit for more specific or complex scenarios.
Production Rules
Production rules are a set of IF-THEN statements that represent knowledge. The
IF part of a rule is a condition, and the THEN part is an action to be taken if the
condition is met. Production rules can be used to represent a wide range of
knowledge, including facts, procedures, and heuristics.
However, there are also some drawbacks to the production rules system. They
do not possess any learning capabilities and cannot store the result of a problem
for future use. Furthermore, they can become complex and difficult to maintain
as the number of rules increases.
4. Define Propositional logic and its use in knowledge representation.
Ans:-
What is Propositional Logic in Artificial Intelligence?
Propositional logic is a kind of logic whereby the expression that takes
into consideration is referred to as a proposition, which is a statement
that can be either true or false but cannot be both at the same time. In
AI propositions are those facts, conditions, or any other assertion
regarding a particular situation or fact in the world. Propositional logic
uses propositional symbols, connective symbols, and parentheses to
build up propositional logic expressions otherwise referred to as
propositions.
Proposition operators like conjunction (∧), disjunction (∨), negation ¬,
implication →, and biconditional ↔ enable a proposition to be
manipulated and combined in order to represent the underlying logical
relations and rules.
Example of Propositions Logic
In propositional logic, well-formed formulas, also called propositions,
are declarative statements that may be assigned a truth value of either
true or false. They are often denoted by letters such as P, Q, and R.
Here are some examples:
P: In this statement, ‘The sky is blue’ five basic sentence
components are used.
Q: ‘There is only one thing wrong at the moment we are in the
middle of a rain.”
R: ‘Sometimes they were just saying things without realizing: “The
ground is wet”’.
All these protasis can be connected by logical operations to create
stamata with greater propositional depth. For instance:
P∧Q: ”It is clear that the word ‘nice’ for the sentence ‘Saturday is a
nice day’ exists as well as the word ‘good’ for the sentence ‘The
weather is good today. ’”
P∨Q: “It may probably be that the sky is blue or that it is raining. ”
¬P: I was not mindful that the old adage “The sky is not blue” deeply
describes a geek.
Basic Concepts of Propositional Logic
1. Propositions:
A proposition is a declarative statement that is either true or false. For
example:
“The sky is blue.” (True)
“It is raining.” (False)
2. Logical Connectives:
Logical connectives are used to form complex propositions from
simpler ones. The primary connectives are:
AND (∧): A conjunction that is true if both propositions are true.
o Example: “It is sunny ∧ It is warm” is true if both
propositions are true.
OR (∨): A disjunction that is true if at least one proposition is true.
o Example: “It is sunny ∨ It is raining” is true if either
proposition is true.
NOT (¬): A negation that inverts the truth value of a proposition.
o Example: “¬It is raining” is true if “It is raining” is false.
IMPLIES (→): A conditional that is true if the first proposition implies
the second.
o Example: “If it rains, then the ground is wet” (It rains → The
ground is wet) is true unless it rains and the ground is not
wet.
IFF (↔): A biconditional that is true if both propositions are either
true or false together.
o Example: “It is raining ↔ The ground is wet” is true if both
are true or both are false.
3. Truth Tables:
Truth tables are used to determine the truth value of complex
propositions based on the truth values of their components. They
exhaustively list all possible truth value combinations for the involved
propositions.
4. Tautologies, Contradictions, and Contingencies:
Tautology: A proposition that is always true, regardless of the truth
values of its components.
o Example: “P ∨ ¬P”
Contradiction: A proposition that is always false.
o Example: “P ∧ ¬P”
Contingency: A proposition that can be either true or false
depending on the truth values of its components.
o Example: “P ∧ Q”
Propositional Logic
Basic Components:
1. Expressing Knowledge:
o Propositional logic provides a formal framework to express
knowledge. Complex scenarios can be broken down into simpler
propositions, allowing for clear representation of facts and rules.
2. Inference and Reasoning:
o It enables inference, allowing systems to derive new propositions
from existing ones. For example, from the propositions "It is
raining" and "If it rains, the ground is wet," we can infer that "The
ground is wet."
3. Simplifying Complex Problems:
o Propositional logic can simplify reasoning about complex problems
by representing them as logical formulas. This makes it easier to
analyze and manipulate knowledge.
4. Truth Tables:
o Truth tables can be employed to evaluate the truth values of
complex propositions based on their constituent parts. This is
useful for verifying the validity of logical statements and ensuring
logical consistency.
5. Automated Reasoning:
o Propositional logic serves as the basis for automated reasoning
systems, enabling tasks such as theorem proving, decision making,
and problem-solving.
6. Formal Proofs:
o It supports formal proof techniques, allowing the establishment of
theorems and verifying logical relationships within a knowledge
base.
Limitations
Conclusion
Inference rules in AI are used to make logical deductions from given premises.
Here are the different types of inference rules in AI:
Modus Ponens
Explanation:
The symbol "→" means "implies" or "if...then". So (P→Q)(P→Q) means "if P,
then Q". The symbol "⊢" means "entails" or "leads to", and is used to indicate
that Q can be deduced from the premises (P → Q) and P.
Modus Tollens
Explanation:
The symbol "¬" means "not", so ¬Q means "it is not the case that Q". The
symbol "⊢" has the same meaning as in Modus Ponens. This rule can be read
as "If P implies Q and Q is false, then P is false".
Hypothetical Syllogism
It is a deductive inference rule that allows us to conclude from two conditional
statements. If A implies B and B implies C, then A implies C. For example, "If
it's raining, then the ground is wet" (A implies B), "If the ground is wet, then the
grass will be green" (B implies C), therefore "If it's raining, then the grass will
be green" (A implies C).
Explanation:
This rule says that if P implies Q, and Q implies R, then P implies R. The
symbol "→" means "implies", and the symbol "⊢" means "entails".
Disjunctive Syllogism
For example, "It's either raining or snowing" (A or B), "It's not raining" (A is
false), therefore "It's snowing" (B is true).
Explanation:
The symbol "∨" means " or", so (P ∨ Q) means "either P or Q (or both) is true".
The symbol "¬" means "not". This rule can be read as "If either P or Q is true,
and P is false, then Q is true".
Addition
Symbolic Notation: P ⊢ (P ∨ Q)
Explanation:
This rule says that if P is true, then P or Q is true. The symbol "∨" means " or".
Simplification
Explanation:
The symbol "∧" means " and", so (P ∧ Q) means "both P and Q are true". This
rule can be read as "If both P and Q are true, then P is true".
Resolution
Explanation:
This rule can be read as "If either P or Q is true, and not-P or R is true,
then Q or R is true". The symbol "¬" means "not", and the symbol "∨" means "
or".
6.What is the first-order logic and how is it different from propositional logic?
Ans:-
Components:
1. Predicates: Functions that return true or false based on the inputs. For
example, Loves(x,y)\text{Loves}(x, y)Loves(x,y) could indicate that
person xxx loves person yyy.
2. Quantifiers:
o Universal Quantifier (∀): Indicates that a statement applies to all
elements in a domain (e.g., "For all xxx, P(x)P(x)P(x)" means PPP
is true for every xxx).
o Existential Quantifier (∃): Indicates that there exists at least one
element in the domain for which the statement is true (e.g., "There
exists an xxx such that P(x)P(x)P(x)").
3. Variables: Symbols that can represent objects in the domain (e.g., x,y,zx,
y, zx,y,z).
4. Constants: Specific objects in the domain (e.g., "Alice", "Bob").
5. Functions: Mappings from objects to other objects (e.g., a function that
returns the mother of a person).
1. Expressiveness:
o Propositional Logic: Deals only with whole statements
(propositions) that can be true or false. It cannot express
relationships between objects or quantify over them.
o First-Order Logic: Can express complex statements involving
relationships between objects and allows for the quantification of
variables.
2. Structure:
o Propositional Logic: Uses simple propositions (e.g., PPP, QQQ)
combined with logical connectives (AND, OR, NOT).
o First-Order Logic: Uses predicates, functions, and quantifiers to
create more intricate and detailed expressions.
3. Domain of Discourse:
o Propositional Logic: Does not specify a domain of discourse; it
operates on abstract propositions.
o First-Order Logic: Operates over a specified domain of objects,
allowing reasoning about those objects and their properties.
4. Inference:
o Propositional Logic: Inferences are limited to the combinations of
true or false statements without deeper analysis of the
relationships.
o First-Order Logic: Enables richer inference capabilities due to the
ability to quantify and express relations, making it suitable for
more complex reasoning tasks.
Example Comparison
Propositional Logic:
o Statement: "It is raining." (represented as PPP)
First-Order Logic:
o Statement: "All humans are mortal." (represented as
∀x(Human(x)→Mortal(x))\forall x (\text{Human}(x) \rightarrow
\text{Mortal}(x))∀x(Human(x)→Mortal(x)))
Conclusion
Example:
A
A -> B
B
—————————–
He is running.
If he is running, he sweats.
He is sweating.
Backward Chaining:
In this, the inference system knows the final decision or goal, this
system starts from the goal and works backwards to determine what
facts must be asserted so that the goal can be achieved, i.e it works
from goal(final decision) and reaches the initial state.
Example:
B
A -> B
A
—————————–
He is sweating.
If he is running, he sweats.
He is running.
Slow as it has to use all the Fast as it has to use only a few
6.
rules. rules.
Types of Reasoning
1. Deductive Reasoning:
o Definition: This type of reasoning involves drawing specific
conclusions from general premises or rules. If the premises are
true, the conclusion must also be true.
o Example:
Premise 1: All humans are mortal.
Premise 2: Socrates is a human.
Conclusion: Therefore, Socrates is mortal.
2. Inductive Reasoning:
o Definition: Inductive reasoning involves making generalizations
based on specific observations or instances. It does not guarantee a
true conclusion but provides probable conclusions based on
evidence.
o Example:
Observation: The sun has risen in the east every day.
Conclusion: The sun will rise in the east tomorrow.
3. Abductive Reasoning:
o Definition: This type of reasoning is used to form the best
explanation for a set of observations. It involves inferring the most
likely cause or explanation from the available evidence.
o Example:
Observation: The grass is wet.
Possible Explanation: It rained last night (or someone
watered the lawn).
Importance of Reasoning in AI
Applications of Reasoning in AI
Challenges in Reasoning
Conclusion
Ans:-
Types of Reasoning in AI
The reasoning is classified into the following types:
1. Deductive Reasoning
Deductive reasoning follows a top-down approach where conclusions
are drawn from general principles or premises that are known or
assumed to be true. This form of reasoning relies on established facts
to infer valid conclusions.
Example: If all humans are mortal, and Socrates is a human, then
Socrates is mortal.
Application in AI: Deductive reasoning is often used in expert systems
and rule-based AI systems, where knowledge is represented through
rules (if-then statements). These systems apply general rules to
specific problems to derive solutions or make decisions.
2. Inductive Reasoning
Inductive reasoning is a bottom-up approach that involves drawing
general conclusions from specific instances or observations. Unlike
deductive reasoning, inductive reasoning generates hypotheses rather
than certain conclusions, making it more probabilistic.
Example: If we observe that the sun rises in the east every day, we
may infer that the sun will rise in the east tomorrow.
Application in AI: Inductive reasoning is widely used in machine
learning algorithms. Models trained on data patterns generalize from
the data and use this information to make predictions about new,
unseen data.
3. Abductive Reasoning
Abductive reasoning starts with an incomplete set of observations
and then seeks the most plausible explanation. It focuses on finding the
most likely conclusion based on what is known, rather than seeking an
absolute truth.
Example: If a patient has a fever and cough, a doctor might
hypothesize that they have the flu, even though other illnesses could
cause similar symptoms.
Application in AI: Abductive reasoning is used in diagnostic systems,
such as medical diagnosis tools or fault detection systems, where the
goal is to identify the most probable cause of a problem given
incomplete data.
4. Analogical Reasoning
Analogical reasoning compares two situations that share similarities,
using knowledge from one domain to solve problems in another. This
reasoning allows AI systems to draw parallels between similar
scenarios.
Example: If flying a drone is similar to piloting a helicopter, knowledge
gained from helicopter control can be applied to drones.
Application in AI: Analogical reasoning is useful in AI for problem-
solving, decision-making, and knowledge transfer, especially in robotics
and cognitive systems.
5. Common Sense Reasoning
Common sense reasoning relies on everyday knowledge and
experiences to draw conclusions. It simulates how humans use
common sense to handle day-to-day situations, which is often
challenging for AI due to the implicit nature of this knowledge.
Example: If it rains, we can expect the ground to get wet, even without
explicitly stating it.
Application in AI: AI systems like conversational agents (e.g., Siri,
Alexa) are being developed to incorporate commonsense reasoning to
handle more natural and complex user interactions effectively.
6. Monotonic Reasoning
Monotonic reasoning refers to a form of reasoning where conclusions,
once drawn, cannot be reversed, even if new information becomes
available. This ensures that conclusions remain consistent regardless
of updates to the knowledge base.
Example: The statement “The Sahara is a desert” remains true even if
more information about the world’s deserts is introduced.
Application in AI: Monotonic reasoning is applied in conventional
reasoning systems and logic-based AI, where consistency is critical.
Systems like formal verification tools rely on this type of reasoning to
ensure that conclusions do not change over time.
7. Nonmonotonic Reasoning
In contrast to monotonic reasoning, nonmonotonic reasoning allows
AI systems to revise conclusions when new information becomes
available. This is especially useful in dynamic environments where the
knowledge base is continuously updated.
Example: Initially concluding that all birds can fly, but revising this
conclusion upon learning about penguins, which cannot fly.
Application in AI: Nonmonotonic reasoning is used in AI for dynamic
decision-making systems that adapt to changing environments or new
information, such as real-time traffic management or adaptive learning
systems.
8. Fuzzy Reasoning
Fuzzy reasoning handles uncertainty and imprecision by allowing
degrees of truth rather than binary true/false outcomes. This makes it
well-suited for real-world scenarios where data can be ambiguous or
incomplete.
Example: In human language, statements like “It is warm outside” are
vague. Fuzzy reasoning might assign a degree of truth, such as 0.7
warm, rather than strictly true or false.
3. Noise in Data
4. Dynamic Environments
5. Probabilistic Reasoning
7. Interpretability
8. Ethical Considerations
1. Handling Uncertainty
7. Robustness to Errors
Probabilistic reasoning can make systems more robust to errors and variations
in input. By accounting for uncertainty, AI systems can often provide more
reliable outputs even when the input data is imperfect.
9. Real-World Applications
Conclusion