Download Chapter 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

Truth-bearer wikipedia , lookup

Peano axioms wikipedia , lookup

Argument wikipedia , lookup

Inquiry wikipedia , lookup

Propositional calculus wikipedia , lookup

Laws of Form wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Intuitionistic logic wikipedia , lookup

Mathematical logic wikipedia , lookup

Gödel's incompleteness theorems wikipedia , lookup

Kolmogorov complexity wikipedia , lookup

Sequent calculus wikipedia , lookup

Turing's proof wikipedia , lookup

Law of thought wikipedia , lookup

Georg Cantor's first set theory article wikipedia , lookup

Curry–Howard correspondence wikipedia , lookup

Natural deduction wikipedia , lookup

Theorem wikipedia , lookup

Mathematical proof wikipedia , lookup

Transcript
Proofs, Recursion and Analysis of
Algorithms
Mathematical Structures
for Computer Science
Chapter 2.1
Copyright © 2006 W.H. Freeman & Co.
MSCS Slides
Proofs, Recursion and Analysis of Algorithms
Section 2.1: Proof Techniques



Chapter 1: formal proofs
The problem: show the validity of theorems represented in the
form P  Q, where P and Q may be compound statements.
Validity proof: Given a set of hypotheses (the antecedent of the
implication) and using equivalence rules and rules of inference
from predicate logic, show that Q follows logically from P.


Section 2.1
Validity of the implication is based on its structure so if a proof is
valid it is universally valid, regardless of the semantics of the
individual components of the antecedent and the consequent.
For example, it was shown that
if (P  Q)  (Q  R), then (P  R)
This is valid regardless of what P, Q, and R represent.
(Remember, we say if the antecedent is true then the consequent is
true.)
Proof Techniques
1
Section 2.1: Proof Techniques


In Chapter 2, we deal with proofs for things that aren’t
universally true but only apply within a certain context – graph
theory, number theory, the animal kingdom, etc.
To prove theorems of this sort we can add facts from the context
that act as hypotheses.




Section 2.1
For example, if the context is number theory, and we are asked to
prove that the product of two even integers is also even, we can use
knowledge about number theory. In particular, we could use the
fact that an even integer is divisible by 2, or that an even integer m
can be rewritten as 2k for some integer k.
In this example, P(x, y) : x is an even integer  y is an even integer
Q(x, y): xy is an even integer
It can be proven that P(x,y)  Q(x, y), but this is true only for the
domain of integers.
Proofs of this sort are often presented in a more informal
manner, and don’t rely solely on rules of inference and
equivalences.
Proof Techniques
2
Proof Techniques

A few terms to remember:

Axioms: Statements that are assumed true.
• Example: Given two distinct points, there is exactly one line that
contains them.
• Axioms can be used as hypotheses in proofs




In order to turn a conjecture into a theorem, we must find a way
to prove it.


Definitions: Used to create new concepts in terms of existing ones.
Theorem: A proposition that has been proven to be true.
Conjecture: an opinion based on incomplete information.
Or, by disproving it, show that no proof exists
Definitions and axioms can be used in the proof process.
.
Section 2.1
Proof Techniques
3
Proof Techniques

Inductive reasoning versus deductive reasoning

Inductive reasoning is drawing conclusions based on experience
• A way of developing conjectures
• Not a proof


Informal proof methods :





Section 2.1
Deductive reasoning: determines the truth or falsity of a conjecture
through proofs or counter examples
Proof by exhaustive enumeration
Direct proof
Proof by contraposition
Proof by contradiction
Serendipity (not really a proof technique)
Proof Techniques
4
Deductive Reasoning: Using Counterexamples




Inductive reasoning: Drawing a conclusion from a hypothesis
based on experience.
Usually, deductive reasoning is also applied to the same
conjecture to ensure that it is indeed correct.
Deductive reasoning may start by looking for a counterexample
that disproves the conjecture, i.e. a case when P is true but Q is
false.
Example: Prove that “For every positive integer n, n!  n2.”




Note that finding a single case that doesn’t satisfy the condition
is enough to disprove the theorem, because formally our
conjecture states (x) P(x)  Q(x)

Section 2.1
Start testing some cases say, n = 1, 2, 3 etc.
This is true for some cases but now let n = 4.
We get n! = 24 and n2 = 16; a counterexample for this conjecture.
On the other hand, finding a single example where the conjecture
is true (or even many examples) is not enough to prove it is true.
Proof Techniques
5
Counterexample

Practice: Find a counterexample for each of the
following conjectures:





Section 2.1
All animals living in the ocean are fish.
Everyone in this class is a computer engineer.
Disproof by counterexample: relatively common
Proof by example: not so much. Works only if you
are able to consider every case that the conjecture
applies to. This leads to the following definition:
Exhaustive enumeration (proof by exhaustion) is a
proof technique that can be applied to conjectures that
are applied to a finite set of objects.
Proof Techniques
6
Exhaustive Proof



Section 2.1
In a finite domain in which the conjecture is to be proven valid, then to
use the exhaustive proof technique, you must try all possible cases for
each member of the domain.
Final result of this exercise: you prove or disprove the theorem but you
could be definitely exhausted.
Example: For any non-negative integer less than or equal to 5, the
square of the integer is less than or equal to the sum of 10 plus 5 times
the integer.
n
n2
10+5n
n2 < 10+5n
0
0
10
yes
1
1
15
yes
2
4
20
yes
3
9
25
yes
4
16
30
yes
5
25
35
yes
Proof Techniques
7
Example: Exhaustive Proof

Example : If an integer between 1 and 20 is divisible by 6, then
it is also divisible by 3.


Example: Prove the conjecture “It is not possible to trace all the
lines in Figure 2.1 without lifting your pencil and without
retracing any lines”


Section 2.1
See the proof in Table 2.1, page 91
Tedious, but possible, to enumerate and try all possible cases
The number of theorems that are proven using proof by
exhaustion is relatively small.
Proof Techniques
8
Direct Proof

Proof methods:











Section 2.1
Proof by exhaustive enumeration
Direct proof
Proof by contraposition
Proof by contradiction
Serendipity (not really a proof technique)
and disproof by counterexample
Direct Proof:
Used when exhaustive proof/disproof by counterexample don’t work.
Using the rules of propositional and predicate logic, prove P  Q.
Hence, assume the hypothesis P and prove Q. Hence, a formal proof
would consist of a proof sequence to go from P to Q.
Consider the conjecture
x is an even integer Λ y is an even integer  the product xy is an even integer.
A formal direct proof would start by listing the hypotheses and then
applying inference rules and equivalence rules to (hopefully) produce the
desired result.
Proof Techniques
9
Direct Proof

For example (see pages 92-93 for complete proof sequence)
1.
2.
3.
4.
5.
6.
7.
8.

Note


Section 2.1
x is an even integer Λ y is an even integer
hyp
(x)[x is even integer (k)(k is an integer Λ x = 2k)]
number fact
(definition of even integer)
x is even integer (k)(k is an integer Λ x = 2k)
2,ui
y is even integer (k)(k is an integer Λ y = 2k)
2,ui
x is an even integer
1,sim
(k)(k is an integer Λ x = 2k)
3,5,mp
m is an integer Λ x = 2m
6, ei
y is an even integer
1,sim
….
xy is an even integer
19, 21, mp
That in step 2, a fact has been introduced that is unique to the domain of
integers.
The use of new inference rules: ui = universal instantiation, and ei =
existential instantiation
Proof Techniques
10
Informal Direct Proof

Informal direct proofs simplify the process of writing out a proof
but they do not skip any essential steps – they are just as complete
in terms of rigor and correctness.


Informal proof that the product of two even integers, x & y, is also
even: (page 93)




Section 2.1
Example: a theorem might be stated as P(x)  Q(x). If the proof is
made for an arbitrary element of the domain, we can safely
generalize to the more formal statement (x) P(x)  Q(x).
Let x = 2m and y = 2n, where m & n are integers
Then xy = (2m)(2n) = 2(2mn).
Thus the product xy has the form 2k, where k is an integer.
The proof doesn’t explicitly state the hypothesis, (that x and y are
even) or the definition of even integer, which is used in the first
step. Nevertheless it is clear about each step and doesn’t leave out
any important information. There are times, even in an informal
proof, when it is useful to explain the reason for a step in the
proof. It’s better to be too complete than to leave out something
significant.
Proof Techniques
11
Proof by Contraposition



Sometimes you aren’t successful generating a direct proof of
P  Q.
In this case, consider using one of the inference rules of
propositional logic, known as contraposition (termed “cont” in
short). See Table 1.14 (page 133).
It states that (Q  P)  (P  Q) (a Tautology).



Section 2.1
Remember that a tautology is a wff that is true in every case,
regardless of the truth values assigned to the individual
components.
Q  P is the contrapositive of P  Q.
Hence, proving the contrapositive proves the conjecture.
Proof Techniques
12
Proof by Contraposition

Example: Prove that if the square of an integer is odd, then the
integer must be odd






Section 2.1
Hence, prove n2 odd  n odd
To do a proof by contraposition prove n even  n2 even
If n is even, then it can be written as 2m where m is an integer, i.e.
even/odd.
Then, n2 = 4m2 which is always even no matter what m2 is because
of the factor 4.
We’ve proved that if the square of an integer is even, then the
integer is even.
Since this is the contrapositive of what we set out to prove, we
have also proven our original conjecture.
Proof Techniques
13
If and Only If Theorems

A theorem that states “Q is true if and only if P is true”
means that you must prove both



Example 9 (p. 94): xy is odd if and only if both x and y are
odd integers.



P → Q and Q → P
Q → P is the converse of P → Q
Assume both are odd. Then x = 2n +1, y = 2m +1
xy = (2n + 1)(2m +1) = 2(wnm + m + n) + 1 or 2k +1
We’ve proven the “if” part – now the “only if”.




Section 2.1
i.e., if xy is odd then both x and y are odd – or, easier,
prove the contrapositive: (x odd and y odd) → (xy even)
Use DeMorgan’s law, rewrite as
x even or y even → xy even
There are then three cases, based on the possible values of x and y
Proof Techniques
14
Proof by Contradiction




Derived from the definition of contradiction which says
P Λ Q  0
Hence, (P Λ Q  0)  (P  Q) is a tautology.
In a proof by contradiction, one assumes that the hypothesis is
true, the negation of the conclusion is true, and that these
assumptions lead to a contradiction.
Example 1: Prove that “If a number added to itself gives itself,
then the number is 0.”



Section 2.1
The hypothesis (P) is x + x = x and the conclusion (Q) is x = 0.
Hence, the hypotheses for the proof by contradiction are:
x + x = x and x 0 (the negation of the conclusion)
Then 2x = x and x 0, hence dividing both sides by x, the result is
2 = 1, which is a contradiction. Hence, (x + x = x)  (x = 0).
Proof Techniques
15
Proof by Contradiction

Example 2: Prove “For all real numbers x and y, if x + y  2,
then either x 1 or y 1.”




Example 3: The sum of even integers is even.




Section 2.1
Proof: Say the conclusion is false, i.e. x < 1 and y < 1. (Note: or
becomes and in negation.)
Adding the two conditions, the result is x + y < 2.
At this point, this condition is P if P = x + y  2, hence, P Λ P
which is a contradiction. Hence, the statement above is true.
Proof: Let x = 2m, y = 2n for integers m and n and assume that
x + y is odd.
Then x + y = 2m + 2n = 2k + 1 for some integer k.
Hence, 2*(m + n - k) = 1, where m + n - k is some integer.
This is a contradiction since 1 is not even.
Proof Techniques
16
Serendipity




Serendipity: Fortuitous happening or something by chance or
good luck.
Not a formal proof technique.
Interesting proofs provided by this method although other
methods can be used as well.
Example: 342 players in a tennis tournament. One winner in the
end. Each match is between two players with exactly one winner
and the loser gets eliminated. Prove the total number of matches
played in the tournament are 341.

Section 2.1
Solution: Only one champion at the end of the tournament, hence
???
Proof Techniques
17
Summarizing Proof techniques
Section 2.1
Proof Technique
Approach to prove P  Q
Remarks
Exhaustive Proof
Demonstrate P  Q
for all cases
May only be used for
finite number of cases
Direct Proof
Assume P, deduce Q
The standard approachusually the thing to try
Proof by
Contraposition
Assume Q, derive P
Use this Q if as a
hypothesis seems to
give more ammunition
then P would
Proof by
Contradiction
Assume P Λ Q , deduce a
contradiction
Use this when Q says
something is not true
Serendipity
Not really a proof
technique
Try thinking outside the
box
Proof Techniques
18
Class Exercise
1.
2.
3.
4.
5.
Section 2.1
Product of any 2 consecutive integers is even.
Product of 3 consecutive integers is even.
The square of an odd integer equals 8k+1 for some
integer k.
The sum of two rational numbers is rational.
For some positive integer x, x + 1/x ≥ 2.
Proof Techniques
19