author | nipkow |
Wed, 25 Oct 2000 18:24:33 +0200 | |
changeset 10328 | bf33cbd76c05 |
parent 10305 | adff80268127 |
child 10329 | a9898d89a634 |
permissions | -rw-r--r-- |
nipkow@10305 | 1 |
\chapter{More about Types} |
nipkow@10305 | 2 |
|
nipkow@10305 | 3 |
So far we have learned about a few basic types (for example \isa{bool} and |
nipkow@10305 | 4 |
\isa{nat}), type abbreviations (\isacommand{types}) and recursive datatpes |
nipkow@10305 | 5 |
(\isacommand{datatype}). This chapter will introduce the following more |
nipkow@10305 | 6 |
advanced material: |
nipkow@10305 | 7 |
\begin{itemize} |
nipkow@10305 | 8 |
\item More about basic types: numbers ({\S}\ref{sec:numbers}), pairs |
nipkow@10305 | 9 |
({\S}\ref{sec:products}) and records ({\S}\ref{sec:records}), and how to reason |
nipkow@10305 | 10 |
about them. |
nipkow@10305 | 11 |
\item Introducing your own types: how to introduce your own new types that |
nipkow@10305 | 12 |
cannot be constructed with any of the basic methods ({\S}\ref{sec:typedef}). |
nipkow@10305 | 13 |
\item Type classes: how to specify and reason about axiomatic collections of |
nipkow@10305 | 14 |
types ({\S}\ref{sec:axclass}). |
nipkow@10305 | 15 |
\end{itemize} |
nipkow@10305 | 16 |
|
nipkow@10305 | 17 |
\section{Axiomatic type classes} |
nipkow@10305 | 18 |
\label{sec:axclass} |
nipkow@10305 | 19 |
\index{axiomatic type class|(} |
nipkow@10305 | 20 |
\index{*axclass|(} |
nipkow@10305 | 21 |
|
nipkow@10305 | 22 |
|
nipkow@10305 | 23 |
The programming language Haskell has popularized the notion of type classes. |
nipkow@10305 | 24 |
Isabelle offers the related concept of an \textbf{axiomatic type class}. |
nipkow@10305 | 25 |
Roughly speaking, an axiomatic type class is a type class with axioms, i.e.\ |
nipkow@10305 | 26 |
an axiomatic specification of a class of types. Thus we can talk about a type |
nipkow@10305 | 27 |
$t$ being in a class $c$, which is written $\tau :: c$. This is the case of |
nipkow@10305 | 28 |
$\tau$ satisfies the axioms of $c$. Furthermore, type classes can be |
nipkow@10305 | 29 |
organized in a hierarchy. Thus there is the notion of a class $d$ being a |
nipkow@10305 | 30 |
\textbf{subclass} of a class $c$, written $d < c$. This is the case if all |
nipkow@10305 | 31 |
axioms of $c$ are also provable in $d$. Let us now introduce these concepts |
nipkow@10305 | 32 |
by means of a running example, ordering relations. |
nipkow@10305 | 33 |
|
nipkow@10305 | 34 |
\subsection{Overloading} |
nipkow@10305 | 35 |
\label{sec:overloading} |
nipkow@10305 | 36 |
\index{overloading|(} |
nipkow@10305 | 37 |
|
nipkow@10305 | 38 |
\input{Types/document/Overloading0} |
nipkow@10305 | 39 |
\input{Types/document/Overloading1} |
nipkow@10305 | 40 |
\input{Types/document/Overloading} |
nipkow@10305 | 41 |
\input{Types/document/Overloading2} |
nipkow@10305 | 42 |
|
nipkow@10305 | 43 |
\index{overloading|)} |
nipkow@10305 | 44 |
|
nipkow@10328 | 45 |
\input{Types/document/Axioms} |
nipkow@10305 | 46 |
|
nipkow@10305 | 47 |
\index{axiomatic type class|)} |
nipkow@10305 | 48 |
\index{*axclass|)} |