Abella logo (small)

subst.thm

%% Correctness for LLambda subst predicate Specification "subst". Define ctx : olist -> olist -> prop by ctx nil nil ; ctx (term X :: L) (copy X X :: K) := ctx L K. Theorem ctx_member1 : forall L K E, ctx L K -> member E L -> exists T, E = term T /\ member (copy T T) K. IH : induction on 1. intros Hctx Hmem. case Hctx. - case Hmem. - Hctx => case Hmem. + search. + Hmem => apply IH to Hctx Hmem. search. Theorem ctx_member2 : forall L K E, ctx L K -> member E K -> exists T, E = copy T T. IH : induction on 1. intros Hctx Hmem. case Hctx. - case Hmem. - Hctx => case Hmem. + search. + Hmem => apply IH to Hctx Hmem. search. Theorem copy_id : forall L K T, ctx L K -> {L |- term T} -> {K |- copy T T}. IH : induction on 2. intros Hctx Hterm. case Hterm. - HtermM HtermN => apply IH to Hctx HtermM. apply IH to Hctx HtermN. search. - Hterm => apply IH to _ Hterm. search. - Hterm Hmem => apply ctx_member1 to Hctx Hmem. case Hterm. search. Theorem copy_eq : forall L K T S, ctx L K -> {K |- copy T S} -> T = S. IH : induction on 2. intros Hctx Hcopy. case Hcopy. - HcopyN HcopyM => apply IH to Hctx HcopyN. apply IH to Hctx HcopyM. search. - Hcopy => apply IH to _ Hcopy. search. - Hcopy Hmem => apply ctx_member2 to Hctx Hmem. case Hcopy. search. Theorem subst : forall R T S, {term T} -> {subst R T S} -> R T = S. intros !_ !T Hterm Hsubst. HsubstBody : case Hsubst. HcopyT : apply copy_id to _ Hterm. HcopyInst : inst HsubstBody with n1 = T. HcopyR : cut HcopyInst with HcopyT. apply copy_eq to _ HcopyR. search.