Extended GCD and divisibility over ℤ #
Main definitions #
- Given
x y : ℕ
,xgcd x y
computes the pair of integers(a, b)
such thatgcd x y = x * a + y * b
.gcdA x y
andgcdB x y
are defined to bea
andb
, respectively.
Main statements #
gcd_eq_gcd_ab
: Bézout's lemma, givenx y : ℕ
,gcd x y = x * gcdA x y + y * gcdB x y
.
Tags #
Bézout's lemma, Bezout's lemma
Extended Euclidean algorithm #
theorem
Nat.xgcdAux_zero
{s : ℤ}
{t : ℤ}
{r' : ℕ}
{s' : ℤ}
{t' : ℤ}
:
Nat.xgcdAux 0 s t r' s' t' = (r', s', t')
@[simp]
theorem
Nat.xgcd_zero_left
{s : ℤ}
{t : ℤ}
{r' : ℕ}
{s' : ℤ}
{t' : ℤ}
:
Nat.xgcdAux 0 s t r' s' t' = (r', s', t')
theorem
Nat.exists_mul_emod_eq_one_of_coprime
{k : ℕ}
{n : ℕ}
(hkn : Nat.Coprime n k)
(hk : 1 < k)
:
Divisibility over ℤ #
The extended GCD a
value in the equation gcd x y = x * a + y * b
.
Equations
- Int.gcdA x✝ x = match x✝, x with | Int.ofNat m, n => Nat.gcdA m (Int.natAbs n) | Int.negSucc m, n => -Nat.gcdA (Nat.succ m) (Int.natAbs n)
Instances For
The extended GCD b
value in the equation gcd x y = x * a + y * b
.
Equations
- Int.gcdB x✝ x = match x✝, x with | m, Int.ofNat n => Nat.gcdB (Int.natAbs m) n | m, Int.negSucc n => -Nat.gcdB (Int.natAbs m) (Nat.succ n)
Instances For
theorem
Int.natAbs_ediv
(a : ℤ)
(b : ℤ)
(H : b ∣ a)
:
Int.natAbs (a / b) = Int.natAbs a / Int.natAbs b
lcm #
theorem
pow_mem_range_pow_of_coprime
{α : Type u_1}
[CommGroupWithZero α]
{m : ℕ}
{n : ℕ}
(hmn : Nat.Coprime m n)
(a : α)
: