author | nipkow |
Thu, 25 Jan 2001 15:31:31 +0100 | |
changeset 10978 | 5eebea8f359f |
parent 10971 | 6852682eaf16 |
child 11196 | bb4ede27fcb7 |
permissions | -rw-r--r-- |
nipkow@10305 | 1 |
(*<*)theory Overloading2 = Overloading1:(*>*) |
nipkow@10305 | 2 |
|
nipkow@10305 | 3 |
text{* |
nipkow@10305 | 4 |
Of course this is not the only possible definition of the two relations. |
nipkow@10328 | 5 |
Componentwise comparison of lists of equal length also makes sense. This time |
nipkow@10328 | 6 |
the elements of the list must also be of class @{text ordrel} to permit their |
nipkow@10328 | 7 |
comparison: |
nipkow@10305 | 8 |
*} |
nipkow@10305 | 9 |
|
nipkow@10305 | 10 |
instance list :: (ordrel)ordrel |
nipkow@10305 | 11 |
by intro_classes |
nipkow@10305 | 12 |
|
nipkow@10305 | 13 |
defs (overloaded) |
nipkow@10305 | 14 |
le_list_def: "xs <<= (ys::'a::ordrel list) \<equiv> |
nipkow@10305 | 15 |
size xs = size ys \<and> (\<forall>i<size xs. xs!i <<= ys!i)" |
nipkow@10305 | 16 |
|
nipkow@10328 | 17 |
text{*\noindent |
nipkow@10328 | 18 |
The infix function @{text"!"} yields the nth element of a list. |
nipkow@10396 | 19 |
*} |
nipkow@10396 | 20 |
|
paulson@10885 | 21 |
subsubsection{*Predefined Overloading*} |
nipkow@10396 | 22 |
|
nipkow@10396 | 23 |
text{* |
nipkow@10396 | 24 |
HOL comes with a number of overloaded constants and corresponding classes. |
nipkow@10978 | 25 |
The most important ones are listed in Table~\ref{tab:overloading} in the appendix. They are |
nipkow@10971 | 26 |
defined on all numeric types and sometimes on other types as well, for example |
nipkow@10396 | 27 |
@{text"-"}, @{text"\<le>"} and @{text"<"} on sets. |
nipkow@10396 | 28 |
|
nipkow@10696 | 29 |
In addition there is a special input syntax for bounded quantifiers: |
nipkow@10696 | 30 |
\begin{center} |
nipkow@10696 | 31 |
\begin{tabular}{lcl} |
nipkow@10696 | 32 |
@{text"\<forall>x \<le> y. P x"} & @{text"\<equiv>"} & @{prop"\<forall>x. x \<le> y \<longrightarrow> P x"} \\ |
nipkow@10696 | 33 |
@{text"\<exists>x \<le> y. P x"} & @{text"\<equiv>"} & @{prop"\<exists>x. x \<le> y \<and> P x"} |
nipkow@10696 | 34 |
\end{tabular} |
nipkow@10696 | 35 |
\end{center} |
nipkow@10696 | 36 |
And analogously for @{text"<"} instead of @{text"\<le>"}. |
nipkow@10696 | 37 |
The form on the left is translated into the one on the right upon input but it is not |
nipkow@10696 | 38 |
translated back upon output. |
nipkow@10328 | 39 |
*}(*<*)end(*>*) |