0% found this document useful (0 votes)
22 views57 pages

Logical Agents

Uploaded by

jamesfds007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views57 pages

Logical Agents

Uploaded by

jamesfds007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

LogicalAgents

1
LOGICAL AGENTS

2
“ In which we design agents that can form
representationsof the world, use a
process ofinferenceto derive new
representations about the world, and
use these new representations to
deducewhat to do.

3
4
▰ A knowledge
-based agent must be able to do the following:
▰ An agent should be able to represent states, actions, etc.
▰ An agent Should be able to incorporate new percepts
▰ An agent can update the internal representation of the world
▰ An agent can deduce the internal representation of the world
▰ An agent can deduce appropriate actions.

5
6
A knowledge
-based agent

▰ A knowledge -based agent includes a


knowledge base and an inference system.
▰ Kb- a set of representations of facts of the
world.
▰ sentence-Each individual representation

7
▰ Inference system - To add/update some new
information or sentences in the knowledge-
based system.
▰ Helps in making conclusions by applying
logical rules.

8
9
FUNCTIONS

▰ The MAKE -PERCEPT -


▰ MAKE-ACTION -
SENTENCE generates a
SENTENCE
sentence as setting that
generates a
the agent perceived the
sentence which
given percept at the given
asserts that the
time.
chosen action was
▰ The MAKE -ACTION -QUERY executed.
generates a sentence to

ask which action should be
carried out at the current 10
time.
A simple knowledge
-based agent

11
Various levels of
knowledge-based agent:

▰ Knowledge level - we need to specify what the


agent knows and the agent’s goals.
▰ Logical level
- knowledge will be encoded into
sentences .
▰ At the logical level, an encoding of
knowledge into logical sentences occurs

12
▰ Implementation level - agent perform actions
as per logical and knowledge level.

13
The Wumpus World environment

The agent always


starts in the field
[1,1].

The task of the


agent is to find
the gold, return to
the field [1,1] and
climb out of the
cave.
14
Components

▰ Agent:The entity that moves around the grid,


exploring and trying to achieve its goals.
▰ Wumpus:A dangerous creature that, if
encountered, will kill the agent. The Wumpus
is usually located in a specific grid cell, and
the agent must avoid that cell.

15
▰ Pits: Dangerous holes in the ground that will
cause the agent to fall and lose the game if it
steps into them. These are randomly placed
in the grid.
▰ Gold:The item the agent is trying to find.
Once found, the agent must return to the
starting position to win the game.

16
PEAS description of Wumpus world

▰ Performance measure:
▰ (+1000)
▰ (-1000)
▰ (-1)
▰ (-10)

17
▰ Environment
▰ 4X4 grid of rooms
▰ The player always starts in the square labeled
[1,1] and facing towards the right.

18
▰ Actuators
▰ Left turn,
▰ Right turn
▰ Move forward
▰ Grab
▰ Shoot
▰ Climb

19
▰ Sensors:
▰ Stench
▰ Breeze
▰ Glitter
▰ Bump
▰ Scream (shot Wumpus)

20
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
21
• 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.

22
Exploring the Wumpus world

23
Exploring the Wumpus world

24
Logic

▰ Logics are formal languages for representing information


such that conclusions can be drawn
▰ Propositional logic and predicate logic are examples of
formal logics
▰ Syntax- how symbo ls can be put together to form the
sentences in the language
▰ In propositional logic, the syntax defines how operators
like "∧" (and), ∨"
" (or), "¬" (not), and→"
" (implies) can be
combined with propositions to create well-formed
formulas. 25
▰ Semantics define the "meaning" of
sentences;
▻ i.e., define truth of a sentence in a world (given an
interpretation)

▰ E.g., the language of arithmetic


▻ x+2 ≥ y is a sentence; x2+y > {} is not a sentence
▻ x+2 ≥ y is true if the number x+2 is not less than the
number y
26
Propositional logic:

▰ Propositional logic (PL) is the simplest form


of logic where all the statements are made by
propositions,are combined using logical
connectives.
▰ It is a declarative statement which is either
true or false.
▰ It is a technique of knowledge representation
in logical and mathematical form.
▰ Propositional Variables- 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,
Q, R, etc.
▰ Propositions can be either true or false, but it cannot be
both.
▰ Propositional logic consists of an object, relations or
function, andlogical connectives

28
Characteristics of a Proposition:

▰ Atomic Propositions - consist of a single


proposition symbol .
▰ Compound propositions- Complex sentences
are constructed from simpler sentences,
using parentheses and logicalconnectives.
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 litera
l or
negative literal.
▰ Conjunction: A sentence which has ∧
connective such as,∧PQ
▰ Example: P= Jane is intelligent, Q= Jane is
hardworking.
▰ → P∧ Q. 32
•Disjunction: A sentence which has ∨ connective, such as P ∨
Q.
Example: Here P= Ritika is Doctor. Q= Ritika is Engineer, so
we can write it as P ∨ Q.
•Implication: A sentence such as P → Q, is called an
implication. Also known as if-then rules.
Example: Let P= It is raining, and Q= Street is wet, so it is
represented as P → Q
•Biconditional: A sentence such as P⇔ Q
example If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented
as P ⇔ Q.
34
35
▰ Just like arithmetic operators, there is a
Precedence of connectives
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:
Logical equivalence is one of the features of propositional logic.
Logical equivalence
This relationship is denoted by the symbol ≡" or" "off" (if and only if).
▰ Two propositions are said to be logically equivalent if and only if
the columns in the truth table are identical to each other.

•P→Q
•¬P∨Q
38
Entailment
A set of sentences (called premises) logically entails a
sentence (called a conclusion) if and only if every truth
assignment that satisfies the premises also satisfies the
conclusion.
▰ Entailment means that one thing follows logically from
another:
α |=β and β |= α
Where α is true and β is also true.

P⊨(P∨Q)
39
▻ E.g.,the sentence (A) The president was
assassinated. entails (B) The president is
dead.”
▻ E.g., x+y = 4 entails 4 = x+y
▻ Entailment is a relationship between
sentences (i.e., syntax) that is based on
semantics

40
▰ Validity-the sentence P∨ ¬P is valid. Valid
sentences are also known as tautologies

41
Inference
▰ Inference rules are the templates for
generating valid arguments.
▰ Inference rules are applied to derive proofs in
artificial intelligence.
▰ proof is a sequence of the conclusion that
leads to the desired goal. Inference

Process through which conclusions are
made.
42
▰ 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.

43
▰ 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.

44
45
Types of Inference rules:

▰ Modus Ponens is a fundamental inference rule in propositio


logic. It allows us to derive a conclusion from a conditional
statement and its antecedent.
▰ Example 1:
▰ Premise 1:If it rains, then the ground will be wet.
→Q)
(P
▰ Premise 2:It is raining. (P)
▰ Conclusion:Therefore, the ground will be wet. (Q)
▰ 46
▰ 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:

47
▰ Eg: if (WumpusAhead ∧WumpusAlive) ⇒
Shoot
▰ and (WumpusAhead ∧ WumpusAlive) are
given, then Shoot can be inferred.

48
Proof by resolution

Resolution basically works by using the principle of proof by


contradiction.
To find the conclusion we should negate the conclusion.
Then the resolution rule is applied to the resulting clauses.
Each clause that contains complementary literals is
resolved to produce a two new clause,whichcan be added
to the set of facts (if it is not already present).

49
▰ This process continues until one of the two
things happen:
▰· There are no new clauses that can be
added
▰· An application of the resolution rule
derives the empty clause

50
▰ Clause: Disjunction of literals (an atomic sentence) is
called aclause. It is also known as a unit clause.
▰ Conjunctive Normal Form : A sentence represented as
a conjunction of clauses is said toconjunctive
be
normal formor CNF.
▰ The purpose of the proof of resolutionis to
demonstrate the validity of logical statements and to
derive conclusions from a set of premises using a
systematic method.

51
▰ Conversion of facts into first
-order logic.
▰ Convert FOL statements into CNF
▰ Negate the statement which needs to prove
(proof by contradiction)
▰ Draw resolution graph (unification).

52
Steps for Resolution:

▰ Express Statements in Conjunctive Normal Form


(CNF).
▰ Conversion Steps:
▰ Eliminate Implications and Biconditionals:

53
▰ Apply the Resolution Rule
▰ Identify Pairs of Clauses to Resolve:
▻ Look for two clauses where one contains a literal and the other
contains its negation.
▰ Perform Resolution:
▻ Resolve by combining the clauses and eliminating the
complementary literals.
▰ Derive a Contradiction
▰ Check for Empty Clause
54
55
Example:

Consider the following KB:


1. The humidity is high or the sky is cloudy.
2. If the sky is cloudy then it will rain.
3. If the humidity is high, then it is hot.
4. It is not hot.
5. Goal: It will rain.

56
▰ Assignment: write a short note on forward
chaining and backward chaining algorithm

57

You might also like