📘 Lecture 23 — Mathematical Induction
📖 Overview: This lecture introduces the Principle of Mathematical Induction, a fundamental proof technique used to verify propositions for all positive integers. It demonstrates the method through multiple examples and exercises, including formulas for sums of integers, series, and set theory laws, establishing why this technique is essential for proving infinite sequences of statements.
🗂️ Topics Covered
The lecture covers the definition and structure of mathematical induction with its basis and inductive steps, followed by detailed proofs of seven different propositions including sum of first n integers, sum of odd numbers, sum of powers of 2, sum of squares, sum of reciprocals of consecutive products, sigma notation with powers of 2, product of fractions, sum involving factorials, and DeMorgan's Law generalization.
📝 Lecture Summary
PRINCIPLE OF MATHEMATICAL INDUCTION
Let P(n) be a propositional function defined for all positive integers n. P(n) is true for every positive integer n if:
- Basis Step: The proposition P(1) is true.
- Inductive Step: If P(k) is true then P(k + 1) is true for all integers k ≥ 1. i.e. ∀k P(k) → P(k + 1)
🔑 Definition — Mathematical Induction: A proof technique consisting of two steps: proving the base case (usually n=1) and proving that if the statement holds for n=k, it also holds for n=k+1. 📌 Example: Proving 1 + 2 + 3 + ... + n = n(n+1)/2 for all n ≥ 1
- Basis: n=1: LHS=1, RHS=1(2)/2=1 ✓
- Inductive: Assume true for k: 1+2+...+k = k(k+1)/2
- Prove for k+1: 1+2+...+k+(k+1) = k(k+1)/2 + (k+1) = (k+1)(k+2)/2 ✓
EXAMPLE — Sum of Odd Numbers
Prove: 1 + 3 + 5 + ... + (2n - 1) = n² for all n ≥ 1
🔑 Key Identity: Sum of first n odd numbers = n² 📌 Example:
- Basis: n=1: LHS=1, RHS=1²=1 ✓
- Inductive: Assume 1+3+5+...+(2k-1)=k²
- Prove for k+1: 1+3+5+...+(2k-1)+(2k+1) = k² + (2k+1) = (k+1)² ✓
EXAMPLE — Sum of Powers of 2
Prove: 1 + 2 + 2² + ... + 2ⁿ = 2ⁿ⁺¹ - 1 for all n ≥ 0
🔑 Definition — Base case starting at n=0: Induction can start at any integer; here the basis step checks n=0. 📌 Example:
- Basis: n=0: LHS=1, RHS=2⁰⁺¹-1=2-1=1 ✓
- Inductive: Assume 1+2+2²+...+2ᵏ = 2ᵏ⁺¹-1
- Prove for k+1: (1+2+...+2ᵏ)+2ᵏ⁺¹ = (2ᵏ⁺¹-1)+2ᵏ⁺¹ = 2·2ᵏ⁺¹-1 = 2ᵏ⁺²-1 ✓
EXAMPLE — Sum of Squares
Prove: 1² + 2² + 3² + ... + n² = n(n+1)(2n+1)/6 for all n ≥ 1
📐 Formula: ∑ᵢ₌₁ⁿ i² = n(n+1)(2n+1)/6 📌 Example:
- Basis: n=1: LHS=1, RHS=1(2)(3)/6=6/6=1 ✓
- Inductive: Assume 1²+2²+...+k² = k(k+1)(2k+1)/6
- Prove for k+1: Add (k+1)² to both sides and factor to get (k+1)(k+2)(2k+3)/6 ✓
EXAMPLE — Sum of Reciprocals
Prove: 1/(1·2) + 1/(2·3) + ... + 1/[n(n+1)] = n/(n+1) for all n ≥ 1
📌 Example:
- Basis: n=1: LHS=1/(1·2)=1/2, RHS=1/(1+1)=1/2 ✓
- Inductive: Assume sum to k terms = k/(k+1)
- Prove: Add 1/[(k+1)(k+2)] and simplify to get (k+1)/(k+2) ✓
EXAMPLE — Summation with Powers
Prove: ∑ᵢ₌₁ⁿ⁺¹ i·2ⁱ = n·2ⁿ⁺² + 2 for all n ≥ 0
📐 Formula: ∑ᵢ₌₁ⁿ⁺¹ i·2ⁱ = n·2ⁿ⁺² + 2 📌 Example:
- Basis: n=0: ∑ᵢ₌₁¹ i·2ⁱ = 1·2¹=2, RHS=0·2²+2=2 ✓
- Inductive: Assume for k, then add (k+2)·2ᵏ⁺² and factor to prove for k+1 ✓
EXAMPLE — Product of Fractions
Prove: (1-1/2²)(1-1/3²)...(1-1/n²) = (n+1)/(2n) for all n ≥ 2
📌 Example:
- Basis: n=2: LHS=1-1/4=3/4, RHS=(2+1)/(2·2)=3/4 ✓
- Inductive: Multiply assumed product by (1-1/(k+1)²) and simplify to get (k+2)/(2(k+1)) ✓
EXAMPLE — Sum with Factorials
Prove: ∑ᵢ₌₁ⁿ i(i!) = (n+1)! - 1 for all n ≥ 1
🔑 Key Factorial Property: (k+2)(k+1)! = (k+2)! 📌 Example:
- Basis: n=1: LHS=1·1!=1, RHS=2!-1=2-1=1 ✓
- Inductive: Assume ∑ᵢ₌₁ᵏ i(i!) = (k+1)!-1
- Prove: Add (k+1)(k+1)! and factor to get (k+2)(k+1)!-1 = (k+2)!-1 ✓
EXAMPLE — DeMorgan's Law Generalization
Prove: (∩ⱼ₌₁ⁿ Aⱼ)' = ∪ⱼ₌₁ⁿ Aⱼ' where A₁,...,Aₙ are subsets of U and n ≥ 2
🔑 Definition — Complement: A' represents the complement of set A (elements not in A). 📌 Example:
- Basis: n=2: Uses basic DeMorgan's Law (A₁ ∩ A₂)' = A₁' ∪ A₂' ✓
- Inductive: Assume true for k sets. For k+1 sets, write (∩ⱼ₌₁ᵏ⁺¹ Aⱼ)' = ((∩ⱼ₌₁ᵏ Aⱼ) ∩ Aₖ₊₁)' and apply basic DeMorgan's Law, then use inductive hypothesis to get ∪ⱼ₌₁ᵏ⁺¹ Aⱼ' ✓
⭐ Key Takeaways
The Principle of Mathematical Induction is a rigorous two-step proof method: first verify the base case (often n=1), then prove the inductive step showing that truth for P(k) implies truth for P(k+1). Mastering this technique requires practicing with various types of propositions including arithmetic series, factorial expressions, set theory identities, and sigma notation. The key algebraic skill is manipulating expressions from the inductive hypothesis to match the desired form for k+1. Always verify that the algebraic manipulation correctly demonstrates the equivalence between the assumed form and the target form.
🧠 Quick Revision Questions
- What are the two essential steps in a proof by mathematical induction?
- How would you prove 2 + 4 + 6 + ... + 2n = n(n+1) using induction?
- Why can mathematical induction start at n=0 instead of n=1?
- In the sum of squares proof, what algebraic manipulation converts k(k+1)(2k+1)/6 + (k+1)² into (k+1)(k+2)(2k+3)/6?
- How does the inductive hypothesis for DeMorgan's Law help prove the statement for k+1 sets?
📘 Lecture 24 — Mathematical Induction for Divisibility
📖 Overview: This lecture covers the application of mathematical induction to prove divisibility statements and inequalities, as well as properties of recursively defined sequences. It demonstrates the structured two-step proof process—basis step and inductive step—essential for establishing truths about all positive integers.
🗂️ Topics Covered
The lecture covers mathematical induction for divisibility problems, including proofs that n³−n is divisible by 3 and 6, that 2²ⁿ−1 is divisible by 3, that the product of two consecutive integers is divisible by 2, and that xⁿ−yⁿ is divisible by x−y. It also covers proving inequalities like 2n+1 < 2ⁿ and 1+nx ≤ (1+x)ⁿ, and proving properties of recursively defined sequences.
📝 Lecture Summary
MATHEMATICAL INDUCTION FOR DIVISIBILITY PROBLEMS INEQUALITY PROBLEMS
DIVISIBILITY:
Let n and d be integers and d ≠ 0. Then n is divisible by d or d divides n, written d | n, iff n = d·k for some integer k.
Alternatively, we say that: n is a multiple of d, d is a divisor of n, d is a factor of n.
Thus d|n ⇔ ∃ an integer k such that n = d·k
🔑 Definition — Divisibility: An integer n is divisible by an integer d (d ≠ 0) if there exists an integer k such that n = d·k.
EXERCISE: Use mathematical induction to prove that n³ - n is divisible by 3 whenever n is a positive integer.
SOLUTION:
1. Basis Step: For n = 1, n³ - n = 1³ - 1 = 1 - 1 = 0. Since 0 = 0·3, it is divisible by 3. Therefore, the statement is true for n = 1.
2. Inductive Step: Suppose the statement is true for n = k, i.e., k³ - k is divisible by 3 for all n ∈ Z⁺. Then k³ - k = 3·q for some q ∈ Z. We need to prove that (k+1)³ - (k+1) is divisible by 3. Now (k+1)³ - (k+1) = (k³ + 3k² + 3k + 1) - (k + 1) = k³ + 3k² + 2k = (k³ - k) + 3k² + 2k + k = (k³ - k) + 3k² + 3k = 3·q + 3·(k² + k) = 3[q + k² + k]. ⇒ (k+1)³ - (k+1) is divisible by 3. Hence, by mathematical induction, n³ - n is divisible by 3 whenever n is a positive integer.
📐 Formula for inductive step manipulation: (k+1)³ - (k+1) = (k³ - k) + 3k(k+1)
EXAMPLE: Use mathematical induction to prove that for all integers n ≥ 1, 2²ⁿ - 1 is divisible by 3.
SOLUTION: Let P(n): 2²ⁿ - 1 is divisible by 3.
1. Basis Step: P(1) is true. Now P(1): 2²⁽¹⁾ - 1 = 4 - 1 = 3, which is divisible by 3. Hence P(1) is true.
2. Inductive Step: Suppose P(k) is true, i.e., 2²ᵏ - 1 is divisible by 3. Then ∃ integer q such that 2²ᵏ - 1 = 3·q. To prove P(k+1) is true, i.e., 2²⁽ᵏ⁺¹⁾ - 1 is divisible by 3. Now consider 2²⁽ᵏ⁺¹⁾ - 1 = 2²ᵏ⁺² - 1 = 2²ᵏ·2² - 1 = 2²ᵏ·4 - 1 = 2²ᵏ(3+1) - 1 = 2²ᵏ·3 + (2²ᵏ - 1) = 2²ᵏ·3 + 3·q = 3(2²ᵏ + q). ⇒ 2²⁽ᵏ⁺¹⁾ - 1 is divisible by 3. Accordingly, by mathematical induction, 2²ⁿ - 1 is divisible by 3 for all integers n ≥ 1.
📐 Key manipulation: 4 = 3 + 1, allowing expression in terms of the inductive hypothesis.
EXERCISE: Use mathematical induction to show that the product of any two consecutive positive integers is divisible by 2.
SOLUTION: Let n and n + 1 be two consecutive integers. We need to prove that n(n+1) is divisible by 2.
1. Basis Step: For n = 1, n(n+1) = 1·(1+1) = 1·2 = 2, which is divisible by 2.
2. Inductive Step: Suppose the statement is true for n = k, i.e., k(k+1) is divisible by 2, for some k ∈ Z⁺. Then k(k+1) = 2·q, q ∈ Z⁺. We must show that (k+1)(k+2) is divisible by 2. Consider (k+1)(k+2) = (k+1)k + (k+1)2 = 2q + 2(k+1) = 2(q + k + 1). Hence (k+1)(k+2) is divisible by 2. Accordingly, by mathematical induction, the product of any two consecutive positive integers is divisible by 2.
📌 Example: For n = 3, product = 3·4 = 12 = 2·6, divisible by 2.
EXERCISE: Prove by mathematical induction n³ - n is divisible by 6, for each integer n ≥ 2.
SOLUTION:
1. Basis Step: For n = 2, n³ - n = 2³ - 2 = 8 - 2 = 6 = 1·6, which is divisible by 6. Therefore, the statement is true for n = 2.
2. Inductive Step: Suppose the statement is true for n = k, i.e., k³ - k is divisible by 6, for all integers k ≥ 2. Then k³ - k = 6·q for some q ∈ Z. We need to prove that (k+1)³ - (k+1) is divisible by 6. Now (k+1)³ - (k+1) = (k³ + 3k³ + 3k + 1) - (k+1) = k³ + 3k³ + 2k = (k³ - k) + (3k³ + 2k + k) = (k³ - k) + 3k³ + 3k = 6·q + 3k(k+1).
Since k is an integer, k(k+1) is the product of two consecutive integers and is therefore even. Let k(k+1) = 2r, r ∈ Z.
Now equation becomes: (k+1)³ - (k+1) = 6·q + 3·2r = 6q + 6r = 6(q + r), q, r ∈ Z. ⇒ (k+1)³ - (k+1) is divisible by 6. Hence, by mathematical induction, n³ - n is divisible by 6 for each integer n ≥ 2.
🔑 Key insight: The proof uses the previously proven result that the product of two consecutive integers is divisible by 2.
EXERCISE: Prove by mathematical induction. For any integer n ≥ 1, xⁿ - yⁿ is divisible by x - y, where x and y are any two integers with x ≠ y.
SOLUTION:
1. Basis Step: For n = 1, xⁿ - yⁿ = x¹ - y¹ = x - y, which is divisible by x - y. So, the statement is true for n = 1.
2. Inductive Step: Suppose the statement is true for n = k, i.e., xᵏ - yᵏ is divisible by x - y. We need to prove that xᵏ⁺¹ - yᵏ⁺¹ is divisible by x - y. Now xᵏ⁺¹ - yᵏ⁺¹ = xᵏ·x - yᵏ·y = xᵏ·x - x·yᵏ + x·yᵏ - yᵏ·y (introducing x·yᵏ) = (xᵏ - yᵏ)·x + yᵏ·(x - y). The first term (xᵏ - yᵏ) is divisible by x - y by inductive hypothesis. The second term contains a factor (x - y), so it is also divisible by x - y. Thus xᵏ⁺¹ - yᵏ⁺¹ is divisible by x - y. Hence, by mathematical induction, xⁿ - yⁿ is divisible by x - y for any integer n ≥ 1.
📐 Formula: xᵏ⁺¹ - yᵏ⁺¹ = (xᵏ - yᵏ)·x + yᵏ·(x - y)
💡 Why this matters: This is a fundamental algebraic identity used in factoring differences of powers.
PROVING AN INEQUALITY: Use mathematical induction to prove that for all integers n ≥ 3, 2n + 1 < 2ⁿ
SOLUTION:
1. Basis Step: For n = 3, L.H.S = 2(3) + 1 = 6 + 1 = 7. R.H.S = 2³ = 8. Since 7 < 8, the statement is true for n = 3.
2. Inductive Step: Suppose the statement is true for n = k, i.e., 2k + 1 < 2ᵏ, k ≥ 3. We need to show it's true for n = k+1: 2(k+1) + 1 < 2ᵏ⁺¹. Consider L.H.S = 2(k+1) + 1 = 2k + 2 + 1 = (2k + 1) + 2 < 2ᵏ + 2 (using (1)). Since 2 < 2ᵏ for k ≥ 3, we have 2ᵏ + 2 < 2ᵏ + 2ᵏ = 2·2ᵏ = 2ᵏ⁺¹. Thus 2(k+1) + 1 < 2ᵏ⁺¹ (proved).
EXERCISE: Show by mathematical induction 1 + nx ≤ (1+x)ⁿ for all real numbers x > -1 and integers n ≥ 2
SOLUTION:
1. Basis Step: For n = 2, L.H.S = 1 + 2x. R.H.S = (1 + x)² = 1 + 2x + x² > 1 + 2x (since x² > 0). ⇒ Statement is true for n = 2.
2. Inductive Step: Suppose the statement is true for n = k, i.e., for k ≥ 2, 1 + kx ≤ (1+x)ᵏ. We want to show: 1 + (k+1)x ≤ (1+x)ᵏ⁺¹. Since x > -1, therefore 1 + x > 0. Multiplying both sides of the inductive hypothesis by (1+x) gives: (1+x)(1+x)ᵏ ≥ (1+x)(1+kx) = 1 + kx + x + kx² = 1 + (k+1)x + kx². Since x > -1, x² ≥ 0, and k ≥ 2 ⇒ kx² ≥ 0, we have (1+x)(1+x)ᵏ ≥ 1 + (k+1)x. Thus 1 + (k+1)x ≤ (1+x)ᵏ⁺¹. Hence, by mathematical induction, the inequality is true.
🔑 Definition — Bernoulli's Inequality: For all real numbers x > -1 and integers n ≥ 2, 1 + nx ≤ (1+x)ⁿ.
PROVING A PROPERTY OF A SEQUENCE: Define a sequence a₁, a₂, a₃, ... as follows: a₁ = 2, aₖ = 5aₖ₋₁ for all integers k ≥ 2. Use mathematical induction to show that the terms of the sequence satisfy the formula aₙ = 2·5ⁿ⁻¹ for all integers n ≥ 1.
SOLUTION:
1. Basis Step: For n = 1, the formula gives a₁ = 2·5¹⁻¹ = 2·5⁰ = 2·1 = 2, which confirms the definition of the sequence. Hence, the formula is true for n = 1.
2. Inductive Step: Suppose the formula is true for n = k, i.e., aₖ = 2·5ᵏ⁻¹ for some integer k ≥ 1. We show the statement is also true for n = k+1: aₖ₊₁ = 2·5ᵏ⁺¹⁻¹ = 2·5ᵏ. Now aₖ₊₁ = 5·aₖ₊₁₋₁ (by definition) = 5·aₖ = 5·(2·5ᵏ⁻¹) = 2·(5·5ᵏ⁻¹) = 2·5ᵏ⁺¹⁻¹ = 2·5ᵏ, which was required.
📌 Example: For a geometric sequence with a₁ = 2 and common ratio 5, a₃ = 2·5² = 50. Verification: a₁ = 2, a₂ = 5·2 = 10, a₃ = 5·10 = 50.
EXERCISE: A sequence d₁, d₂, d₃, ... is defined by letting d₁ = 2 and dₖ = dₖ₋₁/k for all integers k ≥ 2. Show that dₙ = 2/n! for all integers n ≥ 1, using mathematical induction.
SOLUTION:
1. Basis Step: For n = 1, the formula gives d₁ = 2/1! = 2/1 = 2, which agrees with the definition of the sequence.
2. Inductive Step: Suppose the formula is true for n = k, i.e., dₖ = 2/k! for some integer k ≥ 1. We must show that dₖ₊₁ = 2/(k+1)!. Now, by the definition of the sequence, dₖ₊₁ = d₍ₖ₊₁₎₋₁/(k+1) = dₖ/(k+1) = (2/k!)/(k+1) = 2/((k+1)k!) = 2/(k+1)!. Hence the formula is also true for n = k+1. Accordingly, the given formula defines all the terms of the sequence recursively.
📐 Formula: dₙ = 2/n! for all n ≥ 1
EXERCISE: Prove by mathematical induction that 1 + 1/4 + 1/9 + ⋯ + 1/n² < 2 - 1/n whenever n is a positive integer greater than 1.
SOLUTION:
1. Basis Step: For n = 2, L.H.S = 1 + 1/4 = 5/4 = 1.25. R.H.S = 2 - 1/2 = 3/2 = 1.5. Clearly LHS < RHS. Hence the statement is true for n = 2.
2. Inductive Step: Suppose the statement is true for some integer k > 1, i.e., 1 + 1/4 + 1/9 + ⋯ + 1/k² < 2 - 1/k. We need to show the statement is true for n = k+1: 1 + 1/4 + 1/9 + ⋯ + 1/(k+1)² < 2 - 1/(k+1).
Consider LHS for k+1 = (1 + 1/4 + ⋯ + 1/k²) + 1/(k+1)² < (2 - 1/k) + 1/(k+1)² = 2 - (1/k - 1/(k+1)²).
We need to prove: 2 - (1/k - 1/(k+1)²) ≤ 2 - 1/(k+1), or equivalently: 1/k - 1/(k+1)² ≥ 1/(k+1), or 1/k - 1/(k+1) ≥ 1/(k+1)².
Now 1/k - 1/(k+1) = (k+1 - k)/k(k+1) = 1/k(k+1) > 1/(k+1)², proving the inequality.
⭐ Key Takeaways
The core technique for proving divisibility by induction involves showing the base case is true, then assuming the statement holds for n=k to rewrite (k+1)³ - (k+1) in terms of k³-k plus additional multiples of the divisor. For inequalities, the inductive step often requires bounding expressions using the inductive hypothesis combined with simple inequalities like 2 < 2ᵏ for k≥3. For recursively defined sequences, the inductive proof confirms that the closed-form formula satisfies both the base condition and the recurrence relation, with the inductive hypothesis used to replace aₖ with its formulaic expression. A powerful technique for proving xⁿ-yⁿ is divisible by x-y involves introducing the term x·yᵏ to factor the expression into (xᵏ-yᵏ)·x + yᵏ·(x-y).
🧠 Quick Revision Questions
-
State the definition of divisibility and express "d divides n" symbolically.
-
Show the key algebraic manipulation used to prove n³-n is divisible by 3 using the inductive hypothesis.
-
In proving 2²ⁿ-1 is divisible by 3, explain why 2²ᵏ·4 can be rewritten as 2²ᵏ·3 + 2²ᵏ and why this is helpful.
-
How do you prove that the product of two consecutive integers is even, and why is this result needed in the proof that n³-n is divisible by 6?
-
Write the expression xᵏ⁺¹ - yᵏ⁺¹ in terms of (xᵏ - yᵏ) and (x - y), and explain why this proves divisibility by x - y.
📘 Lecture 25 — Methods of Proof
📖 Overview: This lecture introduces fundamental methods of proof used in mathematics and computer science. It focuses on direct proof and disproof by counterexample, explaining how to prove implications (p → q) by showing that if p is true, then q must also be true, and how to disprove false statements with a single counterexample.
🗂️ Topics Covered
The lecture covers the introduction to methods of proof, including direct proof, indirect proof (proof by contraposition and proof by contradiction). It defines basic mathematical concepts like even, odd, prime, composite, rational numbers, divisibility, and perfect squares. Several exercises demonstrate direct proof techniques for properties of integers, rational numbers, and divisibility. Finally, the lecture explains disproof by counterexample with multiple examples.
📝 Lecture Summary
METHODS OF PROOF
Many theorems in mathematics are implications, p → q. The techniques of proving implications give rise to different methods of proofs. A direct proof proves p → q by showing that if p is true, then q must also be true, showing that the combination p true and q false never occurs. Other methods include proof by contraposition (p → q ≡ ~q → ~p) and proof by contradiction (p → q ≡ (p ∧ ~q) → c).
SOME BASICS:
- An integer n is even if, and only if, n = 2k for some integer k.
- An integer n is odd if, and only if, n = 2k + 1 for some integer k.
- An integer n is prime if, and only if, n > 1 and for all positive integers r and s, if n = r·s, then r = 1 or s = 1.
- An integer n > 1 is composite if, and only if, n = r·s for some positive integers r and s with r ≠ 1 and s ≠ 1.
- A real number r is rational if, and only if, r = a/b for some integers a and b with b ≠ 0.
- If n and d are integers and d ≠ 0, then d divides n, written d | n if, and only if, n = d·k for some integers k.
- An integer n is called a perfect square if, and only if, n = k² for some integer k.
EXERCISE: Prove that the sum of two odd integers is even.
🔑 Definition — odd integer: an integer that can be written as 2k + 1 for some integer k. Proof: Let m and n be two odd integers. Then m = 2k + 1 for some k ∈ Z and n = 2l + 1 for some l ∈ Z. Now m + n = (2k + 1) + (2l + 1) = 2k + 2l + 2 = 2(k + l + 1) = 2r where r = (k + l + 1) ∈ Z. Hence m + n is even.
EXERCISE: Prove that if n is any even integer, then (-1)ⁿ = 1
Proof: Suppose n is an even integer. Then n = 2k for some integer k. Now (-1)ⁿ = (-1)²ᵏ = [(-1)²]ᵏ = (1)ᵏ = 1 (proved).
EXERCISE: Prove that the product of an even integer and an odd integer is even.
Proof: Suppose m is an even integer and n is an odd integer. Then m = 2k for some integer k and n = 2l + 1 for some integer l. Now m·n = 2k·(2l + 1) = 2·k(2l + 1) = 2·r where r = k(2l + 1) is an integer. Hence m·n is even.
EXERCISE: Prove that the square of an even integer is even.
Proof: Suppose n is an even integer. Then n = 2k. Now square of n = n² = (2·k)² = 4k² = 2·(2k²) = 2·p where p = 2k² ∈ Z. Hence, n² is even.
EXERCISE: Prove that if n is an odd integer, then n³ + n is even.
Proof: Let n be an odd integer, then n = 2k + 1 for some k ∈ Z. Now n³ + n = n(n² + 1) = (2k + 1)((2k+1)² + 1) = (2k + 1)(4k² + 4k + 1 + 1) = (2k + 1)(4k² + 4k + 2) = (2k + 1)·2·(2k² + 2k + 1) = 2·(2k + 1)(2k² + 2k + 1) = an even integer.
EXERCISE: Prove that, if the sum of any two integers is even, then so is their difference.
Proof: Suppose m and n are integers so that m + n is even. Then m + n = 2k for some integer k ⇒ m = 2k - n. Now m - n = (2k - n) - n = 2k - 2n = 2(k - n) = 2r where r = k - n is an integer. Hence m - n is even.
EXERCISE: Prove that the sum of any two rational numbers is rational.
🔑 Definition — rational number: a real number that can be expressed as a/b for some integers a and b with b ≠ 0. Proof: Suppose r and s are rational numbers. Then r = a/b and s = c/d for some integers a, b, c, d with b ≠ 0 and d ≠ 0. Now r + s = a/b + c/d = (ad + bc)/bd = p/q. Hence r + s is rational, where p = ad + bc ∈ Z and q = bd ∈ Z and q ≠ 0.
EXERCISE: Given any two distinct rational numbers r and s with r < s. Prove that there is a rational number x such that r < x < s.
Proof: Given two distinct rational numbers r and s such that r < s. Adding r to both sides: 2r < r + s ⇒ r < (r + s)/2. Adding s to both sides: r + s < 2s ⇒ (r + s)/2 < s. Combining: r < (r + s)/2 < s. Since the sum of two rationals is rational, r + s is rational. Also the quotient of a rational by a non-zero rational is rational, therefore (r + s)/2 is rational. Hence, we have found a rational number x = (r + s)/2 such that r < x < s.
EXERCISE: Prove that for all integers a, b and c, if a|b and b|c then a|c.
🔑 Definition — divisibility: For integers n and d with d ≠ 0, d divides n (d | n) if n = d·k for some integer k. Proof: Suppose a|b and b|c where a, b, c ∈ Z. Then b = a·r and c = b·s for some integers r and s. Now c = b·s = (a·r)·s = a·(r·s) = a·k where k = r·s ∈ Z, so a | c by definition of divisibility.
EXERCISE: Prove that for all integers a, b and c if a|b and a|c then a|(b+c)
Proof: Suppose a|b and a|c where a, b, c ∈ Z. By definition of divides, b = a·r and c = a·s for some r, s ∈ Z. Now b + c = a·r + a·s = a·(r+s) = a·k where k = (r + s) ∈ Z. Hence a|(b + c) by definition of divides.
EXERCISE: Prove that the sum of any three consecutive integers is divisible by 3.
Proof: Let n, n + 1 and n + 2 be three consecutive integers. Now n + (n + 1) + (n + 2) = 3n + 3 = 3(n + 1) = 3·k where k = (n+1) ∈ Z. Hence, the sum of three consecutive integers is divisible by 3.
EXERCISE: Prove the statement: There is an integer n > 5 such that 2ⁿ - 1 is prime
Proof: Let n = 7, then 2ⁿ - 1 = 2⁷ - 1 = 128 - 1 = 127, and we know that 127 is prime.
EXERCISE: Prove the statement: There are real numbers a and b such that √(a+b) = √a + √b
Proof: Squaring both sides gives a + b = a + b + 2√(ab) ⇒ 0 = 2√(ab) ⇒ 0 = √(ab) ⇒ 0 = ab ⇒ either a = 0 or b = 0. Hence if we let a = 0 and b = 3, then R.H.S = √0 + √3 = √3 and L.H.S = √(0+3) = √3. The given condition is satisfied.
PROOF BY COUNTER EXAMPLE:
Disproof by counterexample is used to show a universal statement is false by finding a single instance where it fails. Example: Disprove: For all real numbers a and b, if a < b then a² < b². Counterexample: Suppose a = -5 and b = -2. Clearly -5 < -2, but a² = 25 and b² = 4, and 25 > 4. This disproves the statement.
EXERCISE: Prove or give counter example to disprove: For all integers n, n² - n + 11 is a prime number.
Disproof: The statement is not true. For n = 11, n² - n + 11 = (11)² - 11 + 11 = (11)² = 121, which is obviously not a prime number.
EXERCISE: Prove or disprove that the product of any two irrational numbers is an irrational number.
Disproof: We know that √2 is an irrational number. Now √2·√2 = (√2)² = 2 = 2/1, which is a rational number. Hence the statement is disproved.
EXERCISE: Find a counter example to the proposition: For every prime number n, n + 2 is prime.
Disproof: Let the prime number n be 7, then n + 2 = 7 + 2 = 9, which is not prime.
⭐ Key Takeaways
The most critical concepts from this lecture are: understanding the definition and use of direct proof for proving implications p → q by assuming p is true and showing q must follow. You must memorize the definitions of even, odd, prime, composite, rational numbers, and divisibility as they form the foundation for constructing proofs. The technique of disproof by counterexample requires finding just one instance where a universal statement fails. Key proof patterns to remember include: even numbers expressed as 2k, odd numbers as 2k+1, and rational numbers as a/b. The transitivity property of divisibility (if a|b and b|c then a|c) and the addition property (if a|b and a|c then a|(b+c)) are essential results.
🧠 Quick Revision Questions
- What is the definition of an even integer? An odd integer?
- How do you prove the sum of two odd integers is even using direct proof?
- What is a counterexample to disprove the statement: "For all real numbers a and b, if a < b then a² < b²"?
- Prove that for all integers a, b, c: if a|b and b|c then a|c.
- Give a counterexample showing that the product of two irrational numbers is not always irrational.
📘 Lecture 26 — Proof by Contradiction
📖 Overview: This lecture introduces proof by contradiction (reductio ad absurdum), a powerful method where a statement is proven true by showing its negation leads to a logical impossibility. It also covers proof by contraposition, which leverages the logical equivalence between an implication and its contrapositive. These methods are fundamental for proving many theorems in mathematics, including results about integers, prime numbers, and irrational numbers.
🗂️ Topics Covered
The lecture begins by defining proof by contradiction and its logical basis in the negation of an implication (p ∧ ~q → c). It then works through numerous examples: proving there is no greatest integer, showing that if n² is even then n is even, and demonstrating that if n³+5 is odd then n is even. The method is also applied to prove that the sum of a rational and irrational number is irrational, that √2 and 6−7√2 are irrational, and that the set of prime numbers is infinite. The lecture concludes with an introduction to proof by contraposition, with examples including the parity of n² and 3n+2, and a conditional statement about divisibility by 5 and 25.
📝 Lecture Summary
PROOF BY CONTRADICTION
A proof by contradiction is based on the fact that either a statement is true or it is false but not both. Hence the supposition, that the statement to be proved is false, leads logically to a contradiction, impossibility or absurdity, then the supposition must be false. Accordingly, the given statement must be true. This method of proof is also known as reductio ad absurdum because it relies on reducing a given assumption to an absurdity.
Many theorems in mathematics are conditional statements (p→q). The negation of the implication p→q is: ~(p→q) ≡ ~(~p ∨ q) ≡ ~(~p) ∧ (~q) (DeMorgan’s Law) ≡ p ∧ ~q Clearly if the implication is true, then its negation must be false, i.e., leads to a contradiction. Hence ~(p→q) ≡ (p ∧ ~q) → c, where c is a contradiction.
Thus to prove an implication p → q by contradiction method, we suppose that the condition p and the negation of the conclusion q, i.e., (p ∧ ~q) is true and ultimately arrive at a contradiction.
The method of proof by contradiction may be summarized as follows:
- Suppose the statement to be proved is false.
- Show that this supposition leads logically to a contradiction.
- Conclude that the statement to be proved is true.
THEOREM: There is no greatest integer.
PROOF: Suppose there is a greatest integer N. Then n ≤ N for every integer n. Let M = N + 1. Now M is an integer since it is a sum of integers. Also M > N since M = N + 1. Thus M is an integer that is greater than the greatest integer, which is a contradiction. Hence our supposition is not true and so there is no greatest integer.
EXERCISE: “If n² is an even integer then n is an even integer.”
PROOF: Suppose n² is an even integer and n is not even, so that n is odd. Hence n = 2k + 1 for some integer k. Now n² = (2k + 1)² = 4k² + 4k + 1 = 2·(2k² + 2k) + 1 = 2r + 1 where r = (2k² + 2k) ∈ Z. This shows that n² is odd, which is a contradiction to our supposition that n² is even. Hence the given statement is true.
EXERCISE: Prove that if n is an integer and n³ + 5 is odd, then n is even.
SOLUTION: Suppose that n³ + 5 is odd and n is not even (odd). Since n is odd and the product of two odd numbers is odd, it follows that n² is odd and n³ = n²·n is odd. Further, since the difference of two odd numbers is even, it follows that 5 = (n³ + 5) − n³ is even. But this is a contradiction. Therefore, the supposition that n³ + 5 and n are both odd is wrong and so the given statement is true.
EXERCISE: If n and m are odd integers, then n + m is an even integer.
SOLUTION: Suppose n and m are odd and n + m is not even (odd i.e., by taking contradiction). Now n = 2p + 1 for some integer p and m = 2q + 1 for some integer q. Hence n + m = (2p + 1) + (2q + 1) = 2p + 2q + 2 = 2·(p + q + 1) which is even, contradicting the assumption that n + m is odd.
THEOREM: The sum of any rational number and any irrational number is irrational.
PROOF: We suppose that the negation of the statement is true. That is, we suppose that there is a rational number r and an irrational number s such that r + s is rational. By definition of rational, r = a/b and r + s = c/d for some integers a, b, c and d with b≠0 and d≠0. Using these, we get: a/b + s = c/d ⇒ s = c/d − a/b ⇒ s = (bc − ad)/(bd) (bd ≠ 0) Now bc−ad and bd are both integers, since products and difference of integers are integers. Hence s is a quotient of two integers bc−ad and bd with bd ≠ 0. So by definition of rational, s is rational. This contradicts the supposition that s is irrational. Hence the supposition is false and the theorem is true.
EXERCISE: Prove that √2 is irrational.
PROOF: Suppose √2 is rational. Then there are integers m and n with no common factors so that √2 = m/n. Squaring both sides gives 2 = m²/n², or m² = 2n². This implies that m² is even (by definition of even). It follows that m is even. Hence m = 2k for some integer k. Substituting this, we get (2k)² = 2n² ⇒ 4k² = 2n² ⇒ n² = 2k². This implies that n² is even, and so n is even. But we also know that m is even. Hence both m and n have a common factor 2. But this contradicts the supposition that m and n have no common factors. Hence our supposition is false and so the theorem is true.
EXERCISE: Prove that 6 − 7√2 is irrational.
PROOF: Suppose 6 − 7√2 is rational. Then by definition of rational, 6 − 7√2 = a/b for some integers a and b with b≠0. Now consider: 7√2 = 6 − a/b ⇒ 7√2 = (6b − a)/b ⇒ √2 = (6b − a)/(7b). Since a and b are integers, so are 6b−a and 7b and 7b≠0; hence √2 is a quotient of the two integers 6b−a and 7b with 7b≠0. Accordingly, √2 is rational. This contradicts the fact that √2 is irrational. Hence our supposition is false and so 6 − 7√2 is irrational.
EXERCISE: Prove that for any integer a and any prime number p, if p|a, then p ∤ (a + 1).
PROOF: Suppose there exists an integer a and a prime number p such that p|a and p|(a+1). Then by definition of divisibility there exist integers r and s so that a = p·r and a + 1 = p·s. It follows that: 1 = (a + 1) − a = p·s − p·r = p·(s−r) where s−r ∈ Z This implies p | 1. But the only integer divisors of 1 are 1 and −1 and since p is prime p>1. This is a contradiction. Hence the supposition is false, and the given statement is true.
EXERCISE: Prove that √2 + √3 is irrational.
SOLUTION: Suppose √2 + √3 is rational. Then there exists integers a and b with b≠0 such that √2 + √3 = a/b. Squaring both sides, we get: 2 + 3 + 2√6 = a²/b² ⇒ 2√6 = a²/b² − 5 ⇒ 2√6 = (a² − 5b²)/b² ⇒ √6 = (a² − 5b²)/(2b²) Since a and b are integers, so are a² − 5b² and 2b² with 2b²≠0. Hence √6 is the quotient of two integers a² − 5b² and 2b². Accordingly, √6 is rational. But this is a contradiction, since √6 is not rational. Hence our supposition is false and so √2 + √3 is irrational.
💡 Why this matters: The sum of two irrational numbers need not be irrational in general, for example (6 − 7√2) + (6 + 7√2) = 12 which is rational.
THEOREM: The set of prime numbers is infinite.
PROOF: Suppose the set of prime numbers is finite. Then all the prime numbers can be listed, say, in ascending order: p₁ = 2, p₂ = 3, p₃ = 5, p₄ = 7, ..., pₙ. Consider the integer N = p₁·p₂·p₃·...·pₙ + 1. Then N > 1. Since any integer greater than 1 is divisible by some prime number p, therefore p | N. Also since p is prime, p must equal one of the prime numbers p₁, p₂, p₃, ..., pₙ. Thus p | (p₁·p₂·p₃·...·pₙ). But then p ∤ (p₁·p₂·p₃·...·pₙ + 1). So p ∤ N. Thus p | N and p ∤ N, which is a contradiction. Hence the supposition is false and the theorem is true.
PROOF BY CONTRAPOSITION
A proof by contraposition is based on the logical equivalence between a statement and its contrapositive. Therefore, the implication p→q can be proved by showing that its contrapositive ~q → ~p is true. The contrapositive is usually proved directly.
The method of proof by contrapositive may be summarized as:
- Express the statement in the form if p then q.
- Rewrite this statement in the contrapositive form if not q then not p.
- Prove the contrapositive by a direct proof.
EXERCISE: Prove that for all integers n, if n² is even then n is even.
PROOF: The contrapositive of the given statement is: “if n is not even (odd) then n² is not even (odd).” We prove this contrapositive statement directly. Suppose n is odd. Then n = 2k + 1 for some k ∈ Z. Now n² = (2k+1)² = 4k² + 4k + 1 = 2·(2k² + 2k) + 1 = 2·r + 1 where r = 2k² + 2k ∈ Z. Hence n² is odd. Thus the contrapositive statement is true and so the given statement is true.
EXERCISE: Prove that if 3n + 2 is odd, then n is odd.
PROOF: The contrapositive of the given conditional statement is “if n is even then 3n + 2 is even.” Suppose n is even, then n = 2k for some k ∈ Z. Now 3n + 2 = 3(2k) + 2 = 2·(3k + 1) = 2·r where r = (3k + 1) ∈ Z. Hence 3n + 2 is even. We conclude that the given statement is true since its contrapositive is true.
EXERCISE: Prove that if n is an integer and n³ + 5 is odd, then n is even.
PROOF: Suppose n is an odd integer. Since a product of two odd integers is odd, therefore n² = n·n is odd; and n³ = n²·n is odd. Since a sum of two odd integers is even, therefore n³ + 5 is even. Thus we have proved that if n is odd then n³ + 5 is even. Since this is the contrapositive of the given conditional statement, the given statement is true.
EXERCISE: Prove that if n² is not divisible by 25, then n is not divisible by 5.
SOLUTION: The contrapositive statement is: “if n is divisible by 5, then n² is divisible by 25.” Suppose n is divisible by 5. Then by definition of divisibility, n = 5·k for some integer k. Squaring both sides: n² = 25·k² where k² ∈ Z. Therefore n² is divisible by 25.
EXERCISE: Prove that if |x| > 1 then x > 1 or x < -1 for all x ∈ R.
PROOF: The contrapositive statement is: if x ≤ 1 and x ≥ -1 then |x| ≤ 1 for x ∈ R. Suppose that x ≤ 1 and x ≥ -1 ⇒ x ≤ 1 and x ≥ -1 ⇒ -1 ≤ x ≤ 1 and so |x| ≤ 1.
EXERCISE: For all integers m and n, if m + n is even then m and n are both even or m and n are both odd.
PROOF: The contrapositive statement is: “For all integers m and n, if m and n are not both even and m and n are not both odd, then m + n is not even.” Or more simply, “For all integers m and n, if one of m and n is even and the other is odd, then m + n is odd.” Suppose m is even and n is odd. Then m = 2p for some integer p and n = 2q + 1 for some integer q. Now m + n = (2p) + (2q + 1) = 2·(p+q) + 1 = 2·r + 1 where r = p+q is an integer. Hence m + n is odd. Similarly, taking m as odd and n even, we again arrive at the result that m + n is odd. Thus, the contrapositive statement is true. Since an implication is logically equivalent to its contrapositive, the given implication is true.
⭐ Key Takeaways
The most critical concepts from this lecture are the logical structure of proof by contradiction—assuming the negation leads to a contradiction—and the logical equivalence between an implication and its contrapositive. Students must master the specific technique of assuming p ∧ ~q and deriving a contradiction to prove p→q, and the method of proving the contrapositive directly as an alternative strategy. The classic proofs—that √2 is irrational, that there is no greatest integer, that the set of primes is infinite, and that the sum of a rational and irrational is irrational—are essential templates that demonstrate how to set up and execute these methods. A common pitfall to avoid is confusing contrapositive with converse or inverse, and students must remember that proof by contradiction and contrapositive are distinct, equally valid approaches.
🧠 Quick Revision Questions
- What is the logical form of the negation of an implication p→q, and how is it used in a proof by contradiction?
- Write a complete proof by contradiction showing that √2 is irrational, explaining why m and n must have no common factors.
- State the contrapositive of the statement "If n² is even, then n is even" and prove it directly.
- Prove by contradiction that there is no greatest integer, explaining where the contradiction arises.
- Why does the proof that the set of primes is infinite require constructing the number N = p₁·p₂·...·pₙ + 1?
📘 Lecture 27 — Algorithm
📖 Overview: This lecture formally defines the concept of an algorithm and provides the complete specification structure used to describe algorithms. It introduces the Division Algorithm as a concrete example and explains how to prove algorithm correctness using pre-conditions, post-conditions, and the loop invariant theorem.
🗂️ Topics Covered
The lecture covers the formal definition of an algorithm and the standard information included when describing algorithms. It presents the Division Algorithm based on the Quotient-Remainder Theorem, demonstrates tracing the algorithm's execution, defines predicates and their domains, and explains pre-conditions and post-conditions. The lecture concludes with a detailed explanation of loop invariants and the Loop Invariant Theorem with its four required properties for proving loop correctness.
📝 Lecture Summary
ALGORITHM
The word "algorithm" refers to a step-by-step method for performing some action. A computer program is a set of instructions executed step-by-step for performing some specific task, but the term algorithm is more general since a program refers to a particular programming language.
INFORMATION ABOUT ALGORITHM
When describing algorithms formally, the following information is generally included:
- The name of the algorithm, together with a list of input and output variables.
- A brief description of how the algorithm works.
- The input variable names, labeled by data type.
- The statements that make the body of the algorithm, with explanatory comments.
- The output variable names, labeled by data type.
- An end statement.
THE DIVISION ALGORITHM
THEOREM (Quotient-Remainder Theorem): Given any integer n and a positive integer d, there exist unique integers q and r such that n = d · q + r and 0 ≤ r < d.
📌 Example:
- n = 54, d = 4: 54 = 4 · 13 + 2; hence q = 13, r = 2
- n = -54, d = 4: -54 = 4 · (-14) + 2; hence q = -14, r = 2
- n = 54, d = 70: 54 = 70 · 0 + 54; hence q = 0, r = 54
ALGORITHM (DIVISION): {Given a nonnegative integer a and a positive integer d, the aim of the algorithm is to find integers q and r that satisfy the conditions a = d · q + r and 0 ≤ r < d. This is done by subtracting d repeatedly from a until the result is less than d but is still nonnegative. The total number of d's that are subtracted is the quotient q. The quantity a - d · q equals the remainder r.}
Input: a {a nonnegative integer}, d {a positive integer} Algorithm body: r := a, q := 0 {Repeatedly subtract d from r until a number less than d is obtained. Add 1 to d each time d is subtracted.}
while (r ≥ d) r := r - d q := q + 1 end while
Output: q, r end Algorithm (Division)
TRACING THE DIVISION ALGORITHM
📌 Example: Trace the Division Algorithm on input variables a = 54 and d = 11.
| Variable | Iteration 0 | Iteration 1 | Iteration 2 | Iteration 3 | Iteration 4 |
|---|---|---|---|---|---|
| a | 54 | ||||
| d | 11 | ||||
| r | 54 | 43 | 32 | 21 | 10 |
| q | 0 | 1 | 2 | 3 | 4 |
The loop stops when r = 10, which is less than d = 11. The final values are q = 4 and r = 10. Since 54 = 11 · 4 + 10 and 0 ≤ 10 < 11, the result satisfies the theorem.
PREDICATE
A predicate is a sentence that contains a finite number of variables and becomes a statement when specific values are substituted for the variables. The domain of a predicate variable is the set of all values that may be substituted in place of the variable.
Consider the sentence "Aslam is a student at the Virtual University." Let P stand for "is a student at the Virtual University" and Q stand for "is a student at." The sentences "x is a student at the Virtual University" and "x is a student at y" are symbolized as P(x) and Q(x, y), where x and y are predicate variables that take values in appropriate sets.
PRE-CONDITIONS AND POST-CONDITIONS
The predicate describing the initial state is called the pre-condition of the algorithm and the predicate describing the final state is called the post-condition of the algorithm.
📌 Example 1: Algorithm to compute a product of two nonnegative integers
- Pre-condition: The input variables m and n are nonnegative integers.
- Post-condition: The output variable p equals m · n.
📌 Example 2: Algorithm to find the quotient and remainder of the division of one positive integer by another
- Pre-condition: The input variables a and b are positive integers.
- Post-condition: The output variables q and r are positive integers such that a = b · q + r and 0 ≤ r < b.
📌 Example 3: Algorithm to sort a one-dimensional array of real numbers
- Pre-condition: The input variable A[1], A[2], ..., A[n] is a one-dimensional array of real numbers.
- Post-condition: The output variable B[1], B[2], ..., B[n] is a one-dimensional array of real numbers with the same elements as A[1], A[2], ..., A[n] but with the property that B[i] ≤ B[j] whenever i ≤ j.
THE DIVISION ALGORITHM WITH PRE AND POST CONDITIONS: [pre-condition: a is a nonnegative integer and d is a positive integer, r = a, and q = 0] while (r ≥ d) 1. r := r - d 2. q := q + 1 end while [post-condition: q and r are nonnegative integers with the property that a = q · d + r and 0 ≤ r < d.]
LOOP INVARIANTS
Definition: A loop is defined as correct with respect to its pre- and post-conditions if, and only if, whenever the algorithm variables satisfy the pre-condition for the loop and the loop is executed, then the algorithm variables satisfy the post-condition of the loop.
The method of loop invariants is used to prove correctness of a loop with respect to certain pre and post-conditions. It is based on the principle of mathematical induction.
LOOP INVARIANT THEOREM
THEOREM: Let a while loop with guard G be given, together with pre- and post-conditions that are predicates in the algorithm variables. Also let a predicate I(n), called the loop invariant, be given. If the following four properties are true, then the loop is correct with respect to its pre- and post-conditions:
I. Basis Property: The pre-condition for the loop implies that I(0) is true before the first iteration of the loop.
II. Inductive Property: If the guard G and the loop invariant I(k) are both true for an integer k ≥ 0 before an iteration of the loop, then I(k + 1) is true after iteration of the loop.
III. Eventual Falsity of Guard: After a finite number of iterations of the loop, the guard becomes false.
IV. Correctness of the Post-Condition: If N is the least number of iterations after which G is false and I(N) is true, then the values of the algorithm variables will be as specified in the post-condition of the loop.
PROOF: Let I(n) be a predicate that satisfies properties I-IV of the loop invariant theorem. Properties I and II establish that for all integers n ≥ 0, if the while loop iterates n times, then I(n) is true. Property III indicates that the guard G becomes false after a finite number N of iterations. Property IV concludes that the values of the algorithm variables are as specified by the post-condition of the loop.
💡 Why this matters: The loop invariant theorem provides a rigorous mathematical framework for proving that algorithms work correctly before they are implemented. By establishing these four properties, programmers can verify that loops produce exactly the intended output for all valid inputs, eliminating the need for exhaustive testing.
⭐ Key Takeaways
The loop invariant theorem is the central tool for proving algorithm correctness and requires establishing four properties: the basis property (invariant holds before loop starts), the inductive property (if invariant and guard hold before an iteration, invariant holds after), eventual falsity of guard (loop terminates), and correctness of post-condition (when loop ends, the results match specifications). Pre-conditions describe what must be true before an algorithm runs, while post-conditions describe what must be true after it completes. The Division Algorithm demonstrates both the concept of tracing execution step-by-step and the application of pre/post conditions in a concrete setting.
🧠 Quick Revision Questions
- What is the Quotient-Remainder Theorem and what does it guarantee about the existence and uniqueness of q and r?
- What are the four properties that must be established by the Loop Invariant Theorem for a loop to be correct?
- In the Division Algorithm, what is the role of the variable q and how does its value change as the algorithm executes?
- What is the difference between an algorithm and a program?
- For the Division Algorithm's proof of correctness, what would be an appropriate loop invariant I(k)?