Basic operations on the integers #
This file contains some basic lemmas about integers.
See note [foundational algebra order theory].
TODO #
Split this file into:
Data.Int.Init
(or maybeData.Int.Batteries
?) for lemmas that could go to BatteriesData.Int.Basic
for the lemmas that require mathlib definitions
succ and pred #
The following few lemmas are proved in the core implementation of the omega
tactic. We expose
them here with nice user-facing names.
def
Int.inductionOn'
{C : ℤ → Sort u_1}
(z b : ℤ)
(H0 : C b)
(Hs : (k : ℤ) → b ≤ k → C k → C (k + 1))
(Hp : (k : ℤ) → k ≤ b → C k → C (k - 1))
:
C z
Inductively define a function on ℤ
by defining it at b
, for the succ
of a number greater
than b
, and the pred
of a number less than b
.
Equations
- z.inductionOn' b H0 Hs Hp = cast ⋯ (match z - b with | Int.ofNat n => Int.inductionOn'.pos b H0 Hs n | Int.negSucc n => Int.inductionOn'.neg b H0 Hp n)
Instances For
def
Int.inductionOn'.pos
{C : ℤ → Sort u_1}
(b : ℤ)
(H0 : C b)
(Hs : (k : ℤ) → b ≤ k → C k → C (k + 1))
(n : ℕ)
:
C (b + ↑n)
The positive case of Int.inductionOn'
.
Equations
- Int.inductionOn'.pos b H0 Hs 0 = cast ⋯ H0
- Int.inductionOn'.pos b H0 Hs n.succ = cast ⋯ (Hs (b + ↑n) ⋯ (Int.inductionOn'.pos b H0 Hs n))
Instances For
def
Int.inductionOn'.neg
{C : ℤ → Sort u_1}
(b : ℤ)
(H0 : C b)
(Hp : (k : ℤ) → k ≤ b → C k → C (k - 1))
(n : ℕ)
:
The negative case of Int.inductionOn'
.
Equations
- Int.inductionOn'.neg b H0 Hp 0 = Hp b ⋯ H0
- Int.inductionOn'.neg b H0 Hp n.succ = cast ⋯ (Hp (b + Int.negSucc n) ⋯ (Int.inductionOn'.neg b H0 Hp n))
Instances For
def
Int.negInduction
{C : ℤ → Sort u_1}
(nat : (n : ℕ) → C ↑n)
(neg : ((n : ℕ) → C ↑n) → (n : ℕ) → C (-↑n))
(n : ℤ)
:
C n
Inductively define a function on ℤ
by defining it on ℕ
and extending it from n
to -n
.
Equations
- Int.negInduction nat neg (Int.ofNat n) = nat n
- Int.negInduction nat neg (Int.negSucc n) = neg nat (n + 1)
Instances For
def
Int.strongRec
{m : ℤ}
{P : ℤ → Sort u_1}
(lt : (n : ℤ) → n < m → P n)
(ge : (n : ℤ) → n ≥ m → ((k : ℤ) → k < n → P k) → P n)
(n : ℤ)
:
P n
A strong recursor for Int
that specifies explicit values for integers below a threshold,
and is analogous to Nat.strongRec
for integers on or above the threshold.
Equations
- One or more equations did not get rendered due to their size.