News for hackers. Stuff that matters.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by xvilka on Saturday June 19, 2021 @10:57AM (#27560975)
Interesting choice of the proof assistant though - some specific parts of the Lean's core are not completely decidable, moreover the upcoming Lean 4 version is incompatible with many libraries and proofs written for Lean 3. See also the discussion[1] if the Coq is suitable for number theory as quotients are ubiquitous here.

[1] https://github.com/coq/coq/issues/10871

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @12:00PM (#27561627)
The claim that Lean's core is not completely sound is FUD. Completely bogus.

You might be confused by the fact that Lean's definitional equality is not decidable, but that doesn't mean it isn't sound. Nobody has ever found a proof of `false` so far in Lean 3.

The choice for Lean is actually quite natural: (i) it has a large and coherent library of mathematics to build such a project upon. And (ii), it has a substantial user base of mathematicians somewhat familiar with the subject at hand (i.e., condensed mathematics).

The initial challenge by Peter Scholze was directed at all theorem proving communities. As far as I know, only the Lean community took up the challenge.

(Concerning Lean 4: yes, mathlib will have to be ported. And yes, people are working hard on this. I think that none of the theorem provers so far are ready for wide-scale use in mathematics. And that's why it is important to iterate fast. The Lean community is not afraid of redesigns and large refactors when discovering better approaches.)

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by xvilka on Saturday June 19, 2021 @12:09PM (#27561716)
> You might be confused by the fact that Lean's definitional equality is not decidable, but that doesn't mean it isn't sound. Nobody has ever found a proof of `false` so far in Lean 3.

You are right, my bad. Taking my words back on that.

A bit more details from the Pierre-Marie Pédrot:

> Lean does not escape this limitation, as it defines the equality type inductively as in Coq. Rather, in a mastermind PR campaign, they successfully convinced non-experts of type theory that they could give them quotient types without breaking everything around.

> The first thing they do is to axiomatize quotient types, which is somewhat fine and can be done the same in Coq. As any use of axioms, this breaks canonicity, meaning your computations may get stuck on some opaque term. (While slightly cumbersome, axiomatizing quotients already solves 99,9% of the problems of the working mathematician).

> Now, were they do evil things that would make decent type theorists shake in terror, they add a definitional reduction rule over the quotient induction principle. We could do the same in the Coq kernel, but there is a very good reason not to do this. Namely, this definitional rule breaks subject reduction, which is a property deemed more important than loss of canonicity.

> In Lean, you can write a term t : A where t reduces to u, but u doesn't have type A (or equivalently may not typecheck at all). This is BAD for a flurry of reasons, mark my words. Reinstating it while keeping quotients requires an undecidable type checking algorithm, which is another can of worms you don't want to wander into. The same kind of trouble arises from similar Lean extensions like choice.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @12:41PM (#27562012)
> Lean does not escape this limitation, as it defines the equality type inductively as in Coq. Rather, in a mastermind PR campaign, they successfully convinced non-experts of type theory that they could give them quotient types without breaking everything around.

This is not the first time that I hear someone from the Coq community talk about Lean and its "mastermind PR campaign". To me it comes across in a denigrating way, and frankly I'm a bit sick of it.

Working mathematicians are usually not experts of type theory. Yes. But they aren't stupid either. Why does the Lean community have such a large number of mathematician users? Why did it successfully formalize the main technical result of Peter Scholze's challenge in less than 6 months? Is this all because of a "mastermind PR campaign" selling mathematicians snake oil?

There has been some strong disagreements and even mud slinging between the Coq and Lean communities in the past. But I thought that axe was buried. I would like to move on.

I'm fine with people finding the foundations of Lean ugly, distasteful, improper, or whatever. But please stop the insults.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by ImprobableTruth on Saturday June 19, 2021 @07:53PM (#27565674)
The context of that "mastermind PR campaign" comment is a video watched now more than 70,000 times in which it's claimed that Coq is just not as good as Lean because it doesn't have quotient types, even though you can get them if you're willing to make the same trade-off that Lean does (broken SR). Calling Lean's framing a 'mastermind PR campaign' is of course still quite snippy, but I don't think it's totally unfair seeing as how it led to those comments.

>There has been some strong disagreements and even mud slinging between the Coq and Lean communities in the past. But I thought that axe was buried. I would like to move on.

I think it just takes time to fully move on. And while it's not the fault of the Lean community, when something like the recent quantamagazine article on formalizing mathematics essentially only mentions Coq to call it old and busted in comparison to Lean, that's only going to cause people to hold onto their resentments for longer.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by zozbot234 on Saturday June 19, 2021 @03:25PM (#27563595)
The Coq folks tend to focus on constructivity, and Lean gets sold as a constructive system but then you get this weird axiomatised-quotients stuff that's the farthest thing from constructivity. I can see how they might find that kind of thing highly frustrating.

It might not show up as a problem if you only ever care about classical stuff, but there are arguably better ways of doing purely classical mathematics that don't arbitrarily break interoperability w/ the constructive world.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @03:31PM (#27563647)
Where does Lean get sold as a constructive system? Certainly mathlib (the main maths library in Lean) is very upfront about being classical.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by zozbot234 on Saturday June 19, 2021 @03:40PM (#27563720)
mathlib != Lean. I'm talking about the basic logic. People will try to sell you Lean by describing its system as constructive, but if so the quotients stuff is pure breakage as the Coq folks point out.

And if Lean could support classical logic without arbitrarily breaking interop for folks who want to also prove constructive statements, we might see some additions to mathlib with a closer focus on constructive math.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @03:44PM (#27563769)
I agree very much that mathlib != Lean. Still, I think much of the talk about Lean will mention that mathlib is classical.

It was an honest question: I don't know where Lean is sold as a constructive system. (Note, I haven't read every part of Lean's documentation or website. I might be missing something obvious here.)

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by foooobar on Saturday June 19, 2021 @03:51PM (#27563822)
I don't think anyone is trying to sell Lean as a constructive system. The current developers certainly don't think of it that way, further evidenced by the fact that the typical way of doing computation in Lean does not involve definitional reduction, but using `#eval` with additional low level code for performance. Proof irrelevance (and quotients) were adopted with that in mind.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Someody42 on Saturday June 19, 2021 @04:11PM (#27563994)
You can absolutely do constructive things in Lean, as long as you use neither the built-in "quot" type nor the three other axioms described in the docs, and then you get a system with all the desired properties I think
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by foooobar on Saturday June 19, 2021 @04:18PM (#27564061)
Some constructivists may also take offense with proof irrelevance (and the resulting loss of normalization [1] or its incompatibility with HoTT), which you can only really avoid by avoiding Prop.

[1] https://arxiv.org/abs/1911.08174

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by xvilka on Saturday June 19, 2021 @11:21PM (#27566824)
There is also a problem of HoTT and equality reflection incompatibility[1].

[1] https://www2.mathematik.tu-darmstadt.de/~streicher/barc_corr...

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @12:15PM (#27561760)
Ok, no worries. I understand that from a theoretical point it's not so nice that defeq is not decidable. But frankly I don't care. Because in practice, I don't know of any example where someone was bitten by this. It only shows up in contrived examples. And even if you have some practical example where lean gets stuck on A = B, it will probably be very easy to find a C so that lean gets unstuck on A = C = B.

[Edit, this comment only replies to the first paragraph of parent. I wrote it before parent was edited.]

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by xvilka on Saturday June 19, 2021 @12:43PM (#27562025)
By the way, just for the record, I like many aspects of the new Lean 4 design and wish the project luck. They really aim for better maintainability and user experience. It is nice to see them taking best solutions from other programming languages and frameworks.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by chriswarbo on Saturday June 19, 2021 @08:24PM (#27565856)
I haven't used quotients (or Lean), but I've certainly encountered subject reduction problems in Coq when using coinduction, so this sounds a tad hypocritical.

It's certainly good to avoid breaking subject reduction even more though ;)

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Jweb_Guru on Saturday June 19, 2021 @10:38PM (#27566628)
Pierre Pedrot has been very vocal in his belief that broken SR from coinductive types is a serious problem with Coq that needs to be fixed. This is quite different from introducing stuff that deliberately breaks it.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by xvilka on Saturday June 19, 2021 @10:25PM (#27566547)
There's ongoing work[1] on fixing that. Also let's see how migrating setoids to cubical type theory might fix more issues for Coq. Will they follow the Arend[2] path? That remains to be seen.

[1] https://github.com/coq/coq/pull/10764

[2] https://arend-lang.github.io/about/arend-features

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kzrdude on Saturday June 19, 2021 @12:18PM (#27561788)
Shouldn't it be easy to automatically port theorems? If they are well defined there can't be ambiguity
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by deadbeef57 on Saturday June 19, 2021 @12:26PM (#27561877)
Yes and no. If you want to port large low-level proof objects in all their gory detail, then this has been done already. But if you want to port the more concise higher-level proof scripts you run in all the same issues as with regular transpilers.

Compare it to porting machine code for one instruction set to another instruction set. This is usually doable in a straightforward manner (maybe with a mild performance penalty). But transpiling idiomatic Java to idiomatic Haskell is nigh impossible.

Luckily, the differences between Lean 3 and Lean 4 are not as large as between Java and Haskell. But still, they have different idioms, different syntax, different features. And this has to be taken care of.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Someody42 on Saturday June 19, 2021 @12:30PM (#27561922)
In theory yes, but there are two main things that makes it harder :

- some technical details have changed. They don't affect the axiomatic aspects of Lean, but they force us to redefine some things in a cleaner way.

- we don't only want to port the theorem. We want to port them to a human-readable proof that can be easily maintained

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by generationP on Saturday June 19, 2021 @03:20PM (#27563545)
As to decidability: I suspect you mean that Lean's foundations are non-constructive. I'd rather they weren't, but with what Peter Scholze is doing, I'd be surprised if the arguments could be made constructive within just a few years from their conception. This usually takes much longer (e.g., constructive proofs of the Quillen-Suslin theorem appeared in print just a few years ago).

About incompatibility: Last time I checked (some 3 or so years ago), Coq was not backwards compatible either, and libraries had to be ported manually with each update. Sadly, as this is the one greatest anti-feature that is currently putting me off proof assistants, but probably it needs some time, and the quickest way to get there is to maximize usage. From what I know about Coq and Lean, I suspect Lean will stabilize faster than Coq does, due to it being more "declarative" (Coq is based too much on complex tactics, which are hard to make stable by design).

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by ulber on Saturday June 19, 2021 @11:31AM (#27561349)
I wasn't aware of Lean not being sound and a quick search didn't come up with anything related to that. Could you link a source?
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by martincmartin on Saturday June 19, 2021 @12:12PM (#27561736)
See other comment. It's sound but not decidable.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kevinbuzzard on Saturday June 19, 2021 @01:22PM (#27562362)
Basically it turned out that theoretical undecidability did not matter in practice, because Scholze mathematics relies so little on definitional equality. We prove theorems with `simp` not `refl`. Pierre-Marie Pédrot is quoted above as saying that various design decisions are "breaking everything around", but we don't care that our `refl` is slightly broken because it is regarded as quite a low-level tool for the tasks (eg proving theorems of Clausen and Scholze) that we are actually interested in, and I believe our interests contrast quite a lot with the things that Pédrot is interested in.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kmill on Saturday June 19, 2021 @02:23PM (#27562968)
And in "Lean style", refl proofs are a bit distasteful from a software engineering point of view because they pierce through the API of a mathematical object. (In the language of OOP, it can break encapsulation.)

It tends to be a good idea to give some definition, then prove a bunch of lemmas that characterize the object, and finally forget the definition.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by bryan0 on Saturday June 19, 2021 @02:58PM (#27563317)
Can you explain to a non-mathematician how you can prove anything without refl (which I assume is the statement “x=x is true”) ?
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by digama0 on Saturday June 19, 2021 @03:19PM (#27563530)
The jargon is a bit confusing sometimes. In Lean, "refl" does a whole lot more than prove x=x. It is of course available if you want to prove x=x, but the real power of "refl" is that it also proves x=y where x and y are definitionally equal. Or at least that's the idea; it turns out that lean's definitional equality relation is not decidable so sometimes it will fail to work even when x and y are defeq, and this is the theoretically distasteful aspect that came up on the linked Coq issue. In practice, the theoretical undecidability issue never happens, however there is a related problem where depending on what is unfolded a proof by "refl" can take seconds to minutes, and if alternative external proof-checkers don't follow exactly the same unfolding heuristics it can turn a seconds long proof into a thousand-year goose chase. By comparison, methods like "simp" have much more controllable performance because they actually produce a proof term, so they tend to be preferable.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by bryan0 on Saturday June 19, 2021 @07:36PM (#27565562)
Thanks for the explanation. Is the defeq undecidability a bug of Lean that should be fixed in the future? Or is it an intentional design decision for it to function properly for other types of proofs?
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kevinbuzzard on Sunday June 20, 2021 @10:32AM (#27570396)
Defeq undecidability is a feature of Lean in the sense that it is a conscious design decision. As we have seen both in this thread and in other places, this design decision puts off some people interested in the foundations of type theory from working with Lean. However it turns out that for people interested other kinds of questions (e.g. the mathematics of Scholze), defeq undecidability is of no relevance at all.

Here's an analogue. It's like saying "Goedel proved that maths was undecidable therefore maths is unusable and you shouldn't prove theorems". The point is that Goedel's observation is of no practical relevance to a modern number theorist and does not provide any kind of obstruction in practice to the kind of things that number theorists think about.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Jweb_Guru on Saturday June 19, 2021 @10:41PM (#27566645)
I am quite confident that the developers of lean consider it a feature (or at least, not a bug). Though I'm also not sure why they are building on a complex metatheory like CiC if they are willing to accept undecidable typechecking since you can simplify a lot of things if you give that up.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by foooobar on Sunday June 20, 2021 @06:58AM (#27568893)
What simplifications do you have in mind?

I think one of the reasons is that Lean's approximation of defeq still works well enough in practice. As mentioned by others, you never really run into the kind of counter examples that break theoretical properties, but instead into examples where checking defeq is inacceptably slow, which remains an issue even when defeq is decidable.

From my understanding CiC is used because it allows using a unified language for proofs, specifications, programs and types, which greatly simplifies the system. For example, in Lean 4, more or less the entire system is built on the same core term language: Proofs, propositions / specifications, programs, tactics (i.e. meta programs), the output of tactics and even Lean 4 itself are all written in that same language, even if they don't always use the same method of computation. In my eyes, for the purposes of writing and checking proofs, CiC is quite complex; but if you want to capture all of the above and have them all checked by the same kernel, CiC seems like a fairly minimal metatheory to do so, even with undecidable type checking.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Jweb_Guru on Sunday June 20, 2021 @02:20PM (#27572561)
For example, if you are willing to accept undecidable typechecking, you can define inductive types in a much simpler theory (inductive types and dependent pattern matching are by far the most complex parts of CiC): https://homepage.cs.uiowa.edu/~astump/papers/from-realizabil... .

There are a few other examples but this is the one that immediately sprung to mind. The complexity of CiC is very much about decidable typechecking, it's not fundamental to writing a sound dependently typed proof assistant. And anyone who has actually worked on a kernel for CiC knows that while it is "minimal" compared to what people want to do with it, no efficient kernel is nearly as minimal as something like λP2 with dependent intersections.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by foooobar on Monday June 21, 2021 @04:42AM (#27577385)
Thanks! But does that not already answer your question as to why Lean would use CIC and not a simpler metatheory?

That particular paper is from 2016 and the type theory presented there is still lacking a number of features from CIC, with those particular extensions being listed as further research. Work on Lean started in 2013 and the kernel in particular has not been touched in a long time for good reason. Around that time, CIC was already battle-proven with there being popular and well-tested reference implementations to learn from. Since then, all the fancy work has been done on the system surrounding the kernel.

I believe one of the goals at the start was that the kernel should be sufficiently simple and small so that it is easy to ensure that the kernel is correct. Despite the apparent redundant complexity that you suggest, the implementation still seems to be sufficiently simple to reach this goal, as no proof of false that was a result of a kernel bug has been reported yet. CIC being well-tested surely also contributed to that.

Another reason is that, as I understand it, it was not always obvious that Lean would break decidability of defeq. Afaik proof irrelevance was only baked in with Lean 3, while it was an option before that. By that point I don't see much of a reason to rewrite an entire kernel that has worked fine so far.

I also vaguely remember that there were arguments related to performance in favor of the current system (e.g. versus W-types), but I don't really understand these things well enough to make that point with confidence :)

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kmill on Sunday June 20, 2021 @04:15PM (#27573503)
How are the ergonomics of a proof assistant based on λP2? Lean does a lot of elaboration of metavariables and typeclass instances and such before handing things off for checking by the kernel -- I'm curious about whether λP2's undecidability is decidable enough, so to speak.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Jweb_Guru on Sunday June 20, 2021 @07:02PM (#27574615)
That's currently an open research question, but the answer most likely is that the ergonomics could be made just as good, considering that elaboration of metavariables, typeclass instances, etc. already uses possibly-undecidable algorithms distinct from those used in the kernel in just about every proof assistant I'm familiar with (Lean included).

In terms of stuff that do go more or less directly through the kernel, some followup papers to the one I linked discuss how to translate inductive definitions etc. automatically into a form accepted by the simpler kernel, so I am even more confident that this would not present a problem.

Re:Mathematicians welcome computer-assisted proof in ‘grand ... by kevinbuzzard on Sunday June 20, 2021 @07:57PM (#27574910)
The fact remains though that Lean 3 worked well enough to do Scholze level mathematics. I never quite know what to make of people saying "if the designers had done it in some other way, it would have been better". Of course if someone comes along doing it another way, and then they go on to also achieve Scholze level mathematics, then I will be all ears.
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by Jweb_Guru on Monday June 21, 2021 @01:08PM (#27581144)
That's a very strange line of argument. Many great programs have been written in C. That doesn't mean that there is no way to improve on C. Perhaps to even the playing field, this hypothetical competitor should be given the resources of Microsoft Research as well :)
Re:Mathematicians welcome computer-assisted proof in ‘grand ... by foooobar on Monday June 21, 2021 @01:52PM (#27581684)
I think Kevin is asserting that to make strong comparative claims about the quality of either system, it's good to have a large and functionally similar body of work to compare the systems with, not that there is no way to improve on Lean's core :)

MSR funds a single developer. The Lean community consists of at least 30 or so active contributors right now, with many more having contributed in the past. Most folks work in academia. Much of Lean's success is absolutely due to the work of that single developer, but I don't think that the playing field is uneven due to MSR's funding.