The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.Rat.Init

20 declarations. Mathlib docs · Source

Basic definitions around the rational numbers

This file declares ℚ notation for the rationals and defines the nonnegative rationals ℚ≥0.

This file is eligible to upstreaming to Batteries.

Cast from NNRat

This section sets up the typeclasses necessary to declare the canonical embedding ℚ≥0 to any semifield.

Numerator and denominator of a nonnegative rational

def NNRatCast.ctorIdx E1 #

{K : Type u_1} → NNRatCast K → ℕ

def termℚ E1 #

Lean.ParserDescr

Rational numbers, implemented as a pair of integers num / den such that the denominator is positive and the numerator and denominator are coprime.

def NNRat E1 #

Type

Nonnegative rational numbers.

def «termℚ≥0» E1 #

Lean.ParserDescr

Nonnegative rational numbers.

class NNRatCast E1 #

Type u_1 → Type u_1

Typeclass for the canonical homomorphism ℚ≥0 → K.

This should be considered as a notation typeclass. The sole purpose of this typeclass is to be extended by DivisionSemiring.

ctor NNRatCast.mk E0 #

{K : Type u_1} → (ℚ≥0 → K) → NNRatCast K

abbrev NNRatCast.nnratCast E1 #

{K : Type u_1} → [self : NNRatCast K] → ℚ≥0 → K

The canonical homomorphism ℚ≥0 → K.

Do not use directly. Use the coercion instead.

instance NNRat.instNNRatCast E0 #

NNRatCast ℚ≥0

def NNRat.cast E1 #

{K : Type u_1} → [NNRatCast K] → ℚ≥0 → K

Canonical homomorphism from ℚ≥0 to a division semiring K.

This is just the bare function in order to aid in creating instances of DivisionSemiring.

instance NNRatCast.toCoeTail E0 #

{K : Type u_1} → [NNRatCast K] → CoeTail ℚ≥0 K

instance NNRatCast.toCoeHTCT E0 #

{K : Type u_1} → [NNRatCast K] → CoeHTCT ℚ≥0 K

instance Rat.instNNRatCast E0 #

NNRatCast ℚ

def NNRat.num E1 #

ℚ≥0 → ℕ

The numerator of a nonnegative rational.

def NNRat.den E1 #

ℚ≥0 → ℕ

The denominator of a nonnegative rational.

theorem NNRat.num_mk E0 #

∀ (q : ℚ) (hq : 0 ≤ q), NNRat.num ⟨q, hq⟩ = q.num.natAbs

theorem NNRat.den_mk E0 #

∀ (q : ℚ) (hq : 0 ≤ q), NNRat.den ⟨q, hq⟩ = q.den

theorem NNRat.cast_id E1 #

∀ (n : ℚ≥0), ↑n = n

theorem NNRat.cast_eq_id E0 #

NNRat.cast = id

theorem Rat.cast_id E1 #

∀ (n : ℚ), ↑n = n

theorem Rat.cast_eq_id E0 #

Rat.cast = id