News for hackers. Stuff that matters.
Re:Lean Verification of the Riemann Hypothesis by dev_dan_2 on Saturday November 21, 2026 @05:43PM (#50594374)
I am sure you will get some more detailed answers; I am a bit lazy today; so I will give you the very high level / informal version of the answer:

Gödel's two incompleteness theorems basically amount to "As soon as your system is can do a ridicolously little amount of things, then either of two things is true in this system: 1) You can express facts in your system that you cannot prove within your system or 2) your system falsely claims that something is true, which isn't."

Now, because 2) is way way worse than 1), you design your systems so that you are firmly in the 1) camp - that way, we gain full confidence in the results our systems proofs, and the price we pay is that our system is less powerfull than it could be.

With Lean, it's similar. The foundation of Lean comes from type theory. There, we do something that is familar to above: We restrict our power (i.e. "which Lean statements do get verified by lean?", and we gain absolute confidence in its proofs (ignoring implementation errors, hardware limitations etc. for now). Intuitively: We have to work harder to satisfy the typechecker/prover, but when it is satisfied, then we have confidence in it.

-------------- Deeper down the rabbit hole

You might have noticed that I seem to muddle the waters a bit with programs, proofs, types and so on... There is a deep reason behind it! In a very strong sense, programs = types = proofs... So, here is how it is all connected Including the RH):

- Lean is a programming language (like Haskell, Rust, ... There is nothing stopping you from writing a server in Lean and deploying that binary somewhere in the cloud. Regarding developer experience, you could think of it like a modern Haskell without lazy evaluation and without its historical warts)

- programs can be tied to types: We first check if the whole program as such has a type ("do all of its parts fit together in a strictly defined way?"). Only if it does, we proceed (and for example, run it). If it does not, then the compiler declares "this program is not good! here is a type error!". Now, here is the price hat Gödel proved we cannot avoid. There are programs that don't type check, but behave perfectly fine at runtime. (That's the "we limit our power" part - those are perfectly good programs where the compiler throws their hand in the air and gives up!)

- Enter the Riemann Hypothesis: types are actually proofs too...! And the RH is a hypothesis we would like to prove...

- So here is how it all ties together: RH is written so that it can be used as a type, in the Lean programming language. The "main program" is basically just another ordinary function with some input types, and returns the type version of the RH being true. Because the function needs an implementation, we are forced to implement that function body - which are many small functions that correspond to mathematical theorems/lemmas if you look at it with the proof glasses on. From the programming pov, it is just functions that call functions that call functions and so on. And from the typechecking point of view; we compose a bunch of functions and check whether input types and output types match up.

Finally, the payoff: If that whole program typechecks, then we know RH is true; which is what just happened.

(PS: The same principle is behind the computational proof of the four-color-theorem. The proof of the four color theorem is "simply" a program that typechecks, where the final type happens to correspond to "can we color any planar graph with at most 4 colors?")

Re:Lean Verification of the Riemann Hypothesis by vbezhenar on Saturday November 21, 2026 @10:33PM (#50595968)
So while I'm not going to question if that's good approach, because if it's so popular, it must be good enough.

But on intuitive level it looks so weird to encode math in types.

When I was taught math, the proofs were more like sequence of statements. So if I would decide to implement proof checker, I'd invent formal language, which looks very close to commonly used math language and which allows to just write proof like it's written in book. Probably a lot more verbose, without skips and implied statements, but in the end, it'd look just like a verbose and formal proof.

Why did math gone this lean type way and not the way I described?

Re:Lean Verification of the Riemann Hypothesis by still_grokking on Saturday November 21, 2026 @11:46PM (#50596340)
It's the most natural thing possible to encode math in a programming language like LEAN.

Because logical propositions are types (in such a language). That's just a very fundamental part of math itself.

Watch this and you'll be enlightened:

https://www.youtube.com/watch?v=IOiZatlZtGU

LEAN code looks actually exactly like you propose; it supports most conventional (Unicode-linearizable) math notation, and you just write expressions like in any other functional language. Close to the textbook, but more verbose and stiff as it's a formal language, while math notation isn't.

Re:Lean Verification of the Riemann Hypothesis by NonHyloMorph on Sunday November 22, 2026 @05:15AM (#50598118)
That lack of relative verbosity and stiffness of mathnotation (what a thing to say haha) to be considered as a proper strength evtly. I'm consider myself as layity in this, but is an interface thinkable?
Re:Lean Verification of the Riemann Hypothesis by dnautics on Sunday November 22, 2026 @02:22PM (#50602964)
> It's the most natural thing possible

It's not intuitive. In isolation, if you took practical computer science and got a theoretical math background and didn't know about curry-howard correspondence, you would not intuitively figure out that propositions are types and proofs are terms. I would have guessed that propositions are functions, sets/classes are types, and elements are terms.

Re:Lean Verification of the Riemann Hypothesis by alethic on Saturday November 21, 2026 @11:48PM (#50596346)
This is a very good question! There are two answers.

First off, you can absolutely do what you are describing. There are systems like Metamath that assume nothing beyond first-order logic and the axioms of set theory, and apply these verbose rewrites. See https://en.wikipedia.org/wiki/Metamath for more. However, Lean (and many past theorem provers, too) have 1) preferred to represent mathematical objects as types rather than sets, and 2) built a large amount of interactive tooling rather than the blind rewriting of Metamath. The first choice is essentially of elegance -- the Curry-Howard correspondence indeed lets you write propositions as types and proofs as terms inhabiting those types, which is a connection of deep beauty. Ontologically, there is also an argument to be made that representing a mathematical object as a type is more "correct". We don't really think of ex. two as "{{},{{}}}" or "{{{}}}". We think of it as "Two", or maybe "Zero +1 +1". This is a win for types. Mathematical objects are not grocery bags.

Second, the historical approach to theorem proving has been interactive theorem proving. Theorem provers were supposed to be a second brain for students and computer scientists and mathematicians... keeping track of assumptions, suggesting possible tactics to take... aiding the human in the process of proof (and subsequently understanding), rather than replacing them. The path of uncritical adoption of AI that Lean has taken, sadly, much replaces the human. There is no real pragmatic reason for Lean to retain its interactive (human) elements any more (besides inertia). It might as well be Metamath indeed.

Re:Lean Verification of the Riemann Hypothesis by dnautics on Sunday November 22, 2026 @08:19PM (#50606240)
Lean also does a lot of things under the hood that make the process of checking a proof tricky, (but make writing the proof easier), it strikes me that maybe in 2026 we should be making writing the proof a bit harder at the expense of making reading the proof easier.
Re:Lean Verification of the Riemann Hypothesis by dev_dan_2 on Sunday November 22, 2026 @05:35AM (#50598274)
To add to the other answers, let me address the experience of "a series of steps" versus "a big single expression with a type" - real life is calling, so I have to make this quicker than I would like to; feel free to ask any followup questions / for clarification! I am sure others or later, I when I am back on the screen can answer :)

So the very short version: There is no difference between those two worlds if you squint your eyes hard enough! They are equally powerfull; just different ways of expressing the same truth. This is the whole declarative ("WHAT should the end result be") vs. implerative ("HOW to achieve the end result")stuff, but it's all the same at the end. Some examples:

  - SQL is declarative; but under the hood, it will get translated to a sequence of operations on the database by the query engine (or however it's called)
  - HTML is declarative; but there is no theoretical reason stopping you from building some sort of "imperative" HTML where you just add elements and stuff in a sequence of steps and at the end; are shown the same webpage (in fact, there are GUI frameworks that build up the GUI in an imperative manner; for the web, transmitting a declaration of what you want rather than a program that constructs it was the more practical choice I assume)
  - Haskell is often considered declarative (for good reasons), but if you think about the IO type as ("Hey I am a wrapper type and all I do is to enforce that step A happens before step B"), then you are pretty close to a imperative way of doing things again
  - Go/Java/C#/Python with types are almost always considered imperative; but you can also put on the type checking hat and pretend that the program is just one big function that will - if written correctly - have a final type. How does composition happen here? It's basically the line break, line :103 is executed before line :104, so lines :103-:104 can be viewed as: "the function that does whatever :103 does, then whatever :104 does", and it has the type "whatever input type :103 has and whatever input type :104 has", and type checking ensures that all those pieces fit together neatly.
They can even be mixed; in the proof assistant Rocq (formerly known as coq), there where both styles used often. In Lean, as I vaguely remember, you can pick both style too, so to say.

I think the pragmatic answer is that most such languages originated from the "one big function" school, and so it is more natural to program/proove in that way.

---------------------------

*Wait, does this mean that every proof I learned can also be done in this "one big function" way, instead of "a series of steps"?*

Yep! But you will find that it is not really practical to do so. A good exercise for sure though; and something I did (by that I mean: infering types on paper; not really taking proofs I know and doing them be type inference on paper) by hand when diving deeper into this topic in grad school.

Re:Lean Verification of the Riemann Hypothesis by rramadass on Sunday November 22, 2026 @07:42AM (#50599156)
The main issue is on how you define a "Type". There are two different logics here;

1) Classical Logic/Set Theory (this is the one you are talking about). Here Type = Set of values defined by membership rules (extensional/intensional).

2) Intuitionistic Constructive Logic/Type Theory (this is what is preferred for proof assistants). Here Type = Set of constructive (often inductive) proofs where the proof itself is the value.

As an example, think of defining the Type "Even_t"; under (1) it can be a predicate "x % 2 == 0", while under (2) it is defined inductively as "0 is Even_t; if construct(n) is Even_t so is construct(n+2)".

Notice that in the latter case a Type maps nicely into the idea of "a computation" and the fact that the very act of generation of one of its inhabitants constitutes "the proof" that the value has that property!

Whereas in Set theory Types are just subsets. But because you can mix anything into a set, an untyped term can be nonsense and will only get caught when you try to use it. Type Theory disallows it by construction.

This leads to the "Curry-Howard Correspondence" so you get a mapping between logic and type theory concepts - https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...

This idea of "Typing" can further be extended (with additions of Dependent Types etc.) giving a complex matrix of powerful Type Theories represented by what is known as "Lambda Cube" (https://en.wikipedia.org/wiki/Lambda_cube) and their implementations in proof assistants eg. Calculus of Constructions (CoC), Calculus of Inductive Constructions (CIC) etc.

Finally, note that not all proof assistants use constructive logic, several use straight ZFC/HOL. Amongst those that use constructive logic it is usually only the kernel (containing the Type System) which models it while the rest of the system still uses classical logic.

PS: See also the previous discussion Why is dependent type theory more suitable than set theory for proof assistants? - https://news.ycombinator.com/item?id=25167468

Re:Lean Verification of the Riemann Hypothesis by dnautics on Sunday November 22, 2026 @02:15PM (#50602895)
> When I was taught math, the proofs were more like sequence of statements. So if I would decide to implement proof checker, I'd invent formal language, which looks very close to commonly used math language and which allows to just write proof like it's written in book. Probably a lot more verbose, without skips and implied statements, but in the end, it'd look just like a verbose and formal proof.

Yes, one can build it, and it's a hell of a lot more verbose:

https://github.com/ityonemo/2b4m

sorry for the AI slop readmes, etc. This is very much a side project and I don't really feel the need to necessarily clean it up unless someone takes a real interest in it.

Re:Lean Verification of the Riemann Hypothesis by matltc on Sunday November 22, 2026 @03:25AM (#50597457)
Thank you very much for this explanation and the list of sources.
Re:Lean Verification of the Riemann Hypothesis by dev_dan_2 on Sunday November 22, 2026 @05:14AM (#50598111)
Sure, and I am very glad to hear that you liked it! :> (I really want to start blogging soon! Then I can simply link it / paste from it haha)