Some day, I'd love to write proofs instead of tests in some places.
Some day, I'd love to write proofs instead of tests in some places.
In my mind it would have to be built from the ground up, sub unit tests for function proofs and maintain 100% coverage as you go along. As long as the constituent parts are proven you don't have to zoom out to a macro level.
As an example, having proofs of various properties of strcat, strcpy, etc. will help less in large programs than having proofs for all Java’s methods on String. In the former, you’ll also have to proof that covers all accesses to your data. In the latter, the JVM guarantees that.
Writing the proofs is one thing but writing the automation that scales those proofs to a larger system and which makes it easy to extend the system without breaking the proofs constantly is key and requires more "engineering" focused people rather than proof-focused ones.
Believe my, you only want to do that if the proof assistent accepts "I leave the details as an exercise to the reader" ;)
It's become a running joke in my grad school of "when in doubt, there's always 'proof by sorry'".
I'm not as familiar with a lot of the other proof assistants but I suspect there are similar constructs?
I always thought that unsafe { .. } blocks in Rust should be called trustme { .. }
But sorry { .. } is even better!
The worst part is when you forget to remove a sorry (or three) because of a linked file you didn't check, and you submit stuff to other people on the team thinking you discovered something pretty cool, only to find out that you didn't actually prove anything.
This "function" has a superficial similarity to unsafePerformIO but it is in fact a malevolent agent of chaos. It unpicks the seams of reality (and the IO monad) so that the normal rules no longer apply. It lulls you into thinking it is reasonable, but when you are not looking it stabs you in the back and aliases all of your mutable buffers. The carcass of many a seasoned Haskell programmer lie strewn at its feet.I prefer the slightly more ominous "surely".
Of course, any junior member of a team that is willing to stand up and state that, no, the assertion is anything but obvious to them, should get an immediate promotion, and be quickly moved to another group!
I get the general complaint, though. I wish I could have the syntax-based interactive proof system everywhere.
- attempt a proof, could pass or fail, but if it times out, then fall back to...
- property-based test case generation, using logical statements and data generators, shrinking, etc.; many will pass, some will fail, but if some time out ...
- generate simple tests, and edge cases, which may trivially pass, but could be edited by hand to become more useful
If you add a timeout, then exponential runtimes, and even the Halting Problem, always give an answer, even if the answer is to try something simpler.
[Note that this meta-programming is very powerful, but also extremely hard to use from what I have managed to see; do not expect LISP style ergonomics here. It doesn't help that the meta-programming book shows some trivial examples of macro rules and then delves deep into proof tactics for the next 2 chapters, leaving the reader who wants general code transformations stranded].
In order to use Lean for proving properties for serious amounts of code, you need to write an entire tactics library similar to mathlib (but for code). Nobody has done this. Maybe it is reasonably hard, or maybe unreasonably hard; the point is, there is no serious collaborative effort that I know of.
The reason I code in Lean is because I find it fun, and I think it is a very nice general purpose language; for instance, I like Lean much better than Haskell. If Lean ever gets the libraries Haskell has, I will be really excited.
- I like Lean's inductive type system much better that Haskell's,
- I prefer eager evaluation by default,
- I like the syntax better,
- I like dependent types; they are dangerous, but it is great to have the option.
I suspect some people may also prefer Lean's macro system to Haskell's, but I haven't worked much with either, so I don't know about that.