Mathematical induction and the well-ordering principle
The three forms of induction (weak, strong and well-ordering), their equivalence, and the art of strengthening the hypothesis, exactly as when finding a loop invariant. A constructive inductive proof is a recursive algorithm.
After this lesson you can
- Write weak and strong induction proofs with correct base cases
- Prove the equivalence between induction and the well-ordering principle
- Strengthen the induction hypothesis when the original statement is not inductive
- Extract the recursive algorithm implicit in a constructive inductive proof
- Identify typical mistakes in inductive proofs
Before you start
Motivation: a million cases are not a proof
Almost everything you program has the form “do something with the small case and combine it.” Mergesort sorts each half and merges them; binary search discards half the interval and starts again; a for loop updates an accumulator once per element. The question “is it correct?” always has the same structure: if the algorithm works on the smallest inputs, does it work on this one? Answering for all inputs requires an argument covering infinitely many cases in finitely many steps. That argument is induction, and without it there is no correctness proof for a recursive or iterative algorithm (you will see it in divide-and-conquer correctness and loop invariants).
Testing many cases does not suffice. Euler observed that is prime for : forty consecutive cases. At it is . Worse, Pólya conjectured in 1919 that, for every , at least half the integers from to have an odd number of prime factors (counted with multiplicity). It was checked for decades; in 1958 Haselgrove proved it false without giving a counterexample, and in 1980 Tanaka found the smallest: . No test suite would have gone so far. As you saw with refutation by counterexample, one failing case suffices to bring down a universal statement; now we need the opposite, a way to establish it without examining every case.
This lesson presents induction in three forms (weak, strong and the well-ordering principle), proves their equivalence and focuses on the genuinely difficult part: what to do when the claim you want to prove is not inductive and must be strengthened, exactly what you do when searching for a loop invariant. Along the way you will see that a constructive inductive proof is literally a recursive program.
Intuition: dominoes pushing one another
Imagine an infinite row of dominoes, one for each natural number. Domino represents the statement , and “fallen” means “proved.” To topple them all, two things suffice: push the first (the base case) and ensure that each domino, upon falling, knocks down the next (the inductive step). Neither suffices alone, and the second has a subtlety: it does not say the dominoes fall, but that if one falls, the next falls.
The scenario teaches the figure’s most useful lesson. The statement is true at and (, ), false at (, , ) and true from onward. The step argument, which we will give shortly, works only for . With base case the first domino falls, but the first link is unproved; with the links are there, but the first domino does not stand. The whole chain needs both at once, first achieved at .
Weak induction
Let us state the principle precisely. A predicate over the naturals is a formula with a free variable .
This scheme is weak induction or ordinary induction. Pay attention to each quantifier, where errors arise (review the quantifier laws if needed). The step does not assert , which is what we want to prove. It asserts , and is proved like any universal: fix an arbitrary , assume (the induction hypothesis) and deduce with a direct proof. Assuming is not cheating: it is the premise of an implication.
Two immediate variants are used constantly. If the claim begins at instead of 0, the base is and the step is proved for every ; apply the principle to . The principle is not a trick to justify every time: in Peano arithmetic it is an axiom (a schema, one per predicate), and in set theory a theorem, because is defined as the smallest set containing 0 and closed under successor. Below we see it is equivalent to another property, well-ordering, which is often more intuitive.
The template
A well-written induction proof always has five parts, all worth writing even when they seem obvious:
- Statement , with explicit induction variable and range ().
- Base case: check .
- Induction hypothesis: “let and assume .”
- Step: deduce , identifying where the hypothesis is used. If unused, the proof is not inductive (and probably wrong).
- Conclusion: by induction, for every .
The proof has a geometric reading: an square of points becomes an square by adding an L-shaped border of points. The inductive step is exactly that addition.
The assumption is used in one place, when multiplying (the last step needs only ), and without it the result is false: with and , . Finding where each assumption enters distinguishes a proof you understand from one you copied. This inequality returns in sequence limits: for example, it gives if , because .
Notice the order: first the step, to find from which it works, then the base case, which must lie within that range. This is what you did with the figure.
Strong induction
Sometimes follows not from but from earlier, more distant cases. When factoring , the factors and may be any pair smaller than ; knowing that is a product of primes does not help.
This is strong induction or complete induction: in the step you may assume all earlier cases, not only the immediately preceding one. Formally there is no separate base case. For the hypothesis “” is empty, so the step requires proving without help. In practice the step splits into cases: small values of with nothing earlier to use (the base cases, possibly several) and the general case.
Proof
It follows from weak induction by a trick that will recur: prove something stronger. Let be “ for every .” holds vacuously. If holds, the theorem’s hypothesis gives , and since means or , we have . By weak induction holds for all ; in particular gives .
∎Notice that the case “ prime” acts as a base case, although it does not occur only at the beginning: are proved without the hypothesis. Uniqueness of factorization is more delicate and you will handle it in the exercises using well-ordering.
Several base cases: the postage-stamp problem
You have only 4-cent and 7-cent stamps. Which amounts can you pay exactly? A little trial shows cannot be paid (neither , nor , nor is a multiple of 4), but , , and .
Statement. Every can be paid with 4- and 7-cent stamps.
Proof. By strong induction. The cases are the four above. If , then and by hypothesis can be paid; adding a 4-cent stamp pays .
Why four base cases? The step uses , and for to lie in the proved range we need . The four values have no earlier case to appeal to within the range and must be done by hand. With one base case the proof would show and nothing more.
The figure suggests the general proof. With stamps and , the multiples have distinct remainders modulo (if , then divides and, since it shares no factor with , divides ). Thus each column becomes payable at one of them and remains so thereafter. The last starts at , and the amount just above, , is the largest impossible one. This is a result of J. J. Sylvester (1884). The general case, finding the largest impossible amount with stamps that are collectively coprime, is the Frobenius problem, and for three or more stamps has no general closed formula (F. Curtis proved in 1990 that none of polynomial type can exist).
The well-ordering principle
There is a third way to say the same thing without mentioning steps or hypotheses.
This is the well-ordering principle. It seems trivial, but depends entirely on the structure of . It fails in (the negative integers have no least element), in (the set has no minimum), and in (nor does the interval ). What makes special is the absence of infinite strictly decreasing sequences: from any one can descend only finitely many times. That idea, Fermat’s infinite descent, guarantees that a loop terminates when its variant function is a natural number decreasing on each iteration.
Proof
(1) ⇒ (2) is the strong induction proof you have seen. Two implications remain.
(3) ⇒ (1). Assume and , and suppose, for contradiction, that the set of counterexamples is nonempty. By well-ordering it has a least element . It cannot be , since is true; thus for some . Since and is the least counterexample, is true, and the step gives . Contradiction.
(2) ⇒ (3). By contraposition: let have no least element and show . Let be “.” Assume holds for every , meaning no number smaller than is in . If were in , it would be its least element, which does not exist; hence , which is . By strong induction no is in .
∎“Equivalent” has a precise meaning here: each principle follows from either other one plus the basic properties in the statement, which do not imply any of the three by themselves. There is no sense asking which is “the true one”; each is more convenient for a type of proof. Induction builds upward; well-ordering reasons about the first failure.
Minimal-counterexample proofs
The proof of (3) ⇒ (1) is a method in itself. To prove :
- Assume there are counterexamples and take the least, (the minimal counterexample).
- Use the fact that holds for every to construct a counterexample smaller than (or reach another contradiction).
This is strong induction written backward, and often the most natural form when the argument “descends” from one case to a smaller one.
This is the same argument as in the previous lesson, but well-ordering makes explicit why descent cannot continue forever. Another application needed in the exercises: every has a prime divisor. Otherwise let be the least counterexample. is not prime (it would be its own prime divisor), so with ; by minimality has a prime divisor, which also divides . Contradiction.
Strengthening the hypothesis
Until now the statement could be proved as given. The lesson’s most important phenomenon is that often it cannot, even when true.
Start with a minimal example. Statement: the sum of the first odd numbers is a perfect square. Try the step: you know is some square and want to be a square. Without knowing , you cannot: with and is . The hypothesis is too weak to feed the step. The solution is to prove something stronger, that the sum is exactly , and then the step works, as you saw. The paradox is only apparent: strengthening the statement also strengthens the induction hypothesis used in the step. Pólya called this the inventor’s paradox: the more ambitious plan may be more likely to succeed.
We must clarify what “cannot” means, because logic has a trap. If holds for all , the implication is true outright, because its conclusion is true. What fails is not the implication, but the possibility of deducing it knowing only what says about , the situation of the person proving it. In the case most relevant here, a recursively defined quantity (a partial sum, a loop state), this is formalized by separating value from property.
“Every value ,” not just the actual value , makes the notion demanding. In the odd-number example, and . The property “ is a square” is not inductive (the earlier : , ), although it holds for every ; “” is inductive and implies the first.
That move is strengthening the induction hypothesis. A series is the canonical example.
Why is not inductive
Let . We want to show for every . It is true (the limit is ), yet the direct step is impossible. If all you know is , then
which is not . The problem is not algebraic skill: the hypothesis allows arbitrarily close to 2, and then any positive term pushes it over. In the definition’s language, and is not inductive: with and we get . We need to know how much margin remains.
Proof
Base: . Step: assume . Then
and this is if and only if , which holds because .
∎The strengthened claim says more (it gives a bound improving with ), and precisely for that reason is provable: the hypothesis supplies a cushion of , of which the step spends only part. Since is increasing and bounded, the bound also proves the series converges (by completeness of the reals), without calculating its sum.
How do we find such a bound? Regard the step as a budget. If the hypothesis is , the step closes using only the hypothesis if the bound rises at least as much as the sum:
With the bound does not rise and the step always fails. With it rises by , and the condition becomes for every , that is, . But the base case requires . The value is the only one that works with base : the bound was not found by inspiration, but by solving both constraints.
The lab’s third family shows there is room for refinement. Since , we have , so closes the step for any , with margin. The base case gives : a five-line induction proof establishes , only from the exact value. Delaying the base to (and checking by hand) gives , with three correct digits of .
The same move in a program
Consider a loop computing and the assertion to verify at the end:
s = 0.0
for k in range(1, n + 1):
s += 1 / k**2
assert s < 2 # cierto, pero no se puede demostrar iteración a iteración
A checker (or you, reasoning) can use at each iteration only what it knows from the previous one. Knowing s < 2 does not guarantee s + 1/(k+1)**2 < 2. What is preserved is s <= 2 - 1/k: a loop invariant, a property true on entry and preserved by every iteration. An invariant is, word for word, an induction hypothesis over the number of iterations, and almost never matches the desired postcondition: it must be strengthened. Finding invariants is the creative part of loop verification in lesson 8, and tools such as Dafny or proof assistants ask for exactly that: an inductive invariant, not merely a true one.
Induction as recursion
A board missing one square has squares, a multiple of 3 (because modulo 3). Can it always be covered without overlaps by L-trominoes, three-square pieces occupying a block minus one corner? Whatever square is missing, yes, and the proof (Solomon Golomb, 1954) is as short as a program.
Proof
Induct on . Base, : the board is one square, ; what remains is empty and is tiled by the empty set of pieces.
Step: assume the result for with any hole, and take a board without square . Divide it into four quadrants. One contains . Place a tromino at the board’s center covering, in each of the other three quadrants, the square touching the board’s center (the four squares around the center form a block, one per quadrant, so those three form an L). Each quadrant now has exactly one unavailable square (the hole , or the square just covered by the central tromino), so by the induction hypothesis each can be tiled. Combining the four tilings and central tromino tiles the board.
∎The induction hypothesis applies to quadrants with holes in arbitrary positions: not the board with its hole , but four boards with four different holes. That is why the statement says “every square ” and not “one fixed square”: the quantifier over must be inside predicate so the hypothesis inherits it. This is another form of strengthening: generalizing a parameter.
Read the proof again as code and the correspondence is complete:
| Proof | Program |
|---|---|
| statement : “for every hole there is a tiling” | signature teselar(n, h) returning a tiling |
| base case | recursion base: nothing to place |
| induction hypothesis applied to a quadrant | recursive call teselar(n - 1, h') |
| construction in the step (central tromino) | local work of each call |
| induction is on , which decreases | recursion terminates |
A constructive inductive proof, which not only asserts existence but says how to obtain the object from smaller cases, is a recursive algorithm whose correctness is the proof itself. Prime factorization above is factorizar(n): if n is prime, return it; otherwise find a divisor and concatenate the two calls. The stamp problem is sellos(n) = sellos(n - 4) + [4] with four base cases in a table. This correspondence is no metaphor: in the module’s final lesson, the Curry–Howard correspondence turns it into a formal identity between proofs and programs.
The proof also gives the cost. If counts placed pieces, and , a recurrence with solution : exactly the number of squares divided by three, as required. The algorithm does constant work per piece, so it is linear in board size, which is optimal.
Classic mistakes
All horses are the same color
Pólya popularized this “proof” that all horses in any finite set have the same color.
: in every set of horses, all are the same color. Base: with one horse, obvious. Step: take horses numbered . The first , , have the same color by hypothesis. The last , , do too. Since the middle horses belong to both groups, the two colors agree and the horses all have the same color.
The statement is false, so something fails. The base case is correct. The flaw is in “the middle horses”: has elements, and when it is empty. With two horses, and share none and nothing relates their colors. The step is valid for every , but fails at , precisely the link joining the base to everything else.
Implementation: inductive proofs are programs
First, tromino tiling, translated line by line from the proof. Each piece receives a number; the hole stays 0. Verification is independent of the algorithm: it checks that each piece has three squares within a block (three distinct squares in a block always form an L) and nothing remains uncovered.
import numpy as np
def teselar(n, hueco):
"""Tesela el tablero 2^n x 2^n sin la casilla `hueco` = (fila, columna), siguiendo la demostración.
Devuelve una matriz con 0 en el hueco y el número de pieza (1, 2, ...) en cada casilla."""
lado = 2 ** n
T = np.zeros((lado, lado), dtype=np.int32)
siguiente = [0]
def resolver(f0, c0, tam, hf, hc):
if tam == 1: # caso base: un tablero 1x1 sin su única casilla está vacío
return
m = tam // 2
qh = (hf >= f0 + m, hc >= c0 + m) # cuadrante del hueco
siguiente[0] += 1
huecos = {}
for df in (0, 1):
for dc in (0, 1):
if (df, dc) == qh:
huecos[(df, dc)] = (hf, hc) # el hueco real se queda en su cuadrante
else:
f, c = f0 + m - 1 + df, c0 + m - 1 + dc # casilla de este cuadrante que toca el centro
T[f, c] = siguiente[0] # la cubre el triominó central
huecos[(df, dc)] = (f, c) # y pasa a ser su hueco «ficticio»
for (df, dc), (f, c) in huecos.items():
resolver(f0 + df * m, c0 + dc * m, m, f, c) # hipótesis de inducción = llamada recursiva
resolver(0, 0, lado, *hueco)
return T
def es_teselado(T, hueco):
"""Comprueba que T cubre cada casilla salvo el hueco exactamente una vez con triominós en L."""
if T[hueco] != 0 or (T == 0).sum() != 1:
return False
k = T.max()
if not np.all(np.bincount(T.ravel(), minlength=k + 1)[1:] == 3): # 3 casillas por pieza
return False
f, c = np.indices(T.shape)
p, f, c = T.ravel(), f.ravel(), c.ravel()
fmin = np.full(k + 1, T.shape[0]); fmax = np.full(k + 1, -1)
cmin = fmin.copy(); cmax = fmax.copy()
np.minimum.at(fmin, p, f); np.maximum.at(fmax, p, f)
np.minimum.at(cmin, p, c); np.maximum.at(cmax, p, c)
# cada pieza cabe en un bloque 2x2: sus filas y sus columnas abarcan exactamente 2 valores
return bool(np.all(fmax[1:] - fmin[1:] == 1) and np.all(cmax[1:] - cmin[1:] == 1))
T = teselar(3, (1, 5))
print(T)
print("piezas:", T.max(), " (4^3 - 1)/3 =", (4**3 - 1) // 3)
# todos los huecos posibles hasta 16x16
for n in range(0, 5):
lado = 2 ** n
assert all(es_teselado(teselar(n, (f, c)), (f, c)) for f in range(lado) for c in range(lado))
donde = "su única casilla" if lado == 1 else f"cualquiera de sus {lado * lado} casillas"
print(f"n = {n}: tablero {lado}x{lado}, hueco en {donde}: teselado válido")
# huecos aleatorios en tableros mayores, hasta 128x128
rng = np.random.default_rng(0)
for n in (5, 6, 7):
lado = 2 ** n
for _ in range(3):
h = tuple(int(v) for v in rng.integers(0, lado, size=2))
assert es_teselado(teselar(n, h), h)
print(f"n = {n}: {lado}x{lado}, {(4**n - 1) // 3} triominós, 3 huecos aleatorios correctos")The board matrix with the hole in row 1 and column 5 (counting from 0, as in the code) is the same construction as the figure: piece 1 is the central tromino, and pieces appear in depth-first order. The 341 exhaustive checks and those for large boards do not prove anything we did not already know; they catch translation errors between proof and code, where people make mistakes.
The lesson’s other two constructive proofs, written similarly. Strong induction appears in the recursive call not necessarily being on .
def factorizar(n):
"""Todo n >= 2 es producto de primos: la demostración por inducción fuerte, ejecutable."""
assert n >= 2
for d in range(2, int(n ** 0.5) + 1):
if n % d == 0: # n = d * (n // d) con 2 <= d, n // d < n
return factorizar(d) + factorizar(n // d) # hipótesis de inducción en dos valores menores
return [n] # sin divisores propios: n es primo
BASE = {18: [4, 7, 7], 19: [4, 4, 4, 7], 20: [4, 4, 4, 4, 4], 21: [7, 7, 7]}
def sellos(n):
"""Paga n >= 18 con sellos de 4 y 7, siguiendo la demostración por inducción fuerte."""
if n in BASE:
return BASE[n] # los cuatro casos base
assert n >= 22, "solo está demostrado para n >= 18"
return sellos(n - 4) + [4] # paso: P(n - 4) implica P(n)
def sellos_iterativo(n):
"""La misma prueba, desenrollada: la hipótesis de inducción se convierte en invariante."""
assert n >= 18, "solo está demostrado para n >= 18"
k = 0
while n not in BASE: # invariante: n_original = n + 4k y n >= 18
n, k = n - 4, k + 1
return BASE[n] + [4] * k
for n in (360, 1001, 2**10, 9973, 600851475143):
print(n, "=", " * ".join(map(str, factorizar(n))))
for n in (18, 25, 37, 100):
s = sellos(n)
assert sum(s) == n and s.count(4) * 4 + s.count(7) * 7 == n
print(f"{n} = {s.count(4)}*4 + {s.count(7)}*7")
print("100000 en iterativo:", sum(sellos_iterativo(100000)) == 100000)
def pagable(n, a, b):
return any((n - b * y) % a == 0 for y in range(n // b + 1))
for a, b in [(4, 7), (3, 5), (5, 8), (6, 11), (9, 13)]:
F = max(n for n in range(500) if not pagable(n, a, b))
print(f"sellos {a} y {b}: mayor imposible = {F}, ab - a - b = {a * b - a - b}")sellos(100000) would fail in Python due to recursion depth (around 25,000 calls against the default limit of 1000). The iterative version has no such problem and illustrates a general point: linear recursion like this, with one call and work that can be accumulated (here, the counter of 4-cent stamps), is a loop, and the induction hypothesis justifying the call becomes the invariant justifying each iteration. Brute-force checking of Sylvester’s formula, , agrees for all five pairs.
Checking inductive steps with sympy
For an identity of the form , the inductive step is mechanical: assuming the sum through is , the sum through is , and the step closes if and only if is identically zero. A computer algebra system checks it without sign errors.
import sympy as sp
n, c, a = sp.symbols("n c a", positive=True)
def comprobar_identidad(F, termino, n0=1):
"""¿Prueba la inducción que sum_{k=n0}^{n} termino(k) = F(n)? Devuelve (base, residuo del paso)."""
base = sp.cancel(F.subs(n, n0) - termino.subs(n, n0))
# paso: suponiendo F(n) = suma hasta n, la suma hasta n + 1 es F(n) + termino(n + 1)
residuo = sp.cancel(F + termino.subs(n, n + 1) - F.subs(n, n + 1))
return base, residuo
casos = {
"1 + 3 + ... + (2n - 1) = n^2": (n**2, 2 * n - 1),
"1 + 2 + ... + n = n(n + 1)/2": (n * (n + 1) / 2, n),
"1^3 + ... + n^3 = (n(n + 1)/2)^2": ((n * (n + 1) / 2) ** 2, n**3),
"1^2 + ... + n^2 = n^3/3 (falsa)": (n**3 / 3, n**2),
}
for nombre, (F, t) in casos.items():
base, residuo = comprobar_identidad(F, t)
print(f"{nombre:36s} base: {base} residuo del paso: {sp.factor(residuo)}")The three true identities give base 0 and residue 0. The false one, , fails on both fronts, and its residue also says how far the step is wrong: the correct formula is with , and the residue is exactly the increment of what is missing.
For inequalities the calculation is the same, but we examine a sign. With hypothesis , the step closes using only the hypothesis if and only if the margin is for every in range.
def margen(B):
return sp.factor(sp.cancel(B.subs(n, n + 1) - B - 1 / (n + 1) ** 2))
print("B(n) = 2: margen =", margen(sp.Integer(2)))
print("B(n) = 2 - c/n: margen =", margen(2 - c / n))
print("B(n) = 2 - 1/n: margen =", margen(2 - 1 / n))
print("B(n) = a - 1/(n + 1/2): margen =", margen(a - 1 / (n + sp.Rational(1, 2))))
m09 = margen(2 - sp.Rational(9, 10) / n)
print("\nc = 9/10: margen =", m09)
print("primer n con margen < 0:", next(k for k in range(1, 100) if m09.subs(n, k) < 0))The original bound gives an always negative margin, ; the family gives , which is for every precisely when ; and the bound with leaves a positive margin of order . With the step survives until and fails at : the lab’s red bars.
Finally, turn well-ordering into search: if a statement about naturals is false, it has a least counterexample, and traversing finds it (if within reach). This is the right tool to refute, and the wrong one to prove.
def menor_contraejemplo(P, desde=0, hasta=10**6):
"""El principio del buen orden convertido en búsqueda: el menor n del rango con P(n) falso."""
return next((k for k in range(desde, hasta) if not P(k)), None)
def es_primo(m):
return m >= 2 and all(m % d for d in range(2, int(m ** 0.5) + 1))
k = menor_contraejemplo(lambda k: es_primo(k * k + k + 41))
print("n^2 + n + 41 es primo para n <", k, " y en n =", k, "vale", k * k + k + 41, "= 41 * 41")
print("2^n > n^2 falla en:", [k for k in range(30) if not 2 ** k > k * k])
S = 0.0
print("\nmenor a con la que S(n) <= a - 1/(n + 1/2) se demuestra desde n0:")
for n0 in range(1, 7):
S += 1 / n0**2
print(f" n0 = {n0}: a = S(n0) + 1/(n0 + 1/2) = {S + 1 / (n0 + 0.5):.6f}")
print("pi^2/6 =", round(3.141592653589793**2 / 6, 6))The final table is the lab’s: with base we need , and each delay brings the bound closer to , below which no bound in this family can go, since and .
The library version
| Tool | What it does | When to use it |
|---|---|---|
sympy.summation(t, (k, 1, n)) | closed symbolic sum | find the you then prove by induction |
sympy.factorint(n) | prime factorization | what factorizar does, with fast algorithms (including Pollard rho) |
functools.cache | memoizes a recursive function | strong-induction recursions with repeated subproblems |
Lean 4 (tactic induction) | checks the whole proof | when you need mechanical certainty, not just the step |
import sympy as sp
k, n = sp.symbols("k n", integer=True, positive=True)
for t in (k, k**2, k**3, 2 * k - 1, 1 / (k * (k + 1))):
print(f"sum_(k=1)^n {str(t):12s} = {sp.factor(sp.summation(t, (k, 1, n)))}")
print("sum 1/k^2 hasta infinito =", sp.summation(1 / k**2, (k, 1, sp.oo)))
print("factorint(600851475143) =", sp.factorint(600851475143))summation finds the formula; induction certifies it. Notice : this is the telescoping sum behind the strengthened bound, because .
In a proof assistant induction is a tactic, and the system checks that base and step have been proved (see proof assistants). This is Maurolico’s example in Lean 4 with Mathlib:
import Mathlib
theorem suma_impares (n : ℕ) : ∑ i ∈ Finset.range n, (2 * i + 1) = n ^ 2 := by
induction n with
| zero => simp -- caso base: la suma vacía es 0 = 0^2
| succ n ih => -- ih : ∑ i ∈ range n, (2i + 1) = n^2
rw [Finset.sum_range_succ, ih] -- separa el último término y usa la hipótesis
ring -- n^2 + (2n + 1) = (n + 1)^2
The three lines of the step are the three lines of the paper proof. And if the statement is not inductive, Lean leaves you stuck at the same point: you must strengthen it before calling induction.
Exercises
Step 1 of 3. How do you check the base case?
Step 1 of 4. Which induction do you use for existence?
Step 1 of 3. First: why not prove directly by induction?
More than one answer may be correct.
tile(n, hueco), returning an integer matrix of with 0 at hueco = (fila, columna) and, elsewhere, the identifier (1, 2, 3...) of the tromino covering it, following the induction proof. Also implement verificar(T, hueco), returning True if and only if the hole is the only square with 0 and every identifier appears in exactly three squares forming an L (three squares in one block). Your verificar must reject incorrect boards.import numpy as np
def tile(n, hueco):
lado = 2 ** n
T = np.zeros((lado, lado), dtype=int)
# tu código: divide en cuadrantes, coloca el triominó central y resuelve los cuatro cuadrantes
return T
def verificar(T, hueco):
# tu código: el hueco es la única casilla a 0 y cada pieza son 3 casillas en un bloque 2x2
return FalseSummary
- Weak induction: and give . The step is a universal proved assuming for arbitrary , and the base must be where the step already works.
- Strong induction: the step assumes all earlier cases. If it uses , base cases are needed, like the four for 4- and 7-cent stamps.
- Well-ordering: every nonempty subset of has a minimum. Equivalent to both inductions, it gives the minimal-counterexample method, natural when the argument descends to a smaller case.
- Strengthening the hypothesis: is true but not inductive; is, because it carries the margin needed by the step. Find it by treating the step as a budget, .
- Induction and recursion: a constructive inductive proof is a recursive algorithm (tromino tiling, factorization, stamps), and its correctness is the proof itself; unrolled, the induction hypothesis becomes an invariant.
- Typical errors: steps valid only from a certain (horses), missing or ill-fitting base cases, inducting on the wrong variable or fixing the other, and assuming what one wants to prove.