doc-src/TutorialI/Misc/Translations.thy
author paulson
Fri, 03 Aug 2001 18:04:55 +0200
changeset 11458 09a6c44a48ea
parent 11456 7eb63f63e6c6
permissions -rw-r--r--
numerous stylistic changes and indexing
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}
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
     7
\index{syntax translations|(}%
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
     8
\index{translations@\isacommand {translations} (command)|(}
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
     9
Isabelle offers an additional definitional facility,
11428
332347b9b942 tidying the index
paulson
parents: 11310
diff changeset
    10
\textbf{syntax translations}.
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    11
They resemble macros: upon parsing, the defined concept is immediately
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    12
replaced by its definition.  This effect is reversed upon printing.  For example,
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    13
the symbol @{text"\<noteq>"} is defined via a syntax translation:
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    14
*}
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    15
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    16
translations "x \<noteq> y" \<rightleftharpoons> "\<not>(x = y)"
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    17
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    18
text{*\index{$IsaEqTrans@\isasymrightleftharpoons}
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    19
\noindent
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    20
Internally, @{text"\<noteq>"} never appears.
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    21
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    22
In addition to @{text"\<rightleftharpoons>"} there are
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    23
@{text"\<rightharpoonup>"}\index{$IsaEqTrans1@\isasymrightharpoonup}
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    24
and @{text"\<leftharpoondown>"}\index{$IsaEqTrans2@\isasymleftharpoondown}
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    25
for uni-directional translations, which only affect
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    26
parsing or printing.  This tutorial will not cover the details of
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    27
translations.  We have mentioned the concept merely because it
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    28
crops up occasionally; a number of HOL's built-in constructs are defined
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    29
via translations.  Translations are preferable to definitions when the new 
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    30
concept is a trivial variation on an existing one.  For example, we
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    31
don't need to derive new theorems about @{text"\<noteq>"}, since existing theorems
11428
332347b9b942 tidying the index
paulson
parents: 11310
diff changeset
    32
about @{text"="} still apply.%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    33
\index{syntax translations|)}%
7eb63f63e6c6 revisions and indexing
paulson
parents: 11428
diff changeset
    34
\index{translations@\isacommand {translations} (command)|)}
11211
febb93798bb8 translations: a tweak
paulson
parents: 11208
diff changeset
    35
*}
11208
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    36
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    37
(*<*)
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    38
end
76bc8ea0c6f2 *** empty log message ***
nipkow
parents:
diff changeset
    39
(*>*)