命题(P -> Q) -> Q
和P \/ Q
是等价的。
有没有办法在Haskell中见证这种等效性:
from :: Either a b -> ((a -> b) -> b)
from x = case x of
Left a -> \f -> f a
Right b -> \f -> b
to :: ((a -> b) -> b) -> Either a b
to = ???
这样
from . to = id
和to . from = id
?
g = const someHardcodedB
a
或b
。说得通。
to f = callcc (\k -> k (Right (f (\a -> k (Left a)))))
可以使用。(这是含蓄的经典证明。)
((a -> b) -> b)
同构为a
:唯一可能的实现是g f = f someHardcodedA
。