The part of a number with its prime factors in a set #
Candidates for Mathlib.Data.Nat.Factors: the product of the prime factors of n that pass a test
p, (n.primeFactorsList.filter p).prod, the part of n with its prime factors in a set (as
Nat.prod_mem_factoredNumbers of Mathlib.NumberTheory.SmoothNumbers has it), is multiplicative, a
divisor of n, 1 when no prime factor passes and n when all do; for the test (·.Coprime m) it
is Nat.coprimePart n m, the largest divisor of n ≠ 0 prime to m.
Main definitions #
Nat.coprimePart: the product of the prime factors ofn, with multiplicity, that are prime tom.
Main statements #
Nat.prod_filter_primeFactorsList_mul: the part ofa bis the product of the parts ofaandb;Nat.prod_filter_primeFactorsList_mul_of_forall: a factorawithout a prime factor that passes leaves the part ofbas it is.Nat.prod_filter_primeFactorsList_eq_one,Nat.prod_filter_primeFactorsList_eq_self: the part is1when no prime factor passes, andnwhen all do.Nat.prod_filter_primeFactorsList_dvd: the part dividesn.Nat.coprimePart_dvd,Nat.coprime_coprimePart,Nat.dvd_coprimePart_of_dvd: the part ofnprime tomdividesn, is prime tom, and every divisor ofn ≠ 0prime tomdivides it, so that it is the largest divisor ofnprime tom.
Implementation notes #
Nat.coprime_coprimePart and Nat.dvd_coprimePart_of_dvd use Nat.coprime_list_prod_left_iff and
Nat.coprime_list_prod_right_iff of Mathlib.Data.Nat.GCD.BigOperators, which
Mathlib.Data.Nat.Factors does not import.
Multiplying by a number without a prime factor that passes the test keeps the part of a number with its prime factors passing it.
The product of the prime factors of n, with multiplicity, that are prime to m: for n ≠ 0
the largest divisor of n prime to m (Nat.dvd_coprimePart_of_dvd).
Equations
- n.coprimePart m = (List.filter (fun (x : ℕ) => decide (x.Coprime m)) n.primeFactorsList).prod
Instances For
The largest divisor prime to m. Every divisor of n ≠ 0 prime to m divides
Nat.coprimePart n m, since it is prime to the other prime factors of n, which divide m.