192 add them according to the function @{text "add_pair"} and then take the |
192 add them according to the function @{text "add_pair"} and then take the |
193 abstraction of the result. This is all straightforward and the existing |
193 abstraction of the result. This is all straightforward and the existing |
194 quotient packages can deal with such definitions. But what is surprising |
194 quotient packages can deal with such definitions. But what is surprising |
195 that none of them can deal with slightly more complicated definitions involving |
195 that none of them can deal with slightly more complicated definitions involving |
196 \emph{compositions} of quotients. Such compositions are needed for example |
196 \emph{compositions} of quotients. Such compositions are needed for example |
197 in case of quotienting lists to obtain finite sets and the operator that |
197 in case of quotienting lists to yield finite sets and the operator that |
198 flattens lists of lists, defined as follows |
198 flattens lists of lists, defined as follows |
199 |
199 |
200 @{thm [display, indent=10] concat.simps(1) concat.simps(2)[no_vars]} |
200 @{thm [display, indent=10] concat.simps(1) concat.simps(2)[no_vars]} |
201 |
201 |
202 \noindent |
202 \noindent |
203 We expect that the corresponding operator on finite sets, written @{term "fconcat"}, |
203 We expect that the corresponding operator on finite sets, written @{term "fconcat"}, |
204 builds the union of finite sets of finite sets: |
204 builds the finite unions of finite sets: |
205 |
205 |
206 @{thm [display, indent=10] fconcat_empty[no_vars] fconcat_insert[no_vars]} |
206 @{thm [display, indent=10] fconcat_empty[no_vars] fconcat_insert[no_vars]} |
207 |
207 |
208 \noindent |
208 \noindent |
209 The quotient package should provide us with a definition for @{text "\<Union>"} in |
209 The quotient package should provide us with a definition for @{text "\<Union>"} in |
210 terms of @{text flat}, @{text Rep_fset} and @{text Abs_fset}. The problem is |
210 terms of @{text flat}, @{text Rep_fset} and @{text Abs_fset}. The problem is |
211 that the method used in the existing quotient |
211 that the method used in the existing quotient |
212 packages of just taking the representation of the arguments and then take |
212 packages of just taking the representation of the arguments and then taking |
213 the abstraction of the result is \emph{not} enough. The reason is that case in case |
213 the abstraction of the result is \emph{not} enough. The reason is that case in case |
214 of @{text "\<Union>"} we obtain the incorrect definition |
214 of @{text "\<Union>"} we obtain the incorrect definition |
215 |
215 |
216 @{text [display, indent=10] "\<Union> S \<equiv> Abs_fset (flat (Rep_fset S))"} |
216 @{text [display, indent=10] "\<Union> S \<equiv> Abs_fset (flat (Rep_fset S))"} |
217 |
217 |
236 of \emph{aggregate equivalence relation}, \emph{respectfulness} and \emph{preservation} |
236 of \emph{aggregate equivalence relation}, \emph{respectfulness} and \emph{preservation} |
237 from Homeier \cite{Homeier05}. |
237 from Homeier \cite{Homeier05}. |
238 |
238 |
239 We are also able to address the criticism by Paulson \cite{Paulson06} cited |
239 We are also able to address the criticism by Paulson \cite{Paulson06} cited |
240 at the beginning of this section about having to collect theorems that are |
240 at the beginning of this section about having to collect theorems that are |
241 lifted from the raw level to the quotient level. Our quotient package is the |
241 lifted from the raw level to the quotient level into one giant list. Our |
242 first one that is modular so that it allows to lift single theorems |
242 quotient package is the first one that is modular so that it allows to lift |
243 separately. This has the advantage for the user to develop a formal theory |
243 single theorems separately. This has the advantage for the user to develop a |
244 interactively an a natural progression. A pleasing result of the modularity |
244 formal theory interactively an a natural progression. A pleasing result of |
245 is also that we are able to clearly specify what needs to be done in the |
245 the modularity is also that we are able to clearly specify what needs to be |
246 lifting process (this was only hinted at in \cite{Homeier05} and implemented |
246 done in the lifting process (this was only hinted at in \cite{Homeier05} and |
247 as a ``rough recipe'' in ML-code). |
247 implemented as a ``rough recipe'' in ML-code). |
|
248 |
248 |
249 |
249 The paper is organised as follows: Section \ref{sec:prelims} presents briefly |
250 The paper is organised as follows: Section \ref{sec:prelims} presents briefly |
250 some necessary preliminaries; Section \ref{sec:type} presents the definitions |
251 some necessary preliminaries; Section \ref{sec:type} describes the definitions |
251 of quotient types and shows how definitions can be made over quotient types. \ldots |
252 of quotient types and shows how definition of constants can be made over |
|
253 quotient types. \ldots |
252 *} |
254 *} |
253 |
255 |
254 |
256 |
255 section {* Preliminaries and General Quotient\label{sec:prelims} *} |
257 section {* Preliminaries and General Quotient\label{sec:prelims} *} |
256 |
258 |
257 text {* |
259 text {* |
258 In this section we present the definitions of a quotient that follow |
260 In this section we present the definitions of a quotient that follow |
259 those by Homeier, the proofs can be found there. |
261 closely those given by Homeier. |
260 |
262 |
261 \begin{definition}[Quotient] |
263 \begin{definition}[Quotient] |
262 A relation $R$ with an abstraction function $Abs$ |
264 A relation $R$ with an abstraction function $Abs$ |
263 and a representation function $Rep$ is a \emph{quotient} |
265 and a representation function $Rep$ is a \emph{quotient} |
264 if and only if: |
266 if and only if: |
339 |
338 |
340 \noindent |
339 \noindent |
341 which introduce the type of integers and of finite sets using the |
340 which introduce the type of integers and of finite sets using the |
342 equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text |
341 equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text |
343 "\<approx>\<^bsub>list\<^esub>"} defined earlier in \eqref{natpairequiv} and |
342 "\<approx>\<^bsub>list\<^esub>"} defined earlier in \eqref{natpairequiv} and |
344 \eqref{listequiv}, respectively. Given this data, we declare internally |
343 \eqref{listequiv}, respectively (the proofs about being equivalence |
|
344 relations is omitted). Given this data, we declare internally |
345 the quotient types as |
345 the quotient types as |
346 |
346 |
347 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
347 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
348 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
348 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
349 \end{isabelle} |
349 \end{isabelle} |
350 |
350 |
351 \noindent |
351 \noindent |
352 where the right hand side is the (non-empty) set of equivalence classes of |
352 where the right-hand side is the (non-empty) set of equivalence classes of |
353 @{text "R"}. The restriction in this declaration is that the type variables |
353 @{text "R"}. The restriction in this declaration is that the type variables |
354 in the raw type @{text "\<sigma>"} must be included in the type variables @{text |
354 in the raw type @{text "\<sigma>"} must be included in the type variables @{text |
355 "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us with |
355 "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us with the following |
356 abstraction and representation functions having the type |
356 abstraction and representation functions having the type |
357 |
357 |
358 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
358 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
359 @{text "abs_\<kappa>\<^isub>q :: \<sigma> set \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"}\hspace{10mm}@{text "rep_\<kappa>\<^isub>q :: \<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma> set"} |
359 @{text "abs_\<kappa>\<^isub>q :: \<sigma> set \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"}\hspace{10mm}@{text "rep_\<kappa>\<^isub>q :: \<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma> set"} |
360 \end{isabelle} |
360 \end{isabelle} |
410 building unions of finite sets. |
411 building unions of finite sets. |
411 |
412 |
412 The problem for us is that from such declarations we need to derive proper |
413 The problem for us is that from such declarations we need to derive proper |
413 definitions using the @{text "Abs"} and @{text "Rep"} functions for the |
414 definitions using the @{text "Abs"} and @{text "Rep"} functions for the |
414 quotient types involved. The data we rely on is the given quotient type |
415 quotient types involved. The data we rely on is the given quotient type |
415 @{text "\<tau>"} and the raw type @{text "\<sigma>"}. They allow us to define aggregate |
416 @{text "\<tau>"} and the raw type @{text "\<sigma>"}. They allow us to define \emph{aggregate |
416 abstraction and representation functions using the functions @{text "ABS (\<sigma>, |
417 abstraction} and \emph{representation functions} using the functions @{text "ABS (\<sigma>, |
417 \<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses are given below. The idea behind |
418 \<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses we given below. The idea behind |
418 them is to recursively descend into types @{text \<sigma>} and @{text \<tau>}, and generate the appropriate |
419 these two functions is to recursively descend into the raw types @{text \<sigma>} and |
|
420 quotient types @{text \<tau>}, and generate the appropriate |
419 @{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore |
421 @{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore |
420 we returning just the identity whenever the types are equal. All clauses |
422 we generate just the identity whenever the types are equal. All clauses |
421 are as follows: |
423 are as follows: |
422 |
424 |
423 \begin{center} |
425 \begin{center} |
424 \begin{tabular}{rcl} |
426 \begin{tabular}{rcl} |
425 \multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ |
427 \multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ |
432 @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (ABS (\<sigma>s, \<tau>s))"}\\ |
434 @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (ABS (\<sigma>s, \<tau>s))"}\\ |
433 @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (REP (\<sigma>s, \<tau>s))"}\smallskip\\ |
435 @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (REP (\<sigma>s, \<tau>s))"}\smallskip\\ |
434 \multicolumn{3}{@ {\hspace{-4mm}}l}{unequal type constructors:}\\ |
436 \multicolumn{3}{@ {\hspace{-4mm}}l}{unequal type constructors:}\\ |
435 @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "Abs_\<kappa>\<^isub>q \<circ> (MAP(\<rho>s \<kappa>) (ABS (\<sigma>s', \<tau>s)))"}\\ |
437 @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "Abs_\<kappa>\<^isub>q \<circ> (MAP(\<rho>s \<kappa>) (ABS (\<sigma>s', \<tau>s)))"}\\ |
436 @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "(MAP(\<rho>s \<kappa>) (REP (\<sigma>s', \<tau>s))) \<circ> Rep_\<kappa>\<^isub>q"} |
438 @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "(MAP(\<rho>s \<kappa>) (REP (\<sigma>s', \<tau>s))) \<circ> Rep_\<kappa>\<^isub>q"} |
437 \end{tabular} |
439 \end{tabular}\hfill\numbered{ABSREP} |
438 \end{center} |
440 \end{center} |
439 % |
441 % |
440 \noindent |
442 \noindent |
441 where in the last two clauses we have that the quotient type @{text "\<alpha>s |
443 where in the last two clauses we have that the quotient type @{text "\<alpha>s |
442 \<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example |
444 \<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example |
443 @{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha> |
445 @{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha> |
444 list"}). The quotient construction ensures that the type variables in @{text |
446 list"}). The quotient construction ensures that the type variables in @{text |
445 "\<rho>s"} must be amongst the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the |
447 "\<rho>s"} must be among the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the |
446 matchers for the @{text "\<alpha>s"} when matching @{text "\<rho>s \<kappa>"} against |
448 matchers for the @{text "\<alpha>s"} when matching @{text "\<rho>s \<kappa>"} against |
447 @{text "\<sigma>s \<kappa>"}. The |
449 @{text "\<sigma>s \<kappa>"}. The |
448 function @{text "MAP"} calculates an \emph{aggregate map-function} for a raw |
450 function @{text "MAP"} calculates an \emph{aggregate map-function} for a raw |
449 type as follows: |
451 type as follows: |
450 % |
452 % |
458 \end{center} |
460 \end{center} |
459 % |
461 % |
460 \noindent |
462 \noindent |
461 In this definition we abuse the fact that we can interpret type-variables @{text \<alpha>} as |
463 In this definition we abuse the fact that we can interpret type-variables @{text \<alpha>} as |
462 term variables @{text a}. In the last clause we build an abstraction over all |
464 term variables @{text a}. In the last clause we build an abstraction over all |
463 term-variables inside the aggregate map-function generated by the auxiliary function |
465 term-variables inside map-function generated by the auxiliary function |
464 @{text "MAP'"}. |
466 @{text "MAP'"}. |
465 The need of aggregate map-functions can be appreciated if we build quotients, |
467 The need of aggregate map-functions can be seen in cases where we build quotients, |
466 say @{text "(\<alpha>, \<beta>) \<kappa>\<^isub>q"}, out of compound raw types of the form @{text "(\<alpha> list) \<times> \<beta>"}. |
468 say @{text "(\<alpha>, \<beta>) \<kappa>\<^isub>q"}, out of compound raw types, say @{text "(\<alpha> list) \<times> \<beta>"}. |
467 In this case @{text MAP} generates the aggregate map-function: |
469 In this case @{text MAP} generates the |
|
470 aggregate map-function: |
468 |
471 |
469 @{text [display, indent=10] "\<lambda>a b. map_prod (map a) b"} |
472 @{text [display, indent=10] "\<lambda>a b. map_prod (map a) b"} |
470 |
473 |
471 \noindent |
474 \noindent |
472 which we need to define the aggregate abstraction and representation functions. |
475 which we need to define the aggregate abstraction and representation functions. |
473 |
476 |
474 To se how these definitions pan out in practise, let us return to our |
477 To see how these definitions pan out in practise, let us return to our |
475 example about @{term "concat"} and @{term "fconcat"}, where we have types |
478 example about @{term "concat"} and @{term "fconcat"}, where we have the raw type |
476 @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha> |
479 @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and the quotient type @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha> |
477 fset"}. Feeding them into @{text ABS} gives us the abstraction function |
480 fset"}. Feeding them into @{text ABS} gives us (after some @{text "\<beta>"}-simplifications) |
|
481 the abstraction function |
478 |
482 |
479 @{text [display, indent=10] "(map (map id \<circ> Rep_fset) \<circ> Rep_fset) \<singlearr> Abs_fset \<circ> map id"} |
483 @{text [display, indent=10] "(map (map id \<circ> Rep_fset) \<circ> Rep_fset) \<singlearr> Abs_fset \<circ> map id"} |
480 |
484 |
481 \noindent |
485 \noindent |
482 after some @{text "\<beta>"}-simplifications. In our implementation we further |
486 In our implementation we further |
483 simplify this abstraction function employing the usual laws about @{text |
487 simplify this function by rewriting with the usual laws about @{text |
484 "map"}s and @{text "id"}, namely @{term "map id = id"} and @{text "f \<circ> id = |
488 "map"}s and @{text "id"}, namely @{term "map id = id"} and @{text "f \<circ> id = |
485 id \<circ> f = f"}. This gives us the abstraction function |
489 id \<circ> f = f"}. This gives us the abstraction function |
486 |
490 |
487 @{text [display, indent=10] "(map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset"} |
491 @{text [display, indent=10] "(map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset"} |
488 |
492 |
490 which we can use for defining @{term "fconcat"} as follows |
494 which we can use for defining @{term "fconcat"} as follows |
491 |
495 |
492 @{text [display, indent=10] "\<Union> \<equiv> ((map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset) flat"} |
496 @{text [display, indent=10] "\<Union> \<equiv> ((map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset) flat"} |
493 |
497 |
494 \noindent |
498 \noindent |
495 Note that by using the operator @{text "\<singlearr>"} we do not have to |
499 Note that by using the operator @{text "\<singlearr>"} and special clauses |
|
500 for function types in \eqref{ABSREP}, we do not have to |
496 distinguish between arguments and results: the representation and abstraction |
501 distinguish between arguments and results: the representation and abstraction |
497 functions are just inverses of each other, which we can combine using |
502 functions are just inverses of each other, which we can combine using |
498 @{text "\<singlearr>"} to deal uniformly with arguments of functions and |
503 @{text "\<singlearr>"} to deal uniformly with arguments of functions and |
499 their result. As a result, all definitions in the quotient package |
504 their result. Consequently, all definitions in the quotient package |
500 are of the general form |
505 are of the general form |
501 |
506 |
502 @{text [display, indent=10] "c \<equiv> ABS (\<sigma>, \<tau>) t"} |
507 @{text [display, indent=10] "c \<equiv> ABS (\<sigma>, \<tau>) t"} |
503 |
508 |
504 \noindent |
509 \noindent |
505 where @{text \<sigma>} is the type of the definiens @{text "t"} and @{text "\<tau>"} the |
510 where @{text \<sigma>} is the type of the definiens @{text "t"} and @{text "\<tau>"} the |
506 type of the defined quotient constant @{text "c"}. To ensure we |
511 type of the defined quotient constant @{text "c"}. This data can be easily |
507 obtained a correct definition, we can prove: |
512 generated from the declaration given by the user. |
|
513 To increase the confidence of making correct definitions, we can prove |
|
514 that the terms involved are all typable. |
508 |
515 |
509 \begin{lemma} |
516 \begin{lemma} |
510 If @{text "ABS (\<sigma>, \<tau>)"} returns some abstraction function @{text "Abs"} |
517 If @{text "ABS (\<sigma>, \<tau>)"} returns some abstraction function @{text "Abs"} |
511 and @{text "REP (\<sigma>, \<tau>)"} some representation function @{text "Rep"}, |
518 and @{text "REP (\<sigma>, \<tau>)"} some representation function @{text "Rep"}, |
512 then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type |
519 then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type |
513 @{text "\<tau> \<Rightarrow> \<sigma>"}. |
520 @{text "\<tau> \<Rightarrow> \<sigma>"}. |
514 \end{lemma} |
521 \end{lemma} |
515 |
522 |
516 \begin{proof} |
523 \begin{proof} |
517 By induction and analysing the definitions of @{text "ABS"}, @{text "REP"} |
524 By induction and analysing the definitions of @{text "ABS"}, @{text "REP"} |
518 and @{text "MAP"}. The cases of equal and function types are straightforward |
525 and @{text "MAP"}. The cases of equal types and function types are |
519 (the latter follows from @{text "\<singlearr>"} having the type |
526 straightforward (the latter follows from @{text "\<singlearr>"} having the |
520 @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). The case of equal |
527 type @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). In case of equal type |
521 type constructors follows by observing that a map-function after applying |
528 constructors we can observe that a map-function after applying the functions |
522 the functions @{text "ABS (\<sigma>s, \<tau>s)"} produce a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}. |
529 @{text "ABS (\<sigma>s, \<tau>s)"} produces a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}. The |
523 The interesting case is the one with unequal type constructors. Since we know the |
530 interesting case is the one with unequal type constructors. Since we know |
524 quotient is between @{text "\<alpha>s \<kappa>\<^isub>q"} and @{text "\<rho>s \<kappa>"}, we have that @{text "Abs_\<kappa>\<^isub>q"} |
531 the quotient is between @{text "\<alpha>s \<kappa>\<^isub>q"} and @{text "\<rho>s \<kappa>"}, we have |
525 is of type @{text "\<rho>s \<kappa> \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"}, that can be more specialised to @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s \<kappa>\<^isub>q"} |
532 that @{text "Abs_\<kappa>\<^isub>q"} is of type @{text "\<rho>s \<kappa> \<Rightarrow> \<alpha>s |
526 where the type variables @{text "\<alpha>s"} are instantiated with @{text "\<tau>s"}. The |
533 \<kappa>\<^isub>q"}. This type can be more specialised to @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s |
527 complete type can be calculated by observing that @{text "MAP (\<rho>s \<kappa>)"} after applying |
534 \<kappa>\<^isub>q"} where the type variables @{text "\<alpha>s"} are instantiated with the |
528 the functions @{text "ABS (\<sigma>s', \<tau>s)"} to it, returns a term of type |
535 @{text "\<tau>s"}. The complete type can be calculated by observing that @{text |
529 @{text "\<rho>s[\<sigma>s'] \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}. This type is equivalent to @{text "\<sigma>s \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"} |
536 "MAP (\<rho>s \<kappa>)"}, after applying the functions @{text "ABS (\<sigma>s', \<tau>s)"} to it, |
530 as desired.\qed |
537 returns a term of type @{text "\<rho>s[\<sigma>s'] \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}. This type is |
|
538 equivalent to @{text "\<sigma>s \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}, which we just have to compose with |
|
539 @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s \<kappa>\<^isub>q"} according to the type of @{text "\<circ>"}.\qed |
531 \end{proof} |
540 \end{proof} |
532 |
541 |
533 \noindent |
542 \noindent |
534 The reader should note that this lemma fails for the abstraction and representation |
543 The reader should note that this lemma fails for the abstraction and representation |
535 functions used, for example, in Homeier's quotient package. |
544 functions used, for example, in Homeier's quotient package. |
536 *} |
545 *} |
537 |
546 |
538 section {* Respectfulness and Preservation *} |
547 section {* Respectfulness and Preservation *} |
539 |
548 |
540 text {* |
549 text {* |
541 Before we can lift theorems involving the raw types to theorems over |
550 The main point of the quotient package is to automatically ``lift'' theorems |
542 quotient types, we have to impose some restrictions. The reason is that not |
551 involving constants over the raw type to theorems involving constants over |
543 all theorems can be lifted. Homeier formulates these restrictions in terms |
552 the quotient type. Before we can describe this lift process, we need to impose |
544 of \emph{respectfullness} and \emph{preservation} of constants occuring in |
553 some restrictions. The reason is that even if definitions for all raw constants |
545 theorems. |
554 can be given, \emph{not} all theorems can be actually be lifted. Most notably is |
546 |
555 the bound variable function, that is the constant @{text bn}, defined for |
547 The respectfulness property for a constant states that it essentially |
556 raw lambda-terms as follows |
548 respects the equivalence relation involved in the quotient. An example |
557 |
549 is the function returning bound variables of a lambda-term (see \eqref{lambda}) |
558 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
550 and @{text "\<alpha>"}-equivalence. It will turn out that this function is not |
559 @{text "bn (x) \<equiv> \<emptyset>"}\hspace{5mm} |
551 respectful. |
560 @{text "bn (t\<^isub>1 t\<^isub>2) \<equiv> bn (t\<^isub>1) \<union> bn (t\<^isub>2)"}\hspace{5mm} |
552 |
561 @{text "bn (\<lambda>x. t) \<equiv> {x} \<union> bn (t)"} |
553 To state the respectfulness property we have to define \emph{aggregate equivalence |
562 \end{isabelle} |
554 relations}. |
563 |
|
564 \noindent |
|
565 This constant just does not respect @{text "\<alpha>"}-equivalence and as |
|
566 consequently no theorem involving this constant can be lifted to @{text |
|
567 "\<alpha>"}-equated lambda terms. Homeier formulates the restrictions in terms of |
|
568 the properties of \emph{respectfullness} and \emph{preservation}. We have |
|
569 to slighlty extend Homeier's definitions in order to deal with quotient |
|
570 compositions. |
|
571 |
|
572 To formally define what respectfulness is, we have to first define |
|
573 the notion of \emph{aggregate equivalence relations}. |
555 |
574 |
556 @{text [display] "GIVE DEFINITION HERE"} |
575 @{text [display] "GIVE DEFINITION HERE"} |
557 |
576 |
558 class returned by this constant depends only on the equivalence |
577 class returned by this constant depends only on the equivalence |
559 classes of the arguments applied to the constant. To automatically |
578 classes of the arguments applied to the constant. To automatically |