doc-src/Exercises/2001/a3/generated/Trie2.tex
author obua
Sun, 09 May 2004 23:04:36 +0200
changeset 14722 8e739a6eaf11
parent 13841 ed4e97874454
permissions -rw-r--r--
replaced apply-style proof for instance Multiset :: plus_ac0 by recommended Isar proof style
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13841
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     1
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     2
\begin{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     3
\def\isabellecontext{Trie{\isadigit{2}}}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     4
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     5
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     6
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     7
Die above definition of \isa{update} has the disadvantage
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     8
that it often creates junk: each association list it passes through is
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
     9
extended at the left end with a new (letter,value) pair without
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    10
removing any old association of that letter which may already be
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    11
present.  Logically, such cleaning up is unnecessary because \isa{assoc} always searches the list from the left. However, it constitutes
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    12
a space leak: the old associations cannot be garbage collected because
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    13
physically they are still reachable. This problem can be solved by
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    14
means of a function%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    15
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    16
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    17
\isacommand{consts}\ overwrite\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isacharasterisk}\ {\isacharprime}b{\isacharparenright}\ list\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isacharasterisk}\ {\isacharprime}b{\isacharparenright}\ list{\isachardoublequote}\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    18
%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    19
\begin{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    20
that does not just add new pairs at the front but replaces old
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    21
associations by new pairs if possible.
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    22
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    23
Define \isa{overwrite}, modify \isa{modify} to employ \isa{overwrite}, and show the same relationship between \isa{modify} and
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    24
\isa{lookup} as before.%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    25
\end{isamarkuptext}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    26
\isamarkuptrue%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    27
\isamarkupfalse%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    28
\end{isabellebody}%
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    29
%%% Local Variables:
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    30
%%% mode: latex
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    31
%%% TeX-master: "root"
ed4e97874454 keep a copy of generated files in repository
kleing
parents:
diff changeset
    32
%%% End: