Unofficial Hacker News companion — get notified on comment replies, and more.

So you want to build a mainstream formally verifiable language (opens external site)

119 points by mpweiher 2 days ago | danilafe.com | 82 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (1)

  1. The key to connecting Mathematics to Programming is to study Set Theory/Predicate Calculus and think of your program statement as a "Predicate Transformer" (https://en.wikipedia.org/wiki/Predicate_transformer_semantic...).

    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/