Which is the Curry-Howard correspondent of double negation of a
; (a -> r) -> r
or (a -> ⊥) -> ⊥
, or both?
Both types can be encoded in Haskell as follows, where ⊥
is encoded as forall b. b
.
p1 :: forall r. ((a -> r) -> r)
p2 :: (a -> (forall b. b)) -> (forall b. b)
Paper by Wadler 2003 as well as implementation in Haskell seem to adopt the former, while some other literature (e.g. this) seems to support the latter.
My current understanding is that the latter is correct. I have difficulty in understanding the former style, since you can create a value of type a
from forall r. ((a -> r) -> r)
using pure computation:
> let p1 = ($42) :: forall r. (Int -> r) -> r
> p1 id
42
which seems to contradict with intuitionistic logic that you cannot derive a
from ¬¬a
.
So, my question is: can p1
and p2
both be regarded as Curry-Howard correspondent of ¬¬a
? If so, how does the fact that we can construct p1 id :: a
interact with the intuitionistic logic?
I have come up with clearer encoding of conversion to/from double negation, for convenience of discussion. Thanks to @user2407038 !
{-# LANGUAGE RankNTypes #-}
to_double_neg :: forall a. a -> (forall r. (a->r)->r)
to_double_neg x = ($x)
from_double_neg :: forall a. (forall r. (a->r)->r) -> a
from_double_neg x = x id
Void
as in en.wikibooks.org/wiki/Haskell/…. – Harrietharriett