733 works via \emph{higher-order backchaining}, which involves |
733 works via \emph{higher-order backchaining}, which involves |
734 unification module @{text "\<alpha>\<beta>\<eta>"}-conversion of @{text "\<lambda>"}-terms, |
734 unification module @{text "\<alpha>\<beta>\<eta>"}-conversion of @{text "\<lambda>"}-terms, |
735 and so-called \emph{lifting} of rules into a context of @{text "\<And>"} |
735 and so-called \emph{lifting} of rules into a context of @{text "\<And>"} |
736 and @{text "\<Longrightarrow>"} connectives. Thus the full power of higher-order |
736 and @{text "\<Longrightarrow>"} connectives. Thus the full power of higher-order |
737 natural deduction in Isabelle/Pure becomes readily available. |
737 natural deduction in Isabelle/Pure becomes readily available. |
738 |
738 *} |
|
739 |
|
740 |
|
741 subsection {* Hereditary Harrop Formulae *} |
|
742 |
|
743 text {* |
739 The idea of object-level rules is to model Natural Deduction |
744 The idea of object-level rules is to model Natural Deduction |
740 inferences in the style of Gentzen \cite{Gentzen:1935}, but we allow |
745 inferences in the style of Gentzen \cite{Gentzen:1935}, but we allow |
741 arbitrary nesting similar to \cite{extensions91}. The most basic |
746 arbitrary nesting similar to \cite{extensions91}. The most basic |
742 rule format is that of a \emph{Horn Clause}: |
747 rule format is that of a \emph{Horn Clause}: |
743 \[ |
748 \[ |
749 object-level inference corresponds to an iterated implication in |
754 object-level inference corresponds to an iterated implication in |
750 Pure like this: |
755 Pure like this: |
751 \[ |
756 \[ |
752 @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> A"} |
757 @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> A"} |
753 \] |
758 \] |
754 Any parameters occurring in rule statement are conceptionally |
759 As an example consider conjunction introduction: @{text "A \<Longrightarrow> B \<Longrightarrow> A \<and> |
755 treated as arbitrary: |
760 B"}. Any parameters occurring in such rule statements are |
756 \[ |
761 conceptionally treated as arbitrary: |
757 @{text "\<And>x\<^sub>1 \<dots> x\<^sub>m. A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> A"} |
762 \[ |
758 \] |
763 @{text "\<And>x\<^sub>1 \<dots> x\<^sub>m. A\<^sub>1 x\<^sub>1 \<dots> x\<^sub>m \<Longrightarrow> \<dots> A\<^sub>n x\<^sub>1 \<dots> x\<^sub>m \<Longrightarrow> A x\<^sub>1 \<dots> x\<^sub>m"} |
759 This outermost quantifier prefix via is represented in Isabelle via |
764 \] |
760 schematic variables @{text "?x\<^sub>1, \<dots>, ?x\<^sub>m"} occurring in |
765 |
761 the statement body. Note that this representation lacks information |
766 Nesting of rules means that the positions of @{text "A\<^sub>i"} may |
762 about the order of parameters, and vacuous quantifiers disappear |
767 hold compound rules of the same shape, not just atomic propositions. |
763 automatically. |
768 Propositions of this format are called \emph{Hereditary Harrop |
764 |
769 Formulae} in the literature \cite{Miller:1991}. Here we give an |
765 \medskip Nesting of rules means that the positions of @{text |
770 inductive characterization as follows: |
766 "A\<^sub>i"} may hold recursively rules of the same shape, not just |
|
767 atomic propositions. This format is called \emph{Hereditary Harrop |
|
768 Form} in the literature \cite{Miller:1991} and may be characterized |
|
769 inductively as follows: |
|
770 |
771 |
771 \medskip |
772 \medskip |
772 \begin{tabular}{ll} |
773 \begin{tabular}{ll} |
773 @{text "\<^bold>x"} & set of variables \\ |
774 @{text "\<^bold>x"} & set of variables \\ |
774 @{text "\<^bold>A"} & set of atomic propositions \\ |
775 @{text "\<^bold>A"} & set of atomic propositions \\ |
775 @{text "\<^bold>H = \<And>\<^bold>x\<^sup>*. \<^bold>H\<^sup>* \<Longrightarrow> \<^bold>A"} & set of Hereditary Harrop Formulas \\ |
776 @{text "\<^bold>H = \<And>\<^bold>x\<^sup>*. \<^bold>H\<^sup>* \<Longrightarrow> \<^bold>A"} & set of Hereditary Harrop Formulas \\ |
776 \end{tabular} |
777 \end{tabular} |
777 \medskip |
778 \medskip |
778 |
779 |
779 \noindent Due to @{prop "(PROP A \<Longrightarrow> (\<And>x. PROP B x)) \<equiv> (\<And>x. PROP A \<Longrightarrow> |
780 \noindent Thus we essentially impose nesting levels on Pure |
780 PROP B x)"} any Pure proposition can be seen a rule in HHF format. |
781 propositions. At each level there is a local parameter prefix, |
781 Some operations in Isabelle already work modulo that equivalence, in |
782 followed by premises, and concluding another atomic proposition. |
782 other places results are explicitly put into canonical form (e.g.\ |
783 Typical examples are implication introduction @{text "(A \<Longrightarrow> B) \<Longrightarrow> A \<longrightarrow> |
783 when exporting results, notably at the end of a proof). Regular |
784 B"} or mathematical induction @{text "P 0 \<Longrightarrow> (\<And>n. P n \<Longrightarrow> P (Suc n)) \<Longrightarrow> |
784 user-level results should always be in canonical HHF format. |
785 P n"}. Even deeper nesting occurs in well-founded induction @{text |
785 |
786 "(\<And>x. (\<And>y. y \<prec> x \<Longrightarrow> P y) \<Longrightarrow> P x) \<Longrightarrow> P x"}, but this already marks the |
|
787 limit of rule complexity seen in practice. |
|
788 |
|
789 \medskip The main inference system of Isabelle/Pure always maintains |
|
790 the following canonical form of framework propositions: |
|
791 |
|
792 \begin{itemize} |
|
793 |
|
794 \item Results are normalized by means of the equivalence @{prop |
|
795 "(PROP A \<Longrightarrow> (\<And>x. PROP B x)) \<equiv> (\<And>x. PROP A \<Longrightarrow> PROP B x)"}, which is a |
|
796 theorem of Pure. By pushing quantifiers inside conclusions in front |
|
797 of the implication, we arrive at a normal form that is always a |
|
798 Hereditary Harrop Formula. |
|
799 |
|
800 \item The outermost prefix of parameters is represented via |
|
801 schematic variables, i.e.\ instead of @{text "\<And>\<^vec>x. \<^vec>H |
|
802 \<^vec>x \<Longrightarrow> A \<^vec>x"} we always work with @{text "\<^vec>H |
|
803 ?\<^vec>x \<Longrightarrow> A ?\<^vec>x"}. Note that this representation looses |
|
804 information about the order of parameters, and vacuous quantifiers |
|
805 vanish automatically. |
|
806 |
|
807 \end{itemize} |
|
808 *} |
|
809 |
|
810 |
|
811 subsection {* Rule composition *} |
|
812 |
|
813 text {* |
786 There are two main principles of rule composition: @{inference |
814 There are two main principles of rule composition: @{inference |
787 resolution} (i.e.\ backchaining of rules) and @{inference |
815 resolution} (i.e.\ backchaining of rules) and @{inference |
788 assumption} (i.e.\ closing a branch); both principles are combined |
816 assumption} (i.e.\ closing a branch); both principles are combined |
789 in the variants of @{inference elim_resolution} and @{inference |
817 in the variants of @{inference elim_resolution} and @{inference |
790 dest_resolution}. Raw @{inference composition} is occasionally |
818 dest_resolution}. Raw @{inference composition} is occasionally |