我正在使用 Coq Proof Assistant 来实现(小型)编程语言的模型(扩展了 Bruno De Fraine、Erik Ernst、Mario Südholt 的 Featherweight Java 的实现)。使用该策略时不断出现的一件事induction
是如何保留包装在类型构造函数中的信息。
我有一个子类型 Prop 实现为
Inductive sub_type : typ -> typ -> Prop :=
| st_refl : forall t, sub_type t t
| st_trans : forall t1 t2 t3, sub_type t1 t2 -> sub_type t2 t3 -> sub_type t1 t3
| st_extends : forall C D,
extends C D ->
sub_type (c_typ C) (c_typ D).
Hint Constructors sub_type.
extends
Java 中的类扩展机制在哪里,typ
代表了两种不同的可用类型,
Inductive typ : Set :=
| c_typ : cname -> typ
| r_typ : rname -> typ.
我希望保留类型信息的一个例子是在induction
对一个假设使用该策略时,例如
H: sub_type (c_typ u) (c_typ v)
例如在
u : cname
v : cname
fsv : flds
H : sub_type (c_typ u) (c_typ v)
H0 : fields v fsv
============================
exists fs : flds, fields u (fsv ++ fs)
using丢弃有关和的induction H.
所有信息。案件变成u
v
st_refl
u : cname
v : cname
fsv : flds
t : typ
H0 : fields v fsv
============================
exists fs : flds, fields u (fsv ++ fs)
如您所见,与 中的构造函数相关的信息u
以及与中的构造函数相关的信息都丢失了。更糟糕的是,由于这个 Coq 无法看到这一点,并且在这种情况下实际上必须是相同的。v
typ
H
t
u
v
当inversion
在 Coq 上使用该策略时,H
成功地看到了这一点u
并且v
是相同的。然而,这种策略在这里并不适用,因为我需要induction
生成的归纳假设来证明st_trans
和st_extends
案例。
有没有一种策略可以结合最好的inversion
和induction
生成归纳假设并推导等式,而不会破坏有关构造函数中包含的内容的信息?或者,有没有办法手动获取我需要的信息?info inversion H
并且info induction H
两者都表明许多转换是自动应用的(尤其是使用inversion
)。这些使我在构建的同时尝试了该change
策略let ... in
,但没有任何进展。