Zulip Chat Archive

Stream: general

Topic: Prime Reciprocal Series


Vladimir Goryachev (Aug 18 2021 at 14:29):

Hello everyone. Me and my friend have formalized the divergence of prime reciprocal series, theorem 81 from the 100 theorems list. However, the code is really messy, as it was almost the first thing we ever did with Lean. What is the best way to make the proof available?

Vladimir Goryachev (Aug 18 2021 at 14:29):

Also, how are Lean proofs typically licensed, and how should this license be indicated?

Ruben Van de Velde (Aug 18 2021 at 14:31):

Looks like there's also a PR open: https://github.com/leanprover-community/mathlib/pull/7274

Johan Commelin (Aug 18 2021 at 14:31):

@Vladimir Goryachev Welcome. Note that #7274 is another PR that deals with nr 81 of the 100 thm list.

Concerning sharing your code: is it 1 file, or multiple files? If it is 1 file, you can post it in a github gist. If it's more files, just post a link to the main file (assuming it's somewhere on github).

Johan Commelin (Aug 18 2021 at 14:32):

Concerning license, see any file in mathlib https://github.com/leanprover-community/mathlib/blob/master/src/field_theory/abel_ruffini.lean#L1L5

Vladimir Goryachev (Aug 18 2021 at 14:35):

Thank you. But why then does it say that 81 is not yet formalised in Lean https://leanprover-community.github.io/100-missing.html ?

Eric Rodriguez (Aug 18 2021 at 14:38):

#7274 is a dead PR as I see it, the author has been MIA for ever

Eric Rodriguez (Aug 18 2021 at 14:38):

and I don't think they wanted to refactor / add more comments

Eric Rodriguez (Aug 18 2021 at 14:38):

what proof do you follow Vladimir?

Vladimir Goryachev (Aug 18 2021 at 14:39):

The proof by Erdos.

Eric Rodriguez (Aug 18 2021 at 14:40):

same as the other pr then :) that's cool, can you share your code?

Vladimir Goryachev (Aug 18 2021 at 14:49):

Well, I am not proficient with github yet, but I'll try : )
https://gist.github.com/SymmetryUnbroken/d2bee9459764681b8efbed9b3a6dd16f

Vladimir Goryachev (Aug 18 2021 at 14:49):

Does it work?

Johan Commelin (Aug 18 2021 at 15:01):

yes, that works. If you change the extension to .lean then you also get syntax highlighting

Johan Commelin (Aug 18 2021 at 15:03):

@Vladimir Goryachev are you interested in contributing to mathlib? If so, can you identify a small chunk of code that you think can be reused outside of this proof?

Johan Commelin (Aug 18 2021 at 15:03):

If you want to contribute to mathlib, a good first step would be to take such a small piece, and PR it to mathlib first.

Vladimir Goryachev (Aug 18 2021 at 15:12):

Yes, I am interested in contributing to mathlib.

Vladimir Goryachev (Aug 18 2021 at 15:27):

As for a chunk of code - I have recursively defined the prime-counting function (a function giving the n-th prime number), its inverse (number of primes smaller than a given number), proved that they are inverses, that they are monotone, and that the prime-counting function of n is greater than n. Is this in mathlib yet?

Bryan Gin-ge Chen (Aug 18 2021 at 15:50):

We've got a page with some tips for contributing to mathlib here: https://leanprover-community.github.io/contribute/index.html

I don't think we have the prime-counting function yet.

Vladimir Goryachev (Aug 18 2021 at 16:04):

Thank you! I'll try to edit the prime-counting part according to the styleguide and make a PR.

Vladimir Goryachev (Aug 18 2021 at 16:34):

Actually, I've thought about it, and I don't use any properties of primes there (except that there are infinitely many primes), and I should probably make a general counting function (count (f : N -> Prop) (n : N) : N), which, given a property and an index n, returns the n-th natural number having this property. And then define the inverse of this function, and prove their properties. Is it true that those things aren't implemented yet?

Yaël Dillies (Aug 18 2021 at 16:36):

I very much suspect that already exists hidden somewhere, with extra carefulness around computability issues. Maybe Mario knows where that is?

Yaël Dillies (Aug 18 2021 at 16:37):

Another great thing you can do is use encodable. This will allow you to set up an explicit bijection between the naturals and the primes.

Vladimir Goryachev (Aug 18 2021 at 16:43):

But that would mean using types rather than predicates, right? For example, I would need to use the type of prime numbers, rather than a predicate of being prime.

Yaël Dillies (Aug 18 2021 at 16:45):

Yes. This type is already defined as nat.primes. I don't know whether switching to types is a good idea, but you can definitely try.

Vladimir Goryachev (Aug 18 2021 at 16:57):

OK. But this still leaves the question if there is a counting function for predicates - I have briefly browsed the mathlib, and haven't found it yet.

Johan Commelin (Aug 18 2021 at 17:38):

There is nat.find, but no nat.nth_find. Do you want it to take as arguments (1) the predicate, and (2) a proof that there are infinitely many nats that satisfy the predicate?

Floris van Doorn (Aug 18 2021 at 17:39):

I looked through the library, and it doesn't seem to exist yet...

Eric Wieser (Aug 18 2021 at 18:01):

All you need is a proof that there are at least n nats which satisfy the predicate


Last updated: Dec 20 2023 at 11:08 UTC