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

Chapter4 PropositionalLogicpptx 2023 09 17 01 09 44

Uploaded by

paulbogale
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)
22 views53 pages

Chapter4 PropositionalLogicpptx 2023 09 17 01 09 44

Uploaded by

paulbogale
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/ 53

rtificial Intelligence

Unit-3
Artificial Intelligence 3170716

Department of Computer
Engineering
Propositional Logic
Logic
• One of the prime activities of the human intelligence
is reasoning.
• The activity of reasoning involves construction, organization
and manipulation of statements to arrive at new conclusions.
• Thus logic can be defined as a scientific study of the process
of reasoning.
• Logic is a formal language.
• Logic is basically classified in two main categories
– Propositional logic
– Predicate logic
Proposition
• Propositions are elementary atomic sentences.
• Propositions may be either true or false but may take on
no other value.
• There are two kinds of proposition
– Simple
– compound
• Some examples of simple propositions are
– It is raining.
– My car is painted silver.
– John and sue have five children.
– Snow is white.
– People live on the moon.
Propositional Logic

• A proposition (or a statement) is a declarative sentence which is


either true or false but not both.

• Imperative, exclamatory, interrogative or open sentences are not


statements in logic.

• The Truth Value of a proposition is True(denoted as T)


if it is a true statement, and False(denoted as F) if it is a
false statement.
Some examples of Propositions are given below −
• "Man is Mortal", it returns truth value “TRUE”
• "12 + 9 = 3 – 2", it returns truth value “FALSE”

The following is not a Proposition −


• "A is less than 2".
It is because unless we give a specific value of A, we cannot say
whether the statement is true or false.
Statements That Are Not Propositions-

Following kinds of statements are not propositions-


1.Command
2.Question
3.Exclamation
4.Inconsistent
5.Predicate or Proposition Function
Following statements are not propositions-
• Close the door. (Command)
• Do you speak French? (Question)
• What a beautiful picture! (Exclamation)
• I always tell lie. (Inconsistent)
• P(x) : x + 3 = 5 (Predicate)
• All of them are propositions except (iv), (v),(ix) & (x) sentences ( i), (ii)
.
are true, whereas (iii),(iv), (vii) & (viii) are false.
• Sentence (iv) is command, hence not a proposition.
• ( v ) is a question so not a statement.
• ( ix) is a declarative sentence but not a statement, since it is true or
false depending on the value of x.
• (x) is a exclamatory sentence and so it is not a statement.
Mathematical identities are considered to be statements. Statements
which are imperative, exclamatory, interrogative or open are not
statements in logic
Compound Statements
Many propositions are composites that are, composed of sub
propositions and various connectives discussed subsequently. Such
composite propositions are called compound propositions.
A proposition is said to be primitive if it cannot be broken down into
simpler propositions, that is, if it is not composite.

Example : Consider, for example following sentences.


a. “The sun is shining today and it is colder than yesterday”
b. b. “Sita is intelligent and she studies every night.”
The propositions in Example 1 are primitive propositions.
Two Normal (Canonical) Forms

All wffs can be expressed in the following to normal forms

1. CNF (Conjunctive Normal Form)

e.g.: (A  B)  (B  D  C)


Clause 1 clause 2

2. DNF (Disjunctive Normal Form)


e.g.: (A  B)  (B  D  C)
models models
Some Equivalence Laws

Prepared by- Agniwesh Mishra, Rungta


College of Engg. & Tech. , Bhilai
LOGICAL OPERATIONS OR LOGICAL
CONNECTIVES :

The phrases or words which combine simple statements are called


logical connectives. There are five types of connectives. Namely, ‘not’,
‘and’, ‘or’, ‘if…then’, iff etc.
The first one is a unitary operator whereas the other four are binary
operators.
In the following table we list some possible connectives, their symbols
& the nature of the compound statement formed by them.
1.Conjunction (AND):
• If two statements are combined by the word “and” to form a
compound proposition (statement) then the resulting proposition is
called the conjunction of two propositions. Symbolically, if P & Q are
two simple statements, then ‘P ∧ Q’ denotes the conjunction of P
and Q and is read as ‘P and Q.
• Since, P ∧ Q is a proposition it has a truth value and this truth value
depends only on the truth values of P and Q. Specifically, if P & Q are
true then P ∧ Q is true; otherwise P ∧ Q is false
Truth Table

Example : Let
P: In this year monsoon is very good.
Q: The rivers are flooded.

Then, P ∧ Q: In this year monsoon is very good and the rivers are flooded.
2.Disjunction (OR) :
• Any two statements can be connected by the word ‘or’ to form a
compound statement called disjunction. Symbolically, if P and Q are
two simple statements, then P ∨ Q denotes the disjunction of P and Q
and read as 'P or Q’ .
• The truth value of P ∨ Q depends only on the truth values of P and Q.
Specifically if P and Q are false then P∨Q is false, otherwise P ∨ Q is
true.
Truth Table

Example 4:
P: Paris is in France
Q :2 +3 =6 then
P ∨ Q : Paris is in France or 2 + 3 = 6.
Here, P ∨ Q is true since P is true & Q is False. Thus, the disjunction P ∨ Q is false only when P and Q are
both false.
3.Negation (NOT)
• Given any proposition P, another proposition, called negation of P, can
be formed by modifying it by “not”. Also by using the phrase “It is not
the case that or” “It is false that” before P we will able to find the
negation.
• Symbolically, ¬P Read as “not P” denotes the negation of P.
• The truth value of ¬P depends on the truth value of P If P is true then
¬P is false and if P is false then ¬P is true.
Truth Table

Example : Let P: 3 is a factor of 12.


Then Q = ¬ P: 3 is not a factor of 12.

Here P is true & ¬P is false.


4.Conditional or Implication: (If…
then)
• If two statements are combined by using the logical connective ‘if…
then’ then the resulting statement is called a conditional statement.
• If P and Q are two statements forming the implication “if P then Q”
then we denotes this implication P → Q .
• In the implication P → Q, P is called antecedent or hypothesis
• Q is called consequent or conclusion.
The statement P → Q false. is true in all cases except when P is true and
Q is
Truth Table
• Since conditional statement play an essential role in mathematical reasoning a variety of
terminology is used to express P → Q .
• i) If P then Q
• ii) P implies Q
• iii) P only if Q
• iv) Q if P
• v) P is sufficient condition for Q
• vi) Q when P
• vii) Q is necessary for P
• viii) Q follows from P
• ix) if P, Q
• x) Q unless ¬ P
Inverse, Converse, and Contra-positive
Implication / if-then (→) is also called a conditional statement. It has two parts −
•Hypothesis, p
•Conclusion, q
As mentioned earlier, it is denoted as p→q.

Example of Conditional Statement − “If you do your homework, you will not be
punished.” Here, "you do your homework" is the hypothesis, p, and "you will not be
punished" is the conclusion, q.

1.Inverse − An inverse of the conditional statement is the negation of both the hypothesis
and the conclusion. If the statement is “If p, then q”, the inverse will be “If not p, then not
q”. Thus the inverse of p→q is ¬p→¬q.
Example − The inverse of “If you do your homework, you will not be punished” is

“If you do not do your homework, you will be punished.”


2.Converse − The converse of the conditional statement is computed by interchanging the hypothesis
and the conclusion. If the statement is “If p, then q”, the converse will be “If q, then p”. The converse
of p→q is q→p.

Example − The converse of "If you do your homework, you will not be punished" is

"If you will not be punished, you do your homework”.

3.Contra-positive − The contra-positive of the conditional is computed by interchanging the


hypothesis and the conclusion of the inverse statement. If the statement is “If p, then q”, the contra-
positive will be “If not q, then not p”. The contra-positive of p→q is ¬q→¬p.

Example − The Contra-positive of " If you do your homework, you will not be punished” is

"If you are punished, you did not do your homework”.


Example: Let
P: You are good in Mathematics.
Q: You are good in Logic
Then, P → Q : If you are good in Mathematics then you are good in Logic.
Write the converse, inverse and contrapositive of the following
statements-
1.If today is Sunday, then it is a holiday.
2.If 5x – 1 = 9, then x = 2.
3.If it rains, then I will stay at home
1. Converse Statement- If it is a holiday, then today is Sunday.
• Inverse Statement- If today is not Sunday, then it is not a holiday.
• Contrapositive Statement- If it is not a holiday, then today is not Sunday.

2. Converse Statement- If x = 2, then 5x – 1 = 9.


• Inverse Statement- If 5x – 1 ≠ 9, then x ≠ 2.
• Contrapositive Statement- If x ≠ 2, then 5x – 1 ≠ 9.

3. Converse Statement- If I will stay at home, then it rains.


• Inverse Statement- If it does not rain, then I will not stay at home.
• Contrapositive Statement- If I will not stay at home, then it does not rain.
5. BICONDITIONAL STATEMENT
• Example : Let P : Ram can take the flight.
• Q : Ram buy a ticket.

• Then P↔Q is the statement. “Ram can take the flight iff Ram buy a
ticket”.
Precedence of Logical Operators:
• We can c o n s t r u c t c o m p o u n d p r o p o s i t i o n s u s i n g t h e
n e g a t i o n operator and the logical operators defined so far. We will
generally use parentheses to specify the order in which logical
operators in a compound proposition are to be applied.
• In order to avoid an excessive number of parentheses.
• We sometimes adopt an order of precedence for the logical
connectives.
The following table displays the precedence levels of
the logical operators.
DERIVED CONNECTORS
1. NAND: It means negation after ANDing of two statements. Assume p
and q be two propositions. NANDing of p and q to be a proposition
which is false when both p and q are true, otherwise true. It is denoted
by p ↑ q.
2. NOR or Joint Denial: It means negation after ORing
of two statements. Assume p and q be two
propositions. NORing of p and q to be a proposition
which is true when both p and q are false, otherwise
false. It is denoted by p q.
3. XOR: Assume p and q be two propositions. XORing of p
and q is true if p is true or q is true but not both and vice-
versa. It is denoted by p ⨁ q.
Example1: Prove that X ⨁ Y ≅ (X ∧∼Y)∨(∼X∧Y).
Solution: Construct the truth table for both the
propositions.
Example2: Show that (p ⨁q) ∨(p↓q) is equivalent to p ↑
q.
Solution: Construct the truth table for both the
propositions.
Converting English Words to
Propositional Logic
Examples
1. If it rains, then I will stay at home.
2. If I will go to Australia, then I will earn more money.
3. He is poor but honest.
4. If a = b and b = c then a = c.
5. Neither it is hot nor cold today.
6. Either today is Sunday or Monday.
7. You will qualify GATE only if you work hard.
8. Presence of cycle in a single instance RAG is a necessary and sufficient condition for deadlock.
9. Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for deadlock.
10. I will dance only if you sing.
11. Neither the red nor the green is available in size 5.
Part-01:
p : It rains
 The given sentence is- “If it rains, then I will stay at home.”
q : I will stay at home
 This sentence is of the form- “If p then q”.
So, the symbolic form is p → q where-

Part-02:

 p : I will go to Australia
The given sentence is- “If I will go to Australia, then I will earn more money.”
 This sentence is of the form- “If p then q”. q : I will earn more money
So, the symbolic form is p → q where-

Part-03:
p : He is poor
 The given sentence is- “He is poor but honest.”
 We can replace “but” with “and”. q : He is honest
 Then, the sentence is- “He is poor and honest.”
So, the symbolic form is p ∧ q where-
Part-04:
 The given sentence is- “If a = b and b = c then a = c.” p:a=b
 This sentence is of the form- “If p then q”.
So, the symbolic form is (p ∧ q) → r where-
q:b=c

r:a=c
Part-05:
 The given sentence is- “Neither it is hot nor cold today.” p : It is hot today
 This sentence is of the form- “Neither p nor q”.
q : It is cold today
 “Neither p nor q” can be re-written as “Not p and Not q”.
So, the symbolic form is ∼p ∧ ∼q where-
Part-6:
 The given sentence is- “Either today is Sunday or Monday.” p : Today is Sunday
 It can be re-written as- “Today is Sunday or Monday.”
So, the symbolic form is p ∨ q where-
q : Today is Monday

Part-7:
 The given sentence is- “You will qualify GATE only if you work hard.” p : You will qualify GATE
 This sentence is of the form- “p only if q”. q : You work hard
So, the symbolic form is p → q where-
Part-17:
The given sentence is- “Presence of cycle in a single instance RAG is a necessary and sufficient condition for deadlock.”
This sentence is of the form- “p is necessary and sufficient for q”. p : Presence of cycle in a single instance
So, the symbolic form is p ↔ q where- RAG
Part-18:
q : Presence of deadlock
The given sentence is- “Presence of cycle in a multi instance RAG is a necessary but not sufficient condition for deadlock.”
This sentence is of the form- “p is necessary but not sufficient for q”.

So, the symbolic form is (q → p) ∧ ∼(p → q) where-


p : Presence of cycle in a multi instance RAG

Part-19: q : Presence of deadlock

The given sentence is- “I will dance only if you sing.”


This sentence is of the form- “p only if q”.
So, the symbolic form is p → q where-
p : I will dance
Part-20:
The given sentence is- “Neither the red nor the green is available in size 5.” q : You sing
This sentence is of the form- “Neither p nor q”.

So, the symbolic form is ∼p ∧ ∼q where-


“Neither p nor q” can be written as “Not p and Not q”.

p : Red is available in size 5

q : Green is available in size 5


Forward Chaining
• An inference engine using forward chaining searches the inference rules
until it finds one where the IF clause is known to be true.
• When found it can conclude, or infer, the THEN clause, resulting in the
addition of new information to its dataset. In other words, it starts with
some facts and applies rules to find all possible conclusions. Therefore, it is
also known as Data Driven Approach.
• The standard definition of a forward-chaining system is that the system
operates by repeating the following sequence of operations
1. Examine the rules to find one who‟s If part is satisfied by the
current
contents of Working Memory.
2. Fire the rule by adding to Working Memory the facts that are specified in the
rules Then part. (The Then part may perform other actions as well, but that
can be ignored for now.) This control cycle continues until no rules have
satisfied If parts.
Flowchart for forward chaining

Prepared by- Agniwesh Mishra, Rungta


College of Engg. & Tech. , Bhilai
Backward chaining
• An inference engine using backward chaining would search
the inference rules until it finds one which has a THEN
clause that matches a desired goal. If the IF clause of that
inference rule is not known to be true, then it is added to
the list of goals (in order for goal to be confirmed it must
also provide data that confirms this new rule) . In other
words, this approach starts with the desired conclusion and
works backward to find supporting facts. Therefore, it is
also known as Goal-Driven Approach.
• Backward-chaining systems try to satisfy the goals in the
goal stack. They do this by finding rules that can conclude
the information needed by the goal, and trying to make the
If parts of those rules satisfied . In more detail, the standard
backward-chaining control cycle is shown in figure.

Prepared by- Agniwesh Mishra, Rungta


College of Engg. & Tech. , Bhilai
Steps for backward chaining
1. Check the conclusions of the rules to find all rules
that can satisfy the top goal on the stack. 2. Process
these rules one at a time:
a. Evaluate the conditions in the rules If part one at a
time:
i. If the condition is currently unknown (that is, if there is
not enough information currently known to determine
whether the condition is satisfied) push a goal to make
that condition known, and recursively invoke the system.
ii. If the condition is known to be unsatisfied, continue
with the loop at Step 2.
iii.If it was not possible to determine whether the condition
was satisfied, continue with the loop at Step 2.
Steps for backward chaining
b. If all the conditions in the selected rule are
satisfied, add to Working Memory the facts
specified in the Then part of the rule, pop the
goal off the stack, and return from this
invocation of the system. The system
terminates with success when the goal stack is
empty. It terminates with failure if the system
runs out of rules to try in Step 2.
Flowchart for backward chaining

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy