Abella logo (small)

normal.thm

%% Disjoint partitioning of lambda terms into normal and non-normal form %% The ctxs predicate encodes the relationship between the context %% of the judgements (term T) and (normal T). Specification "normal". Define name : tm -> prop by nabla x, name x. Define ctxs : olist -> olist -> prop by ctxs nil nil ; nabla x, ctxs (term x :: L) (neutral x :: K) := ctxs L K. %% Lemmas about contexts Theorem ctxs_member_term : forall L K E, ctxs L K -> member E L -> exists X, E = term X /\ member (neutral X) K /\ name X. IH : induction on 1. intros Hctxs Hmem. case Hctxs. - case Hmem. - HctxsTail => case Hmem. + search. + HmemTail => apply IH to HctxsTail HmemTail. search. Theorem ctxs_var : forall E L K, ctxs L K -> member E K -> exists X, E = neutral X /\ name X. IH : induction on 1. intros Hctxs Hmem. case Hctxs. - case Hmem. - HctxsTail => case Hmem. + search. + HmemTail => apply IH to HctxsTail HmemTail. search. %% Partitioning is total Theorem total_ext : forall T L K, ctxs L K -> {L |- term T} -> {K |- normal T} \/ {non_normal T}. IH : induction on 2. intros Hctxs Hterm. case Hterm. - HtermM HtermN => HdisjM : apply IH to Hctxs HtermM. HdisjN : apply IH to Hctxs HtermN. case HdisjM. + HnormM => case HdisjN. * HnormN => case HnormM. ++ search. ++ search. ++ HseqBack Hmem => HnameX : apply ctxs_var to Hctxs Hmem. case HseqBack. * search. + search. - HtermAbs => Hdisj : apply IH to _ HtermAbs. case Hdisj. + search. + search. - HtermBack Hmem => HtermX HmemNeut : apply ctxs_member_term to Hctxs Hmem. case HtermBack. search. Theorem total : forall T, {term T} -> {normal T} \/ {non_normal T}. intros Hterm. Hdisj : apply total_ext to _ Hterm. search. %% Partitioning is disjoint Theorem neutral_abs_absurd : forall L K R, ctxs L K -> {K |- neutral (abs R)} -> false. intros Hctxs Hneut. HseqBack Hmem : case Hneut. HnameX : apply ctxs_var to Hctxs Hmem. case HseqBack. case HnameX. Theorem disjoint_ext : forall L K T, ctxs L K -> {K |- normal T} -> {non_normal T} -> false. IH : induction on 3. intros Hctxs Hnorm HnonNorm. case Hnorm. - HnormAbsBody => HnonNormBody : case HnonNorm. apply IH to _ HnormAbsBody HnonNormBody. - Hneut => case Hneut. + HneutM HnormN => case HnonNorm. * apply neutral_abs_absurd to Hctxs HneutM. * HnonNormM => apply IH to Hctxs _ HnonNormM. * HnonNormN => apply IH to Hctxs HnormN HnonNormN. + HseqBack Hmem => HnameX : apply ctxs_var to Hctxs Hmem. case HnonNorm ; case HnameX ; case HseqBack. - HseqBack Hmem => HnameX : apply ctxs_var to Hctxs Hmem. case HseqBack. Theorem disjoint : forall T, {normal T} -> {non_normal T} -> false. intros Hnor Hnon. apply disjoint_ext to _ Hnor Hnon.