So you want to build a mainstream formally verifiable language (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
Another difficulty is with programming, we succeed by making abstractions that don't leak, where with math we're constantly opening up mathematical objects and messing around with their internals, chaining together the internals with theorems to get to our desired outcome.
Since we so often need access to the guts of the objects we're working with to prove facts, it makes it really hard to interoperate with other systems, because either we have to make assumptions about those systems which can compromise correctness or we have to be able to plug in all the way.
Signed, an undergrad in math with decent coding experience.
Replies (7)
I'd sum it up as starting to code before/without trying to get a proper* understanding of the end-to-end problem, and then incrementally adjusting along the way. This often solves a chicken and egg problem, of not being able to advance understanding before building. The problem is not rewriting or fully refactoring the code once your understanding persist. Often this is too late (aka "shipping the prototype"). Then everything expands into more complexity over more or less** time.
I think this whole process can actually be described formally. I'm not sure how much it matters anymore, but I suspect agent generated code suffers from the same issue, just with different measures due to speed/memory advantages agents have.
----
* I say "proper" assuming "full" is likely unachievable in most settings
** the difference between many software projects can be reduced to how fast they become dead ends based on how fast complexity explodes.
Replies (1)
That's good but it doesn't prove your point, or any point for that matter.
> I'd sum it up as starting to code before/without trying to get a proper* understanding... [chicken, egg, omelet] ... > I think this whole process can actually be described formally.
I'm not sure why anyone in his right mind would want to describe formally this entire process. Formal verification proves the correctness of the code produced by this process, not the process itself - and correctness is always provable, if in fact the code is correct.
So, we basically fail then.
you usually define the internals of your mathematical object based on the requirements of the 'rest of the system' and then you study the objects a lot to see it they even make sense or collapse.
As soon as you have an object that does not collapse, you know you can use it.
Take for example measure theory, you start with the basics axioms that are there to make the measure useful to others, then, based on the axioms you derive everything that you need to ensure that it's well defined, and then some more theorems that are like glue code to be able to use that measure for particular cases.
In this view, the axioms are your basic API, and the 'glue' theorems for an application are your frameworks.
Now a big difference between maths and programming is that maths is way bigger and more complex though
I also somewhat disagree with you about abstraction. In programming as well we move "up and down the ladder of abstraction", which means opening up objects and revisiting how we've built their abstractions. If you're doing performance work or debugging, while you don't exactly IGNORE abstractions, you're definitely opening them up.
Signed, professional software engineer with math degrees. :)
Replies (1)
Of course, when I have a good design for a program I also have a mental map of how it all connects, but the methods I use to morph a problem in programming is sequential and directed in a way, where proof by contradiction or contrapositive feels very different.
The idea of making abstractions comes from mathematics. The entire field of algebra is just abstractions. Algebraists think about the group, the ring, the field rather than the underlying objects. These abstractions absolutely don’t leak. These are some of the most elegant abstractions available, and this style of abstractions is known as type classes (in Haskell) or traits (in Rust), and is far superior to programmer-derived object-oriented abstractions. Why do most programmers create abstractions that leak? Because they are only taught object-oriented programming and yet without even learning about the Liskov substitution principle.
Replies (1)
I'm aware about bidirectional implication, but that's not quite what I'm getting at. With programming I think in terms of starting with some input data, successively applying calculations, and then ending with a result. There's a step-by-stepness to it. With math I have to think of it existing in all ways, simultaneously. Equality works both directions, but variable assignment doesn't. Math functions go both ways (at least when they're bijective), but programming functions only go one way. Maybe I haven't done enough math yet, but it hurts my brain in ways that programming never has. I don't usually program contrapositively or by contradiction.
And it's true that math arguments are presented linearly, but that's because there's not really another way. I have to reconstruct the mathematical framework from the linear presentation, but it hardly feels linear once it's all brought together in my head.
> The entire field of algebra is just abstractions.
I'm afraid I haven't taken abstract algebra yet, that'll be next semester! But I hadn't considered about how algebra works with objects that satisfy certain properties, so I'm glad you've brought that up. Thus far I've mainly been done proofs in linear algebra and my intro to proofs class, so that certainly colors my understanding.
Replies (2)
Equality works both directions in math just as it does in programming (the == operator in popular languages). Variable assignments don’t because they model definitions. The only difference is referential transparency, which is not required in most programming languages but a good thing to have (say in Haskell).
I do use contrapositivity occasionally when programming, but I don’t use proof by contradiction. This is actually interesting because proof by contradiction is inherently non-constructive: it can be used to prove the existence of things without a way to compute them. I do think restricting math to what’s computable makes things much easier and makes students’ brain hurt less, but it is also a lot less interesting.
Good luck!
The state space of a program is given by the cartesian product of all the types (i.e. sets) of its variables (global+those in current frame/scope). If you know your Relational Algebra (from RDBMS theory) you can see that this program state space is a relational table of n-ary tuples. You then write out predicates (i.e. precondition) which select a subset of the above tuples based on relationships between the variables. Your program statement acts on this subset to produce another subset of tuples which is asserted by another predicate (i.e. postcondition). Your program statement between the pre and post simply maps between the two subsets (either pre to post or post to pre). So mathematically your program is just a sequence of predicates (pre and post) asserting subsets from the global state space which is progressively transformed to give you your final result.
To understand how logical deduction is used to verify programs in a "correct-by-construction" approach (the above state space predicate transformer), see the seminal papers; Assigning Meanings to Programs by Floyd, An Axiomatic Basis for Computer Programming by Hoare and Guarded commands, Nondeterminacy and Formal derivation of Programs by Dijkstra.
For understanding how abstract algebra maps to programming see From Mathematics to Generic Programming by Stepanov and Rose. Basically your program implements a "Model" of an algebraic "Theory" - https://www.fm2gp.com/
Replies (1)