Abella logo (small)

hh_meta.thm

% Meta-theory of HH in G (Abella's reasoning logic) % Reasoning on multisets -- this is needed in the statement % of the cut theorem. % The definition (remove G A D) asserts that G is D extended with A. Define remove : list T -> T -> list T -> prop by remove (A :: G) A G ; remove (B :: G) A (B :: D) := remove G A D. % If G is an extension of D, then all members of D are also members of G. Theorem remove_incl[T] : forall G D (A : T) B, remove G A D -> member B D -> member B G. IH : induction on 1. intros Hrem Hmem. case Hrem. - search. - Hsub => case Hmem. + search. + Hmem => apply IH to Hsub Hmem. search. % If G is D extended with A, then any member of G is either A or a % member of D. Theorem remove_charac[T] : forall G (A : T) D B, remove G A D -> member B G -> A = B \/ member B D. IH : induction on 1. intros Hrem Hmem. case Hrem (keep). - case Hmem ; search. - Hsub => case Hmem. + search. + Hmem => Hdisj : apply IH to Hsub Hmem. case Hdisj ; search. % Types of formulas and terms Kind fm, tm type. % Terms are left abstract, while formulas have the following constructors Type atm tm -> fm. Type and fm -> fm -> fm. Type top fm. Type imp fm -> fm -> fm. Type all (tm -> fm) -> fm. % We will need to induct on the structure of formulas, so we write % an inductive definition of all formulas. Define is_fm : fm -> prop by is_fm (atm A) ; is_fm (and A B) := is_fm A /\ is_fm B ; is_fm top ; is_fm (imp A B) := is_fm A /\ is_fm B ; is_fm (all A) := forall x, is_fm (A x). % We keep the prog definition abstract. Type prog fm -> prop. % We have to assume that any prog clause is independent of nabla in % order for instantiation to be sound. We state this as an axiom. Axiom prog_has_no_nablas : forall F, nabla (n:tm), prog (F n) -> exists E, F = x\ E. % The backchaining calculus consists of two phases: seq and bch % % bch L F A stands for L ; [F] |- A (F backchainied) % seq L G stands for L |- G Define seq : list fm -> fm -> prop, bch : list fm -> fm -> tm -> prop by seq L (atm A) := exists F, member F L /\ bch L F A ; seq L (atm A) := exists F, prog F /\ bch L F A ; seq L (and G1 G2) := seq L G1 /\ seq L G2 ; seq L top ; seq L (imp F G) := seq (F :: L) G ; seq L (all A) := nabla x, seq L (A x) ; bch L (atm A) A ; bch L (and F1 F2) A := bch L F1 A \/ bch L F2 A ; bch L (imp G F) A := seq L G /\ bch L F A ; bch L (all F) A := exists t, bch L (F t) A. % Note: the third argument to bch always represents an atom. % This is because the atomic formula P(t1, ..., tn) is represented as % (atm (P t1 ... tn)), where P has type (tm -> ... -> tm -> tm). Theorem $monotone : (forall L L' C, (forall E, member E L -> member E L') -> seq L C -> seq L' C) /\ (forall L L' F A, (forall E, member E L -> member E L') -> bch L F A -> bch L' F A). IHseq IHbch : induction on 2 2. split. - intros !L !L' Hsub Hseq. case Hseq (keep). + Hmem Hbch1 => apply IHbch to Hsub Hbch1. apply Hsub to Hmem. search. + Hprog Hbch2 => apply IHbch to Hsub Hbch2. search. + Hseq1 Hseq2 => apply IHseq to Hsub Hseq1. apply IHseq to Hsub Hseq2. search. + search. + !_ !F HseqImp => HsubExt : assert forall E, member E (F :: L) -> member E (F :: L'). * intros Hmem2. case Hmem2. ** search. ** Htail => apply Hsub to Htail. search. * apply IHseq to HsubExt HseqImp. search. + HseqAll => apply IHseq to Hsub HseqAll. search. - intros Hsub Hbch. case Hbch (keep). + search. + Hdisj => case Hdisj. * HbchA => apply IHbch to Hsub HbchA. search. * HbchB => apply IHbch to Hsub HbchB. search. + HseqG Hbch3 => apply IHseq to Hsub HseqG. apply IHbch to Hsub Hbch3. search. + Hbch4 => apply IHbch to Hsub Hbch4. search. Split $monotone as monotone_seq, monotone_bch. Theorem $weakening : (forall L L' B G, remove L' B L -> seq L G -> seq L' G) /\ (forall L L' B F A, remove L' B L -> bch L F A -> bch L' F A). split. - intros !L !L'. assert forall E, member E L -> member E L'. + intros. backchain remove_incl. + backchain monotone_seq. - intros !L !L'. assert forall E, member E L -> member E L'. + intros. backchain remove_incl. + backchain monotone_bch. Split $weakening as weakening_seq, weakening_bch. Theorem member_inst : forall F (L:tm -> list fm), nabla (n:tm), member (F n) (L n) -> forall t, member (F t) (L t). IH : induction on 1. intros !_ !_ !_ !t H1. case H1. - search. - H3 => H4 : apply IH to H3. apply H4 with t = t. search. % The instantiation lemma Theorem $inst : (forall L G, nabla (n:tm), seq (L n) (G n) -> forall t, seq (L t) (G t)) /\ (forall L F A, nabla (n:tm), bch (L n) (F n) (A n) -> forall t, bch (L t) (F t) (A t)). IH IH1 : induction on 1 1. split. - intros !_ !_ !_ !t Hseq. case Hseq. + Hmem Hbch => HbchI : apply IH1 to Hbch. HmemI : apply member_inst to Hmem. apply HbchI with t = t. apply HmemI with t = t. search. + Hprog HbchP => HbchI2 : apply IH1 to HbchP. apply prog_has_no_nablas to Hprog. apply HbchI2 with t = t. search. + Hseq1 Hseq2 => HseqI1 : apply IH to Hseq1. HseqI2 : apply IH to Hseq2. apply HseqI1 with t = t. apply HseqI2 with t = t. search. + search. + HseqImp => HseqImpI : apply IH to HseqImp. apply HseqImpI with t = t. search. + HseqAll => HseqAllI : apply IH to HseqAll. apply HseqAllI with t = t. search. - intros !_ !_ !_ !_ !t Hbch. case Hbch. + search. + Hdisj => case Hdisj. * Hdisj1 => HbchI1 : apply IH1 to Hdisj1. apply HbchI1 with t = t. search. * Hdisj2 => HbchI2b : apply IH1 to Hdisj2. apply HbchI2b with t = t. search. + HseqB HbchB => HseqBI : apply IH to HseqB. HbchBI : apply IH1 to HbchB. apply HseqBI with t = t. apply HbchBI with t = t. search. + HbchAll => HbchAllI2 : apply IH1 to HbchAll. apply HbchAllI2 with t = t. search. Split $inst as inst_seq, inst_bch. % The main cut-admissibility theorem. % We proceed by nested induction on: % % - the structure of the cut-formula, then % - the structure of the container derivation (i.e., the derivation % that contains the cut-formula as a hypothesis). Theorem $cut : (forall L K F G, is_fm F -> seq K F -> remove L F K -> seq L G -> seq K G) /\ (forall L K F F' A, is_fm F -> seq K F -> remove L F K -> bch L F' A -> bch K F' A) /\ (forall L F A, is_fm F -> seq L F -> bch L F A -> seq L (atm A)). IHcut IHcutBch IHcutPrin : induction on 1 1 1. IHseq IHbch IHprin : induction on 4 4 3. split. - intros !L !K !F HisFm HseqK Hrem HseqL. case HseqL (keep). + HmemL HbchL => HremDisj : apply remove_charac to Hrem HmemL. case HremDisj. * case HisFm (keep). -- case HbchL. search. -- HisFm1 HisFm2 => case HbchL (keep). HbchDisj => case HbchDisj. ++ HbchL1 => HbchK1 : apply IHbch to HisFm HseqK Hrem HbchL1. case HseqK. HseqK1 => apply IHcutPrin to HisFm1 HseqK1 HbchK1. search. ++ HbchL1 => HbchK1 : apply IHbch to HisFm HseqK Hrem HbchL1. case HseqK. _ HseqK2 => apply IHcutPrin to HisFm2 HseqK2 HbchK1. search. -- case HbchL. -- HisFm1 HisFm2 => case HbchL. HseqLImp HbchLImp => HseqKImp : apply IHseq to HisFm HseqK Hrem HseqLImp. HbchKImp : apply IHbch to HisFm HseqK Hrem HbchLImp. case HseqK (keep). HseqKImp2 => HcutTmp : apply IHcut to HisFm1 HseqKImp _ HseqKImp2. apply IHcutPrin to HisFm2 HcutTmp HbchKImp. search. -- HisFmAll => case HbchL. !t HbchAll => HbchKAll : apply IHbch to HisFm HseqK Hrem HbchAll. case HseqK. HseqKNabla => HseqKInst : apply inst_seq to HseqKNabla. HseqKInstT : apply HseqKInst with t = t. HinstApp : apply HisFmAll with x = t. apply IHcutPrin to HinstApp HseqKInstT HbchKAll. search. * apply IHbch to HisFm HseqK Hrem HbchL. search. + Hprog HbchL2 => apply IHbch to HisFm HseqK Hrem HbchL2. search. + HseqL1 HseqL2 => apply IHseq to HisFm HseqK Hrem HseqL1. apply IHseq to HisFm HseqK Hrem HseqL2. search. + search. + !_ !F1 HseqImp => HremExt : assert remove (F1 :: L) F (F1 :: K). HseqKExt : assert seq (F1 :: K) F. backchain weakening_seq. apply IHseq to HisFm HseqKExt HremExt HseqImp. search. + HseqAll => apply IHseq to HisFm HseqK Hrem HseqAll. search. - intros HisFm HseqK Hrem HbchL. case HbchL (keep). + search. + HbchDisj => case HbchDisj. * HbchL1 => apply IHbch to HisFm HseqK Hrem HbchL1. search. * HbchL1 => apply IHbch to HisFm HseqK Hrem HbchL1. search. + HseqLImp HbchLImp => apply IHseq to HisFm HseqK Hrem HseqLImp. apply IHbch to HisFm HseqK Hrem HbchLImp. search. + HbchEx => apply IHbch to HisFm HseqK Hrem HbchEx. search. - intros HisFm HseqL HbchL. case HbchL (keep). + search. + HbchDisj2 => case HbchDisj2. * HbchL1 => case HisFm (keep). HisFm1 => case HseqL (keep). HseqL1 => apply IHcutPrin to HisFm1 HseqL1 HbchL1. search. * HbchL1 => case HisFm (keep). _ HisFm2 => case HseqL (keep). _ HseqL2 => apply IHcutPrin to HisFm2 HseqL2 HbchL1. search. + HseqLImp2 HbchLImp2 => case HisFm (keep). HisFm1 HisFm2 => case HseqL (keep). HseqLExt => HcutMid : apply IHcut to HisFm1 HseqLImp2 _ HseqLExt. apply IHcutPrin to HisFm2 HcutMid HbchLImp2. search. + !t HbchEx2 => case HisFm (keep). HisFmAll => case HseqL (keep). HseqLNabla => HinstApp : apply HisFmAll with x = t. HseqLInst : apply inst_seq to HseqLNabla. HseqLInstT : apply HseqLInst with t = t. apply IHcutPrin to HinstApp HseqLInstT HbchEx2. search. Split $cut as cut, cut_commutative, cut_principal.