Chapter 1 -- The Foundations: Logic and Proof, Sets and Functions

advertisement
Chapter 1 -- The Foundations:
Logic and Proof, Sets and Functions
Logic is the underlying foundation for mathematical
reasoning. It is a formalism of our system of thought.
Proofs are mathematical arguments used to establish results
within a mathematical system.
Sets form the foundation for one particular mathematical
system and are the basis for many discrete data structures
that we find useful (such as graphs, trees and relations).
Functions are used to specify a relationship between two
sets.
Section 1.1: Logic
Logic is used to give a precise meaning to
statements made in a mathematical system.
We will study the rules and components of
logical statements in order to gain a deeper
understanding of how to reason in
mathematics.
Propositions
Def: A proposition is a declarative statement
that is either true or false but not both.
Ex:
1. Washington, D.C., is the capital of the United States. T
2. 2 + 2 = 5. F
3. Tennessee shares a border with Utah. F
CE:
1. What time is it?
2. Be prepared to stop.
3. Turn right at the next intersection.
Comments
There is a bit of confusion in the text as to what constitutes a
proposition and what does not. For example
“x + 1 = 2” is not considered a proposition (assuming that x is a
variable that could take on any integer value) because it is not either
true or false. If x = 1 then it is true but if x = 2 then it is false.
However, the statement
“Today is Friday” is considered a proposition (Example 3).
I find this inconsistent.
If this statement is made on January 15, 2003, then it is false.
However, if it is made on January 17, 2003, then it is true.
It is not clear to me why the text considers “Today is Friday”
to be a proposition (that is, with a fixed truth value).
Perhaps they consider the value of “Today” to be fixed when
the statement is spoken or read?
But this is ludicrous, the statement is written in our text!
Further compounding this problem are statements such as
“It is raining.”
[What is the concern here?]
What constitutes raining? Does a drizzle count? What if
there are only a few drops? Does it have to be steady?
When? (Now??) Where? (Here??)
There is a great deal of implicit information hiding in these statements.
Unstated Distinction:
In as statement such as “Today is Friday” there is an implicit
assignment of what today is. We don’t use “Today” in the same
manner as we use “x” in “x + 1 = 2”.
For x, we intend it to be a variable able to take on any value.
If I say (right now) “Today is Friday” then what I’ve said is
clearly true. The same statement made a few days from now would be
false. But it is not the same statement. “Today” is implicitly given a
different value then. So when I say “It is raining” that is a statement.
I have implicitly given a value to the when, where, and what
constitutes raining. The statement is either true or false, but not both.
If someone else says “It is raining” with a different set of implicit
meanings, then it is a different statement. It is a different proposition.
This is the distinction. It is subtle. It disturbs me that they don’t
even attempt to explain this in the text.
The important thing is that you know that a proposition is:
(1) a statement (as opposed to a question or imperative command).
(2) has an unvarying truth value. It is either true or false.
These are the properties of a proposition and the text does a good
job of making this clear. The difficulty arises in deciding
whether or not a statement satisfies (2). This is where the text
is lacking and there is a fine line, but the line is drawn
nonetheless.
More about propositions
We use letters to denote propositions such as
p, q, r, and s. We denote the truth value of a
proposition as T (true) or F (false). Using
these notations we will proceed to introduce
ways of forming new (compound)
propositions from known propositions. This
area of logic is known as propositional
calculus or propositional logic.
Calculus has come to mean manipulation of
(or computation with) symbols.
Negation
Def: Let p be a proposition. The statement
“p is not the case” is another proposition
called the negation of p. It is denoted ¬p
and read as “not p”.
Ex: Let p be “Today is Friday”.
Then ¬p is “Today is not Friday”.
Truth Tables
Def: A truth table displays the relationship between the truth
values of propositions. They are useful as a visual display for the
workings of a logical operator such as ¬, and can also be used to
determine the truth value of a compound proposition based on the
truth values of its component propositions.
Ex: Truth table for negation. This table involves one proposition,
p, and the possibilities for p (T or F) are exhaustively listed in the
left column. This feature of truth tables (exhaustive listing) makes
them impractical with large propositions.
Operators
¬ can be viewed as an operator (the negation
operator which operates on a single logical
proposition by complementing its truth value.
For this reason, it is also called the logical
complement.
We will now introduce logical operators that
take two existing propositions and form a
new proposition from them. These operators
are called logical connectives.
Conjunction
Def: Let p and q be propositions. The
proposition “p and q”, called the
conjunction of p and q, is true when both p
and q are true and false otherwise. It is
denoted “p  q”. [Truth Table]
Ex: Let p be “Today is Friday” and q be “Classes are cancelled”.
Then p  q is the proposition “Today is Friday and classes are
cancelled”.
Disjunction
Def: Let p and q be propositions. The
proposition “p or q”, called the disjunction of
p and q, is false when both p and q are false
and true otherwise. It is denoted “p  q”.
[Truth Table]
Note: The disjunction corresponds to an inclusive or. That is, the
disjunction is true when p or q or both are true. The “or both” is
implicit in “p or q”.
Remark
This is somewhat inconsistent with the way the
word or is used in English. When it is said, “soup
or salad comes with an entrée” this does not mean
“or both”. However, when one says, “You must
have taken CS 101 or CS 110 before you can
register for this class” this does mean “or both”.
In English, we leave it up to context whether an
or is inclusive or exclusive.
In this class (and logic in general), “or” is implicitly
inclusive. If we desire an exclusive or, we will
add “but not both” to the end of our statement. In
this way, we make precise what we mean.
Exclusive or
Def: Let p and q be propositions. The exclusive or of
p and q is true when p is true or q is true but not
both. It is false when p and q are both true or both
false. The exclusive or is denoted “p  q”.
[Truth Table]
Note: The only difference between the truth table for inclusive or
and the truth table for exclusive or occurs in the top row where
both p and q are true.
Implication
Def: Let p and q be propositions. The
implication, p  q, is false when p is true and q
is false; it is true otherwise. In the implication,
p is called the hypothesis (or antecedent or
premise) and q is called the conclusion (or
consequence). [Truth Table]
There are a number of ways to indicate or express an
implication in a mathematical statement:
pq
“if p, then q”
“p implies q”
“if p, q”
“p only if q”
“p is sufficient for q”
“q whenever p”
“q if p”
“q is necessary for p”
“q when p”
“q follows from p”
All of these statements convey the sentiment that if p is true
then q must be true. Don’t confuse this with the idea that p
causes q (p may not have anything to do with q other than
the knowledge that p being true means q is true).
Ex: “To q, it is necessary for you to r”
qr
Ex: Consider the statement “If you get a 100 on the final then you
will get an A in the class.”
In this case we have a statement of the form p  q where p is “you
get a 100 on the final” and q is “you get an A in the class”.
This statement is only violated (False) if you do get a 100 on the
final but you do not get an A in the class. This corresponds to p
being true while q is false.
Consider the 3 other scenarios where this statement is satisfied:
p:T, q:T; you get a 100 on the final and you get an A in the class.
p:F, q:T; you do not get a 100 on the final but you do get an A. p:F,
q:F; you do not get a 100 on the final and you do not get an A.
All the original statement does (if I were to say it to you) is to rule
out the possibility of getting a 100 on the final but not getting an A.
The other 3 scenarios can all occur with my original statement still
being satisfied.
Ex: Consider the implication “If 2 + 2 = 5 then my middle name
is Mathew”. In this case p is “2 + 2 = 5” and q is “my middle
name is Mathew”.
What is the truth value of this proposition?
It is true. Since the hypothesis is false (2 + 2 = 5) then the
implication is true (regardless of whether my middle name is
Mathew or not). Refer back to the truth table.
Similarly the proposition “If my middle name is Mathew then 2 +
2 = 4” is true. Since the consequent is true, it doesn’t matter
whether the hypothesis is true or false.
This also illustrates an implication that does not deal with
causation (only correlation). In these examples, the hypothesis
and consequence have nothing to do with one another but the
implication is still meaningful and has a truth value.
Converse, Contrapositive, and Inverse
If we have an implication p  q we can consider 3
related implications:
Converse: The converse of p  q is q  p.
Ex: “If you get an A in this class then you get a 100
on the final” is the converse of our previous
example. The only way this converse is violated
is if you get an A in the class but don’t get a 100
on the final. So now, the only way to get an A in
the class is to get a 100 on the final (and even
getting a 100 on the final doesn’t guarantee you an
A in the class).
Inverse
Inverse: The inverse of p  q is ¬p  ¬q.
Ex: “If you don’t get a 100 on the final then
you don’t get an A in the class” is the
inverse of our original example. This
statement means the same thing as the
converse (as we will see). Basically to be
eligible to get an A in the class, you must
get a 100 on the final (again, a 100 on the
final doesn’t guarantee an A in the class).
Contrapositive
The contrapositive of p  q is q   p.
Ex: “If you don’t get an A in this class then you don’t
get a 100 on the final” is the contrapositive of our
original example. This statement means the same
thing as the original implication, p  q. That is, if
you don’t end up with an A in the class then you
didn’t get a 100 on the final (original: getting a 100
on the final implies you get an A in the class). We will
get back to logical equivalences in the next section.
For now, know how to form the inverse, converse, and
contrapositive of a given implication.
Biconditional
Def: Let p and q be propositions. The
biconditional p  q is true when p and q have
the same truth value; it is false otherwise.
Note that p  q is true precisely when both p  q
and q  p are true. Because of this we indicate
the biconditional as “p if and only if q”.
The symbol  is a combination of  and 
since p  q is l. e. to (p  q)  (p  q).
[Truth table comparison with all three]
“iff”, “… and conversely”, “necessary and suff.”
Ex: “If you get a 100 on the final then you will get an A in the
class, and conversely.”
Now I am not only stipulating that you’ll get an A in the class if
you get a 100 on the final, but also that this is necessary for you
to get an A in the class.
This statement is the combination of both the original
implication and its converse. As stated previously p  q is
logically equivalent to (p  q)  (q  p). We have used
parentheses here to explicitly indicate how our symbols are to
be grouped because we have not yet introduced an order of
precedence for our logical operators. We will do this now.
Precedence of Logical Operators
(1) Negation (¬) is applied before any other logical operators.
(2) Conjunction () takes precedence over disjunction ().
(3) Conditional () and biconditional () have lower precedence
than conjuction () and disjunction ().
(4) The conditional () takes precedence over biconditional ().
Now we can write a proposition such as
p  q  r  p  s  t
without ambiguity. [Parse it]
((p  (q))  (r  p))  (s  t)
Translating English Sentences
Often we need to translate a statement in
English into a compound proposition
involving symbols and logical connectives.
English statements are often ambiguous so we
translate them in order to specify precisely
what we mean and to be able to reason.
Due to the ambiguity in an English statement,
there is often more than one way to translate
it into a logical proposition.
Ex: Translate the following English statement into a statement in
propositional logic utilizing letters and logical connectives.
“I buy something or I return something whenever I go to the store.”
Solution: p. (where p stands for the above statement)
Why not?
Though this is a way to represent the given statement, it is not
particularly useful because all of the logical structure of the
statement is hidden within the symbol p. We can not use such a
representation to reason with the statement. It does illustrate the
useful concept that a single symbol can represent a compound
proposition. This can be useful when we wish to apply established
logical equivalences to simplify complicated logical expressions.
For example: ((p  q)  r)  ((p  q)  r) is true. Substitute s for
((p  q)  r) to get s  s. This is know to be true.
Ex: Translate the following English statement into a statement in
propositional logic utilizing letters and logical connectives.
“I buy something or I return something whenever I go to the store.”
Better Solution: Let p be “I buy something”, r be “I return
something”, and s be “I go to the store”. Then we have
“p or r whenever s”.
“p  r whenever s”.
“s  p  r”
Recall that by our rules of precedence that this means s  (p  r).
This is probably what was meant. (It is no accident that the
precedence rules are set up the way they are. [Often agree with En])
But English is ambiguous; especially written English. The statement
above could well have been intended to mean (s  p)  r. [Pause]
Logic Puzzles
There are a wide variety of logic puzzles that
can be solved by expressing them with logic
symbols and connectives then reasoning
using propositions. We will look at a few
examples but as we progress further into
logic you should be able to solve logical
puzzles that you have not seen before by
applying the general concepts of logic.
Ex: An island has two kinds of inhabitants called knights and
knaves. A knight always tells the truth whereas a knave always
lies. You approach two inhabitants of this isle, A and B.
A says, “B is a knight”.
B says, “A and B are of opposite types”.
Determine which category A and B fall into.
Let p be the proposition “A is a knight” and q be “B is a knight”.
Then p is “A is not a knight” or equivalently “A is a knave”.
Recall that A’s statement was q. B’s statement can be represented
as (p  q)  (p  q). Remember that we don’t know whether
these statements are true or false. It depends on what type the
speaker was.
First, consider the possibility that A is a knight.
If this is so, then A’s statement is true. Namely, B is a knight. But
now B’s statement must also be true, namely that A and B are of
different types. But if A and B are both knights then they are not
of different types. So it is not possible that A is a knight.
Therefore, A must be a knave. So A’s statement is false. A said
that B is a knight, so B is not a knight. B is a knave. Now both A
and B are knaves, so B’s statement must be false. B said that A
and B are of different types. This is indeed false because A and B
are both knaves.
So the conclusion is that A and B are both knaves.
Ex: A detective has interviewed four witnesses to a crime. From
the stories of the witnesses the detective has concluded that if the
butler is telling the truth, then so is the cook; the cook and the
gardener can not both be telling the truth; the gardener and the
handyman are not both lying; and if the handyman is telling the
truth then the cook is lying. For each of the four witnesses, can the
detective determine whether that person is telling the truth or lying?
Let us use the first letter of each title to represent the proposition that
the person is telling the truth (e.g. h stands for “the handyman is
telling the truth). We are given 4 statements which we translate into
symbolic propositions using our letters and logical connectives:
(1) b  c
(2) (c  g)
or
c  g
(3) (g  h)
or
gh
(4) h  c
(1) b  c
(2) (c  g)
or
c  g
(3) (g  h)
or
gh
(4) h  c
What if the cook were telling the truth? [Use propositions]
By using our propositions and rules of logic, we determine that if the
cook is telling the truth then the cook must be lying! So it can not
possibly be that the cook is telling the truth. What we have done,
basically, is to chain our propositions together to see that this follows:
(5) c  c [How can this be? What truth value must c have?]
Now we know that c is false. [What does (1) tell us?]
b is false. Now we know both b and c are false. [(1), (2), (4)?]
They are all satisfied and so give no further info. [What about (3)?]
(3) Says that the gardener is truthful or the handyman or both. [Fal. h...]
Logic and Bit Operations
Def: A bit string is a sequence of zero or more bits.
You’ve all seen bit strings in CS 101. You know
that a bit is the fundamental unit of information
that a computer stores (via electrical current,
magnetic orientation, etc.). A bit can take on two
possible values denoted 0 and 1 in this class. A bit
string is simply an ordered sequence of bits. For
example, a bit string of length 8 is called a byte:
0110 1010. How might we use a bit in logic?
A bit can be used to represent a propositions truth value (such as
p). If the bit is a 1, this indicates that p is true. If it is a 0, then p is
false.
Computer bit operations correspond to logical connectives. We
can use bit operations to efficiently compute the logical and, or,
not, xor connectives.
Ex: 1  1 = 1
10=1
11=0
1 = 0
10=0
00=0
10=1
0 = 1
We can extend this to bit strings.
Ex: 01 1010 1100
 11 0110 1011
---------------------01 0010 1000
Download