类型集的关联性证明

时间:2017-11-25 11:47:56

标签: haskell set proof type-level-computation associativity

我试图证明类型级函数Union是关联的,但我不确定它应该如何完成。我证明了对于联盟的类型级别追加函数和正确身份的正确的身份和关联法则:

data SList (i :: [k]) where
  SNil :: SList '[]
  SSucc :: SList t -> SList (h ': t)

appRightId :: SList xs -> xs :~: (xs :++ '[])
appRightId SNil       = Refl
appRightId (SSucc xs) = case appRightId xs of Refl -> Refl

appAssoc
  :: SList xs
  -> Proxy ys
  -> Proxy zs
  -> (xs :++ (ys :++ zs)) :~: ((xs :++ ys) :++ zs)
appAssoc SNil       _  _  = Refl
appAssoc (SSucc xs) ys zs = case appAssoc xs ys zs of Refl -> Refl

cong :: a :~: b -> f a :~: f b
cong Refl = Refl

unionRightId :: SList xs -> AsSet xs :~: Union xs '[]
unionRightId xs = case cong (appRightId xs) of Refl -> Refl

但我不知道如何证明联盟是联想的。

0 个答案:

没有答案