0% found this document useful (0 votes)
12 views

Unit 4

Uploaded by

shopping6270
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Unit 4

Uploaded by

shopping6270
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

Unit 4

Knowledge Representation -Knowledge based agents –


The Wumpus world – Propositional Logic - syntax,
semantics and knowledge base building - inferences –
reasoning patterns in propositional logic – predicate logic
– representing facts in logic: Syntax and semantics –
Unification – Unification Algorithm - Knowledge
representation using rules - Knowledge representation
using semantic nets - Knowledge representation using
frames inferences - Uncertain Knowledge and reasoning
Methods
Knowledge and Reasoning
• Knowledge representation and reasoning (KR, KRR) is the part of Artificial
intelligence which is concerned with AI agents thinking and how thinking
contributes to intelligent behavior of agents.
• It is responsible for representing information about the real world so that a
computer can understand and can utilize this knowledge to solve the complex
real world problems such as diagnosis a medical condition or communicating
with humans in natural language.
• It is also a way which describes how we can represent knowledge in artificial
intelligence.
• Knowledge representation is not just storing data into some database, but it
also enables an intelligent machine to learn from that knowledge and
experiences so that it can behave intelligently like a human.
Knowledge and Reasoning
Kind of Knowledge which needs to be represented in AI
systems:
• Object: All the facts about objects in our world domain.
• E.g., Guitars contains strings, trumpets are brass instruments.
• Events: Events are the actions which occur in our world.
• Performance: It describe behavior which involves knowledge
about how to do things.
• Meta-knowledge: It is knowledge about what we know.
• Facts: Facts are the truths about the real world and what we
represent.
• Knowledge-Base: The central component of the knowledge-
based agents is the knowledge base. It is represented as KB.
Different Types of
Knowledge • Declarative Knowledge – It includes concepts,
facts, and objects and expressed in a
declarative sentence.
• Structural Knowledge – It is a basic problem-
solving knowledge that describes the
relationship between concepts and objects.
• Examples include family relations, social relations,
administrative organizations, etc.
• Procedural Knowledge – This is responsible for
knowing how to do something and includes
rules, strategies, procedures, etc.
• mobile robot that navigates in a building, contain
procedures such as "navigate to a room" or "plan
a path".
• Meta Knowledge – Meta Knowledge defines
knowledge about other types of Knowledge.
• methods of planning, modeling, tagging, learning
and every modification
• Heuristic Knowledge – This represents some
expert knowledge in the field or subject.
• a hypothesis, common sense, rule of thumb,
Cycle of Knowledge Representation in AI
• The Perception component retrieves data or
information from the environment.
• The Learning Component that learns from the
captured data by the perception component.
• The main component in the cycle is Knowledge
Representation and Reasoning which shows the
human-like intelligence in the machines. Knowledge
representation is all about understanding intelligence.
• The Planning and Execution components depend on
the analysis of knowledge representation and
reasoning. Here, planning includes giving an initial
state, finding their preconditions and effects, and a
sequence of actions to achieve a state in which a
particular goal holds. Now once the planning is
completed, the final stage is the execution of the
entire process.
Approaches to knowledge Representation
• Representational adequacy: It is the ability to represent all of the kinds of
knowledge that are needed in that domain.
• Inferential Adequacy: The ability to manipulate the representation
structures in such a way as to derive new structures corresponding to
new knowledge inferred from old.
• Inferential Efficiency: The ability to incorporate into the knowledge
structure additional information that can be used to focus the attention of
the inference mechanism in the most promising directions.
• Acquisitioned Efficiency: The ability to acquire new information easily.
The simplest case involves direct insertion by a person of new
knowledge into the database.
Issues in Knowledge Representation
Issues in Knowledge Representation
1.Attributes are the most important ones that have an impact on the representation. It is required to understand
and identify the important attributes. This helps in absorbing the important parameters for the KB
representation.

2. Similarly, identifying the relationships among the attributes in the representation is equally important.
Reasoning about values that are taken up also adds up complexities in the selection process. Hence, proper
selection of the attributes impacts the relationships.

3. Handling the issue of level or up to what depth the mapping of the knowledge is to be done defines the
granularity. This is governed by the availability of facts and the level upto which it is possible to split them and
represent them. Sometimes, splitting can prove to be an option to handle the issue, making the easy
accessibility, but sometimes, it adds complexities to handle the data.

4. Further, the issue is representation of the objects as sets.

5. Finally, selection of correct structure is the most important part to have a proper representation
Various levels of knowledge-based agents
1. Knowledge level
• Knowledge level is the first level of knowledge-based agent, and in this level, we need to specify what the agent
knows, and what the agent goals are.
• With these specifications, we can fix its behavior.
• For example, suppose an automated taxi agent needs to go from a station A to station B, and he knows the way
from A to B, so this comes at the knowledge level.
2. Logical level
• At this level, we understand that how the knowledge representation of knowledge is stored.
• At this level, sentences are encoded into different logics, and encoding of knowledge into logical sentences occurs.
• At the logical level we can expect to the automated taxi agent to reach to the destination B.

3. Implementation level
• This is the physical representation of logic and knowledge.
• At the implementation level agent perform actions as per logical and knowledge level.
• At this level, an automated taxi agent actually implement his knowledge and logic so that he can reach to the
destination.
Wumpus world
• The Wumpus world is a simple world example to illustrate the worth of a knowledge-based agent and to
represent knowledge representation.
• It was inspired by a video game Hunt the Wumpus by Gregory Yob in 1973.

The Wumpus world is a cave which has 4/4 rooms connected with passageways. So there are total 16 rooms
which are connected with each other. We have a knowledge-based agent who will go forward in this world. The
cave has a room with a beast which is called Wumpus, who eats anyone who enters the room. The Wumpus can
be shot by the agent, but the agent has a single arrow. In the Wumpus world, there are some Pits rooms which are
bottomless, and if agent falls in Pits, then he will be stuck there forever. The exciting thing with this cave is that
in one room there is a possibility of finding a heap of gold. So the agent goal is to find the gold and climb out the
cave without fallen into Pits or eaten by Wumpus. The agent will get a reward if he comes out with gold, and he
will get a penalty if eaten by Wumpus or falls in the pit.
Wumpus World
There are also some components which can
help the agent to navigate the cave. These
components are given as follows:
• The rooms adjacent to the Wumpus room
are smelly, so that it would have some
stench.
• The room adjacent to PITs has a breeze, so
if the agent reaches near to PIT, then he
will perceive the breeze.
• There will be glitter in the room if and only
if the room has gold.
• The Wumpus can be killed by the agent if
the agent is facing to it
• Wumpus will emit a horrible scream which
can be heard anywhere in the cave.
PEAS description of Wumpus world:
Performance measure: Actuators:
• Left turn,
• +1000 reward points if the agent comes out of
• Right turn
the cave with the gold. • Move forward
• -1000 points penalty for being eaten by the • Grab
Wumpus or falling into the pit. • Release
• Shoot.
• -1 for each action, and -10 for using an arrow. Sensors:
• The game ends if either agent dies or came • The agent will perceive the stench if he is in the
out of the cave. room adjacent to the Wumpus. (Not diagonally).
• The agent will perceive breeze if he is in the
Environment: room directly adjacent to the Pit.
• A 4*4 grid of rooms. • The agent will perceive the glitter in the room
where the gold is present.
• The agent initially in room square [1, 1], facing • The agent will perceive the bump if he walks
toward the right. into a wall.
• Location of Wumpus and gold are chosen • When the Wumpus is shot, it emits a horrible
randomly except the first square [1,1]. scream which can be perceived anywhere in the
cave.
• Each square of the cave can be a pit with
probability 0.2 except the first square.
The Wumpus world Properties

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


agent can only perceive the close environment such as an adjacent room.
• Deterministic: It is deterministic, as the result and outcome of the world are
already known.
• Sequential: The order is important, so it is sequential.
• Static: It is static as Wumpus and Pits are not moving.
• Discrete: The environment is discrete.
• One agent: The environment is a single agent as we have one agent only and
Wumpus is not considered as an agent.
Wumpus World Agent's First step:
Now agent needs to move forward, so it will
either move to [1, 2], or [2,1]. Let's suppose
agent moves to the room [2, 1], at this room
agent perceives some breeze which means
Pit is around this room. The pit can be in [3,
1], or [2,2], so we will add symbol P? to say
that, is this Pit room?

Agent’s Second step:


Now agent will stop and think and will not
make any harmful move. The agent will go
back to the [1, 1] room. The room [1,1], and
[2,1] are visited by the agent, so we will use
symbol V to represent the visited squares.
Wumpus World Agent’s third step:
At the third step, now agent will move to the room
[1,2] which is OK. In the room [1,2] agent perceives
a stench which means there must be a Wumpus
nearby. But Wumpus cannot be in the room [1,1] as
by rules of the game, and also not in [2,2] (Agent had
not detected any stench when he was at [2,1]).
Therefore agent infers that Wumpus is in the room
[1,3], and in current state, there is no breeze which
means in [2,2] there is no Pit and no Wumpus. So it
is safe, and we will mark it OK, and the agent moves
further in [2,2].

Agent's fourth step:


At room [2,2], here no stench and no breezes present
so let's suppose agent decides to move to [2,3]. At
room [2,3] agent perceives glitter, so it should grab
the gold and climb out of the cave.
Propositional logic in Artificial intelligence
• Propositional logic (PL) is the simplest form of logic where all the
statements are made by propositions. A proposition is a declarative
statement which is either true or false. It is a technique of knowledge
representation in logical and mathematical form.
Example:
• a) It is Sunday.
• b) The Sun rises from West (False proposition)
• c) 3+3= 7(False proposition)
• d) 5 is a prime number.
Basic facts about propositional logic:
• Propositional logic is also called Boolean logic as it works on 0 and 1.
• In propositional logic, we use symbolic variables to represent the logic, and we can use
any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
• Propositions can be either true or false, but it cannot be both.
• Propositional logic consists of an object, relations or function, and logical connectives.
• These connectives are also called logical operators
• Connectives can be said as a logical operator which connects two sentences.
• A proposition formula which is always true is called Tautology.
• A proposition formula which is always false is called Contradiction.
• A proposition formula which is true for some model is called Satisfiability.
• Statements which are questions, commands, or opinions are not propositions such as
"Where is Rohini", "How are you", "What is your name", are not propositions.
Syntax of propositional logic
• The syntax of propositional logic defines the allowable sentences for the knowledge representation.
There are two types of Propositions:
• Atomic Propositions
• Compound propositions
Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single
proposition symbol. These are the sentences which must be either true or false.
Example:
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
Compound proposition: Compound propositions are constructed by combining simpler or atomic
propositions, using parenthesis and logical connectives.
Example:
a) "It is raining today, and street is wet."
b) "Ankit is a doctor, and his clinic is in Mumbai."
Logical Connectives
Logical connectives are used to connect two simpler propositions or representing a
sentence logically. We can create compound propositions with the help of logical
connectives. There are mainly five connectives, which are given as follows:
• Negation: A sentence such as ¬ P is called negation of P. A literal can be either
Positive literal or negative literal.
• Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a
conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
• Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction,
where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
Logical Connectives

• Implication: A sentence such as P → Q, is called an implication. Implications are


also known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
• Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If
I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Truth Table
Truth Table:
Truth table with three propositions:
We can build a proposition composing three propositions P, Q, and R. This truth table is made-up of
8n Tuples as we have taken three proposition symbols.
Semantics of Propositional Logic
Semantics tells us about the rules to determine the truth of
the sentence.
Precedence of connectives:
Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators.
This order should be followed while evaluating a propositional problem. Following is the list of the
precedence order for operators:
Properties of Propositional Operators

• Commutativity:
• P ∧ Q= Q ∧ P, or
• P ∨ Q = Q ∨ P.
• Associativity:
• (P ∧ Q) ∧ R = P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R).
• Identity element:
• P ∧ True = P,
• P ∨ True= True.
• Distributive:
• P ∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
• DE Morgan's Law:
• ¬(P ∧ Q) = (¬P) ∨ (¬Q),
• ¬(P ∨ Q) = (¬ P) ∧ (¬Q).
• Double-negation elimination:
• ¬(¬P) = P.
Propositional Logic - Reasoning
• The reasoning is the mental process of deriving logical conclusion
and making predictions from available knowledge, facts, and
beliefs.
• "Reasoning is a way to infer facts from existing data."
• It is a general process of thinking rationally, to find valid
conclusions.
Types of Reasoning
• Deductive reasoning
• Inductive reasoning
• Abductive reasoning
• Common Sense Reasoning
• Monotonic Reasoning
• Non-monotonic Reasoning
Propositional Logic - Reasoning
1. Deductive reasoning:

2. Inductive Reasoning:

3. Abductive reasoning:
Abductive reasoning is a form of logical reasoning which starts with single or
multiple observations then seeks to find the most likely explanation or conclusion
for the observation.
Example:
• Implication: Cricket ground is wet if it is raining
• Axiom: Cricket ground is wet.
Reasoning

4. Common Sense Reasoning


• Common sense reasoning is an informal form of reasoning, which can
be gained through experiences.
• It relies on good judgment rather than exact logic and operates
on heuristic knowledge and heuristic rules.
Example:
1.One person can be at one place at a time.
2.If I put my hand in a fire, then it will burn.
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.
Example:
• Earth revolves around the Sun.
Reasoning

6. Non-monotonic Reasoning
• In Non-monotonic reasoning, some conclusions may be
invalidated if we add some more information to our knowledge
base.
Example:
• Birds can fly
• Penguins cannot fly
• Pitty is a bird
• So from the above sentences, we can conclude that Pitty can
fly.
• However, if we add one another sentence into knowledge base
"Pitty is a penguin", which concludes "Pitty cannot fly", so it
invalidates the above conclusion.
Propositional Logic - Reasoning
1. If it didn’t rain, Harry visited Hagrid today.
2. Harry visited Hagrid or Dumbledore today, but not both.
3. Harry visited Dumbledore today.
• Looking at sentence 3, we know Harry visited Dumbledore.
• Looking at sentence 2, we know Harry visited either Dumbledore
or Hagrid, and thus we can conclude 4. 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 5. It rained today.
Inferences
• Inference signifies the art of drawing conclusions and making decisions by utilizing the
power of available information or data.
Inference rules:
• Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.
• Implication: It is one of the logical connectives which can be represented as P → Q. It is
a Boolean expression.
• 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.
• Contrapositive: The negation of converse is termed as contrapositive, and it can be
represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be represented as ¬ P → ¬
Q.
Inference Rules
Inference Rules in Proposition Logic
Types of Inference rules:

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

• Example:
• Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
• Statement-2: "I am sleepy" ==> P
• Conclusion: "I go to bed." ==> Q.
• Hence, we can say that, if P→ Q is true and P is true then
Q will be true.
Types of Inference rules:

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

Example
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P
Forward Chaining:

• Forward Chaining the Inference Engine goes through all the


facts, conditions and derivations before deducing the
outcome i.e When based on available data a decision is taken
then the process is called as Forwarding chaining, It works
from an initial state and reaches to the goal(final decision).
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.
Resolution
• Resolution was discovered by Alan Robinson in mid 1960s.
• Resolution is used, if there are various statements are
given, and we need to prove a conclusion of those
statements.
• Conjunctive normal form (CNF) is a Boolean logic
approach that expresses formulas as conjunctions
of clauses with an AND or OR.
• Resolution is one kind of proof technique that works this
way –
(i) select two clauses that contain conflicting terms
(ii) combine those two clauses and
(iii) cancel out the conflicting terms.
Resolution
Resolution
For example, we have following statements,
(1) If it is a pleasant day you will do
strawberry picking
(2) If you are doing strawberry picking
you are happy. 1) If it is a pleasant day – A
Above statements can be written in 2) Will do strawberry picking – B
propositional logic like this - 3) You are happy – C
Propositional logic
(1) strawberry_picking ← pleasant
4) AB
(2) happy ← strawberry_picking 5) BC
And again these statements can be written in CNF
CNF like this - 6) ҃ A v B
(1) (strawberry_picking ∨~pleasant) ∧ 7) ҃ B v C
(2) (happy ∨~strawberry_picking)
• By resolving these two clauses and cancelling
out the conflicting terms 'strawberry_picking'
and '~strawberry_picking', we can have one
new clause, ҃ AvC AC
• (3) ~pleasant ∨ happy
Resolution
For example, we have following statements,
(1) If it is a pleasant day you will do strawberry
picking
(2) If you are doing strawberry picking you are
happy.
Above statements can be written in propositional logic
like this -
(1) strawberry_picking ← pleasant
(2) happy ← strawberry_picking
And again these statements can be written in CNF like
this -
(1) (strawberry_picking ∨~pleasant) ∧
(2) (happy ∨~strawberry_picking)
• By resolving these two clauses and cancelling out the
conflicting terms 'strawberry_picking' and
'~strawberry_picking', we can have one new clause,
• (3) ~pleasant ∨ happy
Refutation
• Refutation proof method i.e. proof by contradiction using
Resolution.
• So for the asked goal we will negate the goal and will add it to
the given statements to prove the contradiction.
In the example,
• Part(I) represents the English meanings for the clauses,
• Part(II) represents the propositional logic statements for given
english sentences,
• Part(III) represents the Conjunctive Normal Form (CNF) of
Part(II)
• Part(IV) shows some other statements we want to prove using
Refutation proof method.
Resolution by Refutation
Resolution by Refutation
Refutation
Refutation
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.
• Propositional logic has limited expressive power.
• In propositional logic, we cannot describe statements in terms of their
properties or logical relationships.

You might also like