Quotient-Paper/Paper.thy
changeset 2188 57972032e20e
parent 2186 762a739c9eb4
child 2189 029bd37d010a
equal deleted inserted replaced
2187:f9cc69b432ff 2188:57972032e20e
     9   rel_conj ("_ OOO _" [53, 53] 52)
     9   rel_conj ("_ OOO _" [53, 53] 52)
    10 and
    10 and
    11   fun_map ("_ ---> _" [51, 51] 50)
    11   fun_map ("_ ---> _" [51, 51] 50)
    12 and
    12 and
    13   fun_rel ("_ ===> _" [51, 51] 50)
    13   fun_rel ("_ ===> _" [51, 51] 50)
       
    14 and
       
    15   list_eq (infix "\<approx>" 50) (* Not sure if we want this notation...? *)
    14 
    16 
    15 ML {*
    17 ML {*
    16 fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n;
    18 fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n;
    17 fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
    19 fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
    18   let
    20   let
    78 
    80 
    79   @{thm concat.simps(1)}\\
    81   @{thm concat.simps(1)}\\
    80   @{thm concat.simps(2)[no_vars]}
    82   @{thm concat.simps(2)[no_vars]}
    81 
    83 
    82   \noindent
    84   \noindent
    83   One would like to lift this definition to the operation
    85   One would like to lift this definition to the operation:
    84   
    86 
    85   @{text [display] "union definition"}
    87   @{thm fconcat_empty[no_vars]}\\
       
    88   @{thm fconcat_insert[no_vars]}
    86 
    89 
    87   \noindent
    90   \noindent
    88   What is special about this operation is that we have as input
    91   What is special about this operation is that we have as input
    89   lists of lists which after lifting turn into finite sets of finite
    92   lists of lists which after lifting turn into finite sets of finite
    90   sets. 
    93   sets. 
   100   \begin{itemize}
   103   \begin{itemize}
   101 
   104 
   102   \item We define quotient composition, function map composition and
   105   \item We define quotient composition, function map composition and
   103     relation map composition. This lets lifting polymorphic types with
   106     relation map composition. This lets lifting polymorphic types with
   104     subtypes quotiented as well. We extend the notions of
   107     subtypes quotiented as well. We extend the notions of
   105     respectfullness and preservation to cope with quotient
   108     respectfulness and preservation to cope with quotient
   106     composition.
   109     composition.
   107 
   110 
   108   \item We allow lifting only some occurrences of quotiented
   111   \item We allow lifting only some occurrences of quotiented
   109     types. Rsp/Prs extended. (used in nominal)
   112     types. Rsp/Prs extended. (used in nominal)
   110 
   113 
   139   \item @{thm (rhs3) Quotient_def[of "R", no_vars]}
   142   \item @{thm (rhs3) Quotient_def[of "R", no_vars]}
   140   \end{enumerate}
   143   \end{enumerate}
   141 
   144 
   142   \end{definition}
   145   \end{definition}
   143 
   146 
   144   \begin{definition}[Relation map and function map]
   147   \begin{definition}[Relation map and function map]\\
   145   @{thm fun_rel_def[no_vars]}\\
   148   @{thm fun_rel_def[no_vars]}\\
   146   @{thm fun_map_def[no_vars]}
   149   @{thm fun_map_def[no_vars]}
   147   \end{definition}
   150   \end{definition}
   148 
   151 
   149   The main theorems for building higher order quotients is:
   152   The main theorems for building higher order quotients is:
   154 
   157 
   155 *}
   158 *}
   156 
   159 
   157 section {* Constants *}
   160 section {* Constants *}
   158 
   161 
   159 (* Describe what containers are? *)
   162 (* Say more about containers? *)
   160 
   163 
   161 text {*
   164 text {*
       
   165 
       
   166   To define a constant on the lifted type, an aggregate abstraction
       
   167   function is applied to the raw constant. Below we describe the operation
       
   168   that generates
       
   169   an aggregate @{term "Abs"} or @{term "Rep"} function given the
       
   170   compound raw type and the compound quotient type.
       
   171   This operation will also be used in translations of theorem statements
       
   172   and in the lifting procedure.
       
   173 
       
   174   The operation is additionally able to descend into types for which
       
   175   maps are known. Such maps for most common types (list, pair, sum,
       
   176   option, \ldots) are described in Homeier, and our algorithm uses the
       
   177   same kind of maps. Given the raw compound type and the quotient compound
       
   178   type the Rep/Abs algorithm does:
       
   179 
       
   180   \begin{itemize}
       
   181   \item For equal types or free type variables return identity.
       
   182 
       
   183   \item For function types recurse, change the Rep/Abs flag to
       
   184      the opposite one for the domain type and compose the
       
   185      results with @{term "fun_map"}.
       
   186 
       
   187   \item For equal type constructors use the appropriate map function
       
   188      applied to the results for the arguments.
       
   189 
       
   190   \item For unequal type constructors, look in the quotients information
       
   191     for a quotient type that matches, and instantiate the raw type
       
   192     appropriately getting back an instantiation environment. We apply
       
   193     the environment to the arguments and recurse composing it with the
       
   194     aggregate map function.
       
   195   \end{itemize}
       
   196 
       
   197   The first three points above are identical to the algorithm present in
       
   198   in Homeier's HOL implementation, below is the definition of @{term fconcat}
       
   199   that shows the last step:
       
   200 
       
   201   @{thm fconcat_def[no_vars]}
       
   202 
       
   203   The aggregate @{term Abs} function takes a finite set of finite sets
       
   204   and applies @{term "map rep_fset"} composed with @{term rep_fset} to
       
   205   its input, obtaining a list of lists, passes the result to @{term concat}
       
   206   obtaining a list and applies @{term abs_fset} obtaining the composed
       
   207   finite set.
       
   208 *}
       
   209 
       
   210 subsection {* Respectfulness *}
       
   211 
       
   212 text {*
       
   213 
       
   214   A respectfulness lemma for a constant states that the equivalence
       
   215   class returned by this constant depends only on the equivalence
       
   216   classes of the arguments applied to the constant. This can be
       
   217   expressed in terms of an aggregate relation between the constant
       
   218   and itself, for example the respectfullness for @{term "append"}
       
   219   can be stated as:
       
   220 
       
   221   @{thm append_rsp[no_vars]}
       
   222 
       
   223   Which is equivalent to:
       
   224 
       
   225   @{thm append_rsp[no_vars,simplified fun_rel_def]}
       
   226 
       
   227   Below we show the algorithm for finding the aggregate relation.
       
   228   This algorithm uses
       
   229   the relation composition which we define as:
       
   230 
   162   \begin{definition}[Composition of Relations]
   231   \begin{definition}[Composition of Relations]
   163   @{abbrev "rel_conj R1 R2"}
   232   @{abbrev "rel_conj R1 R2"}
   164   \end{definition}
   233   \end{definition}
   165 
   234 
   166   The first operation that we describe is the generation of
   235   Given an aggregate raw type and quotient type:
   167   aggregate Abs or Rep function for two given compound types.
       
   168   This operation will be used for the constant defnitions
       
   169   and for the translation of theorems statements. It relies on
       
   170   knowing map functions and relation functions for container types.
       
   171   It follows the following algorithm:
       
   172 
   236 
   173   \begin{itemize}
   237   \begin{itemize}
   174   \item For equal types or free type variables return identity.
   238   \item ...
   175 
       
   176   \item For function types recurse, change the Rep/Abs flag to
       
   177      the opposite one for the domain type and compose the
       
   178      results with @{term "fun_map"}.
       
   179 
       
   180   \item For equal type constructors use the appropriate map function
       
   181      applied to the results for the arguments.
       
   182 
       
   183   \item For unequal type constructors are unequal, we look in the
       
   184     quotients information for a raw type quotient type pair that
       
   185     matches the given types. We apply the environment to the arguments
       
   186     and recurse composing it with the aggregate map function.
       
   187   \end{itemize}
   239   \end{itemize}
   188 
   240 
   189 
   241   Aggregate @{term "Rep"} and @{term "Abs"} functions are also
   190 
   242   present in composition quotients. An example composition quotient
   191   Rsp and Prs
   243   theorem that needs to be proved is the one needed to lift theorems
       
   244   about concat:
       
   245 
       
   246   @{thm quotient_compose_list[no_vars]}
       
   247 
       
   248   Prs
   192 *}
   249 *}
   193 
   250 
   194 section {* Lifting Theorems *}
   251 section {* Lifting Theorems *}
   195 
   252 
   196 text {* TBD *}
   253 text {* TBD *}