Zulip Chat Archive

Stream: new members

Topic: Help needed on a proof that seems to involve factorization


Kevin Cheung (Mar 06 2024 at 20:11):

I wonder how I should proceed in the following:

import Mathlib.Data.Nat.Factorization.Basic

example : ( k, 2  ((Nat.factorization n) k))   a, n = a ^ 2 := by
  constructor
  . sorry
  . intro  a, ha 
    intro k
    rw [ha]
    rw [Nat.factorization_pow]
    dsimp
    apply exists_apply_eq_apply'

Insights or pointers greatly appreciated.

Ruben Van de Velde (Mar 06 2024 at 20:26):

You're missing some imports

Kevin Cheung (Mar 06 2024 at 20:28):

I had the following: import Mathlib.Data.Nat.Factorization.Basic

Ruben Van de Velde (Mar 06 2024 at 20:30):

Please edit your first message to include it

Kevin Cheung (Mar 06 2024 at 20:31):

Added the import.

Ruben Van de Velde (Mar 06 2024 at 20:52):

import Mathlib.Data.Nat.Factorization.Basic

example : ( k, 2  ((Nat.factorization n) k))   a, n = a ^ 2 := by
  constructor
  . intro h
    by_cases n = 0
    · use 0
      subst n
      simp
    use (Nat.factorization n).prod fun a b => a ^ ((Nat.factorization n) a / 2)
    rw [@Nat.prod_factorization_eq_prod_primeFactors]
    trans Finset.prod n.primeFactors fun x => x ^ ((Nat.factorization n) x)
    · rw [ @Nat.prod_factorization_eq_prod_primeFactors]
      rwa [Nat.factorization_prod_pow_eq_self]
    · rw [ @Finset.prod_pow]
      apply Finset.prod_congr rfl fun k _ => ?_
      rw [ pow_mul, Nat.div_mul_cancel (h k)]
  . intro  a, ha 
    intro k
    rw [ha]
    rw [Nat.factorization_pow]
    dsimp
    apply exists_apply_eq_apply'

Kevin Cheung (Mar 06 2024 at 21:34):

Thank you. This looks a lot harder than I expected.

Kevin Cheung (Mar 06 2024 at 21:42):

Where can one find more examples of proofs using Nat.factorization and related theorems?

Ruben Van de Velde (Mar 06 2024 at 21:46):

I use loogle: https://loogle.lean-lang.org/?q=Nat.factorization

Ruben Van de Velde (Mar 06 2024 at 21:46):

It does feel like there's some lemmas missing

Kevin Cheung (Mar 06 2024 at 21:47):

You mean the library should have more results that people like me can use?

Ruben Van de Velde (Mar 06 2024 at 21:49):

Yeah, exactly.

Eric Wieser (Mar 06 2024 at 21:50):

Maybe the mathlib result should be in terms of Even (Nat.factorization n)?

Eric Wieser (Mar 06 2024 at 21:50):

With IsSquare on the RHS

Eric Wieser (Mar 06 2024 at 21:51):

Probably there's some low hanging fruit here for lemmas about Even / IsSquare on Pi/Prod/Finsupp etc

Kevin Cheung (Mar 06 2024 at 21:52):

Maybe a result like this could be added?

theorem some_name (d : Nat) (h : d > 0) : ( k, d  ((Nat.factorization n) k))   a, n = a ^ d := sorry

Yaël Dillies (Mar 06 2024 at 23:17):

I think we basically have this in the form of docs#Nat.floorRoot

Yaël Dillies (Mar 06 2024 at 23:17):

Not entirely sure how painful the glue is


Last updated: May 02 2025 at 03:31 UTC