5 ms·
Curry–Howard correspondence
- vincenzow 8y agoOnly tangentially related story, but maybe worth sharing. There’s an older gentleman who frequents a Panera in Chicago my wife works at. He is known and loved by all the employees and is staple of the store around closing time. At some point, I made a comment about the paper he was reading (he always brings in the daily paper) and we sat for a bit and talked politics and news. He had introduced himself as Bill, and over the course of the conversation I came to found out that he was William Howard. I’ve sat down and chatted with him a few times since, and he’s always happy to help explain type theory to my feeble web dev mind :). I was really impressed by how well versed he was, not only in his field of math, but also in his expertise of (what he considers a tangential field) programming, aerospace, ecenomics, etc. He’s got an air of humble greatness about him, and meeting him really left me a better and more educated person.
- whateveracct 8y agoA beautiful truth of the universe :)
- gavinh 8y agoTLDR: Stephen Curry and Dwight Howard exchanged letters monthly between November 2014 and June 2018.
- kjeetgill 8y agoI've always been intrigued by, but never delved deeply enough into the depths of the more mathematical sides of programming. I've always wondered is there a good mathematical representation of an algorithm that is useful for algebraic manipulation? For example: Take an ugly equation like: x^2 + 3x+y+2+(−x)^2 = 3+(−x)^2 . It can be transformed to either (x+1)(x+2)-3 = y or y=−x^2−3x+1 fairly cleanly and usefully with just a few algebraic theorems. I remove redundancy among other things. Can I take "bubble sort" work my way in steps to produce a "quick sort" or a "merge sort"? Sure you could prove they produce identical results but it doesn't feel like you're bridging that gap. Maybe this is too vague a question.
- nilknarf 8y agoThe answer is surprisingly yes! It's usually called equational reasoning or Bird–Meertens formalism. Transforming an insertion sort into merge sort is covered in Section 5 of "FUNCTIONAL PEARLS The Third Homomorphism Theorem": http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.2247&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45....
- kjeetgill 8y agoI can't begin to explain how excited I am to delve into this! Thank you for the lead.
- yangzx 8y agoYou can have a look at Richard Bird's book _Pearls of Functional Algorithm Design_. It's much more accessible than his earlier influential book _Algebra of Programming_. In this book, many well-known algorithms, e.g. KMP pattern matching, are derived from naive implementations by step-by-step applications of algebraic rules of (functional) programs.
- kjeetgill 8y agoThanks!
- jgautsch 8y agoProfessor Philip Wadler has a fantastic talk titled "Propositions as Types" that introduces the Curry-Howard correspondence, some history behind it and ideas following it. In fact it's one of my favorite talks. Well worth a watch if you haven't seen it: https://www.youtube.com/watch?v=IOiZatlZtGU&t=1s https://www.youtube.com/watch?v=IOiZatlZtGU&t=1s
- galaxyLogic 8y agoSo proofs and programs are isomorphic. We know there are programs which never halt and we know there are programs for which we can not algorithmically decide whether they halt or not. What is the equivalent thing in proofs? Are there proofs which never halt? Is a proof really isomorphic with a program as written in source-code, or is it isomorphic with the EXECUTION of a program with a given input? A program and its execution are not the same thing are they? But with proofs I find it hard to think about the difference between the "source-code" of a proof and the "execution" of a proof. Is there such a thing as distinction between the execution of a proof and the "source-code" of it?
- IngoBlechschmid 8y ago> So proofs and programs are isomorphic. We know there are programs which never halt and we know there are programs for which we can not algorithmically decide whether they halt or not. What is the equivalent thing in proofs? Are there proofs which never halt? Yes; a "proof which never halts" is an invalid attempt at a proof (so not really a proof). To a first approximation, the Curry–Howard correspondence says that programming and proving are the same. This is literally true if "programming" and "proving" are restricted to mean more specific things. (There are many variants of the Curry–Howard correspondence. The simplest one relates "simply-typed lambda calculus" with "propositional intuitionistic logic". Simply-typed lambda calculus is basically what you get when you take Python, strip everything away except for the keyword "lambda", and add types. Intuitionistic propositional logic is basically what you get when you take ordinary logical reasoning, strip away quantifiers ("for all", "there exists") and force yourself to never use proof by contradiction. There are also variants for more powerful programming languages and more powerful logics. The case of classical logic, where we can use proof by contradiction, is particularly interesting, since the translations of such proofs make use of continuations. See https://rawgit.com/iblech/talk-constructive-mathematics/master/negneg-translation.pdf. https://rawgit.com/iblech/talk-constructive-mathematics/mast...) But in a wider sense it's false: Invalid proves aren't very much worthwhile, while non-terminating programs can be. Thus a better approximation is "programming strictly encompasses proving". > Is a proof really isomorphic with a program as written in source-code, or is it isomorphic with the EXECUTION of a program with a given input? The former. > A program and its execution are not the same thing are they? Correct. A program is a piece of a text. Its execution is (for me, in this context) the final value computed by the program. (The Curry–Howard correspondence is easiest to understand when we restrict to programs in a purely-functional programming language like Haskell.) > But with proofs I find it hard to think about the difference between the "source-code" of a proof and the "execution" of a proof. Is there such a thing as distinction between the execution of a proof and the "source-code" of it? I'm with you; the reason the difference is hard to see is because while we run programs all the time, we almost never run proofs. However, yes, indeed, you can run proofs. The result will be a "proof certificate", something like a proof with all intermediate definitions unrolled and then maximally simplified. Quite different-looking proofs (texts) can yield the same "proof certificate" when ran, exactly as different-looking source codes can yield the same final value when ran. Here is an example. Consider the following proof (due to Euclid) of the fact that there is a prime number greater than 6: "Like any positive natural number, the number N = 1⋅2⋅3⋅4⋅5⋅6 + 1 is a product of prime numbers. However, no number between 2 and 6 is a factor of N, since dividing N by any such number will always leave a remainder of one. Hence all the prime factors of N, for definiteness pick the smallest one, are prime numbers greater than 6." The proof certificate obtained by running this proof will be the pair (7,...), where "..." is a certificate that the number 7 is indeed prime. The reason the number 7 appears here is because 1⋅2⋅3⋅4⋅5⋅6 + 1 = 721 = 7 * 103. If the proof picked the largest factor instead of the smallest, the result of the proof would be the pair (103,...) (with a different primality certificate). Running proofs is becoming a more important thing nowadays, thanks to the development of good proof assistants and homotopy type theory. (While in principle it's possible run proofs manually, like in the previous paragraph, it's only fun when a computer does it for you.) For instance, a mathematician might prove that some particular structure of interest only contains finitely many elements, without having a clue how many values there are. If she runs the proof, the computer will tell her the answer. The catch is that with current (mathematical) technology, she might have to wait quite a bit for the answer. (The in my circles famous "Brunerie two" comes to mind: This is a proof where we know the answer to be the number 2, and made much progress in pimping the Curry–Howard correspondence, but aren't quite there yet. See https://guillaumebrunerie.github.io/pdf/cubicalexperiments.pdf. https://guillaumebrunerie.github.io/pdf/cubicalexperiments.p...)
- foxes 8y agoThere is a nice blog with a lot of resources on this topic http://therisingsea.org/post/seminar-ch/ http://therisingsea.org/post/seminar-ch/