Propositional Logic
PROPOSITIONAL LOGIC
▪ It 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:
▪ It is Sunday.
▪ The Sun rises from West (False proposition)
▪ 3+3= 7(False proposition)
▪ 5 is a prime number.
2
PROPOSITIONAL LOGIC – FACTS
▪ 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 representing a proposition, such as 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.
▪ The propositions and connectives are the basic elements of the propositional logic.
▪ Connectives can be said as a logical operator which connects two sentences.
▪ A proposition formula which is always true is called tautology, and it is also called a
valid sentence.
▪ A proposition formula which is always false is called Contradiction.
▪ 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.
3
PROPOSITIONAL LOGIC – TYPES
▪ Atomic Propositions
▪ 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:
▪ 2+2 is 4, it is an atomic proposition as it is a true fact.
▪ "The Sun is cold" is also a proposition as it is a false fact.
▪ Compound propositions
▪ Compound propositions are constructed by combining simpler or atomic propositions,
using parenthesis and logical connectives.
▪ Example:
▪ "It is raining today, and street is wet."
▪ "Ankit is a doctor, and his clinic is in Mumbai."
4
PROPOSITIONAL LOGIC – 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.
▪ Negation: A sentence such as ¬ P is called negation of P.
▪ 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 a Doctor. Q= Ritika is an Engineer, so we can write it as P ∨ Q.
▪ 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 (iff), example If I am
breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
5
PROPOSITIONAL LOGIC – LIMITATIONS
▪ We cannot represent relations like ALL, some, or none with propositional logic.
▪ Example:
▪ All 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.
6
PROPOSITIONAL LOGIC – INFERENCE RULES
▪ Inference:
▪ generating the conclusions from evidence and facts is termed as Inference.
▪ Inference rules:
▪ Inference rules are the templates for generating valid arguments.
▪ Inference rules are applied to derive proofs, and the proof is a sequence of the conclusion that
leads to the desired goal.
7
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
1. Modus Ponens or Implication Elimination:
▪ 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.
8
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
2. Modus Tollens:
▪ The Modus Tollens rule states 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
Which infers that "I am not sleepy" => ~P
9
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
3. Hypothetical Syllogism:
▪ The Hypothetical Syllogism rule states that if P→R is true whenever P→Q is true, and
Q→R is true.
▪ Example:
▪ Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
10
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
4. Disjunctive Syllogism:
▪ The Disjunctive syllogism rule states that if P∨Q is true, and ¬P is true, then Q will be true.
It can be represented as:
▪ Example:
▪ Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
11
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
5. Addition:
▪ The Addition rule is one the common inference rule, and it states that If P is true, then P∨Q
will be true.
▪ Example:
▪ Statement-1: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
12
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
▪ 6. Simplification:
▪ The simplification rule states that if P∧ Q is true, then Q or P will also be true. It can be
represented as:
13
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
7. Resolution:
▪ The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be true. It can
be represented as
14
PROPOSITIONAL LOGIC – TYPES OF INFERENCE RULES
8. Unit Resolution:
▪ The Resolution rule state that if P∨Q and ¬ Q is true, then P will also be true. It can be
represented as
P∨Q, ¬Q
P
15
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.
16
WUMPUS WORLD – COMPONENTS
▪ Components which can help the agent to navigate the cave:
▪ 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, and Wumpus will
emit a horrible scream which can be heard anywhere in the cave.
17
WUMPUS WORLD – PEAS DESCRIPTION
▪ Performance measure:
▪ +1000 reward points if the agent comes out of the cave with the gold.
▪ -1000 points penalty for being eaten by the Wumpus or falling into the pit.
▪ -1 for each action, and -10 for using an arrow.
▪ The game ends if either agent dies or came out of the cave.
▪ Environment:
▪ A 4*4 grid of rooms.
▪ The agent initially in room square [1, 1], facing toward the right.
▪ Location of Wumpus and gold are chosen randomly except the first square [1,1].
▪ Each square of the cave can be a pit with probability 0.2 except the first square.
18
WUMPUS WORLD – PEAS DESCRIPTION
▪ Actuators:
▪ Left turn
▪ Right turn
▪ Move forward
▪ Grab
▪ Release
▪ Shoot
▪ Sensors:
▪ The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally).
▪ The agent will perceive breeze if he is in the room directly adjacent to the Pit.
▪ The agent will perceive the glitter in the room where the gold is present.
▪ The agent will perceive the bump if he walks into a wall.
▪ When the Wumpus is shot, it emits a horrible scream which can be perceived anywhere in the cave.
▪ These percepts can be represented as five element list, in which we will have different indicators for
each sensor.
▪ Example if agent perceives stench, breeze, but no glitter, no bump, and no scream then it can be represented
as: [Stench, Breeze, None, None, None].
19
EXPLORING THE WUMPUS WORLD
▪ determine how the agent will find its goal by applying logical reasoning.
▪ Agent’s first step
Breeze
20
EXPLORING THE WUMPUS WORLD
▪ Agent’s second 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?
▪ 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.
21
EXPLORING THE WUMPUS WORLD
▪ Agent’s third step
Breeze
22
EXPLORING THE WUMPUS WORLD
▪ 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.
23
KNOWLEDGE BASE FOR WUMPUS WORLD
▪ The agent starts visiting from first square [1, 1], and already know that this room is
safe for the agent.
▪ To build a knowledge base for wumpus world, use some rules and atomic
propositions.
▪ Symbol [i, j] for each location in the wumpus world, where i is for the location of
rows, and j for column location.
24
ATOMIC PROPOSITION VARIABLE FOR WUMPUS WORLD
▪ Let Pi,j be true if there is a Pit in the room [i, j].
▪ Let Bi,j be true if agent perceives breeze in [i, j], (dead or alive).
▪ Let Wi,j be true if there is wumpus in the square[i, j].
▪ Let Si,j be true if agent perceives stench in the square [i, j].
▪ Let Vi,j be true if that square[i, j] is visited.
▪ Let Gi,j be true if there is gold (and glitter) in the square [i, j].
▪ Let OKi,j be true if the room is safe.
25
PROPOSITIONAL RULES FOR WUMPUS WORLD
26
REPRESENTATION OF KNOWLEDGE BASE FOR WUMPUS WORLD
▪ Simple KB for wumpus world when an agent moves from room [1, 1], to room [2,1]
27
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ We can prove that wumpus is in the room (1, 3) using propositional rules which we
have derived for the wumpus world and using inference rule.
▪ Apply Modus Ponens with ¬S11 and R1:
28
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply And-Elimination Rule:
▪ After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21, we will get three
statements:
¬ W11, ¬ W12, and ¬W21.
29
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply Modus Ponens to ¬S21, and R2:
30
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply And-Elimination Rule:
▪ After applying And-elimination rule to ¬ W21 ∧ ¬ W22 ∧¬ W31, We will get three
statements:
¬ W21, ¬ W22, and ¬ W31.
31
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply Modus Ponens to S12 and R4:
32
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply Unit resolution on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 :
33
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply Unit resolution on W13 ∨ W12 ∨ W22 and ¬ W22 :
34
PROOF: WUMPUS IS IN THE ROOM (1,3)
▪ Apply Unit Resolution on W13 ∨ W12 and ¬ W12 :
35
EXAMPLE ON DEDUCTION
▪ If the unicorn is mythical, then it is immortal, but if it is not mythical, then it is a
mortal mammal.
▪ If the unicorn is either immortal or a mammal, then it is horned.
▪ The unicorn is magical if it is horned.
can we prove that the unicorn is mythical? Magical? Horned?
36
EXAMPLE ON DEDUCTION - MODELLING IN
PROPOSITIONAL LOGIC
▪ Propositions:
Umyth: Unicorn is mythical
Umort: Unicorn is mortal
Umam: Unicorn is mammal
Umag: Unicorn is magical
Uhorn: Unicorn is horned
37