我想将依赖类型定义为eqType
. 例如,假设我们定义了以下依赖类型Tn
:
From mathcomp Require Import all_ssreflect.
Variable T: nat -> eqType.
Inductive Tn: Type := BuildT: forall n, T n -> Tn.
为了做到这一点,我为eqType
定义了一个相等函数:Tn_eq
Tn
Definition Tn_eq: rel Tn :=
fun '(BuildT n1 t1) '(BuildT n2 t2) =>
(if n1 == n2 as b return (n1==n2) = b -> bool
then fun E => t1 == eq_rect_r T t2 (elimTF eqP E)
else fun _ => false) (erefl (n1 == n2)).
然后我试图证明相等公理,Tn_eq
但它失败了。
Lemma Tn_eqP: Equality.axiom Tn_eq.
Proof.
case=>n1 t1; case=>n2 t2//=.
case_eq(n1==n2).
我在这里有一个错误:
Illegal application:
The term "elimTF" of type
"forall (P : Prop) (b c : bool), reflect P b -> b = c -> if c then P else ~ P"
cannot be applied to the terms
"n1 = n2" : "Prop"
"b" : "bool"
"true" : "bool"
"eqP" : "reflect (n1 = n2) (n1 == n2)"
"E" : "b = true"
The 4th term has type "reflect (n1 = n2) (n1 == n2)" which should be coercible to
"reflect (n1 = n2) b".
我应该如何证明这个引理?