238 points · by dgellow · 8y ago · 132 comments
Most mathematical arguments are actually not formal, in the way a program is a formal language.
In many instances, there are not only ambiguities but errors in the mathematical expression. They only become formalised to an equivalent degree in a system like Isabelle or Coq.
Writing proofs in Isabelle and Coq is essentially the same process as writing highly functional code, and is susceptible to the same arduous process. It's hard because it's a formal language running on a rigid machine.
Programming would be easy if you specified everything in a semi --formal pseudo code, designed to be interpreted by a human mind that can fill in the blanks. This is what most mathematics is.
This is more useful than it sounds, since studying problems themselves can often lead to generalizations ("ah, this is NP-hard") that let you import plug-and-play knowledge ("we shouldn't expect a polynomial time solution").
But yeah when it comes time to implement/simulate, papers that are hand wavey with constants get annoying.
The implementation in fact took less space than their plain English description...
For papers that are deeply abstract and focused on solving a problem of the nature you describe, that's to me very different, and clearly there are papers where you won't get around using maths to communicate the problem well. But at least in the fields I've worked in, those kind of papers are rare exceptions.
I do wish more authors published their source code separately from the actual paper.
This distinction was very obvious when I did the literature survey for my MSc. - the papers with even partial code fragments were uniformly less likely to miss out essential information.
Elementary Strong Functional Programming by D.A. Turner
https://pdfs.semanticscholar.org/b60b/1c2e49ec6f574f220f162c...
http://web.mit.edu/Saltzer/www/publications/rfc/csr-rfc-185....
Unix:
https://people.eecs.berkeley.edu/~brewer/cs262/unix.pdf
or pretty much everything here: http://cseweb.ucsd.edu/classes/fa17/cse221-a/readings.html
CS can be pretty broad.
Statically encoding something like a memory constraint sounds very hard for all but the simplest algorithms. What about a randomized algorithm that sometimes uses more heap? How do you get around not knowing how much it's going to use without running it?
What you're describing is essentially a proven, lightweight, formal method for improving software quality. Many commercial apps use it.
but another reason is that code often has to be written in a shorter time frame. there are tools like coq that enable people to write code that is correct by proofs, but I'd hate to do my daily work that way
My experience is this isn't true. The reason it seems to be true is mathematicians will skip over writing out "boring" edge cases, which while hypothetically simple are often where the bugs occur in code.
At the top of various fields, you basically have a bunch of experts writing for each other, using heuristic arguments, and writing only to a level that will convince one another that the result is "probably true". Important results of great public interest are picked to pieces. But this is not true of less prominent work (of which the majority of the literature consists), probably each paper is read an average of 0.6 times, including by the authors and referees.
Can you provide any examples? I know this is true, but I'm interested in examples you have off the top of your head.
In broad generality, I work on algorithms for number theory and fast arithmetic. If you look at published, peer reviewed, conference proceedings in this area, there are many, many well known cases of incorrect algorithms.
Sometimes in the mathematical literature there are multiple definitions given for similar concepts, and later authors assume without checking that they are the same thing. I'm aware of papers that are entirely wrong because of this.
Another area where errors are common is in stating identities, which the author didn't try to check with a computer.
But, I am also aware of examples in less computational, pure mathematics too.
The phenomenon also extends to famous textbooks and undergraduate notes. Simply look at the errata section of any sufficiently well-read textbook. Sometimes incorrect or inadequate assumptions are carried right through the book without explicitly mentioning them.
A famous cryptographer used to have online a rant about half-gcd algorithms. As the story goes, the original publication was correct. One famous improvement is only correct for polynomials. A later attempt by another author is not correct for polynomials or integers. And a famous textbook in the field took until their third edition to get the proof/algorithm correct.
I've even seen an incorrect definition given for something as fundamental as a field, even by the most famous of mathematicians, now two or three times I think (admittedly once by someone who wasn't an algebraist).
You can find many examples easily by Googling, "proof was unfortunately incorrect", although it is usually stated more generously than that, e.g. "we have been unable to reconstruct their argument", "we supply some missing details", "it is not clear exactly what the authors intended", "where we correct an obvious typographical error", etc.
And this is to say nothing of the almost infinite supply of papers that are missing critical elements of the proof, or where folklore theorems are relied upon without proof or citation. Simply search for the ubiquitous phrases, "the well-known result" and "it is well-known that".
What really matters is the actual thinking about the actual subject. In nearly all math proofs, the writing is closer to that thinking than in coding. Or, each sentence in a math proof -- and well written proofs actually are written in sentences -- is closer to the thinking than for the programming language statements in the coding. Or, look at the statements in the coding -- without mnemonic identifier naming, they are close to just gibberish.
To get the coding closer to the thinking, that's the documentation in the coding. However the documentation is usually not as precise as the sentences in a math proof or the statements in code.
So, maybe we need to do something to get programming closer to the real thinking: For this, maybe try to have what we use in programming to be easier to describe. That is, in a math proof, we have numbers, sets, vectors, functions, etc. and at each point in the proof see clearly what these mean. In programming we have variables, arrays, structures, IF statements, loops, subroutines, and without documentation or careful reading don't see clearly what these mean.
Once I tried: I wrote some subroutines for sorting, permutations, etc. and tried to have clear properties for the operations the code die, properties that could reason about. Then for some uses of these subroutines, could do some logical reasoning much like in algebra in math. I didn't go very far with that idea!
> Still, I hope that this sheds some light on the question that is implied: "What really is the difference between proving some theorem and writing a program?" (To which a careless observer of the Curry-Howard correspondence might say: "Nothing at all!")
I've actually done this a number of times before, but only in the ACM ICPC programming contest, so maybe a difference here is the environment in which people write programs vs proofs. In the contest, you have a team of three people and only one computer, and if you submit an incorrect solution, the only response you get back is "Wrong answer" with no detail about what test case was wrong. The typical way that teams approach this is to write code out completely on paper, then transcribe it from paper to the computer, run the provided test cases, and submit. Computer time is valuable, so if you run into a mistake that you can't figure out, it's common to print your code and look through the code on paper rather than trying to debug it on the computer.
When you train enough in an environment like that, you learn to be very careful about all of the details of the program you're writing. A single mistake can dramatically increase the time it takes to solve a problem, and there's pretty much no opportunity to "try it and see" like there is in normal programming. Also, the simple act of writing code down on paper and then copying it into the computer (double-checking as you go) gives you much more time to notice mistakes.
Mistakes are still common, of course, but I've had a number of times where I write out a program on paper, type it into the computer, compile it with no errors, run the sample test cases and have them all pass, and then submit it and and see that it's correct. I've never experienced something like that in any other programming environment, including other programming contests, which typically let you write your code on the computer.
Proofs tend to be the same type of environment: you write it out, with no compiler to help you, and you have plenty of time to read through it over and over before you have someone else check it for correctness. Maybe that sort of environment forces a level of care that you don't see as much in programming.
In Mathematics you operate on a much higher level of concepts, and these concepts don't just fall out of thin air, but were sometimes decades or centuries in the making.
In programming though your concepts are made up very much on the fly (if you bother developing concepts at all; usually you just use your framework of choice and hope it got enough concepts baked in so you can survive), and therefore often not very good and coherent. That means you can not rely on them for any kind of correctness assessment.
Note: I'm not claiming that programmers should be treated like mathematicians or vice versa, I'm merely pointing out the differences of the activities.
Edit: There is of course also a more trivial reason. On average, research mathematicians are probably more intelligent, skillful and diligent than typical programmers.
Given the examples in the linked discussion of cases where not only did mathematicians write buggy proofs but it took years to figure out a mistake existed at all, let alone what it was, I find it hard to believe that. To the extent it may appear superficially to be true it's likely the result of the academic setting in which there is no connection to real world relevance and the only pressure that exists to get things done comes from peers and the need to publish papers - but if those papers achieve very little and your peers papers also achieve little, that's totally OK.
Compare to the world of the working programmer who is judged not by how fast he writes code but by the real world positive impact of that code, and it is easy to see how the mathematician may come across as more diligent or intelligent. But it's just an artifact of the pressure-free environment.
I was also surprised to learn that the idea of checking mathematical proofs using Coq is considered just as exotic or impractical as checking programs. I had thought that Coq and other proof assistants were in wide usage for this use case, as surely pure mathematics is simpler to reason about formally than entire programs ... but apparently not. The fact that maths proofs are still mostly checked by hand, whereas machine-checked proofs (like static type systems) are widely used by even novice programmers, is hardly reassuring.
Keep in mind that there are a lot more programmers than professional mathematicians, and programmers are more likely to be well paid than mathematicians. As a result, mathematicians are self-selected for doing math while most programmers are only in it for the paycheck, on top of the fact that a mediocre mathematician probably isn't going to be able to make a living in math.
"Compare to the world of the working programmer who is judged not by how fast he writes code but by the real world positive impact of that code,..."
I suspect that you have an excessively positive opinion of the work of most programmers. I myself know far too many who are both slow and detrimental to the projects they are assigned.
As for formal mathematical proofs, I bet you will find that most mathematicians don't do them for the same reason that essentially no coffee is verified: it adds a lot of complexity (the same complexity, I suspect) without any obvious benefit.
> Programmers are less intelligent, skillful and diligent on average than research mathematicians? How do you figure that?
Well, the selection process is much harder. It's an empirical claim that could be falsified, but the claim seems reasonable in lack of any counter-evidence.
[1] https://en.wikipedia.org/wiki/Inter-universal_Teichm%C3%BCll...
The statement is a metaphor. Mathematicians are commonly deemed intelligent, with high variability of course, as university graduates generally are. On the meta level, mathematicians provided a lot of the basis which computers and programs are build from. Now it's poetic freedom to include programmers who venture into mathematics in this fuzzy term.
I think you're right about the pressure-free environment bit, too - some places developers are so bogged down with fire-fighting that planned development with real foresight rarely gets developed.
Moreover I think there are just more software developers, with much more variance in their abilities than research mathematicians.
In mathematics, there are abstract concepts like integers. For any i, i+1 is also an integer.
In programming, there is a MIN_INT and MAX_INT. If you write i/2, it's different than i/2.0. If you store a long string in a database, the column may be cut off at 32 chars because of the column type. Running string algorithms that sounds perfectly reasonable on ASCII may result in weird outcomes on Unicode. Most of these things also depend on the programming language, the compiler (MS, gnu, etc), the compiler version, OS, libraries, sometimes even the locale! A provably good crypto algorithm may be vulnerable to side-channel attacks. A mathematician may be happy to give an existential proof, but a programmer needs an implementation, and one that is polynomial [usually]. And so on...
The tldr is, the real world is more complicated, limited and nuanced than the abstract concepts of mathematics.
Now imagine writing proofs on a very low level (check Metamath) where you work with wff and rewrite rules. It gets as tricky as programming.
Proofs are usually about some very small thing, and require a tremendous amount of work. Then, there is a huge literature for guidance and reusable elements (though, a lot of work to use it), and peer review to check it (also labour intensive).
Are there any mathematicians here who can weigh in?
On the one hand we have something like the 4-colour theorem where there is some kind of "proof", which is very large and incomprehensible. This is probably unsatisfactory to many because one is not really interested in just knowing that something is true, but ideally one also want an understanding of "why" something is true. This is, to various degrees, achived in more standard proofs.
Another reason for disliking proof assistants is probably that they simply are very cumbersome to use and not very much can be proven with them so far. I would guess that even if you could get someone to admitt that the idea is cool and could be very useful, it's just not practical and for most people in mathematics it's just a distraction from what they are trying to work on at the moment.
Compare with trying to convince someone that a flying car is really cool, yeah, sure, it probably would be, but so far it's basically sci-fi. If you want to work on building this, great, but most commuters will probably "look down" on your idea if you start bugging them about it.
To be specific, I've used Coq in the past to help verify properties of programs such as a sorted list really being sorted. That said, I primarily work in applied math areas such as optimization, numerical linear algebra, and numerical PDEs and I have no idea where to begin with fundamental proofs such as Newton's method converging quadratically within a certain neighborhood of the solution. Alternatively, I'd love to see formalized proofs of the theorems that we'd learn in a course in real analysis such as one based on Rudin's Principles of Mathematical Analysis. Really, if anyone has examples of these, please let me know.
There's an amazing number of errors in published work. Most of the time, the work is still mostly right, but that's not OK. In my opinion, we'd be better off with formalized proofs.
It may be rather an off-topic, but I suggest you to read my funny paper: https://docs.google.com/document/d/10pTRJFgwEGnUM5RF1CHX2OO5...
Not to mention decidability issues.
Regarding your second point, to me this looks pretty much the same as in software: In high-quality code I expect high-level comments that give me intuition about the code, and I also expect high-level documentation giving me further intuition about the components and the system as a whole. The more complicated the system is, the more important the comments and the documentation become.
I see no reason why we should hold computer-assisted proofs to a lesser standard.
There's some attempts to alleviate these problems, which are named Homotopy Type Theory, and they are quite successful.
From what I have seen, proof assistants in math are used when extreme rigour is desired (which is not always the case) and when working with extremely long computational proofs with hundreds of cases (where you need to work at a higher abstraction level; a human writes a program that outputs the proof and then the proof checker verifies that this extremely long step by step proof is valid)
Proof assistants are the opposite. Sacrifice intuition and insight for the sake of correctness.
This is also why mathematicians love picture proofs.
I love pictures that give me intuition about a proof and I agree that intuition is crucial to understanding. But all the intuition in the world is useless if the proof fails because of one tiny logically unsound step or one pathological corner case, so it's no good to ignore the technical details or, even worse, to become unable to expand a purpoted proof one has written into a fully detailed version, which I suppose can easily happen if someone relies too much on intuition.
First of all, I think that the author underestimates the complexity of writing correct programs. What if integer overflow occurs? What is some exceptions happens somewhere? Programmers rarely consider all the pathological cases, while mathematicians must consider all of them. If program works most of the time, it's good enough for programmer but not good enough for mathematician.
Second, thanks to Curry Howard Correspondence, every formal proof has a corresponding program which 'constructs' a result of the theorem from preconditions, so, the proof is basically a program (and vice versa in a typed programming language).
pi. Easy in "math", effing hard to do in code. You don't have to worry about iee floats in "math". You don't have to worry about computational restrictions like ram, cpu time, null pointers etc.
Mathematics is based more in the "spirit" of the idea and proof, rather than pedantically driving things down into the ultimate nuts and bolts. Many paper proofs are likely full of bugs deep in the details.
As intuitionism and machine formalism develop, and the standard of rigor rises, we might see entire branches of mathematics being relegated to the dustbin of historically interesting human endeavors but totally useless as foundations/formal assumptions for future work.
Most math lacks these features common in programming.
With iteration you blend the results at time t with the results at time t+1.
Because of conditionals (if statements), a programming mistake at time t may not become evident till some much later step in the iteration, because the path through the logic is not guaranteed to be consistent.
Typically the data of all intervening steps has been lost by the time you encounter the error.
Nobody is going to pay me to spend that kind of time on that little amount of code. Heck, I'm not even going to spend that kind of time on my own projects.
One exists in the world of abstraction while the other lives in the real world.
Might as well ask why we can have a perfect circle in math while a perfect circle doesn't exist in the real world.
I remember the fist time I saw that line and said, that's false. And it's been an ever ending divergence from pure math for the past 30 years.
x <- x + 1
x := x + 1
But I guess since assignment is more frequent than equality checks, most PL designers opt for using equals. I do like R's left arrow assignment operator. If only keyboards had a default arrow character key. It would completely get rid of a class of errors based on forgetting the second equals sign.
The teacher steps would resume in 5 sentences, but the function would be more long and include exceptions and weird cases. No room for mistakes with my JavaScript. No wonder I had the biggest score in the classroom.
The bane of my existence as a math undergrad.
https://en.wikipedia.org/wiki/Coq
Some would argue that writing code IS more fault proof than writing proofs the traditional way.
Of course these aren't mutually exclusive, provided the theorem prover is simple enough to understand.
Writing mathematical proofs is as fault-proof as writing pseudo-code.
Writing machine-check proofs is as fault-proof as writing code.
One might say the amazing thing is that many (not all!) such theorems are correct, despite the errors. Somehow, mathematical insight sees the truth, despite formalism failure...
But, by this standard, most programs are "correct", they just have some inconsequential errors.
I think this goes to a systemic problem in mathematics, that proofs are not very rigorous. I've never found one convincing. Instead, math is slightly like English Literature, where you learn "theories" that are held to be true by the community. You get inducted, and off you go. It's not purely objective.
Of course, this doesn't explain the usefulness of mathematics when applied to reality, so I only claim it's "slightly like" an Arts subject. Perhaps some survivor bias, and engineers fix any problems.
This is an outrageous exaggeration.
However there are execution environments, read RTOS that try to be fault tolerant. Also various virtual machines like JVM,CLR try to provide fault tolerance to varying degrees.
With real world applied software that is very rarely the case.
If you're saying that math/theoretical computer science makes unrealistic assumptions, that's a different (and more reasonable) claim.
You have an example of this kind of thought police behavior? In all my years on that site I have never seen anything like what you are describing.
For one, they did not do sufficient backgroud checks on intake, so the volunteers were self-selected group of people with sadistic tendencies.
Also, researchers were not fully neutral, they were (conciously or not) encouraging subjects to violent behaviours, thus steering the whole study towards expected results
IMO, we need better commenting systems in general.
There seemed to be less downvoting around 10am GMT than at 6pm GMT.