math1.ru · Title: untitled Created Date: 1/14/2004 9:19:08 PM
Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College...
-
Upload
curtis-sherman -
Category
Documents
-
view
231 -
download
4
Transcript of Logic - Elementary Discrete Math1 Discrete Mathematics Jim Skon Mount Vernon Nazarene College...
Logic - Elementary Discrete Math 1
Discrete Mathematics
Jim Skon
Mount Vernon Nazarene College
Chapter 1
Logic - Elementary Discrete Math 2
Discrete Mathematics Discrete - "Consisting of unconnected
parts"Discrete/Continuous Math
pieces of ice vs. liquid water Letter grade vs. gpa
Logic - Elementary Discrete Math 3
Discrete MathematicsApplications of discrete mathematics:
Formal Languages (computer languages) Compiler Design Data Structures Computability Automata Theory Algorithm Design Relational Database Theory Complexity Theory (counting)
Logic - Elementary Discrete Math 4
Discrete MathematicsExample (counting):
The Traveling Salesman Problem Important in
• circuit design• many other CS problems
Logic - Elementary Discrete Math 5
The Traveling Salesman ProblemGiven:
n cities c1 , c2 , . . . , cn
distance between city i and j, dij
Find the shortest tour.
a
c
b
d
3
54
7
2dab = 3
Logic - Elementary Discrete Math 6
The Traveling Salesman Problem Assume a very fast PC:1 flop = 1 nanosecond
= 10 -9 sec.= 1,000,000,000 ops/sec= 1 GHz.
Logic - Elementary Discrete Math 7
The Traveling Salesman ProblemA tour requires n-1 additions. How
many different tours? Choose the first city n ways, the second city n-1 ways, the third city n-2 ways, etc.
a
c
b
d
3
54
7
2
Logic - Elementary Discrete Math 8
The Traveling Salesman Problem Total number of tours
n (n-1) (n-2) . . . .(2) (1) = n! (Combinations)
Total number of additions (n-1) n! (Rule of Product)
Logic - Elementary Discrete Math 9
The Traveling Salesman ProblemIf n = 8,
T(n) = 78! = 282,240 flops < 1/3 second.
HOWEVER
Logic - Elementary Discrete Math 10
The Traveling Salesman ProblemIf n=50,
T(n) = 49 50!= 1.48 10 66
= 1.49 10 57 seconds= 2.48 10 55 minutes= 4.13 10 53 hours= 1.72 10 52 days= 2.46 10 51 weeks= 4.73 10 49 years.
Logic - Elementary Discrete Math 11
The Traveling Salesman Problem...a long time. You’ll be an old
person before it’s finished.There are some problems for which
we do not know if efficient algorithms exist to solve them!
Logic - Elementary Discrete Math 12
Propositions An assertion which is either true (or 1) or false (or
0). Today is Wednesday. Some dogs each fish. 4 + 2 = 5 There exists a person who can run 100 mph. The number of hairs on Bill Clinton’s head is 5,543,234,123. Every natural number can be written as the sum of the squares of
four natural numbers. The equation xn + yn = zn where n > 2 and x, y, and z are positive
integers has no solutions. (Fermat’s last Theorem) Every even number greater then 4 can be written as the sum of two
prime numbers.
Logic - Elementary Discrete Math 13
Propositions Now consider:
• a. Give me my book. (Imperative)
• b. What is my test score? (Interrogative)
• c. Four score and seven years ago (Clause)
Logic - Elementary Discrete Math 14
Logical ConnectivesConsider
I like rock and I like classical. I’ll either eat at Jody’s or I will go to class. I did not do my homework today. I will either ride will Bill or I will walk
tomorrow, but not both.
Logic - Elementary Discrete Math 15
Logical ConnectivesProposition - Any sentence with a truth
valueSimple Proposition - No connectivesCompound Proposition - made up of one or
more simple Propositions linked together by connectives.
Logic - Elementary Discrete Math 16
Logical ConnectivesExamples:
I like pop music and I like classical music. I got an A in English or I got an B in
Philosophy. You did not bring me what I wanted. If you see my mother, then tell her where I am.
Logic - Elementary Discrete Math 17
Logical Connectives 4 basic connectivesConnective Notation Name of Connective
not negation
and conjunction
or disjunction
if..then.. conditional, implication
Logic - Elementary Discrete Math 18
Logical ConnectivesSentence form statements may be translated to
symbolic form:• If today is Wednesday and the time is 10:30 am then we
should all be in chapel.
P: today is Wednesday
Q: time is 10:30 am
R: We should all be in chapel
(P Q) R
Logic - Elementary Discrete Math 19
Logical ConnectivesIt is false that roses are red and violets are
blue. P: roses are red Q: violets are blue
(p q)
Logic - Elementary Discrete Math 20
Truth Tables:Negation
p p
T F
F T
Negation ‘not’ Symbol:
Example:P: I am going to townP:I am not going to town;It is not the case that I am going to
town;I ain’t goin’.
Logic - Elementary Discrete Math 21
Truth Tables:
Disjunction
p q p q
T T T
T F T
F T T
F F F
Disjunction inclusive ‘or’ Symbol:
Example: P - ‘I am going to
town’ Q - ‘It is going to
rain’ PQ: ‘I am going to
town or it is going to rain.’
Logic - Elementary Discrete Math 22
Truth Tables:Conjunction
‘and’ Symbol:
Example:P - ‘I am going to town’Q - ‘It is going to rain’PQ: ‘I am going to town and
it is going to rain.’
Conjunction
p q p qT T T
T F F
F T F
F F F
Logic - Elementary Discrete Math 23
Truth Tables:Exclusive OR
Symbol:
Example:P - ‘I am going to town’Q - ‘It is going to rain’PQ: ‘Either I am going to town
or it is going to rain.’
Exclusive Or
p q p q
T T F
T F T
F T T
F F F
Logic - Elementary Discrete Math 24
Truth Tables: Implication
‘If...then...’ Symbol:
Example:P - ‘I am going to town’Q - ‘It is going to rain’P Q: ‘If I am going to town then
it is going to rain.’
Implicationp q p q
T T T
T F F
F T T
F F T
Logic - Elementary Discrete Math 25
ImplicationEquivalent forms:
If P, then Q P implies Q If P, Q P only if Q P is a sufficient condition for Q Q if P Q whenever P Q is a necessary condition for P
Note: The implication is false only when P is true and Q is false!
Implicationp q p q
T T T
T F F
F T T
F F T
Logic - Elementary Discrete Math 26
ImplicationThe implication p q is the proposition that is false
when p is true and q is false and true otherwise.p is called the hypothesis (or antecedent or premise)q is called the conclusion (or consequence)Conditional
p q p q
T T T
T F F
F T T
F F T
Logic - Elementary Discrete Math 27
ImplicationConsider
If it is sunny, class will meet in the grove If today is Saturday, then we will all play leap frog. If x is even then x2 is even If the moon is made of green cheese then I
have more money than Bill Gates If the moon is made of green cheese then I’m
on welfare If 1+1=3 then your grandma wears combat
boots
Logic - Elementary Discrete Math 28
Implication implication P Q converse Q P inverse P Q contrapositive Q P
QP is the CONVERSE of P QQP is the CONTRAPOSITIVE of P Q
Logic - Elementary Discrete Math 29
Implication implication P Q
converse Q P
inverse P Q
contrapositive Q P
If it's after 10:00, then I will go to bed.If I go to bed, then it is after 10:00.If it's not after 10:00 then I will not go to bed.If I do not go to bed, then it is not after 10:00.
Logic - Elementary Discrete Math 30
ImplicationFind the converse and contrapositive of
the following statement:R: ‘Raining tomorrow is a sufficient
condition for my not going to town.’
Logic - Elementary Discrete Math 31
ImplicationStep 1: Assign propositional
variables to component propositionsP: It will rain tomorrowQ: I will not go to town
Logic - Elementary Discrete Math 32
ImplicationStep 2: Symbolize the assertion
R: PQ
Step 3: Symbolize the converseQP
Logic - Elementary Discrete Math 33
ImplicationStep 4: Convert the symbols back into
words‘If I don’t go to town then it will rain
tomorrow’or‘Raining tomorrow is a necessary
condition for my not going to town.’or‘My not going to town is a sufficient
condition for it raining tomorrow.’
Logic - Elementary Discrete Math 34
Implication implication converse inverse contrapositive
p q p q p q q p p q q p
T T F F T T T T
T F F T F T T F
F T T F T F F T
F F T T T T T T
Therefore: p q q p, implication contrapositive
q p p q, converse inverse
Logic - Elementary Discrete Math 35
Examples Make a truth table for:
p q (p q) (p q) r (p q) (r q) p q
Logic - Elementary Discrete Math 36
Logical ConnectivesPut in symbolic form:
I am not a mathematician. I am not a mathematician and 2 + 2 = 5. If I am not a mathematician then 2 + 2 = 5. If it is raining, then I will not go to the store, and
if it is not raining, then I will go to the store. Either Frank love Mary, or Mary loves Frank, but
not both.
Logic - Elementary Discrete Math 37
Examples1. MVNC is in Mt. Vernon or Mt. Vernon is in Russia.
2. MVNC is in Ohio and Lake Erie is in Florida.
3. If MVNC is in Ohio then Mt. Vernon is in Ohio.
4. If MVNC is in Ohio then Mt. Vernon is made of cheese.
5. If MVNC is a military school then Mt. Vernon is in Ohio.
6. If MVNC is a military school then Mt. Vernon is made of cheese.
Logic - Elementary Discrete Math 38
Examples Let p = True, q = False, r = True.
p q ( p q) (p q) (p q) (p q) (r p)
Logic - Elementary Discrete Math 39
Logical Equivalence How about:
If x = 2, then x2 = 4 If x is positive and x2 = 4,
then x = 2 If n2 is odd, then n is odd
Logic - Elementary Discrete Math 40
Implication p q may be stated as: "if p then q" "p only if q" "p is a sufficient condition for q" "q is a necessary condition for p" "a necessary condition for p is q" "a sufficient condition for q is p" "q if p" "q follows from p" "q is a logical consequence of p" "q whenever p"
Logic - Elementary Discrete Math 41
Translating English SentencesYou cannot take CS II if you have not
taken CS or have not passed a c proficiency exam
Try 1.1:problem 5
Logic - Elementary Discrete Math 42
Propositional VariablesA proposition can also be represented as a
variable.• Use lower case for numeric variables.
• Use upper case for propositional variables.
• Example:– Let p be “Today is Wednesday.”
– Let p be “I like to eat in the MVNC cafeteria.”
– Let p be “1 = 3”
Logic - Elementary Discrete Math 43
BiconditionalLet p and q be propositions.The biconditional p q is the proposition that is
true when p and q have the same truth values, and false otherwise.
It is BOTH the implication AND its converse Ex: “I will eat in the cafeteria if and only if they
have pizza.” biconditionalp q p qT T TT F FF T FF F T
Logic - Elementary Discrete Math 44
Translating to English sentences p: you like eating candyq: you lose your teeth
p q p q(p q) p q
Logic - Elementary Discrete Math 45
Logic and Bit Operationsbit - two values: 0 or 1bit can be used to store truth values
0 = false 1 = true
Thus logic operators can apply
Logic - Elementary Discrete Math 46
Bit operation Truth Tables:Negation
p p
1 0
0 1
Disjunction
p q p q
1 1 1
1 0 1
0 1 1
0 0 0
Conjunction
p q p q1 1 1
1 0 0
0 1 0
0 0 0
Exclusive OR
p q p q
1 1 0
1 0 1
0 1 1
0 0 0
Logic - Elementary Discrete Math 47
Bit StringsA bit string is a sequence of zero or more
0’s and 1’sExample
0100010010 00111011 1111111111111 00100100000010101 0
Logic - Elementary Discrete Math 48
Bit Strings Bit operations can be extended to bit stringsexample:
01000101
00111101
00000101 bitwise and
01111101 bitwise or
01111000 bitwise xor
Logic - Elementary Discrete Math 49
Propositional EquivalencesTautology - true for any values assigned to it's
variablesContradiction - never true, irregardless of
values of variables.Consider
I will either get a new car, or I won’t get a new car. I will come tomorrow and I won’t come tomorrow
Logic - Elementary Discrete Math 50
Propositional Equivalences Examples
p p p p p p
F T T F
T F T F
Tautology Contradiction
Logic - Elementary Discrete Math 51
Propositional Equivalences Tautologies are logically true. Contradictions are logically false. Such statements are true or false because of
it's structure rather then because of it's variables truth values.
Logic - Elementary Discrete Math 52
Propositional EquivalencesConsider:
p (q p)
(p q) (p q)
Logic - Elementary Discrete Math 53
Logical EquivalenceTwo compound statements are logically
equivalent if they always have the same truth value.
Two compound statements are logically equivalent if they have the same truth tables.
If p and q are logically equivalent, then:
p q
Logic - Elementary Discrete Math 54
Logical Equivalence Consider:
(p q) (p q)
Logic - Elementary Discrete Math 55
Logical Equivalence Logical Identities
Useful properties of logic Similar to the properties of Algebra
Logic - Elementary Discrete Math 56
Logical Equivalence Properties of Identity and Dominance:
p F p , p T p
p T T , p F F
The idempotent properties:
p p p , p p p
Logic - Elementary Discrete Math 57
Logical EquivalenceThe commutative properties:
p q q p
p q q p
The associative properties:
p (q r) (p q) rp (q r) (p q) r
Logic - Elementary Discrete Math 58
Logical Equivalence The distributive properties:
p (q r) (p q) (p r)
p (q r) (p q) (p r)
Logic - Elementary Discrete Math 59
Logical Equivalence properties of Complement:
T F , F T
p p T , p p F
(p) p
Logic - Elementary Discrete Math 60
Logical Equivalence Demorgan's laws:
(p q) p q
(p q) p q
Logic - Elementary Discrete Math 61
Logical Equivalence Implication
p q p q
Negation of Implication
(p q) p q
Logic - Elementary Discrete Math 62
Logical Equivalence If and only if
p q (p q) (q p)
Logic - Elementary Discrete Math 63
Logical Equivalence By Demorgan's law the negation of
I don’t like to eat apples and I don’t like to walk.
becomes
It's not true that I like to eat apples or I don't like to walk.
Logic - Elementary Discrete Math 64
Logical EquivalenceExamples:
Try 1.2: 7, 9, 11, 13, 15, 17, 19
Logic - Elementary Discrete Math 65
Logical Equivalence Notice that:
p q (p q) (q p)In order to prove a biconditional statement P Q, we
must only prove the statement
p q, and it's converse
q p.(Or perhaps by proving the inverse and the contrapositive).
Logic - Elementary Discrete Math 66
Propositions Free Variables
A proposition may contain variable - values not yet assigned.
Variables must be assigned values before the truth value can be assessed.
Examples x + y = 11 Car m the faster then car n. There are x people in this room. I have h hairs on my head.
Logic - Elementary Discrete Math 67
Propositions as FunctionsA proposition with variables can be written as a
function: x2 > 4 P(x) x + 3y2 + 8 = y + 2x2 - 15 Q(x, y) x is the mother of y M(x, y) Student a is in the b class S(a, b, c)
and lives in apartment c.
How would we write: 32 > 4 Sally is Bill's mother 3 + 3(2)2 + 8 = 5 + 2(3)2 - 15
Logic - Elementary Discrete Math 68
Existential QuantificationConsider the proposition:
There is a person in this class with a January birthday.
Existentially quantified expression: x : (x is in this class and x has a January
birthday)
Logic - Elementary Discrete Math 69
Existential QuantificationConsider again:
There is a person in this class with a January birthday.
Existentially quantified expression:
x : ( C(x) JBD(x) )Read "There exists an x such that C(x) and
JBD(x) are true.
Logic - Elementary Discrete Math 70
Existential Quantification - existential quantifierx : - x is a bound variablex : P - existentially quantified
proposition
Logic - Elementary Discrete Math 71
Existential QuantificationTo show that an existentially quantified
proposition x : P is true, you must only find a single example of x which makes P true.
To show that an existentially quantified proposition x : P is false, you must show that x possible values of x makes P false.
Logic - Elementary Discrete Math 72
Universal QuantificationConsider the proposition:
Every student eating in the MVNC cafeteria must either have a meal ticket, or have paid at the door.
Universal quantified expression:
s : if s is eating in the cafeteria s has a meal ticket or s paid at the door.
Logic - Elementary Discrete Math 73
Universal QuantificationConsider again:
Every student eating in the MVNC cafeteria must either have a meal ticket, or have paid at the door.
Functions: s eating in the cafeteria C(s) s has a meal ticket MT(s) s paid at the door PAID(s)
Existentially quantified expression
s : (C(s) MT(s) PAID(s) ) )
Logic - Elementary Discrete Math 74
Universal QuantificationEvery student eating in the MVNC
cafeteria must either have a meal ticket, or have paid at the door.
Universally quantified expression
s : (C(s) MT(s) PAID(s) ) )Read "For every student s, if s is eating in the
cafeteria then s has a meal ticket or s has paid at the door.
Logic - Elementary Discrete Math 75
Universal Quantification - universal quantifierx : - x is a bound variablex : P(x) - universally
quantified proposition
Logic - Elementary Discrete Math 76
Universal QuantificationTo show that an universally quantified
proposition x : P is true, you must show that P holds for all values of x .
To show that an universally quantified proposition x : P is false, you must only show at least one x for which P is false (a counter example)
Logic - Elementary Discrete Math 77
Quantification Consider:
For every x, x2 > 4 if and only if x > 2 or x < -2. There exists a number that equals it own square For every number x > 1, there exists a number y where x < y <
2x. There exists a number x such that for every y, y2 > x. Everybody has a mother and a father. Tom and Harry have the same mother. Nobody is their own mother. Peter has no children.
Logic - Elementary Discrete Math 78
Universal QuantificationThe following ranger over the real numbers:
x:y: x + y = y.x:y: x + y = y.x:y: x + y = y.x:y: x + y = y.
Logic - Elementary Discrete Math 79
Universal QuantificationThe following range over the integers:
x:y: (x2 = y2 x = -y).
x:y: (x = y x > y).
x:y: (x = y x > y).
Logic - Elementary Discrete Math 80
Negations of Quantified Propositions Let P be a proposition. Then:
x:P x:P
x:P x:P
Logic - Elementary Discrete Math 81
Negations of Quantified Propositions
Consider: There is a student in this class with a January
birthday.
x: JB(x) It is not true that there is a a student in this class
with a January birthday.
x: JB(x) x: JB(x)
Logic - Elementary Discrete Math 82
Negations of Quantified Propositions
Expand domain to include all students:
x: CL(x) JB(x)
x: CL(x) JB(x) )
x: CL(x) JB(x)
Logic - Elementary Discrete Math 83