5 "../Nominal/FSet" |
5 "../Nominal/FSet" |
6 begin |
6 begin |
7 |
7 |
8 notation (latex output) |
8 notation (latex output) |
9 rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and |
9 rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and |
10 pred_comp ("_ \<circ>\<circ> _") and |
10 pred_comp ("_ \<circ>\<circ> _" [1, 1] 30) and |
11 "op -->" (infix "\<longrightarrow>" 100) and |
11 "op -->" (infix "\<longrightarrow>" 100) and |
12 "==>" (infix "\<Longrightarrow>" 100) and |
12 "==>" (infix "\<Longrightarrow>" 100) and |
13 fun_map ("_ \<^raw:\mbox{\singlearr}> _" 51) and |
13 fun_map ("_ \<^raw:\mbox{\singlearr}> _" 51) and |
14 fun_rel ("_ \<^raw:\mbox{\doublearr}> _" 51) and |
14 fun_rel ("_ \<^raw:\mbox{\doublearr}> _" 51) and |
15 list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *) |
15 list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *) |
86 which states that two lists are equivalent if every element in one list is |
86 which states that two lists are equivalent if every element in one list is |
87 also member in the other. The empty finite set, written @{term "{||}"}, can |
87 also member in the other. The empty finite set, written @{term "{||}"}, can |
88 then be defined as the empty list and the union of two finite sets, written |
88 then be defined as the empty list and the union of two finite sets, written |
89 @{text "\<union>"}, as list append. |
89 @{text "\<union>"}, as list append. |
90 |
90 |
91 Quotients are important in a variety of areas, but they are ubiquitous in |
91 Quotients are important in a variety of areas, but they are really ubiquitous in |
92 the area of reasoning about programming language calculi. A simple example |
92 the area of reasoning about programming language calculi. A simple example |
93 is the lambda-calculus, whose raw terms are defined as |
93 is the lambda-calculus, whose raw terms are defined as |
94 |
94 |
95 |
95 |
96 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
96 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
150 \end{tikzpicture} |
150 \end{tikzpicture} |
151 \end{center} |
151 \end{center} |
152 |
152 |
153 \noindent |
153 \noindent |
154 The starting point is an existing type, to which we refer as the |
154 The starting point is an existing type, to which we refer as the |
155 \emph{raw type}, over which an equivalence relation given by the user is |
155 \emph{raw type} and over which an equivalence relation given by the user is |
156 defined. With this input the package introduces a new type, to which we |
156 defined. With this input the package introduces a new type, to which we |
157 refer as the \emph{quotient type}. This type comes with an |
157 refer as the \emph{quotient type}. This type comes with an |
158 \emph{abstraction} and a \emph{representation} function, written @{text Abs} |
158 \emph{abstraction} and a \emph{representation} function, written @{text Abs} |
159 and @{text Rep}.\footnote{Actually slightly more basic functions are given; |
159 and @{text Rep}.\footnote{Actually slightly more basic functions are given; |
160 the functions @{text Abs} and @{text Rep} need to be derived from them. We |
160 the functions @{text Abs} and @{text Rep} need to be derived from them. We |
161 will show the details later. } These functions relate elements in the |
161 will show the details later. } They relate elements in the |
162 existing type to elements in the new type and vice versa; they can be uniquely |
162 existing type to elements in the new type and vice versa, and can be uniquely |
163 identified by their quotient type. For example for the integer quotient construction |
163 identified by their quotient type. For example for the integer quotient construction |
164 the types of @{text Abs} and @{text Rep} are |
164 the types of @{text Abs} and @{text Rep} are |
165 |
165 |
166 |
166 |
167 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
167 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
261 *} |
261 *} |
262 |
262 |
263 section {* Preliminaries and General Quotients\label{sec:prelims} *} |
263 section {* Preliminaries and General Quotients\label{sec:prelims} *} |
264 |
264 |
265 text {* |
265 text {* |
266 We describe here briefly the most basic notions of HOL we rely on, and |
266 We describe in this section briefly the most basic notions of HOL we rely on, and |
267 the important definitions given by Homeier for quotients \cite{Homeier05}. |
267 the important definitions given by Homeier for quotients \cite{Homeier05}. |
268 |
268 |
269 At its core HOL is based on a simply-typed term language, where types are |
269 At its core HOL is based on a simply-typed term language, where types are |
270 recorded in Church-style fashion (that means, we can infer the type of |
270 recorded in Church-style fashion (that means, we can always infer the type of |
271 a term and its subterms without any additional information). The grammars |
271 a term and its subterms without any additional information). The grammars |
272 for types and terms are as follows |
272 for types and terms are as follows |
273 |
273 |
274 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
274 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
275 \begin{tabular}{@ {}rl@ {\hspace{3mm}}l@ {}} |
275 \begin{tabular}{@ {}rl@ {\hspace{3mm}}l@ {}} |
281 |
281 |
282 \noindent |
282 \noindent |
283 We often write just @{text \<kappa>} for @{text "() \<kappa>"}, and use @{text "\<alpha>s"} and |
283 We often write just @{text \<kappa>} for @{text "() \<kappa>"}, and use @{text "\<alpha>s"} and |
284 @{text "\<sigma>s"} to stand for collections of type variables and types, |
284 @{text "\<sigma>s"} to stand for collections of type variables and types, |
285 respectively. The type of a term is often made explicit by writing @{text |
285 respectively. The type of a term is often made explicit by writing @{text |
286 "t :: \<sigma>"}. HOL contains a type @{typ bool} for booleans and the function |
286 "t :: \<sigma>"}. HOL includes a type @{typ bool} for booleans and the function |
287 type, written @{text "\<sigma> \<Rightarrow> \<tau>"}. HOL also contains |
287 type, written @{text "\<sigma> \<Rightarrow> \<tau>"}. HOL also contains |
288 many primitive and defined constants; for example equality @{text "= :: \<sigma> \<Rightarrow> |
288 many primitive and defined constants; this includes equality, with type @{text "= :: \<sigma> \<Rightarrow> |
289 \<sigma> \<Rightarrow> bool"} and the identity function @{text "id :: \<sigma> => \<sigma>"} (the former |
289 \<sigma> \<Rightarrow> bool"}, and the identity function, with type @{text "id :: \<sigma> => \<sigma>"} (the former |
290 being primitive and the latter being defined as @{text |
290 being primitive and the latter being defined as @{text |
291 "\<lambda>x\<^sup>\<sigma>. x\<^sup>\<sigma>"}). |
291 "\<lambda>x\<^sup>\<sigma>. x\<^sup>\<sigma>"}). |
292 |
292 |
293 An important point to note is that theorems in HOL can be seen as a subset |
293 An important point to note is that theorems in HOL can be seen as a subset |
294 of terms that are constructed specially (namely through axioms and prove |
294 of terms that are constructed specially (namely through axioms and prove |
295 rules). As a result we are able later on to define automatic proof |
295 rules). As a result we are able to define automatic proof |
296 procedures showing that one theorem implies another by decomposing the term |
296 procedures showing that one theorem implies another by decomposing the term |
297 underlying the first theorem. |
297 underlying the first theorem. |
298 |
298 |
299 Like Homeier, our work relies on map-functions defined for every type constructor, |
299 Like Homeier, our work relies on map-functions defined for every type constructor, |
300 like @{text map} for lists. Homeier describes others for products, sums, |
300 like @{text map} for lists. Homeier describes in \cite{Homeier05} map-functions |
|
301 for products, sums, |
301 options and also the following map for function types |
302 options and also the following map for function types |
302 |
303 |
303 @{thm [display, indent=10] fun_map_def[no_vars, THEN eq_reflection]} |
304 @{thm [display, indent=10] fun_map_def[no_vars, THEN eq_reflection]} |
304 |
305 |
305 \noindent |
306 \noindent |
307 uniform, definition for @{text add} shown in \eqref{adddef}: |
308 uniform, definition for @{text add} shown in \eqref{adddef}: |
308 |
309 |
309 @{text [display, indent=10] "add \<equiv> (Rep_int \<singlearr> Rep_int \<singlearr> Abs_int) add_pair"} |
310 @{text [display, indent=10] "add \<equiv> (Rep_int \<singlearr> Rep_int \<singlearr> Abs_int) add_pair"} |
310 |
311 |
311 \noindent |
312 \noindent |
312 We will sometimes refer to a map-function defined for a type-constructor @{text \<kappa>} |
313 Using extensionality and unfolding the definition, we can get back to \eqref{adddef}. |
313 as @{text "map_\<kappa>"}. |
314 In what follows we shall use the terminology @{text "map_\<kappa>"} for a map-function |
|
315 defined for the type-constructor @{text \<kappa>}. In our implementation we have |
|
316 a database of map-functions that can be dynamically extended. |
314 |
317 |
315 It will also be necessary to have operators, referred to as @{text "rel_\<kappa>"}, |
318 It will also be necessary to have operators, referred to as @{text "rel_\<kappa>"}, |
316 which define equivalence relations in terms of constituent equivalence |
319 which define equivalence relations in terms of constituent equivalence |
317 relations. For example given two equivalence relations @{text "R\<^isub>1"} |
320 relations. For example given two equivalence relations @{text "R\<^isub>1"} |
318 and @{text "R\<^isub>2"}, we can define an equivalence relations over |
321 and @{text "R\<^isub>2"}, we can define an equivalence relations over |
319 products as follows |
322 products as follows |
320 % |
323 % |
321 @{text [display, indent=10] "(R\<^isub>1 \<tripple> R\<^isub>2) (x\<^isub>1, x\<^isub>2) (y\<^isub>1, y\<^isub>2) \<equiv> R\<^isub>1 x\<^isub>1 y\<^isub>1 \<and> R\<^isub>2 x\<^isub>2 y\<^isub>2"} |
324 @{text [display, indent=10] "(R\<^isub>1 \<tripple> R\<^isub>2) (x\<^isub>1, x\<^isub>2) (y\<^isub>1, y\<^isub>2) \<equiv> R\<^isub>1 x\<^isub>1 y\<^isub>1 \<and> R\<^isub>2 x\<^isub>2 y\<^isub>2"} |
322 |
325 |
323 \noindent |
326 \noindent |
324 Similarly, Homeier defines the following operator for defining equivalence |
327 Homeier gives also the following operator for defining equivalence |
325 relations over function types: |
328 relations over function types |
326 % |
329 % |
327 @{thm [display, indent=10] fun_rel_def[of "R\<^isub>1" "R\<^isub>2", no_vars, THEN eq_reflection]} |
330 @{thm [display, indent=10] fun_rel_def[of "R\<^isub>1" "R\<^isub>2", no_vars, THEN eq_reflection]} |
328 |
331 |
329 The central definition in Homeier's work \cite{Homeier05} relates equivalence |
332 The central definition in Homeier's work \cite{Homeier05} relates equivalence |
330 relations, abstraction and representation functions: |
333 relations, abstraction and representation functions: |
339 \item @{thm (rhs3) Quotient_def[of "R", no_vars]} |
342 \item @{thm (rhs3) Quotient_def[of "R", no_vars]} |
340 \end{enumerate} |
343 \end{enumerate} |
341 \end{definition} |
344 \end{definition} |
342 |
345 |
343 \noindent |
346 \noindent |
344 The value of this definition is that validity of @{text Quotient} can be |
347 The value of this definition is that validity of @{text "Quotient R Abs Rep"} can |
345 proved in terms of the validity of @{text "Quotient"} over the constituent types. |
348 often be proved in terms of the validity of @{text "Quotient"} over the constituent |
|
349 types of @{text "R"}, @{text Abs} and @{text Rep}. |
346 For example Homeier proves the following property for higher-order quotient |
350 For example Homeier proves the following property for higher-order quotient |
347 types: |
351 types: |
348 |
352 |
349 \begin{proposition}[Function Quotient]\label{funquot} |
353 \begin{proposition}\label{funquot} |
350 @{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2" |
354 @{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2" |
351 and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]} |
355 and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]} |
352 \end{proposition} |
356 \end{proposition} |
353 |
357 |
354 \begin{definition}[Respects]\label{def:respects} |
358 \begin{definition}[Respects]\label{def:respects} |
355 An element @{text "x"} respects a relation @{text "R"} if and only if @{text "R x x"}. |
359 An element @{text "x"} respects a relation @{text "R"} if and only if @{text "R x x"}. |
356 \end{definition} |
360 \end{definition} |
357 |
361 |
358 \noindent |
362 \noindent |
359 We will heavily rely on this part of Homeier's work including an extension |
363 As a result, Homeier was able to build an automatic prover that can nearly |
|
364 always discharge a proof obligation involving @{text "Quotient"}. Our quotient |
|
365 package makes heavy |
|
366 use of this part of Homeier's work including an extension |
360 to deal with compositions of equivalence relations defined as follows |
367 to deal with compositions of equivalence relations defined as follows |
361 |
368 |
362 \begin{definition}[Composition of Relations] |
369 \begin{definition}[Composition of Relations] |
363 @{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate |
370 @{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate |
364 composition defined by the rule |
371 composition defined by the rule |
379 |
386 |
380 text {* |
387 text {* |
381 The first step in a quotient construction is to take a name for the new |
388 The first step in a quotient construction is to take a name for the new |
382 type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation, say @{text R}, |
389 type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation, say @{text R}, |
383 defined over a raw type, say @{text "\<sigma>"}. The type of the equivalence |
390 defined over a raw type, say @{text "\<sigma>"}. The type of the equivalence |
384 relation must be of type @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool"}. The user-visible part of |
391 relation must be @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool"}. The user-visible part of |
385 the declaration is therefore |
392 the quotient type declaration is therefore |
386 |
393 |
387 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
394 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
388 \isacommand{quotient\_type}~~@{text "\<alpha>s \<kappa>\<^isub>q = \<sigma> / R"} |
395 \isacommand{quotient\_type}~~@{text "\<alpha>s \<kappa>\<^isub>q = \<sigma> / R"}\hfill\numbered{typedecl} |
389 \end{isabelle} |
396 \end{isabelle} |
390 |
397 |
391 \noindent |
398 \noindent |
392 and a proof that @{text "R"} is indeed an equivalence relation. Two concrete |
399 and a proof that @{text "R"} is indeed an equivalence relation. Two concrete |
393 examples are |
400 examples are |
401 \end{isabelle} |
408 \end{isabelle} |
402 |
409 |
403 \noindent |
410 \noindent |
404 which introduce the type of integers and of finite sets using the |
411 which introduce the type of integers and of finite sets using the |
405 equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text |
412 equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text |
406 "\<approx>\<^bsub>list\<^esub>"} defined earlier in \eqref{natpairequiv} and |
413 "\<approx>\<^bsub>list\<^esub>"} defined in \eqref{natpairequiv} and |
407 \eqref{listequiv}, respectively (the proofs about being equivalence |
414 \eqref{listequiv}, respectively (the proofs about being equivalence |
408 relations is omitted). Given this data, we declare internally |
415 relations is omitted). Given this data, we declare for \eqref{typedecl} internally |
409 the quotient types as |
416 the quotient types as |
410 |
417 |
411 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
418 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
412 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
419 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
413 \end{isabelle} |
420 \end{isabelle} |
415 \noindent |
422 \noindent |
416 where the right-hand side is the (non-empty) set of equivalence classes of |
423 where the right-hand side is the (non-empty) set of equivalence classes of |
417 @{text "R"}. The restriction in this declaration is that the type variables |
424 @{text "R"}. The restriction in this declaration is that the type variables |
418 in the raw type @{text "\<sigma>"} must be included in the type variables @{text |
425 in the raw type @{text "\<sigma>"} must be included in the type variables @{text |
419 "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us with the following |
426 "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us with the following |
420 abstraction and representation functions having the type |
427 abstraction and representation functions |
421 |
428 |
422 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
429 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
423 @{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"} |
430 @{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"} |
424 \end{isabelle} |
431 \end{isabelle} |
425 |
432 |
426 \noindent |
433 \noindent |
427 They relate the new quotient type and equivalence classes of the raw |
434 As can be seen from the type, they relate the new quotient type and equivalence classes of the raw |
428 type. However, as Homeier \cite{Homeier05} noted, it is much more convenient |
435 type. However, as Homeier \cite{Homeier05} noted, it is much more convenient |
429 to work with the following derived abstraction and representation functions |
436 to work with the following derived abstraction and representation functions |
430 |
437 |
431 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
438 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
432 @{text "Abs_\<kappa>\<^isub>q x \<equiv> abs_\<kappa>\<^isub>q (R x)"}\hspace{10mm}@{text "Rep_\<kappa>\<^isub>q x \<equiv> \<epsilon> (rep_\<kappa>\<^isub>q x)"} |
439 @{text "Abs_\<kappa>\<^isub>q x \<equiv> abs_\<kappa>\<^isub>q (R x)"}\hspace{10mm}@{text "Rep_\<kappa>\<^isub>q x \<equiv> \<epsilon> (rep_\<kappa>\<^isub>q x)"} |
449 as above (for the proof see \cite{Homeier05}). |
456 as above (for the proof see \cite{Homeier05}). |
450 |
457 |
451 The next step in a quotient construction is to introduce definitions of new constants |
458 The next step in a quotient construction is to introduce definitions of new constants |
452 involving the quotient type. These definitions need to be given in terms of concepts |
459 involving the quotient type. These definitions need to be given in terms of concepts |
453 of the raw type (remember this is the only way how to extend HOL |
460 of the raw type (remember this is the only way how to extend HOL |
454 with new definitions). For the user visible is the declaration |
461 with new definitions). For the user the visible part of such definitions is the declaration |
455 |
462 |
456 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
463 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
457 \isacommand{quotient\_definition}~~@{text "c :: \<tau>"}~~\isacommand{is}~~@{text "t :: \<sigma>"} |
464 \isacommand{quotient\_definition}~~@{text "c :: \<tau>"}~~\isacommand{is}~~@{text "t :: \<sigma>"} |
458 \end{isabelle} |
465 \end{isabelle} |
459 |
466 |
460 \noindent |
467 \noindent |
461 where @{text t} is the definiens (its type @{text \<sigma>} can always be inferred) |
468 where @{text t} is the definiens (its type @{text \<sigma>} can always be inferred) |
462 and @{text "c"} is the name of definiendum, whose type @{text "\<tau>"} needs to be |
469 and @{text "c"} is the name of definiendum, whose type @{text "\<tau>"} needs to be |
463 given explicitly (the point is that @{text "\<tau>"} and @{text "\<sigma>"} can only differ |
470 given explicitly (the point is that @{text "\<tau>"} and @{text "\<sigma>"} can only differ |
464 in places where a quotient and raw type are involved). Two concrete examples are |
471 in places where a quotient and raw type is involved). Two concrete examples are |
465 |
472 |
466 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
473 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
467 \begin{tabular}{@ {}l} |
474 \begin{tabular}{@ {}l} |
468 \isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0::nat, 0::nat)"}\\ |
475 \isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0::nat, 0::nat)"}\\ |
469 \isacommand{quotient\_definition}~~@{text "\<Union> :: (\<alpha> fset) fset \<Rightarrow> \<alpha> fset"}~~% |
476 \isacommand{quotient\_definition}~~@{text "\<Union> :: (\<alpha> fset) fset \<Rightarrow> \<alpha> fset"}~~% |
482 abstraction} and \emph{representation functions} using the functions @{text "ABS (\<sigma>, |
489 abstraction} and \emph{representation functions} using the functions @{text "ABS (\<sigma>, |
483 \<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses we give below. The idea behind |
490 \<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses we give below. The idea behind |
484 these two functions is to recursively descend into the raw types @{text \<sigma>} and |
491 these two functions is to recursively descend into the raw types @{text \<sigma>} and |
485 quotient types @{text \<tau>}, and generate the appropriate |
492 quotient types @{text \<tau>}, and generate the appropriate |
486 @{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore |
493 @{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore |
487 we generate just the identity whenever the types are equal. All clauses |
494 we generate just the identity whenever the types are equal. On the ``way'' down, |
488 are as follows: |
495 however we might have to use map-functions to let @{text Abs} and @{text Rep} act |
|
496 over the appropriate types. The clauses of @{text ABS} and @{text REP} |
|
497 are as follows (where we use the short-hand notation @{text "ABS (\<sigma>s, \<tau>s)"} to mean |
|
498 @{text "ABS (\<sigma>\<^isub>1, \<tau>\<^isub>1)\<dots>ABS (\<sigma>\<^isub>i, \<tau>\<^isub>i)"}; similarly for @{text REP}): |
489 |
499 |
490 \begin{center} |
500 \begin{center} |
491 \hfill |
501 \hfill |
492 \begin{tabular}{rcl} |
502 \begin{tabular}{rcl} |
493 \multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ |
503 \multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ |
504 @{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"} |
514 @{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"} |
505 \end{tabular}\hfill\numbered{ABSREP} |
515 \end{tabular}\hfill\numbered{ABSREP} |
506 \end{center} |
516 \end{center} |
507 % |
517 % |
508 \noindent |
518 \noindent |
509 where in the last two clauses we have that the quotient type @{text "\<alpha>s |
519 where in the last two clauses we have that the type @{text "\<alpha>s |
510 \<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example |
520 \<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example |
511 @{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha> |
521 @{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha> |
512 list"}). The quotient construction ensures that the type variables in @{text |
522 list"}). The quotient construction ensures that the type variables in @{text |
513 "\<rho>s"} must be among the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the |
523 "\<rho>s"} must be among the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the |
514 matchers for the @{text "\<alpha>s"} when matching @{text "\<rho>s \<kappa>"} against |
524 matchers for the @{text "\<alpha>s"} when matching @{text "\<rho>s \<kappa>"} against |
536 aggregate map-function: |
546 aggregate map-function: |
537 |
547 |
538 @{text [display, indent=10] "\<lambda>a b. map_prod (map a) b"} |
548 @{text [display, indent=10] "\<lambda>a b. map_prod (map a) b"} |
539 |
549 |
540 \noindent |
550 \noindent |
541 which we need to define the aggregate abstraction and representation functions. |
551 which we need in order to define the aggregate abstraction and representation |
|
552 functions. |
542 |
553 |
543 To see how these definitions pan out in practise, let us return to our |
554 To see how these definitions pan out in practise, let us return to our |
544 example about @{term "concat"} and @{term "fconcat"}, where we have the raw type |
555 example about @{term "concat"} and @{term "fconcat"}, where we have the raw type |
545 @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and the quotient type @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha> |
556 @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and the quotient type @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha> |
546 fset"}. Feeding them into @{text ABS} gives us (after some @{text "\<beta>"}-simplifications) |
557 fset"}. Feeding them into @{text ABS} gives us (after some @{text "\<beta>"}-simplifications) |
583 then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type |
594 then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type |
584 @{text "\<tau> \<Rightarrow> \<sigma>"}. |
595 @{text "\<tau> \<Rightarrow> \<sigma>"}. |
585 \end{lemma} |
596 \end{lemma} |
586 |
597 |
587 \begin{proof} |
598 \begin{proof} |
588 By induction and analysing the definitions of @{text "ABS"}, @{text "REP"} |
599 By mutual induction and analysing the definitions of @{text "ABS"}, @{text "REP"} |
589 and @{text "MAP"}. The cases of equal types and function types are |
600 and @{text "MAP"}. The cases of equal types and function types are |
590 straightforward (the latter follows from @{text "\<singlearr>"} having the |
601 straightforward (the latter follows from @{text "\<singlearr>"} having the |
591 type @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). In case of equal type |
602 type @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). In case of equal type |
592 constructors we can observe that a map-function after applying the functions |
603 constructors we can observe that a map-function after applying the functions |
593 @{text "ABS (\<sigma>s, \<tau>s)"} produces a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}. The |
604 @{text "ABS (\<sigma>s, \<tau>s)"} produces a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}. The |