0% found this document useful (0 votes)
3 views70 pages

15 ProPosLogic

The document provides an overview of propositional logic (PL) in artificial intelligence, explaining its basic elements, syntax, and logical connectives. It discusses inference rules, methods for logical reasoning, and applications of propositional logic in various AI systems. Key concepts such as tautology, contradiction, and logical equivalence are also covered, along with examples and truth tables for better understanding.

Uploaded by

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

15 ProPosLogic

The document provides an overview of propositional logic (PL) in artificial intelligence, explaining its basic elements, syntax, and logical connectives. It discusses inference rules, methods for logical reasoning, and applications of propositional logic in various AI systems. Key concepts such as tautology, contradiction, and logical equivalence are also covered, along with examples and truth tables for better understanding.

Uploaded by

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

Propositional logic in

Artificial Intelligence

06/10/2025 1
Makeup class on Thursday

CS4813-251-BCS-223-3 2025-05-22 12:00-12:50 M8

06/10/2025 2
Propositional Logic - PL
• 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 Sunday.
• The Sun rises from West (False proposition)
• 3+3 = 7 (False proposition)
• 5 is a prime number.
• The propositions and connectives are the basic
elements of the propositional logic.
• In propositional logic, we use symbolic variables to
represent a proposition, such A, B, C, P, Q, R, etc.
06/10/2025 3
Basic Facts about 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.
• There are two types of Propositions:
• Atomic Propositions:
• 2+2 is 4
• Compound propositions
• "It is raining, and street is wet."
06/10/2025 4
Syntax of propositional logic - Logical
Connectives
1.Negation:A sentence such as ¬ P is called negation of P. A literal can be
either Positive literal or negative literal.
2.Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a
conjunction.
Example: Ali is intelligent and hardworking. It can be written as,
P = Ali is intelligent,
Q = Ali is hardworking.
P∧ Q.
3.Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction,
where P and Q are the propositions.
Example: “Rani is a doctor or Engineer",
Here P= Rani is Doctor. Q= Rani is Doctor, so we can write it as P ∨ Q.
4.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
5.Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I
am breathing, then I am alive
06/10/2025 P = I am breathing, Q = I am alive, it can be represented as P ⇔ Q. 5
Syntax of propositional logic
• Truth Tables

Conjunctio Disjunctio Implicatio Biconditio


n n n nal

06/10/2025 6
Syntax of propositional logic
• Precedence of connectives
Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Six Precedence Biconditional
06/10/2025 7
Syntax of propositional logic
• Logical equivalence: Logical equivalence is one of the
features of propositional logic.
• Two propositions are said to be logically equivalent if
and only if the columns in the truth table are identical to
each other.

06/10/2025 8
Properties of Operators
• Commutativity: •Distributive:
• P∧ Q= Q ∧ P, or • P∧ (Q ∨ R) = (P ∧ Q) ∨
• P ∨ Q = Q ∨ P. (P ∧ R).
• Associativity: • P ∨ (Q ∧ R) = (P ∨ Q) ∧
(P ∨ R).
• (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
•DE Morgan's Law:
• Identity element: • ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
• P ∧ True = P, • ¬ (P ∨ Q) = (¬ P) ∧
• P ∨ True= True. (¬Q).

•Double-negation
06/10/2025 elimination: 9
Logical Inference
• Logical inference using propositional logic is the process of deriving
new propositions (statements) that logically follow from a set of given
propositions, using the rules of logic.
• Given a knowledge base (a set of known true propositions, Premise),
logical inference is the process of determining whether a conclusion
(Hypothesis) logically follows.
• The goal: check if KB ⊨ α, meaning "α is entailed by KB" — that is, α is
true in all models where KB is true.

06/10/2025 10
Common Inference Methods

1. Truth Table Method

2. Modus Ponens (MP)


If: P→Q
P Then: Q

3. Modus Tollens (MT)


If: P→Q
¬Q Then: ¬P

4. Resolution
A rule of inference useful for automated reasoning:
From (A ∨ B) AND (¬B ∨ C) infer (A ∨ C)

5. Deduction
Build a chain of implications using known rules until the target statement is reached.
06/10/2025 11
Example

• Premise: A kid is in the park playing baseball with friends

• Hypothesis 1: Child plays baseball with friends – Entailment

• Hypothesis 2: A person is waiting to be served his food – Neutral

• Hypothesis 3: A kid is playing basketball with friends - Contradiction

06/10/2025 12
Applications
• Automated reasoning
• AI systems (e.g., expert systems)
• Verification of hardware and software
• Natural language understanding

• Clinical Trial Reports Inference: The original documents containing


detailed information about the design, methods, results, and conclusions
of a clinical trial.
• Question Answering Systems (e.g., "What drug improves survival in lung
cancer?")
06/10/2025 13
Proof and Reasoning...
• logic is often used for logical proofs.
• Proofs are valid arguments that determine the truth values of
mathematical statements.
• An argument is a sequence of statements. The last
statement is the conclusion, and all its preceding
statements are called premises (or hypothesis). The
symbol ∴ (read therefore) is placed before the
conclusion.
• A valid argument is one where the conclusion follows
from the truth values of the premises.
06/10/2025 14
Rules of Inference in Artificial
intelligence
• Intelligent computing system can create new logic from
old logic or by evidence, so
• Generating the conclusions from evidence and
facts is termed as Inference.
• 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.
• In inference rules, the implication among all the
connectives plays an important role.

06/10/2025 15
Premise to Conclusions

06/10/2025 16
Next Lecture

06/10/2025 17
Inference rules
• Implication: It is one of the logical connectives which can
be represented as P → Q. It is a Boolean expression.
• Inverse: The negation of implication is called inverse.
It can be represented as ¬ P → ¬ Q.

• 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.
06/10/2025 18
Implications to Disjunctions
• P → Q is logically equivalent to ¬ P ∨ Q .
• Example: “If a number is a multiple of 4, then it is even”
is equivalent to, “a number is not a multiple of 4 or
(else) it is even.”

06/10/2025 19
Example
• The sun is not visible. P
• The sky is overcast. Q
• if the sun is not visible, then the sky is overcast.
P->Q

• The sun is visible. ¬P


• The sky is not overcast. ¬Q
• Can we say if the sun is visible, then the sky is not
overcast?
06/10/2025 20
Example
• P -> Q
• ¬P -> ¬Q

06/10/2025 21
Another way
• The sun is visible. P
• The sun is not visible. ¬P

• The sky is overcast. Q


• if the sun is not visible, then the sky is overcast. ¬P -> Q
• The sun is visible. P
• The sky is visible (not overcast). ¬Q
• Can we say if the sun is visible, then the sky is not
overcast?
• P -> ¬Q ?

06/10/2025 22
Inference rules – Truth Tables
• some of the compound statements are equivalent to
each other, which we can prove using truth table

As an example of logical implication, suppose the sentences P


and Q are assigned as follows: P = The sky is overcast. Q =
The sun is not visible.
Using the above sentences as examples, ca we say that if the
sun is visible, then the sky is not overcast?
06/10/2025 23
Implications to Disjunctions
• P → Q is logically equivalent to ¬ P ∨ Q .
• Example: “If a number is a multiple of 4, then it is even”
is equivalent to, “a number is not a multiple of 4 or
(else) it is even.”

06/10/2025 24
With this and De
Morgan's laws, you can
take any statement
and simplify it to the
point where negations
are only being applied
to atomic propositions.

06/10/2025 25
Next Class

06/10/2025 26
• Which one of the following propositional logic formulas is TRUE
when exactly two of p, q, and r are TRUE?

06/10/2025 27
• Which one is equivalent to p↔q

06/10/2025 28
• Tommy Flanagan was telling you what he ate yesterday afternoon. He
tells you, “I had either popcorn or raisins. Also, if I had cucumber
sandwiches, then I had soda. But I didn’t drink soda or tea.” Of
course, you know that Tommy is the world’s worst liar, and everything
he says is false. What did Tommy eat?

06/10/2025 29
A deduction rule - Modus
Ponens
• What is given:

• The truth of the antecedent: 𝑃


• The implication: P→Q

• What we prove (infer):

• 𝑄
• The truth of the consequent:

• Given:
• If a person is a doctor, then they have completed medical school. P→Q
• Alice is a doctor. P
• Prove:
• Alice has completed
This onemedical school.Q
is a particularly famous rule
06/10/2025 called modus ponens. 30
A deduction rule

• Modus Ponens is valid even if you don't know whether 𝑄 is true on

• You cannot apply modus ponens unless both 𝑃→𝑄 and 𝑃 are known
its own.

to be true.
• Modus ponens is used to prove that the consequence of a rule (Q)
must be true, given that the rule itself (P → Q) and its condition (P)
are true.

06/10/2025 31
Example
• Show if

06/10/2025 32
Types of Inference rules
• Row 1 and 3,
• Q is true as well
• the argument form is a
valid (it is a valid
deduction rule)

06/10/2025 33
Types of Inference rules
• Check if this one is a valid rule

06/10/2025 34
Types of Inference rules
• Look at the second to last row.
• Here all three premises of the
argument are true, but the
conclusion is false.
• Thus, this is not a valid
deduction rule.

06/10/2025 35
• While we have the truth table
in front of us, look at rows 1,
3, and 5. These are the only
rows in which all the
statements are true. It also
happens that R is true in
these rows as well.
• Thus, we have discovered a
new deduction rule we
know is valid:

06/10/2025 36
Types of Inference rules
• 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
06/10/2025 37
Proof by Truth table
• 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

06/10/2025 38
Aspect Modus Ponens / Tollens Truth Table
Exhaustive truth-value
Purpose Logical inference (proof)
checking
Slower, especially for many
Speed Fast and intuitive
variables
When specific premises When analyzing all logical
Use case
are given possibilities
Scales well with many Becomes large quickly
Scalability
variables (e.g., 2ⁿ rows)
More human-like
Clarity More systematic and visual
reasoning
06/10/2025 39
When Modus Ponens
Use Modus Ponens / Tollens When:
• You are doing logical inference from known facts (e.g., in math
proofs, AI rule-based systems).
• You need to derive a conclusion efficiently from given premises.
• You're working with a few known statements, not exploring all
combinations.
• You want reasoning that mirrors natural human logic.

06/10/2025 40
When what?
Given:
• If a student studies, they pass the exam. P→Q
• The student studied. → P
Use Modus Ponens to infer:
• The student passed the exam. → Q
Use Truth Tables When:
• You want to verify logical equivalence, validity, or tautology.
• You're designing or analyzing digital circuits or compound propositions.
• You’re dealing with logic where you must examine all possible truth
values.
06/10/2025 41
Truth Tables
Use Truth Tables When:
• You want to verify logical equivalence, validity, or tautology.
• You're designing or analyzing digital circuits or compound
propositions.
• You’re dealing with logic where you must examine all possible truth
values.
Example:
• To prove (P∧Q)→P is always true (a tautology), a truth table is ideal.

06/10/2025 42
Conclusion
• Use modus ponens/tollens when doing step-by-step reasoning based
on known facts.
• Use truth tables when analyzing the structure or validity of logical
formulas.
• Think of modus ponens as a tool for deduction, and truth tables as a
tool for analysis.

06/10/2025 43
Inference: Hypothetical
Syllogism
• If you have my home key, then you can unlock my home
• P→Q
• 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
• This is sometimes called the transitivity of implication.
Symbolically:
(P→Q)∧(Q→R)⊢(P→R)
06/10/2025 44
Example
1.If it rains, the ground will get wet. (R→W)
2.If the ground gets wet, the game will be cancelled. (W→C)
Therefore:
• If it rains, the game will be cancelled. (R→C)

06/10/2025 45
Types of Inference rules
• The Hypothetical Syllogism rule state that if P→R is true
whenever P→Q is true, and Q→R is true. It can be
represented as the following notation:
• 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

06/10/2025 46
Examples: Modus Ponens
• If an agent uses a knowledge base, then it can
perform logical inference.
• The agent uses a knowledge base.
What can you conclude?
A. The agent cannot learn.
B. The agent can perform logical inference.
C. The agent is autonomous.
D. Nothing can be concluded.

06/10/2025 47
Examples: Modus Tollens
If P→Q , and ¬Q, then ¬P.
Question:
If an AI system uses supervised learning, it must have labeled training
data.
This AI system does not have labeled training data.
What can you conclude?
• A. The AI system uses supervised learning.
B. The AI system is intelligent.
C. The AI system does not use supervised learning.
D. Nothing can be concluded.

06/10/2025 48
Hypothetical Syllogism
f P→Q, and Q→R, then P→R .
If an AI system learns from data, it improves its performance.
If it improves its performance, it becomes more accurate.
What can you conclude?
• A. If the AI system learns from data, it becomes more accurate.
B. The AI system is accurate.
C. The AI system cannot learn.
D. Nothing can be concluded.

06/10/2025 49
Mixed Practice Question
Question:
Which rule of inference is used in the following reasoning?
If an agent perceives its environment, it can make decisions.
The agent perceives its environment.
Therefore, it can make decisions.
• A. Modus Ponens
B. Modus Tollens
C. Hypothetical Syllogism
D. Disjunctive Syllogism

06/10/2025 50
Types of Inference rules
• Disjunctive Syllogism
• The Disjunctive syllogism rule state 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

06/10/2025 51
Types of Inference rules
• 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

06/10/2025 52
Types of Inference rules

06/10/2025 53
Types of Inference rules

06/10/2025 54
Types of Inference rules

06/10/2025 55
Types of Inference rules

06/10/2025 56
Puzzle and Inference
Given:
There are three people: A, B, and C.
• Knights always tell the truth.
• Knaves always lie.
They make these statements:
• A says: “All of us are knaves.”
• B says: “Exactly one of us is a knight.”
• We must determine who is a Knight and who is a Knave.

06/10/2025 57
Puzzle and Inference
• Step 1: Analyze A's Statement
• A says: “All of us are knaves.”
• Suppose A is a Knight (truth-teller):
• Then A’s statement must be true: “All of us are knaves”.
• But A himself is claiming that he is a knave, which contradicts him being a
knight. Contradiction.
• A cannot be a Knight.➡️So, A is a Knave.
• That means A is lying.
• So the statement “All of us are knaves” is false.
• For that to be false, not all of them are knaves → at least one is a Knight.
06/10/2025 58
Step 2: Analyze B's Statement
B says: “Exactly one of us is a knight.”
Let’s suppose B is a Knight. Then his statement must be true.
So exactly one of A, B, and C is a Knight.
But B is the Knight → then A and C must be Knaves.
Check:
•A is a Knave ✅
•C is a Knave ✅
•B is a Knight ✅
Only one knight → B. ✔ Statement is consistent.
✅ So this scenario works!
Now check if the statements are valid:
•A is a knave → lies → says “All of us are knaves” (but that's false) → ✔
Consistent.
•B is a knight → truth → “Exactly one of us is a knight” (true) → ✔ Consistent.
•C is a knave → says nothing (okay).

06/10/2025 59
Puzzle and Inference
✅ Final Answer:
• A is a Knave
• B is a Knight
• C is a Knave
• ✔ All statements are internally consistent with these roles.

06/10/2025 60
With Propositional Logic

06/10/2025 61
With Propositional Logic

06/10/2025 62
06/10/2025 63
• A’s statement is false,he is a Knave and lying)
• B’s statement is true, (exactly one knight: himself)
• C says nothing → unrestricted
• This assignment is consistent with all logical conditions.
06/10/2025 64
06/10/2025 65
A’s B’s
A’s Statement B’s Statement ✅
A_K B_K C_K Statement Statement
Valid? True? Consistent?
True? Valid?
F (not all F (3 knights ≠
T T T ❌ A lies → ❌ ❌ B lies → ❌ ❌
knaves) 1)
F (2 knights ≠
T T F F ❌ ❌ ❌
1)
✅ (B is a
F (2 knights ≠
T F T F ❌ knave → can ❌
1)
lie)
F (1 knight: ❌ A says all
T F F T ✅ ✅
A) are knaves
✅ (A is knave
F T T F F (2 knights) ❌ ❌
→ lies)
T (only B is
F T F F ✅ ✅ ✅✅✅
knight)
F (only C is
F F T F ✅ ✅ ❌
knight)
F F F T ✅ F (0 knights) ✅ ❌

06/10/2025 66
Final Answer from Truth Table
The only row that satisfies all conditions is:

A_K B_K C_K


F T F

So:
•A is a Knave
•B is a Knight
•C is a Knave

06/10/2025 67
1. Define propositions
Let:
• AKA_KAK​: A is a Knight
• BKB_KBK​: B is a Knight
• CKC_KCK​: C is a Knight
Then:
• ¬AK\neg A_K¬AK​: A is a Knave
• ¬BK\neg B_K¬BK​: B is a Knave
• ¬CK\neg C_K¬CK​: C is a Knave
06/10/2025 68
• Translate the English statements into symbolic logic, making the
atomic propositions as basic as possible.
• (a) “To watch Tangled, it suffices to have a DisneyPlus account or a
DVD.”
• (b) Define a set of at most three atomic propositions. Then use them
to translate all of these sentences.
• (i) It’s time for bed only if it is after 9 PM and I’m tired.
• (ii) I’m not tired unless it is after 9 PM.
• (iii) It’s time for bed and after 9 PM if and only if I am tired.
• (c) Define a set of at most 4 atomic propositions. Then use them to
translate all of these sentences.
• (i) Vampires attack humans if and only if the town does not have a blood bank
and the humans are tasty.
• (ii) Humans are tasty if the grocery store does not carry garlic.
• (iii) At least one of the following is true: vampires attack humans, the town 69
06/10/2025
does not have a blood bank, or the grocery store does not carry garlic.
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.

06/10/2025 70

You might also like