Quotient-Paper/Paper.thy
changeset 2270 4ae32dd02d14
parent 2269 e4699a240d2c
parent 2268 1fd6809f5a44
child 2272 bf3a29ea74f6
equal deleted inserted replaced
2269:e4699a240d2c 2270:4ae32dd02d14
   355   \begin{proposition}\label{funquot}
   355   \begin{proposition}\label{funquot}
   356   @{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2" 
   356   @{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2" 
   357       and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]}
   357       and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]}
   358   \end{proposition}
   358   \end{proposition}
   359 
   359 
       
   360   \begin{definition}[Respects]
       
   361   An element @{text "x"} respects a relation @{text "R"} if and only if @{text "R x x"}.
       
   362   \end{definition}
       
   363 
   360   \noindent
   364   \noindent
   361   As a result, Homeier was able to build an automatic prover that can nearly
   365   As a result, Homeier was able to build an automatic prover that can nearly
   362   always discharge a proof obligation involving @{text "Quotient"}. Our quotient
   366   always discharge a proof obligation involving @{text "Quotient"}. Our quotient
   363   package makes heavy 
   367   package makes heavy 
   364   use of this part of Homeier's work including an extension 
   368   use of this part of Homeier's work including an extension 
   370   %
   374   %
   371   @{thm [mode=Rule, display, indent=10] pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}
   375   @{thm [mode=Rule, display, indent=10] pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}
   372   \end{definition}
   376   \end{definition}
   373 
   377 
   374   \noindent
   378   \noindent
   375   Unfortunately, restrictions in HOL's type-system prevent us from stating
   379   Unfortunately a quotient type theorem, like Proposition \ref{funquot}, for
   376   and proving a quotient type theorem, like Proposition \ref{funquot}, for compositions 
   380   the composition of any two quotients in not true (it is not even typable in
   377   of relations. However, we can prove all instances where @{text R\<^isub>1} and 
   381   the HOL type system). However, we can prove useful instances for compatible
   378   @{text "R\<^isub>2"} are built up by constituent equivalence relations.
   382   containers. We will show such example in Section \ref{sec:resp}.
       
   383 
       
   384 
   379 *}
   385 *}
   380 
   386 
   381 section {* Quotient Types and Quotient Definitions\label{sec:type} *}
   387 section {* Quotient Types and Quotient Definitions\label{sec:type} *}
   382 
   388 
   383 text {*
   389 text {*
   737   when we compose the quotient with itself, as there is no simple
   743   when we compose the quotient with itself, as there is no simple
   738   intermediate step.
   744   intermediate step.
   739 
   745 
   740   Lets take again the example of @{term flat}. To be able to lift
   746   Lets take again the example of @{term flat}. To be able to lift
   741   theorems that talk about it we provide the composition quotient
   747   theorems that talk about it we provide the composition quotient
   742   theorem:
   748   theorem which allows quotienting inside the container:
   743 
   749 
   744   @{thm [display, indent=10] quotient_compose_list[no_vars]}
   750   If @{term R} is an equivalence relation and @{term "Quotient R Abs Rep"}
       
   751   then
       
   752 
       
   753   @{text [display, indent=10] "Quotient (list_rel R \<circ>\<circ>\<circ> \<approx>\<^bsub>list\<^esub>) (abs_fset \<circ> map Abs) (map Rep o rep_fset)"}
   745 
   754 
   746   \noindent
   755   \noindent
   747   this theorem will then instantiate the quotients needed in the
   756   this theorem will then instantiate the quotients needed in the
   748   injection and cleaning proofs allowing the lifting procedure to
   757   injection and cleaning proofs allowing the lifting procedure to
   749   proceed in an unchanged way.
   758   proceed in an unchanged way.
   790 
   799 
   791   \begin{center}
   800   \begin{center}
   792   \begin{tabular}{rcl}
   801   \begin{tabular}{rcl}
   793   \multicolumn{3}{@ {\hspace{-4mm}}l}{abstractions (with same types and different types):}\\
   802   \multicolumn{3}{@ {\hspace{-4mm}}l}{abstractions (with same types and different types):}\\
   794   @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<sigma>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma>. REG (t, s)"}\\
   803   @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<sigma>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma>. REG (t, s)"}\\
   795   @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<tau>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma> \<in> Res (REL (\<sigma>, \<tau>)). REG (t, s)"}\\
   804   @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<tau>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma> \<in> Respects (REL (\<sigma>, \<tau>)). REG (t, s)"}\\
   796   \multicolumn{3}{@ {\hspace{-4mm}}l}{quantification (over same types and different types):}\\
   805   \multicolumn{3}{@ {\hspace{-4mm}}l}{quantification (over same types and different types):}\\
   797   @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<sigma>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma>. REG (t, s)"}\\
   806   @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<sigma>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma>. REG (t, s)"}\\
   798   @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<tau>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma> \<in> Res (REL (\<sigma>, \<tau>)). REG (t, s)"}\\
   807   @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<tau>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma> \<in> Respects (REL (\<sigma>, \<tau>)). REG (t, s)"}\\
   799   \multicolumn{3}{@ {\hspace{-4mm}}l}{equalities (with same types and different types):}\\
   808   \multicolumn{3}{@ {\hspace{-4mm}}l}{equalities (with same types and different types):}\\
   800   @{text "REG ((op =) : \<sigma>, (op =) : \<sigma>)"} & $\dn$ & @{text "(op =) : \<sigma>"}\\
   809   @{text "REG ((op =) : \<sigma>, (op =) : \<sigma>)"} & $\dn$ & @{text "(op =) : \<sigma>"}\\
   801   @{text "REG ((op =) : \<sigma>, (op =) : \<tau>)"} & $\dn$ & @{text "REL (\<sigma>, \<tau>) : \<sigma>"}\\
   810   @{text "REG ((op =) : \<sigma>, (op =) : \<tau>)"} & $\dn$ & @{text "REL (\<sigma>, \<tau>) : \<sigma>"}\\
   802   \multicolumn{3}{@ {\hspace{-4mm}}l}{applications, variables, constants:}\\
   811   \multicolumn{3}{@ {\hspace{-4mm}}l}{applications, variables, constants:}\\
   803   @{text "REG (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2)"} & $\dn$ & @{text "REG (t\<^isub>1, s\<^isub>1) REG (t\<^isub>2, s\<^isub>2)"}\\
   812   @{text "REG (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2)"} & $\dn$ & @{text "REG (t\<^isub>1, s\<^isub>1) REG (t\<^isub>2, s\<^isub>2)"}\\
  1034 
  1043 
  1035 section {* Conclusion and Related Work\label{sec:conc}*}
  1044 section {* Conclusion and Related Work\label{sec:conc}*}
  1036 
  1045 
  1037 text {*
  1046 text {*
  1038 
  1047 
       
  1048   The code of the quotient package and the examples described here are
       
  1049   already included in the
       
  1050   standard distribution of Isabelle.\footnote{Available from
       
  1051   \href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.} It is
       
  1052   heavily used in Nominal Isabelle, which provides a convenient reasoning
       
  1053   infrastructure for programming language calculi involving binders.  Earlier
       
  1054   versions of Nominal Isabelle have been used successfully in formalisations
       
  1055   of an equivalence checking algorithm for LF \cite{UrbanCheneyBerghofer08},
       
  1056   Typed Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for
       
  1057   concurrency \cite{BengtsonParow09} and a strong normalisation result for
       
  1058   cut-elimination in classical logic \cite{UrbanZhu08}.
       
  1059 
  1039   Oscar Slotosch~\cite{Slotosch97} implemented a mechanism that automatically
  1060   Oscar Slotosch~\cite{Slotosch97} implemented a mechanism that automatically
  1040   defines quotient types for Isabelle/HOL. It did not include theorem lifting.
  1061   defines quotient types for Isabelle/HOL. It did not include theorem lifting.
  1041   John Harrison's quotient package~\cite{harrison-thesis} is the first one to
  1062   John Harrison's quotient package~\cite{harrison-thesis} is the first one to
  1042   lift theorems, however only first order. There is work on quotient types in
  1063   lift theorems, however only first order. There is work on quotient types in
  1043   non-HOL based systems and logical frameworks, namely theory interpretations
  1064   non-HOL based systems and logical frameworks, namely theory interpretations
  1044   in PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, or
  1065   in PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, or
  1045   the use of setoids in Coq, with some higher order issues~\cite{ChicliPS02}.
  1066   the use of setoids in Coq, with some higher order issues~\cite{ChicliPS02}.
  1046   Larry Paulson shows a construction of quotients that does not require the
  1067   Larry Paulson shows a construction of quotients that does not require the
  1047   Hilbert Choice operator, again only first order~\cite{Paulson06}.
  1068   Hilbert Choice operator, again only first order~\cite{Paulson06}.
  1048 
       
  1049   The closest to our package is the package for HOL4 by Peter Homeier~\cite{Homeier05},
  1069   The closest to our package is the package for HOL4 by Peter Homeier~\cite{Homeier05},
  1050   which is the first one to support lifting of higher order theorems. In
  1070   which is the first one to support lifting of higher order theorems.
  1051   comparison with this package we explore the notion of composition of quotients,
  1071 
  1052   which allows lifting constants like @{term "concat"} and theorems about it.
  1072 
  1053   The HOL4 package requires a big lists of constants, theorems to lift,
  1073   Our quotient package for the first time explore the notion of
  1054   respectfullness conditions as input. Our package is modularized, so that
  1074   composition of quotients, which allows lifting constants like @{term
  1055   single definitions, single theorems or single respectfullness conditions etc
  1075   "concat"} and theorems about it. We defined the composition of
  1056   can be added, which allows a natural use of the quotient package together
  1076   relations and showed examples of compositions of quotients which
  1057   with type-classes and locales.
  1077   allows lifting polymorphic types with subtypes quotiented as well.
  1058 
  1078   We extended the notions of respectfullness and preservation;
  1059   The code of the quotient package described here is already included in the
  1079   with quotient compositions there is more than one condition needed
  1060   standard distribution of Isabelle.\footnote{Available from
  1080   for a constant.
  1061   \href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.} It is
  1081 
  1062   heavily used in Nominal Isabelle, which provides a convenient reasoning
  1082   Our package is modularized, so that single definitions, single
  1063   infrastructure for programming language calculi involving binders.  Earlier
  1083   theorems or single respectfullness conditions etc can be added,
  1064   versions of Nominal Isabelle have been used successfully in formalisations
  1084   which allows the use of the quotient package together with
  1065   of an equivalence checking algorithm for LF \cite{UrbanCheneyBerghofer08},
  1085   type-classes and locales. This has the advantage over packages
  1066   Typed Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for
  1086   requiring big lists as input for the user of being able to develop
  1067   concurrency \cite{BengtsonParow09} and a strong normalisation result for
  1087   a theory progressively.
  1068   cut-elimination in classical logic \cite{UrbanZhu08}.
  1088 
  1069 
  1089   We allow lifting only some occurrences of quotiented types, which
  1070 *}
  1090   is useful in Nominal. The package can be used automatically with
  1071 
  1091   an attribute, manually with separate tactics for parts of the lifting
  1072 
  1092   procedure, and programatically. Automated definitions of constants
  1073 subsection {* Contributions *}
  1093   and respectfulness proof obligations are used in Nominal. Finally
  1074 
  1094   we streamlined and showed the detailed lifting procedure, which
  1075 text {*
  1095   has not been presented before.
  1076   We present the detailed lifting procedure, which was not shown before.
       
  1077 
       
  1078   The quotient package presented in this paper has the following
       
  1079   advantages over existing packages:
       
  1080   \begin{itemize}
       
  1081 
       
  1082   \item We define quotient composition, function map composition and
       
  1083     relation map composition. This lets lifting polymorphic types with
       
  1084     subtypes quotiented as well. We extend the notions of
       
  1085     respectfulness and preservation to cope with quotient
       
  1086     composition.
       
  1087 
       
  1088   \item We allow lifting only some occurrences of quotiented
       
  1089     types. Rsp/Prs extended. (used in nominal)
       
  1090 
       
  1091   \item The quotient package is very modular. Definitions can be added
       
  1092     separately, rsp and prs can be proved separately, Quotients and maps
       
  1093     can be defined separately and theorems can
       
  1094     be lifted on a need basis. (useful with type-classes).
       
  1095 
       
  1096   \item Can be used both manually (attribute, separate tactics,
       
  1097     rsp/prs databases) and programatically (automated definition of
       
  1098     lifted constants, the rsp proof obligations and theorem statement
       
  1099     translation according to given quotients).
       
  1100 
       
  1101   \end{itemize}
       
  1102 
  1096 
  1103   \medskip
  1097   \medskip
  1104   \noindent
  1098   \noindent
  1105   {\bf Acknowledgements:} We would like to thank Peter Homeier for the
  1099   {\bf Acknowledgements:} We would like to thank Peter Homeier for the
  1106   discussions about the HOL4 quotient package and explaining us its
  1100   discussions about the HOL4 quotient package and explaining us its