Quotient-Paper/Paper.thy
changeset 2227 42d576c54704
parent 2226 36c9d9e658c7
child 2228 a827d36fa467
equal deleted inserted replaced
2226:36c9d9e658c7 2227:42d576c54704
     9 
     9 
    10 notation (latex output)
    10 notation (latex output)
    11   rel_conj ("_ OOO _" [53, 53] 52) and
    11   rel_conj ("_ OOO _" [53, 53] 52) and
    12   "op -->" (infix "\<rightarrow>" 100) and
    12   "op -->" (infix "\<rightarrow>" 100) and
    13   "==>" (infix "\<Rightarrow>" 100) and
    13   "==>" (infix "\<Rightarrow>" 100) and
    14   fun_map ("_ \<^raw:\mbox{\tt{---\textgreater}}> _" 51) and
    14   fun_map ("_ \<^raw:\mbox{\singlearr}> _" 51) and
    15   fun_rel ("_ \<^raw:\mbox{\tt{===\textgreater}}> _" 51) and
    15   fun_rel ("_ \<^raw:\mbox{\doublearr}> _" 51) and
    16   list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *)
    16   list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *)
    17   fempty ("\<emptyset>") and
    17   fempty ("\<emptyset>") and
    18   funion ("_ \<union> _") and
    18   funion ("_ \<union> _") and
    19   finsert ("{_} \<union> _") and 
    19   finsert ("{_} \<union> _") and 
    20   Cons ("_::_") and
    20   Cons ("_::_") and
    38   Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #>
    38   Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #>
    39   Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #>
    39   Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #>
    40   Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2))
    40   Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2))
    41 *}
    41 *}
    42 (*>*)
    42 (*>*)
       
    43 
    43 
    44 
    44 section {* Introduction *}
    45 section {* Introduction *}
    45 
    46 
    46 text {* 
    47 text {* 
    47    \begin{flushright}
    48    \begin{flushright}
   292       @{text "|"} & @{text "\<lambda>x\<^isup>\<sigma>. t"} & \textrm{(abstraction)} \\ \nonumber
   293       @{text "|"} & @{text "\<lambda>x\<^isup>\<sigma>. t"} & \textrm{(abstraction)} \\ \nonumber
   293   \end{eqnarray}
   294   \end{eqnarray}
   294 
   295 
   295 *}
   296 *}
   296 
   297 
   297 section {* Lifting of Definitions *}
   298 section {* Quotient Types and Lifting of Definitions *}
   298 
   299 
   299 (* Say more about containers? *)
   300 (* Say more about containers? *)
   300 
   301 
   301 text {*
   302 text {*
   302 
   303 
   312   maps are known. Such maps for most common types (list, pair, sum,
   313   maps are known. Such maps for most common types (list, pair, sum,
   313   option, \ldots) are described in Homeier, and we assume that @{text "map"}
   314   option, \ldots) are described in Homeier, and we assume that @{text "map"}
   314   is the function that returns a map for a given type. Then REP/ABS is defined
   315   is the function that returns a map for a given type. Then REP/ABS is defined
   315   as follows:
   316   as follows:
   316 
   317 
   317   \begin{itemize}
   318   {\it the first argument is the raw type and the second argument the quotient type}
   318   \item @{text "ABS(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "id"}
   319 
   319   \item @{text "REP(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"}  =  @{text "id"}
   320 
   320   \item @{text "ABS(\<sigma>, \<sigma>)"}  =  @{text "id"}
   321   \begin{center}
   321   \item @{text "REP(\<sigma>, \<sigma>)"}  =  @{text "id"}
   322   \begin{tabular}{rcl}
   322   \item @{text "ABS(\<sigma>\<^isub>1\<rightarrow>\<sigma>\<^isub>2,\<tau>\<^isub>1\<rightarrow>\<tau>\<^isub>2)"}  =  @{text "REP(\<sigma>\<^isub>1,\<tau>\<^isub>1) \<longrightarrow> ABS(\<sigma>\<^isub>2,\<tau>\<^isub>2)"}
   323 
   323   \item @{text "REP(\<sigma>\<^isub>1\<rightarrow>\<sigma>\<^isub>2,\<tau>\<^isub>1\<rightarrow>\<tau>\<^isub>2)"}  =  @{text "ABS(\<sigma>\<^isub>1,\<tau>\<^isub>1) \<longrightarrow> REP(\<sigma>\<^isub>2,\<tau>\<^isub>2)"}
   324   % type variable case says that variables must be equal...therefore subsumed by the equal case below
   324   \item @{text "ABS((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>n))\<kappa>)"}  =  @{text "(map \<kappa>) (ABS(\<sigma>\<^isub>1,\<tau>\<^isub>1)) \<dots> (ABS(\<sigma>\<^isub>n,\<tau>\<^isub>n))"}
   325   %
   325   \item @{text "REP((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>n))\<kappa>)"}  =  @{text "(map \<kappa>) (REP(\<sigma>\<^isub>1,\<tau>\<^isub>1)) \<dots> (REP(\<sigma>\<^isub>n,\<tau>\<^isub>n))"}
   326   %\multicolumn{3}{@ {\hspace{-4mm}}l}{type variables:}\\ 
   326   \item @{text "ABS((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m))\<kappa>\<^isub>2)"}  =  @{text "Abs_\<kappa>\<^isub>2 \<circ> (map \<kappa>\<^isub>1) (ABS(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (ABS(\<rho>\<^isub>p,\<nu>\<^isub>p)"} provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
   327   %@{text "ABS (\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} & $\dn$ & @{text "id"}\\
   327   \item @{text "REP((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m))\<kappa>\<^isub>2)"}  =  @{text "(map \<kappa>\<^isub>1) (REP(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (REP(\<rho>\<^isub>p,\<nu>\<^isub>p) \<circ> Rep_\<kappa>\<^isub>2"} provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
   328   %@{text "REP (\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} & $\dn$ & @{text "id"}\smallskip\\
   328   \end{itemize}
   329 
       
   330   \multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ 
       
   331   @{text "ABS (\<sigma>, \<sigma>)"} & $\dn$ & @{text "id"}\\
       
   332   @{text "REP (\<sigma>, \<sigma>)"} & $\dn$ & @{text "id"}\smallskip\\
       
   333   \multicolumn{3}{@ {\hspace{-4mm}}l}{function types:}\\ 
       
   334   @{text "ABS (\<sigma>\<^isub>1 \<rightarrow> \<sigma>\<^isub>2, \<tau>\<^isub>1 \<rightarrow> \<tau>\<^isub>2)"} & $\dn$ & @{text "REP (\<sigma>\<^isub>1, \<tau>\<^isub>1) \<singlearr> ABS (\<sigma>\<^isub>2, \<tau>\<^isub>2)"}\\
       
   335   @{text "REP (\<sigma>\<^isub>1 \<rightarrow> \<sigma>\<^isub>2, \<tau>\<^isub>1 \<rightarrow> \<tau>\<^isub>2)"} & $\dn$ & @{text "ABS (\<sigma>\<^isub>1, \<tau>\<^isub>1) \<singlearr> REP (\<sigma>\<^isub>2, \<tau>\<^isub>2)"}\smallskip\\
       
   336   \multicolumn{3}{@ {\hspace{-4mm}}l}{equal type constructors:}\\ 
       
   337   @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "\<kappa>_map (ABS (\<sigma>s, \<tau>s))"}\\
       
   338   @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "\<kappa>_map (REP (\<sigma>s, \<tau>s))"}\smallskip\\
       
   339   \multicolumn{3}{@ {\hspace{-4mm}}l}{unequal type constructors:}\\
       
   340   @{text "ABS (\<sigma>s \<kappa>\<^isub>1, \<tau>s \<kappa>\<^isub>2)"} & $\dn$ & @{text "\<kappa>\<^isub>2_Abs \<circ> \<kappa>\<^isub>1_map (ABS (\<sigma>s', \<tau>s'))"}\\
       
   341   @{text "REP (\<sigma>s \<kappa>\<^isub>1, \<tau>s \<kappa>\<^isub>2)"} & $\dn$ & @{text "\<kappa>\<^isub>1_map (REP (\<sigma>s', \<tau>s')) \<circ> \<kappa>\<^isub>2_Rep"}\\
       
   342   \end{tabular}
       
   343   \end{center}
       
   344 
       
   345   \begin{center}
       
   346   \begin{tabular}{rcl}
       
   347   @{text "ABS((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n) \<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m) \<kappa>\<^isub>2)"}  =  @{text "Abs_\<kappa>\<^isub>2 \<circ> (map \<kappa>\<^isub>1) (ABS(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (ABS(\<rho>\<^isub>p,\<nu>\<^isub>p)"}\\ 
       
   348   @{text "REP((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n) \<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m) \<kappa>\<^isub>2)"}  =  @{text "(map \<kappa>\<^isub>1) (REP(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (REP(\<rho>\<^isub>p,\<nu>\<^isub>p) \<circ> Rep_\<kappa>\<^isub>2"}\\
       
   349   provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
       
   350   \end{tabular}
       
   351   \end{center}
   329 
   352 
   330   Apart from the last 2 points the definition is same as the one implemented in
   353   Apart from the last 2 points the definition is same as the one implemented in
   331   in Homeier's HOL package. Adding composition in last two cases is necessary
   354   in Homeier's HOL package. Adding composition in last two cases is necessary
   332   for compositional quotients. We ilustrate the different behaviour of the
   355   for compositional quotients. We ilustrate the different behaviour of the
   333   definition by showing the derived definition of @{term fconcat}:
   356   definition by showing the derived definition of @{term fconcat}:
   337   The aggregate @{term Abs} function takes a finite set of finite sets
   360   The aggregate @{term Abs} function takes a finite set of finite sets
   338   and applies @{term "map rep_fset"} composed with @{term rep_fset} to
   361   and applies @{term "map rep_fset"} composed with @{term rep_fset} to
   339   its input, obtaining a list of lists, passes the result to @{term concat}
   362   its input, obtaining a list of lists, passes the result to @{term concat}
   340   obtaining a list and applies @{term abs_fset} obtaining the composed
   363   obtaining a list and applies @{term abs_fset} obtaining the composed
   341   finite set.
   364   finite set.
       
   365 
       
   366   {\it we can compactify the term by noticing that map id\ldots id = id}
       
   367 
       
   368   {\it we should be able to prove}
       
   369 
       
   370   \begin{lemma}
       
   371   If @{text "ABS (\<sigma>, \<tau>)"} returns some abstraction function @{text "Abs"} 
       
   372   and @{text "REP (\<sigma>, \<tau>)"} some representation function @{text "Rep"}, 
       
   373   then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type
       
   374   @{text "\<tau> \<Rightarrow> \<sigma>"}.
       
   375   \end{lemma}
   342 *}
   376 *}
   343 
   377 
   344 subsection {* Respectfulness *}
   378 subsection {* Respectfulness *}
   345 
   379 
   346 text {*
   380 text {*
   448 
   482 
   449   @{thm [display] quotient_compose_list[no_vars]}
   483   @{thm [display] quotient_compose_list[no_vars]}
   450 *}
   484 *}
   451 
   485 
   452 
   486 
   453 section {* Lifting Theorems *}
   487 section {* Lifting of Theorems *}
   454 
   488 
   455 text {*
   489 text {*
   456   The core of the quotient package takes an original theorem that
   490   The core of the quotient package takes an original theorem that
   457   talks about the raw types, and the statement of the theorem that
   491   talks about the raw types, and the statement of the theorem that
   458   it is supposed to produce. This is different from other existing
   492   it is supposed to produce. This is different from other existing
   761 
   795 
   762   \end{itemize}
   796   \end{itemize}
   763 *}
   797 *}
   764 
   798 
   765 
   799 
       
   800 
   766 (*<*)
   801 (*<*)
   767 end
   802 end
   768 (*>*)
   803 (*>*)