Ch01-Lecture 1&2 (Week 1)
Ch01-Lecture 1&2 (Week 1)
Discrete Structures I
Chapter 01
The Foundations: Logic and Proofs
1
Course Information
• Grading:
– Participation: 10%
– Assignments and Quizzes : 20%
– Midterm Exam: 20%
– Final Exam: 50%
2
Lectures Reference
Textbook 2018
3
DM is a Gateway Course
5
Chapter 1: Logic
• Introduction to Propositional Logic.
• Compound Propositions.
• Applications of Propositional Logic.
• Propositional Equivalences.
6
Introduction to Propositional Logic (1/4)
What is Logic?
• Logic is the discipline that deals with the methods of
reasoning.
• On an elementary level, logic provides rules and
techniques for determining whether a given argument is
valid.
• Logical reasoning is used in mathematics to prove
theorems.
7
Introduction to Propositional Logic (2/4)
8
Introduction to Propositional Logic (3/4)
Examples:
Propositions Truth value
2 + 3 =5 True
5 − 2 =1 False
Today is Friday False
𝑥+3 =7 , for 𝑥 = 4 True
Cairo is the capital of Egypt True
Sentences Is a Proposition
What time is it? Not propositions
Read this carefully. Not propositions
𝑥+3 =7 Not propositions
9
Introduction to Propositional Logic (4/4)
10
Compound Propositions (1/23)
Compound Proposition
• Compound Propositions are formed from existing
propositions using logical operators.
11
Compound Propositions (2/23)
Negation
12
Compound Propositions (3/23)
Example
Find the negation of the proposition
𝑝: “Cairo is the capital of Egypt”
13
Compound Propositions (4/23)
Example: Solution
Find the negation of the proposition
𝑝: “Cairo is the capital of Egypt”
The negation is
¬𝑝: “It is not the case that Cairo is the capital of Egypt”
This negation can be more simply expressed as
¬𝑝: “Cairo is not the capital of Egypt”
14
Compound Propositions (5/23)
Truth Table
• Truth Table: is a table that gives the truth values of a compound
statement.
𝒑 ¬𝒑
Proposition
𝑇
Truth Values 𝐹
15
Compound Propositions (5/23)
Truth Table
• Truth Table: is a table that gives the truth values of a compound
statement.
𝒑 ¬𝒑
Proposition
𝑇 𝐹
Truth Values 𝐹 𝑇
16
Compound Propositions (6/23)
Negation
17
Compound Propositions (7/23)
Logical Connectives
Example
𝑝: Today is Friday.
𝑞: It is raining today.
𝑝 ∧ 𝑞: Today is Friday and it is
raining today.
18
Compound Propositions (8/23)
Logical Connectives
Example
𝑝: Today is Friday.
𝑞: It is raining today.
𝑝 ∨ 𝑞: Today is Friday or it
is raining today.
19
Compound Propositions (9/23)
Logical Connectives
Example
20
Compound Propositions (10/23)
Logical Connectives
21
Compound Propositions (10/23)
Logical Connectives
22
Compound Propositions (11/23)
Logical Connectives
1
23
Compound Propositions (12/23)
Logical Connectives
2
24
Compound Propositions (12/23)
Logical Connectives
2
25
Compound Propositions (13/23)
Logical Connectives
3
26
Compound Propositions (13/23)
Logical Connectives
3
27
Compound Propositions (14/23)
Logical Connectives
28
Compound Propositions (15/23)
29
Compound Propositions (16/23)
30
Compound Propositions (16/23)
31
Compound Propositions (16/23)
32
Compound Propositions (16/23)
33
Compound Propositions (16/23)
34
Compound Propositions (17/23)
35
Compound Propositions (18/23)
36
Compound Propositions (19/23)
𝒑 𝒒 𝒓 ¬𝒒 𝒑 ∧ ¬𝒒 𝒑 ∧ ¬𝒒 →𝒓
37
Compound Propositions (19/23)
𝒑 𝒒 𝒓 ¬𝒒 𝒑 ∧ ¬𝒒 𝒑 ∧ ¬𝒒 →𝒓
𝐓 𝐓 𝐓
𝐓 𝐓 𝐅
𝐓 𝐅 𝐓
𝐓 𝐅 𝐅
𝐅 𝐓 𝐓
𝐅 𝐓 𝐅
𝐅 𝐅 𝐓
𝐅 𝐅 𝐅
38
Compound Propositions (19/23)
𝒑 𝒒 𝒓 ¬𝒒 𝒑 ∧ ¬𝒒 𝒑 ∧ ¬𝒒 →𝒓
𝐓 𝐓 𝐓 𝐅
𝐓 𝐓 𝐅 𝐅
𝐓 𝐅 𝐓 𝐓
𝐓 𝐅 𝐅 𝐓
𝐅 𝐓 𝐓 𝐅
𝐅 𝐓 𝐅 𝐅
𝐅 𝐅 𝐓 𝐓
𝐅 𝐅 𝐅 𝐓
39
Compound Propositions (19/23)
𝒑 𝒒 𝒓 ¬𝒒 𝒑 ∧ ¬𝒒 𝒑 ∧ ¬𝒒 →𝒓
𝐓 𝐓 𝐓 𝐅 𝐅
𝐓 𝐓 𝐅 𝐅 𝐅
𝐓 𝐅 𝐓 𝐓 𝐓
𝐓 𝐅 𝐅 𝐓 𝐓
𝐅 𝐓 𝐓 𝐅 𝐅
𝐅 𝐓 𝐅 𝐅 𝐅
𝐅 𝐅 𝐓 𝐓 𝐅
𝐅 𝐅 𝐅 𝐓 𝐅
40
Compound Propositions (19/23)
𝒑 𝒒 𝒓 ¬𝒒 𝒑 ∧ ¬𝒒 𝒑 ∧ ¬𝒒 →𝒓
𝐓 𝐓 𝐓 𝐅 𝐅 𝐓
𝐓 𝐓 𝐅 𝐅 𝐅 𝐓
𝐓 𝐅 𝐓 𝐓 𝐓 𝐓
𝐓 𝐅 𝐅 𝐓 𝐓 𝐅
𝐅 𝐓 𝐓 𝐅 𝐅 𝐓
𝐅 𝐓 𝐅 𝐅 𝐅 𝐓
𝐅 𝐅 𝐓 𝐓 𝐅 𝐓
𝐅 𝐅 𝐅 𝐓 𝐅 𝐓
41
Compound Propositions (20/23)
42
Compound Propositions (21/23)
43
Compound Propositions (22/23)
Bit Strings
• Information is often represented using bit strings, which
are lists of zeros and ones. When this is done, operations
on the bit strings can be used to manipulate this
information.
44
Compound Propositions (23/23)
Example
• Find the bitwise OR, bitwise AND, and bitwise XOR of
the bit strings 01 1011 0110 and 11 0001 1101
45
Applications of Propositional Logic (1/13)
2- System Specifications.
3- Boolean Searches.
4- Logic Puzzles.
5- Logic Circuits.
46
Applications of Propositional Logic (1/13)
2- System Specifications.
3- Boolean Searches.
4- Logic Puzzles.
5- Logic Circuits.
47
Applications of Propositional Logic (1/13)
48
Applications of Propositional Logic (3/13)
Example 1
You can access the Internet from campus only if you are a
computer science major or you are not a student.
49
Applications of Propositional Logic (4/13)
Example 1
You can access the Internet from campus only if you are a
computer science major or you are not a student.
50
Applications of Propositional Logic (4/13)
Example 1
(You can access the Internet from campus) only if (you are
a computer science major or you are not a student).
51
Applications of Propositional Logic (5/13)
Example 1
(You can access the Internet from campus) only if (you are
a computer science major or you are not a student).
Example 2
The automated reply cannot be sent when the file system is
full.
53
Applications of Propositional Logic (7/13)
Example 2
The automated reply cannot be sent when the file system is
full.
54
Applications of Propositional Logic (8/13)
Example 2
(The automated reply cannot be sent) when (the file system
is full.)
55
Applications of Propositional Logic (9/13)
Logic Circuits
• A logic circuit (or digital circuit) receives input signals
𝑝1 , 𝑝2 , … , 𝑝𝑛 , each a bit [either 0 (off) or 1 (on)], and
produces output signals 𝑠1, 𝑠2, … , 𝑠𝑛, each a bit.
• In this course, we will restrict our attention to logic
circuits with a single output signal; in general, digital
circuits may have multiple outputs.
56
Applications of Propositional Logic (10/13)
Logic Circuits
• Complicated digital circuits can be constructed from
three basic circuits, called gates.
57
Applications of Propositional Logic (11/13)
Example 1
• Determine the output for the combinatorial circuit in the
following figure.
58
Applications of Propositional Logic (11/13)
Example 1
• Determine the output for the combinatorial circuit in the
following figure.
59
Applications of Propositional Logic (11/13)
Example 1
• Determine the output for the combinatorial circuit in the
following figure.
60
Applications of Propositional Logic (11/13)
Example 1
• Determine the output for the combinatorial circuit in the
following figure.
61
Applications of Propositional Logic (12/13)
Example 2
• Build a digital circuit that produces the output
(𝑝 ∨ ¬𝑟) ∧ (¬𝑝 ∨ (𝑞 ∨ ¬𝑟))
when given input bits 𝑝, 𝑞, and 𝑟.
62
Applications of Propositional Logic (13/13)
Example 2
(𝑝 ∨ ¬𝑟) ∧ (¬𝑝 ∨ (𝑞 ∨ ¬𝑟))
63
Applications of Propositional Logic (13/13)
Example 2
(𝑝 ∨ ¬𝑟) ∧ (¬𝑝 ∨ (𝑞 ∨ ¬𝑟))
64
Applications of Propositional Logic (13/13)
Example 2
(𝑝 ∨ ¬𝑟) ∧ (¬𝑝 ∨ (𝑞 ∨ ¬𝑟))
65
Compound Propositions Classification (1/2)
66
Compound Propositions Classification (2/2)
Example:
• Show that following conditional statement is a tautology
by using truth table
𝑝 ∧ 𝑞 →𝑝
𝒑 𝒒 𝒑 ∧𝒒 𝒑 ∧ 𝒒 →𝒑
67
Compound Propositions Classification (2/2)
Example:
• Show that following conditional statement is a tautology
by using truth table
𝑝 ∧ 𝑞 →𝑝
𝒑 𝒒 𝒑 ∧𝒒 𝒑 ∧ 𝒒 →𝒑
𝐓 𝐓 𝐓 𝐓
𝐓 𝐅 𝐅 𝐓
𝐅 𝐓 𝐅 𝐓
𝐅 𝐅 𝐅 𝐓
68
Logical Equivalences (1/6)
Logically equivalent:
≡
⇔
69
Logical Equivalences (2/6)
Example1:
70
Logical Equivalences (3/6)
Example1:
71
Logical Equivalences (3/6)
Example1:
72
Logical Equivalences (3/6)
Example1:
73
Logical Equivalences (3/6)
Example1:
74
Logical Equivalences (3/6)
Example1:
75
Logical Equivalences (3/6)
Example1:
76
Next class
77