Download CS2300-1.1-1.2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Discrete Structures – CS2300
Text
Discrete Mathematics and Its
Applications
Kenneth H. Rosen (7th Edition)
Chapter 1
The Foundations: Logic and
Proofs
1
About This Course
• The Conceptual Foundation of Computer Science
• Prerequisite for CS 3240 (Theory of
Computation)
• Applied Mathematics Course
Continuous vs. Discrete Math
Continuous
Sliding down a slide
Pouring water
Length of rope
Crawling slug
Adding milk
Grade point average
Discrete
Climbing up stairs
Stacking ice cubes
Number of knots
Hopping rabbit
Adding eggs
Calculus grade
3
Discrete Solutions
• How many ways are there to choose a valid
password?
• What is the probability of winning the lottery?
• Is there a path linking two particular computers
in a network?
• What is the shortest path between two
destinations using a transportation system?
• How many valid Internet addresses are there?
4
Chapter 1 Objective
“In this chapter we will explain what makes up a
correct mathematical [logical] argument and
introduce tools to construct these arguments.”
5
Sections 1.1, 1.2
Logic
Propositional Logic
6
Propositions
A proposition is a statement
that is either true or false, but
not both.
Today is Tuesday.
Six is a prime number.
Count is less than ten.
7<5
Consider this statement.
7
Compound Propositions
Compound propositions are formed
from existing propositions using
logical operators
Today is Wednesday and it is snowing outside.
12 is not a prime number.
8
Negation of a Proposition
P
P
T
F
F
T
NOT
!
9
Negation of a Proposition
repeat{
…
}until(feof(my_file));
while (!feof(my_file)){
…
}
10
Disjunction of Two
Propositions
p q
pq
T T
T
T F
T
F T
T
F F
F
OR
||
11
Disjunction of Two
Propositions
repeat{
…
}until(count>10 || feof(myfile));
if(choice==PAUSE || choice ==STOP)
...
12
Conjunction of Two
Propositions
p q
pq
T T
T
T F
F
F T
F
F F
F
AND &&
13
Conjunction of Two
Propositions
while(!feof(a_file) && index<SIZE)
{
…
}
if(!done && time_left)
...
14
Exclusive-OR of Two
Propositions
p q pq
T T
F
T F
T
F T
T
F F
F
^
Exactly
one of
them is
true.
15
“but not both”
Implication
p q pq
T T
T
T F
F
F T
T
F F
T
p is called the
hypothesis and
q is the
conclusion
16
Implication (“Conditional”)
p q pq
T T
T
T F
F
F T
T
F F
T
•
•
•
•
•
•
•
•
“if p, then q”
“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”
17
17
q whenever p
p q pq
T T
T
T F
F
F T
T
F F
T
Suppose that the
proposition is true.
Then, q is true
whenever p is true.
18
18
p is sufficient for q
p q pq
T T
T
T F
F
F T
T
F F
T
Suppose that the
proposition is true.
Then, to guarantee
that q is true it is
sufficient to say that
p is true.
19
19
Converse of an Implication
p q pq pq
T T
T
T
T F
F
T
F T
T
F
F F
T
T
And
Conversely
20
20
Example of Converse
If it stays warm for a week, the apple trees will bloom.
If the apple trees bloom, it will be warm for a week.
If x is even then x2 is even.
If x2 is even then x is even.
21
Contrapositive of an
Implication
p
q p  q p q  q   p
T T
T
F
F
T
T F
F
F
T
F
F T
T
T
F
T
F F
T
T
T
T
22
22
Examples of Contrapositive
If it snows tonight, then I will stay at home.
If I do not stay at home, then it didn’t snow tonight.
If x is odd then x2 is odd.
If x2 is not odd then x is not odd.
If x2 is even then x is even.
23
Biconditional
p
pq
q p  q p  q ( p  q)  ( p  q)
T T
T
T
T
T F
F
T
F
F T
T
F
F
F F
T
T
T
24
Biconditional
pq
( p  q)  ( p  q)
p if and only if q
p iff q
25
Bitwise operators
a&b
AND

a|b

1101 1001
1110 0100
1111 1101
1101 1001
1110 0100
1100 0000
a^b
OR
XOR

1101 1001
1110 0100
0011 1101
27
t01_1_009.jpg
Tautology
Tautology - a compound
proposition that is always true.
( p  q)  p
p
q p  q ( p  q)  p
T
T
F
F
T
F
T
F
T
F
T
T
T
T
T
T
29
Contradiction
Contradiction - a compound
proposition that is always false.
p p p   p
T
F
F
F
T
F
30
Contingency
A contingency is neither a
tautology nor a contradiction.
p  ( p  q)
p
q p  q p  ( p  q)
T
T
F
F
T
F
T
F
T
F
F
F
T
F
T
T
31
Related documents