ListP t
とListI t
同型です。これらのコンストラクタはまったく同じです。
<prompt>Coq < 12 || 0 < </prompt>Check (NilP, NilI).
(NilP, NilI)
: (forall t : Type, ListP t) *
(forall t : Type, ListI t)
<prompt>Coq < 13 || 0 < </prompt>Check (ConsP, ConsI).
(ConsP, ConsI)
: (forall t : Type, t -> ListP t -> ListP t) *
(forall t : Type, t -> ListI t -> ListI t)
ただし、Coqは異なる誘導原理を生成します。
<prompt>Coq < 14 || 0 < </prompt>Check (ListP_ind, ListI_ind).
(ListP_ind, ListI_ind)
: (forall (t : Type) (P : ListP t -> Prop),
P (NilP t) ->
(forall (t0 : t) (l : ListP t), P l -> P (ConsP t t0 l)) ->
forall l : ListP t, P l) *
(forall P : forall T : Type, ListI T -> Prop,
(forall t : Type, P t (NilI t)) ->
(forall (t : Type) (t0 : t) (l : ListI t),
P t l -> P t (ConsI t t0 l)) ->
forall (T : Type) (l : ListI T), P T l)
の誘導原理はListI
、要素タイプ(P : forall T, ListI T -> Prop
)でプロパティをパラメーター化する必要がありますが、の誘導原理はListP
任意のタイプt
(P : ListP t -> Prop
)でインスタンス化できます。これはCoqのフロントエンドの弱点であり、非均一な再帰型については賢くありません。手動で(それがされていることを与えられた驚くべきことではない型チェッカーはそれを受け入れ、同じ誘導原理定義することができますListP_ind
間の明白な同型によって変換さListP
とをListI
)。
パラメトリックフォームListP
はシンプルで、箱から出してすぐに使用できます。ListI
フォームは、再帰呼び出しのパラメータは、元のない不均一な再帰に一般化することができます。例については、ポリモーフィズムと帰納的データ型を参照してください。