0% found this document useful (0 votes)
21 views37 pages

Discrete Structure 2

Uploaded by

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

Discrete Structure 2

Uploaded by

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

Discrete Structures

Lecture # 2

PMAS – Arid Agriculture University,


Rawalpindi
The Foundations: Logic

• Mathematical Logic is a tool for working with


compound statements

• Logic is the study of correct reasoning

• Use of logic

• In mathematics: to prove theorems

• In computer science: to prove that programs do


what they are supposed to do
Propositional Logic

• Propositional logic: It deals with propositions.


• The area of logic that deals with propositions

• Predicate logic: It deals with predicates.


• The area of logic that deals with predicates
Definition of a Proposition
Definition: A proposition (usually denoted by p, q, r, …) is
a declarative statement that is either True (T) or False (F),
but not both or somewhere “in between!”.

Propositional Variables
• Variables that represent propositions
• Conventional letters are : p, q, r, s, . . .
• Truth values: T(true), F(false)

Note: Commands and questions are not propositions.


Examples of Propositions

The following are all propositions:


• “It is raining” (In a given situation)
• “Amman is the capital of Jordan”
• “1 + 2 = 3” or "2+2 = 3”
• Two plus two is equal to four.
• Toronto is the capital of Canada.
• etc.
Examples of Propositions

But, the following are NOT propositions:

• “Who’s there?” (Question)


• “La la la la la.” (Meaningless)
• “Just do it!” (Command)
• “1 + 2” (Expression with a non-true/false value)
• “1 + 2 = x” (Expression with unknown value of x)
Operators / Connectives

An operator or connective combines one or more


operand expressions into a larger expression. (e.g., “+”
in numeric expression.)

• Unary operators take 1 operand (e.g. −3);

• Binary operators take 2 operands (e.g. 3  4).

• Propositional or Boolean operators operate on


propositions (or their truth values) instead of on numbers.
Compound Statement (Propositions)
Complicated logical statements build out of simple ones
Three Symbols
• ~ (not) --- ~ p (not p)
• Λ (and) --- pΛq (p and q)
• V (or) --- pVq (p or q)
~ p (Negation), pΛq (Conjunction), pVq (Disjunctions)
English words to logic
• “p but q” means “p and q”
• “neither p nor q” means “~ p and ~ q”
Some Popular Boolean Operators

Formal Name Nickname Arity Symbol

Negation operator NOT Unary ¬


Conjunction operator AND Binary 
Disjunction operator OR Binary 
Exclusive-OR operator XOR Binary 
Implication operator IMPLIES Binary 
Biconditional operator IFF Binary ↔
The Negation Operator

Definition: Let p be a proposition then ¬p is the


negation of p (Not p , it is not the case that p).
e.g. If p = “London is a city”
Truth Table: Method to show the relationship of propositions
then ¬p = “London is not a city” or “ it is not the
case that London is a city” p p
The truth table for NOT: F T
T F
T :≡ True; F :≡ False Operand Result
“:≡” means “is defined as”. column column
Examples

1. Let p = “Ahmad’s PC runs Linux”


•~p?
2. Let H = “It is hot”
S= “It is Sunny”
(i). “It is not hot but it is Sunny”
“_______________”
(ii). “It is neither hot nor Sunny”
“_______________”
The Conjunction Operator
Definition: Let p and q be propositions, the proposition “p AND q”
denoted by (p  q) is called the conjunction of p and q.

The conjunction of the statements P and Q is the statement


“P and Q” and its denoted by P ∧ Q. The statement P ∧ Q is
true only when both P and Q are true.

e.g. If p = “I will have salad for lunch” and


q = “I will have steak for dinner”, then
p  q = “I will have salad for lunch and
I will have steak for dinner”

Remember: “” points up like an “A”, and it means “AND”


Conjunction Truth Table

• Note that a conjunction p1  p2  …  pn of n


propositions will have 2n rows in its truth table.

“And”, “But”, “In addition to”, “Moreover”. Ex: The


sun is shining but it is raining
Operand columns
p q p q
F F F
F T F
T F F
T T T
The Disjunction Operator

Definition: Let p and q be propositions, the proposition “p


OR q” denoted by (p  q) is called the disjunction of p
and q.

The disjunction of the statements P and Q is the statement


“P or Q” and its denoted by P ∨ Q. The statement P ∨
Q is true only when at least one of P or Q is true.

e.g. p = “My car has a bad engine”


q = “My car has a bad carburetor”
p  q = “Either my car has a bad engine or my car has
a bad carburetor”
Disjunction Truth Table

• Note that p  q means that p is true, or q is true, or


both are true!

• So, this operation is also called inclusive or,


because it includes the possibility that both p and q
are true. p q p q
F F F Note the
F T T differences
from AND
T F T
T T T
Takeaway

• Rather memorizing, it is easier to remember the rules


summarized.

Operator Symbolic Summary of Truth Values


Conjunction P∧Q True only when both P and Q are true
Disjunction P∨Q False only when both P and Q are false
Negation (~ or ┐) ~P Opposite truth value of P
Compound Statements

• Let p, q, r be simple statements. We can form


other compound statements, such as

(p  q)  r

p  (q  r)

¬p  ¬q

(p  q)  (¬r  s)

and many others…
Truth Table – Example

• Lets try to build table for


1.~P ∧ Q
2.~P ∧ (Q ∨~P)
3.(P ∨ Q) ∧ ~(P ∧ Q)
4.~(~P)

P Q ~P ~P ∧ Q
T T
T F
F T
F F
Truth Table – Example – Cont..

• Lets try to build table for

1.~P ∧ Q

P Q ~P ~P ∧ Q
T F
T F
F T
F T
Truth Table – Example – Cont..

• Lets try to build table for

1.~P ∧ Q

P Q ~P ~P ∧ Q
T F F
F F F
T T T
F T F
Truth Table – Example – Cont..

• Lets try to build table for

1.~P ∧ Q

P Q ~P ~P ∧ Q
T T F F
T F F F
F T T T
F F T F
Truth Table – Example – (pq)r

p q r pq (p  q)  r
F F F
F F T
F T F
F T T
T F F
T F T
T T F
T T T
Truth Table – Example – Cont.. (pq)r

p q r pq (p  q)  r
F F F F F
F F T F F
F T F T F
F T T T T
T F F T F
T F T T T
T T F T F
T T T T T
Truth Table – Example

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F
Truth Table – Example – Cont..

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T F
F T
T F
F T
T F
F T
T F
F T
Truth Table – Example – Cont..

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T F T
T T T
F F F
F T T
T F T
T T T
F F F
F T T
Truth Table – Example – Cont..

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T F
T F
T F
T F
F T
F T
F T
F T
Truth Table – Example – Cont..

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T F F
T F F
F F F
T F F
T T T
T T T
F T F
T T T
Truth Table – Example – Cont..

1. ~P ∧ (Q ∨~R)
~P ∧ (Q
P Q R ~R Q ∨ ~R ~P
∨~R)
T T T F T F F
T T F T T F F
T F T F F F F
T F F T T F F
F T T F T T T
F T F T T T T
F F T F F T F
F F F T T T T
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T
T F
F T
F F
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T T
T F T
F T T
F F F
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T T
T F F
F T F
F F F
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T T F
T F F T
F T F T
F F F T
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T T F F
T F T T T
F T T T T
F F F T F
Truth Table – Example – Cont..

1. (P ∨ Q) ∧ ~(P ∧ Q)

~(P ∧
P Q P∨Q P∧Q (P ∨ Q) ∧ ~(P ∧ Q)
Q)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
A Simple Exercise

Let p = “It rained last night”,


q = “The sprinklers came on last night” ,
r = “The grass was wet this morning”.

Translate each of the following into English:

¬p =
r  ¬p =
¬rpq =
A Simple Exercise

Let p = “It rained last night”,


q = “The sprinklers came on last night” ,
r = “The grass was wet this morning”.
Translate each of the following into English:

¬p = “It didn’t rain last night”

r  ¬p = “The grass was wet this morning, and it didn’t rain last
night”

¬ r  p  q = “Either the grass wasn’t wet this morning, or it rained


last night, or the sprinklers came on last night”

You might also like