doc-src/AxClass/Group/Product.thy
changeset 9146 dde1affac73e
parent 8907 813fabceec00
child 9306 d0ef4a41ae63
equal deleted inserted replaced
9145:9f7b8de5bfaf 9146:dde1affac73e
     1 
     1 
     2 header {* Syntactic classes *};
     2 header {* Syntactic classes *}
     3 
     3 
     4 theory Product = Main:;
     4 theory Product = Main:
     5 
     5 
     6 text {*
     6 text {*
     7  \medskip\noindent There is still a feature of Isabelle's type system
     7  \medskip\noindent There is still a feature of Isabelle's type system
     8  left that we have not yet discussed.  When declaring polymorphic
     8  left that we have not yet discussed.  When declaring polymorphic
     9  constants $c :: \sigma$, the type variables occurring in $\sigma$ may
     9  constants $c :: \sigma$, the type variables occurring in $\sigma$ may
    14  $term$ is the universal class of HOL, this is not really a constraint
    14  $term$ is the universal class of HOL, this is not really a constraint
    15  at all.
    15  at all.
    16 
    16 
    17  The $product$ class below provides a less degenerate example of
    17  The $product$ class below provides a less degenerate example of
    18  syntactic type classes.
    18  syntactic type classes.
    19 *};
    19 *}
    20 
    20 
    21 axclass
    21 axclass
    22   product < "term";
    22   product < "term"
    23 consts
    23 consts
    24   product :: "'a::product \\<Rightarrow> 'a \\<Rightarrow> 'a"    (infixl "\\<Otimes>" 70);
    24   product :: "'a::product \\<Rightarrow> 'a \\<Rightarrow> 'a"    (infixl "\\<Otimes>" 70)
    25 
    25 
    26 text {*
    26 text {*
    27  Here class $product$ is defined as subclass of $term$ without any
    27  Here class $product$ is defined as subclass of $term$ without any
    28  additional axioms.  This effects in logical equivalence of $product$
    28  additional axioms.  This effects in logical equivalence of $product$
    29  and $term$, as is reflected by the trivial introduction rule
    29  and $term$, as is reflected by the trivial introduction rule
    48  arguments restricted to an associated (logically trivial) class $c$.
    48  arguments restricted to an associated (logically trivial) class $c$.
    49  Only immediately before \emph{specifying} these constants on a
    49  Only immediately before \emph{specifying} these constants on a
    50  certain type $\tau$ do we instantiate $\tau :: c$.
    50  certain type $\tau$ do we instantiate $\tau :: c$.
    51 
    51 
    52  This is done for class $product$ and type $bool$ as follows.
    52  This is done for class $product$ and type $bool$ as follows.
    53 *};
    53 *}
    54 
    54 
    55 instance bool :: product;
    55 instance bool :: product
    56   by intro_classes;
    56   by intro_classes
    57 defs
    57 defs
    58   product_bool_def: "x \\<Otimes> y \\<equiv> x \\<and> y";
    58   product_bool_def: "x \\<Otimes> y \\<equiv> x \\<and> y"
    59 
    59 
    60 text {*
    60 text {*
    61  The definition $prod_bool_def$ becomes syntactically well-formed only
    61  The definition $prod_bool_def$ becomes syntactically well-formed only
    62  after the arity $bool :: product$ is made known to the type checker.
    62  after the arity $bool :: product$ is made known to the type checker.
    63 
    63 
    76  the system what these ``member functions'' should be.
    76  the system what these ``member functions'' should be.
    77 
    77 
    78  This style of \texttt{instance} won't make much sense in Isabelle's
    78  This style of \texttt{instance} won't make much sense in Isabelle's
    79  meta-logic, because there is no internal notion of ``providing
    79  meta-logic, because there is no internal notion of ``providing
    80  operations'' or even ``names of functions''.
    80  operations'' or even ``names of functions''.
    81 *};
    81 *}
    82 
    82 
    83 end;
    83 end