# HG changeset patch # User wenzelm # Date 970592123 -7200 # Node ID ba9297b71897da6f0bd69ae8d76938d3ddf28754 # Parent 9fa7d38904881554ad5b3b4a81fc4d90ad96b5c2 major cleanup -- improved typesetting; diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/Group/Group.thy --- a/doc-src/AxClass/Group/Group.thy Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/Group/Group.thy Tue Oct 03 18:55:23 2000 +0200 @@ -4,7 +4,7 @@ theory Group = Main: text {* - \medskip\noindent The meta-type system of Isabelle supports + \medskip\noindent The meta-level type system of Isabelle supports \emph{intersections} and \emph{inclusions} of type classes. These directly correspond to intersections and inclusions of type predicates in a purely set theoretic sense. This is sufficient as a @@ -21,56 +21,53 @@ *} consts - times :: "'a => 'a => 'a" (infixl "\" 70) - inverse :: "'a => 'a" ("(_\)" [1000] 999) - one :: 'a ("\") + times :: "'a \ 'a \ 'a" (infixl "\" 70) + inverse :: "'a \ 'a" ("(_\)" [1000] 999) + one :: 'a ("\") text {* - \noindent Next we define class $monoid$ of monoids with operations - $\TIMES$ and $1$. Note that multiple class axioms are allowed for - user convenience --- they simply represent the conjunction of their - respective universal closures. + \noindent Next we define class @{text monoid} of monoids with + operations @{text \} and @{text \}. Note that multiple class + axioms are allowed for user convenience --- they simply represent the + conjunction of their respective universal closures. *} -axclass - monoid < "term" - assoc: "(x \ y) \ z = x \ (y \ z)" - left_unit: "\ \ x = x" - right_unit: "x \ \ = x" +axclass monoid < "term" + assoc: "(x \ y) \ z = x \ (y \ z)" + left_unit: "\ \ x = x" + right_unit: "x \ \ = x" text {* - \noindent So class $monoid$ contains exactly those types $\tau$ where - $\TIMES :: \tau \To \tau \To \tau$ and $1 :: \tau$ are specified - appropriately, such that $\TIMES$ is associative and $1$ is a left - and right unit element for the $\TIMES$ operation. + \noindent So class @{text monoid} contains exactly those types @{text + \} where @{text "\ \ \ \ \ \ \"} and @{text "\ \ \"} are + specified appropriately, such that @{text \} is associative and + @{text \} is a left and right unit element for the @{text \} + operation. *} text {* - \medskip Independently of $monoid$, we now define a linear hierarchy - of semigroups, general groups and Abelian groups. Note that the - names of class axioms are automatically qualified with each class - name, so we may re-use common names such as $assoc$. + \medskip Independently of @{text monoid}, we now define a linear + hierarchy of semigroups, general groups and Abelian groups. Note + that the names of class axioms are automatically qualified with each + class name, so we may re-use common names such as @{text assoc}. *} -axclass - semigroup < "term" - assoc: "(x \ y) \ z = x \ (y \ z)" +axclass semigroup < "term" + assoc: "(x \ y) \ z = x \ (y \ z)" -axclass - group < semigroup - left_unit: "\ \ x = x" - left_inverse: "x\ \ x = \" +axclass group < semigroup + left_unit: "\ \ x = x" + left_inverse: "x\ \ x = \" -axclass - agroup < group - commute: "x \ y = y \ x" +axclass agroup < group + commute: "x \ y = y \ x" text {* - \noindent Class $group$ inherits associativity of $\TIMES$ from - $semigroup$ and adds two further group axioms. Similarly, $agroup$ - is defined as the subset of $group$ such that for all of its elements - $\tau$, the operation $\TIMES :: \tau \To \tau \To \tau$ is even - commutative. + \noindent Class @{text group} inherits associativity of @{text \} + from @{text semigroup} and adds two further group axioms. Similarly, + @{text agroup} is defined as the subset of @{text group} such that + for all of its elements @{text \}, the operation @{text "\ \ \ \ \ \ \"} + is even commutative. *} @@ -79,13 +76,13 @@ text {* In a sense, axiomatic type classes may be viewed as \emph{abstract theories}. Above class definitions gives rise to abstract axioms - $assoc$, $left_unit$, $left_inverse$, $commute$, where any of these - contain a type variable $\alpha :: c$ that is restricted to types of - the corresponding class $c$. \emph{Sort constraints} like this - express a logical precondition for the whole formula. For example, - $assoc$ states that for all $\tau$, provided that $\tau :: - semigroup$, the operation $\TIMES :: \tau \To \tau \To \tau$ is - associative. + @{text assoc}, @{text left_unit}, @{text left_inverse}, @{text + commute}, where any of these contain a type variable @{text "'a \ c"} + that is restricted to types of the corresponding class @{text c}. + \emph{Sort constraints} like this express a logical precondition for + the whole formula. For example, @{text assoc} states that for all + @{text \}, provided that @{text "\ \ semigroup"}, the operation + @{text "\ \ \ \ \ \ \"} is associative. \medskip From a technical point of view, abstract axioms are just ordinary Isabelle theorems, which may be used in proofs without @@ -94,21 +91,21 @@ well-known laws of general groups. *} -theorem group_right_inverse: "x \ x\ = (\\\'a\\group)" +theorem group_right_inverse: "x \ x\ = (\\'a\group)" proof - - have "x \ x\ = \ \ (x \ x\)" + have "x \ x\ = \ \ (x \ x\)" by (simp only: group.left_unit) - also have "... = \ \ x \ x\" + also have "... = \ \ x \ x\" by (simp only: semigroup.assoc) - also have "... = (x\)\ \ x\ \ x \ x\" + also have "... = (x\)\ \ x\ \ x \ x\" by (simp only: group.left_inverse) - also have "... = (x\)\ \ (x\ \ x) \ x\" + also have "... = (x\)\ \ (x\ \ x) \ x\" by (simp only: semigroup.assoc) - also have "... = (x\)\ \ \ \ x\" + also have "... = (x\)\ \ \ \ x\" by (simp only: group.left_inverse) - also have "... = (x\)\ \ (\ \ x\)" + also have "... = (x\)\ \ (\ \ x\)" by (simp only: semigroup.assoc) - also have "... = (x\)\ \ x\" + also have "... = (x\)\ \ x\" by (simp only: group.left_unit) also have "... = \" by (simp only: group.left_inverse) @@ -116,18 +113,18 @@ qed text {* - \noindent With $group_right_inverse$ already available, - $group_right_unit$\label{thm:group-right-unit} is now established - much easier. + \noindent With @{text group_right_inverse} already available, @{text + group_right_unit}\label{thm:group-right-unit} is now established much + easier. *} -theorem group_right_unit: "x \ \ = (x\\'a\\group)" +theorem group_right_unit: "x \ \ = (x\'a\group)" proof - - have "x \ \ = x \ (x\ \ x)" + have "x \ \ = x \ (x\ \ x)" by (simp only: group.left_inverse) - also have "... = x \ x\ \ x" + also have "... = x \ x\ \ x" by (simp only: semigroup.assoc) - also have "... = \ \ x" + also have "... = \ \ x" by (simp only: group_right_inverse) also have "... = x" by (simp only: group.left_unit) @@ -136,24 +133,25 @@ text {* \medskip Abstract theorems may be instantiated to only those types - $\tau$ where the appropriate class membership $\tau :: c$ is known at - Isabelle's type signature level. Since we have $agroup \subseteq - group \subseteq semigroup$ by definition, all theorems of $semigroup$ - and $group$ are automatically inherited by $group$ and $agroup$. + @{text \} where the appropriate class membership @{text "\ \ c"} is + known at Isabelle's type signature level. Since we have @{text + "agroup \ group \ semigroup"} by definition, all theorems of @{text + semigroup} and @{text group} are automatically inherited by @{text + group} and @{text agroup}. *} subsection {* Abstract instantiation *} text {* - From the definition, the $monoid$ and $group$ classes have been - independent. Note that for monoids, $right_unit$ had to be included - as an axiom, but for groups both $right_unit$ and $right_inverse$ are - derivable from the other axioms. With $group_right_unit$ derived as - a theorem of group theory (see page~\pageref{thm:group-right-unit}), - we may now instantiate $monoid \subseteq semigroup$ and $group - \subseteq monoid$ properly as follows - (cf.\ \figref{fig:monoid-group}). + From the definition, the @{text monoid} and @{text group} classes + have been independent. Note that for monoids, @{text right_unit} had + to be included as an axiom, but for groups both @{text right_unit} + and @{text right_inverse} are derivable from the other axioms. With + @{text group_right_unit} derived as a theorem of group theory (see + page~\pageref{thm:group-right-unit}), we may now instantiate @{text + "monoid \ semigroup"} and @{text "group \ monoid"} properly as + follows (cf.\ \figref{fig:monoid-group}). \begin{figure}[htbp] \begin{center} @@ -162,20 +160,20 @@ \begin{picture}(65,90)(0,-10) \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}} \put(15,50){\line(1,1){10}} \put(35,60){\line(1,-1){10}} - \put(15,5){\makebox(0,0){$agroup$}} - \put(15,25){\makebox(0,0){$group$}} - \put(15,45){\makebox(0,0){$semigroup$}} - \put(30,65){\makebox(0,0){$term$}} \put(50,45){\makebox(0,0){$monoid$}} + \put(15,5){\makebox(0,0){@{text agroup}}} + \put(15,25){\makebox(0,0){@{text group}}} + \put(15,45){\makebox(0,0){@{text semigroup}}} + \put(30,65){\makebox(0,0){@{text "term"}}} \put(50,45){\makebox(0,0){@{text monoid}}} \end{picture} \hspace{4em} \begin{picture}(30,90)(0,0) \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}} \put(15,50){\line(0,1){10}} \put(15,70){\line(0,1){10}} - \put(15,5){\makebox(0,0){$agroup$}} - \put(15,25){\makebox(0,0){$group$}} - \put(15,45){\makebox(0,0){$monoid$}} - \put(15,65){\makebox(0,0){$semigroup$}} - \put(15,85){\makebox(0,0){$term$}} + \put(15,5){\makebox(0,0){@{text agroup}}} + \put(15,25){\makebox(0,0){@{text group}}} + \put(15,45){\makebox(0,0){@{text monoid}}} + \put(15,65){\makebox(0,0){@{text semigroup}}} + \put(15,85){\makebox(0,0){@{text term}}} \end{picture} \caption{Monoids and groups: according to definition, and by proof} \label{fig:monoid-group} @@ -185,30 +183,30 @@ instance monoid < semigroup proof intro_classes - fix x y z :: "'a\\monoid" - show "x \ y \ z = x \ (y \ z)" + fix x y z :: "'a\monoid" + show "x \ y \ z = x \ (y \ z)" by (rule monoid.assoc) qed instance group < monoid proof intro_classes - fix x y z :: "'a\\group" - show "x \ y \ z = x \ (y \ z)" + fix x y z :: "'a\group" + show "x \ y \ z = x \ (y \ z)" by (rule semigroup.assoc) - show "\ \ x = x" + show "\ \ x = x" by (rule group.left_unit) - show "x \ \ = x" + show "x \ \ = x" by (rule group_right_unit) qed text {* \medskip The $\isakeyword{instance}$ command sets up an appropriate goal that represents the class inclusion (or type arity, see - \secref{sec:inst-arity}) to be proven - (see also \cite{isabelle-isar-ref}). The $intro_classes$ proof - method does back-chaining of class membership statements wrt.\ the - hierarchy of any classes defined in the current theory; the effect is - to reduce to the initial statement to a number of goals that directly + \secref{sec:inst-arity}) to be proven (see also + \cite{isabelle-isar-ref}). The @{text intro_classes} proof method + does back-chaining of class membership statements wrt.\ the hierarchy + of any classes defined in the current theory; the effect is to reduce + to the initial statement to a number of goals that directly correspond to any class axioms encountered on the path upwards through the class hierarchy. *} @@ -226,15 +224,15 @@ class membership may be established at the logical level and then transferred to Isabelle's type signature level. - \medskip As a typical example, we show that type $bool$ with - exclusive-or as $\TIMES$ operation, identity as $\isasyminv$, and - $False$ as $1$ forms an Abelian group. + \medskip As a typical example, we show that type @{typ bool} with + exclusive-or as @{text \} operation, identity as @{text \}, and + @{term False} as @{text \} forms an Abelian group. *} defs (overloaded) - times_bool_def: "x \ y \\ x \\ (y\\bool)" - inverse_bool_def: "x\ \\ x\\bool" - unit_bool_def: "\ \\ False" + times_bool_def: "x \ y \ x \ (y\bool)" + inverse_bool_def: "x\ \ x\bool" + unit_bool_def: "\ \ False" text {* \medskip It is important to note that above $\DEFS$ are just @@ -247,18 +245,18 @@ best applied in the context of type classes. \medskip Since we have chosen above $\DEFS$ of the generic group - operations on type $bool$ appropriately, the class membership $bool - :: agroup$ may be now derived as follows. + operations on type @{typ bool} appropriately, the class membership + @{text "bool \ agroup"} may be now derived as follows. *} instance bool :: agroup proof (intro_classes, unfold times_bool_def inverse_bool_def unit_bool_def) fix x y z - show "((x \\ y) \\ z) = (x \\ (y \\ z))" by blast - show "(False \\ x) = x" by blast - show "(x \\ x) = False" by blast - show "(x \\ y) = (y \\ x)" by blast + show "((x \ y) \ z) = (x \ (y \ z))" by blast + show "(False \ x) = x" by blast + show "(x \ x) = False" by blast + show "(x \ y) = (y \ x)" by blast qed text {* @@ -268,12 +266,13 @@ care of this new instance automatically. \medskip We could now also instantiate our group theory classes to - many other concrete types. For example, $int :: agroup$ (e.g.\ by - defining $\TIMES$ as addition, $\isasyminv$ as negation and $1$ as - zero) or $list :: (term)semigroup$ (e.g.\ if $\TIMES$ is defined as - list append). Thus, the characteristic constants $\TIMES$, - $\isasyminv$, $1$ really become overloaded, i.e.\ have different - meanings on different types. + many other concrete types. For example, @{text "int \ agroup"} + (e.g.\ by defining @{text \} as addition, @{text \} as negation + and @{text \} as zero) or @{text "list \ (term) semigroup"} + (e.g.\ if @{text \} is defined as list append). Thus, the + characteristic constants @{text \}, @{text \}, @{text \} + really become overloaded, i.e.\ have different meanings on different + types. *} @@ -288,27 +287,27 @@ This feature enables us to \emph{lift operations}, say to Cartesian products, direct sums or function spaces. Subsequently we lift - $\TIMES$ component-wise to binary products $\alpha \times \beta$. + @{text \} component-wise to binary products @{typ "'a \ 'b"}. *} defs (overloaded) - times_prod_def: "p \ q \\ (fst p \ fst q, snd p \ snd q)" + times_prod_def: "p \ q \ (fst p \ fst q, snd p \ snd q)" text {* - It is very easy to see that associativity of $\TIMES^\alpha$ and - $\TIMES^\beta$ transfers to ${\TIMES}^{\alpha \times \beta}$. Hence - the binary type constructor $\times$ maps semigroups to semigroups. - This may be established formally as follows. + It is very easy to see that associativity of @{text \} on @{typ 'a} + and @{text \} on @{typ 'b} transfers to @{text \} on @{typ "'a \ 'b"}. + Hence the binary type constructor @{text \} maps semigroups to + semigroups. This may be established formally as follows. *} instance * :: (semigroup, semigroup) semigroup proof (intro_classes, unfold times_prod_def) - fix p q r :: "'a\\semigroup \\ 'b\\semigroup" + fix p q r :: "'a\semigroup \ 'b\semigroup" show - "(fst (fst p \ fst q, snd p \ snd q) \ fst r, - snd (fst p \ fst q, snd p \ snd q) \ snd r) = - (fst p \ fst (fst q \ fst r, snd q \ snd r), - snd p \ snd (fst q \ fst r, snd q \ snd r))" + "(fst (fst p \ fst q, snd p \ snd q) \ fst r, + snd (fst p \ fst q, snd p \ snd q) \ snd r) = + (fst p \ fst (fst q \ fst r, snd q \ snd r), + snd p \ snd (fst q \ fst r, snd q \ snd r))" by (simp add: semigroup.assoc) qed diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/Group/Product.thy --- a/doc-src/AxClass/Group/Product.thy Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/Group/Product.thy Tue Oct 03 18:55:23 2000 +0200 @@ -6,67 +6,70 @@ text {* \medskip\noindent There is still a feature of Isabelle's type system left that we have not yet discussed. When declaring polymorphic - constants $c :: \sigma$, the type variables occurring in $\sigma$ may - be constrained by type classes (or even general sorts) in an + constants @{text "c \ \"}, the type variables occurring in @{text \} + may be constrained by type classes (or even general sorts) in an arbitrary way. Note that by default, in Isabelle/HOL the declaration - $\TIMES :: \alpha \To \alpha \To \alpha$ is actually an abbreviation - for $\TIMES :: (\alpha::term) \To \alpha \To \alpha$. Since class - $term$ is the universal class of HOL, this is not really a constraint - at all. + @{text "\ \ 'a \ 'a \ 'a"} is actually an abbreviation for + @{text "\ \ 'a\term \ 'a \ 'a"} Since class @{text "term"} is the + universal class of HOL, this is not really a constraint at all. - The $product$ class below provides a less degenerate example of + The @{text product} class below provides a less degenerate example of syntactic type classes. *} axclass product < "term" consts - product :: "'a::product \\ 'a \\ 'a" (infixl "\\" 70) + product :: "'a\product \ 'a \ 'a" (infixl "\" 70) text {* - Here class $product$ is defined as subclass of $term$ without any - additional axioms. This effects in logical equivalence of $product$ - and $term$, as is reflected by the trivial introduction rule - generated for this definition. + Here class @{text product} is defined as subclass of @{text term} + without any additional axioms. This effects in logical equivalence + of @{text product} and @{text term}, as is reflected by the trivial + introduction rule generated for this definition. - \medskip So what is the difference of declaring $\TIMES :: (\alpha :: - product) \To \alpha \To \alpha$ vs.\ declaring $\TIMES :: (\alpha :: - term) \To \alpha \To \alpha$ anyway? In this particular case where - $product \equiv term$, it should be obvious that both declarations - are the same from the logic's point of view. It even makes the most - sense to remove sort constraints from constant declarations, as far - as the purely logical meaning is concerned \cite{Wenzel:1997:TPHOL}. + \medskip So what is the difference of declaring + @{text "\ \ 'a\product \ 'a \ 'a"} vs.\ declaring + @{text "\ \ 'a\term \ 'a \ 'a"} anyway? In this particular case + where @{text "product \ term"}, it should be obvious that both + declarations are the same from the logic's point of view. It even + makes the most sense to remove sort constraints from constant + declarations, as far as the purely logical meaning is concerned + \cite{Wenzel:1997:TPHOL}. On the other hand there are syntactic differences, of course. - Constants $\TIMES^\tau$ are rejected by the type-checker, unless the - arity $\tau :: product$ is part of the type signature. In our - example, this arity may be always added when required by means of an - $\isarkeyword{instance}$ with the trivial proof $\BY{intro_classes}$. + Constants @{text \} on some type @{text \} are rejected by the + type-checker, unless the arity @{text "\ \ product"} is part of the + type signature. In our example, this arity may be always added when + required by means of an $\isarkeyword{instance}$ with the trivial + proof $\BY{intro_classes}$. \medskip Thus, we may observe the following discipline of using syntactic classes. Overloaded polymorphic constants have their type - arguments restricted to an associated (logically trivial) class $c$. - Only immediately before \emph{specifying} these constants on a - certain type $\tau$ do we instantiate $\tau :: c$. + arguments restricted to an associated (logically trivial) class + @{text c}. Only immediately before \emph{specifying} these constants + on a certain type @{text \} do we instantiate @{text "\ \ c"}. - This is done for class $product$ and type $bool$ as follows. + This is done for class @{text product} and type @{typ bool} as + follows. *} instance bool :: product by intro_classes defs (overloaded) - product_bool_def: "x \\ y \\ x \\ y" + product_bool_def: "x \ y \ x \ y" text {* - The definition $prod_bool_def$ becomes syntactically well-formed only - after the arity $bool :: product$ is made known to the type checker. + The definition @{text prod_bool_def} becomes syntactically + well-formed only after the arity @{text "bool \ product"} is made + known to the type checker. \medskip It is very important to see that above $\DEFS$ are not directly connected with $\isarkeyword{instance}$ at all! We were - just following our convention to specify $\TIMES$ on $bool$ after - having instantiated $bool :: product$. Isabelle does not require - these definitions, which is in contrast to programming languages like - Haskell \cite{haskell-report}. + just following our convention to specify @{text \} on @{typ bool} + after having instantiated @{text "bool \ product"}. Isabelle does + not require these definitions, which is in contrast to programming + languages like Haskell \cite{haskell-report}. \medskip While Isabelle type classes and those of Haskell are almost the same as far as type-checking and type inference are concerned, @@ -75,9 +78,9 @@ Therefore, its \texttt{instance} has a \texttt{where} part that tells the system what these ``member functions'' should be. - This style of \texttt{instance} won't make much sense in Isabelle's - meta-logic, because there is no internal notion of ``providing - operations'' or even ``names of functions''. + This style of \texttt{instance} would not make much sense in + Isabelle's meta-logic, because there is no internal notion of + ``providing operations'' or even ``names of functions''. *} end \ No newline at end of file diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/Group/Semigroups.thy --- a/doc-src/AxClass/Group/Semigroups.thy Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/Group/Semigroups.thy Tue Oct 03 18:55:23 2000 +0200 @@ -7,49 +7,47 @@ \medskip\noindent An axiomatic type class is simply a class of types that all meet certain properties, which are also called \emph{class axioms}. Thus, type classes may be also understood as type predicates - --- i.e.\ abstractions over a single type argument $\alpha$. Class + --- i.e.\ abstractions over a single type argument @{typ 'a}. Class axioms typically contain polymorphic constants that depend on this - type $\alpha$. These \emph{characteristic constants} behave like - operations associated with the ``carrier'' type $\alpha$. + type @{typ 'a}. These \emph{characteristic constants} behave like + operations associated with the ``carrier'' type @{typ 'a}. We illustrate these basic concepts by the following formulation of semigroups. *} consts - times :: "'a \\ 'a \\ 'a" (infixl "\" 70) -axclass - semigroup < "term" - assoc: "(x \ y) \ z = x \ (y \ z)" + times :: "'a \ 'a \ 'a" (infixl "\" 70) +axclass semigroup < "term" + assoc: "(x \ y) \ z = x \ (y \ z)" text {* - \noindent Above we have first declared a polymorphic constant $\TIMES - :: \alpha \To \alpha \To \alpha$ and then defined the class - $semigroup$ of all types $\tau$ such that $\TIMES :: \tau \To \tau - \To \tau$ is indeed an associative operator. The $assoc$ axiom - contains exactly one type variable, which is invisible in the above - presentation, though. Also note that free term variables (like $x$, - $y$, $z$) are allowed for user convenience --- conceptually all of - these are bound by outermost universal quantifiers. + \noindent Above we have first declared a polymorphic constant @{text + "\ \ 'a \ 'a \ 'a"} and then defined the class @{text semigroup} of + all types @{text \} such that @{text "\ \ \ \ \ \ \"} is indeed an + associative operator. The @{text assoc} axiom contains exactly one + type variable, which is invisible in the above presentation, though. + Also note that free term variables (like @{term x}, @{term y}, @{term + z}) are allowed for user convenience --- conceptually all of these + are bound by outermost universal quantifiers. \medskip In general, type classes may be used to describe - \emph{structures} with exactly one carrier $\alpha$ and a fixed + \emph{structures} with exactly one carrier @{typ 'a} and a fixed \emph{signature}. Different signatures require different classes. - Below, class $plus_semigroup$ represents semigroups of the form - $(\tau, \PLUS^\tau)$, while the original $semigroup$ would correspond - to semigroups $(\tau, \TIMES^\tau)$. + Below, class @{text plus_semigroup} represents semigroups of the form + @{text "(\, \)"}, while the original @{text semigroup} would + correspond to semigroups @{text "(\, \)"}. *} consts - plus :: "'a \\ 'a \\ 'a" (infixl "\" 70) -axclass - plus_semigroup < "term" - assoc: "(x \ y) \ z = x \ (y \ z)" + plus :: "'a \ 'a \ 'a" (infixl "\" 70) +axclass plus_semigroup < "term" + assoc: "(x \ y) \ z = x \ (y \ z)" text {* - \noindent Even if classes $plus_semigroup$ and $semigroup$ both - represent semigroups in a sense, they are certainly not quite the - same. + \noindent Even if classes @{text plus_semigroup} and @{text + semigroup} both represent semigroups in a sense, they are certainly + not quite the same. *} end \ No newline at end of file diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/Nat/NatClass.ML --- a/doc-src/AxClass/Nat/NatClass.ML Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/Nat/NatClass.ML Tue Oct 03 18:55:23 2000 +0200 @@ -34,7 +34,7 @@ back(); back(); -Goalw [add_def] "0+n = n"; +Goalw [add_def] "\\+n = n"; by (rtac rec_0 1); qed "add_0"; @@ -50,7 +50,7 @@ by (Asm_simp_tac 1); qed "add_assoc"; -Goal "m+0 = m"; +Goal "m+\\ = m"; by (res_inst_tac [("n","m")] induct 1); by (Simp_tac 1); by (Asm_simp_tac 1); diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/Nat/NatClass.thy --- a/doc-src/AxClass/Nat/NatClass.thy Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/Nat/NatClass.thy Tue Oct 03 18:55:23 2000 +0200 @@ -15,34 +15,33 @@ *} consts - zero :: 'a ("0") - Suc :: "'a \\ 'a" - rec :: "'a \\ 'a \\ ('a \\ 'a \\ 'a) \\ 'a" + zero :: 'a ("\") + Suc :: "'a \ 'a" + rec :: "'a \ 'a \ ('a \ 'a \ 'a) \ 'a" -axclass - nat < "term" - induct: "P(0) \\ (\\x. P(x) \\ P(Suc(x))) \\ P(n)" - Suc_inject: "Suc(m) = Suc(n) \\ m = n" - Suc_neq_0: "Suc(m) = 0 \\ R" - rec_0: "rec(0, a, f) = a" - rec_Suc: "rec(Suc(m), a, f) = f(m, rec(m, a, f))" +axclass nat < "term" + induct: "P(\) \ (\x. P(x) \ P(Suc(x))) \ P(n)" + Suc_inject: "Suc(m) = Suc(n) \ m = n" + Suc_neq_0: "Suc(m) = \ \ R" + rec_0: "rec(\, a, f) = a" + rec_Suc: "rec(Suc(m), a, f) = f(m, rec(m, a, f))" constdefs - add :: "'a::nat \\ 'a \\ 'a" (infixl "+" 60) - "m + n \\ rec(m, n, \\x y. Suc(y))" + add :: "'a::nat \ 'a \ 'a" (infixl "+" 60) + "m + n \ rec(m, n, \x y. Suc(y))" text {* - This is an abstract version of the plain $Nat$ theory in + This is an abstract version of the plain @{text Nat} theory in FOL.\footnote{See \url{http://isabelle.in.tum.de/library/FOL/ex/Nat.html}} Basically, - we have just replaced all occurrences of type $nat$ by $\alpha$ and - used the natural number axioms to define class $nat$. There is only - a minor snag, that the original recursion operator $rec$ had to be - made monomorphic. + we have just replaced all occurrences of type @{text nat} by @{typ + 'a} and used the natural number axioms to define class @{text nat}. + There is only a minor snag, that the original recursion operator + @{term rec} had to be made monomorphic. - Thus class $nat$ contains exactly those types $\tau$ that are - isomorphic to ``the'' natural numbers (with signature $0$, $Suc$, - $rec$). + Thus class @{text nat} contains exactly those types @{text \} that + are isomorphic to ``the'' natural numbers (with signature @{term + \}, @{term Suc}, @{term rec}). \medskip What we have done here can be also viewed as \emph{type specification}. Of course, it still remains open if there is some diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/axclass.tex --- a/doc-src/AxClass/axclass.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/axclass.tex Tue Oct 03 18:55:23 2000 +0200 @@ -1,15 +1,13 @@ \documentclass[12pt,a4paper,fleqn]{report} -\usepackage{graphicx,../iman,../extra,../isar,../pdfsetup} +\usepackage{graphicx,../iman,../extra,../isar} \usepackage{generated/isabelle,generated/isabellesym} +\usepackage{../pdfsetup} % last one! -\newcommand{\TIMES}{\cdot} -\newcommand{\PLUS}{\oplus} -\newcommand{\isasymOtimes}{\emph{$\cdot$}} -\newcommand{\isasymOplus}{\emph{$\oplus$}} +\isabellestyle{it} \newcommand{\isasyminv}{\emph{${}^{-1}$}} \newcommand{\isasymunit}{\emph{$1$}} - +\newcommand{\isasymzero}{\emph{$0$}} \newcommand{\secref}[1]{\S\ref{#1}} \newcommand{\figref}[1]{figure~\ref{#1}} diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/body.tex --- a/doc-src/AxClass/body.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/body.tex Tue Oct 03 18:55:23 2000 +0200 @@ -44,7 +44,7 @@ object-logic that directly uses the meta type system, such as Isabelle/HOL \cite{isabelle-HOL}. Subsequently, we present various examples that are all formulated within HOL, except the one of \secref{sec:ex-natclass} which is in -FOL. See also \url{http://isabelle.in.tum.de/library/HOL/AxClass/} and +FOL. See also \url{http://isabelle.in.tum.de/library/HOL/AxClasses/} and \url{http://isabelle.in.tum.de/library/FOL/ex/NatClass.html}. \input{generated/Semigroups} diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/generated/Group.tex --- a/doc-src/AxClass/generated/Group.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/generated/Group.tex Tue Oct 03 18:55:23 2000 +0200 @@ -5,7 +5,7 @@ \isamarkupheader{Basic group theory} \isacommand{theory}\ Group\ {\isacharequal}\ Main{\isacharcolon}% \begin{isamarkuptext}% -\medskip\noindent The meta-type system of Isabelle supports +\medskip\noindent The meta-level type system of Isabelle supports \emph{intersections} and \emph{inclusions} of type classes. These directly correspond to intersections and inclusions of type predicates in a purely set theoretic sense. This is sufficient as a @@ -21,51 +21,47 @@ signature parts of our structures.% \end{isamarkuptext}% \isacommand{consts}\isanewline -\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymOtimes}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline -\ \ inverse\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isacharequal}{\isachargreater}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharparenleft}{\isacharunderscore}{\isasyminv}{\isacharparenright}{\isachardoublequote}\ {\isacharbrackleft}\isadigit{1}\isadigit{0}\isadigit{0}\isadigit{0}{\isacharbrackright}\ \isadigit{9}\isadigit{9}\isadigit{9}{\isacharparenright}\isanewline -\ \ one\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymunit}{\isachardoublequote}{\isacharparenright}% +\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline +\ \ inverse\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharparenleft}{\isacharunderscore}{\isasyminv}{\isacharparenright}{\isachardoublequote}\ {\isacharbrackleft}\isadigit{1}\isadigit{0}\isadigit{0}\isadigit{0}{\isacharbrackright}\ \isadigit{9}\isadigit{9}\isadigit{9}{\isacharparenright}\isanewline +\ \ one\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymunit}{\isachardoublequote}{\isacharparenright}% \begin{isamarkuptext}% -\noindent Next we define class $monoid$ of monoids with operations - $\TIMES$ and $1$. Note that multiple class axioms are allowed for - user convenience --- they simply represent the conjunction of their - respective universal closures.% +\noindent Next we define class \isa{monoid} of monoids with + operations \isa{{\isasymodot}} and \isa{{\isasymunit}}. Note that multiple class + axioms are allowed for user convenience --- they simply represent the + conjunction of their respective universal closures.% \end{isamarkuptext}% -\isacommand{axclass}\isanewline -\ \ monoid\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline -\ \ assoc{\isacharcolon}\ \ \ \ \ \ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOtimes}\ y{\isacharparenright}\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline -\ \ left{\isacharunderscore}unit{\isacharcolon}\ \ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline -\ \ right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}% +\isacommand{axclass}\ monoid\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline +\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymodot}\ y{\isacharparenright}\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}\isanewline +\ \ left{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}{\isasymunit}\ {\isasymodot}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline +\ \ right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}% \begin{isamarkuptext}% -\noindent So class $monoid$ contains exactly those types $\tau$ where - $\TIMES :: \tau \To \tau \To \tau$ and $1 :: \tau$ are specified - appropriately, such that $\TIMES$ is associative and $1$ is a left - and right unit element for the $\TIMES$ operation.% +\noindent So class \isa{monoid} contains exactly those types \isa{{\isasymtau}} where \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} and \isa{{\isasymunit}\ {\isasymColon}\ {\isasymtau}} are + specified appropriately, such that \isa{{\isasymodot}} is associative and + \isa{{\isasymunit}} is a left and right unit element for the \isa{{\isasymodot}} + operation.% \end{isamarkuptext}% % \begin{isamarkuptext}% -\medskip Independently of $monoid$, we now define a linear hierarchy - of semigroups, general groups and Abelian groups. Note that the - names of class axioms are automatically qualified with each class - name, so we may re-use common names such as $assoc$.% +\medskip Independently of \isa{monoid}, we now define a linear + hierarchy of semigroups, general groups and Abelian groups. Note + that the names of class axioms are automatically qualified with each + class name, so we may re-use common names such as \isa{assoc}.% \end{isamarkuptext}% -\isacommand{axclass}\isanewline -\ \ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline -\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOtimes}\ y{\isacharparenright}\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline +\isacommand{axclass}\ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline +\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymodot}\ y{\isacharparenright}\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}\isanewline \isanewline -\isacommand{axclass}\isanewline -\ \ group\ {\isacharless}\ semigroup\isanewline -\ \ left{\isacharunderscore}unit{\isacharcolon}\ \ \ \ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline -\ \ left{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x{\isasyminv}\ {\isasymOtimes}\ x\ {\isacharequal}\ {\isasymunit}{\isachardoublequote}\isanewline +\isacommand{axclass}\ group\ {\isacharless}\ semigroup\isanewline +\ \ left{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}{\isasymunit}\ {\isasymodot}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline +\ \ left{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x{\isasyminv}\ {\isasymodot}\ x\ {\isacharequal}\ {\isasymunit}{\isachardoublequote}\isanewline \isanewline -\isacommand{axclass}\isanewline -\ \ agroup\ {\isacharless}\ group\isanewline -\ \ commute{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isacharequal}\ y\ {\isasymOtimes}\ x{\isachardoublequote}% +\isacommand{axclass}\ agroup\ {\isacharless}\ group\isanewline +\ \ commute{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ y\ {\isacharequal}\ y\ {\isasymodot}\ x{\isachardoublequote}% \begin{isamarkuptext}% -\noindent Class $group$ inherits associativity of $\TIMES$ from - $semigroup$ and adds two further group axioms. Similarly, $agroup$ - is defined as the subset of $group$ such that for all of its elements - $\tau$, the operation $\TIMES :: \tau \To \tau \To \tau$ is even - commutative.% +\noindent Class \isa{group} inherits associativity of \isa{{\isasymodot}} + from \isa{semigroup} and adds two further group axioms. Similarly, + \isa{agroup} is defined as the subset of \isa{group} such that + for all of its elements \isa{{\isasymtau}}, the operation \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} + is even commutative.% \end{isamarkuptext}% % \isamarkupsubsection{Abstract reasoning} @@ -73,13 +69,12 @@ \begin{isamarkuptext}% In a sense, axiomatic type classes may be viewed as \emph{abstract theories}. Above class definitions gives rise to abstract axioms - $assoc$, $left_unit$, $left_inverse$, $commute$, where any of these - contain a type variable $\alpha :: c$ that is restricted to types of - the corresponding class $c$. \emph{Sort constraints} like this - express a logical precondition for the whole formula. For example, - $assoc$ states that for all $\tau$, provided that $\tau :: - semigroup$, the operation $\TIMES :: \tau \To \tau \To \tau$ is - associative. + \isa{assoc}, \isa{left{\isacharunderscore}unit}, \isa{left{\isacharunderscore}inverse}, \isa{commute}, where any of these contain a type variable \isa{{\isacharprime}a\ {\isasymColon}\ c} + that is restricted to types of the corresponding class \isa{c}. + \emph{Sort constraints} like this express a logical precondition for + the whole formula. For example, \isa{assoc} states that for all + \isa{{\isasymtau}}, provided that \isa{{\isasymtau}\ {\isasymColon}\ semigroup}, the operation + \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} is associative. \medskip From a technical point of view, abstract axioms are just ordinary Isabelle theorems, which may be used in proofs without @@ -87,38 +82,37 @@ ``abstract theorems''. For example, we may now derive the following well-known laws of general groups.% \end{isamarkuptext}% -\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ x{\isasyminv}\ {\isacharequal}\ {\isacharparenleft}{\isasymunit}{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline +\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}inverse{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ x{\isasyminv}\ {\isacharequal}\ {\isacharparenleft}{\isasymunit}{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline \isacommand{proof}\ {\isacharminus}\isanewline -\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymOtimes}\ x{\isasyminv}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ {\isacharparenleft}x\ {\isasymOtimes}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymodot}\ x{\isasyminv}\ {\isacharequal}\ {\isasymunit}\ {\isasymodot}\ {\isacharparenleft}x\ {\isasymodot}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ x\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymodot}\ x\ {\isasymodot}\ x{\isasyminv}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ x{\isasyminv}\ {\isasymOtimes}\ x\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymodot}\ x{\isasyminv}\ {\isasymodot}\ x\ {\isasymodot}\ x{\isasyminv}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isacharparenleft}x{\isasyminv}\ {\isasymOtimes}\ x{\isacharparenright}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymodot}\ {\isacharparenleft}x{\isasyminv}\ {\isasymodot}\ x{\isacharparenright}\ {\isasymodot}\ x{\isasyminv}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isasymunit}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymodot}\ {\isasymunit}\ {\isasymodot}\ x{\isasyminv}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ {\isacharparenleft}{\isasymunit}\ {\isasymOtimes}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymodot}\ {\isacharparenleft}{\isasymunit}\ {\isasymodot}\ x{\isasyminv}{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymOtimes}\ x{\isasyminv}{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isacharparenleft}x{\isasyminv}{\isacharparenright}{\isasyminv}\ {\isasymodot}\ x{\isasyminv}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline \ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline \ \ \isacommand{finally}\ \isacommand{show}\ {\isacharquery}thesis\ \isacommand{{\isachardot}}\isanewline \isacommand{qed}% \begin{isamarkuptext}% -\noindent With $group_right_inverse$ already available, - $group_right_unit$\label{thm:group-right-unit} is now established - much easier.% +\noindent With \isa{group{\isacharunderscore}right{\isacharunderscore}inverse} already available, \isa{group{\isacharunderscore}right{\isacharunderscore}unit}\label{thm:group-right-unit} is now established much + easier.% \end{isamarkuptext}% -\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline +\isacommand{theorem}\ group{\isacharunderscore}right{\isacharunderscore}unit{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ {\isasymunit}\ {\isacharequal}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isasymColon}group{\isacharparenright}{\isachardoublequote}\isanewline \isacommand{proof}\ {\isacharminus}\isanewline -\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}x{\isasyminv}\ {\isasymOtimes}\ x{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \isacommand{have}\ {\isachardoublequote}x\ {\isasymodot}\ {\isasymunit}\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}x{\isasyminv}\ {\isasymodot}\ x{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}inverse{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ x\ {\isasymOtimes}\ x{\isasyminv}\ {\isasymOtimes}\ x{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ x\ {\isasymodot}\ x{\isasyminv}\ {\isasymodot}\ x{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline -\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymOtimes}\ x{\isachardoublequote}\isanewline +\ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ {\isasymunit}\ {\isasymodot}\ x{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isacharunderscore}right{\isacharunderscore}inverse{\isacharparenright}\isanewline \ \ \isacommand{also}\ \isacommand{have}\ {\isachardoublequote}{\isachardot}{\isachardot}{\isachardot}\ {\isacharequal}\ x{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ only{\isacharcolon}\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline @@ -126,23 +120,20 @@ \isacommand{qed}% \begin{isamarkuptext}% \medskip Abstract theorems may be instantiated to only those types - $\tau$ where the appropriate class membership $\tau :: c$ is known at - Isabelle's type signature level. Since we have $agroup \subseteq - group \subseteq semigroup$ by definition, all theorems of $semigroup$ - and $group$ are automatically inherited by $group$ and $agroup$.% + \isa{{\isasymtau}} where the appropriate class membership \isa{{\isasymtau}\ {\isasymColon}\ c} is + known at Isabelle's type signature level. Since we have \isa{agroup\ {\isasymsubseteq}\ group\ {\isasymsubseteq}\ semigroup} by definition, all theorems of \isa{semigroup} and \isa{group} are automatically inherited by \isa{group} and \isa{agroup}.% \end{isamarkuptext}% % \isamarkupsubsection{Abstract instantiation} % \begin{isamarkuptext}% -From the definition, the $monoid$ and $group$ classes have been - independent. Note that for monoids, $right_unit$ had to be included - as an axiom, but for groups both $right_unit$ and $right_inverse$ are - derivable from the other axioms. With $group_right_unit$ derived as - a theorem of group theory (see page~\pageref{thm:group-right-unit}), - we may now instantiate $monoid \subseteq semigroup$ and $group - \subseteq monoid$ properly as follows - (cf.\ \figref{fig:monoid-group}). +From the definition, the \isa{monoid} and \isa{group} classes + have been independent. Note that for monoids, \isa{right{\isacharunderscore}unit} had + to be included as an axiom, but for groups both \isa{right{\isacharunderscore}unit} + and \isa{right{\isacharunderscore}inverse} are derivable from the other axioms. With + \isa{group{\isacharunderscore}right{\isacharunderscore}unit} derived as a theorem of group theory (see + page~\pageref{thm:group-right-unit}), we may now instantiate \isa{monoid\ {\isasymsubseteq}\ semigroup} and \isa{group\ {\isasymsubseteq}\ monoid} properly as + follows (cf.\ \figref{fig:monoid-group}). \begin{figure}[htbp] \begin{center} @@ -151,20 +142,20 @@ \begin{picture}(65,90)(0,-10) \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}} \put(15,50){\line(1,1){10}} \put(35,60){\line(1,-1){10}} - \put(15,5){\makebox(0,0){$agroup$}} - \put(15,25){\makebox(0,0){$group$}} - \put(15,45){\makebox(0,0){$semigroup$}} - \put(30,65){\makebox(0,0){$term$}} \put(50,45){\makebox(0,0){$monoid$}} + \put(15,5){\makebox(0,0){\isa{agroup}}} + \put(15,25){\makebox(0,0){\isa{group}}} + \put(15,45){\makebox(0,0){\isa{semigroup}}} + \put(30,65){\makebox(0,0){\isa{term}}} \put(50,45){\makebox(0,0){\isa{monoid}}} \end{picture} \hspace{4em} \begin{picture}(30,90)(0,0) \put(15,10){\line(0,1){10}} \put(15,30){\line(0,1){10}} \put(15,50){\line(0,1){10}} \put(15,70){\line(0,1){10}} - \put(15,5){\makebox(0,0){$agroup$}} - \put(15,25){\makebox(0,0){$group$}} - \put(15,45){\makebox(0,0){$monoid$}} - \put(15,65){\makebox(0,0){$semigroup$}} - \put(15,85){\makebox(0,0){$term$}} + \put(15,5){\makebox(0,0){\isa{agroup}}} + \put(15,25){\makebox(0,0){\isa{group}}} + \put(15,45){\makebox(0,0){\isa{monoid}}} + \put(15,65){\makebox(0,0){\isa{semigroup}}} + \put(15,85){\makebox(0,0){\isa{term}}} \end{picture} \caption{Monoids and groups: according to definition, and by proof} \label{fig:monoid-group} @@ -174,28 +165,28 @@ \isacommand{instance}\ monoid\ {\isacharless}\ semigroup\isanewline \isacommand{proof}\ intro{\isacharunderscore}classes\isanewline \ \ \isacommand{fix}\ x\ y\ z\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}monoid{\isachardoublequote}\isanewline -\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymodot}\ y\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ monoid{\isachardot}assoc{\isacharparenright}\isanewline \isacommand{qed}\isanewline \isanewline \isacommand{instance}\ group\ {\isacharless}\ monoid\isanewline \isacommand{proof}\ intro{\isacharunderscore}classes\isanewline \ \ \isacommand{fix}\ x\ y\ z\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}group{\isachardoublequote}\isanewline -\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymodot}\ y\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline -\ \ \isacommand{show}\ {\isachardoublequote}{\isasymunit}\ {\isasymOtimes}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline +\ \ \isacommand{show}\ {\isachardoublequote}{\isasymunit}\ {\isasymodot}\ x\ {\isacharequal}\ x{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ group{\isachardot}left{\isacharunderscore}unit{\isacharparenright}\isanewline -\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymOtimes}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}\isanewline +\ \ \isacommand{show}\ {\isachardoublequote}x\ {\isasymodot}\ {\isasymunit}\ {\isacharequal}\ x{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}rule\ group{\isacharunderscore}right{\isacharunderscore}unit{\isacharparenright}\isanewline \isacommand{qed}% \begin{isamarkuptext}% \medskip The $\isakeyword{instance}$ command sets up an appropriate goal that represents the class inclusion (or type arity, see - \secref{sec:inst-arity}) to be proven - (see also \cite{isabelle-isar-ref}). The $intro_classes$ proof - method does back-chaining of class membership statements wrt.\ the - hierarchy of any classes defined in the current theory; the effect is - to reduce to the initial statement to a number of goals that directly + \secref{sec:inst-arity}) to be proven (see also + \cite{isabelle-isar-ref}). The \isa{intro{\isacharunderscore}classes} proof method + does back-chaining of class membership statements wrt.\ the hierarchy + of any classes defined in the current theory; the effect is to reduce + to the initial statement to a number of goals that directly correspond to any class axioms encountered on the path upwards through the class hierarchy.% \end{isamarkuptext}% @@ -212,14 +203,14 @@ class membership may be established at the logical level and then transferred to Isabelle's type signature level. - \medskip As a typical example, we show that type $bool$ with - exclusive-or as $\TIMES$ operation, identity as $\isasyminv$, and - $False$ as $1$ forms an Abelian group.% + \medskip As a typical example, we show that type \isa{bool} with + exclusive-or as \isa{{\isasymodot}} operation, identity as \isa{{\isasyminv}}, and + \isa{False} as \isa{{\isasymunit}} forms an Abelian group.% \end{isamarkuptext}% \isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline -\ \ times{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ \ \ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymequiv}\ x\ {\isasymnoteq}\ {\isacharparenleft}y{\isasymColon}bool{\isacharparenright}{\isachardoublequote}\isanewline +\ \ times{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ y\ {\isasymequiv}\ x\ {\isasymnoteq}\ {\isacharparenleft}y{\isasymColon}bool{\isacharparenright}{\isachardoublequote}\isanewline \ \ inverse{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}x{\isasyminv}\ {\isasymequiv}\ x{\isasymColon}bool{\isachardoublequote}\isanewline -\ \ unit{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ \ \ \ {\isachardoublequote}{\isasymunit}\ {\isasymequiv}\ False{\isachardoublequote}% +\ \ unit{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}{\isasymunit}\ {\isasymequiv}\ False{\isachardoublequote}% \begin{isamarkuptext}% \medskip It is important to note that above $\DEFS$ are just overloaded meta-level constant definitions, where type classes are @@ -231,8 +222,8 @@ best applied in the context of type classes. \medskip Since we have chosen above $\DEFS$ of the generic group - operations on type $bool$ appropriately, the class membership $bool - :: agroup$ may be now derived as follows.% + operations on type \isa{bool} appropriately, the class membership + \isa{bool\ {\isasymColon}\ agroup} may be now derived as follows.% \end{isamarkuptext}% \isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ agroup\isanewline \isacommand{proof}\ {\isacharparenleft}intro{\isacharunderscore}classes{\isacharcomma}\isanewline @@ -250,12 +241,13 @@ care of this new instance automatically. \medskip We could now also instantiate our group theory classes to - many other concrete types. For example, $int :: agroup$ (e.g.\ by - defining $\TIMES$ as addition, $\isasyminv$ as negation and $1$ as - zero) or $list :: (term)semigroup$ (e.g.\ if $\TIMES$ is defined as - list append). Thus, the characteristic constants $\TIMES$, - $\isasyminv$, $1$ really become overloaded, i.e.\ have different - meanings on different types.% + many other concrete types. For example, \isa{int\ {\isasymColon}\ agroup} + (e.g.\ by defining \isa{{\isasymodot}} as addition, \isa{{\isasyminv}} as negation + and \isa{{\isasymunit}} as zero) or \isa{list\ {\isasymColon}\ {\isacharparenleft}term{\isacharparenright}\ semigroup} + (e.g.\ if \isa{{\isasymodot}} is defined as list append). Thus, the + characteristic constants \isa{{\isasymodot}}, \isa{{\isasyminv}}, \isa{{\isasymunit}} + really become overloaded, i.e.\ have different meanings on different + types.% \end{isamarkuptext}% % \isamarkupsubsection{Lifting and Functors} @@ -269,24 +261,24 @@ This feature enables us to \emph{lift operations}, say to Cartesian products, direct sums or function spaces. Subsequently we lift - $\TIMES$ component-wise to binary products $\alpha \times \beta$.% + \isa{{\isasymodot}} component-wise to binary products \isa{{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b}.% \end{isamarkuptext}% \isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline -\ \ times{\isacharunderscore}prod{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}p\ {\isasymOtimes}\ q\ {\isasymequiv}\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}{\isachardoublequote}% +\ \ times{\isacharunderscore}prod{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}p\ {\isasymodot}\ q\ {\isasymequiv}\ {\isacharparenleft}fst\ p\ {\isasymodot}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymodot}\ snd\ q{\isacharparenright}{\isachardoublequote}% \begin{isamarkuptext}% -It is very easy to see that associativity of $\TIMES^\alpha$ and - $\TIMES^\beta$ transfers to ${\TIMES}^{\alpha \times \beta}$. Hence - the binary type constructor $\times$ maps semigroups to semigroups. - This may be established formally as follows.% +It is very easy to see that associativity of \isa{{\isasymodot}} on \isa{{\isacharprime}a} + and \isa{{\isasymodot}} on \isa{{\isacharprime}b} transfers to \isa{{\isasymodot}} on \isa{{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}b}. + Hence the binary type constructor \isa{{\isasymodot}} maps semigroups to + semigroups. This may be established formally as follows.% \end{isamarkuptext}% \isacommand{instance}\ {\isacharasterisk}\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}semigroup{\isacharcomma}\ semigroup{\isacharparenright}\ semigroup\isanewline \isacommand{proof}\ {\isacharparenleft}intro{\isacharunderscore}classes{\isacharcomma}\ unfold\ times{\isacharunderscore}prod{\isacharunderscore}def{\isacharparenright}\isanewline \ \ \isacommand{fix}\ p\ q\ r\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}semigroup\ {\isasymtimes}\ {\isacharprime}b{\isasymColon}semigroup{\isachardoublequote}\isanewline \ \ \isacommand{show}\isanewline -\ \ \ \ {\isachardoublequote}{\isacharparenleft}fst\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}\ {\isasymOtimes}\ fst\ r{\isacharcomma}\isanewline -\ \ \ \ \ \ snd\ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymOtimes}\ snd\ q{\isacharparenright}\ {\isasymOtimes}\ snd\ r{\isacharparenright}\ {\isacharequal}\isanewline -\ \ \ \ \ \ \ {\isacharparenleft}fst\ p\ {\isasymOtimes}\ fst\ {\isacharparenleft}fst\ q\ {\isasymOtimes}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymOtimes}\ snd\ r{\isacharparenright}{\isacharcomma}\isanewline -\ \ \ \ \ \ \ \ snd\ p\ {\isasymOtimes}\ snd\ {\isacharparenleft}fst\ q\ {\isasymOtimes}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymOtimes}\ snd\ r{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline +\ \ \ \ {\isachardoublequote}{\isacharparenleft}fst\ {\isacharparenleft}fst\ p\ {\isasymodot}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymodot}\ snd\ q{\isacharparenright}\ {\isasymodot}\ fst\ r{\isacharcomma}\isanewline +\ \ \ \ \ \ snd\ {\isacharparenleft}fst\ p\ {\isasymodot}\ fst\ q{\isacharcomma}\ snd\ p\ {\isasymodot}\ snd\ q{\isacharparenright}\ {\isasymodot}\ snd\ r{\isacharparenright}\ {\isacharequal}\isanewline +\ \ \ \ \ \ \ {\isacharparenleft}fst\ p\ {\isasymodot}\ fst\ {\isacharparenleft}fst\ q\ {\isasymodot}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymodot}\ snd\ r{\isacharparenright}{\isacharcomma}\isanewline +\ \ \ \ \ \ \ \ snd\ p\ {\isasymodot}\ snd\ {\isacharparenleft}fst\ q\ {\isasymodot}\ fst\ r{\isacharcomma}\ snd\ q\ {\isasymodot}\ snd\ r{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline \ \ \ \ \isacommand{by}\ {\isacharparenleft}simp\ add{\isacharcolon}\ semigroup{\isachardot}assoc{\isacharparenright}\isanewline \isacommand{qed}% \begin{isamarkuptext}% diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/generated/NatClass.tex --- a/doc-src/AxClass/generated/NatClass.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/generated/NatClass.tex Tue Oct 03 18:55:23 2000 +0200 @@ -15,33 +15,30 @@ \url{http://isabelle.in.tum.de/library/FOL/ex/NatClass.html}}% \end{isamarkuptext}% \isacommand{consts}\isanewline -\ \ zero\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequote}\isadigit{0}{\isachardoublequote}{\isacharparenright}\isanewline +\ \ zero\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymzero}{\isachardoublequote}{\isacharparenright}\isanewline \ \ Suc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isanewline \ \ rec\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isanewline \isanewline -\isacommand{axclass}\isanewline -\ \ nat\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline -\ \ induct{\isacharcolon}\ \ \ \ \ {\isachardoublequote}P{\isacharparenleft}\isadigit{0}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ P{\isacharparenleft}x{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}Suc{\isacharparenleft}x{\isacharparenright}{\isacharparenright}{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}n{\isacharparenright}{\isachardoublequote}\isanewline +\isacommand{axclass}\ nat\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline +\ \ induct{\isacharcolon}\ {\isachardoublequote}P{\isacharparenleft}{\isasymzero}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ P{\isacharparenleft}x{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}Suc{\isacharparenleft}x{\isacharparenright}{\isacharparenright}{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}n{\isacharparenright}{\isachardoublequote}\isanewline \ \ Suc{\isacharunderscore}inject{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ Suc{\isacharparenleft}n{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}\isanewline -\ \ Suc{\isacharunderscore}neq{\isacharunderscore}\isadigit{0}{\isacharcolon}\ \ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ \isadigit{0}\ {\isasymLongrightarrow}\ R{\isachardoublequote}\isanewline -\ \ rec{\isacharunderscore}\isadigit{0}{\isacharcolon}\ \ \ \ \ \ {\isachardoublequote}rec{\isacharparenleft}\isadigit{0}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ a{\isachardoublequote}\isanewline -\ \ rec{\isacharunderscore}Suc{\isacharcolon}\ \ \ \ {\isachardoublequote}rec{\isacharparenleft}Suc{\isacharparenleft}m{\isacharparenright}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ f{\isacharparenleft}m{\isacharcomma}\ rec{\isacharparenleft}m{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline +\ \ Suc{\isacharunderscore}neq{\isacharunderscore}\isadigit{0}{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ {\isasymzero}\ {\isasymLongrightarrow}\ R{\isachardoublequote}\isanewline +\ \ rec{\isacharunderscore}\isadigit{0}{\isacharcolon}\ {\isachardoublequote}rec{\isacharparenleft}{\isasymzero}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ a{\isachardoublequote}\isanewline +\ \ rec{\isacharunderscore}Suc{\isacharcolon}\ {\isachardoublequote}rec{\isacharparenleft}Suc{\isacharparenleft}m{\isacharparenright}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ f{\isacharparenleft}m{\isacharcomma}\ rec{\isacharparenleft}m{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline \isanewline \isacommand{constdefs}\isanewline \ \ add\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isacharcolon}{\isacharcolon}nat\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharplus}{\isachardoublequote}\ \isadigit{6}\isadigit{0}{\isacharparenright}\isanewline \ \ {\isachardoublequote}m\ {\isacharplus}\ n\ {\isasymequiv}\ rec{\isacharparenleft}m{\isacharcomma}\ n{\isacharcomma}\ {\isasymlambda}x\ y{\isachardot}\ Suc{\isacharparenleft}y{\isacharparenright}{\isacharparenright}{\isachardoublequote}% \begin{isamarkuptext}% -This is an abstract version of the plain $Nat$ theory in +This is an abstract version of the plain \isa{Nat} theory in FOL.\footnote{See \url{http://isabelle.in.tum.de/library/FOL/ex/Nat.html}} Basically, - we have just replaced all occurrences of type $nat$ by $\alpha$ and - used the natural number axioms to define class $nat$. There is only - a minor snag, that the original recursion operator $rec$ had to be - made monomorphic. + we have just replaced all occurrences of type \isa{nat} by \isa{{\isacharprime}a} and used the natural number axioms to define class \isa{nat}. + There is only a minor snag, that the original recursion operator + \isa{rec} had to be made monomorphic. - Thus class $nat$ contains exactly those types $\tau$ that are - isomorphic to ``the'' natural numbers (with signature $0$, $Suc$, - $rec$). + Thus class \isa{nat} contains exactly those types \isa{{\isasymtau}} that + are isomorphic to ``the'' natural numbers (with signature \isa{{\isasymzero}}, \isa{Suc}, \isa{rec}). \medskip What we have done here can be also viewed as \emph{type specification}. Of course, it still remains open if there is some diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/generated/Product.tex --- a/doc-src/AxClass/generated/Product.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/generated/Product.tex Tue Oct 03 18:55:23 2000 +0200 @@ -7,63 +7,66 @@ \begin{isamarkuptext}% \medskip\noindent There is still a feature of Isabelle's type system left that we have not yet discussed. When declaring polymorphic - constants $c :: \sigma$, the type variables occurring in $\sigma$ may - be constrained by type classes (or even general sorts) in an + constants \isa{c\ {\isasymColon}\ {\isasymsigma}}, the type variables occurring in \isa{{\isasymsigma}} + may be constrained by type classes (or even general sorts) in an arbitrary way. Note that by default, in Isabelle/HOL the declaration - $\TIMES :: \alpha \To \alpha \To \alpha$ is actually an abbreviation - for $\TIMES :: (\alpha::term) \To \alpha \To \alpha$. Since class - $term$ is the universal class of HOL, this is not really a constraint - at all. + \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} is actually an abbreviation for + \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}term\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} Since class \isa{term} is the + universal class of HOL, this is not really a constraint at all. - The $product$ class below provides a less degenerate example of + The \isa{product} class below provides a less degenerate example of syntactic type classes.% \end{isamarkuptext}% \isacommand{axclass}\isanewline \ \ product\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline \isacommand{consts}\isanewline -\ \ product\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isacharcolon}{\isacharcolon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymOtimes}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}% +\ \ product\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}% \begin{isamarkuptext}% -Here class $product$ is defined as subclass of $term$ without any - additional axioms. This effects in logical equivalence of $product$ - and $term$, as is reflected by the trivial introduction rule - generated for this definition. +Here class \isa{product} is defined as subclass of \isa{term} + without any additional axioms. This effects in logical equivalence + of \isa{product} and \isa{term}, as is reflected by the trivial + introduction rule generated for this definition. - \medskip So what is the difference of declaring $\TIMES :: (\alpha :: - product) \To \alpha \To \alpha$ vs.\ declaring $\TIMES :: (\alpha :: - term) \To \alpha \To \alpha$ anyway? In this particular case where - $product \equiv term$, it should be obvious that both declarations - are the same from the logic's point of view. It even makes the most - sense to remove sort constraints from constant declarations, as far - as the purely logical meaning is concerned \cite{Wenzel:1997:TPHOL}. + \medskip So what is the difference of declaring + \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} vs.\ declaring + \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}term\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} anyway? In this particular case + where \isa{product\ {\isasymequiv}\ term}, it should be obvious that both + declarations are the same from the logic's point of view. It even + makes the most sense to remove sort constraints from constant + declarations, as far as the purely logical meaning is concerned + \cite{Wenzel:1997:TPHOL}. On the other hand there are syntactic differences, of course. - Constants $\TIMES^\tau$ are rejected by the type-checker, unless the - arity $\tau :: product$ is part of the type signature. In our - example, this arity may be always added when required by means of an - $\isarkeyword{instance}$ with the trivial proof $\BY{intro_classes}$. + Constants \isa{{\isasymodot}} on some type \isa{{\isasymtau}} are rejected by the + type-checker, unless the arity \isa{{\isasymtau}\ {\isasymColon}\ product} is part of the + type signature. In our example, this arity may be always added when + required by means of an $\isarkeyword{instance}$ with the trivial + proof $\BY{intro_classes}$. \medskip Thus, we may observe the following discipline of using syntactic classes. Overloaded polymorphic constants have their type - arguments restricted to an associated (logically trivial) class $c$. - Only immediately before \emph{specifying} these constants on a - certain type $\tau$ do we instantiate $\tau :: c$. + arguments restricted to an associated (logically trivial) class + \isa{c}. Only immediately before \emph{specifying} these constants + on a certain type \isa{{\isasymtau}} do we instantiate \isa{{\isasymtau}\ {\isasymColon}\ c}. - This is done for class $product$ and type $bool$ as follows.% + This is done for class \isa{product} and type \isa{bool} as + follows.% \end{isamarkuptext}% \isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ product\isanewline \ \ \isacommand{by}\ intro{\isacharunderscore}classes\isanewline \isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline -\ \ product{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}x\ {\isasymOtimes}\ y\ {\isasymequiv}\ x\ {\isasymand}\ y{\isachardoublequote}% +\ \ product{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}x\ {\isasymodot}\ y\ {\isasymequiv}\ x\ {\isasymand}\ y{\isachardoublequote}% \begin{isamarkuptext}% -The definition $prod_bool_def$ becomes syntactically well-formed only - after the arity $bool :: product$ is made known to the type checker. +The definition \isa{prod{\isacharunderscore}bool{\isacharunderscore}def} becomes syntactically + well-formed only after the arity \isa{bool\ {\isasymColon}\ product} is made + known to the type checker. \medskip It is very important to see that above $\DEFS$ are not directly connected with $\isarkeyword{instance}$ at all! We were - just following our convention to specify $\TIMES$ on $bool$ after - having instantiated $bool :: product$. Isabelle does not require - these definitions, which is in contrast to programming languages like - Haskell \cite{haskell-report}. + just following our convention to specify \isa{{\isasymodot}} on \isa{bool} + after having instantiated \isa{bool\ {\isasymColon}\ product}. Isabelle does + not require these definitions, which is in contrast to programming + languages like Haskell \cite{haskell-report}. \medskip While Isabelle type classes and those of Haskell are almost the same as far as type-checking and type inference are concerned, @@ -72,9 +75,9 @@ Therefore, its \texttt{instance} has a \texttt{where} part that tells the system what these ``member functions'' should be. - This style of \texttt{instance} won't make much sense in Isabelle's - meta-logic, because there is no internal notion of ``providing - operations'' or even ``names of functions''.% + This style of \texttt{instance} would not make much sense in + Isabelle's meta-logic, because there is no internal notion of + ``providing operations'' or even ``names of functions''.% \end{isamarkuptext}% \isacommand{end}\end{isabellebody}% %%% Local Variables: diff -r 9fa7d3890488 -r ba9297b71897 doc-src/AxClass/generated/Semigroups.tex --- a/doc-src/AxClass/generated/Semigroups.tex Tue Oct 03 18:45:36 2000 +0200 +++ b/doc-src/AxClass/generated/Semigroups.tex Tue Oct 03 18:55:23 2000 +0200 @@ -8,45 +8,40 @@ \medskip\noindent An axiomatic type class is simply a class of types that all meet certain properties, which are also called \emph{class axioms}. Thus, type classes may be also understood as type predicates - --- i.e.\ abstractions over a single type argument $\alpha$. Class + --- i.e.\ abstractions over a single type argument \isa{{\isacharprime}a}. Class axioms typically contain polymorphic constants that depend on this - type $\alpha$. These \emph{characteristic constants} behave like - operations associated with the ``carrier'' type $\alpha$. + type \isa{{\isacharprime}a}. These \emph{characteristic constants} behave like + operations associated with the ``carrier'' type \isa{{\isacharprime}a}. We illustrate these basic concepts by the following formulation of semigroups.% \end{isamarkuptext}% \isacommand{consts}\isanewline -\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymOtimes}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline -\isacommand{axclass}\isanewline -\ \ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline -\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOtimes}\ y{\isacharparenright}\ {\isasymOtimes}\ z\ {\isacharequal}\ x\ {\isasymOtimes}\ {\isacharparenleft}y\ {\isasymOtimes}\ z{\isacharparenright}{\isachardoublequote}% +\ \ times\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline +\isacommand{axclass}\ semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline +\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymodot}\ y{\isacharparenright}\ {\isasymodot}\ z\ {\isacharequal}\ x\ {\isasymodot}\ {\isacharparenleft}y\ {\isasymodot}\ z{\isacharparenright}{\isachardoublequote}% \begin{isamarkuptext}% -\noindent Above we have first declared a polymorphic constant $\TIMES - :: \alpha \To \alpha \To \alpha$ and then defined the class - $semigroup$ of all types $\tau$ such that $\TIMES :: \tau \To \tau - \To \tau$ is indeed an associative operator. The $assoc$ axiom - contains exactly one type variable, which is invisible in the above - presentation, though. Also note that free term variables (like $x$, - $y$, $z$) are allowed for user convenience --- conceptually all of - these are bound by outermost universal quantifiers. +\noindent Above we have first declared a polymorphic constant \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} and then defined the class \isa{semigroup} of + all types \isa{{\isasymtau}} such that \isa{{\isasymodot}\ {\isasymColon}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}\ {\isasymRightarrow}\ {\isasymtau}} is indeed an + associative operator. The \isa{assoc} axiom contains exactly one + type variable, which is invisible in the above presentation, though. + Also note that free term variables (like \isa{x}, \isa{y}, \isa{z}) are allowed for user convenience --- conceptually all of these + are bound by outermost universal quantifiers. \medskip In general, type classes may be used to describe - \emph{structures} with exactly one carrier $\alpha$ and a fixed + \emph{structures} with exactly one carrier \isa{{\isacharprime}a} and a fixed \emph{signature}. Different signatures require different classes. - Below, class $plus_semigroup$ represents semigroups of the form - $(\tau, \PLUS^\tau)$, while the original $semigroup$ would correspond - to semigroups $(\tau, \TIMES^\tau)$.% + Below, class \isa{plus{\isacharunderscore}semigroup} represents semigroups of the form + \isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymoplus}{\isacharparenright}}, while the original \isa{semigroup} would + correspond to semigroups \isa{{\isacharparenleft}{\isasymtau}{\isacharcomma}\ {\isasymodot}{\isacharparenright}}.% \end{isamarkuptext}% \isacommand{consts}\isanewline -\ \ plus\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymOplus}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline -\isacommand{axclass}\isanewline -\ \ plus{\isacharunderscore}semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline -\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymOplus}\ y{\isacharparenright}\ {\isasymOplus}\ z\ {\isacharequal}\ x\ {\isasymOplus}\ {\isacharparenleft}y\ {\isasymOplus}\ z{\isacharparenright}{\isachardoublequote}% +\ \ plus\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymoplus}{\isachardoublequote}\ \isadigit{7}\isadigit{0}{\isacharparenright}\isanewline +\isacommand{axclass}\ plus{\isacharunderscore}semigroup\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline +\ \ assoc{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x\ {\isasymoplus}\ y{\isacharparenright}\ {\isasymoplus}\ z\ {\isacharequal}\ x\ {\isasymoplus}\ {\isacharparenleft}y\ {\isasymoplus}\ z{\isacharparenright}{\isachardoublequote}% \begin{isamarkuptext}% -\noindent Even if classes $plus_semigroup$ and $semigroup$ both - represent semigroups in a sense, they are certainly not quite the - same.% +\noindent Even if classes \isa{plus{\isacharunderscore}semigroup} and \isa{semigroup} both represent semigroups in a sense, they are certainly + not quite the same.% \end{isamarkuptext}% \isacommand{end}\end{isabellebody}% %%% Local Variables: