doc-src/TutorialI/Misc/document/prime_def.tex
author Thomas Sewell <tsewell@nicta.com.au>
Fri, 25 Sep 2009 19:04:18 +1000
changeset 32754 4e0256f7d219
parent 17187 45bee2f6e61f
child 40406 313a24b66a8d
permissions -rw-r--r--
Avoid record-inner constants in polymorphic definitions in Bali The Bali package needs to insert a record extension into a type class and define an associated polymorphic constant. There is no elegant way to do this. The existing approach was to insert every record extension into the type class, defining the polymorphic constant at each layer using inner operations created by the record package. Some of those operations have been removed. They can be replaced by use of record_name.extend if necessary, but we can also sidestep this altogether. The simpler approach here is to use defs(overloaded) once to provide a single definition for the composition of all the type constructors, which seems to be permitted. This gets us exactly the fact we need, with the cost that some types that were admitted to the type class have no definition for the constant at all.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     1
%
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     2
\begin{isabellebody}%
10267
325ead6d9457 updated;
wenzelm
parents: 10187
diff changeset
     3
\def\isabellecontext{prime{\isacharunderscore}def}%
17056
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     4
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     5
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     6
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     7
\endisadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     8
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
     9
\isatagtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    10
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    11
\endisatagtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    12
{\isafoldtheory}%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    13
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    14
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    15
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    16
\endisadelimtheory
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    17
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    18
\begin{isamarkuptext}%
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    19
\begin{warn}
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    20
A common mistake when writing definitions is to introduce extra free
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 10267
diff changeset
    21
variables on the right-hand side.  Consider the following, flawed definition
7eb63f63e6c6 revisions and indexing
paulson
parents: 10267
diff changeset
    22
(where \isa{dvd} means ``divides''):
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    23
\begin{isabelle}%
10187
0376cccd9118 *** empty log message ***
nipkow
parents: 9924
diff changeset
    24
\ \ \ \ \ {\isachardoublequote}prime\ p\ {\isasymequiv}\ {\isadigit{1}}\ {\isacharless}\ p\ {\isasymand}\ {\isacharparenleft}m\ dvd\ p\ {\isasymlongrightarrow}\ m\ {\isacharequal}\ {\isadigit{1}}\ {\isasymor}\ m\ {\isacharequal}\ p{\isacharparenright}{\isachardoublequote}%
9924
3370f6aa3200 updated;
wenzelm
parents: 9844
diff changeset
    25
\end{isabelle}
11457
279da0358aa9 additional revisions to chapters 1, 2
paulson
parents: 11456
diff changeset
    26
\par\noindent\hangindent=0pt
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    27
Isabelle rejects this ``definition'' because of the extra \isa{m} on the
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 10267
diff changeset
    28
right-hand side, which would introduce an inconsistency (why?). 
7eb63f63e6c6 revisions and indexing
paulson
parents: 10267
diff changeset
    29
The correct version is
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    30
\begin{isabelle}%
10187
0376cccd9118 *** empty log message ***
nipkow
parents: 9924
diff changeset
    31
\ \ \ \ \ {\isachardoublequote}prime\ p\ {\isasymequiv}\ {\isadigit{1}}\ {\isacharless}\ p\ {\isasymand}\ {\isacharparenleft}{\isasymforall}m{\isachardot}\ m\ dvd\ p\ {\isasymlongrightarrow}\ m\ {\isacharequal}\ {\isadigit{1}}\ {\isasymor}\ m\ {\isacharequal}\ p{\isacharparenright}{\isachardoublequote}%
9924
3370f6aa3200 updated;
wenzelm
parents: 9844
diff changeset
    32
\end{isabelle}
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    33
\end{warn}%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    34
\end{isamarkuptext}%
17175
1eced27ee0e1 updated;
wenzelm
parents: 17056
diff changeset
    35
\isamarkuptrue%
17056
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    36
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    37
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    38
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    39
\endisadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    40
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    41
\isatagtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    42
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    43
\endisatagtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    44
{\isafoldtheory}%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    45
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    46
\isadelimtheory
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    47
%
05fc32a23b8b updated;
wenzelm
parents: 13778
diff changeset
    48
\endisadelimtheory
9844
8016321c7de1 *** empty log message ***
nipkow
parents: 9722
diff changeset
    49
\end{isabellebody}%
9145
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    50
%%% Local Variables:
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    51
%%% mode: latex
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    52
%%% TeX-master: "root"
9f7b8de5bfaf updated;
wenzelm
parents: 8749
diff changeset
    53
%%% End: