doc-src/TutorialI/Misc/Translations.thy
author paulson
Thu, 15 Mar 2001 16:56:35 +0100
changeset 11211 febb93798bb8
parent 11208 76bc8ea0c6f2
child 11310 51e70b7bc315
permissions -rw-r--r--
translations: a tweak
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     1
(*<*)
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     2
theory Translations = Main:
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     3
(*>*)
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     4
subsection{*Syntax Translations*}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     5
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     6
text{*\label{sec:def-translations}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     7
Isabelle offers an additional definition-like facility,
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
     8
\textbf{syntax translations}\indexbold{syntax translation}.
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
     9
They resemble macros: upon parsing, the defined concept is immediately
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    10
replaced by its definition, and this is reversed upon printing. For example,
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    11
the symbol @{text"\<noteq>"} is defined via a syntax translation:
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    12
*}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    13
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    14
translations "x \<noteq> y" \<rightleftharpoons> "\<not>(x = y)"
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    15
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    16
text{*\indexbold{*translations}\indexbold{$IsaEqTrans@\isasymrightleftharpoons}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    17
\noindent
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    18
Internally, @{text"\<noteq>"} never appears.
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    19
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    20
In addition to @{text"\<rightleftharpoons>"} there are
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    21
@{text"\<rightharpoonup>"}\indexbold{$IsaEqTrans1@\isasymrightharpoonup}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    22
and @{text"\<leftharpoondown>"}\indexbold{$IsaEqTrans2@\isasymleftharpoondown}
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    23
for uni-directional translations, which only affect
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    24
parsing or printing.  We do not want to cover the details of
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    25
translations at this point.  We haved mentioned the concept merely because it
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    26
crops up occasionally: a number of HOL's built-in constructs are defined
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    27
via translations.  Translations are preferable to definitions when the new 
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    28
concept is a trivial variation on an existing one.  For example, we
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    29
don't need to derive new theorems about @{text"\<noteq>"}, since existing theorems
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    30
about @{text"="} still apply.
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    31
*}
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    32
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    33
(*<*)
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    34
end
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    35
(*>*)