Yoneda embedding as contrapositive and call-cc as double negation
Consider the problem of how to represent negation of a proposition when we only have implication and falsehood:
Since is true and
is false, this does what we want.
The contrapositive says has the same truth value as
Using only implication, the contrapositive of
is
What if we don’t even have falsehood? Well, we can pick any proposition to represent falsehood and form
The Yoneda embedding takes a category and produces a category
:
This embedding is better known among computer scientists as the continuation passing style transformation.
In a symmetric monoidal closed category, like lambda calculus, we can move everything “inside:” every morphism has an internal version
The internal Yoneda embedding of
is
Here is the “unit” type; notice how the target type is isomorphic under the Curry-Howard isomorphism to the contrapositive. This is a term that maps a continuation
and a value
to
To get double negation, first do the Yoneda embedding on the identity to get
then uncurry, braid, and recurry to get
or, internally,
This takes a value to a function value
Call-with-current-continuation expects a term that has been converted to CPS style as above, and then hands it the remainder of the computation in
I believe you have a typo on the third line. While “F -> T” is certainly true, it would make more sense to mention that “F -> F” is true.
Good catch, thanks! Fixed.