如何解决此Haskell代码中的skolemization错误?

时间:2017-07-07 22:27:15

标签: haskell existential-type rank-n-types

我有以下Haskell代码

{-# LANGUAGE RankNTypes, TypeOperators, ExistentialQuantification #-}

newtype Forall p = Forall (forall a. p a)
data Exists p = forall a. Exists !(p a)

newtype p :-> b = ForallFun (forall a. p a -> b)
data b :~> p = forall a. ExistsFun !(b -> p a)

newtype EmuExists p = EmuExists (forall b. (p :-> b) -> b)
data EmuForall p = forall b. EmuForall b (b :~> p)

toEmuForall :: Forall p -> EmuForall p
toEmuForall (Forall x) = EmuForall x (ExistsFun (\y -> y))

toEmuExists :: Exists p -> EmuExists p
toEmuExists (Exists x) = EmuExists (\(ForallFun f) -> f x)

fromEmuForall :: EmuForall p -> Forall p
fromEmuForall (EmuForall x (ExistsFun f)) = Forall (f x)

fromEmuExists :: EmuExists p -> Exists p
fromEmuExists (EmuExists f) = Exists (f (ForallFun (\x -> x)))

我试图使用逻辑公式

来模拟存在量化方面的通用量化
(∀a. P(a) → b) → b = ∃a. P(a)

我认为双重公式是:

∀a. P(a) = ∃b. b ∧ (∃a. b → P(a))

但是我无法让函数起作用。

0 个答案:

没有答案