Você está na página 1de 43

DISCRETE MATHEMATICS

Lecture 1
Dr. Kemal Akkaya
Department of Computer Science

Kemal Akkaya Discrete Mathematics 1


Course Organization
 Instructor: Dr. Kemal Akkaya
Office: FANER 2138
Office Phone: 453-6054
E-Mail Address: kemal at cs dot siu dot edu
Office Hours: MWF: 10-11am or by appointment 
 TA: Mr. Enes Yildiz
Office: FANER 3129
Office Phone:453-6036
E-Mail Address: eyildiz at siu dot edu
Office Hours: TR:10-11am

Kemal Akkaya Discrete Mathematics 2


Textbook
 Discrete Mathematics
and Its Applications by
Kenneth H. Rosen. 6th
edition, McGraw Hill
Publisher.
 Class Hours: MWF 11-11:50am PARK 107
 Webpage: www.cs.siu.edu/~cs215
 The course slides are adapted from publisher’s
(Rosen) website. I thank the author and
publisher.
Kemal Akkaya Discrete Mathematics 3
So, What’s this class about?

What are “discrete structures” anyway?


 “Discrete” ( “discreet”!) - Composed of
distinct, separable parts. (Opposite of
continuous.)
discrete:continuous :: digital:analog
 “Structures” - Objects built up from simpler
objects according to some definite pattern.
 “Discrete Mathematics” - The study of
discrete, mathematical objects and structures.

Kemal Akkaya Discrete Mathematics 4


Some Discrete Structures
 Propositions  Sequences
 Predicates  Strings
 Proofs  Permutations
 Sets  Combinations
 Functions  Relations
 Orders of Growth  Graphs
 Algorithms  Trees
 Integers  Logic Circuits
 Summations  Automata

Kemal Akkaya Discrete Mathematics 5


Relationships Between Structures
 “→” :≝ “Can be defined in terms of”
Groups Programs Proofs
Operators Trees
Complex
numbers Propositions
Graphs
Real numbers Strings
Integers Functions
Natural Relations Matrices
numbers Sequences
Infinite Bits n-tuples
ordinals Vectors
Sets Not all possibilities
are shown here.

Kemal Akkaya Discrete Mathematics 6


Some Notations We’ll Learn

p pq pq pq pq x P( x)


x P( x) {a1 ,, an } Z, N, R  {x | P( x)} xS
n
 S T |S| A B A A i
i 1
n
f :A B f 1 ( x) f g  x a
 S
 a
i 1
i

O, ,  min, max a /| b gcd, lcm mod a  b (mod m)


n
( a k  a0 ) b [aij ] AT AΟ B A[ n ]  
r
C (n; n1 ,, nm ) p( E | F ) R  [ a ]R deg  (v)

Kemal Akkaya Discrete Mathematics 7


Why Study Discrete Math?
 The basis of all of digital information
processing is: Discrete manipulations of
discrete structures represented in memory.
 It’s the basic language and conceptual
foundation for all of computer science.
 Discrete math concepts are also widely
used throughout math, science,
engineering, economics, biology, etc., …
 A generally useful tool for rational thought!

Kemal Akkaya Discrete Mathematics 8


Uses for Discrete Math in Computer Science

 Advanced algorithms  Database


& data structures management systems
 Programming  Cryptography
language compilers  Error correction codes
& interpreters.  Graphics & animation
 Computer networks algorithms, game
 Operating systems engines, etc.…
 Computer  i.e., the whole field!
architecture

Kemal Akkaya Discrete Mathematics 9


Course Objectives
 Upon completion of this course, the student
should be able to:
 Check validity of simple logical arguments (proofs).
 Check the correctness of simple algorithms.
 Creatively construct simple instances of valid logical
arguments and correct algorithms.
 Describe the definitions and properties of a variety
of specific types of discrete structures.
 Correctly read, represent and analyze various types
of discrete structures using standard notations.

Kemal Akkaya Discrete Mathematics 10


Module #1: Foundations of Logic

Mathematical Logic is a tool for working with


elaborate compound statements. It includes:
 A formal language for expressing them.
 A concise notation for writing them.
 A methodology for objectively reasoning about
their truth or falsity.

It is the foundation for expressing formal proofs


in all branches of mathematics.

Kemal Akkaya Discrete Mathematics 11


Foundations of Logic: Overview

 Propositional logic:
 Basic definitions.
 Equivalence rules & derivations.

 Predicate logic
 Predicates.
 Quantified predicate expressions.
 Equivalences & derivations.

Kemal Akkaya Discrete Mathematics 12


Propositional Logic (§1.1)

Propositional Logic is the logic of compound


statements built from simpler statements
using so-called Boolean connectives.
Some applications in computer science:
 Design of digital electronic circuits.
 Expressing conditions in programs.
 Queries to databases & search engines.

Kemal Akkaya Discrete Mathematics 13


Definition of a Proposition
Definition: A proposition (denoted p, q, r, …) is simply:
 a statement (i.e., a declarative sentence)
 with some definite meaning, (not vague or ambiguous)

 having a truth value that’s either true (T) or false (F)


 it is never both, neither, or somewhere “in between!”

 However, you might not know the actual truth value,

 and, the truth value might depend on the situation or

context.
 Later, we will study probability theory, in which we assign
degrees of certainty (“between” T and F) to propositions.
 But for now: think True/False only!

Kemal Akkaya Discrete Mathematics 14


Examples of Propositions
 “It is raining.” (In a given situation.)
 “Beijing is the capital of China.”
 “1 + 2 = 3”

But, the following are NOT propositions:


 “Who’s there?” (interrogative, question)
 “La la la la la.” (meaningless interjection)
 “Just do it!” (imperative, command)
 “Yeah, I sorta dunno, whatever...” (vague)
 “1 + 2” (expression with no truth value)

Kemal Akkaya Discrete Mathematics 15


Operators / Connectives

An operator or connective combines one or


more operand expressions into a larger
expression. (e.g., “+” in numeric exprs.)
 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.

Kemal Akkaya Discrete Mathematics 16


Some Popular Boolean Operators

Formal Name Nickname Parity Symbol


Negation operator NOT Unary ¬
Conjunction operator AND Binary 
Disjunction operator OR Binary 
Exclusive-OR XOR Binary 
operator
Implication operator IMPLIES Binary 
Biconditional operator IFF Binary ↔

Kemal Akkaya Discrete Mathematics 17


The Negation Operator

The unary negation operator “¬” (NOT)


transforms a prop. into its logical
negation.
E.g. If p = “I have brown hair.”
then ¬p = “I do not have brown
p p hair.”
The truth table for NOT: T F
F T
Operand Result
T :≡ True; F :≡ False
column column
“:≡” means “is defined as”
Kemal Akkaya Discrete Mathematics 18
The Conjunction Operator

The binary conjunction operator “” (AND)


combines two propositions to form their
logical conjunction. ND
E.g. 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 “ND”

Kemal Akkaya Discrete Mathematics 19


Conjunction Truth Table

 Note that a Operand columns


conjunction p q pq

p1  p2  …  pn F F F
of n propositions F T F
will have 2n rows
T F F
in its truth table.
T T T
 Also: ¬ and  operations together are
sufficient to express any Boolean truth
table!

Kemal Akkaya Discrete Mathematics 20


The Disjunction Operator

The binary disjunction operator “” (OR)


combines two propositions to form their
logical disjunction.
p=“My car has a bad engine.”
q=“My car has a bad transmission.”
pq=“Either my car has a bad engine, or
my car has a bad transmission.”
Meaning is like “and/or” in English.

Kemal Akkaya Discrete Mathematics 21


Disjunction Truth Table

 Note that pq means p q pq


that p is true, or q is F F F
true, or both are true! F T T Note
 So, this operation is difference
T F T from AND
also called inclusive or,
T T T
because it includes the
possibility that both p and q are true.

Kemal Akkaya Discrete Mathematics 22


A Simple Exercise
Let p = “It rained last night”,
q = “The sprinklers came on last night,”
r = “The lawn was wet this morning.”
Translate each of the following into English:
¬p = “It didn’t rain last night.”
“The lawn was wet this morning, and it
r  ¬p = didn’t rain last night.”
¬ r  p  q = “Either the lawn wasn’t wet this morning,
or it rained last night, or the sprinklers
came on last night.”

Kemal Akkaya Discrete Mathematics 23


The Exclusive Or Operator

The binary exclusive-or operator “”


(XOR) combines two propositions to
form their logical “exclusive or”
(exjunction?).
p = “I will earn an A in this course,”
q = “I will drop this course,”
p  q = “I will either earn an A in this
course, or I will drop it (but not both!)”

Kemal Akkaya Discrete Mathematics 24


Exclusive-Or Truth Table

 Note that pq means p q pq


that p is true, or q is
true, but not both!
F F F
 This operation is
F T T
T F T
called exclusive or,
because it excludes the T T F Note
difference
from OR.
possibility that both p and q are true.

Kemal Akkaya Discrete Mathematics 25


Natural Language is Ambiguous
Note that English “or” can be ambiguous
regarding the “both” case!
“Pat is a singer or
 p q p "or" q
Pat is a writer.” -
F F F
“Pat has got an A or
Pat has got a B.” - 
F T T
T F T
T T F
Need context to disambiguate the meaning!
For this class, assume “or” means inclusive.

Kemal Akkaya Discrete Mathematics 26


The Implication Operator
Hypothesis Conclusion
The implication p  q states that p implies q.

e.g., let p = “You study hard.”


q = “You will get a good grade.”
p  q = “If you study hard, then you will get a
good grade.” (else, it could go either way)

Kemal Akkaya Discrete Mathematics 27


Implication Truth Table

 p  q is false only when


p is true but q is not true.
 p  q does not say p q pq
that p causes q! F F T
F T T The
T F F only
 p  q does not require T T T False
case!
that p or q are ever true!
 E.g. “(1=0)  pigs can fly” is TRUE!

Kemal Akkaya Discrete Mathematics 28


Why does this seem wrong?
 Consider a sentence like,
 “If I wear a red shirt tomorrow, then it will
snow!”
 In logic, we consider the sentence True
as long as either I don’t wear a red shirt,
or it snowed.
 But, in normal English conversation, if I
were to make this claim, you would think
that I was lying.

Kemal Akkaya Discrete Mathematics 29


Resolving the Discrepancy
 In English, a sentence “if p then q” usually really implicitly
means something like,
 “In all possible situations, p implies q.”
 If p is true then q will be true.
 If p is not true then q will not be true.
 There is a relationship between, hypothesis and conclusion.
 This is not the case in logic.
 pq means ¬p V q
 Ex.: “If you get 100 on the final, you’ll get an A”
 If you get 100, you would expect to receive an A (11=1)
 If not, you can still get an A depending on other factors (01=1)
 However, if you get 100 but do not have an A, then you’ll feel
cheated (10 = 0)

Kemal Akkaya Discrete Mathematics 30


Examples of Implications
 “If this lecture ever ends, then the sun will
rise tomorrow.” True or False?
 “If Tuesday is a day of the week, then I am
a penguin.” True or False?
 “If 1+1=6, then Bush is president.”
True or False?
 “If the moon is made of green cheese, then I
am richer than Bill Gates.” True or False?

Kemal Akkaya Discrete Mathematics 31


English Phrases Meaning p  q
 “p implies q”  “p only if q”
 “if p, then q”  “p is sufficient for q”
 “if p, q”  “q is necessary for p”
 “when p, q”  “q follows from p”
 “whenever p, q”  “q is implied by p”
 “q if p” We will see some
equivalent logic
 “q when p” expressions later.
 “q whenever p”

Kemal Akkaya Discrete Mathematics 32


Converse, Inverse, Contrapositive

Some terminology, for an implication p  q:


 Its converse is: q  p.
 Its inverse is: ¬p  ¬q.
 Its contrapositive: ¬q  ¬ p.
 One of these three has the same meaning
(same truth table) as p  q. Can you
figure out which?

Kemal Akkaya Discrete Mathematics 33


How do we know for sure?

Proving the equivalence of p  q and its


contrapositive using truth tables:

p q q p pq q p
F F T T T T
F T F T T T
T F T F F F
T T F F T T

Kemal Akkaya Discrete Mathematics 34


The biconditional operator
The biconditional p  q states that p is true if and
only if (IFF) q is true.
p = “Bush wins the 2004 election.”
q = “Bush will be president for all of 2005.”
p  q = “If, and only if, Bush wins the 2004
election, Bush will be president for all of 2005.”
2005
2004 I’m
staying

Kemal Akkaya Discrete Mathematics 35


Biconditional Truth Table
 p  q means that p and q
have the same truth value. p q pq
 Note this truth table is the F F T
exact opposite of ’s! F T F
Thus, p  q means ¬(p  q) T F F
T T T
 p  q does not imply
that p and q are true, or that either of them
causes the other, or that they have a common
cause.

Kemal Akkaya Discrete Mathematics 36


Precedence of operators
 We can have compound
statements Operator Precedence
 rpq
 What is the order of ¬ 1
applying logical
operators?  2
 We use parenthesis to
specify the order  3
 r  (p  q) : Implication
first  4
 If no parenthesis, we still
 5
have a precedence list :

Kemal Akkaya Discrete Mathematics 37


Boolean Operations Summary
 We have seen 1 unary operator (out of
the 4 possible) and 5 binary operators
(out of the 16 possible). Their truth
tables are below.
p q p pq pq pq pq pq
F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T
Kemal Akkaya Discrete Mathematics 38
Some Alternative Notations

N
a
me: no
ta
ndo
rxo
rimp
l
ies i
ff
P
r
oposi
ti
onall
ogic
: 
B
ool
eanalg
ebra
: ppq+
C
/C++/
Java(wor
dw i
se)
:! &&|
| !
= ==
C
/C++/
Java(b
it
w i
se)
: ~&|^
L
og
i
c g
at
es:

Kemal Akkaya Discrete Mathematics 39


Logic and Bit Operations
 A bit is a binary (base 2) digit: 0 or 1.
 Bits may be used to represent truth values.
 By convention:
0 represents “false”; 1 represents “true”.
 Boolean algebra is like ordinary algebra
except that variables stand for bits, + means
“or”, and multiplication means “and”.
 See module 23 (chapter 10) for more
details.

Kemal Akkaya Discrete Mathematics 40


Bit Strings
 A Bit string of length n is an ordered sequence
(series, tuple) of n0 bits.
 By convention, bit strings are (sometimes)
written left to right:
 e.g. the “first” bit of the bit string “1001101010” is 1.
 When a bit string represents a base-2 number,
by convention, the first (leftmost) bit is the
most significant bit. Ex. 11012=8+4+1=13.

Kemal Akkaya Discrete Mathematics 41


Bitwise Operations

 Boolean operations can be extended to


operate on bit strings as well as single bits.
 E.g.:
01 1011 0110
11 0001 1101
11 1011 1111 Bit-wise OR
01 0001 0100 Bit-wise AND
10 1010 1011 Bit-wise XOR

Kemal Akkaya Discrete Mathematics 42


End of §1.1
You have learned about:  Atomic vs.
 Propositions: What compound
they are. propositions.
 Propositional logic  Alternative notations.
operators’  Bits and bit-strings.
 Symbolic notations.  Next section: §1.2
 English equivalents.  Propositional
 Logical meaning. equivalences.
 Truth tables.  How to prove them.

Kemal Akkaya Discrete Mathematics 43

Você também pode gostar