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
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/