Zulip Chat Archive

Stream: Is there code for X?

Topic: Coprime if product is squarefree


Arend Mellendijk (Jul 02 2023 at 12:30):

Am I right to say that we don't have the following lemma? It should hold more generally for PIDs or unique factorisation monoids depending on the definition of coprime you use.

import Mathlib.Data.Nat.Squarefree

theorem coprime_of_mul_squarefree (x y : ) (h : Squarefree $ x * y) : x.coprime y := by
  by_contra h_ncop
  cases' Nat.Prime.not_coprime_iff_dvd.mp h_ncop with p hp
  exact (Nat.squarefree_iff_prime_squarefree.mp h) p hp.1 $ Nat.mul_dvd_mul hp.2.1 hp.2.2

Yaël Dillies (Jul 02 2023 at 12:34):

We seem to have exactly one lemma relating coprime and squarefree: nat.squarefree_mul

Arend Mellendijk (Jul 02 2023 at 14:15):

#5669

Yury G. Kudryashov (Jul 02 2023 at 19:46):

@Yaël Dillies Why do you keep posting links to mathlib3 docs even if the thread is about mathlib4?

Kyle Miller (Jul 02 2023 at 19:55):

Mathlib3: docs3#nat.squarefree_mul, Mathlib4: docs#Nat.squarefree_mul (Note these are both linkifiers Yaël. No need to make your own links)

Yaël Dillies (Jul 02 2023 at 21:32):

because that's the docs I have open and it's easy to figure out the mathlib4 declaration from there.

Kevin Buzzard (Jul 03 2023 at 06:53):

It's easier for everyone else if you post a less confusing message

Junyan Xu (Jul 05 2023 at 05:30):

Wow, a language model rewrote your proof: https://wolfia.com/query/01H4J8BPAGH5RQ0F2NEGZY1KSB (see here for context)
It seems to know Lean (3) pretty well and was able to informalize the proof (or maybe it already knew the proof); probably GPT(-4)?

Scott Morrison (Jul 05 2023 at 06:22):

That link doesn't seem germane to this thread?

Junyan Xu (Jul 05 2023 at 08:02):

Thanks, fixed

Eric Rodriguez (Jul 05 2023 at 08:33):

Can it generalise it?

Junyan Xu (Jul 07 2023 at 07:48):

I asked it to generalize (two of the attempts) but the results were disappointing. Anyway, here's a generalization by myself of the PR to arbitrary "decomposition monoids", which include all gcd monoids: https://gist.github.com/alreadydone/0ad7fb42db30711c4540ac92e37f6655 (probably golfable)

Arend Mellendijk (Jul 07 2023 at 11:51):

With that definition of RelPrime the original lemma actually holds for arbitrary commutative monoids!

import Mathlib.Algebra.Squarefree

theorem relPrime_of_squarefree_mul {M : Type _} [CommMonoid M]
  (x y : M) (h : Squarefree (x*y)) :
     (p : M), p  x  p  y  IsUnit p :=
  fun p hx hy => h p $ mul_dvd_mul hx hy

Arend Mellendijk (Jul 07 2023 at 15:25):

Ah sorry, I missed that you proved it too


Last updated: Dec 20 2023 at 11:08 UTC