I am using the Coq Proof Assistant to implement a model of a (small) programming language (extending an implementation of Featherweight Java by Bruno De Fraine, Erik Ernst, Mario Südholt). One thing that keeps coming up when using the induction
tactic is how to preserve the information wrapped in type constructors.
I have a sub typing Prop implemented as
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.
where extends
is the class extension mechanism as seen in Java, and typ
represents the two different kinds of types available,
Inductive typ : Set :=
| c_typ : cname -> typ
| r_typ : rname -> typ.
An example of where I would like type information to be preserved is when using the induction
tactic on a hypothesis like
H: sub_type (c_typ u) (c_typ v)
E.g. in
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.
discards all information about u
and v
. The st_refl
case becomes
u : cname
v : cname
fsv : flds
t : typ
H0 : fields v fsv
============================
exists fs : flds, fields u (fsv ++ fs)
As you can see the information that u
and v
are related to the typ
constructors in H
, and thus to t
, is lost. What is worse is that due to this Coq is unable to see that u
and v
must in fact be the same in this case.
When using the inversion
tactic on H
Coq succeeds in seeing that u
and v
are the same. That tactic is not applicable here however, as I need the induction hypotheses that induction
generates to prove the st_trans
and st_extends
cases.
Is there a tactic that combines the best of inversion
and induction
to both generate induction hypotheses and derive equalities without destroying information about what is wrapped in the constructors? Alternatively, is there a way to manually derive the information I need? info inversion H
and info induction H
both show that a lot of transformations are applied automatically (especially with inversion
). These have led me to experiment with the change
tactic along with let ... in
construction, but without any progress.
generalize dependent H0. induction H.
help? It's all I can offer without having something I could feed to Coq myself (your question is missing more definitions than I care to fill out, I'm not familiar enough with Java's type system). – Enfold