Documentation
Init
.
Data
.
Nat
.
Div
Search
Google site search
return to top
source
Imports
Init.WF
Init.WFTactics
Init.Data.Nat.Basic
Imported by
Nat
.
div_rec_lemma
Nat
.
div
Nat
.
instDivNat
Nat
.
div_eq
Nat
.
div
.
inductionOn
Nat
.
div_le_self
Nat
.
div_lt_self
Nat
.
modCore
Nat
.
mod
Nat
.
instModNat
Nat
.
modCore_eq_mod
Nat
.
mod_eq
Nat
.
mod
.
inductionOn
Nat
.
mod_zero
Nat
.
mod_eq_of_lt
Nat
.
mod_eq_sub_mod
Nat
.
mod_lt
Nat
.
mod_le
Nat
.
zero_mod
Nat
.
mod_self
Nat
.
mod_one
Nat
.
div_add_mod
Nat
.
div_eq_sub_div
Nat
.
mod_add_div
Nat
.
div_one
Nat
.
div_zero
Nat
.
zero_div
Nat
.
le_div_iff_mul_le
Nat
.
div_mul_le_self
Nat
.
div_lt_iff_lt_mul
Nat
.
add_div_right
Nat
.
add_div_left
Nat
.
add_mul_div_left
Nat
.
add_mul_div_right
Nat
.
add_mod_right
Nat
.
add_mod_left
Nat
.
add_mul_mod_self_left
Nat
.
add_mul_mod_self_right
Nat
.
mul_mod_right
Nat
.
mul_mod_left
Nat
.
div_eq_of_lt_le
Nat
.
sub_mul_div
Nat
.
mul_sub_div
Nat
.
mul_mod_mul_left
Nat
.
div_eq_of_lt
source
theorem
Nat
.
div_rec_lemma
{x :
Nat
}
{y :
Nat
}
:
0
<
y
∧
y
≤
x
→
x
-
y
<
x
source
@[extern lean_nat_div]
def
Nat
.
div
(x :
Nat
)
(y :
Nat
)
:
Nat
Equations
Nat.div
x
y
=
if
0
<
y
∧
y
≤
x
then
Nat.div
(
x
-
y
)
y
+
1
else
0
Instances For
source
instance
Nat
.
instDivNat
:
Div
Nat
Equations
Nat.instDivNat
=
{
div
:=
Nat.div
}
source
theorem
Nat
.
div_eq
(x :
Nat
)
(y :
Nat
)
:
x
/
y
=
if
0
<
y
∧
y
≤
x
then
(
x
-
y
)
/
y
+
1
else
0
source
theorem
Nat
.
div
.
inductionOn
{motive :
Nat
→
Nat
→
Sort
u
}
(x :
Nat
)
(y :
Nat
)
(ind :
(
x
y :
Nat
) →
0
<
y
∧
y
≤
x
→
motive
(
x
-
y
)
y
→
motive
x
y
)
(base :
(
x
y :
Nat
) →
¬
(
0
<
y
∧
y
≤
x
)
→
motive
x
y
)
:
motive
x
y
source
theorem
Nat
.
div_le_self
(n :
Nat
)
(k :
Nat
)
:
n
/
k
≤
n
source
theorem
Nat
.
div_lt_self
{n :
Nat
}
{k :
Nat
}
(hLtN :
0
<
n
)
(hLtK :
1
<
k
)
:
n
/
k
<
n
source
@[extern lean_nat_mod]
def
Nat
.
modCore
(x :
Nat
)
(y :
Nat
)
:
Nat
Equations
Nat.modCore
x
y
=
if
0
<
y
∧
y
≤
x
then
Nat.modCore
(
x
-
y
)
y
else
x
Instances For
source
@[extern lean_nat_mod]
def
Nat
.
mod
:
Nat
→
Nat
→
Nat
Equations
Nat.mod
x✝
x
=
match
x✝
,
x
with |
0
,
x
=>
0
|
x
@
h
:
(
Nat.succ
n
)
,
y
=>
Nat.modCore
x
y
Instances For
source
instance
Nat
.
instModNat
:
Mod
Nat
Equations
Nat.instModNat
=
{
mod
:=
Nat.mod
}
source
theorem
Nat
.
modCore_eq_mod
(x :
Nat
)
(y :
Nat
)
:
Nat.modCore
x
y
=
x
%
y
source
theorem
Nat
.
mod_eq
(x :
Nat
)
(y :
Nat
)
:
x
%
y
=
if
0
<
y
∧
y
≤
x
then
(
x
-
y
)
%
y
else
x
source
theorem
Nat
.
mod
.
inductionOn
{motive :
Nat
→
Nat
→
Sort
u
}
(x :
Nat
)
(y :
Nat
)
(ind :
(
x
y :
Nat
) →
0
<
y
∧
y
≤
x
→
motive
(
x
-
y
)
y
→
motive
x
y
)
(base :
(
x
y :
Nat
) →
¬
(
0
<
y
∧
y
≤
x
)
→
motive
x
y
)
:
motive
x
y
source
@[simp]
theorem
Nat
.
mod_zero
(a :
Nat
)
:
a
%
0
=
a
source
theorem
Nat
.
mod_eq_of_lt
{a :
Nat
}
{b :
Nat
}
(h :
a
<
b
)
:
a
%
b
=
a
source
theorem
Nat
.
mod_eq_sub_mod
{a :
Nat
}
{b :
Nat
}
(h :
a
≥
b
)
:
a
%
b
=
(
a
-
b
)
%
b
source
theorem
Nat
.
mod_lt
(x :
Nat
)
{y :
Nat
}
:
y
>
0
→
x
%
y
<
y
source
theorem
Nat
.
mod_le
(x :
Nat
)
(y :
Nat
)
:
x
%
y
≤
x
source
@[simp]
theorem
Nat
.
zero_mod
(b :
Nat
)
:
0
%
b
=
0
source
@[simp]
theorem
Nat
.
mod_self
(n :
Nat
)
:
n
%
n
=
0
source
theorem
Nat
.
mod_one
(x :
Nat
)
:
x
%
1
=
0
source
theorem
Nat
.
div_add_mod
(m :
Nat
)
(n :
Nat
)
:
n
*
(
m
/
n
)
+
m
%
n
=
m
source
theorem
Nat
.
div_eq_sub_div
{b :
Nat
}
{a :
Nat
}
(h₁ :
0
<
b
)
(h₂ :
b
≤
a
)
:
a
/
b
=
(
a
-
b
)
/
b
+
1
source
theorem
Nat
.
mod_add_div
(m :
Nat
)
(k :
Nat
)
:
m
%
k
+
k
*
(
m
/
k
)
=
m
source
@[simp]
theorem
Nat
.
div_one
(n :
Nat
)
:
n
/
1
=
n
source
@[simp]
theorem
Nat
.
div_zero
(n :
Nat
)
:
n
/
0
=
0
source
@[simp]
theorem
Nat
.
zero_div
(b :
Nat
)
:
0
/
b
=
0
source
theorem
Nat
.
le_div_iff_mul_le
{k :
Nat
}
{x :
Nat
}
{y :
Nat
}
(k0 :
0
<
k
)
:
x
≤
y
/
k
↔
x
*
k
≤
y
source
theorem
Nat
.
div_mul_le_self
(m :
Nat
)
(n :
Nat
)
:
m
/
n
*
n
≤
m
source
theorem
Nat
.
div_lt_iff_lt_mul
{k :
Nat
}
{x :
Nat
}
{y :
Nat
}
(Hk :
0
<
k
)
:
x
/
k
<
y
↔
x
<
y
*
k
source
@[simp]
theorem
Nat
.
add_div_right
(x :
Nat
)
{z :
Nat
}
(H :
0
<
z
)
:
(
x
+
z
)
/
z
=
Nat.succ
(
x
/
z
)
source
@[simp]
theorem
Nat
.
add_div_left
(x :
Nat
)
{z :
Nat
}
(H :
0
<
z
)
:
(
z
+
x
)
/
z
=
Nat.succ
(
x
/
z
)
source
theorem
Nat
.
add_mul_div_left
(x :
Nat
)
(z :
Nat
)
{y :
Nat
}
(H :
0
<
y
)
:
(
x
+
y
*
z
)
/
y
=
x
/
y
+
z
source
theorem
Nat
.
add_mul_div_right
(x :
Nat
)
(y :
Nat
)
{z :
Nat
}
(H :
0
<
z
)
:
(
x
+
y
*
z
)
/
z
=
x
/
z
+
y
source
@[simp]
theorem
Nat
.
add_mod_right
(x :
Nat
)
(z :
Nat
)
:
(
x
+
z
)
%
z
=
x
%
z
source
@[simp]
theorem
Nat
.
add_mod_left
(x :
Nat
)
(z :
Nat
)
:
(
x
+
z
)
%
x
=
z
%
x
source
@[simp]
theorem
Nat
.
add_mul_mod_self_left
(x :
Nat
)
(y :
Nat
)
(z :
Nat
)
:
(
x
+
y
*
z
)
%
y
=
x
%
y
source
@[simp]
theorem
Nat
.
add_mul_mod_self_right
(x :
Nat
)
(y :
Nat
)
(z :
Nat
)
:
(
x
+
y
*
z
)
%
z
=
x
%
z
source
@[simp]
theorem
Nat
.
mul_mod_right
(m :
Nat
)
(n :
Nat
)
:
m
*
n
%
m
=
0
source
@[simp]
theorem
Nat
.
mul_mod_left
(m :
Nat
)
(n :
Nat
)
:
m
*
n
%
n
=
0
source
theorem
Nat
.
div_eq_of_lt_le
{k :
Nat
}
{n :
Nat
}
{m :
Nat
}
(lo :
k
*
n
≤
m
)
(hi :
m
<
Nat.succ
k
*
n
)
:
m
/
n
=
k
source
theorem
Nat
.
sub_mul_div
(x :
Nat
)
(n :
Nat
)
(p :
Nat
)
(h₁ :
n
*
p
≤
x
)
:
(
x
-
n
*
p
)
/
n
=
x
/
n
-
p
source
theorem
Nat
.
mul_sub_div
(x :
Nat
)
(n :
Nat
)
(p :
Nat
)
(h₁ :
x
<
n
*
p
)
:
(
n
*
p
-
Nat.succ
x
)
/
n
=
p
-
Nat.succ
(
x
/
n
)
source
theorem
Nat
.
mul_mod_mul_left
(z :
Nat
)
(x :
Nat
)
(y :
Nat
)
:
z
*
x
%
(
z
*
y
)
=
z
*
(
x
%
y
)
source
theorem
Nat
.
div_eq_of_lt
{a :
Nat
}
{b :
Nat
}
(h₀ :
a
<
b
)
:
a
/
b
=
0