我对coq很新颖,迄今为止我设法证明了我也可以通过手工证明的东西。所以当我遇到Selection monad并决定在haskell中实现它时,我认为这将是一个很好的练习,但我被卡住了。有人能提供一个coq证明的例子,说明选择monad是应用程序和monad吗?这是一个函数的haskell实现。Coq证明选择monad是应用程序和monad
newtype Sel r a = Sel { runSel :: (a -> r) -> a }
instance Functor (Sel r) where
fmap ab (Sel ara) = Sel (ab . ara . (. ab))
额外的感谢,如果你也能也证明了单子法律。
编辑:这是我的证明函子存在:
Definition sel (R A : Type) := (A -> R) -> A.
Theorem functor_exists : forall (R A B : Type),
(A -> B) -> sel R A -> sel R B.
intros R A B. unfold sel. intros AB ARA BR.
apply AB. apply ARA. intro. apply BR. apply AB. exact X.
Qed.
当我第一次开始使用勒柯克,我重新实现的定义和引理从这个[“教程”(https://pdp7.org/blog/2011/01/the-maybe-monad-in- coq /),然后切换到其他(更有趣)monad。 – ichistmeinname
我已经完成了这些,但我似乎无法做到超出这一点。我认为这对一个经验丰富的coq-ist来说很简单,这就是我发布的原因,但我可能是错的。 – fakedrake
但是我猜你可以提供Coq代码,这样你就可以看到你陷入困境的具体情况了吗? – ichistmeinname