11208
|
1 |
(*<*)
|
|
2 |
theory Translations = Main:
|
|
3 |
(*>*)
|
|
4 |
subsection{*Syntax Translations*}
|
|
5 |
|
|
6 |
text{*\label{sec:def-translations}
|
11456
|
7 |
\index{syntax translations|(}%
|
|
8 |
\index{translations@\isacommand {translations} (command)|(}
|
|
9 |
Isabelle offers an additional definitional facility,
|
11428
|
10 |
\textbf{syntax translations}.
|
11211
|
11 |
They resemble macros: upon parsing, the defined concept is immediately
|
11456
|
12 |
replaced by its definition. This effect is reversed upon printing. For example,
|
11208
|
13 |
the symbol @{text"\<noteq>"} is defined via a syntax translation:
|
|
14 |
*}
|
|
15 |
|
|
16 |
translations "x \<noteq> y" \<rightleftharpoons> "\<not>(x = y)"
|
|
17 |
|
11456
|
18 |
text{*\index{$IsaEqTrans@\isasymrightleftharpoons}
|
11208
|
19 |
\noindent
|
|
20 |
Internally, @{text"\<noteq>"} never appears.
|
|
21 |
|
|
22 |
In addition to @{text"\<rightleftharpoons>"} there are
|
11456
|
23 |
@{text"\<rightharpoonup>"}\index{$IsaEqTrans1@\isasymrightharpoonup}
|
|
24 |
and @{text"\<leftharpoondown>"}\index{$IsaEqTrans2@\isasymleftharpoondown}
|
11211
|
25 |
for uni-directional translations, which only affect
|
11456
|
26 |
parsing or printing. This tutorial will not cover the details of
|
|
27 |
translations. We have mentioned the concept merely because it
|
|
28 |
crops up occasionally; a number of HOL's built-in constructs are defined
|
11211
|
29 |
via translations. Translations are preferable to definitions when the new
|
|
30 |
concept is a trivial variation on an existing one. For example, we
|
|
31 |
don't need to derive new theorems about @{text"\<noteq>"}, since existing theorems
|
11428
|
32 |
about @{text"="} still apply.%
|
11456
|
33 |
\index{syntax translations|)}%
|
|
34 |
\index{translations@\isacommand {translations} (command)|)}
|
11211
|
35 |
*}
|
11208
|
36 |
|
|
37 |
(*<*)
|
|
38 |
end
|
|
39 |
(*>*)
|