Library Fsub_LetSum_Lemmas
Administrative lemmas for Fsub.
Authors: Brian Aydemir and Arthur Chargu\'eraud, with help from Aaron Bohannon, Jeffrey Vaughan, and Dimitrios Vytiniotis.
This file contains a number of administrative lemmas that we require for proving type-safety. The lemmas mainly concern the relations wf_typ and wf_env.
This file also contains regularity lemmas, which show that various relations hold only for locally closed terms. In addition to being necessary to complete the proof of type-safety, these lemmas help demonstrate that our definitions are correct; they would be worth proving even if they are unneeded for any "real" proofs.
Table of contents:
Authors: Brian Aydemir and Arthur Chargu\'eraud, with help from Aaron Bohannon, Jeffrey Vaughan, and Dimitrios Vytiniotis.
This file contains a number of administrative lemmas that we require for proving type-safety. The lemmas mainly concern the relations wf_typ and wf_env.
This file also contains regularity lemmas, which show that various relations hold only for locally closed terms. In addition to being necessary to complete the proof of type-safety, these lemmas help demonstrate that our definitions are correct; they would be worth proving even if they are unneeded for any "real" proofs.
Table of contents:
If a type is well-formed in an environment, then it is locally
closed.
The remaining properties are analogous to the properties that we
need to show for the subtyping and typing relations.
Lemma wf_typ_weakening : forall T E F G,
wf_typ (G ++ E) T ->
uniq (G ++ F ++ E) ->
wf_typ (G ++ F ++ E) T.
Lemma wf_typ_weaken_head : forall T E F,
wf_typ E T ->
uniq (F ++ E) ->
wf_typ (F ++ E) T.
Lemma wf_typ_narrowing : forall V U T E F X,
wf_typ (F ++ X ~ bind_sub V ++ E) T ->
wf_typ (F ++ X ~ bind_sub U ++ E) T.
Lemma wf_typ_strengthening : forall E F x U T,
wf_typ (F ++ x ~ bind_typ U ++ E) T ->
wf_typ (F ++ E) T.
Lemma wf_typ_subst_tb : forall F Q E Z P T,
wf_typ (F ++ Z ~ bind_sub Q ++ E) T ->
wf_typ E P ->
uniq (map (subst_tb Z P) F ++ E) ->
wf_typ (map (subst_tb Z P) F ++ E) (subst_tt Z P T).
Lemma wf_typ_open : forall E U T1 T2,
uniq E ->
wf_typ E (typ_all T1 T2) ->
wf_typ E U ->
wf_typ E (open_tt T2 U).
We add uniq_from_wf_env as a hint here since it helps blur the
distinction between wf_env and uniq in proofs. The lemmas in
the MetatheoryEnv library use uniq, whereas here we naturally
have (or can easily show) the stronger wf_env. Thus,
uniq_from_wf_env serves as a bridge that allows us to use the
environments library.
Hint Resolve uniq_from_wf_env.
Lemma wf_typ_from_binds_typ : forall x U E,
wf_env E ->
binds x (bind_typ U) E ->
wf_typ E U.
Lemma wf_typ_from_wf_env_typ : forall x T E,
wf_env (x ~ bind_typ T ++ E) ->
wf_typ E T.
Lemma wf_typ_from_wf_env_sub : forall x T E,
wf_env (x ~ bind_sub T ++ E) ->
wf_typ E T.
These properties are analogous to the properties that we need to
show for the subtyping and typing relations.
Lemma wf_env_narrowing : forall V E F U X,
wf_env (F ++ X ~ bind_sub V ++ E) ->
wf_typ E U ->
wf_env (F ++ X ~ bind_sub U ++ E).
Lemma wf_env_strengthening : forall x T E F,
wf_env (F ++ x ~ bind_typ T ++ E) ->
wf_env (F ++ E).
Lemma wf_env_subst_tb : forall Q Z P E F,
wf_env (F ++ Z ~ bind_sub Q ++ E) ->
wf_typ E P ->
wf_env (map (subst_tb Z P) F ++ E).
Lemma notin_fv_tt_open : forall (Y X : atom) T,
X `notin` fv_tt (open_tt T Y) ->
X `notin` fv_tt T.
Lemma notin_fv_wf : forall E (X : atom) T,
wf_typ E T ->
X `notin` dom E ->
X `notin` fv_tt T.
Lemma map_subst_tb_id : forall G Z P,
wf_env G ->
Z `notin` dom G ->
G = map (subst_tb Z P) G.
Lemma sub_regular : forall E S T,
sub E S T ->
wf_env E /\ wf_typ E S /\ wf_typ E T.
Lemma typing_regular : forall E e T,
typing E e T ->
wf_env E /\ expr e /\ wf_typ E T.
Lemma value_regular : forall e,
value e ->
expr e.
Lemma red_regular : forall e e',
red e e' ->
expr e /\ expr e'.
The lemma uniq_from_wf_env was already added above as a hint
since it helps blur the distinction between wf_env and uniq in
proofs.
As currently stated, the regularity lemmas are ill-suited to be used with auto and eauto since they end in conjunctions. Even if we were, for example, to split sub_regularity into three separate lemmas, the resulting lemmas would be usable only by eauto and there is no guarantee that eauto would be able to find proofs effectively. Thus, the hints below apply the regularity lemmas and type_from_wf_typ to discharge goals about local closure and well-formedness, but in such a way as to minimize proof search.
The first hint introduces an wf_env fact into the context. It works well when combined with the lemmas relating wf_env and wf_typ. We choose to use those lemmas explicitly via (auto using ...) tactics rather than add them as hints. When used this way, the explicitness makes the proof more informative rather than more cluttered (with useless details).
The other three hints try outright to solve their respective goals.
As currently stated, the regularity lemmas are ill-suited to be used with auto and eauto since they end in conjunctions. Even if we were, for example, to split sub_regularity into three separate lemmas, the resulting lemmas would be usable only by eauto and there is no guarantee that eauto would be able to find proofs effectively. Thus, the hints below apply the regularity lemmas and type_from_wf_typ to discharge goals about local closure and well-formedness, but in such a way as to minimize proof search.
The first hint introduces an wf_env fact into the context. It works well when combined with the lemmas relating wf_env and wf_typ. We choose to use those lemmas explicitly via (auto using ...) tactics rather than add them as hints. When used this way, the explicitness makes the proof more informative rather than more cluttered (with useless details).
The other three hints try outright to solve their respective goals.
Hint Extern 1 (wf_env ?E) =>
match goal with
| H: sub _ _ _ |- _ => apply (proj1 (sub_regular _ _ _ H))
| H: typing _ _ _ |- _ => apply (proj1 (typing_regular _ _ _ H))
end.
Hint Extern 1 (wf_typ ?E ?T) =>
match goal with
| H: typing E _ T |- _ => apply (proj2 (proj2 (typing_regular _ _ _ H)))
| H: sub E T _ |- _ => apply (proj1 (proj2 (sub_regular _ _ _ H)))
| H: sub E _ T |- _ => apply (proj2 (proj2 (sub_regular _ _ _ H)))
end.
Hint Extern 1 (type ?T) =>
let go E := apply (type_from_wf_typ E); auto in
match goal with
| H: typing ?E _ T |- _ => go E
| H: sub ?E T _ |- _ => go E
| H: sub ?E _ T |- _ => go E
end.
Hint Extern 1 (expr ?e) =>
match goal with
| H: typing _ ?e _ |- _ => apply (proj1 (proj2 (typing_regular _ _ _ H)))
| H: red ?e _ |- _ => apply (proj1 (red_regular _ _ H))
| H: red _ ?e |- _ => apply (proj2 (red_regular _ _ H))
end.
This page has been generated by coqdoc