Analysis I, Section 2.3: Multiplication #
This file is a translation of Section 2.3 of Analysis I to Lean 4. All numbering refers to the original text.
I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.
Main constructions and results of this section:
- Definition of multiplication and exponentiation for the "Chapter 2" natural numbers,
Chapter2.Nat.
Note: at the end of this chapter, the Chapter2.Nat class will be deprecated in favor of the
standard Mathlib class _root_.Nat, or ℕ. However, we will develop the properties of
Chapter2.Nat "by hand" for pedagogical purposes.
Tips from past users #
Users of the companion who have completed the exercises in this section are welcome to send their tips for future users in this section as PRs.
- (Add tip here)
Definition 2.3.1 (Multiplication of natural numbers)
Equations
- n.mul m = Chapter2.Nat.recurse (fun (x prod : Chapter2.Nat) => prod + m) 0 n
Instances For
This instance allows for the * notation to be used for natural number multiplication.
Equations
- Chapter2.Nat.instMul = { mul := Chapter2.Nat.mul }
Definition 2.3.1 (Multiplication of natural numbers)
Compare with Mathlib's Nat.zero_mul
Definition 2.3.1 (Multiplication of natural numbers)
Compare with Mathlib's Nat.succ_mul
This lemma will be useful to prove Lemma 2.3.2.
Compare with Mathlib's Nat.mul_zero
This lemma will be useful to prove Lemma 2.3.2.
Compare with Mathlib's Nat.mul_succ
Lemma 2.3.2 (Multiplication is commutative) / Exercise 2.3.1
Compare with Mathlib's Nat.mul_comm
This lemma will be useful to prove Lemma 2.3.3.
Compare with Mathlib's Nat.mul_pos
Lemma 2.3.3 (Positive natural numbers have no zero divisors) / Exercise 2.3.2.
Compare with Mathlib's Nat.mul_eq_zero.
Proposition 2.3.4 (Distributive law)
Compare with Mathlib's Nat.mul_add
Proposition 2.3.4 (Distributive law)
Compare with Mathlib's Nat.add_mul
Proposition 2.3.5 (Multiplication is associative) / Exercise 2.3.3
Compare with Mathlib's Nat.mul_assoc
(Not from textbook) Nat is a commutative semiring.
This allows tactics such as ring to apply to the Chapter 2 natural numbers.
Equations
- One or more equations did not get rendered due to their size.
Proposition 2.3.6 (Multiplication preserves order)
Compare with Mathlib's Nat.mul_lt_mul_of_pos_right
Proposition 2.3.6 (Multiplication preserves order)
Compare with Mathlib's Nat.mul_lt_mul_of_pos_left
Corollary 2.3.7 (Cancellation law)
Compare with Mathlib's Nat.mul_right_cancel
(Not from textbook) Nat is an ordered semiring.
This allows tactics such as gcongr to apply to the Chapter 2 natural numbers.
Definition 2.3.11 (Exponentiation for natural numbers)
Equations
- m.pow n = Chapter2.Nat.recurse (fun (x prod : Chapter2.Nat) => prod * m) 1 n
Instances For
Equations
- Chapter2.Nat.instPow = { pow := Chapter2.Nat.pow }
Definition 2.3.11 (Exponentiation for natural numbers)
Compare with Mathlib's Nat.pow_zero
Definition 2.3.11 (Exponentiation for natural numbers)
Definition 2.3.11 (Exponentiation for natural numbers)
Compare with Mathlib's Nat.pow_succ