Proof of associativity law for type-level set

不羁岁月 提交于 2020-01-02 07:55:10

问题


I'm trying to prove that type-level function Union is associative, but I'm not sure how it should be done. I proved right identity and associativity laws for type-level append function and right identity for 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

but I don't get how to prove that union is associative.

来源:https://stackoverflow.com/questions/47485615/proof-of-associativity-law-for-type-level-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!