Zulip Chat Archive

Stream: new members

Topic: infinitely many primes satisfying a property


Alex Brodbelt (Apr 06 2025 at 15:31):

Hi! I am back again having fun :dancer: with Lean and was wondering how one would simulate the (very satisfying) argument that is done for proving infinitely many primes, but in a more general context:

Problem statement: Prove there are infinitely many primes satisfying the proposition PP.

Argument I would like to simulate as closely as possible:
Suppose for a contradiction you have a finite set of primes {p1,p2,,pN}\{p_1, p_2, \ldots, p_N\} satisfying proposition PP. So the statement would look like:

import Mathlib

theorem infinitely_many_good_primes (P :   Prop) :
    Infinite { p :  | Nat.Prime p  P p } := by
    by_contra! h
    rw [not_infinite_iff_finite] at h
    sorry

Then using (or not) all the pip_i I can generate a new number not divisible by any of the pip_i but has a prime divisor ppip \ne p_i which I can prove satisfies PP; thus (...not sure how to generate the contradiction here) this finite set is larger than originally presumed since ppip \ne p_i and by repeating this process it can be made arbitrarily large (this is how I would plausibly try formalise this style of proof).

I suspect I do not even have to phrase it as a contradiction proof in Lean (as I do in the stubbed out statement) since I vaguely recall Infinite typeclass can be shown to hold by providing an injection from the naturals to the set/type, or some variation of this kind.

Thanks :-)

Edward van de Meent (Apr 06 2025 at 15:56):

i'd say this is the style of the proof here:

import Mathlib

theorem infinitely_many_numbers (P :   Prop) (f : Finset {p // P p}  {p // P p})
    (hf :  s, f s  s) :
    Infinite { p :  | P p } := by
  by_contra! h
  rw [not_infinite_iff_finite, Set.coe_setOf] at h
  have : Fintype {p :  // P p} := @Fintype.ofFinite _ h
  exact hf _ (Finset.mem_univ _)

Edward van de Meent (Apr 06 2025 at 15:57):

so basically, "find a function which takes a finite set of numbers with a property, and finds a new one"

Alex Brodbelt (Apr 06 2025 at 16:06):

ahhh beautiful, I haven't peeked into the details to see whether it is quite what I need... but already :cook:

Alex Brodbelt (Apr 06 2025 at 16:09):

indeed indeed, I should have trusted the elegance of it. Thanks @Edward van de Meent !


Last updated: May 02 2025 at 03:31 UTC