Quotient-Paper/Paper.thy
changeset 2333 a0fecce8b244
parent 2332 9a560e489c64
child 2334 0d10196364aa
equal deleted inserted replaced
2332:9a560e489c64 2333:a0fecce8b244
    11 *
    11 *
    12 * - what are quot_thms?
    12 * - what are quot_thms?
    13 * - what do all preservation theorems look like,
    13 * - what do all preservation theorems look like,
    14     in particular preservation for quotient
    14     in particular preservation for quotient
    15     compositions
    15     compositions
       
    16   - explain how Quotient R Abs Rep is proved (j-version)
       
    17   - give an example where precise specification helps (core Haskell in nominal?)
    16 *)
    18 *)
    17 
    19 
    18 notation (latex output)
    20 notation (latex output)
    19   rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and
    21   rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and
    20   pred_comp ("_ \<circ>\<circ> _" [1, 1] 30) and
    22   pred_comp ("_ \<circ>\<circ> _" [1, 1] 30) and
   307   of terms that are constructed specially (namely through axioms and proof
   309   of terms that are constructed specially (namely through axioms and proof
   308   rules). As a result we are able to define automatic proof
   310   rules). As a result we are able to define automatic proof
   309   procedures showing that one theorem implies another by decomposing the term
   311   procedures showing that one theorem implies another by decomposing the term
   310   underlying the first theorem.
   312   underlying the first theorem.
   311 
   313 
   312   Like Homeier, our work relies on map-functions defined for every type
   314   Like Homeier's, our work relies on map-functions defined for every type
   313   constructor taking some arguments, for example @{text map} for lists. Homeier
   315   constructor taking some arguments, for example @{text map} for lists. Homeier
   314   describes in \cite{Homeier05} map-functions for products, sums, options and
   316   describes in \cite{Homeier05} map-functions for products, sums, options and
   315   also the following map for function types
   317   also the following map for function types
   316 
   318 
   317   @{thm [display, indent=10] fun_map_def[no_vars, THEN eq_reflection]}
   319   @{thm [display, indent=10] fun_map_def[no_vars, THEN eq_reflection]}
   388   \noindent
   390   \noindent
   389   As a result, Homeier is able to build an automatic prover that can nearly
   391   As a result, Homeier is able to build an automatic prover that can nearly
   390   always discharge a proof obligation involving @{text "Quotient"}. Our quotient
   392   always discharge a proof obligation involving @{text "Quotient"}. Our quotient
   391   package makes heavy 
   393   package makes heavy 
   392   use of this part of Homeier's work including an extension 
   394   use of this part of Homeier's work including an extension 
   393   to deal with compositions of equivalence relations defined as follows:
   395   for dealing with compositions of equivalence relations defined as follows:
   394 
   396 
   395   \begin{definition}[Composition of Relations]
   397   \begin{definition}[Composition of Relations]
   396   @{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate
   398   @{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate
   397   composition defined by 
   399   composition defined by 
   398   @{thm (concl) pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}
   400   @{thm (concl) pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}
   743   \end{isabelle}
   745   \end{isabelle}
   744 
   746 
   745   \noindent
   747   \noindent
   746   which is straightforward given the definition shown in \eqref{listequiv}.
   748   which is straightforward given the definition shown in \eqref{listequiv}.
   747 
   749 
   748   The second restriction we have to impose arises from
   750   The second restriction we have to impose arises from non-lifted polymorphic
   749   non-lifted polymorphic constants, which are instantiated to a
   751   constants, which are instantiated to a type being quotient. For example,
   750   type being quotient. For example, take the @{term "cons"}-constructor to 
   752   take the @{term "cons"}-constructor to add a pair of natural numbers to a
   751   add a pair of natural numbers to a list, whereby the pair of natural numbers 
   753   list, whereby we assume the pair of natural numbers turns into an integer in
   752   turns into an integer in the quotient construction. The point is that we 
   754   the quotient construction. The point is that we still want to use @{text
   753   still want to use @{text cons} for
   755   cons} for adding integers to lists---just with a different type. To be able
   754   adding integers to lists---just with a different type. 
   756   to lift such theorems, we need a \emph{preservation property} for @{text
   755   To be able to lift such theorems, we need a \emph{preservation property} 
   757   cons}. Assuming we have a polymorphic raw constant @{text "c\<^isub>r :: \<sigma>"}
   756   for @{text cons}. Assuming we have a polymorphic raw constant 
   758   and a corresponding quotient constant @{text "c\<^isub>q :: \<tau>"}, then a
   757   @{text "c\<^isub>r :: \<sigma>"} and a corresponding quotient constant @{text "c\<^isub>q :: \<tau>"}, 
   759   preservation property is as follows
   758   then a preservation property is as follows
   760 
   759 
   761 
   760   @{text [display, indent=10] "Quotient R\<^bsub>\<alpha>s\<^esub> Abs\<^bsub>\<alpha>s\<^esub> Rep\<^bsub>\<alpha>s\<^esub> implies  ABS (\<sigma>, \<tau>) c\<^isub>r = c\<^isub>r"}
   762   @{text [display, indent=10] "Quotient R\<^bsub>\<alpha>s\<^esub> Abs\<^bsub>\<alpha>s\<^esub> Rep\<^bsub>\<alpha>s\<^esub> implies  ABS (\<sigma>, \<tau>) c\<^isub>r = c\<^isub>r"}
   761 
   763 
   762   \noindent
   764   \noindent
   763   where the @{text "\<alpha>s"} stand for the type variables in the type of @{text "c\<^isub>r"}.
   765   where the @{text "\<alpha>s"} stand for the type variables in the type of @{text "c\<^isub>r"}.
   887   \end{center}
   889   \end{center}
   888   %
   890   %
   889   \noindent
   891   \noindent
   890   In the above definition we omitted the cases for existential quantifiers
   892   In the above definition we omitted the cases for existential quantifiers
   891   and unique existential quantifiers, as they are very similar to the cases
   893   and unique existential quantifiers, as they are very similar to the cases
   892   for the universal quantifier. For the third and fourt clause, note that 
   894   for the universal quantifier. For the third and fourth clause, note that 
   893   @{text "\<forall>x. P"} is defined as @{text "\<forall> (\<lambda>x. P)"}.
   895   @{text "\<forall>x. P"} is defined as @{text "\<forall> (\<lambda>x. P)"}.
   894 
   896 
   895   Next we define the function @{text INJ} which takes as argument
   897   Next we define the function @{text INJ} which takes as argument
   896   @{text "reg_thm"} and @{text "quot_thm"} (both as
   898   @{text "reg_thm"} and @{text "quot_thm"} (both as
   897   terms) and returns @{text "inj_thm"}:
   899   terms) and returns @{text "inj_thm"}:
  1066   @{text "(int_rel \<doublearr> int_rel \<doublearr> int_rel) add_pair add_pair"}
  1068   @{text "(int_rel \<doublearr> int_rel \<doublearr> int_rel) add_pair add_pair"}
  1067   \end{tabular}
  1069   \end{tabular}
  1068   \end{isabelle}
  1070   \end{isabelle}
  1069 
  1071 
  1070   \noindent
  1072   \noindent
  1071   This property needs to beproved by the user. It
  1073   This property needs to be proved by the user. It
  1072   can be discharged automatically by Isabelle when hinting to unfold the definition
  1074   can be discharged automatically by Isabelle when hinting to unfold the definition
  1073   of @{text "\<doublearr>"}.
  1075   of @{text "\<doublearr>"}.
  1074   After this, the user can prove the lifted lemma as follows:
  1076   After this, the user can prove the lifted lemma as follows:
  1075 
  1077 
  1076   \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %
  1078   \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %
  1077   \isacommand{lemma}~~@{text "0 + (x :: int) = x"}~~\isacommand{by}~~@{text "lifting add_pair_zero"}
  1079   \isacommand{lemma}~~@{text "0 + (x :: int) = x"}~~\isacommand{by}~~@{text "lifting add_pair_zero"}
  1078   \end{isabelle}
  1080   \end{isabelle}
  1079 
  1081 
  1080   \noindent
  1082   \noindent
  1081   or by using the completely automated stating just:
  1083   or by using the completely automated mode stating just:
  1082 
  1084 
  1083   \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %
  1085   \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %
  1084   \isacommand{thm}~~@{text "add_pair_zero[quot_lifted]"}
  1086   \isacommand{thm}~~@{text "add_pair_zero[quot_lifted]"}
  1085   \end{isabelle}
  1087   \end{isabelle}
  1086 
  1088 
  1088   Both methods give the same result, namely
  1090   Both methods give the same result, namely
  1089 
  1091 
  1090   @{text [display, indent=10] "0 + x = x"}
  1092   @{text [display, indent=10] "0 + x = x"}
  1091 
  1093 
  1092   \noindent
  1094   \noindent
       
  1095   where @{text x} is of type integer.
  1093   Although seemingly simple, arriving at this result without the help of a quotient
  1096   Although seemingly simple, arriving at this result without the help of a quotient
  1094   package requires a substantial reasoning effort.
  1097   package requires a substantial reasoning effort (see \cite{Paulson06}).
  1095 *}
  1098 *}
  1096 
  1099 
  1097 section {* Conclusion and Related Work\label{sec:conc}*}
  1100 section {* Conclusion and Related Work\label{sec:conc}*}
  1098 
  1101 
  1099 text {*
  1102 text {*
  1100 
  1103 
  1101   The code of the quotient package and the examples described here are
  1104   The code of the quotient package and the examples described here are already
  1102   already included in the
  1105   included in the standard distribution of Isabelle.\footnote{Available from
  1103   standard distribution of Isabelle.\footnote{Available from
  1106   \href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.} The package is
  1104   \href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.} It is
  1107   heavily used in the new version of Nominal Isabelle, which provides a
  1105   heavily used in the new version of Nominal Isabelle, which provides a convenient reasoning
  1108   convenient reasoning infrastructure for programming language calculi
  1106   infrastructure for programming language calculi involving general binders.  
  1109   involving general binders.  To achieve this, it builds types representing
  1107   To achieve this, it builds types representing @{text \<alpha>}-equivalent terms.
  1110   @{text \<alpha>}-equivalent terms.  Earlier versions of Nominal Isabelle have been
  1108   Earlier
  1111   used successfully in formalisations of an equivalence checking algorithm for
  1109   versions of Nominal Isabelle have been used successfully in formalisations
  1112   LF \cite{UrbanCheneyBerghofer08}, Typed
  1110   of an equivalence checking algorithm for LF \cite{UrbanCheneyBerghofer08},
  1113   Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency
  1111   Typed Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for
  1114   \cite{BengtsonParow09} and a strong normalisation result for cut-elimination
  1112   concurrency \cite{BengtsonParow09} and a strong normalisation result for
  1115   in classical logic \cite{UrbanZhu08}.
  1113   cut-elimination in classical logic \cite{UrbanZhu08}.
  1116 
  1114 
  1117 
  1115   There is a wide range of existing of literature for dealing with
  1118   There is a wide range of existing literature for dealing with quotients
  1116   quotients in theorem provers.
  1119   in theorem provers.  Slotosch~\cite{Slotosch97} implemented a mechanism that
  1117   Slotosch~\cite{Slotosch97} implemented a mechanism that automatically
  1120   automatically defines quotient types for Isabelle/HOL. But he did not
  1118   defines quotient types for Isabelle/HOL. But he did not include theorem lifting.
  1121   include theorem lifting.  Harrison's quotient package~\cite{harrison-thesis}
  1119   Harrison's quotient package~\cite{harrison-thesis} is the first one that is
  1122   is the first one that is able to automatically lift theorems, however only
  1120   able to automatically lift theorems, however only first-order theorems (that is theorems
  1123   first-order theorems (that is theorems where abstractions, quantifiers and
  1121   where abstractions, quantifiers and variables do not involve functions that
  1124   variables do not involve functions that include the quotient type). There is
  1122   include the quotient type). 
  1125   also some work on quotient types in non-HOL based systems and logical
  1123   There is also some work on quotient types in
  1126   frameworks, including theory interpretations in
  1124   non-HOL based systems and logical frameworks, including theory interpretations
  1127   PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, and
  1125   in PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, 
  1128   setoids in Coq \cite{ChicliPS02}.  Paulson showed a construction of
  1126   and setoids in Coq \cite{ChicliPS02}.
  1129   quotients that does not require the Hilbert Choice operator, but also only
  1127   Paulson showed a construction of quotients that does not require the
  1130   first-order theorems can be lifted~\cite{Paulson06}.  The most related work
  1128   Hilbert Choice operator, but also only first-order theorems can be lifted~\cite{Paulson06}.
  1131   to our package is the package for HOL4 by Homeier~\cite{Homeier05}.  He
  1129   The most related work to our package is the package for HOL4 by Homeier~\cite{Homeier05}.
  1132   introduced most of the abstract notions about quotients and also deals with
  1130   He introduced most of the abstract notions about quotients and also deals with
  1133   lifting of higher-order theorems. However, he cannot deal with quotient
  1131   lifting of higher-order theorems. However, he cannot deal with quotient compositions (needed
  1134   compositions (needed for lifting theorems about @{text flat}). Also, a
  1132   for lifting theorems about @{text flat}). Also, a number of his definitions, like @{text ABS},
  1135   number of his definitions, like @{text ABS}, @{text REP} and @{text INJ} etc
  1133   @{text REP} and @{text INJ} etc only exist in \cite{Homeier05} as ML-code, not included
  1136   only exist in \cite{Homeier05} as ML-code, not included in the paper.
  1134   in the paper. 
  1137 
  1135 
  1138 
  1136   One feature of our quotient package is that when lifting theorems, the user can
  1139   One feature of our quotient package is that when lifting theorems, the user
  1137   precisely specify what the lifted theorem should look like. This feature is
  1140   can precisely specify what the lifted theorem should look like. This feature
  1138   necessary, for example, when lifting an induction principle for two lists.
  1141   is necessary, for example, when lifting an induction principle for two
  1139   Assuming this principle has as the conclusion a predicate of the form @{text "P xs ys"},
  1142   lists.  Assuming this principle has as the conclusion a predicate of the
  1140   then we can precisely specify whether we want to quotient @{text "xs"} or @{text "ys"},
  1143   form @{text "P xs ys"}, then we can precisely specify whether we want to
  1141   or both. We found this feature very useful in the new version of Nominal 
  1144   quotient @{text "xs"} or @{text "ys"}, or both. We found this feature very
  1142   Isabelle, where such a choice is required to generate a resoning infrastructure
  1145   useful in the new version of Nominal Isabelle, where such a choice is
  1143   for alpha-equated terms. 
  1146   required to generate a reasoning infrastructure for alpha-equated terms.
  1144 %%
  1147 %%
  1145 %% give an example for this
  1148 %% give an example for this
  1146 %%
  1149 %%
  1147   \medskip
  1150   \medskip
  1148 
  1151