0% found this document useful (0 votes)
14 views

Discrete Structures lecture 1

Uploaded by

muradubaidullah8
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Discrete Structures lecture 1

Uploaded by

muradubaidullah8
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

COMP-121 - Discrete Structures

(Discrete Mathematics)
Fall 2024

Lecture-1

Introduction
Propositional Logic
Instructor: Mr. Nazeer Muhammad
Office: C1-102
Email : [email protected]
Rules

• Notebook/Register
• I encourage class participation
• Mobile phones – Silent or switch off
• 75% Attendance (No Relaxation)
• Arrive on time in class
• If you do not understand a point, raise your hand and ask me to
explain or contact during office hours
• No disturbance!!!! No Misconduct!!!!
• REMEMBER: Your first priority must be your studies
Course Objectives
• Deep understanding of discrete structures used in
Computer Science
• Developing problem solving and analytical skills
• Developing algorithmic and computational skills

• Ability to understand mathematical arguments and their design


• Understanding of logic
• Proofing techniques
Course Outline
• Formal Logic
• Quantifiers and Predicates
• Proof Techniques
• Number Theory
• Sequence and Summations
• Induction and Recursion
• Basic Set Theory
• Relations
• Functions
• Graphs
• Trees
Text Books

• Discrete Mathematics and its Applications 7th Ed. by


Kenneth H. Rosen, McGraw Hill Publisher.

• Discrete Mathematics with Applications 4th Ed. by


Susanna S., Thomson Learning, Inc.
Course Assessment/Grading
• For all assignments, do follow the formatting
guidelines given in course handbook.
• Submit all assignments on MS Team link.
• No credit for copied or late submissions.
• No relaxation for students found cheating in
any quiz or exam.
• To get good grade you must attend all lectures
and perform good in all course assessments.
Reasons to Study Discrete Structures

• Proof
Ability to understand and create mathematical
argument

• Gateway to more advanced CS courses


Data structures, algorithms, automata theory, formal
languages, Database, networks, operating system,
security etc.
Reasons to Study Discrete Structures
• It is the mathematics underlying almost all of
computer science:
• Program verification
• Analyzing algorithms for correctness and efficiency
• Finding efficient algorithms
• (for sorting, searching, etc.)
• Formalizing security requirements
• Designing cryptographic protocols for enhanced
security
• Graph Theory (Networks – both physical & social)
Problems solved using Discrete Math's
• How many secure passwords (using a specific number of
characters or digits)?
• Probability of winning a lottery?
• How can I encrypt a message?
• Shortest paths between two cities using public
transportation?
• How many steps required to sort 10,000 numbers? Is this
algorithm correct?
• How to design a circuit that multiply two integers?
Logic

Logic is the study of the principles and methods that


distinguishes between a valid and an invalid argument.

Logic deals with general reasoning laws, which you can


trust.
Applications
• Applied in proving program correctness and
verification
• Databases (Relational Algebra and calculus)
• Artificial Intelligence
Propositional Logic
• Proposition
• A proposition is a declarative statement that is either TRUE or FALSE, but not
both.

• Example 1
• 2 + 2 = 4.
• Lahore is the capital of Pakistan.
• It is Sunday today.
• Ali is student of this class.

• Example 2
• What time is it?
• X + 1 = 2.
• Close the door.
• Read this carefully.
Propositional Logic

• Letter are used to denote propositional variables, to


symbolically represent propositions.
• Letters used for this purpose are p, q, r, s,………
• A propositional can have one of two values: true (T) or false (F).

• Example
• p = “Islamabad is the capital of Pakistan”
• q = “17 is divisible by 3”
Propositional Logic
• The area of logic that deals with propositions is called the
Propositional Calculus or Propositional Logic.

• Compound Propositions are constructed by combining


one or more propositions using logical operators
(connectives).

• Examples
• “3 + 2 = 5” and “Lahore is a city in Pakistan”
• “The grass is green” or “ It is hot today”
Symbols for Logical Operators

Symbol Meaning
¬ Negation
∧ And, Conjunction
∨ Or, Disjunction
→ Implication
Bi-Conditional
Logical Operators (Logical connectives)
• Negation

• This just turns a false proposition to true and the opposite for a true
proposition.
• Symbol: ¬
• Let p is a proposition. The statement
“It is not the case that p.”
is another proposition, called the negation of p.

• The negation of p is written ¬p and read as “not p”.


Logical Operator - Negation
• Logical operators are defined by truth tables –tables
which give the output of the operator
¬ in the right-most
column.
• Here is the truth table for negation:

p ¬p
T F
P ¬P
F T
Logical Operator - Negation
• Example

Let p = “Today is Friday.”

The negation of p is

¬p = “It is not the case that today is Friday.”


¬p = “Today is not Friday.”
¬p = “It is not Friday today.”

• What is negation of following proposition: “My PC runs Linux”


Logical Operator - Conjunction
• Conjunction is a binary operator in that it operates on two
propositions when creating compound proposition. On
the other hand, negation is a unary operator.
• Conjunction corresponds to English “and.”
• Symbol: ∧
• 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 ∧qis true when both p and q are true. If one
of these is false, than the compound statement is false as
well.
Logical Operator - Conjunction
• Truth Table

p q p∧q
T T T
T F F
F T F
F F F
Logical Operator - Conjunction
• Example

Let p = “Today is Friday.”


and q = “It is raining today.”

p ∧q = “Today is Friday and it is raining today.”


Logical Operator - Conjunction
• Hamza’s PC has more than 16 GB free hard disk space,
and the processor in Hamza’s PC runs faster than 1 GHz.

• It is cold but sunny.


Logical Operator - Disjunction

• Disjunction is also a binary operator.


• Disjunction corresponds to English “or.”
• Symbol:∨

• Let p and q be propositions. The disjunction of p and q,


denoted by p∨q, is the proposition “p or q”. The
conjunction p∨q is false when both p and q are false and
is true otherwise.
Logical Operator - Disjunction
• Truth Table

p q p∨q
T T T
T F T
F T T
F F F
Logical Operator - Disjunction
• Example

Let p = “Today is Friday.”


and q = “It is raining today.”

p∨q = “Today is Friday or it is raining today.”


Example

Let p = “it is hot”,


q = “it is sunny”

• It is hot and sunny p∧q

• It is not hot but sunny ¬p ∧ q

• It is neither hot nor sunny ¬p ∧ ¬q


Logical Operator – Exclusive Or
• Symbol: ⊕
• 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, and false
otherwise.
• Truth Table

p q p⊕ q
T T F
T F T
F T T
F F F
Logical Operator – Exclusive Or
• Example
Let p = “Students who have taken calculus can take this
class.”
and q = “Students who have taken computer science can
take this class.”

p ∨ q = “Students who have taken calculus or computer


science can take this class.”
p ⊕ q = “Students who have taken calculus or
computer science, but not both, can enroll in this
class.”
Exclusive or Versus Inclusive or (Disjunction)

• Coffee or tea comes with dinner. Exclusive or

• A password must have at least three digits or be at least


five characters long. Inclusive or

• Lunch includes soup or salad. Exclusive or

• Experience with C++ or Java is required. Inclusive or


Logical Operator – Implication
• p → q corresponds to English “if p then q,” or “p implies
q.”
• Symbol: →
• The implication p → q is the proposition that is false when
p is true and q is false, and true otherwise.
p→q

• Examples
• If it is raining then it is cloudy.
Hypothesis Conclusion
• If you get 100% on the final, then you will get an A.
• If p then 2+2 = 4.
Logical Operator – Implication
• Truth Table

p q p→q
T T T
T F F
F T T
F F T
Logical Operator – Implication

• Alternate ways of stating an implication

• p implies q
• If p, q
• p only if q
• p is sufficient for q
• q if p
• q whenever p
• q is necessary for p
Implication - Example
p: you get 100% on the final
q: you will get an A
• p implies that q.
you get 100% on the final implies that you will get an A.
• If p, then q.
If you get 100% on the final, then that you will get an A.
• If p, q.
If you get 100% on the final, that you will get an A.
• p is sufficient for q.
Get 100% on the final is sufficient for getting an A.
• q if p.
you will get an A if you get 100% on the final.
• q unless ¬ p.
you will get an A unless you don’t get 100% on final.
Logical Operator – Implication

• Converse
The proposition q → p is converse of p → q.

• Contrapositive
The contrapositive of p → q is the proposition ¬q →¬p.

• Inverse
The proposition ¬p →¬q is called the inverse of p → q.
Logical Operator – Implication
• Example

“The home team wins whenever it is raining?”


Because “q whenever p”, so p → q, the original statement
can be rewritten as “If it is raining, then the home team wins.”

• Contrapositive
“If the home team does not win, then it is not raining.”
• Converse
“If the home team wins, then it is raining.”
• Inverse
“If it is not raining, then the home team does not win.”
Logical Operator – Bi-conditional
•p q corresponds to English “p if and only if q.”
• Symbol:
• The bi-conditional statement p q is true when p and q
have the same truth values, and is false otherwise.
• Bi-conditional statements are also called bi-implications.
• Alternatively, it means “(if p then q) and (if q then p)”

• Example
• “You can take the flight if and only if you buy a ticket.”
Logical Operator – Bi-conditional
• Truth Table

p q p q
T T T
T F F
F T F
F F T
Logical Operator – Bi-conditional
p: You can take flight
q: You buy a ticket
𝑝𝑝 𝑞𝑞
You can take flight if and only if you buy a ticket
What is the truth value when:
• you buy a ticket and you can take the flight ??
• 𝑇𝑇 𝑇𝑇 ≡ 𝑇𝑇
• you don’t buy a ticket and you can’t take the flight ??
• 𝐹𝐹 𝐹𝐹 ≡ 𝑇𝑇
• you buy a ticket but you can’t take the flight ??
• 𝑇𝑇 𝐹𝐹 ≡ 𝐹𝐹
• you can’t buy a ticket but can take the flight ??
• 𝐹𝐹 𝑇𝑇 ≡ 𝐹𝐹
Logical Operator – Bi-conditional

• Other English equivalents:

• “p if and only if q”
• “p is equivalent to q”
• “p is necessary and sufficient for q”
• “p iff q”
• “If p then q, and conversely”
Bi-conditional -Example
p: “You can take the flight”
q: “You buy a ticket”
p q:

You can take the flight if and only if you buy a ticket

You can take the flight iff you buy a ticket

The fact that you can take the flight is necessary and
sufficient for buying a ticket
Logical Operators Summary

Not Not And Or Xor Implication Bi-conditional


p q ¬p ¬q p∧ q p∨q p⊕q p→q p q
T T F F T T F T T
T F F T F T T F F
F T T F F T T T F
F F T T F F F T T
Truth Table of Compound Propositions
• Construction of a truth table:
• Rows
• Need a row for every possible combination of values for the every
propositions.
• Columns
• Need a column for the compound proposition (usually at far right)
• Need a column for the truth value of each expression that occurs in
the compound proposition as it is built up.
• This includes the atomic propositions
Truth Table of Compound Propositions
• (p ∨¬q) → (p ∧ q)

p q ¬q p ∨¬q p∧q (p ∨¬q) → (p ∧ q)

T T F T T T
T F T T F F
F T F F F T
F F T T F F
Truth Table of Compound Propositions
• p → (¬q ∧ r )

p q r ¬q ¬q ∧ r p → (¬q ∧ r )

T T T F F F
T T F F F F
T F T T T T
T F F T F F
F T T F F T
F T F F F T
F F T T T T
F F F T F T
Precedence of Logical Operators
• Just as in algebra, operators have precedence

4+3*2 = 4+(3*2), not (4+3)*2

Operator Precedence
• Example
¬ 1
This means that
∧ 2
p ∨ q ∧ ¬r → s t ∨ 3
yields: (p ∨ (q ∧ (¬r)) → s) (t) → 4
5
Truth Tables
• Construct the truth table of following compound
propositions
• p →¬p
• p⊕p
• (q →¬p) (p q)
Chapter Reading
• Chapter 1, Kenneth H. Rosen, Discrete Mathematics and
Its Applications
Chapter Exercise ( For Practice)
• Question # 1, 2, 3, 4, 8, 9, 13, 24, 27, 28, 31, 32

You might also like