-Dr. Jyoti Shokeen
(Assistant Professor, IT)
Logic
• Logic is the study of principles and methods
that distinguishes a valid and an invalid
argument.
• Logic helps in understanding mathematical
reasoning.
• Applications: Designing computer circuits,
construction of computer programs, etc.
Proposition
• It is a declarative statement that is either true
or false, but not both.
Q 1: 1. New Delhi is the capital of India.
2. Toronto is the capital of Canada.
3. 1+1=2
4. 2+2=3
Q 2: 1. What time is it?
2. Read this carefully.
3. x+1=2
4. x+y=z
Propositional Logic
• Area of logic that deals with propositions.
• Letters are used to denote propositional
variables.
Def 1: Let p be a proposition. The negation of p,
denoted by ¬p is the statement
“ It is not the case that p”
or
“not p"
Negation of p
Q3: Find the negation of:
1. “Swati’s smartphone has at least 64GB of
memory.
2. Swati drinks tea.
Truth table of Negation of a proposition
p ¬p
T F
F T
• Def 2: Let p and q be propositions. The
conjunction of p and q, denoted by p ∧ q, is
the proposition “p and q.” The conjunction p ∧
q is true when both p and q are true and is
false otherwise.
• Def 3: Let p and q be propositions. The
disjunction of p and q, denoted by p ∨ q, is
the proposition “p or q.” The disjunction p ∨ q
is false when both p and q are false and is true
otherwise.
Terminologies
• A formula is valid if it is true under every
possible assignment of values to its variables.
Ex: p ∨ ¬p is valid
• A formula is satisfiable if there is at least one
assignment of values to its variables that
makes the formula true. Ex: p ∧ q
• A formula is unsatisfiable if there is no
possible interpretation or assignment of
values to its variables that makes the formula
true. Ex: p ∧ ¬p
• Def 4: Let p and q be propositions. The
exclusive or of p and q, denoted by p ⊕ q, is
the proposition that is true when exactly one
of p and q is true and is false otherwise.
• Def 5: Let p and q be propositions. The
conditional statement p → q is the
proposition “if p, then q.” The conditional
statement p → q is false when p is true and q
is false, and true otherwise. p is hypothesis
(antecedant) and q is conclusion (consequent)
Q 4: Let p be the statement “Kaira learns
discrete mathematics” and q the statement
“Kaira find a good job.”
Express the statement p → q as a statement in
English.
Def 6: Let p and q be propositions. The biconditional
statement p ↔ q is the proposition “p if and only if
q.” The biconditional statement p ↔ q is true when p
and q have the same truth values, and is false
otherwise. Biconditional statements are also called bi-
implications.
Ex: Let p be the statement “You can take the flight,” and
let q be the statement “You buy a ticket.” Then p ↔ q
is the statement
“You can take the flight if and only if you buy a ticket.”
Or “The light is on if and only if the switch is up"
Q5: Construct the truth table of the compound
proposition (p ∨ ¬q) → (p ∧ q).
Precedence of Logical Operators
Operator Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5
p ∧ q ∨ r means (p ∧ q) ∨ r
Q6: Let p, and q be the propositions
p : I bought a lottery ticket this week.
q : I won the million dollar jackpot.
Express each of these propositions as an English
sentence.
a) ¬p b) p ∨ q c) p → q
d) p ∧ q e) p ↔ q f ) ¬p → ¬q
g) ¬p ∧ ¬q h) ¬p ∨ (p ∧ q)
Q7: Let p, q, and r be the propositions
p : You have the flu.
q : You miss the final examination.
r : You pass the course.
Express each of these propositions as an English
sentence.
a) p → q b) ¬q ↔ r
c) q → ¬r d) p ∨ q ∨ r
e) (p → ¬r) ∨ (q → ¬r)
f ) (p ∧ q) ∨ (¬q ∧ r)
Sol: p: You have the flu.
q: You miss the final examination.
r: You pass the course.
a) p→q: If you have the flu, then you miss the final
examination.
b) ¬q↔r: You do not miss the final examination if and only if
you pass the course.
c) q→¬r: If you miss the final examination, then you do not
pass the course.
d) p∨q∨r: You have the flu, or you miss the final examination,
or you pass the course.
e) (p→¬r)∨(q→¬r): Either if you have the flu then you do not
pass the course, or if you miss the final examination then
you do not pass the course.
f) (p∧q)∨(¬q∧r): Either you have the flu and miss the final
examination, or you do not miss the final examination and
you pass the course.
Q8: Let p,q,r denotes the statements “It is
raining”, “It is cold”, and “It is pleasant”,
respectively. Then represent the following
statement in the mathematical formula “It is
not raining and it is pleasant, and it is not
pleasant only if it is raining and it is cold”.
Sol: p: “It is raining”
q:“It is cold”
r: “It is pleasant”
Given Statement:
“It is not raining and it is pleasant, and it is not
pleasant only if it is raining and it is cold.”
“It is not raining and it is pleasant” :¬p ∧ r
“It is not pleasant only if it is raining and it is cold”
¬r→(p ∧ q)
(¬p ∧ r)∧(¬r→(p ∧ q)
Q9: Let p and q be the propositions
p : You drive over 65 miles per hour.
q : You get a speeding ticket.
Write these propositions using p and q and logical
connectives (including negations).
a) You do not drive over 65 miles per hour.
b) You drive over 65 miles per hour, but you do not
get a speeding ticket.
c) You will get a speeding ticket if you drive over 65
miles per hour.
d) If you do not drive over 65 miles per hour, then
you will not get a speeding ticket.
e) Driving over 65 miles per hour is sufficient for
getting a speeding ticket.
f ) You get a speeding ticket, but you do not
drive over 65 miles per hour.
g) Whenever you get a speeding ticket, you are
driving over 65 miles per hour.
Sol: a) ¬p
b) p∧¬q
c) p→q
d) ¬p→¬q
e) p→q
f) q∧¬p
g) q→p
Predicate Logic
• Predicates are statements that contain
variables.
• Predicate quantifiers are symbols that specify
the extent to which a predicate is true over a
range of elements.
• Predicates are functions that return true or
false.
Ex: Let P(x)= "x is a prime number"
When x=2, P(2) is true & when x=4, P(4) is false
1. Universal Quantifier (∀) "For all" or "for
every”.
• Used to assert that a predicate or property
holds for every element in a given domain.
• Def: ∀x P(x) means that the predicate P(x) is
true for every value of x in the domain of
discourse.
Ex: Statement: "All humans are mortal."
Formal Expression: ∀x (H(x)→M(x))
– Where H(x) denotes "x is a human" and M(x)
denotes "x is mortal."
– For every x, if x is a human, then x is mortal.
2. Existential Quantifier (∃)  "There exists" or
"there is at least one."
• Used to assert that there is at least one element
in the domain for which the predicate or property
holds.
• Def: ∃x P(x) means that there is at least one value
of x in the domain of discourse for which P(x) is
true.
Ex: Let P(x)be the predicate "x is a student." Then
∃x P(x) means "There exists at least one student."
Negation: The negation of an existential
statement is a universal statement. For
example, ¬(∃x P(x)) is equivalent to ∀x ¬P(x).
Rules of Inference
An argument is a sequence of statements. The
last statement is the conclusion and all its
preceding statements are called premises (or
hypothesis).
• Addition
Ex: Let P be the proposition, “He studies very
hard” is true
Therefore − "Either he studies very hard Or he is a
very bad student." Here Q is the proposition “he
is a very bad student”.
• Conjunction
Ex: Let P − “He studies very hard”
Let Q − “He is the best boy in the class”
Therefore − "He studies very hard and he is the best
boy in the class“
• Simplification
P∧Q -"He studies very hard and he is the best
boy in the class",
Therefore − "He studies very hard”
• Modus Ponens
P∧Q -"If you have a password, then you can
log on to facebook",
P -"You have a password",
Therefore − "You can log on to facebook"
• Modus Tollens
P→Q "If you have a password, then you can
log on to facebook"
¬Q "You cannot log on to facebook"
Therefore − "You do not have a password "
• Disjunctive Syllogism
¬P-"The ice cream is not vanilla flavored"
P∨Q"The ice cream is either vanilla flavored or
chocolate flavored"
Therefore "The ice cream is chocolate flavored”
• Hypothetical Syllogism
P→Q "If it rains, I shall not go to school”
Q→R "If I don't go to school, I won't need to do
homework"
Therefore − "If it rains, I won't need to do
homework"
• Constructive Dilemma
(P→Q) “If it rains, I will take a leave”,
(R→S) “If it is hot outside, I will go for a shower”,
P∨R “Either it will rain or it is hot outside”,
Therefore "I will take a leave or I will go for a shower“
• Destructive Dilemma
(P→Q) “If it rains, I will take a leave”,
(R→S) “If it is hot outside, I will go for a shower”,
¬Q∨¬S “Either I will not take a leave or I will not go for a
shower”,
Therefore − "Either it does not rain or it is not hot outside"
Examples
• Consider the following statements:
P: Good mobile phones are not cheap
Q: Cheap mobile phones are not good
L: P implies Q
M: Q implies P
N: P is equivalent to Q
Which of the following about L, M, and N is Correct?
(A) Only L is TRUE
(B) Only M is TRUE
(C) Only N is TRUE
(D) L, M, and N are TRUE
Examples
Let p and q be the following propositions:
p: Fail grade can be given.
q: Student scores more than 50% marks.
Consider the statement: “Fail grade cannot be
given when student scores more than 50%
marks.”
What is the representation of the above
statement in propositional logic?
Methods of Proofs
1. Forward Proof
2. Proof by Contradiction
3. Contrapositive proof
4. Proof of Necessity and sufficiency
Forward Proof
Example: Prove that if n is an even integer, then
n² is also even.
Given: n is even
Definition: n can be expressed as n=2k for some
integer k.
Proof:
Compute n² : n² =(2k)²
Note that 4k² =2⋅(2k²), which is clearly even.
Conclusion: n² is even.
Q: The square of an odd integer is odd.
Proof by Contradiction
Example: Prove that there is no smallest positive
rational number.
Statement: There is no smallest positive rational
number.
Assumption: Suppose there is a smallest positive
rational number, say r.
Proof:
Consider the number r/2​, which is also a positive
rational number and smaller than r.
This contradicts the assumption that r is the smallest
positive rational number.
Conclusion: Therefore, there is no smallest positive
rational number.
• Prove that √2 is irrational.
Proof by Contrapositive
Method:
• Form the Contrapositive: Convert the
statement P→Q into ¬Q→¬P.
• Prove the Contrapositive: Show that ¬Q→¬P
is true.
• Conclude the Original Statement: Since the
contrapositive is equivalent to the original
statement, proving it establishes the truth of
the original statement.
Proof by Contrapositive
Example: Prove that if n² is odd, then n is odd.
• Statement: If n² is odd, then n is odd.
• Contrapositive: If n is even, then n² is even.
• Proof:
– Assume n is even, so n=2k for some integer k.
– Compute n² =(2k)² =4k², which is even.
• Conclusion: Since the contrapositive is true,
the original statement is also true.
Proof of Necessity and sufficiency
• Let A: "X is a mammal"
• B: "X is a dog".
• A is a necessary condition for B: B A
• B is a sufficient condition for A: A B

this is the presentation on Discrete Structures

  • 1.
  • 2.
    Logic • Logic isthe study of principles and methods that distinguishes a valid and an invalid argument. • Logic helps in understanding mathematical reasoning. • Applications: Designing computer circuits, construction of computer programs, etc.
  • 3.
    Proposition • It isa declarative statement that is either true or false, but not both. Q 1: 1. New Delhi is the capital of India. 2. Toronto is the capital of Canada. 3. 1+1=2 4. 2+2=3
  • 4.
    Q 2: 1.What time is it? 2. Read this carefully. 3. x+1=2 4. x+y=z
  • 5.
    Propositional Logic • Areaof logic that deals with propositions. • Letters are used to denote propositional variables. Def 1: Let p be a proposition. The negation of p, denoted by ¬p is the statement “ It is not the case that p” or “not p"
  • 6.
    Negation of p Q3:Find the negation of: 1. “Swati’s smartphone has at least 64GB of memory. 2. Swati drinks tea. Truth table of Negation of a proposition p ¬p T F F T
  • 7.
    • Def 2:Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, is the proposition “p and q.” The conjunction p ∧ q is true when both p and q are true and is false otherwise. • Def 3: Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q, is the proposition “p or q.” The disjunction p ∨ q is false when both p and q are false and is true otherwise.
  • 8.
    Terminologies • A formulais valid if it is true under every possible assignment of values to its variables. Ex: p ∨ ¬p is valid • A formula is satisfiable if there is at least one assignment of values to its variables that makes the formula true. Ex: p ∧ q • A formula is unsatisfiable if there is no possible interpretation or assignment of values to its variables that makes the formula true. Ex: p ∧ ¬p
  • 9.
    • Def 4:Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕ q, is the proposition that is true when exactly one of p and q is true and is false otherwise. • Def 5: Let p and q be propositions. The conditional statement p → q is the proposition “if p, then q.” The conditional statement p → q is false when p is true and q is false, and true otherwise. p is hypothesis (antecedant) and q is conclusion (consequent)
  • 10.
    Q 4: Letp be the statement “Kaira learns discrete mathematics” and q the statement “Kaira find a good job.” Express the statement p → q as a statement in English.
  • 12.
    Def 6: Letp and q be propositions. The biconditional statement p ↔ q is the proposition “p if and only if q.” The biconditional statement p ↔ q is true when p and q have the same truth values, and is false otherwise. Biconditional statements are also called bi- implications. Ex: Let p be the statement “You can take the flight,” and let q be the statement “You buy a ticket.” Then p ↔ q is the statement “You can take the flight if and only if you buy a ticket.” Or “The light is on if and only if the switch is up"
  • 13.
    Q5: Construct thetruth table of the compound proposition (p ∨ ¬q) → (p ∧ q).
  • 14.
    Precedence of LogicalOperators Operator Precedence ¬ 1 ∧ 2 ∨ 3 → 4 ↔ 5 p ∧ q ∨ r means (p ∧ q) ∨ r
  • 15.
    Q6: Let p,and q be the propositions p : I bought a lottery ticket this week. q : I won the million dollar jackpot. Express each of these propositions as an English sentence. a) ¬p b) p ∨ q c) p → q d) p ∧ q e) p ↔ q f ) ¬p → ¬q g) ¬p ∧ ¬q h) ¬p ∨ (p ∧ q)
  • 16.
    Q7: Let p,q, and r be the propositions p : You have the flu. q : You miss the final examination. r : You pass the course. Express each of these propositions as an English sentence. a) p → q b) ¬q ↔ r c) q → ¬r d) p ∨ q ∨ r e) (p → ¬r) ∨ (q → ¬r) f ) (p ∧ q) ∨ (¬q ∧ r)
  • 17.
    Sol: p: Youhave the flu. q: You miss the final examination. r: You pass the course. a) p→q: If you have the flu, then you miss the final examination. b) ¬q↔r: You do not miss the final examination if and only if you pass the course. c) q→¬r: If you miss the final examination, then you do not pass the course. d) p∨q∨r: You have the flu, or you miss the final examination, or you pass the course. e) (p→¬r)∨(q→¬r): Either if you have the flu then you do not pass the course, or if you miss the final examination then you do not pass the course. f) (p∧q)∨(¬q∧r): Either you have the flu and miss the final examination, or you do not miss the final examination and you pass the course.
  • 18.
    Q8: Let p,q,rdenotes the statements “It is raining”, “It is cold”, and “It is pleasant”, respectively. Then represent the following statement in the mathematical formula “It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold”.
  • 19.
    Sol: p: “Itis raining” q:“It is cold” r: “It is pleasant” Given Statement: “It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold.” “It is not raining and it is pleasant” :¬p ∧ r “It is not pleasant only if it is raining and it is cold” ¬r→(p ∧ q) (¬p ∧ r)∧(¬r→(p ∧ q)
  • 20.
    Q9: Let pand q be the propositions p : You drive over 65 miles per hour. q : You get a speeding ticket. Write these propositions using p and q and logical connectives (including negations). a) You do not drive over 65 miles per hour. b) You drive over 65 miles per hour, but you do not get a speeding ticket. c) You will get a speeding ticket if you drive over 65 miles per hour. d) If you do not drive over 65 miles per hour, then you will not get a speeding ticket.
  • 21.
    e) Driving over65 miles per hour is sufficient for getting a speeding ticket. f ) You get a speeding ticket, but you do not drive over 65 miles per hour. g) Whenever you get a speeding ticket, you are driving over 65 miles per hour.
  • 22.
    Sol: a) ¬p b)p∧¬q c) p→q d) ¬p→¬q e) p→q f) q∧¬p g) q→p
  • 23.
    Predicate Logic • Predicatesare statements that contain variables. • Predicate quantifiers are symbols that specify the extent to which a predicate is true over a range of elements. • Predicates are functions that return true or false. Ex: Let P(x)= "x is a prime number" When x=2, P(2) is true & when x=4, P(4) is false
  • 24.
    1. Universal Quantifier(∀) "For all" or "for every”. • Used to assert that a predicate or property holds for every element in a given domain. • Def: ∀x P(x) means that the predicate P(x) is true for every value of x in the domain of discourse. Ex: Statement: "All humans are mortal." Formal Expression: ∀x (H(x)→M(x)) – Where H(x) denotes "x is a human" and M(x) denotes "x is mortal." – For every x, if x is a human, then x is mortal.
  • 25.
    2. Existential Quantifier(∃)  "There exists" or "there is at least one." • Used to assert that there is at least one element in the domain for which the predicate or property holds. • Def: ∃x P(x) means that there is at least one value of x in the domain of discourse for which P(x) is true. Ex: Let P(x)be the predicate "x is a student." Then ∃x P(x) means "There exists at least one student."
  • 26.
    Negation: The negationof an existential statement is a universal statement. For example, ¬(∃x P(x)) is equivalent to ∀x ¬P(x).
  • 27.
    Rules of Inference Anargument is a sequence of statements. The last statement is the conclusion and all its preceding statements are called premises (or hypothesis).
  • 29.
    • Addition Ex: LetP be the proposition, “He studies very hard” is true Therefore − "Either he studies very hard Or he is a very bad student." Here Q is the proposition “he is a very bad student”. • Conjunction Ex: Let P − “He studies very hard” Let Q − “He is the best boy in the class” Therefore − "He studies very hard and he is the best boy in the class“ • Simplification P∧Q -"He studies very hard and he is the best boy in the class", Therefore − "He studies very hard”
  • 30.
    • Modus Ponens P∧Q-"If you have a password, then you can log on to facebook", P -"You have a password", Therefore − "You can log on to facebook" • Modus Tollens P→Q "If you have a password, then you can log on to facebook" ¬Q "You cannot log on to facebook" Therefore − "You do not have a password "
  • 31.
    • Disjunctive Syllogism ¬P-"Theice cream is not vanilla flavored" P∨Q"The ice cream is either vanilla flavored or chocolate flavored" Therefore "The ice cream is chocolate flavored” • Hypothetical Syllogism P→Q "If it rains, I shall not go to school” Q→R "If I don't go to school, I won't need to do homework" Therefore − "If it rains, I won't need to do homework"
  • 32.
    • Constructive Dilemma (P→Q)“If it rains, I will take a leave”, (R→S) “If it is hot outside, I will go for a shower”, P∨R “Either it will rain or it is hot outside”, Therefore "I will take a leave or I will go for a shower“ • Destructive Dilemma (P→Q) “If it rains, I will take a leave”, (R→S) “If it is hot outside, I will go for a shower”, ¬Q∨¬S “Either I will not take a leave or I will not go for a shower”, Therefore − "Either it does not rain or it is not hot outside"
  • 33.
    Examples • Consider thefollowing statements: P: Good mobile phones are not cheap Q: Cheap mobile phones are not good L: P implies Q M: Q implies P N: P is equivalent to Q Which of the following about L, M, and N is Correct? (A) Only L is TRUE (B) Only M is TRUE (C) Only N is TRUE (D) L, M, and N are TRUE
  • 34.
    Examples Let p andq be the following propositions: p: Fail grade can be given. q: Student scores more than 50% marks. Consider the statement: “Fail grade cannot be given when student scores more than 50% marks.” What is the representation of the above statement in propositional logic?
  • 35.
    Methods of Proofs 1.Forward Proof 2. Proof by Contradiction 3. Contrapositive proof 4. Proof of Necessity and sufficiency
  • 36.
    Forward Proof Example: Provethat if n is an even integer, then n² is also even. Given: n is even Definition: n can be expressed as n=2k for some integer k. Proof: Compute n² : n² =(2k)² Note that 4k² =2⋅(2k²), which is clearly even. Conclusion: n² is even.
  • 37.
    Q: The squareof an odd integer is odd.
  • 38.
    Proof by Contradiction Example:Prove that there is no smallest positive rational number. Statement: There is no smallest positive rational number. Assumption: Suppose there is a smallest positive rational number, say r. Proof: Consider the number r/2​, which is also a positive rational number and smaller than r. This contradicts the assumption that r is the smallest positive rational number. Conclusion: Therefore, there is no smallest positive rational number.
  • 39.
    • Prove that√2 is irrational.
  • 40.
    Proof by Contrapositive Method: •Form the Contrapositive: Convert the statement P→Q into ¬Q→¬P. • Prove the Contrapositive: Show that ¬Q→¬P is true. • Conclude the Original Statement: Since the contrapositive is equivalent to the original statement, proving it establishes the truth of the original statement.
  • 41.
    Proof by Contrapositive Example:Prove that if n² is odd, then n is odd. • Statement: If n² is odd, then n is odd. • Contrapositive: If n is even, then n² is even. • Proof: – Assume n is even, so n=2k for some integer k. – Compute n² =(2k)² =4k², which is even. • Conclusion: Since the contrapositive is true, the original statement is also true.
  • 42.
    Proof of Necessityand sufficiency • Let A: "X is a mammal" • B: "X is a dog". • A is a necessary condition for B: B A • B is a sufficient condition for A: A B