PyR*_*lez 9 haskell functional-programming equality dependent-type morte
在语言,如Agda
,Idris
或Haskell
用类型扩展,有一种=
像以下类型排序
data a :~: b where
Refl :: a :~: a
Run Code Online (Sandbox Code Playgroud)
a :~: b
意味着a
和b
是一样的.
chi*_*chi 12
a :~: b
CoC 的标准教会编码是:
(a :~: b) =
forall (P :: * -> * -> *).
(forall c :: *. P c c) ->
P a b
Run Code Online (Sandbox Code Playgroud)
Refl
存在
Refl a :: a :~: a
Refl a =
\ (P :: * -> * -> *)
(h :: forall (c::*). P c c) ->
h a
Run Code Online (Sandbox Code Playgroud)
以上表示类型之间的相等性.对于术语之间的平等,:~:
关系必须采取额外的论证t :: *
,其中a b :: t
.
((:~:) t a b) =
forall (P :: t -> t -> *).
(forall c :: t. P c c) ->
P a b
Refl t a :: (:~:) t a a
Refl t a =
\ (P :: t -> t -> *)
(h :: forall (c :: t). P c c) ->
h a
Run Code Online (Sandbox Code Playgroud)