TITLE: Under the Curry-Howard correspondence or loosely "proofs-as-programs", do we also have "programs-as-proofs" and what would some arb. program prove?
QUESTION [36 upvotes]: Curry-Howard Correspondence
Now, pick any 5-30 line algorithm in some programming language of choice.

What is the program proving?  Or, do we not also have "programs-as-proofs"?

Take the GCD algorithm written in pseudo-code:
function gcd(a, b)
    while b ≠ 0
        t := b
        b := a mod b
        a := t
    return a

What is it proving? I apologize for the broad and softness of this question, but I'm really wondering about it.

REPLY [2 votes]: Let $M$ be the measured memory space of a machine running a program written in language $L$, $M$ can be $\Bbb{Z}/2^{32}$ or a standard $\text{int}$ datatype on many machines.  Or it might be $\prod_{i=1}^n(\Bbb{Z}/2^{32})$ for some $n \geq 1$.
This is a good measure of what the program does: the program acts on the registers, cache, memory, storage of a machine, and that pretty much covers everything.  In order to write to a port, you would use one of the above, e.g.
So then a program taking the datatype $M$ as input and doubling it (modulo $2^{32}$) looks like this in Python:
(Let's assume Python has int32's and not arbitrary precision integers, which it does by default in the standard CPython release.)
a = int(input("a="))
a = a << 1

Call with python double_int.py 2.  I know there's no output to the program, but this is for a theoretical argument.  So a program $f$ takes a machine in measured state $m \in M$ and mutates the machine so that it's in measured state $f(m) \in M$.
I want to say that a program constitutes an implementation of an algororithm $A$ such that if you run the program $f$ on its (necessarily finite but sometimes huge, memory space $M$), i.e. you compute $f(m)$ for all $m \in M$ and manually check the result, or the result against a trusted other program's result (unit testing), and the result checks out, then the program is a proof that $A$ is realizeable in the language $L$, and that $A$ is indeed a valid algorithm computing what it's stated to.
Thus when $|M| \lt \approx 10^{9}$ and it runs in $\log(m)$ time or lower, one can check within a few seconds to an hour, a "proof of algorithm $A$" using the machine $M$, and the program $f$.