`Refl` thing in Calculus of Constructions?

2019-03-15 20:06发布

In languages such as Agda, Idris, or Haskell with type extensions, there is a = type sort of like the following

data a :~: b where
  Refl :: a :~: a

a :~: b means that a and b are the same.

Can such a type be defined in the calculus of constructions or Morte (which is programming language based on the calculus of construction)?

1条回答
三岁会撩人
2楼-- · 2019-03-15 21:00

The standard Church-encoding of a :~: b in CoC is:

(a :~: b) =
   forall (P :: * -> * -> *).
      (forall c :: *. P c c) ->
      P a b

Refl being

Refl a :: a :~: a
Refl a =
   \ (P :: * -> * -> *)
     (h :: forall (c::*). P c c) ->
     h a

The above formulates equality between types. For equality between terms, the :~: relation must take an additional argument t :: *, where 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
查看更多
登录 后发表回答