Document

advertisement
‫‪MATH 226‬‬
‫رياضيات متقطعة لعلوم الحاسب‬
Text books:
 (Discrete Mathematics and its applications)
Kenneth H. Rosen, seventh Edition, 2012, McGrawHill
Introduction
 What is discrete mathematics?
Discrete mathematics is the part of mathematics
devoted to
( the study of discrete objects.)
(Here discrete means consisting of distinct or
unconnected elements.)
What is the main purpose for this
course?
- Give About Discrete Mathematics
- Understand the principles of mathematical logic
(Logic), and methods of evidence
- Identify Groups (Sets) and basic operations on groups
- Understand the different types of relationships and
- Boolean algebra (Boolean Algebra), Paul functions and
logical circuits (Logical Circuits)
- Graphs and trees
Chapter 1
1.1 Propositional Logic. 1
1.2 Applications of Propositional Logic
1.3 Propositional Equivalences . .
Section 1.1
Propositions
 A proposition is a declarative sentence that is either true or false.
 Examples of propositions:
a)
riyad is the capital of Saudi Arabia
b)
the color of blood is green
c)
1+0=1
d) 0 + 0 = 2
 Examples that are not propositions.
a)
Sit down!
b) What time is it?
c)
x+1=2
d) x + y = z
Propositions a and c are true, whereas b and d are false.
Propositional Logic
 Propositional Variables:
 We use letters to denote propositional variables
that is, variables that represent propositions
 Propositional Variables: p, q, r, s, …
 E.g. Proposition p – “Today is Friday.”
 Truth values – T, F
 The proposition that is always true is denoted by T and
the proposition that is always false is denoted by F.
 Propositional Logic – the area of logic that deals with
propositions
Compound Propositions
 Compound Propositions; constructed from logical
connectives and other propositions

Negation ¬
Conjunction ∧
Disjunction ∨

Implication →

Biconditional ↔


1.1 Compound Propositions: Negation
DEFINITION 1
Let p be a proposition. The negation of p, denoted by ¬p, is the
statement
“It is not the case that p.”
The proposition ¬p is read “not p.”
 Examples
 Find the negation of the proposition “Today is Friday.” and express
this in simple English.
Solution: The negation is “It is not the case that today is Friday.”
In simple English, “Today is not Friday.” or “It is not
Friday today.”
 Find the negation of the proposition ““Rana PC runs Linux”.” and
express this in simple English.
Solution: The negation is
“It is not the case that Rana PC runs Linux.”
This negation can be more simply expressed as
“Rana PC does not run Linux.”.”
10
 The truth value of the negation of p, ¬p is the opposite of
the truth value of p. has this truth table:
p
¬p
T
F
F
T
 Example: If p denotes “The earth is round.”, then ¬p
denotes “It is not the case that the earth is round,” or
more simply “The earth is not round.”
Conjunction
DEFINITION 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.
 Examples
 Find the conjunction of the propositions p and q where p is the
proposition “Today is Friday.” and q is the proposition “It is raining
today.”, and the truth value of the conjunction.
Solution: The conjunction is the proposition “Today is Friday and it
is raining today.” The proposition is true on rainy Fridays.
12
Conjunction
 (p ∧ q ) and has this truth table:
p
q
p∧q
T
T
T
T
F
F
F
T
F
F
F
F
 Example: If p denotes “I am at home.” and q denotes
“It is raining.” then p ∧q denotes “I am at home and it
is raining.”
Disjunction
DEFINITION 3
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.
 Note:
inclusive or : The disjunction is true when at least one of the two
propositions is true.
 E.g. “Students who have taken calculus or computer science can take this
class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true. p ⊕ q
 E.g. “Students who have taken calculus or computer science, but not both,
can take this class.” – only those who take one of them.
 Definition 3 uses inclusive or.
14
Disjunction
 truth table:
p
q
p ∨q
T
T
T
T
F
T
F
T
T
F
F
F
 Example: If p denotes “I am at home.” and q denotes
“It is raining.” then p ∨q denotes “I am at home or it is
raining.”
Implication(conditional statement )
DEFINITION 5
Let p and q be propositions. The conditional statement p → q, is
the proposition “if p, then q.” The conditional statement is false
when p is true and q is false, and true otherwise.
 and has this truth table:
p
q
p →q
T
T
T
T
F
F
F
T
T
F
F
T
 Example: If p denotes “I am at home.” and q denotes “It is
raining.” then p →q denotes “If I am at home then it is raining.”
 In p →q , p is the hypothesis and q is the conclusion
Understanding Implication
 Example:
 Let p be the statement “Marim learns discrete mathematics.” and q
the statement “Marim will find a good job.” Express the statement p
→ q as a statement in English.
Solution: Any of the following -
“If Marim learns discrete mathematics, then she will find a
good job.
“Marim will find a good job when she learns discrete
mathematics.”
“Marim will find a good job unless she does not learn
discrete mathematics.”
17
Converse, Contrapositive, and Inverse
 From p →q we can form new conditional statements .
 q →p
is the converse of p →q
 ¬q → ¬ p is the contrapositive of p →q
 ¬ p → ¬ q is the inverse of p →q
Example: Find the converse, inverse, and contrapositive of “It
raining is a sufficient condition for my not going to town.”
Solution:
converse: If I do not go to town, then it is raining.
inverse: If it is not raining, then I will go to town.
 contrapositive: If I go to town, then it is not raining.
NOTE :only the contrapositive always has the same truth
value as p → q.
Biconditional
 If p and q are propositions, then we can form the biconditional
proposition p ↔q , read as “p if and only if q .” The biconditional
p ↔q denotes the proposition with this truth table:
p
q
p ↔q
T
T
T
T
F
F
F
T
F
F
F
T
 If p denotes “I am at home.” and q denotes “It is raining.” then
p ↔q denotes “I am at home if and only if it is raining.”
Truth Tables of Compound Propositions
Example Truth Table
 Construct a truth table for
p
q
r
r
pq
p  q → r
T
T
T
F
T
F
T
T
F
T
T
T
T
F
T
F
T
F
T
F
F
T
T
T
F
T
T
F
T
F
F
T
F
T
T
T
F
F
T
F
F
T
F
F
F
T
F
T
Equivalent Propositions
 Two propositions are equivalent if they always have the
same truth value.
 Example: Show using a truth table that the
biconditional is equivalent to the contrapositive.
Solution:
p
q
¬p
¬q
p →q
¬q → ¬ p
T
T
F
F
T
T
T
F
F
T
F
F
F
T
T
F
T
T
F
F
T
T
F
T
Using a Truth Table to Show NonEquivalence
Example: Show using truth tables that neither the
converse nor inverse of an implication are not
equivalent to the implication.
Solution:
p
q
¬p
¬q
p →q
¬ p →¬ q
q→p
T
T
F
F
T
T
T
T
F
F
T
F
T
T
F
T
T
F
T
F
F
F
F
T
T
F
T
T
Problem
 How many rows are there in a truth table with n
propositional variables?
Solution: 2n We will see how to do this in Chapter 6.
 Note that this means that with n propositional
variables, we can construct 2n distinct (i.e., not
equivalent) propositions.
Precedence of Logical Operators
Operator
Precedence

1


2
3


4
5
p q  r is equivalent to (p q)  r
If the intended meaning is p (q  r )
then parentheses must be used.
Section 1.2
Translating English Sentences
 Steps to convert an English sentence to a statement in
propositional logic
 Identify atomic propositions and represent using
propositional variables.
 Determine appropriate logical connectives
 “If I go to Harry’s or to the country, I will not go
shopping.”
 p: I go to Harry’s
 q: I go to the country.
 r: I will go shopping.
If p or q then not r.
Example
Problem: Translate the following sentence into
propositional logic:
“You can access the Internet from campus only if you are
a computer science major or you are not a freshman.”
One Solution: Let a, c, and f represent respectively
“You can access the internet from campus,” “You are a
computer science major,” and “You are a freshman.”
a→ (c ∨ ¬ f )
Logic Circuits
(Studied in depth in Chapter 12)
 Electronic circuits; each input/output signal can be viewed as a 0 or 1.
 0
represents False
 1 represents True
 Complicated circuits are constructed from three basic circuits called gates.
The inverter (NOT gate)takes an input bit and produces the negation of that bit.
 The OR gate takes two input bits and produces the value equivalent to the disjunction of the two
bits.
 The AND gate takes two input bits and produces the value equivalent to the conjunction of the
two bits.

 More complicated digital circuits can be constructed by combining these basic circuits to
produce the desired output given the input signals by building a circuit for each piece of
the output expression and then combining them. For example:
Section 1.3
Logically Equivalent



We write this as p⇔q or as p≡q where p and q are compound
propositions.
Two compound propositions p and q are equivalent if and only if the
columns in a truth table giving their truth values agree.
This truth table show ¬p ∨ q is equivalent to p → q.
p
q
¬p
¬p ∨ q
p→ q
T
T
F
T
T
T
F
F
F
F
F
T
T
T
T
F
F
T
T
T
De Morgan’s Laws
Augustus De Morgan
1806-1871
This truth table shows that De Morgan’s Second Law holds.
p
q
¬p
¬q
(p∨q)
¬(p∨q)
¬p∧¬q
T
T
F
F
T
F
F
T
F
F
T
T
F
F
F
T
T
F
T
F
F
F
F
T
T
F
T
T
Key Logical Equivalences (cont)
 Commutative Laws:
 Associative Laws:
 Distributive Laws:
 Absorption Laws:
,
Key Logical Equivalences
 Identity Laws:
,
 Domination Laws:
,
 Idempotent laws:
,
 Double Negation Law:
 Negation Laws:
,
More Logical Equivalences
Equivalence Proofs
Example: Show that
is logically equivalent to
Solution:
Equivalence Proofs
Example: Show that
is a tautology.
Solution:
Download