1

我有以下 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))

但我无法让 from 函数工作。

4

0 回答 0