feat(library/data/nat): add coprime_primes theorem

This commit is contained in:
Leonardo de Moura 2015-07-04 00:37:09 -07:00
parent e630511184
commit aee8bd8b0c
3 changed files with 38 additions and 1 deletions

View file

@ -366,6 +366,12 @@ coprime_swap (coprime_of_coprime_mul_left (coprime_swap H))
theorem coprime_of_coprime_mul_right_right {k m n : } (H : coprime m (n * k)) : coprime m n :=
coprime_of_coprime_mul_left_right (!mul.comm ▸ H)
theorem comprime_one_left : ∀ n, coprime 1 n :=
λ n, !gcd_one_left
theorem comprime_one_right : ∀ n, coprime n 1 :=
λ n, !gcd_one_right
theorem exists_eq_prod_and_dvd_and_dvd {m n k} (H : k m * n) :
∃ m' n', k = m' * n' ∧ m' m ∧ n' n :=
or.elim (eq_zero_or_pos (gcd k m))

View file

@ -5,7 +5,7 @@ Authors: Leonardo de Moura, Jeremy Avigad
The power function on the natural numbers.
-/
import data.nat.basic data.nat.order data.nat.div algebra.group_power
import data.nat.basic data.nat.order data.nat.div data.nat.gcd algebra.group_power
namespace nat
@ -61,4 +61,17 @@ lemma dvd_pow_of_dvd_of_pos : ∀ {i j n : nat}, i j → n > 0 → i j^n
lemma pow_mod_eq_zero (i : nat) {n : nat} (h : n > 0) : (i^n) mod i = 0 :=
iff.mp !dvd_iff_mod_eq_zero (dvd_pow i h)
lemma coprime_pow_right {a b} : ∀ n, coprime b a → coprime b (a^n)
| 0 h := !comprime_one_right
| (succ n) h :=
begin
rewrite [pow_succ],
apply coprime_mul_right,
exact coprime_pow_right n h,
exact h
end
lemma coprime_pow_left {a b} : ∀ n, coprime b a → coprime (b^n) a :=
λ n h, coprime_swap (coprime_pow_right n (coprime_swap h))
end nat

View file

@ -159,4 +159,22 @@ lemma dvd_of_prime_of_dvd_pow {p m : nat} : ∀ {n}, prime p → p m^n → p
(λ h, dvd_of_prime_of_dvd_pow hp h)
(λ h, h)
lemma coprime_pow_of_prime_of_not_dvd {p m a : nat} : prime p → ¬ p a → coprime a (p^m) :=
λ h₁ h₂, coprime_pow_right m (coprime_swap (coprime_of_prime_of_not_dvd h₁ h₂))
lemma coprime_primes {p q : nat} : prime p → prime q → p ≠ q → coprime p q :=
λ hp hq hn,
assert d₁ : gcd p q p, from !gcd_dvd_left,
assert d₂ : gcd p q q, from !gcd_dvd_right,
or.elim (divisor_of_prime hp d₁)
(λ h : gcd p q = 1, h)
(λ h : gcd p q = p,
have d₃ : p q, by rewrite -h; exact d₂,
or.elim (divisor_of_prime hq d₃)
(λ h₁ : p = 1, by subst p; exact absurd hp not_prime_one)
(λ he : p = q, by contradiction))
lemma coprime_pow_primes {p q : nat} (n m : nat) : prime p → prime q → p ≠ q → coprime (p^n) (q^m) :=
λ hp hq hn, coprime_pow_right m (coprime_pow_left n (coprime_primes hp hq hn))
end nat