Вы находитесь на странице: 1из 54

Basic Propositional Calculus

Logic
 Generation Of Idea for Problem Solving
 Study of reasoning
 Greek Philosopher, Aristotle was the pioneer of Logical
Reasoning
 Logical reasoning provides the theoretical base for many
areas of mathematics and consequently computer science.
 It has many practical applications in computer science like
design of computing machines, artificial intelligence,
definition of data structures for programming languages
etc.
Type of Logic

1. Propositional Logic
2. Predicate Logic
3. Fuzzy Logic(Studied In AI)
Propositional Logic
Proposition:
A proposition is a collection of declarative
statements that has either a truth value "true”
or a truth value "false“ but cannot be both.

Eg: Today is Friday


2+2=5
Propositional Logic

- A Logic that deals with different Propositions for


reasoning is called Propositional Logic

-Representation:
Variables are used to represent proposition
Example:
p: Today is Friday

-We say that the truth value of a proposition is


either true (T) or false (F).
The Statement/Proposition Game
“Elephants are bigger than mice.”

Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? true
The Statement/Proposition Game
“520 < 111”

Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? false
The Statement/Proposition Game
“Kathmandu is capital of Nepal”

Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? true
The Statement/Proposition Game
“y > 5”
Is this a statement? yes

Is this a proposition? no
Y>5 is a statement but cannot be
said as propositional logic
because it is not declarative as it
depends on the value of y
The Statement/Proposition Game
“Today is January 27 and 99 < 5.”

Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? false
The Statement/Proposition Game
“If the moon is made of cheese,
then I will be rich.”
Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? probably
true
The Statement/Proposition Game
“Please do not fall asleep.”

Is this a statement? no

Is this a proposition? no
What is the truth value
of the proposition? Undefined
The Statement/Proposition Game
“Send Us your resume before 11pm.”

Is this a statement? no

Is this a proposition? no
What is the truth value
of the proposition? Undefined
The Statement/Proposition Game
“What time it is?”

Is this a statement? no

Is this a proposition? no
What is the truth value
of the proposition? Undefined
The Statement/Proposition Game
“x < y if and only if y > x.”

Is this a statement? yes

Is this a proposition? yes


What is the truth value
of the proposition? true
Propositional Logic
Compound Proposition:
-when multiple Propositions are combined together to
form a single proposition, the resulting Proposition is called
compound proposition

- To form a compound proposition, different connectives or


logical operators are used

-A proposition which does not require the use of any


connective is called atomic, while one which is composed
out of other propositions combined by means of
connectives is compound.
Propositional Logic
• In Propositional Logic,
– Following connectives are used
1) Negation (NOT, ¬ or ~ )
2) Conjunction (AND, ∧ )
3) Disjunction (OR, ∨ )
4) Exclusive-or (XOR, ⊕ )
5) Implication (if – then, → )
6)  Biconditional (if and only if, ↔ )
Negation
Let p be a proposition then negation of p is
denoted by ~p or ¬p and read as
“ not p “ or “It is not the case that p “
It is Unary Operator
eg: p: Today is Friday
┐p : Today is not Friday
or
It is not the case that
today is Friday
Negation

Truth table of Negation


Conjunction
• Let p and q be two Propositions, then
conjunction of p,q is denoted by
pꓥq
And read as “p and q “

eg. p: Today is Friday


q: it is raining
p ꓥ q : Today is Friday and it is raining
Conjunction
The Truth value of conjunction is true if the truth values
of constituent Propositions are true otherwise false

p q pꓥq
T T T

T F F

F T F

F F F
Disjunction
• Let p and q be two Propositions, then
Disjunction of p,q is denoted by
pꓦq
And read as “p orq “

eg. p: Today is Friday


q: it is raining
p ꓦ q : Today is Friday or it is raining
Disjunction
The Truth value of Disjunction is true if the truth values of
any of constituent Propositions are true otherwise
false
p q pꓦq
T T T

T F T

F T T

F F F
Exclusive-or
• Binary Operator, Symbol: ⊕
• Truth Table is :
p q p⊕q
T T F

T F T

F T T

F F F
Implication
• Let p and q be two Propositions, then
Implication of p,q is denoted by
p→q
And read as
“ if p then q “ or “ p implies q”
Here, p is hypothesis(Sufficient Condition) and

q is conclusion( Necessary Condition)


Implication
Eg: “ if you will go on tour then we will Provide
you 10000
eg. p: You will go on tour
q: we will provide you 10000

written as:p → q
Implication

• Truth Table is :
p q p→q
T T T

T F F

F T T

F F T
Biconditional
• Let p and q be two Propositions, then Biconditional of p,q is
denoted by
p ↔q

And read as “p if and only if q “


Here, p and q both are sufficient and necessary
conditions for each other
Biconditional

• Truth Table is :
p q p↔q
T T T

T F F

F T F

F F T
Identity Compound Proposition form
• This is Tuesday and we have a maths lecture
• In order to get a job in this multinational
company , with c++ or java is mandatory
• Coffee or tea comes with dinner
• If I am elected, then I will lower taxes
• Shape is a triangle if and only if it has exactly
three sides
• I will stay at home only if im sick
Precedence Of Logical Operators
• Precedence operators helps us to decide
which operator will get evaluated first in
complicated looking propositions
Activity
• Find the truth value of given compound
proposition

p  q /\ ~p

If p is true and q is false


• we see that the construction of a compound
sentence may require some way of ensuring
the correct interpretation
• As with arithmetic, we can use brackets to
ensure the correct meaning.
• Also as with arithmetic (where we know that
in the sum 4+3×5 we should do the
multiplication before the addition) there are
precedence rules for how to write
propositions with fewer brackets.
Solution

p  (q /\ ~p)
T (F F)

F
F
Thus truth value of given proposition is False
Activity
1) What is the truth value of (p ⇒ (q∧r)) ⇒
(p∨q) if p and r are true, but q is false?

2) Given that the value of p =>q is false,


determine the value of
~p \/ ~q => q
Compound Proposition
• Construct the truth table of the following
Compound Propositions
i) p /\ ~q
ii) p -> ~q
iii) (p /\ ~q)  (~p \/ q)
iV) p  ~q /\ ~p ~q
v) (p∧¬q)∧¬r
Remove any unnecessary brackets
(p ⇒ (q∧r)) ⇒ (p∨q)

Since ∨ and ∧ have higher priority than⇒,

we can rewrite this as (p ⇒q ∧ r) ⇒p ∨ q

but removing the remaining brackets would


leave the expression ambiguous.
Activity
• Remove any unnecessary brackets

1) ((¬p)∨q) ⇒ (p ∧ q)
2) ((¬p)∨q)∨(p ∧ q)
3) (q ∨ r)∧(q⇒ r)
Types Of Compound Proposition

i) Tautology
ii) Contradiction
iii) Contingency
Tautology
• A Compound Proposition is said to be
tautology if its truth values are always true
no matter what the truth value of their
constituent proposition are.

Example p v ~p is tautology
Contradiction
• A Compound Proposition is said to be
Contradiction if its truth values are always
false no matter what the truth value of their
constituent proposition are.

Example p /\ ~p is
Contradiction
Contingency
• Contingency is a compound Proposition whose
truth values are combination of both true and
false
• Example ~p v q
P q ~p ~p\/ q
T T F T
T F F F
F T T T
F F T F
REMEMBER

The negation of any tautology is a


contradiction and the negation of
any contradiction is a tautology
Activity
• Show that the following Compound
Proposition are Tautology
1) p  (p V q)
2) [p /\ (p  q)]  q
3) P \/ q \/ (~p /\ ~q)

Show that the Given Compound Proposition is


Contradiction
~(~(p ∧ q) ↔ (~p) ∨ (~q))
Converse, Inverse and Contra-Positive of an
Implication
• Let,
p  q be an Implication
- A Statement q  p is called its Converse

- A Statement ~p  ~q is called its Inverse

- A Statement ~q  ~p is called its


Contra-Positive
Converse, Inverse and Contra-Positive of an
Implication
• If she smile , she is happy
pq
- Converse( q  p )
If she is happy, she smile
- Inverse(~p  ~q)
If she doesn’t smile, she is not happy
- Contrapositive( ~q  ~p)
If she is not happy, she doesn’t smile
Find Converse, Inverse and Contra-Positive of given Implication

1) If you are working hard then you are a topper

2) If you walked more, your leg hurt

3) If it snows today, I will ski tomorrow

4) If I wake up early, then I will lift weights

5) If I’m visiting pasupatinath then I’m in


kathmandu
REMEMBER

If the statement is true, then the


contrapositive is also logically true
If the converse is true, then the inverse is also
logically true.
Translating sentences into Statements of Propositional Logic

You can access the college internet only if you are a


computer science student or you are not fresher
To Solve:
i) Identify all the individual sentences in the
given sentence and represent them by
different variables
ii) Identify all the connectives used in the given
sentence
iii) Write an expression in terms of these
variables and connectives which is the
required statement of propositional logic
Translating sentences into Statements of Propositional Logic

You can access the college internet only if you are a


computer science student or you are not fresher
solution:
p: You can access the college internet
q: You are a computer science student
r: you are a fresher

p  (q \/ ~r)
Translate the given sentences into Statements of
Propositional Logic
Q1) Hiking is safe along the trail if and only if berries are ripe
along the trail and Bears have not been seen along the area.

Q2) To take discrete mathematics, you must have taken calculus


or a course in computer science.

Q3)  When you buy a new car from Acme Motor Company, you
get $2000 back in cash or a 2% car loan.

Q4)  School is closed if more than 2 feet of snow falls or if the


wind chill is below -100.
Solution
Q1):
p: Hiking is safe along the trail
q: Berries are ripe along the trial
r: Bears have been seen along the area

•p  (q /\ ~r)
Q2 :
p: take discrete mathematics
q: take calculus
r: take a course in computer science

• p → (q ∨ r)
Solution
Q3:
p: buy a car from Acme Motor Company
q: get $2000 cash back
r: get a 2% car loan

• p → (q ⊕ r)
Q4 :
p: School is closed
q: 2 feet of snow falls
r: wind chill is below -100

• (q ∨ r) → p
Assignment
• We consider the problem of controlling a nuclear reactor. Given
the atomic sentences
‘The operator presses the alarm’,
‘The reactor is in danger of melting down’
‘The control process closes down the reactor’,
‘The core temperature is rising rapidly’,
represent the first by a, the second by b, the third by c and the
last by d.
Convert into English
(a) b⇒ (a∨c)
(b) (a∧b) ⇒c
(c) (a∨d) ⇒ (c ⇔ b)

Вам также может понравиться