Skip to content

Commit

Permalink
Merge pull request #126 from SageMathOER-CCC/proof-and-induction
Browse files Browse the repository at this point in the history
Proof and induction
  • Loading branch information
hcolmanccc authored Sep 8, 2024
2 parents a4b69f2 + 5addf53 commit ea99473
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 18 deletions.
18 changes: 0 additions & 18 deletions source/frontmatter.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@
</p>
</li>

<li permid="XXu">
<p permid="hrg">
Simon King, University of Jena*
</p>
</li>

<li permid="XXu">
<p permid="hrg">
Vartuyi Manoyan, Wright College
Expand All @@ -89,18 +83,6 @@
</p>
</li>

<li permid="XXu">
<p permid="hrg">
Soma Dey, Wright College*
</p>
</li>

<li permid="XXu">
<p permid="hrg">
Sydney Hart, Wright College*
</p>
</li>

<li permid="XXu">
<p permid="hrg">
Ted Jankowski, Wright College
Expand Down
1 change: 1 addition & 0 deletions source/relations/ch-relations.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<xi:include href="sec-properties.ptx" />
<xi:include href="sec-equivalence.ptx" />
<xi:include href="sec-partial-order.ptx" />
<xi:include href="sec-proofs-inductions.ptx" />
</chapter>
107 changes: 107 additions & 0 deletions source/relations/sec-proofs-inductions.ptx
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 &lt; 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 &gt; 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>

0 comments on commit ea99473

Please sign in to comment.