"Why not just use Lean?"
77 points by ibobev 2 hours ago | 25 comments

kccqzy 34 minutes ago
For the HN crowd who are generally programmers but not necessarily mathematicians, it’s more relevant to consider the programming side of things. There is a very good book (one I haven’t finished unfortunately) that covers Lean from a functional programming perspective rather than proving mathematics perspective: https://leanprover.github.io/functional_programming_in_lean/

I am learning Lean myself so forgive me as I have an overly rosy picture of it as a beginner. My current goal is to write and prove the kind of code normal programmers would write, such as in the recent lean-zip example: https://github.com/kiranandcode/lean-zip/blob/master/Zip/Nat...

reply
readthenotes1 11 minutes ago
I recall an experiment in proving software correct from the 1990s that found more errors in the final proof annotations than in the software it had proved correct.

Then, I foresee 2 other obstacles, 1 of which may disappear:

1. Actually knowing what the software is supposed to do is hard. Understanding what the users actually want to do and what the customers are paying to do --which aren't necessarily the same thing--is complex

2. The quality of the work of many software developers is abysmal and I don't know why they would be better at a truth language than they are at Java or some other language.

Objection 2 may disappear to be replaced with AI systems with the attention to do what needs to be done. So perhaps things will change in that to make it worthwhile...

reply
jsmorph 3 minutes ago
Re 1: Discussing and guiding the desirable theorems for general-purpose programs has been a major challenge for us. Proofs for their own sake (bad?) vs glorious general results (good but hard?). Actual human guidance there can be critical there at least for now.
reply
cayley_graph 43 seconds ago
Mind linking the experiment? Sounds interesting.
reply
smj-edison 31 minutes ago
I think what's interesting about Lean is that Lean is a language, and what most people are talking about is a library called Mathlib. From what I've read about Mathlib, the creators are very pragmatic, which is why they encode classical logic in Lean types, with only a bit of intuitionistic logic[1].

[1] for those unfamiliar with math lingo, classical logic has a lot of powerful features. One of those is the law of the excluded middle, which says something can't be true and false at the same time. That means not not true is true, which you can't say in intuitionistic logic. Another feature is proof by contradiction, where you can prove something by showing that the alternative is unsound. There's quite a few results that depend on these techniques, so trying to do everything in intuitionistic logic has run into a lot of roadblocks.

reply
cubefox 34 seconds ago
> One of those is the law of the excluded middle, which says something can't be true and false at the same time.

That would be the law of non-contradiction (LNC). The law of the excluded middle (LEM) says that for every proposition it is true or its negation is true.

LEM: For all p, p or not p.

LNC: For all p, not (p and not p).

Classical logic satisfies both, intuitionistic logic only satisfies LNC.

reply
vscode-rest 25 minutes ago
When/why would one prefer to use intuitive logic, given the limitations/roadblocks?
reply
smj-edison 6 minutes ago
As far as I understand it, classical mathematics is non-constructive. This means there are quite a few proofs that show that some value exists, but not what that value is. And in mathematics, a proof often depends on the existence of some value (you can't do an operation on nothing).

The thing is it can be quite useful to always know what a value is, and there's some cool things you can do when you know how to get a value (such as create an algorithm to get said value). I'm still learning this stuff myself, but inuitionistic logic gets you a lot of interesting properties.

reply
ux266478 12 minutes ago
Classical logic has plenty of limitations/roadblocks, all logics do. Logic isn't a unified domain, but an infinite beach of structural shards, each providing a unique lens of study.

Classical logic was rejected in computer science because the non-constructive nature made it inappropriate for an ostensibly constructive domain. While you can implement its evaluation with a machine, it's extremely unwieldy and inefficient, and allows for a level of non-rigor that proves to be a massive footgun.

reply
thaumasiotes 20 minutes ago
For ideological reasons.
reply
Chinjut 23 minutes ago
You mean intuitionistic logic, not "intuitive logic".
reply
smj-edison 16 minutes ago
Oops, just edited. I'm still fairly new to this area, so I keep mixing up my terms :)
reply
bowsamic 26 minutes ago
This makes it good for formal maths, but bad for philosophy, since it means it can’t encode the speculative movement
reply
thaumasiotes 21 minutes ago
> Another feature is proof by contradiction, where you can prove something by showing that the alternative is unsound.

As far as lean is concerned, this isn't an example of classical logic. It's just the definition of "not" - to say that some proposition implies a contradiction, and to say that that proposition is untrue, are the same statement.

Most "something"s that you'd want to prove this way will require a step from classical logic, but not all of them. (¬p ⟶ F) ⟶ p is classical; (p ⟶ F) ⟶ ¬p is constructive.

reply
smj-edison 11 minutes ago
So proof by contradiction proves ¬p, but it requires the law of excluded middle to prove p (in the case of ¬p -> F)? I didn't realize that was constructive in the first case.
reply
MarkusQ 48 minutes ago
We need more of this.

For every "well of course, just...X, that's what everybody does" group-think argument there's a cogent case to be made for at least considering the alternatives. Even if you ultimately reject the alternatives and go with the crowd, you will be better off knowing the landscape.

reply
sdenton4 3 minutes ago
It depends!

Every time you go off the beaten path, you're locking yourself into less documentation, more bugs (since there's less exploration of the dark corners), and fewer people you can go to for help. If you've got 20+ choices to make, picking the standard option is the right choice on average, so you can just do it and move on. You have finite attention, so doing a research report on every dependency means you're never actually working on the core problem.

The exceptions to this are when a) it becomes apparent that the standard tool doesn't actually fit your use case, or b) the standard tool significantly overlaps the core problem you're trying to solve.

reply
jsmorph 10 minutes ago
Slightly off topic: This project https://agentcourt.ai/arb/analysis/index.html uses a Go/Lean hybrid design. The Go code is mostly glue, and the Lean code is the logic https://github.com/agentcourt/adjudication/tree/main/arb/eng.... It's not math-intensive. Really just functional programming with some interesting proofs (including soundness ideally). Go code can migrate to Lean code when that makes sense.
reply
waffletower 14 minutes ago
Not a healthy lifestyle, but a lot of tracks honor it: https://open.spotify.com/track/1JgkiUg9mSXSwcb5Gbi4Ur?si=37d...
reply
zermelo44 46 minutes ago
Good post! +1
reply
groundzeros2015 20 minutes ago
Type theory and lean is more interesting to people who like computers than to people who like math.
reply
ux266478 4 minutes ago
The set theorists decided that mathematics is the overarching superdomain over all study of structure. You don't get to pick and choose. Either mathematics is a suburb of logic and these two things are separate, or they're not and ZFC dogmatics need to accept they don't have a monopoly on math.

I of course fully support reinstating logicism, but the same dogmatics love putting up a fight over that as well.

reply
soulofmischief 16 minutes ago
Terence Tao, one of the most important living mathematicians, specifically embraces Lean and has been helping the community embrace it.

What you've done here is an overgeneralization. "People who like math" and "people who like computers" are massive demographics with considerable overlap.

reply
baq 16 minutes ago
citation needed, Tao certainly is on record using Lean and that carries some weight.

also, https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon... i.e. there's no reason it should be as you say.

reply
groundzeros2015 4 minutes ago
The link is exactly what I’m saying. I only hear cs people talk about it.

For mathematicians a proof is a means to an end, or a medium of expression - they care about what they say and why.

The correspondence isn’t about C programs corresponding to proofs in math papers. It’s a very a specific claim about kinds of formal systems which don’t resemble how math or programming is done.

reply