generated from PreTeXtBook/pretext-codespace
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<section xml:id="sec-proof-induction" xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<title>Proof and Induction</title> | ||
<introduction> | ||
<p> | ||
Proofs are fundamental to mathematics and computer science, providing the means to demonstrate the truth of statements. One powerful proof technique is mathematical induction, which is especially useful for proving properties about integers, sequences, and recursive structures. Induction allows us to prove that a statement holds for all natural numbers by first proving it for a base case and then showing that if it holds for an arbitrary case, it must also hold for the next case. | ||
</p> | ||
</introduction> | ||
|
||
<subsection xml:id="subsec-direct-proof"> | ||
<title>Direct Proof</title><idx><h>direct proof</h></idx> | ||
<p> | ||
A direct proof is a straightforward method of proving a statement by assuming the premises and logically deriving the conclusion. For example, let’s prove that the sum of two even integers is always even. | ||
</p> | ||
<sage> | ||
<input> | ||
# Direct proof in Sage: Checking the sum of two even numbers | ||
|
||
def is_even(n): | ||
return n % 2 == 0 | ||
|
||
a, b = 4, 6 # Two even numbers | ||
is_even(a + b) | ||
</input> | ||
</sage> | ||
<p> | ||
This simple example shows that the sum of two even numbers <m>a</m> and <m>b</m> is also even, as their sum can be divided evenly by 2. | ||
</p> | ||
</subsection> | ||
|
||
<subsection xml:id="subsec-mathematical-induction"> | ||
<title>Mathematical Induction</title><idx><h>induction</h><h>mathematical induction</h></idx> | ||
<p> | ||
Mathematical induction is a proof technique used to prove statements about natural numbers. It consists of two steps: | ||
</p> | ||
<ul> | ||
<li> | ||
<p> | ||
<term>Base Case</term>: Prove that the statement holds for the first value (usually 0 or 1). | ||
</p> | ||
</li> | ||
<li> | ||
<p> | ||
<term>Inductive Step</term>: Prove that if the statement holds for some arbitrary value <m>k</m>, then it also holds for <m>k+1</m>. | ||
</p> | ||
</li> | ||
</ul> | ||
<p> | ||
Together, these steps show that the statement holds for all natural numbers. Let’s use induction to prove that the sum of the first <m>n</m> positive integers is <m>\frac{n(n + 1)}{2}</m>. | ||
</p> | ||
<sage> | ||
<input> | ||
# Proof by induction: Sum of first n positive integers | ||
|
||
def sum_n(n): | ||
return sum(range(1, n+1)) | ||
|
||
def induction_step(k): | ||
return sum_n(k) + (k + 1) | ||
|
||
base_case = (sum_n(1) == 1 * (1 + 1) // 2) | ||
inductive_step = (induction_step(3) == 3 * (3 + 1) // 2) | ||
|
||
base_case, inductive_step | ||
</input> | ||
</sage> | ||
<p> | ||
In the base case, for <m>n = 1</m>, we check that the sum is <m>1</m>, and for the inductive step, we assume the statement holds for some <m>k</m> and show it holds for <m>k + 1</m>. In this example, we check for <m>k = 3</m>. | ||
</p> | ||
</subsection> | ||
|
||
<subsection xml:id="subsec-strong-induction"> | ||
<title>Strong Induction</title><idx><h>strong induction</h></idx> | ||
<p> | ||
Strong induction is similar to regular induction, but in the inductive step, we assume the statement is true for all values up to some <m>k</m> (not just <m>k</m> itself) and use this to prove it for <m>k+1</m>. This method is particularly useful when proving statements about recursive structures or algorithms. | ||
</p> | ||
<p> | ||
Let’s prove that any integer greater than 1 can be written as a product of prime numbers using strong induction. | ||
</p> | ||
<sage> | ||
<input> | ||
# Example: Strong induction to prove prime factorization | ||
|
||
def is_prime(n): | ||
if n < 2: | ||
return False | ||
for i in range(2, int(n ** 0.5) + 1): | ||
if n % i == 0: | ||
return False | ||
return True | ||
|
||
def factorize(n): | ||
factors = [] | ||
for i in range(2, n + 1): | ||
while n % i == 0: | ||
factors.append(i) | ||
n //= i | ||
return factors | ||
|
||
strong_induction_example = factorize(12) | ||
strong_induction_example | ||
</input> | ||
</sage> | ||
<p> | ||
Using strong induction, we can show that any number <m>n > 1</m> can be factorized into primes. In this example, we factorize <m>12</m> as <m>2 \times 2 \times 3</m>, all of which are prime numbers. | ||
</p> | ||
</subsection> | ||
</section> |