Аналіз I, Глава 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 // b
of 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
Вправа 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
Decidability of equality. Hint: modify the proof of DecidableEq Int
from the previous
section. However, because formal division handles the case of zero denominator separately, it
may be more convenient to avoid that operation and work directly with the Quotient
API.
Equations
- Section_4_2.Rat.decidableEq = sorry
Лема 4.2.3 (Addition well-defined)
Equations
- One or more equations did not get rendered due to their size.
Лема 4.2.3 (Multiplication well-defined)
Equations
- One or more equations did not get rendered due to their size.
Лема 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.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.
Твердження 4.2.4 (laws of algebra) / Вправа 4.2.3
Твердження 4.2.4 (laws of algebra) / Вправа 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 }
Твердження 4.2.4 (laws of algebra) / Вправа 4.2.3
Equations
- One or more equations did not get rendered due to their size.
Твердження 4.2.4 (laws of algebra) / Вправа 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.
Твердження 4.2.4 (laws of algebra) / Вправа 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
(Не із книги) 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
Визначення 4.2.8 (Ordering of the rationals)
Equations
- Section_4_2.Rat.instLT = { lt := fun (x y : Section_4_2.Rat) => (x - y).isNeg }
Визначення 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 }
(Не із книги) Establish the decidability of this order.
Equations
- One or more equations did not get rendered due to their size.
(Не із книги) Rat has the structure of a linear ordering.
Equations
- One or more equations did not get rendered due to their size.
(Не із книги) 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_78 }
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_79, map_add' := Section_4_2.Rat.equivRat_ring._proof_80 }