Mathematical Reasoning: The Foundation of Algorithmics
Mathematical Reasoning: The Foundation of Algorithmics
x
P is read For all x P
-
x
P is read There exists an x such that
P
In both cases, we read out P, we dont
just say P.
Mathematical Quantifiers IV
Practice with these:
x
(x+1)
2
=x
2
+2x+1
-
x
x<5
As in ordinary logic, a universal negates
an existential, and an existential
negates a universal.
The Rules of Inference VII
X and Y are equal (X=Y) if X and Y are
names for the same thing.
If a statement P(X) containing X is true,
and X=Y then the statement P(Y)
obtained by substituting Y for X is also
true.
If P(X) is quantified, and X appears in
the quantifier, then Y must appear in
the quantifier of P(Y)
The Rules of Inference VIII
If the statement
x
P(x) is known to be
true, and k is within the domain of
discourse of P, then P(k) is true.
Example:
x
(x+1)
2
=x
2
+2x+1.
The domain of discourse is all real
numbers. 15.7 is a real number, so
(15.7+1)
2
=15.7
2
+2*15.7+1 is true.
Rules of Inference IX
Example II:
x
(x+1)
2
=x
2
+2x+1
Toothpicks is outside the domain of
discourse of (x+1)
2
=x
2
+2x+1.
We cannot say that (Toothpicks+1)
2
=
Toothpicks
2
+2 Toothpicks+1 is
true.
This statement is not a proposition and
is neither true nor false.
Rules of Inference X
If the statement -
x
P(x) is known to be
false, and k falls within the domain of
discourse of P, then P(k) is false.
Example: -
x
5<x<4
The domain of discourse is all real
numbers.
4.5 is a real number, so 5<4.5<4 is
false.
Negating Quantified Statements
Negate:
x
(x+1)
2
=x
2
+2x+1
Result: -
x
(x+1)
2
=x
2
+2x+1
Negate: -
x
x<5
Result:
x
x>5
By the law of the excluded middle, if a
statement is true, its negation is false,
and vice-versa.
Logical Connectives I
If P is a proposition P is its negation.
P is read Not P.
Do not confuse this mathematical
connective with the general statement
Not All A is B. They are not the same
thing.
Sometimes P is written P or P.
Logical Connectives II
If P and Q are propositions, P.Q is
called the conjunction of P and Q and is
read P AND Q.
If P and Q are propositions, PvQ is
called the disjunction of P and Q and is
read P OR Q.
If P and Q are propositions, PQ is
called the implication of P and Q and is
read IF P THEN Q.
Truth Tables for Connectives
P Q P.Q PvQ PQ
True True True True True
True False False True False
False True False True True
False False False False True
Implications
The most interesting connective is the
implication PQ, which can also be
written PvQ.
If P is False, then the entire statement
is true. That is, A False Statement
Implies Anything.
An implication is proven by assuming
that P is true and then showing that, in
that case, Q must also be true.
Implications II
Given a statement S of the form PQ,
the statement QP is called the
Converse of S.
The Converse of S is an independent
statement that must be proven
independently of S.
S can be true and its converse can be
false and vice versa. They could both
be true or both be false.
Implications III
Given a statement S of the form PQ,
the statement Q P is called the
Contrapositive of S.
A statement and its contrapositive are
logically equivalent. Either both are true
or both are false.
The statement P Q is the Inverse
of S. The inverse of S is logically
equivalent to the converse of S.
Proven Implications
Once an implication has been proven,
we use a special symbol to designate
the implication.
The notation PQ is read if P then Q
and also says that the P=T, Q=F case
never occurs.
In other words, that the implication is
always true.
If and Only If
A statement of the form P if and only if
Q is shorthand for (if P then Q) and (if
Q then P).
In symbols we express this as PQ.
Once the statement has been proven
we rewrite the statement as PQ.
To prove PQ, we must prove both of
PQ and QP.
Negating Compound Statements
(P.Q) = P v Q
X is less than three and X is odd
X is greater than or equal to 3 or X is even
(PvQ) = P . Q
The car was either red or green
The car was not red AND it was not green
(PQ) = P . Q
If a person has a Ph.D. then they must be rich
Prof. Maurer has a Ph.D and Prof. Maurer is poor.
Note change in quantifiers.
The Rules of Inference XI
If P is known to be true, P is false, and vice
versa.
If P.Q is true, then Q.P is true
If P.Q is true then both P and Q are true.
If P.Q is known to be false, and P is known
to be true, then Q is false.
If PvQ is true, then QvP is true.
If PvQ is false, then both P and Q are false.
If PvQ is known to be true, and P is known to
be false, then Q is true.
The Rules of Inference XII
If PQ is known to be true, and P is
true, then Q is true.
If PQ is known to be true, and Q is
false then P is false.
The Rules of Inference XIII
If PQ is known to be true and P is
true then Q is true, and vice versa.
If PQ is known to be true and P is
false then Q is false, and vice versa.
If PQ is known to be false and P is
false then Q is true, and vice versa.
If PQ is known to be false and P is
false then Q is true, and vice versa.
Logical Fallacies: The Biggie I
Lets go back to our theorem
(x+1)
2
=x
2
+2x+1 and give another
invalid proof.
X=5, (x+1)
2
=(5+1)
2
=6
2
=36
x
2
+2x+1=5
2
+2*5+1=25+10+1=36
Hence Proved
What has really been proved?
(See Next Slide)
Logical Fallacies: The Biggie II
This proof proves:
-
x
(x+1)
2
=x
2
+2x+1
But the theorem was:
x
(x+1)
2
=x
2
+2x+1
For the preceding to be a proof, the
following implication would have to be
true for all propositions P
-
x
P
x
P
Logical Fallacies: The Biggie III
Is -
x
P
x
P true for all P?
Here is a capital letter A: A
This capital A is red. For the implication
to be true, ALL capital As would have
to be red.
But this one isnt: A
Logical Fallacies: The Biggie IV
Most students have a hard time
understanding this.
It is not the calculations that are
incorrect in the proof given above.
It is the Inference that is wrong!
If an inference technique can be used
to prove silly nonsense (all capital As
are red), then it cannot be used to
prove anything true.
Logical Fallacies: The Biggie V
When you are asked to prove
something in a class, it is generally
something that is well-known to be
true.
Your proof isnt supposed to derive a
new truth.
Your proof is supposed to demonstrate
that you know how to apply the rules of
inference correctly.
Logical Fallacies: The Biggie VI
Question: You run your program P on X
number of inputs and observe that
condition C is true on all these inputs.
Does this prove that condition C is true
on ALL inputs?
Answer: No
Repeat Answer: No
Repeat Answer Again: No, No, No, No
Logical Fallacies: The Biggie VII
Testing a program cannot prove
anything.
There is no such thing as proof by
example
That is: examples can be used to prove
existential statements, but cannot be
used to prove universal ones.
This is an inductive fallacy known as:
Hasty Generalization
Other Logical Fallacies I
Appeal to Authority: But thats what it
says in the book!
Usually a lie.
If the book has the wrong answer
And you copy the answer onto your test
Then your answer is: WRONG!
Other Logical Fallacies II
Non Sequitur: Squaring something is a
more powerful operation than adding
something, so (x+1)
2
cant possibly
equal x
2
+1, therefore we have to add
2x to offset the power of the squaring
operation.
The truth of (x+1)
2
=x
2
+2x+1 does not
follow from this argument. You must
use the axioms of the real numbers
Other Logical Fallacies III
Ad Ignorandum (appeal to ignorance): We
certainly cannot prove it false that
(x+1)
2
=x
2
+2x+1.
Or alternatively: Why shouldnt it be true that
(x+1)
2
=x
2
+2x+1?
An inability to prove the falsity of something
does not imply that it is true.
You cannot assert whatever you want and
then defy the world to prove it false. You
must prove your statements to be true.
Other Logical Fallacies IV
Assuming the converse: If this square
root function is correct then it will
compute the square root of 4 to be 2.
This square root function computes the
square root of 4 to be 2, therefore it is
correct.
See next slide for the code of this
function.
Other Logical Fallacies V
float SquareRoot(float x)
{
return 2.0;
}
Given a true statement of the form if P
then Q, the truth of P proves the truth
of Q.
However, the truth of Q does not prove
the truth of P.
Other Logical Fallacies VI
Assuming the Inverse: If a number n is
prime and greater than 2 then it must
be odd.
This number is greater than two, but it
is not prime. Therefore, it cant be odd.
The number is 9.
Other Logical Fallacies VII
Given a true statement of the form If P
then Q:
The falsity of Q proves the falsity of P.
However, the falsity of P does not prove
the falsity of Q.
Since the converse is logically
equivalent to the inverse, assuming the
inverse and assuming the converse are
the same fallacy.
Proving Things, In General
Take stock of your resources. These are
the things that are known to be true.
The given elements of the problem
Axioms
Proven Theorems
Use your tools to derive the result from
your resources. Your tools are your
rules of inference.
Proving If-Then Statements
For a statement of the form If P then Q,
add P to your resources. P is assumed
to be true.
You must use the rules of inference to
derive Q from your resources.
Inductive Proofs
Suppose P(n) is a statement about
integers. (It must be about integers.)
To prove that P(n) is true, you must
prove P(0) and the statement if P(n)
then P(n+1)
The axioms of the integers state that
There is an integer 0. and Every
integer n has a successor n+1
Complete Induction
Complete induction is weaker than
normal induction, because it does not
use the axioms of the integers directly.
For complete induction you must prove
P(0) and the statement if P(k) for all
k<n then P(n)
Disproving Things I
A disproof of a statement is the same
as proving the negation of the
statement.
Disprove: No even integer is prime.
2 is prime.
One counterexample is sufficient to
disprove a universally quantified
statement.
Disproving Things II
Disprove: All odd integers are prime.
9 is odd and is not prime
One counterexample is sufficient.
Disprove: There is an even integer
greater than 2 which is prime.
Proof: if x is an even integer it must be
of the form 2k for some integer k (by
definition). (continued on next slide)
Disproving Things III
Since x>2 we have 2k>2.
Canceling the 2s (inverse law of
multiplication) we get k>1.
Since x=2k, and k>1, x is composite,
and cannot be prime. Therefore if x is
an even number greater than 2, it
cannot be prime.
Disproving an existential requires proof
of a universal
Acknowledgements
I would like to thank the following
individuals for drumming these facts
into my head.
Richard Farrell
James Ewbank
George Blodig