Analysis I, Section 4.2 #
This file is a translation of Section 4.2 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 the "Section 4.2" rationals,
Section_4_2.Int, as formal differencesa // bof integersa b:ℤ, up to equivalence. (This is a quotient of a scaffolding typeSection_4_2.PreRat, which consists of formal differences without any equivalence imposed.)field operations and order on these rationals, as well as an embedding of ℕ and ℤ
Equivalence with the Mathlib rationals
_root_.Rat(orℚ), which we will use going forward.
Instances For
Exercise 4.2.1
Equations
- Section_4_2.PreRat.instSetoid = { r := fun (a b : Section_4_2.PreRat) => a.numerator * b.denominator = b.numerator * a.denominator, iseqv := Section_4_2.PreRat.instSetoid._proof_1 }
Instances For
We give division a "junk" value of 0//1 if the denominator is zero
Equations
Instances For
Equations
- Section_4_2.«term_//_» = Lean.ParserDescr.trailingNode `Section_4_2.«term_//_» 100 101 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " // ") (Lean.ParserDescr.cat `term 101))
Instances For
Lemma 4.2.3 (Addition well-defined)
Equations
- One or more equations did not get rendered due to their size.
Lemma 4.2.3 (Multiplication well-defined)
Equations
- One or more equations did not get rendered due to their size.
Lemma 4.2.3 (Negation well-defined)
Equations
- One or more equations did not get rendered due to their size.
Embedding the integers in the rationals
Equations
- Section_4_2.Rat.instIntCast = { intCast := fun (a : ℤ) => a // 1 }
Equations
- Section_4_2.Rat.instNatCast = { natCast := fun (n : ℕ) => ↑n // 1 }
Equations
- Section_4_2.Rat.instOfNat = { ofNat := ↑n // 1 }
Whereas the book leaves the inverse of 0 undefined, it is more convenient in Lean to assign a "junk" value to this inverse; we arbitrarily choose this junk value to be 0.
Equations
- One or more equations did not get rendered due to their size.
Proposition 4.2.4 (laws of algebra) / Exercise 4.2.3
Proposition 4.2.4 (laws of algebra) / Exercise 4.2.3
Equations
- Section_4_2.Rat.instAddCommGroup = { toAddGroup := Section_4_2.Rat.addGroup_inst, add_comm := Section_4_2.Rat.instAddCommGroup._proof_11 }
Proposition 4.2.4 (laws of algebra) / Exercise 4.2.3
Equations
- One or more equations did not get rendered due to their size.
Proposition 4.2.4 (laws of algebra) / Exercise 4.2.3
Equations
- One or more equations did not get rendered due to their size.
Default definition of division
Equations
- One or more equations did not get rendered due to their size.
Proposition 4.2.4 (laws of algebra) / Exercise 4.2.3
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Instances For
(Not from textbook) The textbook rationals are isomorphic (as a field) to the Mathlib rationals
Equations
- One or more equations did not get rendered due to their size.
Instances For
Definition 4.2.8 (Ordering of the rationals)
Equations
- Section_4_2.Rat.instLT = { lt := fun (x y : Section_4_2.Rat) => (x - y).isNeg }
Definition 4.2.8 (Ordering of the rationals)
Equations
- Section_4_2.Rat.instLE = { le := fun (x y : Section_4_2.Rat) => x < y ∨ x = y }
(Not from textbook) The order is decidable. This exercise is only recommended for Lean experts. Alternatively, one can establish this fact in classical logic via classical; exact Classical.decRel _
Equations
(Not from textbook) Rat has the structure of a linear ordering.
Equations
- One or more equations did not get rendered due to their size.
(Not from textbook) Rat has the structure of a strict ordered ring.
Not in textbook: create an equivalence between Rat and ℚ. This requires some familiarity with the API for Mathlib's version of the rationals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Not in textbook: equivalence preserves order
Equations
- Section_4_2.Rat.equivRat_order = { toEquiv := Section_4_2.Rat.equivRat, map_rel_iff' := @Section_4_2.Rat.equivRat_order._proof_72 }
Instances For
Not in textbook: equivalence preserves ring operations
Equations
- Section_4_2.Rat.equivRat_ring = { toEquiv := Section_4_2.Rat.equivRat, map_mul' := Section_4_2.Rat.equivRat_ring._proof_73, map_add' := Section_4_2.Rat.equivRat_ring._proof_74 }