AI Knowledge
Problems
Knowledge in AI
Humans reason based on existing knowledge and draw conclusions. The
concept of representing knowledge and drawing conclusions from it is also
used in AI, and in this lecture we will explore how we can achieve this behavior.
"How do you know that fire is dangerous?"
"Because you’ve learned that fire burns — that’s knowledge.“
Humans use knowledge (like facts, rules, past experiences) to:
Interpret situations
Make decisions
Solve problems
AI does the same thing using something called Knowledge Representation (KR).
What is Knowledge Representation?
• "Knowledge representation is the field of AI dedicated to representing
information about the world in a form that a computer system can
utilize to solve complex tasks.“
• Knowledge Representation (KR) is a core area in AI that focuses on
how to represent information about the real world so that a
computer can use it to act intelligently. It deals with encoding facts,
rules, relationships, and heuristics into a format that machines can
process.
• Think of it as building a map of knowledge that an AI system can
consult and reason over to make decisions or draw conclusions.
Why is it Important?
"Enables reasoning, learning, and decision-making.“
KR is not just about storing data — it’s about storing meaningful knowledge
in a way that supports:
• Reasoning: AI can infer new facts or detect inconsistencies.
• Learning: AI can build upon existing knowledge.
• Decision-making: AI can make informed choices based on represented
knowledge.
For example, in a medical diagnosis system:
• Facts: “Fever and sore throat are symptoms of flu.”
• Inference: If a patient has these symptoms, they might have the flu.
Real-World Analogy
• Imagine trying to teach a robot how to behave like a doctor, a lawyer,
or a driver. How do you give it all the knowledge it needs? That’s
where Knowledge Representation comes in — it’s the process of
‘feeding’ the robot facts, rules, and logic so it can think and act
smart.“
"Knowledge Representation is how AI stores information about the
world in a format that a machine can understand and use to make
decisions.“
AI is useless if it doesn’t know anything. KR helps AI to:”Understand the
world ,Make decisions, Reason like a human, Learn new things.
• Example 1: • Example 2:
• ChatGPT / Google Assistant • Netflix / Amazon
• When you ask “What’s the • Netflix recommends movies by
capital of France?”, understanding:What you like
• it already knows that:“France” is (e.g., action movies)
a country • What others like who are similar
• “capital” refers to the main city to you
• The answer is “Paris” • Relationships between movies
This knowledge is stored, related, and used — that’s KR in action!
Types of KR
• “If you had to teach a robot to order food online, what knowledge
would you need to represent?”
The cycle of knowledge representation in AI refers to the iterative process through which AI systems perceive, learn, represent, and apply knowledge to
make informed decisions. This cycle is essential for building intelligent systems capable of reasoning and interacting with their environment. Here are the
key stages of this cycle:
1. Perception
• Description: The process begins with AI systems perceiving data from their environment. This data could come from sensors, cameras, user inputs, or
databases.
• Example: A self-driving car uses sensors to perceive its surroundings, such as detecting pedestrians and other vehicles.
2. Learning
• Description: After perceiving data, the system learns by identifying patterns, relationships, and trends from the data. This can involve supervised
learning, unsupervised learning, or reinforcement learning techniques.
• Example: An AI algorithm can learn from historical sales data to predict future trends, helping businesses make data-driven decisions.
3. Knowledge Representation & Reasoning
• Description: In this stage, the system organizes the learned data into structured knowledge, allowing it to reason and draw conclusions. This is where
the AI uses knowledge representation techniques to encode the information it has learned.
• Example: A medical diagnosis system represents symptoms, diseases, and treatments as structured knowledge and uses reasoning to suggest the best
treatment based on a patient’s symptoms.
4. Planning
• Description: The system uses the represented knowledge to plan actions based on goals and constraints. Planning involves selecting the best course of
action based on the available knowledge.
• Example: In robotics, AI systems use planning to determine the most efficient path for a robot to navigate through a room while avoiding obstacles.
5. Execution
• Description: Finally, the system executes the planned actions, completing the cycle. After execution, the AI system can receive feedback and adjust its
knowledge and actions accordingly.
• Example: A robot executing the planned actions to pick up and move objects based on the knowledge it has about the environment.
Types of Knowledge Rep
Approaches to Knowledge
Representation
AI systems use different approaches to represent knowledge depending on the nature of the problem and the type
of information they need to handle. Here are some key approaches to knowledge representation in AI:
1. Simple Relational Knowledge
• Description: This approach represents knowledge as simple facts in the form of relations between entities. It
uses tables or relational databases to store information about objects and their relationships.
• Example: A table in a database could store the relationship between students and their courses, with columns
for student names, course names, and grades.
• Strengths: Straightforward and easy to implement, especially in structured environments like databases.
• Weaknesses: Lacks the ability to handle complex relationships or hierarchies.
“This is like storing data in tables — facts about things and how they relate.”
2. Inheritable Knowledge
• Description: Inheritable knowledge uses hierarchies and inheritance to represent general and specific
information about objects. This approach allows entities to inherit properties from higher-level categories.
• Example: In a knowledge base, a “dog” might inherit properties from the more general category “mammal,”
such as being warm-blooded and having fur.
• Strengths: Efficient in representing hierarchical knowledge and reducing redundancy by reusing information.
• Weaknesses: Can be challenging to represent exceptions or unique cases that don’t follow the inheritance
structure.
3. Procedural Knowledge
• Description: Procedural knowledge defines sequences of actions or steps needed to accomplish specific
tasks. It focuses on “how to” knowledge rather than “what is.”
• Example: An AI system for controlling a robot might use procedural knowledge to define the steps required
for the robot to pick up an object: locate the object, move towards it, and grip it with an arm.
• Strengths: Useful for automating tasks and guiding AI systems through well-defined procedures.
• Weaknesses: Not suitable for tasks requiring complex reasoning or flexible decision-making.
• “If you had to teach a robot to order food online, what knowledge
would you need to represent?”
• Menu items
• Payment methods
• Location
• User preferences
4. Inferential Knowledge
• Description: This approach involves representing knowledge in a way that allows
the AI to infer new information from existing facts and rules. Logical reasoning is
applied to draw conclusions.
• Example: Given the facts “All humans are mortal” and “Socrates is a human,” an
AI system using inferential knowledge can infer that “Socrates is mortal.”
• Strengths: Enables AI systems to apply logical reasoning and make deductions.
• Weaknesses: Can be computationally expensive and may struggle with
incomplete or uncertain information.
Knowledge-Based Agents
An agent in AI is anything that perceives its environment and acts accordingly.
A knowledge-based agent (KBA):
•Stores knowledge about the world (facts, rules)
•Uses inference to draw conclusions or make decisions
Imagine a doctor. They don’t guess randomly — they use knowledge of diseases, symptoms,
test results, etc.
A knowledge-based AI agent does something similar.
• Let’s start answering this with a Harry Potter example. Consider the
following sentences:
• If it didn’t rain, Harry visited Hagrid today.
• Harry visited Hagrid or Dumbledore today, but not both.
• Harry visited Dumbledore today.
Based on these three sentences, we can answer the question “did it rain
today?”, even though none of the individual sentences tells us anything
about whether it is raining today. Here is how we can go about it: looking at
sentence 3, we know that Harry visited Dumbledore.
Looking at sentence 2, we know that Harry visited either Dumbledore or
Hagrid, and thus we can conclude
• Let’s start answering this with a Harry Potter example. Consider the following sentences:
• If it didn’t rain, Harry visited Hagrid today.
• Harry visited Hagrid or Dumbledore today, but not both.
• Harry visited Dumbledore today.
Based on these three sentences, we can answer the question “did it rain today?”, even though none of
the individual sentences tells us anything about whether it is raining today. Here is how we can go
about it: looking at sentence 3, we know that Harry visited Dumbledore.
Looking at sentence 2, we know that Harry visited either Dumbledore or Hagrid, and thus we can
conclude
• Harry did not visit Hagrid.
Now, looking at sentence 1, we understand that if it didn’t rain, Harry would have visited Hagrid.
However, knowing sentence 4, we know that this is not the case. Therefore, we can conclude
• It rained today.
To come to this conclusion, we used logic, and this unit explores how AI can use logic to reach to new
conclusions based on existing information.
Propositional Logic
• One way of representing knowledge is using logical rules — especially
propositional logic.
• Propositional Logic (also called Boolean logic or sentential logic) is a
type of logic that deals with propositions — statements that can be
either true or false, but not both.
• Propositional logic is based on propositions, statements about the
world that can be either true or false
• Propositional Symbols
Propositional symbols are most often letters (P, Q, R) that are used to
represent a proposition.
Logical Connectives
• Logical connectives are logical symbols that connect propositional
symbols in order to reason in a more complex way about the world.
It is worthwhile to mention that there are two types of Or: an inclusive Or and an exclusive Or. In an
exclusive Or, P ∨ Q is false if P ∧ Q is true. That is, an exclusive Or requires only one of its arguments
to be true and not both. An inclusive Or is true if any of P, Q, or P ∧ Q is true. In the case of Or ( ∨),
the intention is an inclusive Or.
What is Propositional Logic in
Artificial Intelligence?
• Propositional Logic is a fundamental part of AI that deals with reasoning
using declarative statements. These statements are either true or false, helping AI
systems process facts and make decisions logically. By breaking down complex reasoning
into simple propositions, AI systems can solve puzzles, represent knowledge, and make
automated decisions efficiently.
• Propositional Logic (PL) is a branch of logic that focuses on statements
(propositions) that can be either true or false. It is also known as Boolean logic since the
truth values are binary—either True (1) or False (0).
• In AI, propositional logic forms the foundation for logical reasoning, allowing systems to
represent facts and rules about a problem domain. These rules help the system infer new
information or make decisions based on the given inputs.
• Propositional logic simplifies knowledge representation by breaking down
reasoning into atomic statements or propositions. For example, an AI
system used in home automation might have propositions such as:
• P: “The light is on.”
• Q: “The window is open.”
• Using logical connectives, the system can combine these propositions to
represent more complex statements like:
“If the light is on and the window is open, turn off the light.”
• By using propositional logic, AI systems can reason effectively and perform
tasks like automated decision-making, knowledge representation,
and game playing.
Basic Facts About Propositional Logic
1. Propositions are Declarative Statements:
• In propositional logic, each statement, known as a proposition, is either True or False.
Example:
• P: “It is raining.” (True or False)
• Q: “The heater is on.” (True or False)
2. Atomic Propositions:
• These are simple, indivisible statements that cannot be broken down further. Each atomic proposition
represents a basic fact or condition.
Example: “The door is closed.”
3. Compound Propositions:
• Multiple atomic propositions can be combined using logical connectives (like AND, OR, NOT) to
create compound propositions.
Example: “The door is closed AND the heater is on.”
• 4. Binary Truth Values:
• Every proposition has a binary truth value: it can only be True (1) or False (0). There are no
intermediate states. This simplicity makes propositional logic ideal for clear-cut decisions.
• 5. Logical Connectives Combine Propositions:
• Logical connectives such as AND, OR, NOT, IF-THEN, and IF AND ONLY IF allow us to create more
Syntax of Propositional Logic
• The syntax of propositional logic defines the rules for creating valid
propositions. In propositional logic, we combine atomic propositions
using logical connectives to form more complex statements, known as
compound propositions.
Building Blocks of Propositional
Logic Syntax
Logical Connectives in Propositional Logic
• Logical connectives are essential operators that combine atomic propositions to
form compound propositions. These connectives allow AI systems to build more
complex rules and perform logical reasoning. Below are the most common
connectives used in propositional logic:
• Logical connectives are logical symbols that connect propositional symbols in order
to reason in a more complex way about the world.
• Not (¬) inverses the truth value of the proposition. So, for example, if P: “It is
raining,” then ¬P: “It is not raining”.
Truth tables are used to compare all possible truth assignments to propositions. This
tool will help us better understand the truth values of propositions when connected
with different logical connectives. For example, below is our first truth table:
• And (∧) connects two different propositions. When these two proposition,
P and Q, are connected by ∧, the resulting proposition P ∧ Q is true only
in the case that both P and Q are true.
• Or (∨) is true as as long as either of its arguments is true. This means that
for P ∨ Q to be true, at least one of P or Q has to be true.
• Implication (→) represents a structure of “if P then Q.”
• For example, if P: “It is raining”
Q: “I’m indoors”,
then P → Q means “If it is raining, then I’m indoors.”
In the case of P implies Q (P → Q), P is called the antecedent and Q is called the consequent.
When the antecedent is true, the whole implication is true in the case that the consequent is
true (that makes sense: if it is raining and I’m indoors, then the sentence “if it is raining, then I’m
indoors” is true).
When the antecedent is true, the implication is false if the consequent is false (if I’m outside
while it is raining, then the sentence “If it is raining, then I’m indoors” is false).
However, when the antecedent is false, the implication is always true, regardless of
the consequent. This can sometimes be a confusing concept. Logically, we can’t learn anything
from an implication (P → Q) if the antecedent (P) is false. Looking at our example, if it is not
raining, the implication doesn’t say anything about whether I’m indoors or not. I could be an
indoors type and never walk outside, even when it is not raining, or I could be an outdoors type
and be outside all the time when it is not raining. When the antecedent is false, we say that the
implication is trivially true.
• Biconditional (↔) is an implication that goes both directions. You can
read it as “if and only if.”
• P ↔ Q is the same as P → Q and Q → P taken together.
• For example, if P: “It is raining.” and Q: “I’m indoors,”
• then P ↔ Q means that “If it is raining, then I’m indoors,” and “if I’m
indoors, then it is raining.”
• This means that we can infer more than we could with a simple
implication. If P is false, then Q is also false; if it is not raining, we
know that I’m also not indoors.
Model
• The model is an assignment of a truth value to every proposition. To
reiterate, propositions are statements about the world that can be
either true or false. However, knowledge about the world is
represented in the truth values of these propositions. The model is
the truth-value assignment that provides information about the
world.
Example
• For example, if P: “It is raining.” and Q: “It is Tuesday.”,
• a model could be the following truth-value assignment: {P = True, Q =
False}.
• This model means that it is raining, but it is not Tuesday. However,
there are more possible models in this situation (for example, {P =
True, Q = True}, where it is both raining an a Tuesday).
• In fact, the number of possible models is 2 to the power of the
number of propositions.
• In this case, we had 2 propositions, so 2²=4 possible models.
P∨Q (It is raining or it is Tuesday)
¬∨ (If it’s raining, then it is Tuesday)
¬𝑃∨𝑄
Conditional Statements
Create a KB for (¬p q) ∨(q ∧ r )
Compound prepositions Truth Table
Model
• The model is an assignment of a truth value to every proposition. To
reiterate, propositions are statements about the world that can be either
true or false. However, knowledge about the world is represented in the
truth values of these propositions. The model is the truth-value assignment
that provides information about the world.
• For example, if P: “It is raining.” and Q: “It is Tuesday.”, a model could be the
following truth-value assignment: {P = True, Q = False}. This model means
that it is raining, but it is not Tuesday. However, there are more possible
models in this situation (for example, {P = True, Q = True}, where it is both
raining an a Tuesday). In fact, the number of possible models is 2 to the
power of the number of propositions. In this case, we had 2 propositions, so
2²=4 possible models.
Knowledge Base (KB)
• The knowledge base is a set of sentences known by a knowledge-
based agent. This is knowledge that the AI is provided about the
world in the form of propositional logic sentences that can be used to
make additional inferences about the world.
Entailment (⊨)
• If α ⊨ β (α entails β), then in any world where α is true, β is true, too.
• For example, if α: “It is a Tuesday in January” and β: “It is January,”
then we know that α ⊨ β. If it is true that it is a Tuesday in January,
we also know that it is January.
• Entailment is different from implication.
• Implication is a logical connective between two propositions.
• Entailment, on the other hand, is a relation that means that if all the
information in α is true, then all the information in β is true.
Inference
• Inference is the process of deriving new sentences from old ones.
• For instance, in the Harry Potter example earlier, sentences 4 and 5
were inferred from sentences 1, 2, and 3.
Model Checking algorithm.
To determine if KB ⊨ α (in other words, answering the question: “can
we conclude that α is true based on our knowledge base”)
• Enumerate all possible models.
• If in every model where KB is true, α is true as well, then KB entails α (KB ⊨
α).
Consider the following example:
• P: It is a Tuesday. Q: It is raining. R: Harry will go for a run. KB: (P ∧ ¬Q) → R (in words, P and not Q imply R) P (P is true) ¬Q (Q is
false) Query: R (We want to know whether R is true or false; Does KB ⊨ R?)
• To answer the query using the Model Checking algorithm, we enumerate all possible models.
Then, we go through every model and check whether it is true
given our Knowledge Base.
• First, in our KB, we know that P is true. Thus, we • Next, similarly, in our KB, we know that Q is false. Thus,
can say that the KB is false in all models where P is we can say that the KB is false in all models where Q is
not true. true.
• Finally, we are left with two models. In both, P is true and Q is false. In one model R is true and in
the other R is false. Due to (P ∧ ¬Q) → R being in our KB, we know that in the case where P is true
and Q is false, R must be true. Thus, we say that our KB is false for the model where R is false, and
true for the model where R is true.
Looking at this table, there is only one model where our knowledge base is true. In this model, we see that R
is also true. By our definition of entailment, if R is true in all models where the KB is true, then KB ⊨ R.
Q1
Q2
Q3
Q4
Q4
Q5
Q6
Q7
Model Checking & Truth Tables —
Cheat Sheet