303 text {* |
303 text {* |
304 The first step in a quotient constructions is to take a name for the new |
304 The first step in a quotient constructions is to take a name for the new |
305 type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation defined over a |
305 type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation defined over a |
306 raw type, say @{text "\<sigma>"}. The equivalence relation for the quotient |
306 raw type, say @{text "\<sigma>"}. The equivalence relation for the quotient |
307 construction, lets say @{text "R"}, must then be of type @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> |
307 construction, lets say @{text "R"}, must then be of type @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> |
308 bool"}. Given this data, we can automatically declare the quotient type as |
308 bool"}. The user-visible part of the declaration is therefore |
309 |
309 |
|
310 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
311 \isacommand{quotient\_type}~~@{text "\<alpha>s \<kappa>\<^isub>q = \<sigma> / R"} |
|
312 \end{isabelle} |
|
313 |
|
314 \noindent |
|
315 and a proof that @{text "R"} is indeed an equivalence relation. |
|
316 Given this data, we can internally declare the quotient type as |
310 |
317 |
311 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
318 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
312 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
319 \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
313 \end{isabelle} |
320 \end{isabelle} |
314 |
321 |
315 \noindent |
322 \noindent |
316 being the set of equivalence classes of @{text "R"}. The restriction in this declaration |
323 being the (non-empty) set of equivalence classes of @{text "R"}. The |
317 is that the type variables in the raw type @{text "\<sigma>"} must be included in the |
324 restriction in this declaration is that the type variables in the raw type |
318 type variables @{text "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us |
325 @{text "\<sigma>"} must be included in the type variables @{text "\<alpha>s"} declared for |
319 with abstraction and representation functions having the type |
326 @{text "\<kappa>\<^isub>q"}. HOL will provide us with abstraction and |
|
327 representation functions having the type |
320 |
328 |
321 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
329 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
322 @{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"} |
330 @{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"} |
323 \end{isabelle} |
331 \end{isabelle} |
324 |
332 |
325 \noindent |
333 \noindent |
326 relating the new quotient type and raw type. However, as Homeier noted, it is easier |
334 and relating the new quotient type and equivalence classes of the raw |
327 to work with the following derived definitions |
335 type. However, as Homeier \cite{Homeier05} noted, it is much more convenient |
328 |
336 to work with the following derived abstraction and representation functions |
|
337 |
329 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
338 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
330 @{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)"} |
339 @{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)"} |
331 \end{isabelle} |
340 \end{isabelle} |
332 |
341 |
333 \noindent |
342 \noindent |
334 on the expense of having to use Hilbert's choice operator @{text "\<epsilon>"}. With these |
343 on the expense of having to use Hilbert's choice operator @{text "\<epsilon>"} in the |
335 definitions the abstraction and representation functions relate directly the |
344 definition of @{text "Rep_\<kappa>\<^isub>q"}. These derived notions relate the quotient type |
336 quotient and raw types (their type is @{text "\<sigma> \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"} and @{text "\<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma>"}, |
345 and the raw type directly, as can be seen from their type, namely @{text "\<sigma> |
337 respectively). We can show that the property |
346 \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"} and @{text "\<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma>"}, respectively. Given that |
|
347 @{text "R"} is an equivalence relation, the following property |
338 |
348 |
339 @{text [display, indent=10] "Quotient R Abs_\<kappa>\<^isub>q Rep_\<kappa>\<^isub>q"} |
349 @{text [display, indent=10] "Quotient R Abs_\<kappa>\<^isub>q Rep_\<kappa>\<^isub>q"} |
340 |
350 |
341 \noindent |
351 \noindent |
342 holds (for the proof see \cite{Homeier05}). |
352 holds (for the proof see \cite{Homeier05}). |
|
353 |
|
354 The next step is to lift definitions over the raw type to definitions over the |
|
355 quotient type. For this we providing the declaration |
|
356 |
|
357 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
358 \isacommand{quotient\_definition}~~@{text "c :: \<tau>"}~\isacommand{is}~@{text "c' :: \<sigma>"} |
|
359 \end{isabelle} |
343 |
360 |
344 To define a constant on the lifted type, an aggregate abstraction |
361 To define a constant on the lifted type, an aggregate abstraction |
345 function is applied to the raw constant. Below we describe the operation |
362 function is applied to the raw constant. Below we describe the operation |
346 that generates |
363 that generates |
347 an aggregate @{term "Abs"} or @{term "Rep"} function given the |
364 an aggregate @{term "Abs"} or @{term "Rep"} function given the |